Title: Minor, Intermediate and Major Breaks
1Minor, Intermediate and Major Breaks
- Please use speaker notes for additional
information!
2Input data for major.cbl
Input data 0110121234HOE
01201899 0110121235RAKE
02501595 0110151111TROWEL
02000599 0110151112HAND HOE
01400799 0120171000LILY
05000199 0120171001TULIP
07500299 0121223000PANSY
11200599 0121223001PETUNIA
10000499 0230245555DOGWOOD
01010099 0230245556CHERRY
01012000 0240276789WHITE PINE
00513500 0240276790BLACK PINE
01020000 0250553456MAPLE
00807500 0250553457OAK
00909900
DIV BR DEPT
3 04/11/99 INVENTORY
REPORT PAGE 1
DIV BR DEPT ITEM ITEM NAME ON
HAND PRICE INVEN VALUE 01
10 12 1234 HOE 12
18.99 227.88 01 10 12
1235 RAKE 25 15.95
398.75
TOTALS FOR DEPT 12 37
626.63 01 10 15 1111
TROWEL 20 5.99
119.80 01 10 15 1112 HAND HOE
14 7.99 111.86
TOTALS FOR DEPT 15
34 231.66
TOTALS FOR BRANCH 10 71
858.29 01 20 17
1000 LILY 50
1.99 99.50 01 20 17 1001
TULIP 75 2.99
224.25 TOTALS
FOR DEPT 17 125
323.75 TOTALS FOR
BRANCH 20 125 323.75
01 21 22 3000 PANSY
112 5.99 670.88
01 21 22 3001 PETUNIA
100 4.99 499.00
TOTALS FOR DEPT 22 212
1,169.88
TOTALS FOR BRANCH 21 212
1,169.88 TOTALS FOR
DIVISION 01 408 2,351.92
02 30 24 5555 DOGWOOD
10 100.99 1,009.90
02 30 24 5556 CHERRY
10 120.00 1,200.00
TOTALS FOR DEPT 24 20
2,209.90
TOTALS FOR BRANCH 30 20
2,209.90 02 40 27 6789
WHITE PINE 5 135.00
675.00 02 40 27 6790 BLACK PINE
10 200.00 2,000.00
TOTALS FOR DEPT 27
15 2,675.00
TOTALS FOR BRANCH 40 15
2,675.00 02 50 55
3456 MAPLE 8
75.00 600.00 02 50 55 3457
OAK 9 99.00
891.00 TOTALS
FOR DEPT 55 17
1,491.00 TOTALS FOR
BRANCH 50 17 1,491.00
TOTALS FOR DIVISION 02
52 6,375.90
FINAL TOTAL 460
8,727.82
Report produced by major.cbl
4First 7 records
The first seven input records
0110121234HOE 01201899
0110121235RAKE 02501595
0110151111TROWEL 02000599
0110151112HAND HOE 01400799
0120171000LILY 05000199
0120171001TULIP 07500299
0121223000PANSY 11200599
Note that when the dept changes from 12 to 15, a
total is written for dept 12 before dept 15 is
processed.
04/11/99 INVENTORY REPORT
PAGE 1 DIV BR
DEPT ITEM ITEM NAME ON HAND
PRICE INVEN VALUE 01 10 12
1234 HOE 12 18.99
227.88 01 10 12 1235
RAKE 25 15.95
398.75 TOTALS
FOR DEPT 12 37
626.63 01 10 15 1111
TROWEL 20 5.99
119.80 01 10 15 1112 HAND HOE
14 7.99 111.86
TOTALS FOR DEPT 15
34 231.66
TOTALS FOR BRANCH 10 71
858.29 01 20 17
1000 LILY 50
1.99 99.50 01 20 17 1001
TULIP 75 2.99
224.25 TOTALS
FOR DEPT 17 125
323.75 TOTALS FOR
BRANCH 20 125 323.75
01 21 22 3000 PANSY
112 5.99 670.88
Note when the BR changes from 10 to 20, I need to
write a dept total for the last dept and then a
branch total for the br before I process the
first record in br 20.
5B-100- PROCESS
MAINLINE
A
A-100- INITIALIZE
READ 1ST RECORD
AT END
NO TO MORE-RECS
B-330- MAJOR-ROUT
B-100- PROCESS
DIV TO DIV-HOLD BR TO BR-HOLD DEPT TO DEPT-HOLD
C-100- WRAPUP
B-340- FINAL-ROUT
STOP RUN
B-200- LOOP
END B-100
Y
MORE-RECS NOT NO
A-100-INITIALIZE
OPEN FILES
N
B-310- MINOR-ROUT
PROCESS DATE
NOTE DIV is the major break field, BR is the
intermediate break field, and DEPT is the minor
break field in this example. The move to hold
should move whatever is the major break field,
the intermediate break field and the minor break
field.
B-320- INTER-ROUT
END A-100
A
6B-200-LOOP
DIV NOT DIV-HOLD
Y
N
N
Y
B-310- MINOR-ROUT
BR NOT BR-HOLD
B-310- MINOR-ROUT
B-230- INTER-ROUT
N
Y
DEPT NOT DEPT-HOLD
B-230- INTER-ROUT
B-240- MAJOR-ROUT
B-310- MINOR-ROUT
B
7B
B-300-DETAIL
B-300- DETAIL
Need header?
Y
N
B-400- HDR-ROUT
READ RECORD
AT END
NO TO MORE-RECS
Set up detail line
END B-200
WRITE LINE
Add to MINOR-TOTAL INTER-TOTAL MAJOR-TOTAL FINAL-T
OTAL
END B-300
8B-310-MINOR- ROUT
B-320-FINAL ROUT
B-320-INTER- ROUT
B-330-MAJOR- ROUT
Set up minor total line
Set up final total line
Set up intermed total line
Set up major total line
WRITE MINOR TOTAL LINE
WRITE FINAL TOTAL LINE
WRITE INTER TOTAL LINE
WRITE MAJOR TOTAL LINE
END B-320
RESET DEPT TO DEPT-HOLD
RESET BR TO BR-HOLD
RESET DIVTO DIV-HOLD
RESET MINOR-TOTAL 0
RESET INTER-TOTAL 0
RESET MAJOR-TOTAL 0
END B-310
END B-320
END B-330
9B-400- HDR-ROUT
C-100-WRAPUP
Set up page and line headers
CLOSE FILES
WRITE PAGE LINE HEADERS
END C-100
Add to page and reset line count
END B-400
10A
B-100- PROCESS
READ 1ST RECORD
AT END
NO TO MORE-RECS
B-330- MAJOR-ROUT
DIV TO DIV-HOLD BR TO BR-HOLD DEPT TO DEPT-HOLD
B-340- FINAL-ROUT
END B-100
B-200- LOOP
Y
MORE-RECS NOT NO
B-100-PROCESS. READ
INPUT-FILE AT END
MOVE "NO " TO MORE-RECS. MOVE DIV TO
HOLD-DIV. MOVE BRANCH TO HOLD-BRANCH.
MOVE DEPT TO HOLD-DEPT.
PERFORM B-200-LOOP UNTIL MORE-RECS
"NO ". PERFORM B-310-MINOR-ROUT.
PERFORM B-320-INTER-ROUT.
PERFORM B-330-MAJOR-ROUT. PERFORM
B-340-FINAL-ROUT.
N
B-310- MINOR-ROUT
B-320- INTER-ROUT
A
11B-200-LOOP
DIV NOT DIV-HOLD
Y
N
N
Y
B-310- MINOR-ROUT
BR NOT BR-HOLD
B-310- MINOR-ROUT
B-230- INTER-ROUT
N
DEPT NOT DEPT-HOLD
Y
B-230- INTER-ROUT
B-240- MAJOR-ROUT
B-310- MINOR-ROUT
B-200-LOOP. IF DIV NOT
HOLD-DIV PERFORM B-310-MINOR-ROUT
PERFORM B-320-INTER-ROUT
PERFORM B-330-MAJOR-ROUT
PERFORM U-000-BLANK-LINE ELSE
IF BRANCH NOT HOLD-BRANCH
PERFORM B-310-MINOR-ROUT
PERFORM B-320-INTER-ROUT
PERFORM U-000-BLANK-LINE ELSE
IF DEPT NOT HOLD-DEPT
PERFORM B-310-MINOR-ROUT
PERFORM U-000-BLANK-LINE.
B
12B
B-300- DETAIL
READ RECORD
AT END
NO TO MORE-RECS
END B-200
PERFORM B-300-DETAIL. READ INPUT-FILE AT
END MOVE "NO " TO MORE-RECS.
13B-300-DETAIL
B-300-DETAIL. IF LINE-CT gt 50
OR PAGE-NO 1 PERFORM
B-400-HDR-ROUT. MOVE SPACES TO
PRINTZ. MOVE DIV TO DIV-PR.
MOVE BRANCH TO BRANCH-PR. MOVE DEPT TO
DEPT-PR. MOVE ITEM-NO TO ITEM-NO-PR.
MOVE ITEM-NAME TO ITEM-NAME-PR.
MOVE ON-HAND TO ON-HAND-PR. MOVE
PRICE TO PRICE-PR. MULTIPLY ON-HAND BY
PRICE GIVING INV-VALUE-WS.
MOVE INV-VALUE-WS TO INV-VALUE-PR.
WRITE PRINTZ AFTER ADVANCING 1
LINES. ADD 1 TO LINE-CT.
ADD ON-HAND TO MINOR-ONHAND-ACC. ADD
ON-HAND TO INTER-ONHAND-ACC. ADD
ON-HAND TO MAJOR-ONHAND-ACC ADD
ON-HAND TO FINAL-ONHAND-ACC. ADD
INV-VALUE-WS TO MINOR-VALUE-ACC. ADD
INV-VALUE-WS TO INTER-VALUE-ACC. ADD
INV-VALUE-WS TO MAJOR-VALUE-ACC. ADD
INV-VALUE-WS TO FINAL-VALUE-ACC.
Need header?
Y
N
B-400- HDR-ROUT
Set up detail line
WRITE LINE
Add to MINOR-TOTAL INTER-TOTAL MAJOR-TOTAL FINAL-T
OTAL
END B-300
14B-310-MINOR- ROUT
Set up minor total line
WRITE MINOR TOTAL LINE
B-310-MINOR-ROUT. MOVE
HOLD-DEPT TO DEPT-ML. MOVE
MINOR-ONHAND-ACC TO MINOR-ONHAND-ACC-ML.
MOVE MINOR-VALUE-ACC TO MINOR-VALUE-ACC-ML.
WRITE PRINTZ FROM MINOR-TOTAL-LINE
AFTER ADVANCING 2 LINES. MOVE
DEPT TO HOLD-DEPT. MOVE 0 TO
MINOR-ONHAND-ACC. MOVE 0 TO
MINOR-VALUE-ACC. ADD 2 TO LINE-CT.
RESET DEPT TO DEPT-HOLD
RESET MINOR-TOTAL 0
END B-310
15B-320-INTER- ROUT
Set up intermed total line
WRITE INTER TOTAL LINE
B-320-INTER-ROUT. MOVE HOLD-BRANCH TO
BRANCH-IL. MOVE INTER-ONHAND-ACC TO
INTER-ONHAND-ACC-IL. MOVE
INTER-VALUE-ACC TO INTER-VALUE-ACC-IL.
WRITE PRINTZ FROM INTER-TOTAL-LINE
AFTER ADVANCING 1 LINES. MOVE SPACES
TO PRINTZ. MOVE BRANCH TO
HOLD-BRANCH. MOVE 0 TO
INTER-ONHAND-ACC. MOVE 0 TO
INTER-VALUE-ACC. ADD 1 TO LINE-CT.
RESET BR TO BR-HOLD
RESET INTER-TOTAL 0
END B-320
16B-330-MAJOR- ROUT
Set up major total line
B-330-MAJOR-ROUT. MOVE HOLD-DIV
TO DIV-MJL. MOVE MAJOR-ONHAND-ACC TO
MAJOR-ONHAND-ACC-MJL. MOVE
MAJOR-VALUE-ACC TO MAJOR-VALUE-ACC-MJL.
WRITE PRINTZ FROM MAJOR-TOTAL-LINE
AFTER ADVANCING 1 LINES. MOVE DIV TO
HOLD-DIV. MOVE 0 TO MAJOR-ONHAND-ACC.
MOVE 0 TO MAJOR-VALUE-ACC.
ADD 1 TO LINE-CT.
WRITE MAJOR TOTAL LINE
RESET DIVTO DIV-HOLD
RESET MAJOR-TOTAL 0
END B-330
17B-320-FINAL ROUT
Set up final total line
B-340-FINAL-ROUT. MOVE
FINAL-ONHAND-ACC TO FINAL-ONHAND-ACC-FL.
MOVE FINAL-VALUE-ACC TO FINAL-VALUE-ACC-FL.
WRITE PRINTZ FROM FINAL-TOTAL-LINE
AFTER ADVANCING 1 LINES.
WRITE FINAL TOTAL LINE
END B-320
18B-400- HDR-ROUT
B-400-HDR-ROUT. MOVE PAGE-NO
TO PAGE-NO-HDR. WRITE PRINTZ FROM
PAGE-HDR AFTER ADVANCING PAGE.
WRITE PRINTZ FROM COLUMN-HDR
AFTER ADVANCING 2 LINES. PERFORM
U-000-BLANK-LINE. ADD 1 TO PAGE-NO.
MOVE 4 TO LINE-CT.
Set up page and line headers
WRITE PAGE LINE HEADERS
Add to page and reset line count
END B-400
C-100-WRAPUP
C-100-WRAPUP. CLOSE INPUT-FILE
PRINT-FILE.
CLOSE FILES
END C-100