Skip to Content
avatar image
Former Member

deleting duplicates in abap cds view

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 20, 2018 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



    Add comment
    10|10000 characters needed characters exceeded