ABAP Keyword Documentation → ABAP - Reference → ABAP Syntax → ABAP Statements → Operands → Names for Individual Operands
Class Component Selector
A static component comp
of a class can be accessed using the name
class=>comp
In this case, no instance of the class needs to be created. The characters =>
are the class component selector. The name class
of a class must be to the
left of the class component selector. The name comp
of the component must be to the right of the class component selector.
The class component selector can also be used to access the data types and constants of an interface.
intf=>type
, intf=>const
The name intf
of an interface must be to the left of the class component
sector. The name type
of a data type defined using TYPES
or the name const
of a constant defined using CONSTANTS
must be to the right of the object component selector.
Other versions:
7.31 | 7.40 | 7.54
Note
It is also possible to access the static components of a class using the object component selector if an instance of the class was created.
Example
Declares a class factory
and accesses its static attribute oref
.
CLASS factory DEFINITION CREATE PRIVATE.
PUBLIC SECTION.
CLASS-DATA oref TYPE REF TO factory.
CLASS-METHODS class_constructor.
METHODS do_something.
ENDCLASS.
...
factory=>oref->do_something( ).
...
CLASS factory IMPLEMENTATION.
METHOD class_constructor.
CREATE OBJECT oref.
ENDMETHOD.
METHOD do_something.
...
ENDMETHOD.
ENDCLASS.