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

Select maximum in itab

Former Member
0 Likes
1,250

How can i keep the records with latest date for every order number in an itab that looks like this.

WADAT_IST VBELN

20060519 |0000268071

20060519 |0000268071

20060524 |0000268071

20060519 |0000268071

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,228

Sort the itab with order and date field...

Sort itab by order date descending.

Regards,

JOy.

Edited by: Joyjit Ghosh on Jul 17, 2008 6:44 PM

7 REPLIES 7
Read only

Former Member
0 Likes
1,228


SORT ITAB BY VBELN ASCENDING WADAT_IST DESCENDING. 
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING VBELN WADAT_IST.

Hope this helps.

RK.

Read only

0 Likes
1,228

Thanks for the help.

But i would like to have only the latest date and this method just deletes same dates and keeps the table with a few dates (different dates) for one vbeln

Read only

0 Likes
1,228

SORT ITAB BY VBELN ASCENDING WADAT_IST DESCENDING. 
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING VBELN.

Now this eliminates all the records except the one order with the latest date.

~RK

Read only

Former Member
0 Likes
1,229

Sort the itab with order and date field...

Sort itab by order date descending.

Regards,

JOy.

Edited by: Joyjit Ghosh on Jul 17, 2008 6:44 PM

Read only

0 Likes
1,228

To keep the latest record by date try this:

Sort itab by order date descending.

Delete adjacent duplicates from itab comparing order.

Regards,

JOy.

Read only

0 Likes
1,227

Thank you joy,

It worked fine !!!

Read only

Former Member
0 Likes
1,227

Hi,

Please refer the code below:


sort itab by WADAT_IST descending.

delete adjacent duplicates from itab comparing WADAT_IST.

Thanks,

Sriram POnna.