ABAP Keyword Documentation → ABAP - Reference → ABAP Syntax → ABAP Statements → Operands → Names for Individual Operands
Object Component Selector
comp of an object is accessed using the name
In this case, the character
-> is the object component selector. A reference variable
ref must be specified on the left of the object component selector as follows
- Name of a reference variable (can itself be a composite).
- Functional method call or method chaining with reference variable as a result.
- Constructor expression with the
NEWor the casting operator
comp of the component must be to the right of the object component selector. If an attempt is made to access an object component with a reference variable that contains the
null reference, a non-handleable
exception is raised. Dereferencing of a data reference in the statement
ASSIGN is an exception to this.
The object component selector dereferences the reference variable
ref and makes the components of the referenced object accessible.
refis an object reference variable, the components
compof the object (attributes and methods) to which the object reference variable points are addressed using the object component selector.
refis a data reference variable that is typed as a structure, the components
compof the structure to which the data reference variable points are addressed using the object component selector.
7.31 | 7.40 | 7.54
ref is a data reference variable, the character
can be specified after the object component selector
->. This creates the
general dereferencing operator
->. The expression
labels the entire data object to which the data reference variable points. The dereferencing operator
is the only way to dereference data references. In the case of untyped data reference variables, this
was only possible using the statement
ASSIGN. The dereferencing operator
cannot be specified after object reference variables. The instance components of classes can only be accessed using the expression
Accesses the public attribute
a1 of a class
c1 by using the object reference variable
CLASS c1 DEFINITION.
DATA a1 TYPE string READ-ONLY.
DATA oref TYPE REF TO c1.
... oref->a1 ...
The data reference variable
dref is typed as a structure and the component
carrid of the referenced structure is accessed using the object component
selector. The expression
dref->carrid has the same meaning as the chaining
DATA dref TYPE REF TO sflight.
... dref->carrid ...