Show TOC Start of Content Area

Procedure documentation Creating a Persistent Class  Locate the document in its SAP Library structure

Use

You use this procedure to create persistent classes in the Class Builder.

Prerequisites

You need to use the prefix CL_ (or a corresponding naming convention in the customer namespace) for persistent classes. The auxiliary classes use the same convention.

Procedure

...

       1.      In the Repository Browser (transaction SE80), navigate to the package in which you want to create a persistent class.

       2.      In the context menu of the package, choose Create ® Class Library  ® Class.

The Create Class dialog box appears.

       3.      In the Class Type group box, choose Persistent Class.

       4.      In the Class field, enter a name of the new class according to the naming conventions. The prefix CL_ should be added to the name of all persistent classes.

       5.      In the Description field, enter a short description of the class.

       6.      Enter the rest of the data for the class:

Option

Description

Superclass

      To create a subclass in the Class Builder, choose Superclass on the Properties tab page. Then enter any non-final, global class as a superclass in the Inherits from field. The Undo inheritance and Change inheritance options allow you to change the inheritance relationship.

      To display the components in a subclass that were inherited from the superclass, choose the menu option Utilities ® Settings, and then choose the Display Inherited Components Also option.

Instantiation

      The Public option defines that each user can create instances of the particular class (with CREATE OBJECT).

      The Protected option defines that only inherited classes or the relevant class itself can create instances of this class.

      If you choose the Private option, only the relevant class itself can create its instances (only using its own method).

      You can define an abstract class with the Abstract option. You cannot create an instance for this class. An abstract class can be used as a template for your subclasses. You can only access this class with your static attributes or with your subclasses.

Final

Specifies the development status of the object. Only objects and components with status final can have executable code. This class completes the inheritance hierarchy since a final class may not create any further subclasses.

       7.      Choose Save.

       8.      Enter the name of the package to which your class should belong.

       9.      Choose Save.

Result

The new class implements all the methods of the interface IF_OS_STATE. These service methods are common to all persistent classes and are used when the object status is changed. You can only redefine the implementation of the two methods INIT and HANDLE_EXCEPTION. The other methods are reserved for internal use.

The Class Builder automatically creates two additional auxiliary classes together with the new persistent class. They are assigned to a separate class pool. These classes are needed for managing persistent objects by means of Object Services.

See also:

Generated Classes

Defining Persistence Mapping

 

 

End of Content Area