GET REFERENCE

Short Reference

Syntax

GET REFERENCE OF dobj INTO dref.

Effect

This statement gets itself a reference to a data object dobj and places this into the reference variable dref. The reference variable dref must be declared as a data reference variable. The static type of the data reference variable must - according to the conversion rules for reference variables - be more general than or the same as the data type dobj.

The specification of the data object is done directly and according to the rules described in the section Data Objects in Operand Positions. In the case of an offset or length specification, the data type for dobj here must not be string or xstring.

Notes

The content of two reference variables filled with GET REFERENCE is only the same if - apart from the referenced data objects - the other management information is the same. For example, a reference that is got directly through the specification of the data object is different from a reference that is got through the specification of a field symbol if this has a different data type because of a casting. XXXX

Example

Creating data references to the individual characters of a data object text and their storage in an internal table. This example is possible as of Release 6.10. Before Release 6.10, dref can only be typed using TYPE REF TO data and cannot be dereferenced, except in ASSIGN.

TYPES c1 TYPE c LENGTH 1.

DATA: dref TYPE REF TO c1,
      dref_tab LIKE TABLE OF dref.

DATA: text TYPE c LENGTH 10 VALUE '0123456789',
      off TYPE i.

DO 10 TIMES.
  off = sy-index - 1.
  GET REFERENCE OF text+off(1) INTO dref.
  APPEND dref TO dref_tab.
ENDDO.

LOOP AT dref_tab INTO dref.
  WRITE / dref->*.
ENDLOOP.

Exceptions

Non-Catchable Exceptions