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

DELETE Duplicates seems to delete the line with values!

Hi there

I am using the following 2 lines of code to omit duplicate lines from my data is there are more than 1 matnrs.

sort part_data by matnr.

delete ADJACENT DUPLICATES FROM part_data COMPARING matnr.

The trouble is, this seems to stop 3 of my columns from displaying the values. Stock_days and stock_months both show as 0.

If I used COMPARING ALL FIELDS instead, does this mean that the code would show lines with stock_days and stock_months if they have a value greater than zero but one line per each matnr.

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 Jun 16, 2008 at 07:07 PM

    Hi,

    Use

    delete ADJACENT DUPLICATES FROM part_data.

    This will compare all the fields.

    Thanks

    Vikranth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 07:07 PM

    Hello

    If you use COMPARING ALL FIELDS will delete the lines that have the same content, not the ones that have greater or less value than zero...

    Bye

    Gabriel P.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 07:08 PM

    hi Katie,

    This is how delete adjacent duplicates work for a general scenario ...

    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.

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2008 at 09:46 PM

    You can use the following -

    sort itab.

    delete adjacent duplicates from itab comparing all fields.

    award me points if it helps.

    Thanks,

    Sheel

    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.