11-26-2007 12:45 PM
hi
i have sorted the internal table by field f1 and i need to insert the first row for each f1 entry.
I tried AT NEW f1. But that doesnt seem to work.
Kindlly help.
Thanks.
11-26-2007 12:49 PM
11-26-2007 12:53 PM
Hi here it is..
SORT it_gir BY age ASCENDING.
LOOP AT it_gir INTO wa_gir.
AT NEW age.
MOVE-CORRESPONDING wa_gir TO wa_final1.
APPEND wa_final1 TO it_final1.
ENDAT.
ENDLOOP.
11-26-2007 1:13 PM
Hi riya,
there is widely spear confusion on AT NEW and ON CHANGE OF. I'm sure you did not check or understand the relevant F1 help or WIKI or what ever.
Simply said:
1. AT NEW works for sorted tables only. Sorted by the whole line, that means SORT without any fields addidtion. SORT .
2. AT NEW is triggered only and alöways if the field content OR THE FIELD CONTENT OF ANY FIELD LEFT FROM IT changed.
Regards,
Clemens
11-26-2007 2:23 PM
*--ENSURE THAT age IS FIRST FIELD IN INTERNAL TABLE it_gir while declaring it.....
SORT it_gir BY age ASCENDING.
LOOP AT it_gir INTO wa_gir.
AT NEW age.
<b>*--if there are fields which are getting populated with **** instead of original values....then use below statement...</b>
read table it_gir index sy-tabix.
MOVE-CORRESPONDING wa_gir TO wa_final1.
APPEND wa_final1 TO it_final1.
clear wa_final1.
ENDAT.
ENDLOOP.
now it should definitely work.....
if not check in debugging mode if data exists or not....!!!
Regards
Vasu
11-26-2007 2:27 PM
Hi,
why cant u do like this
SORT it_gir BY age ASCENDING.
it_final[] = it_gir[].
delete adjacent duplicates from it_final[] comapring age.
now it_final contain only unique entries for age field
reward if answered