What You Need to Know Before Reading COBOL Source Suddenly - DIVISION, PIC, COMP-3, COPY, and PERFORM First
Handover work, production incidents, maintenance on a vendor package.
In situations like that, one day a COBOL source file suddenly lands on your desk.
- the file names end in
.cblor.cpy - every identifier is uppercase
01,05,77, and88appear everywhere- something like
PIC S9(7)V99 COMP-3shows up and looks half like an accounting package, half like a spell - and on top of that, the code is full of
COPY, so the file you opened is not even the whole picture
That is usually the point where your brain turns slightly to dust.
The good news is that the map you need is not actually that large.
There are dialect and product differences in COBOL, but the structural ideas you need first are surprisingly consistent across real business systems.
This article organizes the minimum set of concepts for people who suddenly have to read COBOL source.
Contents
- 1. The short answer
- 2. Think of COBOL first as a language of data shape
- 3. Look for the four DIVISIONs first
- 4. Do not panic about fixed-format layout
- 5. The minimum you need from DATA DIVISION
- 5.1 Level numbers
- 5.2 PICTURE / PIC
- 5.3 USAGE, DISPLAY, COMP, COMP-3
- 5.4 REDEFINES, OCCURS, COPY, FILLER
- 6. The minimum you need from PROCEDURE DIVISION
- 6.1 PERFORM
- 6.2 IF, EVALUATE, and scope
- 6.3 READ, WRITE, CALL
- 7. Remember that important parts may live outside the source file
- 8. A safe reading order
- 9. Common places where people get stuck
- 9.1 Thinking REDEFINES is a separate variable
- 9.2 Thinking 88 is an independent Boolean
- 9.3 Ignoring COPY
- 9.4 Thinking MOVE is just simple assignment
- 9.5 Underestimating the period
- 9.6 Treating packed decimal or EBCDIC as random corruption
- 10. A quick cheat sheet
- 11. Wrap-up
- 12. References
1. The short answer
Here is the deliberately rough but very practical version.
- COBOL is not just a logic language; it is very strongly a record-definition language
- If you read only
PROCEDURE DIVISION, you usually understand only half the program. Start withDATA DIVISION PICdescribes the shape of an itemUSAGEdescribes how the value is representedCOMP-3means packed decimal, and it appears constantly around money, counts, and rates88is not really a separate variable; it is a condition name attached to the value of the previous itemREDEFINESmeans view the same memory in another shape, not copy it- If the code uses
COPY, then the file you opened is not the whole program yet - If you can follow
PERFORM,IF,EVALUATE,READ,WRITE, andCALL, you can usually recover the main flow - In older source, fixed-format column positions matter. The spacing is not decorative
So if you remember only a small core, remember this:
DIVISION, PIC, USAGE, COMP-3, REDEFINES, OCCURS, 88, COPY, and PERFORM.
2. Think of COBOL first as a language of data shape
If you come from C# or Java, your instinct is often to follow if, loops, and calls first.
With COBOL, it is usually faster to ask:
what records enter, what records leave, and what working buffers exist?
Typical business COBOL often looks like this:
- read a record from a file or database
- put it into working storage
- branch on conditions
- re-pack the data into another record shape
- write it out
That is why layout often comes before algorithm when you read it.
3. Look for the four DIVISIONs first
COBOL source is first divided into four major parts.
| DIVISION | First thing to look for |
|---|---|
IDENTIFICATION DIVISION |
Program name, old comments, origin clues |
ENVIRONMENT DIVISION |
Files, external resources, I/O assumptions |
DATA DIVISION |
Record definitions, working storage, parameters |
PROCEDURE DIVISION |
Actual processing steps |
In practice, these areas are especially important:
FILE SECTIONWORKING-STORAGE SECTIONLOCAL-STORAGE SECTIONLINKAGE SECTION
If you see LINKAGE SECTION and PROCEDURE DIVISION USING ..., the program may not be stand-alone at all. It may be receiving data from the outside as a subprogram.
4. Do not panic about fixed-format layout
In older COBOL, the column position itself can have meaning.
At a rough level:
- columns 1 to 6: sequence numbers
- column 7: indicator area
- columns 8 to 11: Area A
- columns 12 to 72: Area B
Column 7 matters especially:
*or/means comment line-means continuation lineDcan indicate debugging lines
So what looks like old-fashioned indentation is not always just style.
If you do not first check whether the file is fixed format or free format, modern editing or formatting can break things in a hurry.
5. The minimum you need from DATA DIVISION
5.1 Level numbers
COBOL builds hierarchy with level numbers, not indentation.
At minimum, remember this:
01: top-level record or group02to49: nested levels below that77: independent elementary item88: condition name
The important mistake to avoid is thinking 88 is a separate Boolean variable.
Usually it is just a readable name attached to a value of the preceding item.
5.2 PICTURE / PIC
PIC tells you the shape of the item.
The most common parts are:
X: character9: numeric digitS: signedV: implied decimal point
For example:
PIC X(10)means 10 charactersPIC 9(5)means a 5-digit numeric fieldPIC S9(7)V99means signed, 7 integer digits, 2 decimal digits
The important part here is V: it usually means the decimal point is logical, not stored as a literal . character.
5.3 USAGE, DISPLAY, COMP, COMP-3
If PIC tells you the shape, USAGE tells you how the value is represented.
At minimum, keep these in mind:
| Form | Rough meaning | Reading caution |
|---|---|---|
DISPLAY |
external decimal / character style representation | on mainframe systems, EBCDIC may still matter |
COMP / BINARY |
binary representation | visible digit count and internal storage are not the same thing |
COMP-3 / PACKED-DECIMAL |
packed decimal | it looks broken if you try to read it as plain text |
When you see COMP-3, the practical reaction is often:
- this is packed decimal
- it is probably money, counts, rates, or another business numeric field
- text-oriented inspection is going to mislead you
5.4 REDEFINES, OCCURS, COPY, FILLER
These are classic reading traps.
REDEFINESmeans the same storage is viewed with another layoutOCCURSmeans a table / arrayCOPYmeans the source you opened is incomplete until you inspect the copybook tooFILLERmeans unnamed storage that still takes space
If you ignore COPY, you are very often reading only half the map.
6. The minimum you need from PROCEDURE DIVISION
6.1 PERFORM
PERFORM is the first structural keyword you want to get comfortable with.
In rough terms, it can mean:
- execute another paragraph or section
- loop until a condition changes
- repeat a fixed number of times
If you can follow the main PERFORM chain, you can usually recover the backbone of the program.
6.2 IF, EVALUATE, and scope
Modern COBOL can use explicit terminators like END-IF, but older code can still make heavy use of periods as scope boundaries.
That means a single . can change:
- where an
IFreally ends - how far a
PERFORMbody extends - where control jumps next
When reading older COBOL, it is often safer to watch periods rather than end-of-line shape.
6.3 READ, WRITE, CALL
In business COBOL, these are part of the main reading path all the time.
READWRITEREWRITESTARTCALL
If you see CALL 'SUBPGM' USING ..., the next place to look is usually:
- the callee’s
LINKAGE SECTION - the callee’s
PROCEDURE DIVISION USING
That is how you recover the data contract between programs.
7. Remember that important parts may live outside the source file
COBOL source often does not describe the whole world by itself.
Important pieces may sit outside the current file:
- file definitions
- runtime environment
- database access
- transaction environment
- job control
That is why “I still do not know where this file really comes from” is often not a failure of reading skill. It can simply mean you have not found the surrounding context yet.
8. A safe reading order
If COBOL suddenly lands in front of you, this order is usually safe:
- find every
COPY - list the top-level
01records - read
PICandUSAGE - search for
READ,WRITE,REWRITE,CALL,EXEC SQL, andEXEC CICS - follow only the main path first
- inspect
88condition names and status fields - mark
REDEFINES,OCCURS DEPENDING ON, andCOMP-3as danger zones - if file I/O exists, inspect
FILE STATUS
That order is much safer than trying to understand the whole source file line by line from the beginning.
9. Common places where people get stuck
9.1 Thinking REDEFINES is a separate variable
It is not.
It is another interpretation of the same storage.
9.2 Thinking 88 is an independent Boolean
It usually is not.
It is a readable name attached to a specific value of the previous item.
9.3 Ignoring COPY
That is basically walking into the mountains with half a map folded shut.
Field definitions, common flags, host variables, and shared layouts often live in copybooks.
9.4 Thinking MOVE is just simple assignment
MOVE is not always equivalent to raw memory copy.
Depending on sender and receiver types, conversion, alignment, padding, truncation, or editing behavior may happen.
9.5 Underestimating the period
In older COBOL especially, the . is heavier than it first looks.
It can change the real control-flow scope far more than a newcomer expects.
9.6 Treating packed decimal or EBCDIC as random corruption
It may not be broken at all.
It may simply not be plain text, or not be ASCII-based data.
10. A quick cheat sheet
| What you found | What to think first |
|---|---|
01 |
Top-level record or group; start your map here |
88 |
Named condition for a status or flag field |
PIC X(...) |
Character field |
PIC 9(...) / S9(...)V... |
Numeric field; check digits and decimal position |
COMP |
Binary representation |
COMP-3 |
Packed decimal; often money or counts |
REDEFINES |
Same storage, different interpretation |
OCCURS |
Table / array |
OCCURS DEPENDING ON |
Variable-length table |
FILLER |
Unnamed storage that still takes space |
COPY |
You need the copybook too |
PERFORM |
Main structural flow |
READ / WRITE / REWRITE |
File I/O |
EXEC SQL |
Database boundary |
EXEC CICS |
Transaction boundary |
FILE STATUS |
I/O result code |
11. Wrap-up
COBOL is not difficult just because it is old.
What makes it feel hard at first is that data definition, external files, and runtime context are tightly connected, so the entrance can be easy to miss.
The minimum reading set is still fairly compact:
- use
DIVISIONto build the map - read
DATA DIVISIONbefore chasing logic - use
PICandUSAGEto understand field shape - mark
COMP-3,REDEFINES,OCCURS,88, andCOPY - follow
PERFORM,READ,WRITE, andCALL - treat
FILE STATUS,EXEC SQL, andEXEC CICSas external boundaries - never underestimate the
.in older code
Once that becomes visible, COBOL stops looking like some mysterious ancient spellbook and starts looking like what it often is:
a language for business records and structured data movement.
12. References
- IBM: Reference format
- IBM: Area A or Area B
- Micro Focus: Fixed Format
- IBM: Level-numbers
- IBM: Format 2: condition-name value
- IBM: Examples: numeric data and internal representation
- IBM: PACKED-DECIMAL (COMP-3)
- IBM: REDEFINES clause
- IBM: OCCURS DEPENDING ON clause
- IBM: PERFORM statement
- IBM: FILE STATUS clause
- IBM: Using file status keys
- IBM: Scope terminators
- IBM: Elementary move rules
- IBM: Coding COBOL programs to run under CICS
Related Topics
These topic pages place the article in a broader service and decision context.
Windows Technical Topics
Topic hub for KomuraSoft LLC's Windows development, investigation, and legacy-asset articles.
ActiveX Migration
Topic page for staged decisions around keeping, wrapping, or replacing COM / ActiveX / OCX assets.
Where This Topic Connects
This article connects naturally to the following service pages.
Technical Consulting & Design Review
This topic fits technical consulting and design review well because understanding existing COBOL assets, identifying safe change points, and planning modernization all begin with being able to read the source calmly.
Bug Investigation & Root Cause Analysis
When you inherit a COBOL system during incident response or urgent maintenance, tracing where the inconsistency actually starts often fits bug investigation and root-cause analysis directly.