Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

AT END OF and AT NEW fails ...

Hi,

I have a program where i am looping an internal table (say detail table with 3 liens) which has got a column named hdrid with same values. Another table say header exists wit hthe same hdrid, just one record.

In my code I say

LOOP AT t_detail INTO wa_detail.

...

...

AT NEW hdrid.

ENDAT.

AT END OF hdrid.

ENDAT.

ENDLOOP.

Now it so happens that when looping thru my detail table, the AT END OF hdrid is supposed to trigger only when that column in the detail table changes which is like after the 3rd record. But it is triggering when the first record is read !! Also the AT NEW hdrid is also triggering for every record in the detail table !! What could be wrong ? I debugged and checked the value, it is the same as I expected , say 827789. Only when that value changes these two must be triggered..Any tips ?

thks

Tags:
Former Member
Former Member replied

make sure you sort the table before you loop it. Sort the table as below.

if HDRID is first field in the internal table then

sort HDRID field2 field3.....

if HDRID is second field in the internal table then

sort field1 HDRID field3.....

if HDRID is third field in the internal table then

sort field1 field2 HDRID .....

and so on.............

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question