Skip to main content

End of the COBOL Course

Summary and Final Challenge

Congratulations! You have completed all 8 modules and 16 lessons of the COBOL course — from the four divisions, fixed-format columns, PIC/VALUE/REDEFINES, and decimal arithmetic through PERFORM loops, OCCURS tables, batch file I/O, STRING/INSPECT, CALL subprograms, SORT, copybooks, and COMP-3 packed decimals.

8 modules · 16 lessons · 80 checkpoints

Every COBOL exercise is checked locally via the deterministic in-browser COBOL subset evaluator (column 72 diagnostics, WORKING-STORAGE state, DISPLAY output, and keywords); for full GNUCOBOL compilation, click Open on OneCompiler in any panel.

01 · Structure, Columns and DATA DIVISION

The four mandatory divisions, the fixed 80 column format (Area A / Area B) and the exact RAM layout of the PIC clauses.

  • 4 Divisions
  • Col 1–80
  • PIC X / 9 / V / S
  • VALUE & Padding

02 · Arithmetic and Decisions

Formal COBOL arithmetic (ADD, SUBTRACT, MULTIPLY, DIVIDE), COMPUTE expressions, rounding and branching with IF and EVALUATE.

  • ADD / SUBTRACT
  • MULTIPLY / DIVIDE
  • COMPUTE ROUNDED
  • IF / EVALUATE

03 · Modularity, Paragraphs and Cycles

Structure the PROCEDURE DIVISION into reusable paragraphs with PERFORM, avoid accidental fall-throughs, and master TIMES, UNTIL, and VARYING.

  • Paragraphs
  • PERFORM TIMES
  • PERFORM UNTIL
  • PERFORM VARYING

04 · Hierarchical Records and Tables OCCURS

Organize data into contiguous group items (01/05/10), MOVE group semantics, and base-1 arrays with OCCURS and SEARCH.

  • 01 / 05 / 10 Groups
  • REDEFINES
  • OCCURS Tables
  • 1-Based Subscripts

05 · Batch Sequential Files & I/O

Connect logical and physical files via SELECT ASSIGN / FD and implement safe batch loops with OPEN, priming READ AT END, WRITE and CLOSE.

  • SELECT / ASSIGN
  • FD Records
  • OPEN / CLOSE
  • Priming READ / EOF

06 · Strings, INSPECT and Subroutines

Fixed text field processing with STRING, UNSTRING and INSPECT and multi-program modular architecture via CALL, LINKAGE SECTION and GOBACK.

  • STRING / UNSTRING
  • INSPECT TALLYING
  • CALL ... USING
  • LINKAGE & GOBACK

07 · File Sorting, Copybook and Level 88

High performance pipeline with SORT/MERGE to SD work files, reuse of shared layouts COPY ... REPLACING, REDEFINES and Level 88 condition names.

  • SORT USING / GIVING
  • MERGE Files
  • COPY Copybooks
  • Level 88 Conditions

08 · COMP-3, Tax Accuracy & Legacy Ops

Binary/BCD representation in mainframe memory (COMP-3, DISPLAY Zoned), exact financial arithmetic, and diagnosis of batch jobs and historical bugs.

  • COMP-3 Packed BCD
  • ON SIZE ERROR
  • DISPLAY vs Edited
  • Y2K Maintenance

The Final Challenge, in Five Steps

Combine real-world mainframe batch idioms across five progressive steps: PIC accounting declaration, COMPUTE interest calculation, PERFORM paragraph iteration, Level-88 condition branching, and STRING key composition with COMP-3 storage.

1 · Declare the Interest Rate Variable (DATA DIVISION)

Allocate `WS-INTEREST-RATE` in `WORKING-STORAGE SECTION` using an implied decimal `V` for banking precision (Module 1).

Exercise#cobol.boss.e1
Attempts: 0Loading…

Declare a numeric data item 01 WS-INTEREST-RATE with PIC 9V99 and initial VALUE 0.05. inside WORKING-STORAGE SECTION..

Loading editor…
Show hint

Write 01 WS-INTEREST-RATE PIC 9V99 VALUE 0.05. starting at column 8 (Area A).

Solution available after 3 attempts

2 · Algebraic Interest Calculation (COMPUTE)

Compute accrued interest by multiplying balance and rate in a single readable `COMPUTE` statement (Module 2).

Exercise#cobol.boss.e2
Attempts: 0Loading…

Write a COMPUTE statement storing WS-BALANCE * WS-INTEREST-RATE into WS-INTEREST-AMOUNT.

Loading editor…
Show hint

Use COMPUTE WS-INTEREST-AMOUNT = WS-BALANCE * WS-INTEREST-RATE. in Area B (Col 12).

Solution available after 3 attempts

3 · Modular Paragraph Repetition (PERFORM TIMES)

Execute a dedicated calculation paragraph five consecutive times without duplicating logic (Module 3).

Exercise#cobol.boss.e3
Attempts: 0Loading…

Invoke the CALCULATE-INTEREST paragraph 5 TIMES using PERFORM.

Loading editor…
Show hint

Write PERFORM CALCULATE-INTEREST 5 TIMES. under MAIN-PROCEDURE..

Solution available after 3 attempts

4 · Level-88 Condition Names & Branching (IF)

Model a transaction state using a Level-88 condition name for clean, self-documenting batch checks (Module 4 + Module 7).

Exercise#cobol.boss.e4
Attempts: 0Loading…

Define 88 STATUS-VALID VALUE "V". beneath WS-TX-STATUS and check IF STATUS-VALID DISPLAY "APPROVED" END-IF. in PROCEDURE DIVISION.

Loading editor…
Show hint

Add 88 STATUS-VALID VALUE "V"., then write IF STATUS-VALID, DISPLAY "APPROVED", and close cleanly with END-IF..

Solution available after 3 attempts

5 · STRING Composite Key & Packed COMP-3 Balance

Declare a compact packed-decimal `COMP-3` accumulator and assemble a clean batch key via `STRING` (Module 6 + Module 8).

Exercise#cobol.boss.e5
Attempts: 0Loading…

Declare 01 WS-PACKED-BAL PIC S9(7)V99 COMP-3 VALUE 0. and concatenate WS-ACCT (DELIMITED BY SPACE), "-", and WS-YEAR (DELIMITED BY SIZE) INTO WS-RECORD-KEY ending with END-STRING..

Loading editor…
Show hint

Use PIC S9(7)V99 COMP-3 and STRING WS-ACCT DELIMITED BY SPACE "-" DELIMITED BY SIZE WS-YEAR DELIMITED BY SIZE INTO WS-RECORD-KEY END-STRING..

Solution available after 3 attempts

Printable COBOL Cheatsheet (11 sections)

All essential COBOL syntax on one printable page: divisions, 80-column ruler, PIC, REDEFINES, Level 88, OCCURS/SEARCH, File I/O, STRING/CALL, and COMP-3.

Open cheatsheet

What now?

Practice immediately inside the COBOL Playground with instant in-browser simulation, or run full batch programs in GNUCOBOL via OneCompiler.