Exercises: Migration and Modernization
Exercise 37.1: Modernization Assessment (Beginner)
For each of the following COBOL systems, recommend a position on the modernization spectrum (Maintain, Wrap, Extend, Re-Architect, Replace) and justify your recommendation:
-
A payroll calculation program (5,000 lines) that runs nightly with no issues. It has no external interfaces. The organization wants to keep using it.
-
An inventory management system (50,000 lines) that tracks warehouse stock via 3270 screens. The business wants a mobile app for warehouse workers.
-
A loan origination system (200,000 lines) written in the 1980s. No documentation, no tests, the original developers have retired. The system processes incorrect data approximately once per month.
-
A report generation program (2,000 lines) that reads DB2 tables and produces PDF reports. The business wants the same reports available on a web dashboard.
-
A transaction processing system (100,000 lines) under CICS that handles 10,000 transactions per second with 99.999% availability. The business wants to add a REST API for partner integrations.
Exercise 37.2: API Design for COBOL Wrapping (Beginner)
Given the following COBOL COMMAREA for a customer inquiry transaction:
01 DFHCOMMAREA.
05 CA-REQUEST-TYPE PIC X(2).
88 CA-REQ-INQUIRY VALUE "IQ".
88 CA-REQ-UPDATE VALUE "UP".
05 CA-CUSTOMER-ID PIC X(10).
05 CA-RESPONSE-CODE PIC X(4).
05 CA-CUSTOMER-NAME PIC X(40).
05 CA-CUSTOMER-ADDR PIC X(60).
05 CA-CUSTOMER-PHONE PIC X(15).
05 CA-ACCT-COUNT PIC 9(2).
05 CA-TOTAL-BALANCE PIC S9(11)V99 COMP-3.
05 CA-CUSTOMER-STATUS PIC X.
- Design a REST API (OpenAPI/Swagger format) that wraps this COBOL transaction
- Define the JSON request and response schemas
- Map COBOL return codes to HTTP status codes
- Identify any data transformation challenges
Exercise 37.3: COBOL-to-Database Migration (Intermediate)
Convert the following VSAM file access code to DB2 embedded SQL:
2000-READ-CUSTOMER.
MOVE WS-CUST-KEY TO CUST-ID
READ CUSTOMER-FILE INTO WS-CUST-REC
KEY IS CUST-ID
INVALID KEY
SET CUST-NOT-FOUND TO TRUE
NOT INVALID KEY
SET CUST-FOUND TO TRUE
END-READ.
3000-UPDATE-CUSTOMER.
REWRITE CUSTOMER-REC FROM WS-CUST-REC
INVALID KEY
MOVE "REWRITE-ERR" TO WS-ERROR-MSG
PERFORM 9000-ERROR-HANDLER
END-REWRITE.
4000-ADD-CUSTOMER.
WRITE CUSTOMER-REC FROM WS-CUST-REC
INVALID KEY
MOVE "WRITE-ERR" TO WS-ERROR-MSG
PERFORM 9000-ERROR-HANDLER
END-WRITE.
5000-DELETE-CUSTOMER.
DELETE CUSTOMER-FILE
INVALID KEY
MOVE "DELETE-ERR" TO WS-ERROR-MSG
PERFORM 9000-ERROR-HANDLER
END-DELETE.
For each paragraph: 1. Write the equivalent DB2 embedded SQL 2. Handle SQLCODE appropriately 3. Note any behavioral differences between VSAM and DB2
Exercise 37.4: Containerize a COBOL Program (Intermediate)
Write a complete set of files to containerize a simple COBOL program:
- A COBOL program that takes a principal amount, interest rate, and number of years, and calculates compound interest
- A Dockerfile that compiles the COBOL program using GnuCOBOL
- A Python Flask wrapper that exposes the calculation as a REST API
- A
docker-compose.ymlthat runs the container - Test the API using
curlcommands (provide the commands)
Exercise 37.5: Strangler Fig Planning (Intermediate)
You are planning a Strangler Fig migration for a COBOL system with these modules:
| Module | Lines | Dependencies | Change Frequency | Business Criticality |
|---|---|---|---|---|
| Customer Inquiry | 2,000 | DB2 read-only | Monthly | Medium |
| Account Open | 8,000 | DB2 write, VSAM, calls Validation | Quarterly | High |
| Transaction Post | 12,000 | DB2 write, VSAM, calls Balance Calc | Weekly | Critical |
| Balance Calc | 3,000 | DB2 read-only | Rarely | Critical |
| Report Generator | 5,000 | DB2 read-only, file output | Monthly | Low |
| Validation | 4,000 | DB2 read-only | Quarterly | High |
- In what order would you migrate these modules? Justify your sequence.
- What dependencies must you consider?
- At each step, draw a diagram showing which modules are COBOL and which are in the new language.
- Identify the riskiest step and your mitigation strategy.
Exercise 37.6: Risk Assessment (Advanced)
Perform a detailed risk assessment for modernizing a 500,000-line COBOL banking system. For each modernization strategy (Maintain, Wrap, Extend, Re-Architect, Replace), evaluate:
- Technical risks (data loss, logic errors, performance degradation)
- Schedule risks (likelihood and impact of delays)
- Financial risks (cost overrun probability and magnitude)
- Organizational risks (talent, training, change management)
- Business risks (service disruption, customer impact, regulatory)
For each risk, assign a probability (Low/Medium/High) and impact (Low/Medium/High). Calculate a composite risk score and recommend a strategy.
Exercise 37.7: AI-Assisted Code Analysis (Advanced)
Select a COBOL program from your previous exercises (at least 200 lines). Using any available AI tool (ChatGPT, Claude, Copilot, etc.):
- Ask the AI to summarize what the program does in plain English
- Ask it to identify all business rules embedded in the code
- Ask it to suggest how the program could be refactored for better testability
- Ask it to translate a key paragraph to Java
- Critically evaluate each AI response: What did it get right? What did it get wrong? What nuance did it miss?
Document your findings and write a one-page assessment of AI's strengths and limitations for COBOL code analysis.
Exercise 37.8: Modernization Business Case (Advanced)
Write a one-page business case for modernizing a COBOL system of your choice (use one of the textbook running examples or create your own). Include:
- Current state assessment (costs, risks, limitations)
- Proposed modernization strategy (which point on the spectrum)
- Expected benefits (cost savings, new capabilities, risk reduction)
- Estimated costs (labor, tools, infrastructure)
- Timeline with milestones
- Risk mitigation plan
- ROI calculation (breakeven point)
Present the business case as if you were presenting to a CIO who is skeptical of modernization.