CDS – 22: If the CDS View Has Aggregate Functions, How to Expand It

The Append-structure concept is used in SE11 to add additional fields to the preexisting table structure. In a same vein, let’s say a CDS-View shows 8 fields from a table or join of multiple tables, and we would like to show 3 more fields from the same data. In that scenario, we can extend the CDS view to show all 11 fields.

But in real projects, every thing is not happy path. You will always find some exceptions which no one teaches you in the training. You learn it the hard way.

If your base CDS-view contains Aggregate-functions like: SUM(), MIN(), MAX(), then during view-extension, it gives below error and you’ll not be able to activate the Extended-View.

In this tutorial, we will discuss how to resolve this error and make your extended-view work. First, let’s design our base-view and extended view.

Base-view ‘ZCDS_FLIGHT’

I have utilized the SFLIGHT table to create a rudimentary ZCDS_FLIGHT CDS-view. Using the aggregate-function SUM(), we are including the following information: the aircraft type (planetype) and the total amount of current bookings (paymentsum) for that specific aircraft type. In this case, the view-name that will be generated in the DDIC and HANA databases is ZCDS_FLIGHT_VIEW. Let’s now expand this CDS-View.

You must choose the Extend-view option when creating an extension in order to construct a CDS extension. Use the screenshot as a guide.

You will receive this extended-view skeleton.

Let’s adjust a few things to meet our needs:

A new field called SEATSOCC (Occupied seats in Economy class) has been added. Since group by clause is used in the base view, it is required here. An error stating that “Parent view contains aggregate function and extension is not possible” appears when we try to activate this extended view. In order to fix this mistake, we must add the annotation ApapCatalog.viewEnhancementCategory to the Parent-View[]. The method for extending the view with CDS view extensions is indicated in this annotation. This array can include the following 4 enums: #GROUP_BY, #NONE, #PROJECTION_LIST, and #UNION.

The extension of fields that have already been chosen is made possible by #PROJECTION_LIST. Aggregated or non-aggregated components may be added to a SELECT list using an aggregated expression and the related modifications of the GROUP-BY clause are allowed with the aid of #GROUP_BY. For our scenario, these two enums are adequate.

The UNION clause can be used with #UNION, and further extensions are prohibited with enum #NONE.

The parent CDS-view “ZCDS_FLIGHT” will appear as follows upon modification:

Changed Parent-View

That’s all; both views are now operational after being activated. This is the finished product:

We are just getting started. We shall continue in order to gain a deeper comprehension of CDS Performance Tuning. Please keep watching.


you may be interested in this blog here :-

How to find BAdIs ?

Oracle database structure diagram

Boosting Customer Service with Salesforce and SharePoint Integration

  • Related Posts

    BRF+: Data Objects, Applications, and Catalogs

    we began our BRF+ series. You will learn about BRF+ inventory, application, and data object generation ideas through this blog. Make sure you click the aforementioned link before continuing to…

    Advanced SAPUI5 – 8 – How to Use Python to Get Weight for SAPUI5 Fiori Apps from the Weigh Scale/Weigh Bridge?

    As promised, I will keep writing on SAPUI5, which is a rather complicated topic for which it is difficult to locate tutorial resources. Today, let’s look at a very real-world…

    Leave a Reply

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

    You Missed

    CDS – 22: If the CDS View Has Aggregate Functions, How to Expand It

    • By Varad
    • January 24, 2025
    • 18 views
    CDS – 22: If the CDS View Has Aggregate Functions, How to Expand It

    BRF+: Data Objects, Applications, and Catalogs

    • By Varad
    • January 23, 2025
    • 36 views
    BRF+: Data Objects, Applications, and Catalogs

    Advanced SAPUI5 – 8 – How to Use Python to Get Weight for SAPUI5 Fiori Apps from the Weigh Scale/Weigh Bridge?

    • By Varad
    • January 22, 2025
    • 37 views
    Advanced SAPUI5 – 8 – How to Use Python to Get Weight for SAPUI5 Fiori Apps from the Weigh Scale/Weigh Bridge?

    How can I configure the SAP PI system and set up NetWeaver Developer Studio (SAP NWDS) for SAP XI/PI/PO?

    • By Varad
    • January 21, 2025
    • 41 views
    How can I configure the SAP PI system and set up NetWeaver Developer Studio (SAP NWDS) for SAP XI/PI/PO?

    An Object-Oriented Approach to Emailing a PDF Attachment

    • By Varad
    • January 20, 2025
    • 51 views
    An Object-Oriented Approach to Emailing a PDF Attachment

    How Can I Modify the Master List Item Selection in SAPUI5 Based on Hash Tag URL Changes?

    • By Varad
    • January 19, 2025
    • 39 views
    How Can I Modify the Master List Item Selection in SAPUI5 Based on Hash Tag URL Changes?