COBOL Reference
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. The reference material consulted while preparing these pages is listed in the section bibliography. |
What COBOL is
COBOL (COmmon Business-Oriented Language) was specified in 1959 and is still the language in which a large share of the world’s banking, insurance, government, retail batch and transaction processing runs. It is a compiled, statically typed, record-oriented language designed so that business rules read almost like prose. Two properties explain why it has survived. Its arithmetic is decimal and fixed-point (PIC 9(7)V99, packed decimal COMP-3), so money is added, rounded and truncated exactly as an accountant would on paper rather than as binary floating point. And its input and output are built around fixed-length records, sequential, indexed and relative files and, on the mainframe, VSAM, Db2 and CICS, which is the shape that high-volume batch and online processing has.
COBOL is standardized by ISO/IEC. The language has gained structured programming, intrinsic functions, user-defined functions, object orientation, pointers, UTF-16 and UTF-8 data, JSON and XML statements and, in the 2023 edition, new numeric and syntax features, while compilers keep compiling programs written decades ago. This section teaches the modern language and also the old code you will meet in maintenance work.
Version baseline
This section is written against ISO/IEC 1989:2023, the current published language standard (a fourth edition is in preparation and nothing in the section depends on it). The runnable toolchain is GnuCOBOL 3.2, released on 28 July 2023 and still the latest release when this section was checked on 2026-10-20: every portable example was compiled with cobc -x -Wall (plus -std=ibm where the page says so) and run, and the output shown is real. The mainframe pages follow IBM Enterprise COBOL for z/OS 6.5 with its PTFs through September 2026, on z/OS 3.2, with Db2 13 for z/OS, CICS Transaction Server 6.x and IMS 15.6. z/OS-only code (JCL, IDCAMS, DFSORT, EXEC SQL, EXEC CICS, BMS maps and IMS calls) cannot run on a laptop, so it was checked statement by statement against the IBM manuals and the pages say "z/OS; not run here". The other compilers (IBM COBOL for Linux on x86, Rocket Visual COBOL and Enterprise Developer, Fujitsu NetCOBOL) are described from their documentation, because they were not available for testing. Where a feature came from a later standard or a later compiler release, the page names the release that introduced it.
The Circulation scenario
The examples across the section share one small, original domain: Circulation, the batch and online back office of a public library.
-
BOOKMASTis an indexed book master file keyed by book number (BOOK-ID), with the ISBN, title, copies on the shelf, price and a status (active or withdrawn). -
MEMBMASTis an indexed member file (member number, name, joining date, outstanding fines and a status, active or suspended). The fines are signed zoned decimal (PIC S9(5)V99) so that the sample files stay readable text; USAGE and Numeric Representation explains packed decimal (COMP-3), the form a z/OS master file normally uses for such amounts. -
LOANTRANis a daily sequential transaction file of checkouts and returns, each with the member, the book and the date (YYYYMMDD). -
The record layouts live in the copybooks
BOOKREC,MEMBRECandLOANREC, listed in full on Copybooks, COPY, and REPLACE, so the same layouts appear on every page that uses them. -
The nightly batch run sorts the transactions, applies them to the masters with a balance-line update, computes overdue fines with
ROUNDED, prints a circulation report with control breaks and exports a JSON summary. -
On the z/OS pages the same data lives in VSAM KSDS clusters and a Db2
LOANtable, the batch run is a JCL job and a CICS transactionCINQanswers "where is this book?" (on the shelf, all copies on loan, or withdrawn) from a 3270 map.
The pages build on each other. The cheat sheet summarises the whole section.
New here? Read in this order
-
Getting Started — install GnuCOBOL, a first program, reading compiler messages
-
Program Structure and Divisions and Reference Format: Fixed and Free
-
The PICTURE Clause and USAGE and Numeric Representation — the heart of COBOL data
-
Conditions, IF and EVALUATE and PERFORM and Structured Programming
-
JCL for COBOL Programmers — how the same programs run as batch jobs on z/OS
Then pick topics as you need them and keep the cheat sheet at hand. If you maintain existing code, start with Legacy Features and Migration and What’s New in COBOL; if you are planning to move away from the mainframe, read Modernization Strategies.
What’s covered
Getting started
| Page | What it covers |
|---|---|
installing GnuCOBOL 3.2, Hello world in fixed and free format, the |
|
from CODASYL in 1959 to ISO/IEC 1989:2023, what each edition added and the standards process |
|
IBM, GnuCOBOL ( |
|
z/OS, LPARs, data sets, TSO/ISPF, JES, SDSF, z/OS UNIX, EBCDIC and a developer’s day |
|
the IDEs, editors and compilers commonly used for COBOL, with links to the official pages |
Program structure
| Page | What it covers |
|---|---|
the four divisions, sections and paragraphs, |
|
columns and areas, comment and continuation lines, free format and the |
|
character set, reserved words, every literal form and figurative constants |
|
|
|
|
Data division
| Page | What it covers |
|---|---|
sections, level numbers, group and elementary items, qualification and storage lifetimes |
|
every symbol, data categories and numeric-edited items |
|
zoned and packed decimal, binary, floating point and the byte layouts behind them |
|
initial values, |
|
alternate views of storage, level 66 and user-defined types |
|
EBCDIC against ASCII, CCSIDs, |
|
subscripts, indexes, multidimensional tables and |
|
|
|
|
Procedure division
| Page | What it covers |
|---|---|
the legality table, alignment, truncation and |
|
|
|
relation, class, sign and condition-name tests, |
|
every |
|
reference modification, |
|
the function categories, |
|
|
|
console input and output, command-line access and the screen section |
|
conditional phrases, |
Files
| Page | What it covers |
|---|---|
the file model, |
|
|
|
|
|
slot-numbered files and the RRDS behind them |
|
the two-character status key with a full table |
|
|
|
print layouts, control breaks, |
Modular programming
| Page | What it covers |
|---|---|
static and dynamic calls, parameter passing modes, |
|
|
|
calling C and being called from C and Python, and Java on z/OS |
|
classes, methods, inheritance and the Java-based IBM model |
Data interchange
| Page | What it covers |
|---|---|
|
|
|
Mainframe batch and middleware
| Page | What it covers |
|---|---|
|
|
the compile, bind and run steps, compiler options and runtime options |
|
allocating data sets, |
|
host variables, |
|
pseudo-conversational design, |
|
the hierarchical model, PCBs and the DL/I call interface |
Development practices
| Page | What it covers |
|---|---|
VS Code extensions, Zowe Explorer and the Zowe CLI |
|
run-time checks, tracing, coverage, abends and dumps |
|
test design, a runnable harness and the mainframe test frameworks |
|
numeric usage costs and the options that matter |
|
a style guide for maintainable batch programs |
|
a GitHub Actions workflow and a mainframe pipeline outline |
Evolution and reference
| Page | What it covers |
|---|---|
keep, rehost, refactor, rearchitect or replace, and exposing programs as APIs |
|
obsolete elements you will still meet, with the modern replacement |
|
what the 2002, 2014 and 2023 standards and the compiler releases added |
|
a one-page, downloadable summary of the whole section |
How this section relates to the others
-
C Reference: GnuCOBOL translates COBOL to C and compiles it with the system C compiler, so C linkage, the C runtime and calling conventions matter for interoperability.
-
Java Reference: Java and COBOL meet through the Java interoperability facilities of Enterprise COBOL, and
BigDecimalis the Java counterpart of COBOL decimal arithmetic (see Arithmetic and COMPUTE). -
SQL Reference: SQL itself is covered there; Embedded SQL and Db2 shows how it is embedded in COBOL.
-
Migration Path: Legacy to Modern Stack: Modernization Strategies applies the same strangler-fig approach to COBOL estates.
The reference material consulted is listed in the bibliography below. One commercial title, Andy Vickler’s Cobol: 3 books in 1, was reviewed and deliberately not used, because it proved unreliable as a technical source.
Bibliography
Every source used by the pages of this section is listed here, grouped by origin, and each is cited again on the page that uses it (in the == References section and after each example). Links were checked on 2026-10-20; the ISO and some IBM pages block scripted requests, so a few of those links could not be opened automatically.
Book
-
Tom Taulli, Modern Mainframe Development: COBOL, Databases, and Next-Generation Approaches, 1st edition. O’Reilly Media, 2022. ISBN 978-1-098-10702-4. Publisher page; companion code at ttaulli/Modern-mainframe-development.
The book is a consulted reference, not the primary source: no text, listing, figure or exercise was taken from it, and every example was written against the current official documentation. On any discrepancy, and wherever the book is silent on a later feature, the official documentation wins; where the book shows an outdated form, the pages say so in prose where the concept is covered.
Standards and committees
-
ISO/IEC 1989:2023, Information technology — Programming languages — COBOL
-
ISO/IEC 1989:2014, the 2002 edition (cited by name) and the fourth-edition project
-
INCITS: Available Now — 2023 Edition of ISO/IEC 1989 and the 2003 press release on the 2002 revision
-
ISO/IEC JTC1/SC22/WG4, the COBOL working group
-
History: the Computer History Museum’s Grace Hopper profile and its COBOL catalogue entry
IBM COBOL compilers
-
IBM Enterprise COBOL for z/OS 6.5 and its PDF library: the Language Reference (SC27-8713-04) and Programming Guide (SC27-8714-04) with every topic page used, the Migration Guide (GC27-8715-04), Messages and Codes (PDF), the What’s New pages for 6.5, 6.4 and 6.3, and the standard-features page (
lr/ref/rlstdim.html) -
IBM COBOL for Linux on x86 1.2 documentation library
GnuCOBOL
-
The project and downloads: gnu.org, gnucobol.sourceforge.io, ftp.gnu.org and the 3.2 files on SourceForge
-
The GnuCOBOL Manual
-
The Programmer’s Guide and its 3.2 PDF edition from the guides page
-
The Quick Reference, the Sample Programs and the FAQ
-
The Homebrew formula and the Debian package pages used by the install section, gnucobol3 in trixie and gnucobol3 in bookworm
-
The GnuCOBOL 3.2
NEWSfile (also in the release tarball); LWN’s summary of the release is a secondary source and is labelled as such
Other compilers
-
Rocket Software documentation for Rocket Visual COBOL and Enterprise Developer (the 11.0 line), including the Visual COBOL supported-platforms document
-
Fujitsu NetCOBOL V13: the NetCOBOL for Windows product page and the Fujitsu NetCOBOL Enterprise Edition Developer V13.0.0 manual index
z/OS and middleware
-
z/OS 3.2 and its books under the PDF library: the MVS JCL Reference (
ieab600_v3r2.pdf) and JCL User’s Guide (ieab500_v3r2.pdf), the DFSORT Application Programming Guide (icea100_v3r2.pdf), DFSMS Using Data Sets (idad400_v3r2.pdf), the Language Environment Programming Guide (ceea200_v3r2.pdf) and Programming Reference (ceea300_v3r2.pdf), and the z/OS UNIX System Services User’s Guide (bpxa400_v3r2.pdf) -
Db2 13 for z/OS: the COBOL embedded-SQL and program-preparation pages used
-
CICS Transaction Server 6.x: developing COBOL applications, the integrated translator, the command summary, the command pages used and the compiler-support changes page
-
IMS 15.6: Application Programming and Application Programming APIs
Tooling, testing and learning resources
-
Learning: the Open Mainframe Project COBOL Programming Course (also on the project page), the OMP COBOL Working Group and IBM Z Xplore
-
Zowe: the documentation and Zowe Explorer (its Marketplace page and the installation guide)
-
Editors and IDEs: IBM Z Open Editor, Broadcom COBOL Language Support (also on its Marketplace page) and IBM Developer for z/OS, including zUnit and z/OS Debugger
-
Testing: Broadcom Test4z (its documentation is on Broadcom TechDocs; search for Test4z there, because no stable address of the product pages could be confirmed), Galasa and COBOL Check (archived by its owner on 28 May 2026)
-
Modernization: IBM watsonx Code Assistant for Z and its documentation
-
Community tools, labelled as such: the Open-COBOL-ESQL preprocessor used for GnuCOBOL with PostgreSQL
Specifications
Each is cited where a page uses it:
-
IEEE 754-2019 (binary and decimal floating point)
-
IBM’s CCSID and code-page documentation for EBCDIC: Coded character sets and CCSIDs (Db2 13 for z/OS)