‎2006 Jun 05 9:13 PM
Hello,
Can anyone tell me how can I use a dynamic table name:
Something like this:
data my_table(20).
my_table = 'MARA'.
loop at (my_table).
stuff...
‎2006 Jun 05 9:20 PM
‎2006 Jun 05 9:20 PM
‎2006 Jun 05 9:26 PM
Something like this.
report zrich_0001 .
data: itab1 type table of string with header line.
data: itab2 type table of string with header line.
field-symbols: <fs_tab> type table,
<fs_wa>.
itab1 = 'dataa1'. append itab1.
itab1 = 'dataa2'. append itab1.
itab1 = 'dataa3'. append itab1.
itab2 = 'datab1'. append itab2.
itab2 = 'datab2'. append itab2.
itab2 = 'datab3'. append itab2.
assign itab1[] to <fs_tab>.
assign itab1 to <fs_wa>.
loop at <fs_tab> into <fs_wa>.
write:/ <fs_wa>.
endloop.
assign itab2[] to <fs_tab>.
assign itab2 to <fs_wa>.
loop at <fs_tab> into <fs_wa>.
write:/ <fs_wa>.
endloop.
Regards,
Rich Heilman
‎2006 Jun 05 9:30 PM
If you need to reference the actual fields of the internal table, then you can do it like this.
report zrich_0001 .
types: begin of ttab,
fld1(10) type c,
fld2(10) type c,
fld3(10) type c,
end of ttab.
data: itab1 type table of ttab with header line.
data: itab2 type table of ttab with header line.
field-symbols: <fs_tab> type table,
<fs_wa>,
<fs>.
itab1-fld1 = 'dataa1'.
itab1-fld2 = 'dataa2'.
itab1-fld3 = 'dataa3'.
append itab1.
itab2-fld1 = 'datab1'.
itab2-fld2 = 'datab2'.
itab2-fld3 = 'datab3'.
append itab2.
assign itab1[] to <fs_tab>.
assign itab1 to <fs_wa>.
loop at <fs_tab> into <fs_wa>.
do.
assign component sy-index of structure <fs_wa> to <fs>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <fs>.
else.
write: <fs>.
endif.
enddo.
endloop.
assign itab2[] to <fs_tab>.
assign itab2 to <fs_wa>.
loop at <fs_tab> into <fs_wa>.
do.
assign component sy-index of structure <fs_wa> to <fs>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <fs>.
else.
write: <fs>.
endif.
enddo.
endloop.
Regards,
Rich Heilman