‎2007 Apr 12 11:50 AM
Hi all,
i have one internal table with following fields and also soe other fields.
Kkber land
Ch24 ch
Ch24 al
Ch28 ch
i loop at this internal table as
loop at itab.
at new kkber.
at new land.
......do some calc
endat.
endat.
endloop.
if i do like that it is taking the lines ch24 ch and ch28 ch i.e 1 &3 in to consideration but not the ch24 al even though field land is differerent.
Actually what i need is for every dif combinations of kkber and land i have to do some calculations inside the loop.
How to do this.
‎2007 Apr 12 11:54 AM
Hi... Shwetha..
Try this code.....
no need to write at new kkber because at new will compare all the preceding fields in the internal table.
if Kkber land are the first 2 fields of ur internal table then try this code..
i loop at this internal table as
loop at itab.
at new land.
......do some calc
endat.
endloop.
i hope It helps you.....
Reward points if useful......
Suresh.......
‎2007 Apr 12 11:52 AM
just use at new land it will trigger when land will change or kkber will change...
if it is not solved let us know..
regards
shiba dutta
‎2007 Apr 12 11:52 AM
hi,
when u use at new the right hand fields will lose their memory areas and they form as junk characters.
so u'r code is wrong!!!
try using on change of instead.
‎2007 Apr 12 11:54 AM
Hi swetha,
<b>looop at itab.
at new land.
do calculations...
endat.
endloop.</b>
it suffices..because...<b>AT NEW works for every change of the field</b> that is left to the field that we mentioned in at new <fld>.
‎2007 Apr 12 11:54 AM
Hi... Shwetha..
Try this code.....
no need to write at new kkber because at new will compare all the preceding fields in the internal table.
if Kkber land are the first 2 fields of ur internal table then try this code..
i loop at this internal table as
loop at itab.
at new land.
......do some calc
endat.
endloop.
i hope It helps you.....
Reward points if useful......
Suresh.......
‎2007 Apr 12 11:55 AM
hi,
Did u sort the table b4 u used that code?..
control brk :
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb381a358411d1829f0000e829fbfe/content.htm
aparna
‎2007 Apr 12 12:00 PM
‎2007 Apr 12 12:01 PM
Hi Shweta,
Use the below code -
data : flag(1) type c.
loop at itab.
at new kkber.
......do some calc
flag = 'X'.
endat.
if flag is initial.
at new land.
......do some calc
clear flag.
endat.
endif.
endloop.
Hope this helps!
Regards,
Saurabh
‎2007 Apr 12 12:02 PM
Swetha,
just use 'AT NEW LAND'.. insetad of two at new 's
it vl solve ur prob.
Regards,
Sujatha.
‎2007 Apr 12 12:04 PM
Hi Shweta,
AT NEW control command will trigger for every new entry on the SORTed internal table sequence.
SORT ITAB KKBER LAND. If use internal table with control command with AT NEW on LAND, it will trigger this event when new entry with the KKBER LAND combinations comes.So, no need of nesting the AT events.
<b>SORT ITAB KKBER LAND.</b>
loop at itab.
<b>*at new kkber.</b>
at new land.
......do some calc
endat.
<b>*endat.</b>
endloop.
Thanks,
Vinay
‎2007 Apr 12 12:05 PM
Hi.
The order of the columns in your internal table is important.
Suppose that you have:
data:
begin of rw,
f1,
f2,
f3,
f4,
f5,
end of rw,
rw2 like rw,
iw like table of rw.
Then you loop like this.
sort iw.
loop at iw into rw.
at new f2.
perform something using rw-f1 rw-f2.
endat.
endloop.
This 'at new' will be triggered whenever there is a new value of f2 or of any field to the left of f2 in the internal table, that is, whenever there is a new value of f1 or f2.
That is probably exactly what you need.
Be warned, though, that inside the 'at new', rw fields to the right of f2 will not hold their proper values, but contain asterisks. There are ways round this, for example:
sort iw.
loop at iw into rw.
rw2 = rw.
at new f2.
rw-f3 and rw-f4 will contain asterisks
so use the fields from rw2
perform something_else using rw2-f1 rw2-f2 rw2-f3 rw2-f4.
endat.
endloop.
Hope this helps,
John
‎2007 Apr 12 12:06 PM
this help u use on change of
http://help.sap.com/saphelp_46c/helpdata/en/34/8e73516df74873e10000009b38f9b8/frameset.htm
al the best!!..
Aparna