SAP OS PERSIST ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_OS - Persistency Service
This example demonstrates how a persistent object is created.

ABAP_SOURCE_CODE
ABAP_EXEC

ABAP_DESCRIPTION
A reference to the class agent of the persistent class CL_SPFLI_PERSISTENT is assigned to the reference variable agent. It is created once by the static constructor of the CA_SPFLI_PERSISTENT class. Using the method GET_PERSISTENT , a check is made to establish whether there is already a persistent object with the required key in the database. If an object already exists, it can be deleted using DELETE_PERSISTENT. If no object exists, the exception CX_OS_OBJECT_NOT_FOUND is raised and caught. In the corresponding CATCH block, an attempt is made to create the object using CREATE_PERSISTENT. It should be noted that the object is only created on the database when the statement COMMIT WORK is used. Without an explicit COMMIT WORK, it exists only as a managed object in the program and it is deleted without affecting the database at the end of the program.