SAP CLASS ABAP Statements



Get Example source ABAP code based on a different SAP table
  


ID CLASS
• CLASS ABAP Statement

CLASS
Short Reference

ABAP_SYNTAX_FORMS

Declaration Part of a Class
1 CLASS class DEFINITION $[class_options $].
$[PUBLIC SECTION.
$[components$]$]
$[PROTECTED SECTION.
$[components$]$]
$[PRIVATE SECTION.
$[components$]$]
ENDCLASS.

Implementation Part of a Class
2 CLASS class IMPLEMENTATION.
...
METHOD ...
...
ENDMETHOD.
...
ENDCLASS.

Publication of Classes
3 CLASS class DEFINITION DEFERRED $[PUBLIC$].

Local Friends of Global Classes
4 CLASS class DEFINITION
LOCAL FRIENDS class1 class2 ...
intf1 intf2 ...

What does it do?
The statement CLASS defines a class class, publishes it, or specifies properties.
The complete definition of a class consists of a declaration part and an implementation part, which are both introduced by CLASS and ended by ENDCLASS. In the declaration part, the properties of the class are specified, and its components are declared. In the implementation part, the methods of the class are implemented.
The variants of CLASS without ENDCLASS are used for the publication of classes in a program and the declaration of local friends of a global class.
The statements CLASS and associated statements ENDCLASS can only be specified in the global context of a program. CLASS and ENDCLASS cannot be listed within classes, procedures,
BEGIN_SECTION VERSION 5 OUT and processing blocks that are implemented internally as a procedure, that is, event blocks for GET and AT SELECTION-SCREEN
END_SECTION VERSION 5 OUT . This applies in particular to the variants of CLASS listed here, which are not closed using ENDCLASS.



Latest notes:

The declaration part of a class, and the variants of CLASS that are not closed using ENDCLASS are handled like other declaration statements (DATA, TYPE, ...). In a processing block without a local context, they are handled like global program declarations and do not close the processing block.
The implementation part of a class works like a separate processing block and closes any other processing blocks.
NON_V5_HINTS
The obsolete variant CLASS ... DEFINITION LOAD was formerly used to load classes explicitly.
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Declaration and implementation of a local class demo with some of the possible components.
ABEXA 01593
ABAP_EXAMPLE_END

Return to menu