Show TOC

 Defining Persistence RepresentationLocate this document in the navigation structure

Use

When defining a persistence representation, using either database tables or ABAP Dictionary structures, you also need to define the attributes of persistent classes or to assign fields from tables or structures to existing attributes. The following types of attributes are available:

  • Single-valued attributes

    You can get single-valued attributes explicitly using generated SET and GET methods. These are generated for each single attribute.

  • Attributes that belong to the key of the database table

    If the attribute is part of a business key acting as a primary key, the system generates a GET method for the attribute but not a SET method. These attributes are called key attributes. You cannot change key attributes, but can determine them explicitly using the IMPORT parameter of the constructor when you create an instance of a class.

  • Reference attributes

    Reference attributesrepresent references to persistent objects. Each object reference is mapped to a field for the instance GUID and to a field for the classes GUID. A SET and a GET method are generated for each reference attribute.

Prerequisites
  • The database tables or dictionary structures to which the persistent attributes of the created class are assigned must already exist. If you wish to use reference attributes, you need two fields to save the object reference. The instance GUID is saved in one of these fields, and the class GUID is saved in the other. The referenced object must contain a GUID field for identification.
  • To identify a persistent object, you must create a GUID or a business key for the object
Procedure
  1. In the Class Builder, open the persistent class you want to edit.
  2. In the application toolbar, choose Persistency.

    The system starts the Mapping Assistant and displays a dialog box in which you enter the name of a database table or a dictionary structure.

  3. Enter a reference table, view, or structure.
  4. Choose Continue.

    The table (view, or structure) is displayed.

  5. Expand the table symbol to display all fields of the table or structure.
  6. Define the value and key attributes by extracting attributes from fields.
  7. If necessary, define the reference attributes .
  8. Assign a GUID for object identification if required.
  9. Proceed as described in Defining GUIDs .
  10. Choose Save.

    The corresponding database access methods are generated implicitly at the same time as the attributes.

  11. Choose F3 to return to the Class Builder.

    The generated access methods are displayed.

Result

You have created persistent attributes, the corresponding SET and GET methods, and methods for loading and saving object instances and can use these after the activation of the class in your application. These methods allow you to access attributes of the state object, and also provide the application programmer with an invisible, implicit connection to object services.

See also:

Activating Persistent Classes