SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → ABAP Syntax → ABAP Statements → Operands → Names for Individual Operands →Object Component Selector
A component comp of an object is accessed using the name
ref->comp
In this case, the character -> is the object component selector. The name ref of a reference variable must be to the left of the object component selector. The name ref can itself be composite. The name 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.
Note
If ref is a data reference variable, the character * can be specified after the object component selector ->. This creates the general dereferencing operator ->*. The expression ref->* 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 ref->comp.
Example
Access to the public attribute a1 of a class c1 by using the object reference variable oref.
Example
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 dref->*-carrid.