Skip to Content
author's profile photo Former Member
Former Member

Duplicate entries

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 07:34 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 07:35 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 07:39 AM

    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...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 07:48 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 07:51 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.