Field Symbols & Data References

A field symbol is a placeholder (alias) for an existing data object — similar to a dereferenced pointer.

24.1 Field symbols

A field symbol is a placeholder (alias) for an existing data object — similar to a dereferenced pointer. No memory is copied.

FIELD-SYMBOLS <lv_any>   TYPE any.
FIELD-SYMBOLS <ls_order> TYPE ty_order.
FIELD-SYMBOLS <lt_tab>   TYPE STANDARD TABLE.

DATA lv_num TYPE i VALUE 5.
ASSIGN lv_num TO <lv_any>.
<lv_any> = 10.                                 " lv_num is now 10

LOOP AT lt_orders ASSIGNING <ls_order>.
  <ls_order>-status = 'C'.                     " changes the table row directly
ENDLOOP.

READ TABLE lt_orders ASSIGNING <ls_order> WITH KEY order_id = '1'.
ASSIGN lt_orders[ order_id = '1' ] TO <ls_order>.   " table expression (sy-subrc set, no exception)

IF <lv_any> IS ASSIGNED.
  UNASSIGN <lv_any>.
ENDIF.

24.2 Dynamic component access

DATA(lv_field) = `AMOUNT`.
ASSIGN COMPONENT lv_field OF STRUCTURE ls_order TO FIELD-SYMBOL(<lv_value>).
IF sy-subrc = 0.
  <lv_value> = 500.
ENDIF.
ASSIGN COMPONENT 2 OF STRUCTURE ls_order TO <lv_value>.        " by position
ASSIGN ls_order-(lv_field) TO <lv_value>.                        " 7.55+ short form
ASSIGN (lv_global_name) TO <lv_value>.                           " dynamic variable name

24.3 Casting with field symbols

DATA lv_raw TYPE c LENGTH 8 VALUE '20250630'.
FIELD-SYMBOLS <lv_date> TYPE d.
ASSIGN lv_raw TO <lv_date> CASTING.            " view the same memory as type d

24.4 Data references

DATA lr_num TYPE REF TO i.
lr_num = NEW #( 42 ).                          " anonymous data object
lr_num->* = lr_num->* + 1.                     " dereference with ->*

DATA(lr_order) = REF #( ls_order ).            " reference to existing object
lr_order->amount = 100.                        " structure component via ->

DATA lr_any TYPE REF TO data.
CREATE DATA lr_any TYPE (lv_type_name).        " dynamic type
ASSIGN lr_any->* TO FIELD-SYMBOL(<lv_dyn>).    " work with it through a field symbol

LOOP AT lt_orders REFERENCE INTO DATA(lr_row).
  lr_row->status = 'O'.
ENDLOOP.

24.5 Field symbols vs references

| | Field symbol | Data reference | |-|--------------|----------------| | Nature | Alias, no own value | Variable holding an address | | Store in tables / attributes | No | Yes | | Pass around / return | Limited | Yes | | Anonymous objects | Via ASSIGN lr->* | NEW, CREATE DATA | | Check | IS ASSIGNED | IS BOUND / IS NOT INITIAL | | Typical use | Fast loops, dynamic component access | Generic containers, dynamic data, object graphs |