A COBOL keyword is a word the compiler already uses. Reserved words cannot be data names, paragraph names, or program names. DATE and MOVE are reserved. WS-RUN-DATE is not.
The alphabetical list below is the reserved-word table for Enterprise COBOL for z/OS 6.4 (Language Reference, Appendix E), including synonyms such as PIC and PICTURE. The compiler does not care about case. Arithmetic symbols (+, -, *, /, **) and the comparison signs are reserved too, but you would not pick them as names. Words used only inside EXEC SQL, such as BLOB and ROWID, are left out. They belong to the Db2 coprocessor.
Micro Focus and the GnuCOBOL default dialect reserve a different set. If your compile says a name is reserved and it is missing here, the manual for that compiler is the one to trust.
Most reserved words are verbs, description clauses, or structure names. These are the ones that show up in a first program, and the ones people try to reuse as field names.
| Word | What it does |
|---|---|
| ADD, SUBTRACT, MULTIPLY, DIVIDE, COMPUTE | Arithmetic statements |
| MOVE | Copies a value into one or more fields |
| IF, ELSE, END-IF | A condition, its other branch, and the close of that IF |
| EVALUATE, WHEN, END-EVALUATE | A multi-way test and the close of that EVALUATE |
| PERFORM, END-PERFORM | Runs a paragraph, section, or inline block, then continues |
| DISPLAY, ACCEPT | Writes to the output device, or reads a value in |
| OPEN, READ, WRITE, CLOSE | File statements |
| STOP, GOBACK, EXIT | Ways a program ends or leaves a performed paragraph |
| PIC, PICTURE | The same clause. Describes the digits and characters in a field |
| VALUE | The initial contents of a working-storage item |
| OCCURS | Repeats a field so it can be subscripted |
| WORKING-STORAGE, LINKAGE, LOCAL-STORAGE | Section names. You do not declare a field with these names |
Several spellings are the same reserved word. Using either form is fine. Using either spelling as a data name is not.
| Spellings | Same meaning |
|---|---|
| ZERO, ZEROS, ZEROES | Figurative constant zero |
| SPACE, SPACES | Figurative constant space |
| HIGH-VALUE, HIGH-VALUES | Highest character in the collating sequence |
| LOW-VALUE, LOW-VALUES | Lowest character in the collating sequence |
| QUOTE, QUOTES | The quotation-mark character |
| NULL, NULLS | Null pointer or invalid address, depending on context |
| PIC, PICTURE | The picture clause |
| COMP, COMPUTATIONAL | Binary usage on Enterprise COBOL |
| THRU, THROUGH | An inclusive range, as in PERFORM A THRU B |
| CORR, CORRESPONDING | Move or add matching subordinate names |
| JUST, JUSTIFIED | Right-justify an alphabetic or alphanumeric item |
| SYNC, SYNCHRONIZED | Align a field on a storage boundary |
These are reserved because they appear in the USAGE clause. COMP-3 in particular gets used as a field name in older copybooks and then fails when the program moves to a stricter compile.
| Keyword | How Enterprise COBOL stores it |
|---|---|
| DISPLAY | Character digits. Also the verb that writes a line |
| DISPLAY-1 | DBCS display |
| COMP, COMPUTATIONAL, COMP-4, BINARY | Binary integer |
| COMP-1, COMPUTATIONAL-1 | Short floating point, 4 bytes |
| COMP-2, COMPUTATIONAL-2 | Long floating point, 8 bytes |
| COMP-3, COMPUTATIONAL-3, PACKED-DECIMAL | Packed decimal |
| COMP-5, COMPUTATIONAL-5 | Native binary. The PICTURE does not truncate the capacity the way COMP does |
| POINTER, FUNCTION-POINTER, PROCEDURE-POINTER | An address |
| POINTER-32 | A 4-byte pointer, even under LP(64) |
| INDEX | A subscript stored in an index, not a numeric field you MOVE into |
| NATIONAL | UTF-16 data |
| UTF-8 | UTF-8 data |
A scope terminator ends one statement and nothing else. END-IF does not close a PERFORM. Each verb has its own.
END by itself is also reserved. It shows up in END PROGRAM, END CLASS, and END METHOD. END-OF-PAGE is the linage condition, not a scope terminator.
If the word is in this list, do not use it as a name. A prefix such as WS- is enough for working-storage. DATE fails. WS-RUN-DATE does not, because the reserved-word check is the whole word, not a substring.
These are not reserved in every statement. They are special inside one phrase, so a field named NAME can still be legal, and it can also surprise the next person who writes XML GENERATE NAME. The Language Reference lists them in Appendix F. The short tokens F, LOC, S, U, and V are on that same table. They are not words you would choose, and they are omitted from the list below.
RECURSIVE belongs on PROGRAM-ID when the program calls itself. PARSE belongs on XML PARSE and JSON PARSE. YYYYMMDD and YYYYDDD belong on date intrinsic functions. INITIALIZED belongs on ALLOCATE.
A special register is storage the compiler defines. You read it or move it. You do not write an 01 with the same name. RETURN-CODE is the usual one: the program sets it before GOBACK, and the caller or the JCL step sees that value.
The first data description uses reserved words as names. The second uses ordinary names and still uses the keywords where they belong, as verbs and figurative constants.
1234567891011* DATE, MOVE, and TABLE are reserved. This does not compile. 01 DATE PIC 9(8). 01 MOVE PIC X(10). 01 TABLE PIC X(20). 01 WS-RUN-DATE PIC 9(8). 01 WS-MOVE-COUNT PIC 9(4) VALUE ZERO. PROCEDURE DIVISION. MOVE 20260927 TO WS-RUN-DATE ADD 1 TO WS-MOVE-COUNT STOP RUN.
DATE and TABLE fail. Use WS-INVOICE-DATE and WS-TABLE, or any name that is not in the list. Rename DATA to something like WS-CUSTOMER-INPUT. END-IF and END-READ are scope terminators. SPACE and HIGH-VALUES are figurative constants. PERFORM is a verb.
The compiler already uses some words for its jobs. MOVE means copy this. If you name a box MOVE, the compiler thinks you started an instruction. Call the box WS-AMOUNT and leave MOVE for the instruction.
1. Which name is a reserved word on Enterprise COBOL 6.4?
2. What does END-IF close?
3. ZERO, ZEROS, and ZEROES are:
4. COMP-3 stores a number as:
5. A context-sensitive word:
Character set, Area A and Area B, and how reserved words fit in a program
Rules for names you invent: letters, hyphens, length, and uniqueness
ZERO, SPACE, HIGH-VALUE, LOW-VALUE, and QUOTE
What the statement keywords do once the compiler accepts them
A COBOL keyword is a word the compiler already uses. Reserved keywords cannot be data names, paragraph names, or program names. DATE, MOVE, and TABLE are reserved on Enterprise COBOL for z/OS 6.4.
No. DATE is a reserved word. Name the field WS-RUN-DATE, INVOICE-DATE, or something else that is not on the reserved-word list.
No. MOVE, move, and Move are the same word. The compiler folds letters to one case before it checks the reserved-word table.
No. This page follows Enterprise COBOL for z/OS 6.4, Language Reference Appendix E. Micro Focus Visual COBOL and the GnuCOBOL default dialect reserve a different set. If a compile says a name is reserved and it is not in this list, use the manual for the compiler that produced the message.
A context-sensitive word is ordinary in most of the program and special inside one phrase. RECURSIVE only matters on PROGRAM-ID. PARSE only matters on XML PARSE or JSON PARSE. A reserved word is special everywhere.