CDS

Delete adjacent duplicates in CDS Views

It is rather difficult to do a delete adjacent duplicates in a CDS view. This is a bummer especially if you are building a Fiori Element app and a non-key criterion is used as a filter for selection. It can return multiple entries where key elements are the same and which can lead to duplicate rows in the final list.

I have struggled with it and have wondered why this simple feature is not there in CDS view. This is what I have understood.

First of all, you can do delete adjacent duplicates (or sort of) by using group by syntax. But this only works if you using Basic View as the Consumption view – or in other words, you selection logic is simple enough to fetch data from a database table and show it as a report. Real business scenario are seldom so simple.

But if you have let’s say several basic views and then intermediate views and finally a consumption view, then the problem represents itself. The problem comes because we want to get rid of the duplicates (generally in the consumption view) in some other view and not in the view where duplicates have come. When we execute a complex CDS query, the command goes from consumption to basic view but data is fetched and then adjusted from basic view to consumption view.

That’s is why, usually we create a different view and add some other logic to get rid of the duplicates (beyond CDS commands). And I think, this is why we do not have a syntax or annotation for deleting adjacent duplicates.

What do you think. How do you remove duplicated from Fiori Elements.

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)

Follow by Email
Twitter
LinkedIn
LinkedIn
Share