Get Example source ABAP code based on a different SAP table
ID CLASS-DATA • CLASS-DATA ABAP Statement
CLASS-DATA> Short Reference >
ABAP_SYNTAX CLASS-DATA attr $[options>$].>
What does it do? The statement CLASS-DATA> can only be used in the declaration part of a class or an interface. It declares a static attribute attr> whose validity is not tied to instances of a class, but to the class itself. All instances of the class and its subclasses access a static attribute. The naming conventions> apply to the name attr>. The syntax of the additions options> is identical to the statement DATA>> for instance attributes (only the addition WITH HEADER LINE>> must not be used).
Latest notes:
Like all static components in the inheritance>, the static attributes of a superclass exist in all subclasses. A static attribute that is visible externally can be addressed using the class component selector and all the names of the classes in which it exists. This means that the class in which it is declared is always addressed, which, for example, has an effect on the execution of the static constructor >. A change to a static attribute applies to all classes in which it exists, independently of the addressing.
Static attributes declared using CLASS-DATA> can be accessed using the class component selector only with class names, not with interface names.
Structured static attributes can be declared as a static box> using the addition BOXED>>. NON_V5_HINTS
The static attributes of a shared memory-enabled class> are handled in the same way as a regular class, which means they are created in the ABAP_ISESS > of a program when the class is loaded there. If different programs access the same shared objects>, the static attributes of the associated classes exist more than once and independently of one another in the programs. ABAP_HINT_END
ABAP_EXAMPLE_VX5 In this example, the static attribute text> of class c1> is accessed using the class component selector without creating an instance of the class. ABEXA 00096 ABAP_EXAMPLE_END