Entering content frameProcedure documentation Creating Standard Classes Locate the document in its SAP Library structure

Note

You can find detailed information about ABAP classes in the ABAP manual under Structure link Classes.

Prerequisites

When you name your class, observe the naming conventions for global ABAP classes.

Procedure

To create a new class from the initial screen of the ABAP Workbench:

  1. Enter the name of the new class according to the naming conventions under Object type.
  2. Choose Create.
  3. The Create Class dialog box appears with the name of the class:

  4. Enter the following details for the subclass definition:
  5. - Class

    Name of the new class.

    NoteThis graphic is explained in the accompanying text Create Inheritance

    When you choose this function, the Inherits from dialog box appears. You can define the inheritance relationship here by specifying the name of the superclass.
    You can define the superclass as any class from the class library that is not defined as final.

    - Description

    A short text describing the new class.

    - Inst. Creation

    In general, classes are marked with the Public option. This means 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 template for your subclasses. You can only access this class with your static attributes or with your subclasses.

    - Class type

    You define the basic type and use of the class here. Copy the entry Normal ABAP class. You can also choose Exception class or Persistent class. You can find more information about these special classes under:
    Defining Exception Classes

    Defining Persistent Classes

    - Final

    You define a final class with the Final option. This class completes the inheritance hierarchy since a final class may not create any further subclasses.
    If an abstract class is also defined as final. This is advisable if you only want to access the static components of this class.

    - Modeled only

    If you select this option, the class is not included in the class pool. You will not be able to address it at runtime or test it.

  6. Choose This graphic is explained in the accompanying textSave.
  7. The Create Object Catalog Entry dialog box is displayed.

  8. Enter the Package.
  9. Choose Save.

The method display of the Class Editor appears. From here, you can define its components and include interfaces in it.

Result

You have now defined a new class and entered its basic data. The system creates a class pool for the new class (as long as you did not define it as Modeled only).

Note

Exactly one global class is defined in a class pool. Analogous to function groups, you can specify local classes as auxiliary classes or local types here.

 

 

Leaving content frame