05-04-2011 7:54 AM
Hi SAP Gurus,
I am using fm 'bapi_document_create2' for creating douments.
Document is created without attachments.
I searched SDN and change the code accordingly with no luck.
Please see the code where i am doing wrong.
DATA: ls_doc LIKE bapi_doc_draw2,
ls_return LIKE bapiret2.
DATA: lf_doctype LIKE bapi_doc_draw2-documenttype,
lf_docnumber LIKE bapi_doc_draw2-documentnumber,
lf_docpart LIKE bapi_doc_draw2-documenttype,
lf_docversion LIKE bapi_doc_draw2-documenttype.
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 = 'OPL'.
ls_doc-documentversion = '00'.
ls_doc-documentpart = '000'.
ls_doc-statusextern = 'WR'.
ls_doc-laboratory = '002'.
REFRESH lt_files.
CLEAR lt_files.
*lt_files-sourcedatacarrier = 'SAP-SYSTEM'.
lt_files-storagecategory = 'SAP-SYSTEM'.
lt_files-docfile = 'C:\Documents and Settings\LALIT\My Documents\ac.doc'.
lt_files-wsapplication = 'WRD'.
APPEND lt_files.
CLEAR lt_drat.
REFRESH lt_drat.
lt_drat-language = 'EN'.
lt_drat-description = 'Testing document from bapi'.
APPEND lt_drat.
CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
EXPORTING
documentdata = ls_doc
IMPORTING
return = ls_return
TABLES
documentdescriptions = lt_drat
documentfiles = lt_files.
BREAK-POINT.
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
WRITE : ls_return-message.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = '5'.
ENDIF.
DATA: doknr TYPE doknr.
GET PARAMETER ID 'CV1' FIELD doknr.
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING
documenttype = 'OPL'
documentnumber = doknr
documentpart = '000'
documentversion = '00'
hostname = ''
statusintern = ''
statusextern = ''
statuslog = ''
IMPORTING
return = ls_return
TABLES
documentfiles = lt_files.
Thanks in advance
Lalit
05-04-2011 1:39 PM
Hi Lalit,
Please check the example source code given in documentation for function module BAPI_DOCUMENT_CREATE and check if it helps identify the issue.
Regards,
Shyam
05-04-2011 1:39 PM
Hi Lalit,
Please check the example source code given in documentation for function module BAPI_DOCUMENT_CREATE and check if it helps identify the issue.
Regards,
Shyam
05-05-2011 6:42 AM