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

how to use at

Former Member
0 Likes
1,292

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,249

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.......

11 REPLIES 11
Read only

Former Member
0 Likes
1,249

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

Read only

Former Member
0 Likes
1,249

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.

Read only

Former Member
0 Likes
1,249

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>.

Read only

Former Member
0 Likes
1,250

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.......

Read only

Former Member
0 Likes
1,249

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

Read only

0 Likes
1,249

hi,

try using on change of instead of using at new

aparna

Read only

Former Member
0 Likes
1,249

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

Read only

Former Member
0 Likes
1,249

Swetha,

just use 'AT NEW LAND'.. insetad of two at new 's

it vl solve ur prob.

Regards,

Sujatha.

Read only

Former Member
0 Likes
1,249

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

Read only

Former Member
0 Likes
1,249

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

Read only

Former Member
0 Likes
1,249