Get Example source ABAP code based on a different SAP table
ID ROLLBACK • ROLLBACK WORK ABAP Statement
ROLLBACK WORK> Short Reference >
ABAP_SYNTAX ROLLBACK WORK.>
What does it do? The statement ROLLBACK WORK> closes the current SAP LUW> and opens a new one. BEGIN_SECTION VERSION 5 OUT This cancels all changes requests made by the current SAP LUW. To do this, ROLLBACK WORK> performs the following actions: Executes all subroutines registered using PERFORM ON ROLLBACK>>. Deletes the registrations of all subroutines registered using PERFORM ON COMMIT>>. Raises an internal event in the Object Services> that ensures that the attributes of persistent objects are initialized. Deletes all update function modules registered with CALL FUNCTION ... IN UPDATE TASK> > from the DDIC database tables VB...> and deletes all Remote Function Calls registered with CALL FUNCTION ... IN BACKGROUND UNIT>> or CALL FUNCTION ... IN BACKGROUND TASK>> (obsolete) from the DDIC database tables ARFCSSTATE> and ARFCSDATA>. Removes all SAP locks> set in the current program for which the formal parameter _SCOPE> of the lock function module was set to the value 2. Triggers a database rollback> on all currently open database connections >, which also ends the current database LUW>. After the statement ROLLBACK WORK> is completed, the event TRANSACTION_FINISHED> from the system class CL_SYSTEM_TRANSACTION_STATE> is raised. Here, the parameter KIND> has the value of the constant CL_SYSTEM_TRANSACTION_STATE=>ROLLBACK_WORK>. END_SECTION VERSION 5 OUT
Latest notes:
After a ROLLBACK> statement is executed, sy-subrc> is always zero. It is not necessary to query whether sy-subrc> is not equal to zero after ROLLBACK>.
The ROLLBACK WORK> statement is executed implicitly if a message> of type A is handled by the addition error_message> when calling a function module with CALL FUNCTION>.
ROLLBACK WORK> empties global temporary tables> of all currently open database connections> and prevents the runtime error COMMIT_GTT_ERROR> in the case of implicit database commits>.
All open database cursors> in the database connections concerned are closed during a ROLLBACK>, which means that a runtime error occurs when the system attempts to continue a SELECT> loop after a ROLLBACK>. It must therefore be ensured that cursors that are still open are no longer used after the ROLLBACK>. NON_V5_HINTS
For the same reason, a FETCH>> after a ROLLBACK> on the cursor that is now closed also causes a runtime error.
ROLLBACK> must not be used during updates > (CALL FUNCTION ... IN UPDATE TASK>) or when subroutines registered using PERFORM ... ON COMMIT> or PERFORM ... ON ROLLBACK> are being executed.
The statement ROLLBACK WORK> must not be executed in units or LUWs that are managed by background RFC calls (bgRFC> and the obsolete tRFC> and qRFC>). ABAP_HINT_END VX_EXA_ONLY
Example ABAP Coding
The statement ROLLBACK WORK> deletes the registration of update function modules> using the statements CALL FUNCTION IN UPDATE TASK>> and calls the subroutine cleanup>. ABEXA 00563 ABAP_EXAMPLE_END
Runtime Exceptions
Non-catchable Exceptions
Reason for error:
ROLLBACK WORK> is not allowed within a FORM> that is called using PERFORM ... ON COMMIT>> or PERFORM ... ON ROLLBACK>>.