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: 

Delete duplicate row from internal table

Former Member
0 Kudos

DELETE ADJACENT DUPLICATES FROM itab.

Deletes the all duplicate row except first one.

Searching for the all the duplicate rows should get deleted except last one.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Reshma,

Before using the DELETE ADJACENT DUPLICATES......You should always sort the internal table. Now if the records are as follows :

001 abc 10000

001 abc 1000

002 def 20000

002 def 2000

003 xyz 30000

003 xyz 3000

Out of these entries suppose you want only three entries that is

001 abc 1000

002 def 2000

003 xyz 3000

now sort the table by amt ascending. then the entries in the table will be

001 abc 1000

001 abc 10000

002 def 2000

002 def 20000

003 xyz 3000

003 xyz 30000

Now DELETE ADJACENT DUPLICATES....

Check your entries. This will solve.

Regards,

Swapna.

6 REPLIES 6

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

Is there any other key in the itab on which you can short itab and then SORT itab by that key and then delete itab comparing that key.

Former Member
0 Kudos

Hi Reshma,

Sort the itab in descending order of the fields that you want the records for, and then write DELETE ADJACENT DUPLICATES FROM itab. When you'll sort by descending order, the last record should be on the top and will be kept deleting the remaining records.

regards,

Advait

Former Member
0 Kudos

Hi,

DELETE ADJACENT DUPLICATES FROM itab comparing field1,field2......or all fields.

But before doing this...you have to sort your internal table with respect to those field1,field2....then use the syntax of Delete.

Arunima

Former Member
0 Kudos

Hi,

sort the internal table with some Keys as per your requirement and then use Command:

DELETE ADJACENT DUPLICATES FROM itab

COMPARING <field names on which you sorted the table>

this will delete the duplacte records by comparing the fields.

Former Member
0 Kudos

use the below syntax.

sort itab by <fields1> <field2> .......... ascending.

delete adjacent duplicates from itab.

Former Member
0 Kudos

Hi Reshma,

Before using the DELETE ADJACENT DUPLICATES......You should always sort the internal table. Now if the records are as follows :

001 abc 10000

001 abc 1000

002 def 20000

002 def 2000

003 xyz 30000

003 xyz 3000

Out of these entries suppose you want only three entries that is

001 abc 1000

002 def 2000

003 xyz 3000

now sort the table by amt ascending. then the entries in the table will be

001 abc 1000

001 abc 10000

002 def 2000

002 def 20000

003 xyz 3000

003 xyz 30000

Now DELETE ADJACENT DUPLICATES....

Check your entries. This will solve.

Regards,

Swapna.