Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

LOOP PROCESSING

Former Member
0 Likes
731

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.

6 REPLIES 6
Read only

Former Member
0 Likes
704

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^

Read only

Former Member
0 Likes
704

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.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
704

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.

Read only

Former Member
0 Likes
704

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

Read only

Former Member
0 Likes
704

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.

Read only

Former Member
0 Likes
704

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.