BAPI_TRANSACTION_ROLLBACK — BAPI_TRANSACTION_ROLLBACK Rollback Logic and Pitfalls
BAPI_TRANSACTION_ROLLBACK is the generic function module that discards the update task built up during a BAPI call sequence, mirroring ABAP ROLLBACK WORK for RFC clients. It has no business object of its own and takes no import parameters. It must be called explicitly by the caller whenever a preceding BAPI's RETURN table contains an error, otherwise SAP will not roll back on its own.
This page covers BAPI_TRANSACTION_ROLLBACK, the counterpart to BAPI_TRANSACTION_COMMIT used to discard pending update work after a failed BAPI call. It focuses on why the RETURN table of the business BAPI, not this function module itself, is where the real logic bug usually lives, and on the side effects rollback does not undo such as locks and number range gaps.
Reviewed by an ERPClimb SAP consultant on 16 Sept 2026· 1,051 words
What it does
BAPI_TRANSACTION_ROLLBACK is not tied to any single business object. It is part of the generic BAPI transactional framework and exists to give external callers, RFC clients, and custom ABAP programs a way to explicitly discard the update task entries accumulated during a sequence of BAPI calls, in the same way ROLLBACK WORK does inside a normal dialog program. It is typically called immediately after inspecting the RETURN table of a business BAPI such as a sales order or material master create and finding an error message. Because BAPIs deliberately avoid an implicit commit or rollback inside themselves, so that several BAPIs can be chained into one logical unit of work, this function module is the only clean way to tell the system the whole chain should be abandoned.
Important parameters
BAPI_TRANSACTION_ROLLBACK is unusual among BAPIs in that it takes no importing parameters and returns nothing. There is no WAIT flag equivalent to the one on BAPI_TRANSACTION_COMMIT, and no RETURN table of its own. Calling it simply issues an internal ROLLBACK WORK and clears the update task queue for the current logical unit of work. Because there is nothing to configure, the interface risk sits entirely in when the call is made, not in what is passed to it. Developers coming from other BAPIs sometimes look for a RETURN or a success flag on this call and find none, which is expected behaviour, not a missing interface.
- no importing parameters - the function module takes no input, the call itself is the instruction
- no exporting parameters - there is no RETURN table or status flag to check on this call
Commit behaviour
BAPI_TRANSACTION_ROLLBACK does the opposite of committing: it discards the pending update task rather than writing it to the database. If the caller forgets to call either this or BAPI_TRANSACTION_COMMIT after a BAPI sequence, the update task remains queued against the session. In a long-running RFC connection or a batch job this can leave objects locked far longer than intended, and in some interface patterns the session eventually ends without either call ever firing, so the update is lost silently with no error raised at the point of failure. The absence of an automatic decision is deliberate: SAP will not guess whether a chain of BAPI calls should be kept or thrown away.
Return handling
There is no RETURN table on BAPI_TRANSACTION_ROLLBACK itself, so the return handling that matters is upstream, on the business BAPI that triggered the decision to roll back. The recurring bug is checking sy-subrc after the BAPI call instead of scanning the RETURN table, because most BAPIs return sy-subrc as zero even when RETURN is full of error lines. A second common bug is checking only the first line of RETURN, or filtering only on TYPE equals E, and missing an A (abort) message that should also trigger a rollback. A third is looping through RETURN, finding an error, calling BAPI_TRANSACTION_ROLLBACK correctly, but then continuing execution as if the transaction had succeeded because no exception was raised by the rollback call, leaving the calling program in an inconsistent state relative to what was actually persisted.
ECC vs S/4HANA
BAPI_TRANSACTION_ROLLBACK is retained in S/4HANA as part of the classic BAPI framework and there is no dedicated released API that replaces it, because its role is infrastructural rather than business-specific. Custom code that calls standard BAPIs, whether over RFC or locally within an S/4HANA system, still needs to pair each call sequence with an explicit commit or rollback exactly as it did in ECC. The only change in modern development is that new code written natively against ABAP RESTful application programming model or Cloud APIs typically works with its own transactional handling rather than this function module, but that is a different programming model, not a replacement for it.
Common pitfalls
Most incidents involving this function module are really incidents in the surrounding call logic rather than in the module itself.
- Rollback is called but enqueue locks set by the business BAPI are not released by it, they remain visible in the lock table until the session ends, blocking other users
- Number ranges obtained through buffered number range objects during the failed sequence are not rolled back, so document numbers appear to disappear even though the rollback was correct
- Branching logic calls both BAPI_TRANSACTION_COMMIT and BAPI_TRANSACTION_ROLLBACK in different code paths that both execute due to a missing ELSE, with unpredictable results depending on timing
- Rollback is issued after an update task has already been dispatched asynchronously, so part of the change is on the database despite the rollback call
- Custom wrapper functions swallow the RETURN table from the inner BAPI and always call commit, because the wrapper's own interface treats sy-subrc as the only failure signal
Whose problem this is
This is a developer problem. The fix is almost always in the calling program's error handling around the RETURN table, not in configuration. A functional consultant reporting a symptom such as a document that appears created despite an error message, or a lock that never clears, should provide the RETURN table contents from the failing call and the timestamps of the lock in the lock table, since that evidence points the developer straight at the branch that skipped the rollback.
Related SAP objects
Reviewed pages this object connects to in the ERPClimb knowledge graph.
Source: ERPClimb — https://erpclimb.com/sap-bapis/bapi-transaction-rollbackERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.