Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9091

Re: [ASK] successful create document in DMS using BAPI_DOCUMENT_CREATE2 but error Error while checking out:

$
0
0

Dear Christoph,

 

Thanks a lot for your information and guidance.. solved and this is my code.

 

FORM create_new.

 

   DATA: ls_doc LIKE bapi_doc_draw2,

         ls_return LIKE bapiret2.

 

** key fields for BAPI return

   DATA: lf_doctype LIKE bapi_doc_draw2-documenttype,

   lf_docnumber LIKE bapi_doc_draw2-documentnumber,

   lf_docpart LIKE bapi_doc_draw2-documentpart,

   lf_docversion LIKE bapi_doc_draw2-documentversion.

 

** table to check in the originals

   DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE,

** short text

   lt_drat LIKE bapi_doc_drat OCCURS 0 WITH HEADER LINE,

** object links

   lt_drad LIKE bapi_doc_drad OCCURS 0 WITH HEADER LINE.

 

*********************************************************************

 

** allocate document data *which will be assigned to the new document

 

*********************************************************************

   ls_doc-documenttype = 'DMO'.

   ls_doc-documentnumber = 'SAMPLE_PDF'.

   ls_doc-documentversion = '00'.

   ls_doc-documentpart = '000'.

   ls_doc-description = 'Sample document PDF'.

   ls_doc-docfile1 = 'D:\sample.pdf'.

   ls_doc-wsapplication1 = 'PDF'.

   "ls_doc-statusextern = 'AA'.

   "ls_doc-laboratory = '001'.

 

**********************************************************

 

** hand over originals

 

***********************************************************

 

   REFRESH lt_files.

   CLEAR lt_files.

   lt_files-storagecategory = 'DMS_C1_ST'.

   lt_files-docfile = 'D:\sample.pdf'.

   lt_files-wsapplication = 'PDF'.

 

*if the original should be checked in the old storage place,

* the assignment

   "lt_files-originaltype = '1'.   " or '2' have to be done

   APPEND lt_files.

 

*********************************************************

 

** allocate short texts

 

**********************************************************

   CLEAR lt_drat.

   REFRESH lt_drat.

   lt_drat-language = 'EN'.

   lt_drat-description = 'Sample PDF'.

   APPEND lt_drat.

   lt_drat-language = 'DE'.

   lt_drat-description = 'Sample PDF'.

   APPEND lt_drat.

 

**********************************************************

 

** create object link to material master record

 

***********************************************************

*  CLEAR lt_drad.

*  REFRESH lt_drad.

*  lt_drad-objecttype = 'MARA'.

*  lt_drad-objectkey = 'M4711'.

*  APPEND lt_drad.

 

**************************************************************

 

** call BAPI

 

**************************************************************

 

   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.

 

** error occured ??

 

   IF ls_return-type CA 'EA'.

     ROLLBACK WORK.

     MESSAGE ID '26' TYPE 'I' NUMBER '000'

     WITH ls_return-message.

   ELSE.

     COMMIT WORK.

     MESSAGE 'Successful insert document!' TYPE 'I'.

   ENDIF.

 

ENDFORM.                    "create_new_2


Viewing all articles
Browse latest Browse all 9091

Trending Articles