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

delete duplicates

Former Member
0 Likes
769

want to delete all occurances (not just the adjacent duplicates) from an internal table where certain fields are duplicated.

I tried 'DELETE duplicate entries FROM it_name' but got an error saying 'Between Delete and Duplicate, Adjacent is missing'.

Anyone know how I can do this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
736

Hi Venkat,

see this code.

u can delete duplicates from ur records like this.

DATA: BEGIN OF connection,

cityfrom TYPE spfli-cityfrom,

cityto TYPE spfli-cityto,

distid TYPE spfli-distid,

distance TYPE spfli-distance,

END OF connection.

DATA connection_tab LIKE SORTED TABLE OF connection

WITH NON-UNIQUE KEY cityfrom cityto

distid distance.

SELECT cityfrom cityto distid distance

FROM spfli

INTO TABLE connection_tab.

DELETE ADJACENT DUPLICATES FROM connection_tab.

kindly reward if found helpful.

cheers.

hema.

5 REPLIES 5
Read only

former_member156446
Active Contributor
0 Likes
736

Hi Venkat

try this


sort table it_name by f1 f2.
delete adjacent duplicates from it_name comparing F1 F2.

Award points for helpful answers

Edited by: Jackandjay on Jan 27, 2008 12:21 AM

Read only

former_member188829
Active Contributor
0 Likes
736

Hi,

Before using Delete adjacent duplicates key word...You need to sort the itab..(internal table)..

SORT ITAB BY FIELD.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING FIELD.

Read only

Former Member
0 Likes
737

Hi Venkat,

see this code.

u can delete duplicates from ur records like this.

DATA: BEGIN OF connection,

cityfrom TYPE spfli-cityfrom,

cityto TYPE spfli-cityto,

distid TYPE spfli-distid,

distance TYPE spfli-distance,

END OF connection.

DATA connection_tab LIKE SORTED TABLE OF connection

WITH NON-UNIQUE KEY cityfrom cityto

distid distance.

SELECT cityfrom cityto distid distance

FROM spfli

INTO TABLE connection_tab.

DELETE ADJACENT DUPLICATES FROM connection_tab.

kindly reward if found helpful.

cheers.

hema.

Read only

Former Member
0 Likes
736

it is "delete adjacent duplicates from itab comparing all fields

Edited by: Satish Kumar NRB on Jan 27, 2008 9:27 AM

Read only

Former Member
0 Likes
736

it is "delete adjacent duplicates from itab comparing all fields

Cheers,

satish