Capstone: Modernizing a Legacy COBOL System
COBOL Intermediate/Advanced
Chapter 10 · Capstone: Modernizing a Legacy COBOL System
Fundamentals' own TXNBATCH shipped as a clean, working batch program. A few real years of maintenance later, it has aged into exactly the kind of system Chapter 9 described — real cryptic patches, a lingering ALTER, a customer file that's outgrown sequential access, and no real error-handling discipline at all. This capstone modernizes it, one real technique at a time, using everything Course 2 covered.
Step 1 — Fixing the Legacy Control Flow (Ch. 9)
A maintainer's real patch from years ago used ALTER to skip validation on a "trusted" batch run. It's replaced with a real, explicit EVALUATE flag check instead — the exact fix Chapter 9 documented:
Step 2 — Sharing the Record Layout via a Copybook (Ch. 2)
CUSTOMER-RECORD, hand-typed separately in TXNBATCH and in this capstone's own new CICS program (Step 8), moves into one real shared copybook, CUSTREC, included with REPLACING wherever it's needed.
Step 3 — Converting to a Real Indexed Customer File (Ch. 1)
TXNBATCH's own original sequential scan for a specific customer is replaced with a real direct-by-key READ, dropping the linear search entirely.
Step 4 — Centralizing File Error Handling (Ch. 6)
Every real READ against the newly-indexed file drops its own inline INVALID KEY clause — this one declared section now covers all of them.
Step 5 — Sorting Transactions Before Processing (Ch. 5)
Ordering transactions by customer first lets the modernized batch loop group each customer's own transactions together, rather than jumping around the indexed file at random.
Step 6 — Real-Time Balance Verification via Embedded SQL (Ch. 4)
A genuine cross-check against DB2's own live balance catches drift between the batch file and the real system of record before it compounds.
Step 7 — Running the Modernized Job (Ch. 3)
Step 8 — Wrapping With a Real CICS Front-End (Ch. 7, Ch. 9)
Rather than rewriting the whole system, a new, small CICS transaction — reusing the exact same CUSTREC copybook and the same real indexed CUSTOMER-FILE — is wrapped around it, letting a real teller look up a live balance without touching TXNBATCH2's own proven batch logic at all:
Step 9 — One Shared, Reusable Validation Class (Ch. 8)
Both TXNBATCH2 (Step 1) and the new CICS transaction (Step 8) need the exact same balance validation. Rather than duplicating it, both genuinely INVOKE the same real class method:
Chapter-Attribution Table
| Chapter | What This Modernization Step Draws From It |
|---|---|
| Ch. 1 — Indexed & Relative Files | Converting CUSTOMER-FILE to real ORGANIZATION IS INDEXED with direct-by-key access |
| Ch. 2 — Copybooks | One shared CUSTREC layout, included in both the batch program and the new CICS transaction |
| Ch. 3 — JCL | The real JOB/EXEC/DD job stream running the modernized batch step and its downstream report |
| Ch. 4 — Embedded SQL | A real DB2 cross-check catching file/database balance drift |
| Ch. 5 — Sort | Ordering transactions by customer before the main processing loop |
| Ch. 6 — DECLARATIVES | One centralized error-handling section covering every I/O against the newly-indexed file |
| Ch. 7 — CICS | The new real-time customer-lookup transaction wrapped around the existing system |
| Ch. 8 — OO COBOL | One shared, INVOKE-able validation class used by both the batch job and the CICS transaction |
| Ch. 9 — Legacy Maintenance | Recognizing and replacing the real ALTER-based patch, and choosing to wrap rather than rewrite |
Hands-On Exercises
Using this capstone's own real Step 3 and Step 4, explain in your own words why converting CUSTOMER-FILE to an indexed organization made the real DECLARATIVES-based error handling in Step 4 genuinely more valuable than it would have been for the original sequential file.
📄 View solutionUsing this capstone's own real Step 9, explain in your own words why a shared, INVOKE-able validation class is genuinely a better fit here than either duplicating the validation logic in both programs, or reusing Fundamentals' own plain BALCHECK subprogram unchanged via two separate CALL statements.
📄 View solutionUsing this capstone's own real Step 8, explain in your own words why wrapping a new CICS transaction around the existing, modernized batch system's own indexed file and copybook is a genuine, direct application of Chapter 9's own "wrap rather than rewrite" recommendation, rather than simply a convenient shortcut.
📄 View solutionChapter 10 Quick Reference — This Capstone's Own Real Modernization Steps
- Control flow — a real ALTER-based patch replaced with EVALUATE
- Data — a shared copybook; a sequential file converted to indexed with direct-by-key access
- Error handling — centralized via DECLARATIVES, covering the whole indexed file at once
- Processing order — SORT grouping transactions by customer before the main loop
- Data integrity — a real embedded SQL cross-check against DB2's own live balance
- Execution — a real JCL job stream tying the modernized batch step to a downstream report
- Modernization strategy — a new CICS front-end wrapped around proven logic, not a rewrite; one shared OO validation class reused by both paths