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.

  • BOOKMAST is 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).

  • MEMBMAST is 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.

  • LOANTRAN is 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, MEMBREC and LOANREC, 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 LOAN table, the batch run is a JCL job and a CICS transaction CINQ answers "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

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.

mindmap root((COBOL Reference)) Getting started GnuCOBOL and Enterprise COBOL History and standards Mainframe primer Program structure Divisions Reference format Copybooks and directives Data division PICTURE and USAGE Packed decimal REDEFINES and TYPEDEF Tables Pointers Procedure division MOVE and arithmetic Conditions and PERFORM Strings and intrinsic functions Error handling Files Sequential Indexed and VSAM Relative Sort and reports Modular programming CALL and linkage Functions C, Java and Python Object-oriented COBOL Data interchange JSON XML Mainframe JCL and datasets Language Environment Db2 CICS IMS Practice Tooling and Zowe Debugging and testing Performance DevOps Evolution Modernization Legacy features What is new

What’s covered

Getting started

Page What it covers

Getting Started

installing GnuCOBOL 3.2, Hello world in fixed and free format, the cobc options, a first Circulation program and free ways to try z/OS

History and Standards

from CODASYL in 1959 to ISO/IEC 1989:2023, what each edition added and the standards process

Compilers and Dialects

IBM, GnuCOBOL (-std= values and configuration files), Rocket and Fujitsu, with a feature-support table

Mainframe Environment Primer

z/OS, LPARs, data sets, TSO/ISPF, JES, SDSF, z/OS UNIX, EBCDIC and a developer’s day

IDEs & Tools

the IDEs, editors and compilers commonly used for COBOL, with links to the official pages

Program structure

Page What it covers

Program Structure and Divisions

the four divisions, sections and paragraphs, PROGRAM-ID forms and SPECIAL-NAMES

Reference Format: Fixed and Free

columns and areas, comment and continuation lines, free format and the >>SOURCE directive

Words, Literals and Figurative Constants

character set, reserved words, every literal form and figurative constants

Copybooks, COPY, and REPLACE

COPY with REPLACING, REPLACE, library search paths and the copybook discipline

Compiler Directives and Conditional Compilation

>>DEFINE, >>IF, >>EVALUATE, CBL and PROCESS options and debugging lines

Data division

Page What it covers

Data Division and Level Numbers

sections, level numbers, group and elementary items, qualification and storage lifetimes

The PICTURE Clause

every symbol, data categories and numeric-edited items

USAGE and Numeric Representation

zoned and packed decimal, binary, floating point and the byte layouts behind them

VALUE, INITIALIZE and Condition Names

initial values, INITIALIZE and 88-level condition names

REDEFINES, RENAMES and TYPEDEF

alternate views of storage, level 66 and user-defined types

National UTF-8 and Code Pages

EBCDIC against ASCII, CCSIDs, NATIONAL and UTF-8 data

Tables and OCCURS

subscripts, indexes, multidimensional tables and OCCURS DEPENDING ON

Searching and Sorting Tables

SEARCH, SEARCH ALL and sorting a table

Pointers and Dynamic Storage

POINTER, BASED, ALLOCATE and FREE

Procedure division

Page What it covers

MOVE and Data Movement

the legality table, alignment, truncation and MOVE CORRESPONDING

Arithmetic and COMPUTE

ADD through COMPUTE, ROUNDED, ON SIZE ERROR and intermediate precision

Conditions, IF and EVALUATE

relation, class, sign and condition-name tests, IF and EVALUATE

PERFORM and Structured Programming

every PERFORM form and structured design

Strings: STRING, UNSTRING and INSPECT

reference modification, STRING, UNSTRING and INSPECT

Intrinsic Functions

the function categories, NUMVAL, string, math and date functions

Dates and Times

CURRENT-DATE, integer dates, date arithmetic and the year 2000 legacy

ACCEPT, DISPLAY and Console I/O

console input and output, command-line access and the screen section

Error Handling and Declaratives

conditional phrases, FILE STATUS and DECLARATIVES

Files

Page What it covers

File Concepts: SELECT and FD

the file model, SELECT, ASSIGN, the FD entry and OPEN and CLOSE

Sequential Files

READ, WRITE, REWRITE, line sequential and variable-length records

Indexed Files and VSAM

ORGANIZATION INDEXED, alternate keys and VSAM KSDS, ESDS and RRDS with IDCAMS

Relative Files

slot-numbered files and the RRDS behind them

File Status Codes

the two-character status key with a full table

Sort and Merge

SORT and MERGE, input and output procedures and the sort registers

Reports and Report Writer

print layouts, control breaks, LINAGE and the Report Writer module

Modular programming

Page What it covers

Subprograms, CALL and Linkage

static and dynamic calls, parameter passing modes, LOCAL-STORAGE and recursion

User-Defined Functions and Prototypes

FUNCTION-ID, REPOSITORY and prototypes

Interoperability with C, Java and Python

calling C and being called from C and Python, and Java on z/OS

Object-Oriented COBOL

classes, methods, inheritance and the Java-based IBM model

Data interchange

Page What it covers

JSON GENERATE and PARSE

JSON GENERATE and JSON PARSE with their options and special registers

XML GENERATE and PARSE

XML GENERATE and XML PARSE with a processing procedure

Mainframe batch and middleware

Page What it covers

JCL for COBOL Programmers

JOB, EXEC and DD, procedures, conditions and return codes

Compiling, Linking and Language Environment

the compile, bind and run steps, compiler options and runtime options

Datasets and Mainframe Utilities

allocating data sets, RECFM and LRECL, IDCAMS and DFSORT

Embedded SQL and Db2

host variables, SQLCA, cursors and the precompile and bind steps

CICS Online Programming

pseudo-conversational design, EXEC CICS, BMS maps and RESP handling

IMS DL/I Overview

the hierarchical model, PCBs and the DL/I call interface

Development practices

Page What it covers

Modern Tooling: VS Code and Zowe

VS Code extensions, Zowe Explorer and the Zowe CLI

Debugging and Troubleshooting

run-time checks, tracing, coverage, abends and dumps

Testing COBOL Programs

test design, a runnable harness and the mainframe test frameworks

Performance and Compiler Options

numeric usage costs and the options that matter

Coding Standards and Best Practices

a style guide for maintainable batch programs

DevOps and CI/CD for COBOL

a GitHub Actions workflow and a mainframe pipeline outline

Evolution and reference

Page What it covers

Modernization Strategies

keep, rehost, refactor, rearchitect or replace, and exposing programs as APIs

Legacy Features and Migration

obsolete elements you will still meet, with the modern replacement

What’s New in COBOL

what the 2002, 2014 and 2023 standards and the compiler releases added

Cheat Sheet (PDF)

a one-page, downloadable summary of the whole section

How this section relates to the others

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

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.

IBM COBOL compilers

GnuCOBOL

Other compilers

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

Specifications

Each is cited where a page uses it: