Skip to Content
Oct 18 at 01:29 PM

Reducing Code duplication in Consumption Views


Hello SAP Community,

I am currently creating 3 CDS analytical query views that are very similiar. They have the same restricted and calculated measures, very similar filters and are only different in one where clause and 1-2 fields. Because they are so similar I was looking on how to reduce code duplication and thought that i could build a Cube view with the shared elements and then build the three consumption views on top. This does not work because it does not seem to be possible to have calculated measures in the cube (Annotation \@AnalyticsDetails.query.formula requires it to be an analytical query). Aside from that there are several other annotations that i would have to duplicate in the 3 queries like that.

So next I thought that I maybe could stack Consumption views, so i tried building the base version as a consumption view with \@Analytics.query: true. I then build another consumption view that selects from the first one. While i can activate the views and preview it in Eclipse, I can not view Data in the query browser, the rsrt transaction or the rsrts_odp_dis transaction.

Does anyone have any ideas or recommendations for a good solution here or is the way to go here to have that much code duplication?

Thanks for the help and cheers,