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 'BAPI_DOCUMENT_CHANGE2' is not updating document data

Former Member
0 Kudos

Hi Experts ,

I am using BAPI 'BAPI_DOCUMENT_CHANGE2' to update the document status and ecn no of the document but its failing to do the same.

i am calling this BADI in BEFORE_SAVE method of BADI 'DOCUMENT_MAIN01'. I checked this BAPI in se37 by setting the test sequence calling BAPI_TRANSACTION_COMMIT' after this BAPI and it works.

But when I used the same parameters in the BADI its not updating the status. Please suggest.

lcl_doc_data-documenttype =    draw-dokar.

         lcl_doc_data-documentnumber draw-doknr.

         lcl_doc_data-documentversion = draw-dokvr.

         lcl_doc_data-documentpart = draw-doktl.

         lcl_doc_data-statusextern = 'IW'.

         lcl_doc_data-statusintern = 'IW'.

         lcl_doc_data-ecnumber = lv_fieldvalue.

         lcl_doc_datax-statusextern = 'X'.

         lcl_doc_datax-statusintern = 'X'.

         lcl_doc_datax-ecnumber = 'X'.

         CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'

           EXPORTING

             documenttype    = draw-dokar

             documentnumber  = draw-doknr

             documentpart    = draw-doktl

             documentversion = draw-dokvr

             documentdata    = lcl_doc_data

             documentdatax   = lcl_doc_datax

           IMPORTING

             return          = gs_return_error.


IF gs_return_error-type CA 'EA'.

           MESSAGE gs_return_error-message TYPE 'E'.

         ELSE.

           CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

             EXPORTING

               wait = c_x.

         ENDIF.

1 ACCEPTED SOLUTION

SimoneMilesi
Active Contributor
0 Kudos

Sorry, but i understood correctly?
In the badi you are calling a bapi that update the same document??

4 REPLIES 4

SimoneMilesi
Active Contributor
0 Kudos

Sorry, but i understood correctly?
In the badi you are calling a bapi that update the same document??

0 Kudos

Hi Simone,

Yeah you are correct , I am calling the BAPI mentioned in the BADI before_save method to update the document.

Thanks,

Amitesh

0 Kudos

then it cannot work.

You are still locking the doc, so the bapi will never update it.

0 Kudos

Hi,

Just make the data change directly in the BADI itself. Don't call a BAPI!

Why are you calling a BAPI anyway - what did you want to change?

cheers

Paul