A COBOL batch processing firmware that demonstrates control break reporting with category-based subtotals and grand totals.
This program processes inventory data and generates a formatted batch report with automatic control breaks when the category changes. It's a classic example of batch processing with hierarchical totals.
- Control Break Processing: Automatically detects category changes and triggers subtotals
- Hierarchical Totals: Category subtotals roll up to grand totals
- Batch Report Format: Formatted output with headers and separators
- Page Control: Manages page breaks and line counting
- Mock Data: 10 pre-loaded inventory items across 3 categories
Input Records (10 items):
- Category (10 chars)
- Item Name (15 chars)
- Quantity (4 digits)
- Price (3 digits + 2 decimals)
Categories:
- FOOD (3 items): Tuna Treats, Catnip Dry, Salmon Pate
- TOYS (4 items): Laser Pointer, Yarn Ball, Scratch Post, Mouse Rattle
- TECH (3 items): Flux Capacitor, GPS Collar, Auto-Feeder
The program monitors the CATEGORY field:
- First Record: Initialize previous category
- Subsequent Records: Compare current category with previous
- Category Change Detected:
- Print category subtotal
- Roll up to grand totals
- Reset accumulators
- Update previous category
- End of File: Force final break and print grand totals
DATE: 10/25/1985 CAT-CO LOGISTICS PAGE: 1
------------------------------------------------------------------
CATEGORY ITEM QTY PRICE TOTAL VALUE
------------------------------------------------------------------
FOOD TUNA TREATS 100 $5.50 $550.00
FOOD CATNIP DRY 50 $12.00 $600.00
FOOD SALMON PATE 200 $2.25 $450.00
* CATEGORY SUB: $1,600.00
TOYS LASER POINTER 10 $25.00 $250.00
TOYS YARN BALL 500 $1.50 $750.00
TOYS SCRATCH POST 20 $45.00 $900.00
TOYS MOUSE RATTLE 100 $3.00 $300.00
* CATEGORY SUB: $2,200.00
TECH FLUX CAPACITOR 1 $1500.00 $1,500.00
TECH GPS COLLAR 10 $99.00 $990.00
TECH AUTO-FEEDER 5 $150.00 $750.00
* CATEGORY SUB: $3,240.00
------------------------------------------------------------------
*** GRAND TOTAL : $7,040.00
------------------------------------------------------------------
START
↓
LOAD-MOCK-DATA (Initialize 10 inventory records)
↓
PRINT-TITLE-ART (Display header)
↓
PROCESS-RECORDS (Loop through each record)
├─ Check for control break (category change)
├─ Check for page break
├─ Calculate row value (qty × price)
├─ Accumulate subtotals
├─ Print detail line
└─ Move to next record
↓
CATEGORY-BREAK (Final break on end of file)
├─ Print category subtotal
├─ Roll up to grand totals
└─ Reset accumulators
↓
PRINT-GRAND-TOTAL (Display final totals)
↓
END
Control Break Variables:
PREV-CATEGORY: Previous category value (for comparison)FIRST-RECORD: Flag for first record processing
Accumulators:
SUB-QTY: Subtotal quantity per categorySUB-TOTAL-VAL: Subtotal value per categoryGRAND-QTY: Grand total quantityGRAND-TOTAL-VAL: Grand total value
Page Control:
LINE-COUNT: Current line on pagePAGE-NUM: Current page numberLINES-PER-PAGE: Lines before page break (15)
cobol CAT_LOGISTICS.cob
./CAT_LOGISTICSAdd More Records:
- Increase
OCCURS 10in INTERNAL-FILE - Add more MOVE statements in LOAD-MOCK-DATA
- Update loop condition in MAIN-LOGIC
Change Categories: Edit LOAD-MOCK-DATA section to modify category names and data
Adjust Page Length:
Modify LINES-PER-PAGE value (currently 15)
This program demonstrates:
- Control break processing pattern
- Batch report generation
- Hierarchical totals (subtotals → grand totals)
- Accumulator management
- Page control in reports
- COBOL structured programming
ANDY - SOLVARSAURUS GITHUB