Hi,
I need to subtotal for different fields that avilabe in an internal table.
When i use AT END OF statement i am able to subtotal only the first field that is available in the internal table, but i can't able to subtotal with refferect to second field or third field like that....
Please see the below example program:
in the below program as PRODUCT is the first field, i can do subtotal with refferenct to PRODUCT,
but if i also need subtotal with refference to NAME field also. I am unable to get with the help of AT END OF statement.
Please suggest.
thansk in advance.
Ramana
&----
*& Report ZTEST1 *
*& *
&----
*& *
*& *
&----
REPORT ZTEST1 .
TYPES: BEGIN OF COMPANy_TYPE,
PRODUCT(20),
NAME(30),
SALES TYPE I,
END OF COMPANy_TYPE.
DATA: company TYPE STANDARD TABLE OF COMPANy_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
WA_COMPANy TYPE COMPANy_TYPE.
wa_company-name = 'A'.
wa_company-product = '1'.
wa_company-sales = '10'.
append wa_company to company.
wa_company-name = 'A'.
wa_company-product = '2'.
wa_company-sales = '20'.
append wa_company to company.
wa_company-name = 'B'.
wa_company-product = '1'.
wa_company-sales = '30'.
append wa_company to company.
wa_company-name = 'c'.
wa_company-product = '1'.
wa_company-sales = '40'.
append wa_company to company.
wa_company-name = 'c'.
wa_company-product = '2'.
wa_company-sales = '60'.
append wa_company to company.
sort company by product.
LOOP AT COMPANy INTO WA_COMPANy.
WRITE: / WA_COMPANy-NAME, WA_COMPANy-PRODUCT, WA_COMPANy-SALES.
AT END OF product.
SUM.
WRITE: / 'product subtot', WA_COMPANy-product, WA_COMPANy-SALES.
ENDAT.
ENDLOOP.
sort COMPANy by name.
LOOP AT COMPANy INTO WA_COMPANy.
WRITE: / WA_COMPAny-NAME, WA_COMPANy-PRODUCT, WA_COMPANy-SALES.
AT END OF NAME.
SUM.
WRITE: / 'name subtot', WA_COMPANy-NAME, WA_COMPANy-SALES.
ENDAT.
ENDLOOP.