SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Accesses → Object Services → transaction service →Nesting and Chaining Transactions
Role of the Top Level Transaction
The top level transaction is the transaction of the uppermost level. All the transactions started during the top level transaction are subtransactions and do not lead to a COMMIT WORK when they end. The transaction mode determines how the top level transaction is created.
Subtransactions
You can create a subtransaction by starting a new transaction before another transaction has come to an end. Subtransactions must be ended within the transaction in which they are embedded. A COMMIT WORK is never triggered when a subtransaction ends. Changes to the persistent objects of a subtransaction are only made when the top level transaction has ended. This occurs explicitly in a COMMIT WORK or implicitly in an END, depending on the transaction mode. You can also query the transaction mode with IF_OS_TRANSACTION~GET_MODES for subtransactions, but the transaction mode always tells you the global setting of the Object Services for the current program.
Sequential Processing
Top Level Transactions
A program can only have one top level transaction at a time. A new transaction can be started as the top level transaction when the old top level transaction has come to an end.
Within a transaction, further subtransactions can be started after the end of another subtransaction. Changes made to persistent objects between subtransactions belong to the transaction at the next higher level.
Concatenation of Top Level Transactions
If you execute transactions one after the other, that is you end one top level transaction and then start a new one, the relevant persistent objects are invalidated. When you access such an object in the next transaction, it is loaded again from the database. You can avoid this time-consuming process by concatenating top level transactions with IF_OS_TRANSACTION~END_AND_CHAIN or IF_OS_TRANSACTION~UNDO_AND_CHAIN. In this case, the persistent objects are not invalidated. However, a new transaction object is created and its reference is returned as the return value.
You can use these methods for top level transactions in object-oriented mode, but not for the top level transaction in compatibility mode. You do not need to use the methods for subtransactions since the persistent objects are retained until the change has been made, and are not invalidated.
Example
After method END_AND_CHAIN is called, reference variable t refers to a new transaction object.