Application Development and Automation 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: 
Read only

Alv grid override function

Former Member
0 Likes
2,276

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
Read only

FredericGirod
Active Contributor
0 Likes
2,172

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

Read only

Former Member
0 Likes
2,172

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

Read only

Sandra_Rossi
Active Contributor
2,172

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').

Read only

RaymondGiuseppi
Active Contributor
2,172

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)

Read only

0 Likes
2,172

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

Read only

0 Likes
2,172

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.

Read only

0 Likes
2,172

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 ).