Get Example source ABAP code based on a different SAP table
• -> ABAP_SELECTOR
Object Component Selector ITOC
Static Target A statically specified component comp> of an object is accessed using the following name: ref->comp> In this case, the character ->> is the object component selector. A reference variable ref> must be specified as follows to the left of the object component selector:
Name of a reference variable that can itself be a composite.
Functional method call> or method chaining> with a reference variable as a result.
Single or chained table expression> whose result is a reference variable.
Constructor expression> with the instance operator> NEW>> or the casting operator> CAST>>. The name comp> of the component must be to the right of the object component selector. The object component selector dereferences the reference variable ref> and makes the components of the referenced object accessible.
If ref> is an object reference variable, the components comp > of the object - attributes and methods - to which the object reference variable points are addressed using the object component selector.
If ref> is a data reference variable that is typed as a structure, the components comp> of the structure to which the data reference variable points are addressed using the object component selector. If an attempt is made to access a data object (access to an instance attribute> by an object reference variable> or access to a structure component by a data reference variable>) using a reference variable that contains the null reference>, an uncatchable exception OBJECTS_OBJREF_NOT_ASSIGNED> or DATREF_NOT_ASSIGNED > is raised. If an attempt is made to call an instance method> with a reference variable that contains the null reference, a catchable exception of the class CX_SY_REF_IS_INITIAL> is raised.
Latest notes: If ref> is a data reference variable, the character *> can be specified after the object component selector ->>, which 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. The dereferencing operator cannot be specified after object reference variables. The instance components of classes can only be accessed using the expression ref->comp>. NON_V5_HINTS ABAP_HINT_END BEGIN_SECTION SAP_INTERNAL_HINT If ref> is an interface reference variable and comp> is an interface method, the operator ->>> works as ->>. The operator ->> > was intended for remote interface invocation once and it was forgotten to delete it. Usage of ->>> leads to a syntax warning instead of a syntax error. END_SECTION SAP_INTERNAL_HINT
ABAP_EXAMPLE_VX5 Accesses the public attribute a1> of a class c1> using an object reference variable oref>. CLASS c1 DEFINITION.> PUBLIC SECTION.> DATA a1 TYPE string READ-ONLY.> ENDCLASS.>
...>
DATA oref TYPE REF TO c1.>
... oref->a1 ...> ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 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>. DATA dref TYPE REF TO sflight.>
...>
... dref->carrid ...> ABAP_EXAMPLE_END
Dynamic Target A component of an object can be specified dynamically with the following syntax: ... ${ dref->(comp_name) $} $| ${ cref->(attr_name) $} $| ${ iref->(attr_name) $} ...> The syntax and meaning is the same as for dynamic components> and dynamic access> in the statement ASSIGN> and the result of the expressions behave like an accordingly assigned field symbol of type ANY>. If the component is not found, an exception of class CX_SY_ASSIGN_ILLEGAL_COMPONENT> occurs. This exception is also raised if the reference variable is initial.
ABAP_EXAMPLE_VX5 Dynamic specification of a structure component and an interface attribute of an object. ABEXA 01594 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 Behavior for initial reference. The example shows that an initial reference leads to a catchable exception CX_SY_ASSIGN_ILLEGAL_COMPONENT> for a dynamic target but to an uncatchable exception DATREF_NOT_ASSIGNED> for a static target. ABEXA 01469 ABAP_EXAMPLE_END