Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Types and Objects - Overview →  Data Objects →  References 

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 built-in generic type data or any non-generic data type. Data reference variables can be used with the instance operator NEW to create data objects statically and in the statement CREATE DATA to create 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.

Data references can be heap references or stack references.

Other versions: 7.31 | 7.40 | 7.54

Programming Guideline

Use field symbols and data references in appropriate ways


Example

Inline declaration of a data reference variable dref with the static type scarr on the left side of a corresponding anonymous data object created on the heap. Uses the dereferencing operator ->* to access the full data object and the object component selector -> to access a component.

DATA(dref) = NEW scarr( ). 

SELECT SINGLE * 
       FROM scarr 
       WHERE carrid = 'LH' 
       INTO @dref->*. 

cl_demo_output=>display_data( dref->carrid ).