Today we will see some basics about the Persistent Object Services.
Why do we need Persistent Object Service:
To better understand the need of the persistent objects we need to first understand the concept of the transient data. The local data for the program like Attributes of the class, or program data is known as the transient data.
Normally, with ABAP we load the data into our transient data, work on that and put it back to the database table (if required). At this point of time, our data exists in the two palces: Transient data (ABAP program local data) and in the appropriate database table or other storage medium (which is the persistent data). To avoid having the same data at the same time in two different context, we should use the persistent objects. Because by definition, the persistent data is the data which will be preserved beyound the runtime.
For SAP, we could have the persistent data in form of the Database table or file operations.
SAP Help defines the persistent objects like:
|Technically speaking, ABAP Objects are always transient, just like the data objects in ABAP programs. There are no persistent objects in ABAP Objects. However, the Persistence Service within Object Services allows application developers to work with persistent objects. The Persistence Service can be thought of as a software layer between the ABAP program and the data repository (that is, the database), which allows you to save the attributes of objects with a unique identity, and then load them again when you need them.|
- Good for big dialog / web applications where we are dealing with large number of data but for only one document at time like Sales Order processing, Process Order, GR creation etc.
- Adds one more abstraction layer in between the Business logic and the database.
- Not performance efficient for the report programming
How to create Persistent Objects
SAP Help on Mapping the Persistent Objects
Classes generated alongwith mapping:
When we finish up the creation of the persistent object services for any database table(s) it would create 2 additional classes. E.g: If we sucessfully map the table SPFLI in the Persistent Object class – ZCL_SPFLI_PERSISTENT, system would generate:
Actor Class – ZCA_SPFLI_PERSISTENT
Base Class – ZCB_SPFLI_PERSISTENT
In future posts, we would see how to use Persistent objects in application and some of its properties.