‎2008 Jul 17 7:13 AM
I have a structure with 16 fields.
Only one of them contains a value while others are blank.
How do I check which field contains the value?
‎2008 Jul 17 7:17 AM
hi
no shortcut . you have to chek all the fields. i faced the same issue. Only thin which you can do after geeting value in one field skip testing of rest of the fields.
Aditya
‎2008 Jul 17 7:57 AM
How do I skip the testing the rest of the fields after the value is found in one field?
If I use EXIT satement, it comes out of the method while I need it to come out of the If condition only.
‎2008 Jul 17 7:18 AM
Hi,
You can do it in 2 ways,
1. print them in report with WRITE statement and get it.
OR
2. use condition STATEMENT with
IF (strname)-(Fieldname1) IS NOT INITIAL.
write: (strname)-(Fieldname1).
ELSEIF (strname)-(Fieldname2) IS NOT INITIAL.
write: (strname)-(Fieldname2). .
.
.
.
.
.
.
ENDIF.
regards,
Anirban
‎2008 Jul 17 7:18 AM
hi
no shortcut . you have to chek all the fields. i faced the same issue. Only thin which you can do after geeting value in one field skip testing of rest of the fields.
Aditya
‎2008 Jul 17 7:39 AM
Hi,
maybe this is helpful:
DATA gs_structure TYPE z_structure.
DATA gx_struc TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS <gs_components> TYPE abap_compdescr.
FIELD-SYMBOLS <gv_field> TYPE ANY.
gx_struc ?= cl_abap_typedescr=>describe_by_data( gs_structure ).
LOOP AT gx_struc->components ASSIGNING <gs_components>.
ASSIGN COMPONENT <gs_components>-name OF STRUCTURE gs_structure TO <gv_field>.
CHECK NOT <gv_field> IS INITIAL.
* do something
EXIT.
ENDLOOP.
Regards Rudi