Skip to Content
-1

Dynamic workarea using Field Symbol - Accessing the field value

PARAMETERS:p_ddic LIKE dd02l-tabname.
DATA gdref TYPE REF TO data.
FIELD-SYMBOLS:<itab> TYPE STANDARD TABLE,
              <wa> TYPE ANY,
              <wa_temp> TYPE ANY.
TRY .
    CREATE DATA gdref TYPE STANDARD TABLE OF (p_ddic).
    ASSIGN gdref->* TO <itab>.
    CLEAR gdref.
    CREATE DATA gdref TYPE (p_ddic).
    ASSIGN gdref->* TO <wa>.
  CATCH cx_sy_create_data_error.
ENDTRY.

SELECT * FROM (p_ddic) INTO TABLE <itab> UP TO 5 ROWS.
IF sy-subrc = 0.
  LOOP AT <itab> INTO <wa>.
*    IF <wa>-land1 = 'IN'.
*    ENDIF.
  ENDLOOP.
ENDIF.

Is there a way to access the dynamic field symbols workarea by field name ? I had searched in SCN and it seems the below are the only possible ways.

WHILE sy-subrc = 0. 
  ASSIGN COMPONENT sy-index OF STRUCTURE <wa> TO <comp>. 
  WRITE / <comp>. 
ENDWHILE
or
ASSIGN COMPONENT 'MATKL' OF STRUCTURE <wa> TO <comp>.
But I want to know if the below way can be possible.
IF <wa>-land1 = 'IN'.
ENDIF

Thanks,

K.Kiran.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 29 at 10:33 AM

    "But I want to know if the below way can be possible. IF <wa>-land1 = 'IN'. ENDIF"

    Unless <wa> is statically typed, no, it's not possible.

    Add comment
    10|10000 characters needed characters exceeded