SAP OS PERSISTENCE TERMS
Get Example source ABAP code based on a different SAP table
ARTICLE
Persistence Service Overview
Transient and Persistent Data
ABAP programs work with local program data, which resides in the programs internal session. Such data only survives as long as its
To work with persistent data, the system has to load it into transient data objects of the ABAP program while the program is being executed and then store the data again persistently once it has been processed. During this time, the content of the data exists twice: once in the ABAP program (transiently), and once in the relevant storage medium (persistently). A typical process reads data from a database table using the
Data in Object-Oriented Programming
In an ideal object-oriented application, data exists only as the attributes of objects (apart from the local helper variables in met hods). While the description of an object (that is, the class) exists persistently as source code, its attributes exist only as long as the object. An object in ABAP Objects is transient in principle. It exists in the internal program session only from the time it is generated until it is deleted by the garbage collector. Therefore, to work with persistent data in objects, you have to implement access to their storage locations within the methods of the class.
If a program wants to work with an object straight after and in exactly the same state as another program has left it, there must be a possibility to save a summary of data and functionality for an object persistently. Classes of objects are already persistent anyway, but you need some other way of saving the attributes of an object persistently and referencing them to the appropriate class. The Persistence Service allows you to do exactly that.
The Persistence Service for Persistent Objects
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.
Put simply, the Persistence Service ensures that an object is initialized in a specified state, and saves the state of that object w hen required. The relationship between the object and the description of its state in the database is similar to the relationship between transient and persistent data outlined above. The state of the object when it is instantiated reflects the state of the data in the database at that time. Changes to the object state in the ABAP program are not written to the database immediately, but only after the appropriate request has been made (the
Persistent Classes
To use the Persistence Service for objects, the classes of these objects must have been created as persistent classes in the Class Builder. The term persistent class does not imply that a class is persistent (every class is persistent as a template for objects). Instead, it means that the objects of that class and their state are managed by the Persistence Service. When the Class Builder creates a persistent class, it automatically generates an associated class, known as the class actor or class agent, whose methods manage the objects of persistent classes. As well as their identity, persistent classes can contain key attributes, which allow the Persistence Service to ensure that the content of each persistent object is unique.
Managed Objects
The objects of persistent classes are managed by the Persistence Service. This means, among other things, that these objects are ins tantiated with the appropriate methods of the class actor, not directly in the program. These objects are known as managed objects. Objects managed by the Persistence Service can be either persistent or transient.