Skip to Content

Change Document through cv12 - documents automatically getting deleted

Hello Gurus,

i am trying to create document entries in CV12 using BAPI - BAPI_DOCUMENT_CHANGE2.

But when i try to add single document through BAPI all existing documents are getting deleted automatically and new one getting added and i am not able to see that in CV13.

I have tried by getting all existing documents details using BAPI -  BAPI_DOCUMENT_GETDETAIL2 and pass existing documents along with new document then this is working fine and i can see all documents in CV13.

Please suggest what should i do so existing documents will not get deleted when i pass single document.

i am passing values as below.

ls_docdata-DOCUMENTTYPE    = 'INV'.

ls_docdata-DOCUMENTNUMBER  = '0000000000000010000000134'.

ls_docdata-DOCUMENTVERSION = '00'.

ls_docdata-DOCUMENTPART    = '000'.

ls_docdatax-DOCUMENTTYPE    = 'X'.

ls_docdatax-DOCUMENTNUMBER  = 'X'.

ls_docdatax-DOCUMENTVERSION = 'X'.

ls_docdatax-DOCUMENTPART    = 'X'.

ls_docstr-DOCUMENTTYPE    = 'INV'.

ls_docstr-DOCUMENTNUMBER  = '0000000000000010000000134'.

ls_docstr-DOCUMENTPART    = '000'.

ls_docstr-DOCUMENTVERSION = '00'.

ls_docstr-QUANTITY        = '1'.

append ls_docstr to lt_docstr.



     DOCUMENTTYPE         = 'FOL'


     DOCUMENTPART         = '000'


     DOCUMENTDATA        = ls_docdata

     DOCUMENTDATAX      = ls_docdatax


     RETURN                        = ls_return


     DOCUMENTSTRUCTURE = lt_docstr.

bapi commit.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 12, 2015 at 11:30 AM

    Dear Sanja,

    from DMS point of view I have to inform you that always all the existing positions of the document BOM has to be handed over to BAPI_DOCUMENT_CHANGE2. Because otherwise the system handles the "missing" documents as to be deleted and so they are removed.

    Best regards,


    Add comment
    10|10000 characters needed characters exceeded

    • Hi Christoph,

      Thanks for your reply.

      I mistakenly put my name as SANJA 😉 its sanjay.

      Yes i agree with your suggestion but to get all existing records for reprocessing will work for some point of time while records are less in folder, once it will have huge number of entries it will hamper a program performance.

      Anyways i have done debugging for the FM BAPI_DOCUMENT_CHANGE2 and i found that there is condition in FM  API_DOCUMENT_SAVE_BOM where the deletion flag is set and that deletes the previous entries.

      That condition sendcompletebom sets true(X) (Delete existing items that are not sent anymore)

             if                                 DOCBOMCHANGENUMBER (Change Number)

                                                DOCBOMVALIDFROM (Valid-From Date)

                                                DOCBOMREVISIONLEVEL (Revision Level)

      this three fields are blank in input of BAPI and then all existing records get deletion flag in FM API_DOCUMENT_COMPARE_BOM and then only updates the existing record.

      Then i have entered "Valid-From Date" and it worked 😊 existing records are still present along with new entries.