BAPI_TRANSACTION_COMMIT is called to COMMIT a database operation.
As we can not write COMMIT WORK statement inside BAPI, we need to call this BAPI.
Suppose you are updating some database table inside one BAPI.
According to success status of that BAPI, either you can COMMIT or ROLLBACK. To COMMIT call BAPI BAPI_TRANSACTION_COMMIT
Yes you can use this in R3 also.
BAPI_TRANSACTION_COMMIT.
use : when you are using BAPI's it need external commit. for this we use the above FM.
when you will use..
When there is no error from BAPI then only you need to call this BAPI.
Look at OSS [Note 798535 - COMMIT WORK after calling a BAPI|https://service.sap.com/sap/support/notes/798535]
Regards
This BAPI is used to update the database after all the transactions in a LUW are completed successfully. After execution of this BAPI all the related tables are updated in the database.
So whatever operation you do which requires the database tables to be updated, this BAPI can be used.
This method executes a COMMIT WORK command. It is needed for transactions that are developed outside of the R/3 System, but change data in the R/3 System using BAPI calls.
If you call BAPIs in your program, which are meant to change R/3 System data, you must call this method to write the changes in the database.
In this case, the database commit is executed externally.
Executing the ABAP statement COMMIT WORK:
Besides the database commit, this statement executes other activities - compare the key term documentation for COMMIT WORK.
In this case, the database commit is executed internally.
Example program
************************************************************** Call BAPI ************************************************************** CALL FUNCTION 'BAPI_DOCUMENT_CREATE2' EXPORTING: documentdata = ls_doc IMPORTING: documenttype = lf_doctype documentnumber = lf_docnumber documentpart = lf_docpart documentversion = lf_docversion re stall turn = ls_return TABLES: documentdescriptions = lt_drat object-left = lt_drad documentfiles = lt_files. ************************************************************** **Error Check ************************************************************** IF ls_return-type CA 'EA'. ROLLBACK WORK. 'Errors are made declining MESSAGE ID '''26''' TYPE '''I''' NUMBER '''000''' WITH ls_return-message. ELSE. COMMIT WORK. 'Changes are confirmed ENDIF.
hii
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = w_WAIT
IMPORTING
RETURN = RETURN.
.
This FM will update your data.it will use for the FM like BAPI_DOCUMENT_CHANGE2 ....if its done successfully then 'BAPI_TRANSACTION_COMMIT' FM will save all the changes or else it will not save and will perform rollback.
reward if useful
thx
twinkal
Add a comment