Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  Data Consistency →  Database LUW 

Database Rollback

Database rollbacks are triggered implicitly or explicitly in AS ABAP.

Other versions: 7.31 | 7.40 | 7.54


Note

A database rollback closes all opened database cursors. It is particularly important that database rollbacks are not triggered (in one of the ways listed here) in SELECT loops and after the statement OPEN CURSOR.

Implicit Database Rollbacks

The following exceptions trigger an implicit database rollback:

  • A program is terminated when a message is sent.

The implicit database rollback takes place on all currently open database connections.


Notes

  • A termination message also produces a database rollback if the message is handled by the predefined exception error_message when a function module is called.

  • Termination and exit messages always terminate the program. Other message types can also terminate a program in certain contexts .

Explicit Database Rollbacks

Explicit database rollbacks in ABAP programs can be triggered in the following ways:

  • The relevant database-specific Native SQL statement is used.
  • In ADBC, only the method ROLLBACK of the class CL_SQL_CONNECTION can be used to do this. In other cases, the database interface does not detect the end of the transaction and might not be able to perform certain actions.
  • Any ROLLBACK statement embedded statically between EXEC and ENDEXEC is detected by the database interface and any required actions performed.
  • Calling the function module DB_ROLLBACK. This function module encapsulates the corresponding Native SQL statement. By default, the database rollback is triggered on the connection currently open for EXEC SQL. The rollback is triggered explicitly on the standard connection by passing the value of abap_true to the input parameter IV_DEFAULT. The function module DB_ROLLBACK raises the event DB_TRANSACTION_FINISHED of the class CL_DBI_TRANSACTION_STATE, which is handled by the application log framework.

ROLLBACK statements are not allowed in AMDP methods.


Notes

  • A simple database rollback in an ABAP program is is usually triggered using the statement ROLLBACK CONNECTION (the standard connection can be specified here using default). The database LUW can be monitored by the application log by using the function module DB_ROLLBACK. Apart from the database rollback itself, using the statement ROLLBACK WORK also has certain other consequences with respect to the SAP LUW.

  • An explicit database rollback in an ABAP program is is best triggered using the statement ROLLBACK CONNECTION (the standard connection can be specified here using default).

Database Rollback on Database Connections

When a secondary connection or a service connection is closed explicitly in Native SQL, a database rollback is triggered in the transaction context of this database connection. For more information, see Database Connections.