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

removal of duplicated records

..

Message was edited by:

Padma v

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 04:48 AM

    Hi ,

    Can you please specify what exactly is the problem you are facing , as just pasting the code does not serve much purpose.

    Regards ,

    Arun

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2007 at 06:33 AM

    Hi,

    You can remove duplicate records by:

    1. Sort the table

    2. delete adjacent duplicates.

    eg:

    SORT it_ebeln BY ebeln bwart.

    DELETE ADJACENT DUPLICATES FROM it_ebeln COMPARING ebeln bwart mtart .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2007 at 06:33 AM

    if u want to remove duplicate rec from internal table.

    sort itab by f1 f2.

    delete adjacent duplicates from itab comparing f1 f2.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2007 at 06:34 AM

    HI,

    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.

    Addition 1

    ... COMPARING f1 f2 ...

    Effect

    Two lines of the internal table itab are considered to be duplicates if the specified fields f1 , f2 , .... match.

    Addition 2

    ... COMPARING ALL FIELDS

    Effect

    Two lines are considered to be duplicates if all fields of the table entries match.

    Notes

    The DELETE ADJACENT DUPLICATES statement is especially useful if the internal table itab is sorted by fields (whether in ascending or descending order) which were compared during duplicate determination. In this case, the deletion of neighbouring duplicates is the same as the deletion of all duplicates.

    If a comparison criterion is only known at runtime, it can be specified dynamically as the content of a field name by using COMPARING ... (name) ... . If name is blank at runtime, the comparison criterion is ignored. If name contains an invalid component name, a runtime error occurs.

    Comparison criteria - statistically or dynamically specified - can be further restriced by specifying the offset and/or length.

    Note

    Performance

    Deleting a line from an internal table incurs index maintenance costs which depend on the index of the line to be deleted. The runtime depends on the line width of the table.

    For example, deleting a line in the middle of an internal table with 200 entries requires about 10 msn (standardized microseconds).

    Deleting a range of entries with " DELETE itab FROM idx1 TO idx2. " deleting a set of entries with " DELETE itab WHERE ... " only incur index maintenance costs once. Compared with a LOOP , which deletes line-by-line, this is much faster.

    To delete neighboring, duplicate entries from an internal table, use the variant " DELETE ADJACENT DUPLICATES FROM itab. " instead of LOOP constructions.

    Reward if useful

    Regards,

    Pritha.

    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.