SAP DB ROLLBACK Get Example source ABAP code based on a different SAP table
SAP Help
NO •
Database Rollback Database rollbacks are triggered implicitly or explicitly in
AS ABAP>. ITOC Latest notes: NON_V5_HINTS A database rollback closes all opened database cursors>. It is particularly important that database rollbacks are not triggered in SELECT>> loops and after the statement OPEN CURSOR>> using one of the options listed here. ABAP_HINT_END BEGIN_SECTION VERSION 5 OUT Implicit Database Rollbacks The following exceptions trigger an implicit database rollback: A runtime error>. A termination message> is sent. A program is terminated by sending a respective message>. The implicit database rollback takes place on all currently open database connections>. Latest notes: A termination message also produces a database rollback if the message is handled by the predefined exception error_message>> during the call of a function module. Termination and exit messages> always terminate the program. Other message types can also terminate a program in certain contexts>. When an ABAP_ISESS > is exited, there is no implicit database commit> on the standard connection> and there is no database rollback. This must be programmed explicitly if required. NON_V5_HINTS ABAP_HINT_END • DB_ROLLBACK ABAP_FUMO Explicit Database Rollbacks Explicit database rollbacks in ABAP programs can be triggered in the following ways: The corresponding 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 recognize the end of the transaction and might not be able to perform any necessary actions. Any ROLLBACK> statement embedded statically between EXEC>> and ENDEXEC>> is detected by the database interface and any required actions performed. Executing the AB-SQL > statement ROLLBACK CONNECTION>>. The database rollback takes place on the specified database connection>. 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. Executing the AB-SQL > statement ROLLBACK WORK>>. The database rollback takes place on all currently open database connections>. The statement ROLLBACK WORK> also closes the current SAP LUW> and performs the associated actions. ROLLBACK> statements are not allowed in AMDP> methods. Latest notes: For a simple database rollback in an ABAP program the statement ROLLBACK CONNECTION>> is usually sufficient. The standard connection can be specified here using default>. If the database LUW is to be monitored by the application log>, the function module DB_ROLLBACK>> can be used. The statement ROLLBACK WORK>> should not be used for the sole purpose of a database rollback itself but only for rolling back a complete SAP LUW>. Generally, the use of the statement ROLLBACK CONNECTION>> with the addition default> is recommended for an explicit database rollback in an ABAP program. All the methods specified here for explicit database rollbacks empty any global temporary tables> and prevent the runtime error COMMIT_GTT_ERROR> in the case of implicit database commits>. NON_V5_HINTS ABAP_HINT_END 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>. END_SECTION VERSION 5 OUT