Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic workarea using Field Symbol - Accessing the field value

kiran_k8
Active Contributor
0 Kudos
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.

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos

"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.

1 REPLY 1

matt
Active Contributor
0 Kudos

"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.