Skip to Content

deleting duplicates in abap cds view

Feb 19 at 07:07 AM


avatar image

In abap cds view we want to delete the duplicates(means any one field values may differ. Whole record is not same). If these duplicates exists, we want to fetch the topmost record from the table.

For example if we have records in the table as mentioned below, I want to fetch the first record in this table

kunnr bukrs name

101 bang xyz

101 bang abc

Can anyone help me in this issue.

Thanks in advance

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Dominik Bigl Feb 20 at 08:13 AM


You can use max( name ) / min( name ) to get a distinct group result.

Here's a similar example with table BUT050:

define view zbut050_group_distinct as select from but050 
    key relnr,
    key partner1,
    key max( partner2 ) as partner2
} group by relnr, partner1

  • BUT050 -> your table
  • relnr -> kunnr
  • partner1 -> bukrs
  • partner2 -> name



10 |10000 characters needed characters left characters exceeded