Summary -

In this topic, we have explained about the below sections -

What is the COBOL word?

A COBOL word is a set of characters that forms a user-defined word, a system-name, or a reserved word.

COBOL word maximum size is 30 characters.

Each character of a COBOL word is selected from the following set (except for arithmetic operators and relational characters) -

  • Latin uppercase letters A through Z
  • Latin lowercase letters a through z
  • digits 0 through 9
  • - (hyphen)
  • _ (underscore)

Each lowercase single-byte alphabetic letter is equivalent to its single-byte uppercase alphabetic letter in COBOL words. For example - "a" is equal to "A".

What are the Rules for all COBOL words?

Programmer should follow the below guidelines while creating COBOL words -

  • The hyphen(-) or underscore(_) cannot appear as the first or last character. For example - -WS, WS-, _WS, WS_ are invalid.
  • All user-defined words must contain at least one alphabetic character (except section-names, paragraph-names, priority-numbers, and level-numbers). For example - A123, W-12, 1W2, 12W etc,.
  • A reserved word cannot use as a user-defined word or a system-name. For example - ZERO, MOVE, IF, ELSE etc, are invalid as user-defined words.
  • Depending on the context, the same COBOL word can be used as either a user-defined word or a system-name, or both.

COBOL word types -

COBOL words are 5 types and those are -

COBOL word type Description
User-defined words A COBOL word can be a user-defined that is used by the user to fulfill the format of a clause or statement.

The user-defined word maximum length is 30 bytes (except for level-numbers and priority-numbers).
System-names A system-name is a character string that has a detailed meaning in/to the system.
There are three types of system-names -
  • Computer name
  • Language name
  • Implementor name
Function-names A function-name specifies the mechanism to define an intrinsic function value.
The same word can appear in a program as a user-defined word or a system-name in a different context.
Context-sensitive words A context-sensitive word is formed according to rules for reserved words, and may be used as a function-name, a user-defined word, or a system-name.
Reserved words A reserved word is a set of characters that is defined with a predefined meaning in a COBOL source unit.

Example -

The below list shows the examples for each type of word -

Word Type Some Examples
User-defined words
Type Some Examples
Special-names
SPECIAL-NAMES. 
    ALPHABET SORT-SEQ IS "A" THROUGH "Z"
                         "a" THROUGH "z".
SORT-SEQ is the alphabet-name.
Condition-names
05 STD-GENDER PIC A(06).
	88 STD-MALE VALUE "MALE".
	88 STD-FEMALE VALUE "FEMALE".
STD-MALE, STD-FEMALE is the condition-name.
System Names
Type Some Examples
Computer Name SOURCE-COMPUTER. Alpha.
OBJECT-COMPUTER. Beta.
Language Name INSTALLATION. COBOL DEVELOPMENT CENTER.
Implementor Name AUTHOR. PROGRAMMER NAME(MTH).
Function Name
CHAR
LENGTH
MIN
MAX
SQRT
...
Context-sensitive Words
APPEND
DAYS
DEFAULT
HOURS
MICROSECONDS
MINUTES
MONTHS
SECONDS
SYMMBOL
TIMSTAMP
YEARS
YYYYDDD
YYYYMMDD
...
Reserved Words
MOVE
IF
ELSE
PERFORM
ACCEPT
DISPLAY
...