2006 Dec 07 5:57 AM
Hi,
I have one query regarding loop.
suppose i have fields like f1,f2,f3,..f5.
now all the data's are stored in wa.
is it possible to make the loop like
loop at wa-f1 to wa-f5.
processing.
endloop.
Is it process for wa-f1, wa-f2, wa-f3, wa-f4, wa-f5.
If it is not possible then pls suggest me.
Hi,
I have one query regarding loop.
suppose i have fields like f1,f2,f3,..f5.
now all the data's are stored in wa.
is it possible to make the loop like
loop at wa-f1 to wa-f5.
processing.
endloop.
Is it process for wa-f1, wa-f2, wa-f3, wa-f4, wa-f5.
If it is not possible then pls suggest me.
2006 Dec 07 6:02 AM
hi
good
yes that is not possible to looping a work area as you have mentioned you can directly write as
LOOP AT WA
processing.
thanks
mrutyun^
2006 Dec 07 6:04 AM
Hi
you have to assign the wa like
data: wa like t_wa occurs 0 with header line.
loop at t_wa.
processing.
endloop.
If exactly know ur requirement, then find the right solution.
2006 Dec 07 6:09 AM
Hi,
It's not possible as the way you told.But you can access all the fields of the internal table inside the loop.
data : itab type standard table of mara,"Internal table
wa type mara."work area
select * from mara into table itab.
loop at itab into wa.
write : / wa-matnr."here matnr is a field.similarly all the fields of internal table and workarea are available inside loop.
endloop.
2006 Dec 07 6:35 AM
Hi,
i think u have all of ur data in a internal table. you can just loop at that internal table into a work and do the processing on it.
example:
data: itab type table of mara,
wa type mara.
loop at itab into wa.
processing.
endloop.
or u can just use same work area again and again for the loop. but it is necessary to clear its contents at the end of the loop.
Regards
vamsi
2006 Dec 07 8:26 AM
Salil,
If I understand you right, your fields are different fields with different names within the same structure like this:
data: begin of wa,
f1 type p,
f2 type p,
f3 type p,
...
f12 type p,
end of wa.
If this is so, then LOOP is not a way to attack your problem. Instead have a look at this construct:
DO 12 TIMES VARYING f FROM wa-f1 NEXT wa-f2.
processing. Here just sum up the values
tot_f = tot_f + f.
ENDDO.
You have to make sure all fn fields are of same type and are separated from each other with the same distance.
2006 Dec 07 8:39 AM
wa (work area) is like a tempoary row (header for the itab).
so u cant use loop for a row of data.
u can use loop for internal table... & if u declare your itab with header line, u may not need to use wa at all.
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |