Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_DOCUMENT_CREATE2 Document not Checking in

former_member506713
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

2 REPLIES 2

Former Member
0 Kudos

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

0 Kudos

Thanks Shyam,

Closing the thread.