Objective
This report lists the sales for each plant and prints subtotals by plant and division.
Procedure
Accumulated Total Values
The figure below shows the total values that occur during the processing of the code for the sales report:
Accumulated Total Values for Sales Report
┌───────────────────────────────────────────────┐ │ SORT KEY VALUES TYPE 5 FIELDS │ ├──────────┬───────┬────────────────────────────┤ │ LEVL │ LEVL │ LEVL LEVL LEVL │ │ 2 │ 1 │ 3 2 1 │ │ │ │ AMT ACCUMULATED │ │ DIVISION │ PLANT │ INPUT TOTALS │ ├──────────┼-------┼------─┬──────┬──────┬──────┤ │ 01 │ 01 │ 50 │ 50 │ 50 │ 50 │ ├──────────┼-------┼-------┼------┼------┼-----─┤ │ 01 │ 01 │ 20 │ 70 │ 70 │ 70 │ ├──────────┼-------┼-------┼------┼------┼-----─┤ │ 01 │ 01 │ 10 │ 80 │ 80 │ 80* │ ├──────────┼-------┼-------┼------┼------┼-----─┤ │ 01 │ 02 │ 40 │ 120 │ 120 │ 40 │ ├──────────┼-------┼-------┼------┼------┼-----─┤ │ 01 │ 02 │ 50 │ 170 │ 170* │ 90* │ ├──────────┼-------┼-------┼------┼------┼-----─┤ │ 02 │ 02 │ 20 │ 190 │ 20 │ 20 │ ├──────────┼-------┼-------┼------┼------┼-----─┤ │ 02 │ 02 │ 0 │ 190 │ 20 │ 20 │ ├──────────┼-------┼-------┼------┼------┼-----─┤ │ 02 │ 02 │ 40 │ 230 │ 60* │ 60* │ ├──────────┼-------┼-------┼------┼------┼-----─┤ │ 06 │ 03 │ 40 │ 270 │ 40 │ 40 │ ├──────────┴───────┴───────┴──────┴──────┴──────┤ │ * denotes initialization of the bucket to zero│ │ after the control break │ ├───────────────────────────────────────────────┤ │ LEVL 1 -- PLANT │ │ LEVL 2 -- DIVISION │ │ LEVL 3 -- GRAND TOTAL │ └───────────────────────────────────────────────┘
The values of the accumulators during the output processing of the Sales by Division and Plant code are incremented until a control break occurs. A control break causes initialization of the accumulators for the level having the control break.
Complete Code
col. 2 ▼ REC PLANT 3 2 REC AMOUNT 5 4 2 DP=2 REC TYPE 9 1 REC COMPL-DATE 10 6 2 01SORT DIVISION 1 PLANT 0 013 SALES BY DIVISION AND PLANT 010 COUNT 1 014100200 'DIVISION NUMBER:' 01410037 DIVISION 0151*000 COUNT $Printing on detail line suppressed 0151*010 PLANT 0151*020 AMOUNT F2 SZ=7 0161*0050 DIVISION 0161*010 PLANT HH 'PLANT' 0161*020 AMOUNT SZ=7 HH 'AMOUNT' 0161*021 COUNT SZ=2 HH 'COUNT TOTALS' 0162*0050 DIVISION 0162*020 AMOUNT SZ=7 0162*021 COUNT SZ=2 0163*005 'GRAND TOTAL:' 0163*020 AMOUNT SZ=7 0163*021 COUNT SZ=2 018 IF LEVL EQ 3 300 $Grand total test 018 IF LEVL EQ 2 200 $Division total test 018100 TAKE 1 $Print first type 6 line 018200 TAKE 2 $Print second type 6 line 018300 TAKE 3 $Print third type 6 line
Result
REPORT NO. 01 SALES BY DIVISION AND PLANT mm/dd/yy PAGE 1 DIVISION NUMBER: 01 PLANT AMOUNT COUNT TOTALS 01 50.00 01 20.00 01 20.00 01 01 90.00 3 02 40.00 02 50.00 01 02 90.00 2 01 180.00 5
REPORT NO. 01 SALES BY DIVISION AND PLANT mm/dd/yy PAGE 2 DIVISION NUMBER: 02 PLANT AMOUNT COUNT TOTALS 02 20.00 02 .00 02 40.00 02 02 60.00 3 02 60.00 3
REPORT NO. 01 SALES BY DIVISION AND PLANT mm/dd/yy PAGE 3 DIVISION NUMBER: 06 PLANT AMOUNT COUNT TOTALS 03 40.00 06 03 40.00 1 06 40.00 1 GRAND TOTAL: 280.00 9
|
Copyright © 2014 CA.
All rights reserved.
|
|