ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Assignments →  Assigning References →  Setting Reference Variables → 

GET REFERENCE  Syntax Diagram

Short Reference

Syntax

GET REFERENCE OF dobj INTO dref.

Effect

This statement sets the reference in the reference variable dref in a way that makes it point to the data object dobj. The following can be specified for dref:

The data object is specified directly and in accordance with the rules described in the section Reader Positions. If offsets/lengths (+off(len)) are specified, the data type dobj here cannot be string or xstring.

Notes

Example

Creates data references to the individual characters of a data object text and saves them in an internal table. Direct dereferencing at an operand position is possible because the data reference is fully typed.

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.
  cl_demo_output=>write( |{ dref->* }| ).
ENDLOOP.

Exceptions

Non-Catchable Exceptions