Data : li_sort TYPE LVC_T_SORT,
lw_sort TYPE LVC_S_SORT.
Data : dd type ref tocl_dd_document.
Class c1 Definition.
Method Subtotal.
Endclass.
Class c1 Implementation.
Method subtotal.
lw_sort-fieldname = 'HID'. "sort depending on which field you want,
lw_sort-subtot = 'X'. "sub calculate depending on this field
lw_sort-up = 'X'. "ascending sequence
APPEND lw_sort TO li_sort.
CLEAR lw_sort.
ENDMETHOD.
Data obj_c1 Type ref to c1.
Create Object.
Call METHOD obj_c1->subtotal.
CALL METHOD o_grid->set_table_for_first_display "Grid Object o_grid
........
........
CHANGING
it_sort = li_sort "Pass the internal table filled in subtotal method to this field
This will work..worked fine with my report. I have made it a bit short. Use according to your requirement.