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: 

ALV Sum Percentage Problem

Former Member
0 Kudos

I have got following prob in ALV

Say I have 3 columns like

Total Sales | City Sales | Percentage

50 10 20

40 20 50

Now when I make a sum of thse using ALV I will get

90 30 70

The sum of percentage will not be correct of course.

How should I go about this ?

Cheers,

Nitin

7 REPLIES 7

Former Member
0 Kudos

Hi,

If u want to find the percentage of percent column, u can append a line at the end and do it manually, instead of summing by ALV.

former_member221770
Contributor
0 Kudos

Nitin,

ALV does not have functionality to derive percentages as you specified. It only has basic summing functionality. As Judith specified, you will need to add the "total percentage" field on a line after the ALV report.

Cheers,

Pat.

Former Member
0 Kudos

Hi Nitin,

The reason why this will not work is quite simple -

in the first row, you have got 50-10-20, which suggests that <b>20 % of 50 = 10</b>. But how did you get this value 20 in the grid ? You must have done that manually, right ? Either you have manually put the number 20 directly in that cell or you have used some formula in your program to determine the value for each cell of that column.

Similarly, when you do the summation, you will have to manually calculate the value of the percentage. How will the ALV Grid know that you want to display the percentage in that column ?

There's just another idea that occurred to me. I have not tried it out, but it may work out. you can display an ALV grid as an Excel sheet (provided your local machine has got Excel installed). In that view of the ALV list, you can use the formula function of Excel to derive the percentages at run time.

Regards,

Anand Mandalika.

0 Kudos

Hi Anand,

I understand that there is no way with ALV to understand the column is showing percentage.

What I want is when I press sum button on ALV toolbar, can I override the sum performed on Percentage column only ...... Possible using some event or fm ?

Regards,

Nitin

0 Kudos

Hi Nitin,

I imagine that it is possible. You can try out the events TOOLBAR / BUTTON_CLICK etc., I have never done this till now, but I think it should work. Let me know if you need further assistance.

Regards,

Anand Mandalika.

0 Kudos

Nitin,

I am not sure but try this :

<b>No_totalline(1)</b> TYPE c : Removes the option of having totals after sub-totals.

Value set: SPACE, 'X'

'X' = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are flagged DO_SUM = 'X' in the field list

<b>AND</b>

No_subtotals(1) TYPE c : No subtotals possible

Value set: SPACE, 'X'

'X' = no subtotals.

<b>IN LAYOUT</b>

0 Kudos

Hi Nitin,

For this use BEFORE_USER_COMMAND event.

using this you can write your required code before the actual functionality of the toolbar button (sum in this case ) executes.

Rgds

Kalyan