04-10-2013 3:13 AM
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?
04-10-2013 8:57 AM
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
04-10-2013 7:21 AM
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
04-10-2013 10:23 AM
04-10-2013 8:57 AM
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
04-10-2013 10:16 AM
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.
04-10-2013 10:59 AM
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
04-10-2013 11:28 AM
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
04-11-2013 6:16 AM
I already did that.
Anyway, the other way is not exist.
Thank you so much for your answers!
04-11-2013 6:41 AM
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.