Skip to Content
-1

Dynamic workarea using Field Symbol - Accessing the field value

Mar 29 at 10:15 AM

27

avatar image
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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Matthew Billingham
Mar 29 at 10:33 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded