ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → Object Services → Persistence Service
Saving Persistent Objects
The ABAP statement COMMIT WORK
must be executed to apply any changes to the
instances of persistent classes to the actual persistent objects in the database. If an object-oriented
transaction from the transaction service is not used explicitly, the statement COMMIT
WORK must be specified explicitly. If not, it is encapsulated in the transaction service. Specifying
the statement COMMIT WORK
explicitly means, in the transaction service, that the top level transaction runs in compatibility mode.
The classic statement COMMIT WORK
has additional functions when used in conjunction
with object services. Before the statement closes the SAP LUW and triggers an update, it calls methods
of the persistence service internally. These methods bundle the changes made to managed objects of the
persistence service and pass them to a special update function module using CALL
FUNCTION ... IN UPDATE TASK. This means that the persistence service works with traditional update
methods. The update module is usually registered after any update modules that have already been registered.
The update is then triggered and the update task executes the update module in the order in which they were registered.
After the statement COMMIT WORK
, the attributes of a persistent object in the ABAP program are initial (the method IF_OS_STATE~INVALIDATE was called).
If the changes are to be made to managed objects directly rather than using the update module, the update
mode of the implicitly used transaction service must be changed. This is done by executing the following statements before the statement COMMIT WORK
:
DATA T type ref to IF_OS_TRANSACTION.
...
TM = CL_OS_SYSTEM=>GET_TRANSACTION_MANAGER( ).
T = TM->GET_CURRENT_TRANSACTION( ).
T->SET_MODE_UPDATE( OSCON_DMODE_DIRECT ).
COMMIT WORK.
Persistent objects can be also used during updates – that is, within update modules. The update task changes the persistent objects in update modules as the last step after processing all the registered update modules in the database.
Other versions:
7.31 | 7.40 | 7.54