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 average calculation without zero values

Former Member
0 Kudos

Hi Experts,

I am using the ALV grid for report output, able to get the average values and it's working fine.

User wants the average calculation only for non-zero values, meaning...

1st row = 50.00

2nd row = 20.00

3rd row = 0.00

4th row = 40.00

5th row = 0.00

In this case current output is '110.00 / 5 = 22. it's working fine.

User requriement is 110 / 3 = 36.67. Is this functionallity possible in ALV ?.

Let me know your valueable suggestion.

Thanks

Raj

6 REPLIES 6

former_member181962
Active Contributor
0 Kudos

Hi raj,

Do not go for the standard totalling or average function in the ALV.

instead do the math in your internal table only and have it as a the last line/

like

loop at itab.
if itab-value <> 0.00.
v_total = v_total + itab-value.
count = count + 1.
endif.
at last.
v_average = v_total / count.
clear itab.
itab-value = v_average.
append itab.
endat.
endloop.

former_member188685
Active Contributor
0 Kudos

>In this case current output is '110.00 / 5 = 22. it's working fine.

>User requriement is 110 / 3 = 36.67. Is this functionallity possible in ALV ?.

It is not possible. you need to do that manually and show it at the end.

Former Member
0 Kudos

From ALV you cannot do this.

Instead you need to calculate the average using the values in tables.

And then use it to display.;

Regards,

Lalit Mohan Gupta.

Former Member
0 Kudos

Hi,

I want calculate the percentage of subtotal values in the same row in alv grid report.

Is this functionality is possible...

Plz let me your suggestion.

0 Kudos

Hi,

Did you find the solution for this request (ALV average calculation without zero values). If so, can you please send the details.

0 Kudos

Hi,

Please check this below logic.

clear count.

loop at itab.

if not itab-value = '0.00'.

count = count + 1.

endif.

at last.

v_average = v_total / count.

itab-value = v_average.

append itab.

endat.

endloop.