‎2012 Jan 20 5:02 PM
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
‎2012 Jan 20 5:17 PM
‎2012 Jan 20 5:18 PM
HI,
First see in that report from where you are getting that data.Then you can try for deletion.
Regards,
Madhu.
‎2012 Jan 20 6:05 PM
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
‎2012 Jan 20 6:21 PM
if DELETE ADJACENT DUPLICATES delete one duplicate.. why cant you call it twice then.. or DO..ENd. for table line times..
will tht work?
‎2012 Jan 20 6:23 PM
if DELETE ADJACENT DUPLICATES delete one duplicate.. why cant you call it twice then..
since when
‎2012 Jan 20 6:48 PM
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 DUPLICATESwill delete all duplicates, but not the original. The OP wants the original removed as well.
Rob
‎2012 Jan 21 4:26 AM
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
‎2012 Jan 20 8:20 PM
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
‎2012 Jan 20 10:48 PM
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