SAP OS PERSISTENCE STATE



Get Example source ABAP code based on a different SAP table
  



ABAP_OS - Management States in the Persistence Service
An object of a persistent class managed by the persistence service can have one of seven different management states. The state of the object affects what methods of the persistence service can be performed on it. The methods of the interface IF_OS_CA_INSTANCE provide information about the state of managed objects.
The following constants of the type pool OSCON return the state of the object: ConstantValueState
OSCON_OSTATUS_NOT_LOADED0 Representative object for a persistent object, data not yet loaded from the database.
OSCON_OSTATUS_NEW1The object is persistent and is new.
OSCON_OSTATUS_LOADED2The object is persistent and has been loaded completely.
OSCON_OSTATUS_CHANGED3The object is persistent and has been changed.
OSCON_OSTATUS_DELETED4The object is persistent and has been deleted.
OSCON_OSTATUS_TRANSIENT10The object is transient.
OSCON_OSTATUS_LOADING12The object is currently being loaded.
The states 0 to 4 describe persistent objects with a connection to the database. An object in state 10 is managed by the persistence service but has no connection to the database.
An object in state 12 is in transition to the state OSCON_OSTATUS_LOADED. This state can be observed only in the method INIT of the interface IF_OS_STATE, which means it is no longer listed in the following tables.
The table below indicates the methods of the persistence service that can be performed on objects in different states, and how they affect the state of the managed object. The last row shows the effect of the statement COMMIT WORK. Method-01234 10
CREATE_PERSISTENT11excexcexc 3exc
DELETE_PERSISTENT-40444exc
GET_PERSISTENT22123excexc
GET_attributeexc2123exc10
SET_attributeexc3133exc10
REFRESH_PERSISTENTexc0exc0exc excexc
RELEASEexc-exc-excexc exc
CREATE_TRANSIENT10excexcexc excexcexc
GET_TRANSIENTexcexcexcexc excexc10
COMMIT WORK-0000-10
All methods except GET_attribute and SET_attribute are methods of the class agent. For simplicity, the class methods and interface methods are summarized using their typical names. GET_attribute and SET_attribute are methods of the persistent class.
The numbers reflect the management states. For example, the method DELETE_PERSISTENT shifts a persistent object from the state 0, 2, 3, or 4 to the state 4.
The dash (-) indicates that an object of a persistent class is available but cannot be managed. A situation like this may occur, for example, if the system deletes a persistent object by passing a reference to the method DELETE_PERSISTENT. The statement COMMIT WORK deletes the object from the database and it is no longer managed. However, it is persisted in the ABAP_ISESS until all references to it are also deleted.
As can be seen in the table, the methods DELETE_PERSISTENT, GET_PERSISTENT, and REFRESH_PERSISTENT can work only with persistent objects in a state from 0 to 4, while GET_TRANSIENT can work only with transient objects in the state 10.
Any attempt to apply a method to a management state inappropriately raises an exception, exc.