->* DEREFERENCING OPERATOR

Aus SAP Hilfe

Data References

Data references can point to any data objects or to their parts (components, rows of internal tables, or sections determined by offset and length specifications). The static type of their reference variables is either the predefined generic type data or any non-generic data type. Data reference variables can be used in the statement CREATE DATA to generate data objects dynamically. The statement GET REFERENCE and the reference operator REF can be used to write references to existing data objects in data reference variables. When internal tables are processed, most statements have the addition REFERENCE INTO, to set references to table rows.

The dereferencing operator ->* is used to access the data object to which a data reference points. If the static type of the data reference variable is not generic, the expression dref->* can be specified at any operand position. For data reference variables with a generic static type, only the statement ASSIGN dref ->* TO <fs> can be used to assign the data object (to which the data reference points) to a field symbol.

Data references can be heap references or stack references.

Programming Guideline

Use field symbols and data references in appropriate ways

DATA g_dat TYPE string VALUE '...'.

CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS meth.
ENDCLASS.

CLASS demo IMPLEMENTATION.
  METHOD meth.
    DATA dref TYPE REF TO data.
    FIELD-SYMBOLS <l_dat> TYPE any.
    CREATE DATA dref LIKE g_dat.
    ASSIGN dref->* TO <l_dat>.
    <l_dat> = g_dat.
    cl_demo_output=>display_data( <l_dat> ).
  ENDMETHOD.
ENDCLASS.