‎2006 Aug 02 2:43 AM
HI all
i've one internal table in that table one field like vendor name,
for example
Begin of ittab_ven,
venname like lif1-lifnr,
end of ittab_ven.
in that table've 10 or 15 fields based one my queries,
i want to store each vendor in each variable
for example
loop at ittab_ven
vendor1 (variable1) = ittab_ven
vendor2 (variable1) = ittab_ven
endloop.
how can i do that
anybody help pls
‎2006 Aug 02 2:52 AM
Hi Muthu,
You can do it this way:
data: lv_tabix type sy-tabix,
lv_vendor1 type lfa1-lifnr,
lv_vendor2 type lfa1-lifnr,
lv_vendor3 type lfa1-lifnr,
lv_vendor4 type lfa1-lifnr,
lv_vendor5 type lfa1-lifnr,
lv_vendor6 type lfa1-lifnr,
lv_vendor7 type lfa1-lifnr,
lv_vendor8 type lfa1-lifnr,
lv_vendor9 type lfa1-lifnr,
lv_vendor10 type lfa1-lifnr.
loop at ittab_ven,
lv_tabix = sy-tabix.
case lv_tabix.
when 1.
move ittab_ven-vendor to lv_vendor1.
when 2.
move ittab_ven-vendor to lv_vendor2.
when 3.
move ittab_ven-vendor to lv_vendor3.
when 4.
move ittab_ven-vendor to lv_vendor4.
when 5.
move ittab_ven-vendor to lv_vendor5.
when 6.
move ittab_ven-vendor to lv_vendor6.
when 7.
move ittab_ven-vendor to lv_vendor7.
when 8.
move ittab_ven-vendor to lv_vendor8.
when 9.
move ittab_ven-vendor to lv_vendor9.
when 10.
move ittab_ven-vendor to lv_vendor10.
endcase.
endloop.
Hope this helps...
P.S. Please award points if found useful.
‎2006 Aug 02 3:21 AM
You can probably use a field-symbol.
I do not have a system available, so I am guessing at the syntax.
field-symbols: <f1>.
data: lv_num(2) type n,
lv_field(20) type c.
loop at ittab_ven.
lv_num = sy-tabix.
clear lv_field.
concatenate lv_field lv_num into lv_field.
condense lv_field no-gaps.
assign lv_field to <f1>.
<f1> = ittab_ven-lifnr.
endloop.
‎2006 Aug 02 4:31 AM
I think Norman's idea is the best way. I think this syntax is correct but it's still Norman's solution (and Viraylab's data definitions).
field-symbols: <f1>.
data: lv_num(2) type n,
lv_field(20) type c.
data:
lv_vendor1 type lfa1-lifnr,
lv_vendor2 type lfa1-lifnr,
lv_vendor3 type lfa1-lifnr,
lv_vendor4 type lfa1-lifnr,
lv_vendor5 type lfa1-lifnr,
lv_vendor6 type lfa1-lifnr,
lv_vendor7 type lfa1-lifnr,
lv_vendor8 type lfa1-lifnr,
lv_vendor9 type lfa1-lifnr,
lv_vendor10 type lfa1-lifnr.
loop at ittab_ven.
lv_num = sy-tabix.
clear lv_field.
concatenate 'LV_VENDOR' lv_num into lv_field.
condense lv_field no-gaps.
assign (lv_field) to <f1>.
<f1> = ittab_ven-lifnr.
endloop.
ps, it will cause problems if there are more entries in the table than defined lv_vendor fields.