Hi all gurus,
I'm trying to replicate the creation of an inforecord as performed by means of transaction CV01N.
The complete requirement is: when an user creates an inforecord that belongs to a certain category (let's say ZXY), then I have to create another inforecord, containing the same content (uploaded document) in category ZKX, for a different repository (archivelink).
I was thinking about putting this code on an user-exit, for instance on SAVE on the original inforecord.
Just to understand how this could work, I tried to write a local report in order to check feasibility; please forgive all the hardcoded strings in here, I'm just trying to understand the call sequence:
*STEP 1- creation of the inforecord*
ls_file-documenttype = 'Z16'.
ls_file-documentversion = '00'.
ls_file-documentpart = '000'.
ls_file-statusextern = 'ER'.
ls_file-DOCFILE1 = 'C:\Users\matt\desktop\test_pdf.pdf'.
ls_file-DATACARRIER1 = 'ZG'.
ls_file-SAVEDOCFILE1 = 'C:\Users\matt\desktop\test_pdf.pdf'.
ls_file-SAVEDATACARRIER1 = 'ZG'.
ls_file-WSAPPLICATION1 = 'PDF'.
lt_drat-language = 'EN'.
lt_drat-description = 'Test Matt from Report'.
APPEND lt_drat.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = ls_file
* HOSTNAME =
* DOCBOMCHANGENUMBER =
* DOCBOMVALIDFROM =
* DOCBOMREVISIONLEVEL =
CAD_MODE = ' '
PF_FTP_DEST = ' '
PF_HTTP_DEST = ' '
DEFAULTCLASS = 'X'
IMPORTING
DOCUMENTTYPE = lf_doctype
DOCUMENTNUMBER = lf_docnumber
DOCUMENTPART = lf_docpart
DOCUMENTVERSION = lf_docversion
RETURN = ls_return
TABLES
* CHARACTERISTICVALUES =
* CLASSALLOCATIONS =
DOCUMENTDESCRIPTIONS = lt_drat
* OBJECTLINKS = lt_drad
* DOCUMENTSTRUCTURE = lt_dstru
* DOCUMENTFILES = lt_files.
The above code should create my inforecord.
*STEP 2 - Upload of my file and creation of the entry in TOA01 table (as per customizing)
ls_storage = 'ZG'.
ls_doc_file-filename = 'C:\Users\Matt\Desktop\test_pdf.pdf'.
ls_doc_file-dappl = 'PDF'.
ls_frontend-frontend_type = 'PC'.
ls_frontend-hostname = 'DEFAULT'.
ls_frontend-winsys = 'WN32'.
ls_draw-DOKAR = 'Z16'.
ls_draw-DOKNR = '*'.
ls_draw-dwnam = 'ATEC032'.
ls_draw-dokst = 'ER'.
ls_draw-filep = 'C:\Users\Matt\Desktop\test_pdf.pdf'.
ls_draw-dappl = 'PDF'.
ls_draw-adatum = '20150625'.
CALL FUNCTION 'CV120_DOC_CHECKIN_FROM_CLIENT'
EXPORTING
* PS_CIN_DEF =
pf_storage = ls_storage
PS_DOC_FILE = ls_doc_file
PS_FRONTEND = ls_frontend
TABLES
PT_DRAZ = lt_draz
PT_COMPONENTS = lt_components
PTX_DRAO = lt_drao
PTX_DRAOZ = lt_draoz
PTX_ARCHIVE_CONN = lt_archive_conn
CHANGING
PS_DRAW = ls_draw
* PS_AUDITS =
* PS_PHIO =
EXCEPTIONS
ERROR = 1
OTHERS = 2
.
READ TABLE lt_archive_conn INTO ls_archive_conn INDEX 1.
DATA: objid LIKE SAPB-SAPOBJID.
CONCATENATE lf_doctype lf_docnumber lf_docpart lf_docversion INTO objid.
CONCATENATE objid 'PDF1' INTO objid SEPARATED BY SPACE.
CALL FUNCTION 'ARCHIV_CONNECTION_INSERT'
EXPORTING
archiv_id = 'ZG'
arc_doc_id = ls_archive_conn-arc_doc_id
ar_object = 'DRW'
mandant = sy-mandt
object_id = objid
sap_object = 'DRAW'
doc_type = 'BIN'
EXCEPTIONS
error_connectiontable = 1
OTHERS = 2.
*STEP 3 - update the inforecord with respect to the uploaded resource*
ls_docdata-docfile1 = objid.
ls_docdata-datacarrier1 = 'ZG'.
ls_docdata-wsapplication1 = 'PDF'.
ls_docdatax-docfile1 = 'X'.
ls_docdatax-datacarrier1 = 'X'.
ls_docdatax-docfile1 = 'X'.
CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
EXPORTING
documenttype = lf_doctype
documentnumber = lf_docnumber
documentpart = lf_docpart
documentversion = lf_docversion
documentdata = ls_docdata
documentdatax = ls_docdatax
* HOSTNAME =
* DOCBOMCHANGENUMBER =
* DOCBOMVALIDFROM =
* DOCBOMREVISIONLEVEL =
* SENDCOMPLETEBOM = ' '
* PF_FTP_DEST = ' '
* PF_HTTP_DEST = ' '
* CAD_MODE = ' '
IMPORTING
RETURN = lv_ret
* TABLES
* CHARACTERISTICVALUES =
* CLASSALLOCATIONS =
* DOCUMENTDESCRIPTIONS =
* OBJECTLINKS =
* DOCUMENTSTRUCTURE =
* DOCUMENTFILES =
* LONGTEXTS =
* COMPONENTS =
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
After this sequence:
- the inforecord has been created and it's accessible by CV03N transaction;
- the file has been uploaded as a new entry in TOA01 is available.
However, if I try to access to the original file double clicking on it, a standard popup appears:
" SAP ArchiveLink: Object type not assigned to storage syst. (Customizing) "
Obviously, the customizing steps have been performed therefore probably there's something missing in the inforecord's update.
Thanks for the patience with this huge post, any suggestion's welcome!
M.