01-30-2017 11:13 AM
I’m writing a new report where it should be possible to make a subtotal on a column with a percent field. To get the percent calculated right I’m trying to use the method GET_SUBTOTALS of the class CL_GUI_ALV_GRID (The grid method is the only ALV that allows you to manipulate with totals/subtotals).
The users are calling the report with a variant where to totals/subtotals already are defined. To get the first calculation I’m calling GET_SUBTOTALS just after grid->set_table_for_first_display – before calling my screen containing my ALV container.
This works as it should. Now the problem is that the user can sort the ALV by other fields, or make new subtotal. Therefore the method GET_SUBTOTALS has to be called again. I tried to place the code on the event handle_after_refresh, but to get the new totals/subtotal back on the screen the method refresh_table_display has to be called with the parameter i_soft_refresh. But this action triggers a new refresh, and the result is an endless loop.
I have tried to place the call to GET_SUBTOTALS on other events (handle_after_user_command, handle_data_changed_finished and even of handle_on_toolbar). But in non of these events the new subtotals a calculated yet.
Anybody that has solved this problem ??
01-30-2017 12:25 PM
Handle event after_refresh and force a re-display of ALV with method refresh_table_display. Of course handle some variable to prevent infinite loop as the re-display will re-trigger the first event.
Regards,
Raymond
03-29-2017 2:29 PM
I solved the problem by adding "i_appl_events = 'X'" when calling the CREATE OBJECT of the grid.
With this parameter all key press was send to the USER_COMMAND of the screen.
Now I could call GET_SUBTOTALS, and as the last step call cl_gui_cfw=>flush.
02-13-2019 6:53 AM
First, sorry for posting to this old post. I have 2 remarks which might help other people: