ABAP Keyword Documentation → ABAP - Quick Reference
CLASS - Quick reference
Other versions: 7.31 | 7.40 | 7.54
Syntax Forms
Declaration Part
CLASS class DEFINITION [INHERITING FROM superclass]
[ABSTRACT]
[FINAL]
[CREATE {PUBLIC|PROTECTED|PRIVATE}]
[SHARED MEMORY ENABLED]
[FOR TESTING
[RISK LEVEL {CRITICAL|DANGEROUS|HARMLESS}]
[DURATION {SHORT|MEDIUM|LONG}] ]
[[GLOBAL] FRIENDS [class1 class2 ...]
[intf1 intf2 ...] ].
[PUBLIC SECTION.
[components]]
[PROTECTED SECTION.
[components]]
[PRIVATE SECTION.
[components]]
ENDCLASS.
Implementation Part
CLASS class IMPLEMENTATION.
implementations
ENDCLASS.
Effect
Declares and implements a class class. In the declaration part, the components components of a class are declared in the
visibility sections
PUBLIC,
PROTECTED, and PRIVATE SECTION, using ALIASES, [CLASS-]DATA, [CLASS-]METHODS, and [CLASS-]EVENTS. In the implementation part, all the
concrete methods declared
in the declaration part between METHOD and ENDMETHOD are implemented.
Additions
-
INHERITING FROM superclass
Definesclassas a subclass ofsuperclass. -
ABSTRACT
Definesclassas an abstract class, which cannot be instantiated. -
FINAL
Definesclassas a final class from which subclasses cannot be derived. -
CREATE {PUBLIC|PROTECTED|PRIVATE}
Specifies whether the classclasscan be instantiated as public, protected, or in its package as private. -
SHARED MEMORY ENABLED
Specifies that instances of the class can be stored in shared memory. -
FOR TESTING
Defines a test class for ABAP Unit. The additions determine the test properties. -
[GLOBAL] FRIENDS [class1 class2 ...] [ intf2 ...]
Describes other classesclass1 class2 ...or interfacesintf1 intf2 ...as friends, which are permitted to access all components ofclass.