Ansicht
Dokumentation

ABAPCLASS_DEFINITION - CLASS DEFINITION

ABAPCLASS_DEFINITION - CLASS DEFINITION

Fill RESBD Structure from EBP Component Structure   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

CLASS, DEFINITION

Short Reference



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

Effect

The statement block CLASS class DEFINITION - ENDCLASS declares a class named class. Naming conventions apply to the name class. The components components of the class are declared between CLASS and ENDCLASS. Each component must be listed in a visibility section after one of the statements PUBLIC SECTION, PROTECTED SECTION, or PRIVATE SECTION which must be specified in the order above. The class does not need to contain all the SECTION statements.

The class options additions of the statement CLASS can be used to publish a class globally in the class library, define an inheritance relationship, make the class abstract or final, control instantiability, and offer friendship to other classes or interfaces.

Notes

  • The class is the smallest encapsulation unit in ABAP Objects. A method can therefore use all components of all instances of the same class in addition to the components of its own instance. An exception to this rule are subclasses that cannot access the private components of superclasses if they are not their friends.
  • The declaration part of a class can only be specified in the context described under CLASS.

Example

Declaration part of a class with statements for declaring static components and instance components.

CLASS cls DEFINITION FINAL.
  PUBLIC SECTION.
    TYPES:
      type1 TYPE ...
    CLASS-DATA:
      attr1 TYPE ...
    ...
    CLASS-METHODS:
      meth1 ...
    ...
    CLASS-EVENTS:
       evt1 ...
    ...
    DATA:
      attr2 TYPE ...
    ...
    METHODS:
      meth2 ...
    ...
    EVENTS:
       evt2 ...
    ...
ENDCLASS.







General Material Data   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

Length: 4155 Date: 20240418 Time: 193607     sap01-206 ( 67 ms )