How to dynamically call Field Symbols

It is possible with ASSIGN instruction. Below is an example:

DATA:   lt_mara            TYPE STANDARD TABLE OF mara WITH HEADER LINE,
        parameter_name(10) TYPE c.

parameter_name = 'MATNR'.

FIELD-SYMBOLS: <fs_lt_mara> TYPE mara,
               <fs_value>   TYPE any.

SELECT * FROM mara UP TO 10 ROWS INTO TABLE lt_mara.

LOOP AT lt_mara ASSIGNING <fs_lt_mara>.

  ASSIGN COMPONENT parameter_name OF STRUCTURE <fs_lt_mara> TO <fs_value>.
  IF sy-subrc = 0.
    WRITE: / <fs_value>.
  ENDIF.

ENDLOOP.

Tags:

Abap