Entering content frameProcedure documentation Defining Persistence Representation Locate the document in its SAP Library structure

Use

During persistence representation, using either database tables or ABAP Dictionary structures, the attributes of persistent classes are defined or fields from tables or structures are assigned to existing attributes.
Attributes can generally be either single value attributes, attributes that belong to the key of the database table, or reference attributes.

You can get single value attributes explicitly using generated SET and GET methods. These are generated for each single attribute.
However if the attribute is part of a business key that is 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 creating an instance of a class.
Reference attributes represent references to persistent objects. Each object reference is mapped to a field for the instance GUID and to a field for the classes GUID. As for single value attributes, a SET and a GET method are generated for each reference attribute.

Prerequisites

Procedure

To define the persistence representation of tables or structures for attributes of a class, you must:

  1. Call the Class Builder and load the appropriate persistent class.
  2. In change mode, select the Persistency function from the application toolbar.
  3. The system starts the Mapping Assistant and displays a dialog box in which you enter the name of a database table or Dictionary structure.

  4. Enter a reference table, view, or structure.
  5. Choose This graphic is explained in the accompanying text Continue.
  6. The entered table (view,structure) is displayed in the Layout of Initial Screen .

    Note

    If you prefer to carry out a manual implementation of the database access layer, select This graphic is explained in the accompanying text to change the generator settings and select the field of the same name. In this case you can implement your own database read routines, through which you can redefine the generated SET and GET methods for access to the database. This is particularly recommended if you want to improve performance by providing these routines with their own buffer mechanism.

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

  12. Choose This graphic is explained in the accompanying text Save.
  13. The corresponding database access methods are generated implicitly at the same time as the attributes.

  14. Choose F3 to return to the Class Builder.

The generated access methods are displayed.

This graphic is explained in the accompanying text

Note

If a persistence representation has already been defined for a persistent class, the system will display the initial screen of the Mapping Assistant after step 1. However if the selection of database table or structure is subsequently changed, call the appropriate function from the context menu. See Editing Persistent Attributes.

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 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:

Class Diagram: After Activation

Activating Persistent Classes

 

 

Leaving content frame