Summary -

In this topic, we described about the Reserved Words with detailed example.

A reserved word is a predefined word in a COBOL language with proper meaning. Reserved words can be -

  • Keywords
  • Optional words
  • Figurative constants
  • Special character words
  • Special registers
Reserved WordDescription
Keywords Keywords are reserved words that are required to code each program.
Such keywords appear in uppercase on each sentence or statement.
For example -
ACCEPT
ACCESS
ADD
AFTER
ALL
ALPHABET
ALPHABETIC
ALPHANUMERIC
ASCENDING
ASSIGN
AUTHOR 
...
Optional words Optional words are reserved words that do not affect the program's execution.
They can be included in a sentence or statement to improve readability.
For example -
SKIP1
SKIP2
SKIP3
ROUNDED
...
Figurative constants Figurative constants are reserved words and refers to specific constant values.
For example -
ZERO, ZEROS, ZEROES
SPACE, SPACES
HIGH-VALUE, HIGH-VALUES
LOW-VALUE, LOW-VALUES
QUOTE, QUOTES
NULL, NULLS
...
Special character words Special character words are used for a special purpose.
There are five types of special character words -
  • Arithmetic operators: + - / * **
    For example -
    COMPUTE WS-SUM = WS-A + WS-B.
    COMPUTE WS-SUB = WS-A - WS-B. 
    COMPUTE WS-DIV = WS-A / WS-B.
    COMPUTE WS-MUL = WS-A * WS-B. 
    COMPUTE WS-EXP = WS-A ** WS-B. 
  • Relational operators: < > = <= >=
    For example -
    IF WS-A < WS-B 
    IF WS-A > WS-B
    IF WS-A = WS-B
    IF WS-A <= WS-B
    IF WS-A >= WS-B 
  • Floating comment indicators: *>
  • Pseudo-text delimiters in COPY and REPLACE statements: ==
    For example -
    COPY COPYBOOK REPLACING ==:WS:== BY ==WS1==.
  • Compiler directive indicators: >>
Special registers Special registers represent storage areas generated by the compiler.
Their primary use is to store information produced by specific COBOL components.
Each storage area has a fixed name and should not be defined within the program.
For example -
ADDRESS OF
DEBUG-ITEM
FORMAT OF
LENGTH OF
LINAGE-COUNTER
RETURN-CODE
SORT-RETURN
WHEN-COMPILED
...