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

first row for each entry

Former Member
0 Likes
652

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.

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.

5 REPLIES 5
Read only

rodrigo_paisante3
Active Contributor
0 Likes
628

Hi,

can you post your code? Thanks.

Rodrigo

Read only

0 Likes
628

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.

Read only

Clemenss
Active Contributor
0 Likes
628

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

Read only

Former Member
0 Likes
628

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

Read only

Former Member
0 Likes
628

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