!--a11y-->
Generating a Persistent Object 
report DEMO_CREATE_PERSISTENT.
selection-screen begin of screen 400 title TEXT-400.
parameters DELETE as checkbox.
selection-screen end of screen 400.
selection-screen begin of screen 500 title TEXT-500.
parameters COMMIT as checkbox.
selection-screen end of screen 500.
data WA_SPFLI type SPFLI.
data: CONNECTION type ref to
CL_SPFLI_PERSISTENT ,data: EXC type ref to CX_ROOT,
TEXT type STRING.
WA_SPFLI-CARRID = 'LH'.
WA_SPFLI-CONNID = '123'.
WA_SPFLI-COUNTRYFR = 'DE'.
WA_SPFLI-CITYFROM = 'FRANKFURT'.
WA_SPFLI-AIRPFROM = 'FRA'.
WA_SPFLI-COUNTRYTO = 'SG'.
WA_SPFLI-CITYTO = 'SINGAPORE'.
WA_SPFLI-AIRPTO = 'SIN'.
WA_SPFLI-FLTIME = '740'.
WA_SPFLI-DEPTIME = '234500'.
WA_SPFLI-ARRTIME = '180000'.
WA_SPFLI-DISTANCE = '10000'.
WA_SPFLI-DISTID = 'KM'.
WA_SPFLI-FLTYPE = ' '.
WA_SPFLI-PERIOD = '1'.
AGENT =
CA_SPFLI_PERSISTENT=>AGENT .try.
CONNECTION = AGENT->
A reference to the class actor of the persistent class CL_SPFLI_PERSISTENT is assigned to the reference variable AGENT. The static constructor of the class CA_SPFLI_PERSISTENT generates this reference once only. The GET_PERSISTENT method checks whether or not there is a persistent object with this key in the database already. If so, it can be deleted using DELETE_PERSISTENT. If not, the system raises and catches the exception CX_OS_OBJECT_NOT_FOUND. Then it tries to create the object in the relevant CATCH block using CREATE_PERSISTENT. Note
t hat the object is created in the database only when the COMMIT WORK statement is executed. If there is no COMMIT WORK statement, the program retains only the managed object, which is deleted from the database after the program ends. (See Transaction Mode).