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:

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

  2. An inventory management system (50,000 lines) that tracks warehouse stock via 3270 screens. The business wants a mobile app for warehouse workers.

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

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

  5. 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.
  1. Design a REST API (OpenAPI/Swagger format) that wraps this COBOL transaction
  2. Define the JSON request and response schemas
  3. Map COBOL return codes to HTTP status codes
  4. 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:

  1. A COBOL program that takes a principal amount, interest rate, and number of years, and calculates compound interest
  2. A Dockerfile that compiles the COBOL program using GnuCOBOL
  3. A Python Flask wrapper that exposes the calculation as a REST API
  4. A docker-compose.yml that runs the container
  5. Test the API using curl commands (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
  1. In what order would you migrate these modules? Justify your sequence.
  2. What dependencies must you consider?
  3. At each step, draw a diagram showing which modules are COBOL and which are in the new language.
  4. 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:

  1. Technical risks (data loss, logic errors, performance degradation)
  2. Schedule risks (likelihood and impact of delays)
  3. Financial risks (cost overrun probability and magnitude)
  4. Organizational risks (talent, training, change management)
  5. 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.):

  1. Ask the AI to summarize what the program does in plain English
  2. Ask it to identify all business rules embedded in the code
  3. Ask it to suggest how the program could be refactored for better testability
  4. Ask it to translate a key paragraph to Java
  5. 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:

  1. Current state assessment (costs, risks, limitations)
  2. Proposed modernization strategy (which point on the spectrum)
  3. Expected benefits (cost savings, new capabilities, risk reduction)
  4. Estimated costs (labor, tools, infrastructure)
  5. Timeline with milestones
  6. Risk mitigation plan
  7. ROI calculation (breakeven point)

Present the business case as if you were presenting to a CIO who is skeptical of modernization.