CDS Views on HANA perform aggregate calculations like SUM at the database layer for optimal performance, and the HAVING clause enables filtering aggregated results based on conditions such as sum values greater than a threshold.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
116 - ABAP on HANA - CDS View - Aggregate Functions Part2Added:
Hello everyone. We will continue that topic about on Hana and currently we are covering CDS view and in the last video we started with the aggregate functions into the CDS view. We took one requirement based upon that requirement, we created the CDS view.
Now into this particular video, firstly we will check the output of this particular CDS view.
I will run this CDS view.
Now I will provide that date as that input.
I will go for same to same date.
You can take any test case of your system, yes.
I will go for open data preview. We need to pass that date in YYYYMMDD format.
Now if I will check the result 97159 euro, yes.
1 lakh 10,000, yes. GBP, yes.
240 INR, 1,000 USD. And we got the same to same result. And have you seen how performance effective it is? We all know this CDS view runs on that database layer. From that database layer itself, we are getting the amount sum of this particular NETWR column. We have not written anything or we have not written any logic on the application layer to make the sum of this NETWR column. From that database itself, it is making that sum and we are getting that result onto that application layer. Now I will go for the next part. I will simply create a program and I will use this CDS view there.
I will go to SC38 transaction code and I will create a program.
This is our 11th number program. Yes.
I will go for create.
I will give that description.
To make some of amount based upon creation date.
I will choose that type as executable program.
I'll go for package.
I'll stimulate.
Yes.
Now, how I will take a input into this particular program through parameters.
Here, intentionally, I will take a different name so that I can show you this is program parameter name and this is CDS view parameter name.
P underscore date type ERDAT.
I will provide the selection text.
And then I will write a query for that particular CDS view.
Go to text elements.
DDIC reference.
This is coming from data element.
Now, I will write a query.
Select star from ZCDS view 14 demo.
Now I will pass. What is our CDS view parameter name?
P underscore ERDAT is equal to What is our program parameter? P underscore date. You all know all host variables must be prefixed with at direct.
Now I will write into table at the rate data.
Now I will go for LT underscore date.
Now I will simply go for the class, the demo class.
Pattern a back object patterns.
Now I will choose the method display.
Now I will use LT underscore date.
So whatever the input we will pass to the program, that will go to the parameter of this CDS view. It will fetch that data from VBAK table, yes.
And we will get that data into this internal table and we are displaying this internal table.
I'll pass the same to same date here.
And you can see we got the same to same result. Now we will go for another part of the requirement. How we can go for filtration here? So as of now, yes, we have simply made the sum, we have understood the group by clause. Now anyone can ask the question in the interview. So, have you applied the filtration in the CDS view? Suppose, if you want to filter some data based upon some condition, yes? So, whenever you want to filter that data, we'll simply filter using the having clause. We'll simply use the having clause. So, I will take a requirement first. Let's see as of now what we are getting. The output which we are getting 97159, 110000, means 110,000, 241,000.
But, customer is saying I just want to see only those records where the sum is greater than 1,000. If the sum is less than 10,000 If the sum is less than 1,000, it does not make any sense for me. Whenever the amount is greater than greater than 1,000, I only want to see that particular result, yes?
Currency does not matter, yes? One Suppose, greater than 1,000, it can be 1,001 GBP, it can be 1,001 EUR, 1,001 INR, 1,001 USD. But, customer want that 1,000 greater than 1,000 record customer want in the output. Where the sum of the amount is greater than 1,000. So, we'll simply see how we can filter based upon that.
So, what I will write? I will simply simply go for having clause here.
So, I will write having.
Now. Now, which particular thing you want to filter? Where sum of NETWR column is greater than 1,000.
So, this is the way how you can go for filtration if someone ask in the interview, yes, have you filtered, yes, that data whatever is in the CDS view?
So, yes, we can go for filtration or we can apply the filtering using the having clause. Now, I will go for syntax check.
I will simply go to activation and we'll see. Now, previously we are getting four records in the output. Now, we will only only get that two records.
So, I will run.
Run as Now, I will go for date.
Suppose date is 2024 02 18.
Yes, now you can see other two records are not coming, yes. Now, if I'll check that program also, this is our program.
If whenever I will run Now, you can see. So, what is the summary of this particular video? In this video, firstly, I run the CDS view, we are getting the result. And the best part is sum is calculating on the database layer and we are getting the result here. So, performance effective, yes.
After that, I created the program. In that program, we simply call that CDS view, we got the expected result. After that, we covered, yes, if I want to apply some filtration into the result, so how I can apply? So, you can apply the filtering through having clause. So, I have written having where sum of NETWR is greater than 1,000. I passed that condition and we have got only the two results in the output.
So, that's it in this video. Thank you.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
🚀 BCS613C Compiler Design | Module 1 to 5 Schema Evaluation 🔥 | VTU 6th Sem 💯 #VTU #bcs613c #exam
Pranavaa-y4y
104 views•2026-06-02











