Skip to Content
0
Former Member
Jul 23, 2009 at 10:32 AM

Document not visible in Original document list

27 Views

Hi

I want to add document to SAP DMS, found BAPI_DOCUMENT_CREATE2 on net.

I found a sample program on a thread but when I am executing this I get the newly created document in CV03N but I dont find the document in Original document list.

FUNCTION Z_DMS_CREATE_DOCUMENT_01.

DATA: ls_doc LIKE bapi_doc_draw2,

ls_return LIKE bapiret2.

DATA: lf_doctype LIKE BAPI_DOC_AUX-DOCTYPE,

lf_docnumber LIKE BAPI_DOC_AUX-DOCNUMBER,

lf_docpart LIKE BAPI_DOC_AUX-DOCPART,

lf_docversion LIKE BAPI_DOC_AUX-DOCVERSION.

DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,

lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,

lt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.

ls_doc-documenttype = 'DRW'.

ls_doc-documentversion = '00'.

ls_doc-documentpart = '000'.

ls_doc-description = 'New doc 23 July'.

ls_doc-username = 'TestUser1'.

REFRESH lt_files.

CLEAR lt_files.

lt_files-docfile = 'E:\temp\Sample.pdf'.

lt_files-wsapplication = 'PDF'.

APPEND lt_files.

CLEAR lt_drat.

REFRESH lt_drat.

lt_drat-language = 'EN'.

lt_drat-description = 'Data01'.

APPEND lt_drat.

lt_drat-language = 'EN'.

lt_drat-description = 'Data02'.

APPEND lt_drat.

CLEAR lt_drad.

REFRESH lt_drad.

lt_drad-objecttype = 'MARA'.

lt_drad-objectkey = 'A006'.

APPEND lt_drad.

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2' EXPORTING:

documentdata = ls_doc

IMPORTING:

documenttype = lf_doctype

documentnumber = lf_docnumber

documentpart = lf_docpart

documentversion = lf_docversion

return = ls_return

TABLES:

documentdescriptions = lt_drat

objectlinks = lt_drad

documentfiles = lt_files.

IF ls_return-type CA 'EA'.

ROLLBACK WORK.

MESSAGE ID '26' TYPE 'I' NUMBER '000' WITH ls_return-message.

ELSE.

COMMIT WORK.

ENDIF.

ENDFUNCTION.

Can anybody help.

Thanks in advance

Ruhi Hira