Skip to content
LumenaryAcademy

Lumenary CS · Programming languages

COBOL

The business language of 1959 that still settles payments, pays pensions and prices insurance, from a first program to the mainframe.

COBOL (COmmon Business-Oriented Language) was designed in 1959 by a committee of computer makers, users and the United States government, drawing heavily on Grace Hopper's FLOW-MATIC. It was built for business data: records read from files, exact decimal arithmetic on money, and long, readable programs that people other than the author can maintain. More than sixty years later it still runs a large share of the world's core banking, card processing, insurance, tax and social-security systems, mostly on IBM mainframes, and it is still standardised (ISO/IEC 1989:2023) and still compiled by current, supported compilers.

This course is for anyone who already knows what a variable, a loop and a function are: the Start level of Lumenary CS or equivalent experience in any language. No mainframe access is needed. It begins with the four divisions and a first program, works through data definitions and picture clauses, fixed-point decimal arithmetic, paragraphs and PERFORM, tables, strings, files and reports, and ends with subprograms, modern COBOL, how professionals work on mainframes with JCL, CICS and Db2, and a complete payroll report.

To run the code, install GnuCOBOL, the free compiler from the GNU project (Linux distributions package it as gnucobol; the site links builds for Windows and macOS). Save a program as main.cob, then compile and run it with cobc -x -free main.cob -o main && ./main. COBOL has no official online playground. Every complete program in these lessons was compiled and run with GnuCOBOL 3.2 in free format by Lumenary's test suite, and the output shown is the output it printed. The lessons were drafted with AI assistance and are awaiting review by a human computer scientist.

AI-draftedAwaiting review by a computer scientist
  • Chloe · The Designer
    “Why is the language built this way?”
  • Margaret · The Profiler
    “What does it print, and what does it cost?”
  • Gideon · The Language Lawyer
    “What exactly does the language guarantee?”

Foundations · 3 lessons

Divisions, pictures and decimal money

Where COBOL came from and why it still matters, the four divisions of a program, describing data with levels and picture clauses, and the exact decimal arithmetic that money needs.

  1. 1First steps in COBOLWhere COBOL came from, why banks and governments still run it, and a first program in four divisions. 50 min
  2. 2Data, levels and picturesDescribing every byte in advance, the rules of MOVE, and edited pictures that format numbers for people. 55 min
  3. 3Decimal arithmetic and moneyWhy money needs fixed-point decimals, how COBOL stores numbers (zoned, packed, binary), and the arithmetic verbs with ROUNDED and ON SIZE ERROR. 55 min

Practice · 3 lessons

Procedures, tables, strings and files

Structure a program with paragraphs and PERFORM, decide with IF and EVALUATE, search tables, take text apart and put it together, and read and write files and formatted reports.

  1. 4Paragraphs, PERFORM and control flowStructuring the procedure division into paragraphs, looping with PERFORM, deciding with IF and EVALUATE, and the full stop that can change a program's meaning. 55 min
  2. 5Tables and stringsArrays the COBOL way with OCCURS, linear and binary search, and taking text apart and putting it together with STRING, UNSTRING, INSPECT and reference modification. 60 min
  3. 6Files and reportsSequential and indexed files, FILE STATUS, the SORT statement, and printed reports with headings and control breaks. 60 min

Professional · 2 lessons

Subprograms, mainframes and a complete program

Split a system into called programs and copybooks, meet modern COBOL and the mainframe world of JCL, CICS and Db2, and build a payroll report from a file of employees.

  1. 7Subprograms, modern COBOL and the mainframeCalling programs and sharing copybooks, the newer language features, and the world of z/OS, JCL, CICS and Db2 where most professional COBOL runs. 65 min
  2. 8Project: a weekly payroll reportA complete batch program in professional style, from specification to balanced control totals, and where to go next. 75 min

Further reading and resources