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: 

Can I verify a field-symbol using its component name?

aris_hidalgo
Contributor
0 Kudos

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!

1 ACCEPTED SOLUTION

laxmanakumar_appana
Active Contributor
0 Kudos

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

2 REPLIES 2

laxmanakumar_appana
Active Contributor
0 Kudos

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

former_member186741
Active Contributor
0 Kudos

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.