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

How to remove both two duplicates data?

Former Member
0 Likes
1,298

Hi There,

Is anyone knows how to remove both duplicate data? As far as i know is DELETE ADJACENT DUPLICATE, but it is use to remove one of it. but how to remove both?

Please help.

Thanks

9 REPLIES 9
Read only

Former Member
0 Likes
1,259

You'll have to write some custom code for that.

Rob

Read only

madhu_vadlamani
Active Contributor
0 Likes
1,259

HI,

First see in that report from where you are getting that data.Then you can try for deletion.

Regards,

Madhu.

Read only

Former Member
0 Likes
1,259

itab2[] = itab1[].

loop at itab1 into wa_itab1.
read table itab2 with key itab2key = wa_itab1-itab1key.
count = sy-tabix.
delete from itab2 index count.
read table itab2 with key itab2key = wa_itab1-itab1key.
if sy-subrc = 0.
delete from itab1 where itab1key =  wa_itab1-itab1key.
endif.
clear wa_itab1.
endloop.

refresh itab2.

the above code should do what you want.

Edited by: aashrith on Jan 20, 2012 7:06 PM

Read only

surajarafath
Contributor
0 Likes
1,259

if DELETE ADJACENT DUPLICATES delete one duplicate.. why cant you call it twice then.. or DO..ENd. for table line times..

will tht work?

Read only

0 Likes
1,259

if DELETE ADJACENT DUPLICATES delete one duplicate.. why cant you call it twice then..

since when

Read only

0 Likes
1,259

if DELETE ADJACENT DUPLICATES delete one duplicate.. why cant you call it twice then.. or DO..ENd. for table line times..

> will tht work?

There appears to be a misunderstanding.

DELETE ADJACENT DUPLICATES

will delete all duplicates, but not the original. The OP wants the original removed as well.

Rob

Read only

0 Likes
1,259

Thanks Rob.

Sorry it's my mistake . I understand. I just over thought.

If you want to delete record which appearing twice or more, then I propose one logic for that.

Declare an another internal table with all the fields same as in ur original internal table and include one more integer variable(say count).

Wa_itab2-count = 1.
Loop at itab1 into wa_itab1.
Move-corresponding wa_itab1 to wa_itab2.
Collect wa_itab2 into itab2.
End loop.

Now loop again to delete,
Loop itab2 into wa_itab2 where count gt 1.
Delete...
End loop.

-count will represents no of time record exists

Read only

Former Member
0 Likes
1,259

Hi

As I understand your requirement if any record is occuring more than once , you wish to remove the record (with key) completly from the internal table.

While processing the internal table check for record occurences. If its only 1, then move it to your final internal table.

DELETE ADJACENT DUPLICATES will hold all unique records.

Regards

Raj

Read only

Former Member
0 Likes
1,259

Hi,

U can use the below code.

loop at it_xyz into wa_xyz.

data : wa_xyz1 type it_xyz.

if wa_xyz1 = wa_xyz.

delete it_xyz where abc = wa_xyz-abc.

clear wa_xyz1.

else.

wa_xyz1 = wa_xyz.

endif.

endloop.

Give me your hand if it was helpful.

Thanks

Prashanth

Edited by: Thomas Zloch on Jan 20, 2012 11:49 PM