Application Development 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: 

Select maximum in itab

Former Member
0 Kudos
159

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

Former Member
0 Kudos
137

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

Former Member
0 Kudos
137


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

Hope this helps.

RK.

0 Kudos
137

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

0 Kudos
137

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

Former Member
0 Kudos
138

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

0 Kudos
137

To keep the latest record by date try this:

Sort itab by order date descending.

Delete adjacent duplicates from itab comparing order.

Regards,

JOy.

0 Kudos
137

Thank you joy,

It worked fine !!!

Former Member
0 Kudos
137

Hi,

Please refer the code below:


sort itab by WADAT_IST descending.

delete adjacent duplicates from itab comparing WADAT_IST.

Thanks,

Sriram POnna.