# sub totals in List reports

Hi,

Could anyone tell me how do we do sub totals in List reporting.

For instance, I do have list of records which belongs to different Cost centres and I want to sum up a Value (Type CUR) field cost-centre wise and display it as

CC1 2300

CC1 1000

CC2 500

Sub-totals:

CC1 3300

CC2 500

I tried using AT END statement, but this does not seems to work for this requirement.

Thanks in advance.

Regards,

Farhana.

##### Tags:

##### Former Member replied

Hi,

Check this code

REPORT Z_SUMMARIZE . TYPES: BEGIN OF T_TYPE, CODE(1), name(20), SALES TYPE P, DISCOUNT TYPE P, END OF T_TYPE. DATA: T TYPE STANDARD TABLE OF T_TYPE WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 100. DATA: T2 TYPE STANDARD TABLE OF T_TYPE WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 100, WA_T TYPE T_TYPE, wa_t1 type t_type. data l_mod type i. do 9 times. . l_mod = sy-index mod 2. if l_mod = 0. wa_t-code = '1'. wa_t-name = 'Sam'. else. wa_t-code = '2'. wa_t-name = 'Chris'. endif. wa_t-sales = sy-index * sy-index. append wa_t to t. enddo. wa_t-code = '3'. wa_t-name = 'John'. wa_t-sales = 200. append wa_t to t. wa_t-code = '2'. wa_t-name = 'John'. wa_t-sales = 300. append wa_t to t. wa_t-code = '3'. wa_t-name = 'Mathew'. wa_t-sales = 200. append wa_t to t. sort t by code name. LOOP AT T INTO WA_T. wa_t1 = wa_t. AT FIRST. SUM. WRITE: /4 'Grand Total:', 20 WA_T-SALES. ULINE. SKIP. ENDAT. write :/ wa_t-code, 20 wa_t-name, 40 wa_t-sales. at end of name. SUM. * write : / 'Sum of Sales for', * 20 wa_t-name, 40 wa_t-sales. append wa_t to t2. ENDAT. ENDLOOP. skip. write : / sy-uline(40),'Summary', sy-uline(40). loop at t2 into wa_t. write :/ wa_t-code, 20 wa_t-name, 40 wa_t-sales. skip. endloop.

regards,

Advait