cancel
Showing results for 
Search instead for 
Did you mean: 

ALV subtotal at bottom

0 Kudos

Dear Expert;

I haved developed an ALV report with Subtotal and totals. The subtotal is displaying at the end of the sorted parameter. How can i have all the subtotal at the end os the list on the last page ? Please help.

for sorting I have this:

Clear: WA_SORT.
WA_SORT-spos = 20.
WA_SORT-fieldname = 'DFKKREP06-STPRZ'.
WA_SORT-up = ' '.
WA_SORT-subtot = 'X'.
* WA_SORT-
append WA_SORT TO T_SO

and the alv fm

clear g_variant.

g_variant-report = g_repid.

PERFORM sort_total.
SORT gt_outtab by dfkkrep06-STPRZ ASCENDING.



call function 'REUSE_ALV_GRID_DISPLAY'
exporting
* I_INTERFACE_CHECK = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = g_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
i_callback_top_of_page = 'TOP_OF_PAGE'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = l_layout
it_fieldcat = gt_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = t_sort[]
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
i_save = 'X'
is_variant = g_variant
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_ADD_FIELDCAT =
* IT_HYPERLINK =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = gt_outtab

Accepted Solutions (0)

Answers (3)

Answers (3)

Ganesh_Pandian
Explorer
0 Kudos

Sadly this is how ALV works!

If you need that anyways, Then do the subtotal and the Grand total as yourself in the loop and append those total line in the last.

If you want to make those total lines looks legit, just color those rows to yellow!

I Hope this helps you!

0 Kudos

Hi Simone;

I have subtotal after every change on the variable for sort, after running if I go to setting -> define totals drilldown I have what I whant but because the program is runing at the bacground I what it strait on runing the program. Do you know how I can get around?

Thankks in advance

SimoneMilesi
Active Contributor
0 Kudos

This is how ALV technology works: if you use SubTotals, they are displayed at the end of the grouping factor (and it has a logic from my point on view).
At the end you have the grand total.


If you absolutely need the subtotals at the end, you have to work out programatically, calculating them and adding them as "fake lines" of your ALV.
Sadly this will impact the grand total.

Not knowing your scenario, a possibile workaround is to have a second ALV on the bottom part of the screen where to show just the subtotals (obviously calculated by you).
This requires to shift from old and obsolete FM to OOP

0 Kudos

Thanks Simone;

when you have alv display when you double click on the subtotals from top to bottom you have what I am looking for. All subttotats goes at the end of the page