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: 

DELETE Duplicates seems to delete the line with values!

Former Member
0 Kudos

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.

4 REPLIES 4

Former Member
0 Kudos

Hi,

Use

delete ADJACENT DUPLICATES FROM part_data.

This will compare all the fields.

Thanks

Vikranth

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

You can use the following -

sort itab.

delete adjacent duplicates from itab comparing all fields.

award me points if it helps.

Thanks,

Sheel