BAPI Part 5: Commit, WAIT, Rollback and the SAP LUW
Preview · a free account unlocks the full lesson
Control transactions around BAPIs: why most BAPIs do not commit, BAPI TRANSACTION COMMIT with WAIT, BAPI TRANSACTION ROLLBACK, one LUW per business document, calling several BAPIs in one LUW, and what happens with update errors after the commit.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 4 covered reading the RETURN table. Now the question is what actually gets saved, and when.
Most BAPIs register their database changes in the update task; nothing is saved until the caller commits. The reasoning behind this is that a caller may need to combine several BAPIs into a single business transaction — creating an order and then changing something else, for instance — and leaving the commit entirely up to the caller is what makes genuine all-or-nothing behavior possible.
BAPI_TRANSACTION_COMMIT with WAIT = 'X' waits until the update is done — needed before reading the new document or calling a dependent BAPI. Internally it calls COMMIT WORK, and AND WAIT specifically when WAIT = 'X' is passed. Its own RETURN parameter reports any problems from that synchronous commit, but only when WAIT was actually set — without WAIT, the program carries on executing while the update runs in the background, so trying to read the document immediately afterward can fail.
BAPI_TRANSACTION_ROLLBACK calls ROLLBACK WORK, discarding everything registered since the last commit and releasing any locks that were held. On errors, BAPI_TRANSACTION_ROLLBACK discards everything registered since the last commit, and it's worth calling it immediately after any E or A message, before moving on to process the next document.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Interview questions on this topic
Related SAP topics
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.