cancel
Showing results for 
Search instead for 
Did you mean: 

Successful check in using BAPI_DOCUMENT_CHECKIN2 but document still check out?

0 Kudos

Dear expert,

After successful create document using  BAPI_DOCUMENT_CREATE2, i try to check in the document using BAPI_DOCUMENT_CHECKIN2.

I successfull run BAPI_DOCUMENT_CHECKIN2 without error, but when check the document in explorer, this document still check out?

Why this happen please help me...

This is my sample code..

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

**define required variables

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

** Document key

   DATA: lf_doctype LIKE bapi_doc_draw-documenttype,

         lf_docnumber LIKE bapi_doc_draw-documentnumber,

         lf_docpart LIKE bapi_doc_draw-documentpart,

         lf_docversion LIKE bapi_doc_draw-documentversion,

         lf_status LIKE bapi_doc_draw-statusextern,

         psx_message TYPE messages.

** Bapi-Return structure

   DATA: ls_return LIKE bapiret2.

** internal table in which the information for the originals

** is entered, which is then transferred to the module

   DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.

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

** Assign the data

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

   lf_docnumber = '0000000000000010000000003'.

   lf_doctype = 'DMO'.

   lf_docversion = '00'.

   lf_docpart = '000'.

*empty itab and workarea

   REFRESH lt_files.

   CLEAR lt_files.

** Checkin the original into the SAP-database

   lt_files-storagecategory = 'DMS_C1_ST'.

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

*If the original is to be checked into the old storage, the following must take place

* the assignment of

   "lt_files-originaltype = '1'.   " or '2'

* some optional fields

   "lt_files-description = 'Sample Description2'.

   lt_files-wsapplication = 'PDF'. "defines, with what the original

*was opened in R/3-> WORD

   APPEND lt_files.

*appending multiple documents possible, repeat the above steps

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

** Check in document

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

   CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'

     EXPORTING

       documenttype    = lf_doctype

       documentnumber  = lf_docnumber

       documentpart    = lf_docpart

       documentversion = lf_docversion

     IMPORTING

       return          = ls_return

     TABLES

       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.

Best Regards,

Anastasius

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

solved by myself.. this is the code

FORM check_in USING docnum

                     docfile

                     doctype.

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

**define required variables

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

** Document key

   DATA: lf_doctype LIKE bapi_doc_draw-documenttype,

         lf_docnumber LIKE bapi_doc_draw-documentnumber,

         lf_docpart LIKE bapi_doc_draw-documentpart,

         lf_docversion LIKE bapi_doc_draw-documentversion,

         lf_status LIKE bapi_doc_draw-statusextern,

         psx_message TYPE messages,

         ls_doc LIKE bapi_doc_draw2,

*       Flag for change relevance

         ls_docx LIKE bapi_doc_drawx2.

** Bapi-Return structure

   DATA: ls_return LIKE bapiret2.

** internal table in which the information for the originals

** is entered, which is then transferred to the module

   DATA: lt_files LIKE bapi_doc_files2 OCCURS 0 WITH HEADER LINE.

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

** Assign the data

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

   SELECT * FROM draw

     INTO CORRESPONDING FIELDS OF TABLE it_draw

     WHERE doknr = docnum.

   READ TABLE it_draw INTO wa_draw INDEX 1.

   IF sy-subrc = 0.

     lf_docnumber = wa_draw-doknr.

     lf_doctype = wa_draw-dokar.

     lf_docversion = wa_draw-dokvr.

     lf_docpart = wa_draw-doktl.

   ENDIF.

*empty itab and workarea

   REFRESH lt_files.

   CLEAR lt_files.

** Checkin the original into the SAP-database

  lt_files-storagecategory = 'SAP-SYSTEM'."DMS_C1_ST

   "lt_files-docfile = 'D:\sample2.pdf'.

   lt_files-docfile = docfile.

*If the original is to be checked into the old storage, the following must take place

* the assignment of

   lt_files-originaltype = '1'.   " or '2'

* some optional fields

   "lt_files-description = 'Sample Description2'.

   lt_files-wsapplication = doctype. "defines, with what the original

  lt_files-checkedin = 'X'.

   lt_files-sourcedatacarrier = 'SAP-SYSTEM'.

*was opened in R/3-> WORD

   APPEND lt_files.

*appending multiple documents possible, repeat the above steps

     CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'

     EXPORTING

       documenttype    = lf_doctype

       documentnumber  = lf_docnumber

       documentpart    = lf_docpart

       documentversion = lf_docversion

     IMPORTING

       return          = ls_return

     TABLES

       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 AND WAIT.

   ENDIF.

ENDFORM.                    "check_in

Answers (0)