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

REF - Reference Operator

Syntax

... REF type( dobj | table_exp ) ...

Alternatives:

1. ... REF type( dobj )

2. ... REF type( table_exp )

Effect

A constru tor expression with the reference operator REF creates either a data reference variable that points to the argument dobj or controls a table expression table_exp.

Existing data objects and table expressions can be specified as an argument, but no further expressions or function calls.

Alternative 1

... REF type( dobj )


Effect

If a data object dobj is specified as an argument, the operator REF functions like the statement GET REFERENCE and creates a data reference variable as a result. This variable points to the specified data object dobj. type determines the static type of the result. The following can be specified for type:

The parentheses must contain precisely one unnamed argument dobj. If offsets/lengths (+off(len)) are specified, the data type dobj here cannot be string or xstring.

Notes

Example

Fills an internal table with the value operator VALUE, where the component dref is given a value using REF. This is an excerpt from the example for the class CL_ABAP_BROWSER. Other uses can be found in examples of ADBC, where parameter bindings are used.

TYPES pict_line(1022) TYPE x.

DATA  pict     TYPE STANDARD TABLE OF pict_line WITH EMPTY KEY.
DATA  ext_data TYPE cl_abap_browser=>load_tab.

ext_data = VALUE #( ( name = 'PICT.GIF'
                      type = 'image'
                      dref = REF #( pict ) ) ).

Alternative 2

... REF type( tab_exp )


Effect

If a table expression table_exp is specified as an argument, the operator REF controls the category of its result, as described in the related section.