‎2010 Jul 11 9:56 AM
Hi Abapers,
I have an internal table and i want to delete duplicate entries from the internal table. I am doing that by using delete duplicate entries from command. . Now i want to store the deleted messages in another table to show that these duplicate entries were deleted.
Could anyone please tell me how do i do it??
Thanks & Regards,
Akshay
‎2010 Jul 11 12:54 PM
HI,
Try with this code.
ITAB is your internal table
JTAB is the internal table for deleted entries.
jtab = itab.
delete adjacent duplicates from itab comparing <your condition>.
loop at itab.
read table jtab with key <key field> = itab-<key field>.
if jtab-<key field> = itab-<keyfield>.
delete jtab where jtab-<key field>.
endif.
endloop,
‎2010 Jul 11 10:36 AM
Try with this logic.
suppose ITAB is your internal table.
declare one more internal table to store the deleted entries.(DTAB)
sort the internal table ITAB.
LOOP AT ITAB.
IF ITAB EQ OLD.
APPEND ITAB TO DTAB.
ELSE.
MOVE ITAB TO OLD.
ENDIF.
ENDLOOP.
now delete duplicate entries from ITAB using delete duplicate entries command.
you can see the deleted entries in DTAB table.
‎2010 Jul 11 12:54 PM
HI,
Try with this code.
ITAB is your internal table
JTAB is the internal table for deleted entries.
jtab = itab.
delete adjacent duplicates from itab comparing <your condition>.
loop at itab.
read table jtab with key <key field> = itab-<key field>.
if jtab-<key field> = itab-<keyfield>.
delete jtab where jtab-<key field>.
endif.
endloop,