Skip to Content
avatar image
Former Member


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 ??

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jan 30, 2017 at 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.


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 29, 2017 at 01: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.

    Add comment
    10|10000 characters needed characters exceeded

    • First, sorry for posting to this old post. I have 2 remarks which might help other people:

      • In the USER_COMMAND PAI module, you have probably called cl_gui_cfw=>dispatch to trigger the events
      • The call to cl_gui_cfw=>flush is probably useless because the flush is implicitly done (at the end of all PBO modules)