Hi Everyone,
I have PDF file exist in AL11 and want to upload same file in DMS system using BAPI: BAPI_DOCUMENT_CHANGE2 . Created DMS document number first using BAPI: BAPI_DOCUMENT_CREATE , then calling change BAPI to attach document from application server by giving application server path and file name. Please guys, it's bit urgent, have been trying from past 2 days, but couldn't achieve this.
Could you pls suggest me, is it possible to upload file from Al11 into DMS ? It seems, it's possible, but couldn't find a way.
But i'm unable to attach document in DMS. Please look into below mentioned code and suggest me, am i missing anything.
*******--- Code ----------------------
***---- Create DMS Document
CLEAR ls_documentdata.
ls_documentdata-documenttype = dms_key-dokar. "'ZRM'.
ls_documentdata-description = lv_dartxt. "'Testing DMS-Ecratum'.
ls_documentdata-username = sy-uname.
ls_documentdata-statusextern = 'RE'.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE'
EXPORTING
documentdata = ls_documentdata
IMPORTING
doctype = dms_key-dokar
docnumber = dms_key-doknr
docpart = dms_key-doktl
docversion = dms_key-dokvr
return = ls_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true
IMPORTING
return = ls_return.
*****---- Attach document by getting file from application server
TYPES: BEGIN OF ts_document_hdr,
type TYPE dokar,
number TYPE doknr,
part TYPE doktl_d,
version TYPE dokvr,
END OF ts_document_hdr.
DATA: ls_document_hdr TYPE ts_document_hdr,
" ls_documentdata TYPE bapi_doc_draw2,
ls_documentdatax TYPE bapi_doc_drawx2.
* Document Header
ls_document_hdr-type = dms_key-dokar.
ls_document_hdr-number = dms_key-doknr.
ls_document_hdr-part = dms_key-doktl.
ls_document_hdr-version = dms_key-dokvr.
* Document Data
ls_documentdata1-wsapplication2 = 'PDF'."p_filty.
ls_documentdatax-wsapplication2 = abap_true.
ls_documentdata1-docfile2 = '/usr/sap/trans/FlowChart.pdf'. "p_path && p_filnm.
ls_documentdatax-docfile2 = abap_true.
* Document Files
ls_files-documenttype = ls_document_hdr-type.
ls_files-documentnumber = ls_document_hdr-number.
ls_files-documentpart = ls_document_hdr-part.
ls_files-documentversion = ls_document_hdr-version.
ls_files-docpath = '/usr/sap/trans/'. "p_path.
ls_files-docfile = 'FlowChart.pdf'. "p_filnm.
ls_files-description = 'Filename' && '/usr/sap/trans/' && 'FlowChart.pdf'.
ls_files-wsapplication = 'PDF'. "p_filty.
* ls_files-sourcedatacarrier = 'DV-1' . "p_datcar.
ls_files-originaltype = '1'.
ls_files-storagecategory = 'DMS_C1_ST'. " Here tried with "SAP-SYSTEM"
APPEND ls_files TO lt_files.
* Attach file to the Document.
CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
EXPORTING
documenttype = ls_document_hdr-type
documentnumber = ls_document_hdr-number
documentpart = ls_document_hdr-part
documentversion = ls_document_hdr-version
documentdata = ls_documentdata1
documentdatax = ls_documentdatax
IMPORTING
return = ls_return
TABLES
documentfiles = lt_files.
IF ls_return-type NE 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true.
MESSAGE s000(zz) WITH 'Success'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' .
MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number
WITH ls_return-message_v1 ls_return-message_v2 ls_return-message_v3 ls_return-message_v4.
ENDIF.
After running above code, am getting below error.

As requested, pls it's very urgent.please do needful
Regards
Madan Chandragiri