ROLLBACK

Variants:




1. ROLLBACK WORK.

2. ROLLBACK CONNECTION con.

Effect

Closes a logical unit of work. However, all database changes are reversed and the database state is reset (for example, by using COMMITWORK). All database locks are released.
You use this statement if you cannot be certain that all the database changes have been executed correctly.

ROLLBACK is part of the Open SQL commnad set.

Variant 1

ROLLBACK WORK.

Effect

All database changes on all database connections are reversed and reset to the last saved status(for example, using COMMIT WORK). All database locks on all database connections are released. Before that, the system executes the subprograms registered using PERFORM ... ON ROLLBACK.
The update routines are not performed.

Executing the ROLLBACK WORK triggers the event RAISE_TRANSACTION_FINISHED of the class CL_SYSTEM_TRANSACTION_STATE with parameter value CL_SYSTEM_TRANSACTION_STATE=>ROLLBACK_WORK.

Variant 2

ROLLBACK CONNECTION con.

Effect

The ROLLBACK command is not executed on the standard database, but on the secondary database connection specified with con. con is the name of the database connection as it was specified in the table DBCON in the column CON_NAME. The database connection con can also be specified dynamically in the form (source_text), where the source_text field contains the name of the database connection. The source_text field must be type C or STRING.

Notes

  1. Because all open database cursors on the relevant database connections are closed during the ROLLBACK, attemting to continue a SELECT loop after a ROLLBACK will cause a runtime error. For the same reason, a FETCH after a ROLLBACK on the closed cursor also causes a runtime error. You must ensure that any cursors that are still open are no longer used after the ROLLBACK.

  2. After the ROLLBACK statement, SY-SUBRC is always zero. You do not have to query SY-SUBRC after the ROLLBACK statement.

ROLLBACK is not allowed during an update (CALL FUNCTION ... IN UPDATE TASK) or during the execution of FORMs registered with PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK.

  1. The ROLLBACK WORK statement is executed implicitly if a type A message was handled with the ERROR_MESSAGE addition when a function module was called using CALL FUNCTION.


Exceptions

Non-Catchable Exceptions

Additional help

Writing Changes to the Database