Start of Content Area

Background documentation Saving Object References Persistently  Locate the document in its SAP Library structure

At runtime, the Persistence Service works with the instances of persistent classes, which are generally addressed by reference as in ABAP Objects and kept alive. If you want to keep a reference to a persistent object beyond the runtime of an ABAP program – for example, to work with the same object later in another ABAP program – you must save it persistently.

To save this information in a database, you need two table fields of the type OS_GUID. The first field contains the class GUID generated when the persistent class is created, while the second contains the instance GUID that provides the unique global identifier for the object and its values. Both of these together form an Object ID (or OID). References to objects of persistent classes that are defined by business key cannot be saved such that they have no instance GUID (see also Mapping by Business Key).

You can map both fields of such an OID to a single attribute of a persistent class using the Mapping Assistant. This attribute provides a reference to the appropriate persistent object. The Persistence Service then handles this reference – which is not a reference variable in the original ABAP Objects sense. It also loads the persistent object (to which the reference points) from the database.

Creating these two fields for the class GUID and the instance GUID does not make sense unless the tables are used as the basis for a persistent class. The most common application for this technique is to save references to other persistent objects in a persistent object that is accessed by a business key, where these other objects are managed by instance GUID, and cannot be accessed otherwise (that is, where objects are closely interlinked).

 

 

End of Content Area