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

internal table problems

Former Member
0 Likes
576

Hi All,

I am having an internal table with several entries,

now lets say i have 200 entries then there are 10 each of same keys,

so i want to delete the 9 entries and keep only which has higest date,

so technically i want to reduce 200 to 20 entires, can someone suggest some efficient way of doing that please?

thanks,

Hitesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
537

Hi,

Sort the internal table by date descending & use DELETE ADJECENT DUPLICATES statement.

Or

First sort the table with main key & the date. e.g.:

SORT itab by vbeln ASCENDING date DESCENDING.

Now loop the table & use coantrol break At new VBELN. And append the values to another internal table at new sales order.

at last use the following to assing the contenets of the 2nd internal table to main internal table.

ITAB1[] = ITAB2[].

Reward points if helpful answer.

Ashvender

5 REPLIES 5
Read only

Former Member
0 Likes
537

hi,

sort our internal table by date field as

SORT ITAB BY DATE.

and use DELETE ADJACENT KEYWORD to delete duplicate records as

DELETE ADJACENT DUPLICATES FROM ITAB..............

if helpful reward some points.

with regards,

Suresh Aluri.

Read only

Former Member
0 Likes
537

you can:

sort tha table for data

delete adjacent duplicates from table comparing keys.

Message was edited by:

Ierardi Leo

Read only

Former Member
0 Likes
537

Hi,

Let sat ITAB is ur Internal Table with 200 entries.

<b>SORT ITAB BY <Key Fields> <Date field> DESCENDING.</b>

<b>DELETE ADJACENT DUPLICATE ENTRIES FROM ITAB COMPARING <Key Fields> .</b>

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>

Read only

Former Member
0 Likes
538

Hi,

Sort the internal table by date descending & use DELETE ADJECENT DUPLICATES statement.

Or

First sort the table with main key & the date. e.g.:

SORT itab by vbeln ASCENDING date DESCENDING.

Now loop the table & use coantrol break At new VBELN. And append the values to another internal table at new sales order.

at last use the following to assing the contenets of the 2nd internal table to main internal table.

ITAB1[] = ITAB2[].

Reward points if helpful answer.

Ashvender

Read only

Former Member
0 Likes
537

Hi,

Do it like this

<b>Sort itab by date descending.</b>

<b>Delete adjacent duplicates from itab comparing date.</b>

It wll delete all the adjacent duplicate entries by checking date.

I think it will solve your problem.

Award points if use ful.

Regards,

Kishore