Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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.

CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'

   EXPORTING

     DOCUMENTTYPE         = 'FOL'

     DOCUMENTNUMBER   = 'INVOICES'

     DOCUMENTPART         = '000'

     DOCUMENTVERSION  = '00'

     DOCUMENTDATA        = ls_docdata

     DOCUMENTDATAX      = ls_docdatax

   IMPORTING

     RETURN                        = ls_return

   TABLES

     DOCUMENTSTRUCTURE = lt_docstr.


bapi commit.

Regards

Sanja

replied

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.

Regards

Sanjay

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question