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

ABAP Internal table query

Former Member
0 Likes
421

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

1 ACCEPTED SOLUTION
Read only

0 Likes
382

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,

2 REPLIES 2
Read only

Sridharnekkanti
Active Participant
0 Likes
382

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.

Read only

0 Likes
383

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,