Skip to content

solvarsaurus/CAT_CO_INVENTORY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CAT-CO LOGISTICS - Control Break Batch Processor

A COBOL batch processing firmware that demonstrates control break reporting with category-based subtotals and grand totals.

Overview

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.

Features

  • 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

Data Structure

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

Control Break Logic

The program monitors the CATEGORY field:

  1. First Record: Initialize previous category
  2. Subsequent Records: Compare current category with previous
  3. Category Change Detected:
    • Print category subtotal
    • Roll up to grand totals
    • Reset accumulators
    • Update previous category
  4. End of File: Force final break and print grand totals

Report Output

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
------------------------------------------------------------------

Program Flow

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

Key Variables

Control Break Variables:

  • PREV-CATEGORY: Previous category value (for comparison)
  • FIRST-RECORD: Flag for first record processing

Accumulators:

  • SUB-QTY: Subtotal quantity per category
  • SUB-TOTAL-VAL: Subtotal value per category
  • GRAND-QTY: Grand total quantity
  • GRAND-TOTAL-VAL: Grand total value

Page Control:

  • LINE-COUNT: Current line on page
  • PAGE-NUM: Current page number
  • LINES-PER-PAGE: Lines before page break (15)

Running the Program

cobol CAT_LOGISTICS.cob
./CAT_LOGISTICS

Customization

Add More Records:

  1. Increase OCCURS 10 in INTERNAL-FILE
  2. Add more MOVE statements in LOAD-MOCK-DATA
  3. 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)

Educational Value

This program demonstrates:

  • Control break processing pattern
  • Batch report generation
  • Hierarchical totals (subtotals → grand totals)
  • Accumulator management
  • Page control in reports
  • COBOL structured programming

Author

ANDY - SOLVARSAURUS GITHUB

About

Inventory program with control-breaks in COBOL

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages