‎2011 Apr 14 10:57 AM
Hi Experts,
I am wondering something.
In an ABAP program, datas are extracted from an csv file with many columns (100).
The datas are similar for each columns.
In my internal table, my fields are called field1, field2...Etc.
Is it possible to do a loop to fill these fields.
Something like that:
DO wv_i TIMES.
field(wv_i) = wv_i.
ENDDO.
Where the wv_i is the end of the fieldname.
Thanks.
Nicolas.
‎2011 Apr 14 11:38 AM
Hi
You can do it with field symbols.
Try this.
FIELD-SYMBOLS : <fs1> TYPE ANY.
DATA : field1 TYPE i.
DATA : l_char6 TYPE char6,
l_char1 TYPE c.
START-OF-SELECTION.
DO 1 TIMES.
MOVE sy-index TO l_char1.
CONCATENATE 'FIELD' l_char1 INTO l_char6.
ASSIGN (l_char6) TO <fs1>.
<fs1> = 1.
ENDDO.
WRITE : <fs1>.
‎2011 Apr 14 11:38 AM
Hi
You can do it with field symbols.
Try this.
FIELD-SYMBOLS : <fs1> TYPE ANY.
DATA : field1 TYPE i.
DATA : l_char6 TYPE char6,
l_char1 TYPE c.
START-OF-SELECTION.
DO 1 TIMES.
MOVE sy-index TO l_char1.
CONCATENATE 'FIELD' l_char1 INTO l_char6.
ASSIGN (l_char6) TO <fs1>.
<fs1> = 1.
ENDDO.
WRITE : <fs1>.
‎2011 Apr 18 9:23 AM
Hello,
Thank you ganesh.
Your solution works fine!
Thank you to others too even if I didn't test your solutions.
Nicolas.
‎2011 Apr 14 11:58 AM
try this logic.
data:it_string type table of string.
data:wa_string type string.
data:itab_data type table of XYZ.
data:wa_data type xyz.
do.
read dataset file_path into wa_string.
if sy-subrc = 0.
clear it_string[].
split wa_string at *tab* into it_string.
loop at it_string into wa_string.
assign component sy-tabix of structure wa_data to <fs>.
if sy-subrc = 0.
<fs> = wa_string.
endif.
at last.
append wa_data ti itab_data.
endloop.
else.
exit.
endif.
‎2011 Apr 14 4:10 PM