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 grid override function

Former Member
0 Kudos
502

Is it possible to override SUM function in alv grid, for example do not count the material if it starts with '4'?

7 REPLIES 7

FredericGirod
Active Contributor
0 Kudos
398

Filter the material and do the sum ... or switch to Excel

Former Member
0 Kudos
398

starts with 4 its just example. I have a huge grid with a lot of interchangeable element, wich of course summing if click sum function, so i need to override it and count interchangeable elements only once

Sandra_Rossi
Active Contributor
398

You can do anything in ABAP, you don't need to always use the standard ALV aggregation functions. Do the SUM yourself.

But remember to keep the ALV the most standard way, not to have too much specific weird results.

You may also add custom buttons to apply specific filters so that to simplify the task, and make it clear to the user what is currently filtered (one toggle button to say either include or exclude materials '4').

raymond_giuseppi
Active Contributor
398

If it is really worth it, with CL_GUI_ALV_GRID and method GET_SUBTOTALS you can change the subtotal values.

(suggestion: Handle event after_refresh, if flag 'already done' is not set change subtotals, set flag 'already done' and force a re-display of ALV with method refresh_table_display)

0 Kudos
398

I got subtotal values with get_subtotals method, but which kind of flag are u talking about and how to change subtotal values?

0 Kudos
398

You get some REF TO DATA reference from GET_SUBTOTALS, then assign/loop and update the internal tables behind, recalculate sums.
By flag, I mean an attribute of your local class to make sure you don't do the calculation in an infinite loop, because the refresh_display will trigger the event after_refresh again.

0 Kudos
398

i dont have parameters in AFTER_REFRESH event.It works, i calling mine override method after set_table_for_first_display.
And i call CALL METHOD lo_alv->set_ready_for_input

EXPORTING
i_ready_for_input = 0. in mine method.

But after filtering it couts as it counted before ( as a usual alv sum function ).