CLASS - DEFINITION

Short Reference

Syntax

CLASS class DEFINITION [ [class_options].
  [PUBLIC SECTION.
    [components]]
  [PROTECTED SECTION.
    [components]]
  [PRIVATE SECTION.
    [components]]
ENDCLASS.

The statement block CLASS class DEFINITION - ENDCLASS defines a class named class. The naming conventionsapply to the name class. Components of the class are declared between CLASS and ENDCLASS. Each component must be included in a visibility section after one of the statements PUBLIC SECTION, PROTECTED SECTION, or PRIVATE SECTION. These statements must be listed in the above order. The class does not need to include all the SECTION statements. A class can be published globally in the Class Library. Using the
class options additions to the CLASS statement, you can: publish a class globally in the Class Library, define an inheritance relationship, make the class abstract or final, control where the class can be instantiated, and offer friendship to other classes or interfaces.

The class is the smallest encapsulation unit in ABAP Objects. A method can therefore use all components of all instances of the same class apart from the components of its own instance. The exception to this rule are subclasses that do not have access to the private components of superclasses if they are not their friends.