Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Persistent Class

Former Member
0 Likes
527

Hi,

We need to store some control data in memory and were planning to use Persistent classes. I checked the Demo example provded by SAP, but its way 2 confusing. Does anyone have a simpler example on how to implement it?

Regards,

SG

3 REPLIES 3
Read only

Former Member
0 Likes
450

Hi,

Choose transaction SE24 and create a persistent class; this class must be protected.

steps :

Go to se 24 - choose persistence class

it will be always protected class.

next screen will give u the persistence button when u click on that it will ask u to

add the table or struture.

now u can see two division of the screen where bottom portion of the screen will list uall the fields available and u need to double click and map to the top portion.

Save the persistence class and hit back button..

Whenever u create persistence class zcl_example_persist - it will create two classes - zca_example_persist

and zcb_example_persist automatically

Where zca_example_persist is the agent class and zcb_example_persist is base agent class..

Save and activate.

Activate the whole class. Now that we have a persistent object to access the database table SFLIGHT, we must access it in a program. Here is a small example to read/write data into SFLIGHT using persistent objects.

REPORT  ZPERSISTENCECLASS.
 
data : l_flight type ref to zcl_persist.
data : l_flight_agent type ref to zca_persist.
data : l_seatsfree type i.
data : l_seatsocc type i.
 
l_flight_agent = zca_persist=>agent.
 
 
* CATCH CX_OS_OBJECT_NOT_FOUND .
*ENDTRY.
 
*TRY.
CALL METHOD L_FLIGHT_AGENT->GET_PERSISTENT
  EXPORTING
    I_CARRID = 'LH'
    I_CONNID = '0400'
    I_FLDATE = '20060701'
  RECEIVING
    RESULT   = l_flight
    .
* CATCH CX_OS_OBJECT_NOT_FOUND .
*ENDTRY.
 
 
l_seatsfree = L_FLIGHT->GET_SEATSMAX( ) - L_FLIGHT->GET_SEATSOCC( ).
 
 if l_seatsfree > 0.
 l_seatsfree = L_FLIGHT->GET_SEATSOCC( ) + 1.
 
 l_flight->set_seatsocc( l_seatsfree ).
 endif.

There are lots of other methods and techniques that you can use in persistent classes.

A demonstration of this can be found in program DEMO_CREATE_PERSISTENT.

DEMO_QUERY_PERSISTENT

kindly look into below link for screen shot to create persistence class

[Click here|http://erpgenie.com/abaptips/content/view/417/38/]

[Blog|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1013] [original link is broken] [original link is broken] [original link is broken];

Thanks & regards,

ShreeMohan

Read only

Former Member
0 Likes
450

Hi if you intent to use memory, there is also a technick that named "SHARE MEMORY". You can store your data there and these to be visible not only for you but for everyone. This is good if you are reading often and writing rearly.

1. You have to create a Share Object Class and a root class (tcodes: SE24, SHMA)

2. You have to create a program that will "write" the data into the memory

3. and then an other program that will read the data from the memory.

With Regards

George

Read only

0 Likes
450

George,

This solution looks promising. Can you give me an example?