Application Development 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: 

subtotal and grand total for two fields(iseg-buchm and iseg-erfmg)

Former Member
0 Kudos

hi experts,

how to do subtotal and grand total for two fields (iseg-buchm and iseg-erfmg).please help me on solving the problem.

3 REPLIES 3

Former Member
0 Kudos

Hi,

If you want to display these 2 fields get them in internal table and fill the field catalog properly.For grand total give DO_SUM = 'X'. in field catalog.In the layout define an internal table for sorting.Pass this parameter.

wa_sort-spos = 1.

wa_sort-up = 'X'.

wa_sort-subtot = 'X'.

Call FM REUSE_ALV_GRID_DISPLAY to display report.

Former Member
0 Kudos

hi,

data: it_sort TYPE slis_t_sortinfo_alv,

wa_sort TYPE slis_sortinfo_alv.

for sub total :

wa_sort-fieldname = 'BUCHM'.

wa_sort-tabname = 'IT_ISEG'.

wa_sort-subtot = 'X'.

APPEND wa_sort TO it_sort.

CLEAR wa_sort.

for grand total: in field catlog pass DO_SUM = 'X'.

wa_fieldcat1-fieldname = 'ERFMG'.

wa_fieldcat1-do_sum = 'X'.

thanks,

raji

Former Member
0 Kudos

subtotal & grand total can be done in folowing way in ALV.

1.Pass it_sort parametere to REUSE_ALV_GRID_DISPLAY

2.Give the field name for sorting in it_sort-fieldname. it can be any field name u want to sort ur data with.

3.For iseg-buchm & iseg-erfmg mark do_sum = 'X'. in fieldcat

 
  gs_sort-spos = 1.
  gs_sort-fieldname = 'ANY FIELD NAME'.
  gs_sort-up = 'X'.
  gs_sort-subtot = 'X'.
  APPEND gs_sort TO et_sort.

  IF iv_fieldname = 'BUCHM'
  OR iv_fieldname = 'ERFMG'.
    gs_fieldcat-do_sum = 'X'.
  ENDIF.
  APPEND gs_fieldcat TO gt_fieldcat.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       is_variant              = ev_variant
      it_fieldcat             = gt_fieldcat[]