2023 Mar 21 12:49 PM
Is it possible to override SUM function in alv grid, for example do not count the material if it starts with '4'?
2023 Mar 21 1:07 PM
2023 Mar 21 1:16 PM
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
2023 Mar 21 2:29 PM
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').
2023 Mar 21 4:49 PM
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)
2023 Mar 23 7:37 AM
I got subtotal values with get_subtotals method, but which kind of flag are u talking about and how to change subtotal values?
2023 Mar 23 3:48 PM
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.
2023 Mar 24 9:30 AM
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 ).