Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SUM Aggegation in ABAP

rammel
Participant
0 Kudos

Hi,

I'm getting an error with the below code due to the billing month derivation. Is there any other way to do it? Tried in CDS too and didn't work.

1 ACCEPTED SOLUTION

keremkoseoglu
Contributor

For handling such complex aggregate functions, I highly suggest utilizing AMDP (ABAP Managed Database Procedures). In the initial query, construct 'billing_month' and gather other relevant fields into your ITAB1. In the subsequent query, execute a "SELECT SUM" statement from ITAB1.

Alternatively, you can achieve similar functionality using CDS (Core Data Services). Initially, create 'billing_month' and select additional fields in CDS1, and then perform a "SELECT SUM" operation from CDS1 in CDS2. However, based on my experience, the performance of CDS views might suffer when dealing with such nested aggregate functions.

Therefore, my recommendation leans towards AMDP.

2 REPLIES 2

keremkoseoglu
Contributor

For handling such complex aggregate functions, I highly suggest utilizing AMDP (ABAP Managed Database Procedures). In the initial query, construct 'billing_month' and gather other relevant fields into your ITAB1. In the subsequent query, execute a "SELECT SUM" statement from ITAB1.

Alternatively, you can achieve similar functionality using CDS (Core Data Services). Initially, create 'billing_month' and select additional fields in CDS1, and then perform a "SELECT SUM" operation from CDS1 in CDS2. However, based on my experience, the performance of CDS views might suffer when dealing with such nested aggregate functions.

Therefore, my recommendation leans towards AMDP.

Sandra_Rossi
Active Contributor
0 Kudos

You are "getting an error", which one?

You wanting to find "any other way to do it", to do what? What do you have? What do you want to get?

NB: Please post the code as text instead of image, so that one can easily answer by copying your code in order to complete it. Then, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!

NB: to edit your question, use the menu Actions > Edit.