08-08-2006 6:23 AM
Hello experts,
I am looping at my field-symbol and I need to know what are its component name.
I need to create an IF or CASE statement checking whether the field-symbol's
component name is equal to that of the value that I declared. I want to do
something like this:
LOOP AT <fs_dyntable> ASSIGNING <wa_dyntable>.
ASSIGN COMPONENT sy-index OF STRUCTURE <wa_dyntable>
TO <component>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
if component name = '2000'.
condition...
elseif component name = '1999'.
condition...
elseif component name = '1998'.
condition...
endif.
endloop.
Again, thank you guys and take care!
08-08-2006 6:32 AM
Hi,
I am not clear on your doubt , but you can use field-symbol fields like below:
* if <component>-fld1 = '2000'.
condition...
elseif <component>-fld1 = '1999'.
condition...
elseif <component>-fld1 = '1998'.
condition...
endif.
endloop.
LOOP AT x_table ASSIGNING <wa_table>.
IF <wa_table>-fld1 EQ 100.
-----your code
ENDIF.
ENDLOOP.
Regards
Appana
08-08-2006 6:32 AM
Hi,
I am not clear on your doubt , but you can use field-symbol fields like below:
* if <component>-fld1 = '2000'.
condition...
elseif <component>-fld1 = '1999'.
condition...
elseif <component>-fld1 = '1998'.
condition...
endif.
endloop.
LOOP AT x_table ASSIGNING <wa_table>.
IF <wa_table>-fld1 EQ 100.
-----your code
ENDIF.
ENDLOOP.
Regards
Appana
08-08-2006 7:18 AM
data : ref_descr type ref to cl_abap_structdescr.
data : it_details type abap_compdescr_tab,
wa_details type abap_compdescr.
ref_descr ?= cl_abap_typedescr=>describe_by_DATA( <wa_dyntable> ).
it_details[] = ref_descr->components[].
loop at it_details into wa_details.
CASE wa_details-name.
WHEN '2000'.
WHEN '1999'.
ENDCASE.
ENDLOOP.