2007 Mar 09 12:53 PM
Hi Guyz,
I am trying an interactive ALV program where i am getting total and subtotal by clicking the SUMMATION buttons on Application tool bar. I want to it should show the field name as TOTAL and SUB-TOTAL there in the output screen.
Q>How to handle the sub-totals and the total fields in ALV.
I want to do it using TYPE POOLS : SLIS .
Any new ideas to solve this is also welcome.
Thanks.
2007 Mar 09 12:59 PM
hi Sam!!!!
do this way ..
t_fieldcat-tabname = tabname.
t_fieldcat-fieldname = fieldname.
t_fieldcat-seltext_m = seltext_m.
IF do_sum = 'X'.
t_fieldcat-datatype = 'CURR'.
ENDIF.
t_fieldcat-do_sum = do_sum.
APPEND t_fieldcat TO it_fieldcat.
CLEAR t_fieldcat.
t_sort-fieldname = 'VAR1'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 1.
t_sort-up = 'X'.
t_sort-subtot = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.
t_sort-fieldname = 'VAR3'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 2.
t_sort-up = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.
2007 Mar 09 12:57 PM
For the fields for which you want to get the subtotals and totals, you have to fill the fieldcatalog parameter DO_SUM = 'X'. The totals would appear automatically.(the field should be numeric thogh).
c_fieldcat-do_sum = 'X'. "for all those fields for which you want the total.
You should also fill the sort table information to get the subtotals according to grouping.
Refer the BCALV_TEST_LIST_EVENTS program.
Regards,
Ravi
2007 Mar 09 12:57 PM
u can use at new statement of that field and after that u can call FM resue_alv_list_display.
then check u r answer
regards
vijay
2007 Mar 09 12:59 PM
hi Sam!!!!
do this way ..
t_fieldcat-tabname = tabname.
t_fieldcat-fieldname = fieldname.
t_fieldcat-seltext_m = seltext_m.
IF do_sum = 'X'.
t_fieldcat-datatype = 'CURR'.
ENDIF.
t_fieldcat-do_sum = do_sum.
APPEND t_fieldcat TO it_fieldcat.
CLEAR t_fieldcat.
t_sort-fieldname = 'VAR1'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 1.
t_sort-up = 'X'.
t_sort-subtot = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.
t_sort-fieldname = 'VAR3'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 2.
t_sort-up = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.