2009 Jan 29 3:03 PM
2009 Jan 29 3:09 PM
2009 Jan 29 3:34 PM
Hi venkat,
just check out the below report may be help full to you.
&----
*& Report Z10_ALPROGRAM22 *
*& *
&----
*& *
*& *
&----
REPORT Z10_ALPROGRAM22 NO STANDARD PAGE HEADING
LINE-COUNT 22(3)
LINE-SIZE 150.
****************TABLES**************
TABLES : KNA1, "GENERAL DATA IN CUSTOMER MASTER
VBAK. "SALES ORDER-HEADER DATA
TABLES : SPELL.
****************DATA TYPES**********
TYPES : BEGIN OF TY_ORDERS,
KUNNR TYPE KNA1-KUNNR, "CUSTOMER NUMBER
NAME1 TYPE KNA1-NAME1, "CUSTOMER NAME
ORT01 TYPE KNA1-ORT01, "CITY
LAND1 TYPE KNA1-LAND1, "COUNTRY
VBELN TYPE VBAK-VBELN, "ORDER NUMBER
ERDAT TYPE VBAK-ERDAT, "ORDER DATE
NETWR TYPE VBAK-NETWR, "ORDER VALUE
END OF TY_ORDERS.
****************WORK AREAS***************
DATA : W_ORDERS TYPE TY_ORDERS.
DATA : CURRENCY LIKE SPELL.
DATA : CURRENCY1 LIKE SPELL.
***************INTERNAL TABLES***********
DATA : T_ORDERS TYPE STANDARD TABLE OF TY_ORDERS
INITIAL SIZE 3.
***************SELECTION SCREENS************
SELECT-OPTIONS : S_CUSTNO FOR KNA1-KUNNR,
S_ORDNO FOR VBAK-VBELN.
SELECT-OPTIONS : S_CNTRY FOR KNA1-LAND1 NO INTERVALS.
***************REPORT EVENT*****************
INITIALIZATION.
S_CUSTNO-SIGN ='I'.
S_CUSTNO-OPTION = 'BT'.
S_CUSTNO-LOW = 1000.
S_CUSTNO-HIGH = 2000.
APPEND S_CUSTNO.
*****************REPORT EVENT****************
AT SELECTION-SCREEN.
IF S_CUSTNO-HIGH > 2000.
MESSAGE E004(Z10_ALMSG1).
ENDIF.
**************REPORT EVENT******************
TOP-OF-PAGE.
WRITE : /45 'CUSTOMER ORDER INFORMATION REPORT' COLOR 1 INVERSE ON.
ULINE.
WRITE : /03 'CUSTOMER NUMBER',
25 'CUSTOMER NAME',
53 'CITY',
80 'COUNTRY'.
SET LEFT SCROLL-BOUNDARY COLUMN 45.
WRITE : /100 'ORDER NUMBER',
117 'ORDER DATE',
140 'ORDER VALUE'.
ULINE.
************REPORT EVENT*******************
END-OF-PAGE.
ULINE.
WRITE : /45 'END OF PAGE:',SY-PAGNO.
ULINE.
************REPORT EVENT*******************
START-OF-SELECTION.
****************EXTRACT DATA****************
SELECT K~KUNNR
K~NAME1
K~ORT01
K~LAND1
V~VBELN
V~ERDAT
V~NETWR
INTO TABLE T_ORDERS
FROM KNA1 AS K
INNER JOIN
VBAK AS V
ON KKUNNR = VKUNNR
WHERE K~KUNNR IN S_CUSTNO
AND V~VBELN IN S_ORDNO.
***************DISPLAY DATA****************
NEW-PAGE LINE-COUNT SY-SROWS.
SORT T_ORDERS BY KUNNR.
LOOP AT T_ORDERS INTO W_ORDERS.
AT NEW KUNNR.
READ TABLE T_ORDERS INTO W_ORDERS WITH KEY KUNNR = W_ORDERS-KUNNR.
WRITE : /03 W_ORDERS-KUNNR,
25 W_ORDERS-NAME1,
53 W_ORDERS-ORT01,
80 W_ORDERS-LAND1.
ENDAT.
WRITE : /100 W_ORDERS-VBELN,
117 W_ORDERS-ERDAT,
140 W_ORDERS-NETWR.
************SUB TOTAL*******************************
AT END OF KUNNR.
SUM.
FORMAT COLOR 3.
WRITE : /'SUB TOTAL ORDER VALUE:',130 W_ORDERS-NETWR.
FORMAT COLOR OFF.
DATA K TYPE I.
K = SY-LINCT - SY-LINNO.
RESERVE K LINES.
ENDAT.
****************GRAND TOTAL**************************
AT LAST.
SUM.
FORMAT COLOR 3.
WRITE : /'GRAND TOTAL ORDER VALUE:',130 W_ORDERS-NETWR.
FORMAT COLOR OFF.
ENDAT.
ENDLOOP.
Thanks,
Rajesh
2009 Jan 29 3:41 PM
2009 Jan 29 5:30 PM
Hi,
For calculating subtotal:
1. in reports use AT NEW and AT END OF keywords and use keyword SUM to calculate total.
2. in alv you can use field catalogs for calculating sub-totals, use:-
https://www.sdn.sap.com/irj/scn/wiki?path=/pages/viewpage.action&pageid=68190567
Refer to the field catalogs for grand sum and sort info for sub-totals.
Hope this helps you.
Thanks & Regards,
Tarun