Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

alv reports

Hi friends,

i have problem how to do total ,subtotal and average and percentage of individual,

please can any body give me the solution if possible reference code.

Thanks in advance,



Follow the steps below get Subtotals and Grand totals


Define SORT table and FIELDCATALOG table .

Data :i_field type slis_t_fieldcat_alv,

w_field like line of i_field,

i_sort type slis_t_sortinfo_alv,

w_sort like line of i_sort.

2.Grand Total

While buildingfieldcatalog,We have to set DO_SUM = 'X' for quantity field .


w_field-fieldname = 'MENGE'.

w_field-tabname = 'I_TAB'.

w_field-DO_SUM = 'X'.

append w_field to i_field.

clear w_field.


Whenever WERKS is changed Subtotal is displayed .

Build sort table .

Clear: w_sort,i_sort[].

w_sort-spos = 1.

w_sort-fieldname = 'WERKS'.

w_sort-up = 'X'.

w_sort-subtot = 'X'.

append w_sort to i_sort.

clear w_sort.


Pass this I_SORT table thru REUSE_ALV_LIST_DISPLAY function module fieldcatalog table.


if you want average then use DO_SUM = 'C'."instead of 'X'

then totals will be shown interms of average.


You can't get percentage in ALV by default because ALV don't provide this functionality. You can write the simple code: value/ total * 100 and then display the same in the ALV.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question