sap web gui login

http://molgaard.consolut.eu/sap/bc/gui/sap/its/webgui

Wednesday, July 23, 2014

BAPI_TRANSACTION_COMMIT versus COMMIT WORK

BAPI_TRANSACTION_COMMIT versus COMMIT WORK

You must alw ays call BAPI_TRANSACTION_COMMIT (not COMMIT WORK) if you have called at least one BAPI function module w ithin the current LUW.

By simply looking at BAPI_TRANSACTION_COMMIT code, w e see quickly w hat is different from COMMIT WORK. It calls BUFFER_REFRESH_ALL function module right after COMMIT WORK.
So BAPI_TRANSACTION_COMMIT additionally refreshes a "BAPI buffer".
Here is w hat BAPI buffer is for:
Assuming your program calls BAPIs consecutively and use a COMMIT WORK/BAPI_TRANSACTION_COMMIT only at the end so that to commit all BAPI updates once (better performance).
As you know , BAPIs need to check errors like data missing in database. For example, the second BAPI may have to check the existence of data w ritten by the previously called BAPI. The data doesn't
exist in database yet, but as it know s it w ill be w ritten later at COMMIT WORK time, it uses a buffer (memory) to store this information, so that no error is raised.
Let's suppose the update during the COMMIT WORK fails (for any reason), the data is not w ritten to database. If you have not refreshed the buffer using BAPI_TRANSACTION_COMMIT, the next BAPI
calls w ill consider that some data w ill exist later, that is w rong.
The same kind of logic applies to the rollback: you must call BAPI_TRANSACTION_ROLLBACK instead of ROLLBACK WORK. It w ill empty the BAPI buffer too. Here's w hy:
If you rollback the first BAPI using ROLLBACK WORK statement, you must absolutely refresh the buffer, otherw ise the next BAPI could think that the data w ill exist and w ould attempt erroneously to
w rite data.



0 comments:

Post a Comment