2009 Sep 25 7:44 AM
Hello! I want to display the sum of an ALV column but I want to display it up and not down like in report RM06BA00, I tried with fieldtab-do_sum = 'X' for totals and sort-subtot = 'X' for subtotals, but it always displayed down the list and not up.
Thanks for help.
2009 Sep 25 8:07 AM
Hello! I want to display the sum of an ALV column but I want to display it up and not down like in report RM06BA00, I tried with fieldtab-do_sum = 'X' for totals and sort-subtot = 'X' for subtotals, but it always displayed down the list and not up.
Thanks for help.
2009 Sep 25 7:56 AM
Hi,
This is a standard behavior of the ALV, that the totals are always displayed at the bottom. But if you want to display the total at the top, i.e first row of the ALV, then you can always insert a row in the output table at index 1, this row can be the summary of all the rows.
This is a workaround and I dont think there is any other way. This is also risky as the user might perform sorting, totals, subtotals on another column, after which it wont work.
Br,
Advait
2009 Sep 25 8:00 AM
Hi,
You Can use Like This
Declare :
it_sort type slis_t_sortinfo_alv,
wa_sort-spos = '1'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'. "Sub total for DMBTR.
append wa_sort to it_sort
Then IN REUSE_ALV_GRID_DISPLAY
it_sort = it_sort
Regards,
Vinu.R
2009 Sep 25 8:03 AM
Hello, <li>It is highly impossible to get totals and subtotal on top. SAP Standard functionality does not support. Thanks venkat.O
2009 Sep 25 8:07 AM
2009 Sep 25 8:35 AM
Hi,
Sorry for the wrong information given by me. Yes it is possible to get Sum on top.
<li>I tried the way Rainer has told.
Thanks
Venkat.O
REPORT ztest_notepad.
DATA: BEGIN OF it_mard OCCURS 0,
werks TYPE mard-werks,
lgort TYPE mard-lgort,
matnr TYPE mard-matnr,
labst TYPE mard-labst,
insme TYPE mard-insme,
einme TYPE mard-einme,
END OF it_mard.
TYPE-POOLS:slis.
DATA:it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF it_fieldcat,
wa_layout TYPE slis_layout_alv.
DEFINE fieldcat.
wa_fieldcat-fieldname = &1.
wa_fieldcat-tabname = &2.
wa_fieldcat-seltext_m = &3.
wa_fieldcat-do_sum = &4.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
END-OF-DEFINITION.
START-OF-SELECTION.
SELECT * FROM mard INTO CORRESPONDING FIELDS OF TABLE it_mard UP TO 1000 ROWS.
SORT it_mard BY werks lgort matnr.
fieldcat: 'WERKS' 'IT_MARD' 'MARD-WERKS' '',
'LGORT' 'IT_MARD' 'MARD-LGORT' '',
'MATNR' 'IT_MARD' 'MARD-MATNR' '',
'LABST' 'IT_MARD' 'MARD-LABST' 'X',
'INSME' 'IT_MARD' 'MARD-INSME' 'X',
'EINME' 'IT_MARD' 'MARD-EINME' 'X'.
wa_layout-totals_before_items = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = wa_layout
it_fieldcat = it_fieldcat
TABLES
t_outtab = it_mard.
2009 Sep 25 9:05 AM