11-21-2007 1:14 PM
Hi
In my ALV report output .I have to group the output based on the DAYS field
0-10 days in one group
10-30 days in one group
above 30 days one group
There is also a field by name "AMOUNT" in my output.
I have to calculate SUBTOTALs at the end of every group and at the end of the report i should caluculate GRAND TOTAL.
Please remember that i should not use any any BLOCKED ALVs and for Totals i should not use the SYMBOLS provided in the application toolbar of the report
Thanks in Advance
11-21-2007 1:29 PM
Ajay,
Check these links...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
Reward Points if this helps,
Satish
11-21-2007 2:08 PM
Take on more field in your internal table say GRP (for group).
Now, based on your condition fill this field GRP.
LOOP AT IT_OUT.
IF IT_OUT-DAY > 0 AND IT_OUT < 10.
IT_OUT-GRP = 1.
ELSEIF IT_OUT-DAY > 10 AND IT_OUT < 30.
IT_OUT-GRP = 1.
ELSEIF IT_OUT-DAY > 30.
IT_OUT-GRP = 1.
ENDIF.
MODIFY IT_OUT.
CLEAR IT_OUT.
ENDLOOP.
Set DO_SUM = 'X' in your fildcatalog for the AMOUNT field.
Now, fill the IT_SORT table which can be passed to your ALV.
DATA: t_sort TYPE slis_t_sortinfo_alv.
DATA: ls_sort TYPE slis_sortinfo_alv.
ls_sort-fieldname = 'GRP'.
ls_sort-spos = 1.
ls_sort-up = 'X'.
ls_sort-sub_tot = 'X'. " << For subtotal
ls_sort-group = '*'. " << this will make the group.
APPEND ls_sort TO xt_sort.
CLEAR ls_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_top_of_page = c_formname_top_of_page
i_callback_user_command = c_user_command
i_save = 'A'
is_variant = i_variant
it_sort = xt_sort " << sort table
it_fieldcat = t_fieldcat[]
TABLES
t_outtab = t_output
EXCEPTIONS
program_error = 1
OTHERS = 2.
Regards,
Naimesh Patel