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

Display ALV sum up

Former Member
0 Likes
2,297

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.

1 ACCEPTED SOLUTION
Read only

rainer_hbenthal
Active Contributor
0 Likes
1,849

  alv_layout-totals_before_items = 'X'.

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.

6 REPLIES 6
Read only

Former Member
0 Likes
1,849

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

Read only

Former Member
0 Likes
1,849

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

Read only

venkat_o
Active Contributor
0 Likes
1,849

Hello, <li>It is highly impossible to get totals and subtotal on top. SAP Standard functionality does not support. Thanks venkat.O

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,850

  alv_layout-totals_before_items = 'X'.
Read only

0 Likes
1,849

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.


 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.
Thanks Venkat.O

Read only

0 Likes
1,849

Thank you, it works !!