ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → Data Consistency → SAP LUW
ROLLBACK WORK
Other versions: 7.31 | 7.40 | 7.54
Syntax
ROLLBACK WORK.
Effect
The statement ROLLBACK WORK
closes the current
SAP LUW and opens a new one.
This cancels all changes requests made by the current SAP LUW. In this case, ROLLBACK WORK
performs the following actions:
PERFORM ON ROLLBACK
. PERFORM ON COMMIT
. 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.
Notes
-
All open database cursors
in the database connections concerned are closed during
ROLLBACK
s, which means that a runtime error occurs when the system attempts to continue aSELECT
loop after aROLLBACK
. For the same reason, a FETCH after aROLLBACK
on the cursor that is now closed also causes a runtime error. Make sure that cursors that are still open are no longer used after theROLLBACK
. -
After a
ROLLBACK
statement,sy-subrc
is always zero. It is not necessary to query whethersy-subrc
is not equal to zero afterROLLBACK
. -
ROLLBACK
must not be used during updates (CALL FUNCTION ... IN UPDATE TASK
) or when subroutines registered using PERFORM ... ON COMMIT orPERFORM ... 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). -
The
ROLLBACK WORK
statement is executed implicitly if a message of type A is handled by the additionerror_message
when calling a function module withCALL 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.
Example
The statement ROLLBACK WORK
deletes the registration of
update function
modules made using the statements CALL FUNCTION IN UPDATE TASK
and calls the subroutine cleanup
.
PERFORM cleanup ON ROLLBACK.
...
CALL FUNCTION 'DEMO_UPDATE_DELETE' IN UPDATE TASK.
...
DATA(values) = VALUE demo_update_tab(
( id = 'X' col1 = 100 col2 = 200 col3 = 300 col4 = 400 )
( id = 'Y' col1 = 110 col2 = 210 col3 = 310 col4 = 410 )
( id = 'Z' col1 = 120 col2 = 220 col3 = 320 col4 = 420 ) ).
CALL FUNCTION 'DEMO_UPDATE_INSERT' IN UPDATE TASK
EXPORTING
values = values.
...
ROLLBACK WORK.
...
FORM cleanup.
...
ENDFORM.
Exceptions
Non-Handleable Exceptions
-
Cause:
ROLLBACK WORK
is not permitted within aFORM
that is called using PERFORM ... ON COMMIT orPERFORM ... ON ROLLBACK
.
Runtime error:ROLLBACK_IN_PERFORM_ON_COMMIT
-
Cause:
ROLLBACK WORK
is not permitted within updates.
Runtime error:ROLLBACK_IN_POSTING