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: 

do_sum in alv grid - insert some field's sum separately

0 Kudos

I got three fields - A, B, C.

They are P type.

I use do_sum = 'X' at A, B.

But C = A / B * 100.

my question is :

I want to use do_sum at A, B.

But C is percent that I have to calculate.

Can I use do_sum and  insert C field value into a sum row together?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Jaime ,

As you are telling that C is Percentage Value which is coming from A and B hence there is no need to Sum the C values as sum of Percentage not gives any proper meaning .

So while filling the Field catalog in ALV Grid display use DO_SUM for only A and B and do not use it for C .

Thanks

Mallikarjun

8 REPLIES 8

Former Member
0 Kudos

Hi Jaime,

You can pass the value 'C' to get Average value at the bottom.

w_catalog-do_sum = 'C'.   " C = Average

w_catalog-do_sum = 'X'.   " X = Sum

In your case you need to loop the internal table (final) and you need to do manual calculations for each row, what you have written (C = A / B * 100) if am wrong please correct me.

Once you do this you will get percentage of the value at column 'C', and value will be the type of 'P (packed decimal),

In catalog of filed 'C' add below code.

w_catalog-do_sum = 'C'. " C = Average

Let me know for further clarification.

Reg

Akshath

0 Kudos

Thank you, but I don't need average value.

Former Member
0 Kudos

Hi Jaime ,

As you are telling that C is Percentage Value which is coming from A and B hence there is no need to Sum the C values as sum of Percentage not gives any proper meaning .

So while filling the Field catalog in ALV Grid display use DO_SUM for only A and B and do not use it for C .

Thanks

Mallikarjun

0 Kudos

I understand what you are saying.

But I must display C field value for percentage of sum(A, B).

I know how make sum row without do_sum. ( Using COLLECT.)

But it is inconvenient.

So, if the other way is exist, I want to know that.

0 Kudos

Hello,

I think in alv it's not possible. Best solution is populate your final table and make sum and average left other fields blank.

Thanks,

Abhijit

0 Kudos

Hi Jaime ,

I think your requirement is not possible using DO_SUM in ALV .So you can do this one by programmatic only .

After filling your final internal table completely. Loop your final internal table one more time and sum up all the values(A and B) into an work area and after getting sum of A and B fields calculate the C field as per your mentioned formula and append this work area to your final internal table .If you want last line(SUM) to be displayed in Yellow color please go through the below link and make it as yellow .

http://www.sapdev.co.uk/reporting/alv/alvgrid_color.htm

Thanks

Mallikarjun

0 Kudos

I already did that.

Anyway, the other way is not exist.

Thank you so much for your answers!

0 Kudos

You're right.

In my opinion,

1. Copying CL_GUI_ALV_GRID.

2. Making CBO class.

3 Modifying standard source of do_sum.

 

=> I think this way will solve my problem.

But it is excessive way.

 

Eventually, I made a sum row by collecting.