Ansicht
Dokumentation

ABENOBJECT_COMPONENT_SELECTOR - OBJECT COMPONENT SELECTOR

ABENOBJECT_COMPONENT_SELECTOR - OBJECT COMPONENT SELECTOR

Addresses (Business Address Services)   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

Object Component Selector

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.

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.

Note

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.

Example

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 ...

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.

DATA dref TYPE REF TO sflight.

...

... dref->carrid ...

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 occurs.

Example

Dynamic specification of a structure component and an interface attribute of an object.






SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 5651 Date: 20240328 Time: 183735     sap01-206 ( 82 ms )