Application Development 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: 

Duplicate entries

Former Member
0 Kudos

Hi all,

I would like to fetch duplicate entries which are already in my internal table. I need to display only the duplicate entries. (still ahve to continue with some operations after that) so plz provide me with the details.

Issue resolving answer will be suitably rewarded.

Rgds,

a new HR - Abaper.

6 REPLIES 6

Former Member
0 Kudos

Hi,

you can delete the duplicated entries with

DELETE ADJACENT DUPLICATES FROM itab

To see the deletes rows, move all entries before deleting into an other internal table and check then with loop the missing entries.

Regards

Nicole

Former Member
0 Kudos

declear to internal table.

DELETE ADJACENT DUPLICATES FROM itab_dummy.

loop at itab into wa. orginal

read table itab into wa with key field wa_dummy.dummu

delete wa from itab. delete record

endloop.

Former Member
0 Kudos

Hi,

Please use the below code format to display the duplicate entries:

itab1[] = itab[].

loop at itab1.

loop at itab where condition (for checking duplicate).

write : / itab.

display itab1 where condition for checking duplicate.

endloop.

endloop.

Use this if this helps you and reward if works.

Thank you...

Former Member
0 Kudos

i dont want to delete those duplicate entries. I just want to fetch them in order to perform some other action. I hope I am clear.

former_member404244
Active Contributor
0 Kudos

hi,

Do like this

first sirt both the internal tables by the field on which u want duplicate entry

ITAB2[] = ITAB1[].

sort itab1 by field1.

sort itab2 by field2.

LOOP AT ITAB1.

READ TABLE ITAB2 WITH KEY FIELD1 = ITAB1-FIELD1.

IF SY-SUBRC EQ 0.

MOVE DATA TO ITAB3.

APPEND ITAB3.

ENDIF.

ENDLOOP.

NOW ITAB3 WILL HAVE DUPLICATE ENTRIES.

else

u can do like this also

V_INDEX = 2.

LOOP AT ITAB1 INTO WA.

READ TABLE ITAB1 INTO WA1 INDEX V_INDEX.

IF WA1-FIELD1 = WA-FIELD1.

MOVE DATA TO ITAB2.

APPEND ITAB2.

ENDIF.

CLEAR : WA,

WA1.

V_INDEX = V_INDEX + 1.

ENDLOOP.

Now itab2 will have duplicate entries

Regards,

Nagaraj

0 Kudos

i have used similar code (as in ur second option) I am sending u this code too... plz help me thru.

FORM duplicate .

data: j type i value 1,

wa_qid like i_outtab-qid.

do.

read table i_outtab index j.

if sy-subrc <> 0.

exit.

endif.

wa_qid = i_outtab-qid.

loop at i_outtab.

if sy-tabix eq j.

if wa_qid ne i_outtab-qid.

delete i_outtab index sy-tabix.

endif.

else.

j = j + 1.

endif.

endloop.

enddo.

ENDFORM. " duplicate