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

how to get rid of duplicate records

hi

how can i get rid of the duplicate records that i have in my internal table? knowing that i already used select distinct ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:04 AM

    just sort ur internal table itab via the key field ..as follows -

    sort itab by field1

    then use -

    Delete adjacent duplicates from itab.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:07 AM

    Sort your internal table with fields and use delete adjacent duplicates ..

    SORT i_tab BY field1 field2.

    DELETE ADJACENT DUPLICATES FROM i_tab COMPARING field1.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:04 AM

    hi Essa,

    Immediately after your select statement use <b>delete adjacent duplicates</b> statemet ..

    DELETE ADJACENT DUPLICATES FROM itab. 

    Additions

    1. ... COMPARING f1 f2 ...

    2. ... COMPARING ALL FIELDS

    Effect

    Deletes neighboring, duplicate entries from the internal table itab . If there are n duplicate entries, the first entry is retained and the other n - 1 entries are deleted.

    Two lines are considered to be duplicated if their default keys match.

    The return code value is set as follows:

    SY-SUBRC = 0 At least one duplicate exists, at least one entry deleted.

    SY_SUBRC = 4 No duplicates exist, no entry deleted.

    Message was edited by:

    Santosh Kumar Patha

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:06 AM
    sort itab by field1 field2.
    delete adjacent duplicates from itab comparing field1 field2.
    
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:16 AM

    thanks for helping me out

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:17 AM

    hi Essa,

    <b> Please Mark the helpful answers</b>

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

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.