In this topic, we have explained User-defined Words with detailed examples.
- The developer defines a user-defined word and is used to store the data.
- The user-defined word maximum length is 30 bytes (except for level-numbers).
- The user-defined word should be unique within the type to which it belongs (that might be a program, paragraph, etc.).
WS-VAR1 should be unique variable in the program where it is declared.
01 WS-VAR1 PIC X(05).
01-PARA1 should be unique paragraph in the program where it is declared.
The above declaration is valid as it has a reference and should be represented as -
01 WS-GRP1. 05 WS-VAR1 PIC X(05). 01 WS-GRP-BACKUP. 05 WS-VAR1 PIC X(05).
In the above case, the two usages consider as two different variables.
WS-VAR1 OF WS-GRP1 WS-VAR1 OF WS-GRP-BACKUP
Rules Specific to the user-defined name types-
The below list specifies some types of user-defined names –
|Rules||User-defined name types|
|Each word atleast have one letter.||Alphabet-name
Program-name (Using in PROCEDURE linkage)
|Each word atleast have one letter.
First 10 character should be unique word.
Program-name(using PROGRAM linkage)
|Word may need not contain alphabetic character.||Paragraph-name
|Each word may contain 1 or 2 digits.
It does not have to be unique.
The below list shows the examples for each type of user-defined name -
|User-defined name||Some Examples|
SORT-SEQ is the alphabet-name.
STD-MALE, STD-FEMALE are the condition-names.
WS-PI is the constant-name.
WS-VAR is the data-item-name.
INPUT-FILE is the file-name.
MARKS-INDEX is the index-name.
SRW is the mnemonic-name.
PARA-DISPLAY is the paragraph-name.
MTHPROG1 is the program-name.
WS-REC is the record-name.
ROUTINE1 is the routine-name.
SEC-ADDITION is the section-name.
WS-REC-KEY is the key-name.
BACKSPACE is the symbolic-character.
WS-MTH is the text-name.