WORKING-STORAGE
The section of a COBOL program that declares its internal variables: counters, totals, flags and work areas.
Also written WORKING-STORAGE SECTION
WORKING-STORAGE SECTION is where a COBOL program declares the variables it uses for its own purposes, as opposed to the records it reads and writes.
Everything a program needs to hold while it runs is here: accumulators for totals, subscripts for loops, switches recording whether the end of a file has been reached, formatted fields for printing, and constants such as messages and table values.
The storage is allocated once and persists for the whole run. A variable keeps its value between paragraphs and across iterations of a loop unless something changes it, and initialising values explicitly rather than assuming them is a habit worth forming early.
Values can be set at declaration time, which is how constants and lookup tables are defined.
By convention, names here are given prefixes marking what they are, whether a switch, a counter or a work field, so that reading the PROCEDURE DIVISION tells you what kind of thing each name refers to without looking it up. Site standards for this vary, but nearly every site has one.
Related terms
- DATA DIVISIONThe part of a COBOL program that declares every record layout and variable it will use.
- PICTURE clauseThe COBOL declaration that says what kind of data a field holds and how long it is, written as PIC.
- Level numberThe two-digit number in front of a COBOL data item that shows how fields nest inside a record.
- PROCEDURE DIVISIONThe part of a COBOL program that contains the actual logic, the statements that run.
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.