ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP - Database Accesses → Object Services
Transaction Service
The transaction service implicitly or explicitly deals with the update of persistent objects, which were created in the program or whose persistent attributes were changed.
To work with the transaction service you need to have access to the Transaction Manager of the Object Services Manager which implements the
- IF_OS_TRANSACTION_MANAGER
interface.
This access is enabled by the methods INIT_AND_SET_MODES and GET_TRANSACTION_MANAGER in the
- CL_OS_SYSTEM.
system service class
By using method CREATE_TRANSACTION of the Transaction Manager you can create transactions which you can access using the
- IF_OS_TRANSACTION interface.
The most important methods of a transaction are:
- START
- END
- UNDO
Other versions: 7.31 | 7.40 | 7.54
Example
The following example assumes that the program is running in the object-oriented transaction mode. That
is, either the transaction is specified as a OO transaction in Transaction Maintenance
for which the OO transaction model is marked or the INIT_AND_SET_MODES is
called before there is any access to a persistent object (where the parameter I_EXTERNAL_COMMIT must
be set to OSCON_FALSE). Only then the END method starts an update. Otherwise the program is in the compatibility
mode, in which you must explicitly specify the COMMIT WORK
statement after the end of a transaction.
data TM type ref to IF_OS_TRANSACTION_MANAGER.
data T type ref to IF_OS_TRANSACTION.
...
TM = CL_OS_SYSTEM=>GET_TRANSACTION_MANAGER( ).
T = TM->CREATE_TRANSACTION( ).
...
TRY.
T->START( ).
... "Change persistent Objects
T->END( ).
CATCH CX_OS_ERROR.
...
ENDTRY.