Function
The PROGRAM-ID paragraph contains the name by which a program or program prototype is identified. The program can be assigned the appropriate attributes with the INITIAL, COMMON or RECURSIVE clause.
Format 1
Format 2
PROGRAM-ID. program-prototype-name-1 IS PROTOTYPE.
Syntax rules
The program-name must be a user-defined name with a length of 1-30 characters, beginning with a letter.
Note:
A program name should not begin with the letter "I" to avoid potential conflicts with the names of COBOL runtime modules or modules of other runtime systems.The programs of a nested program must have different names.
The COMMON clause may only be specified for the contained programs of a nested program. It must not be specified in the outermost containing program.
The INITIAL clause may not be specified if any program that is directly or indirectly contained in a recursive program.
The RECURSIVE clause may not be specified if any program that is directly or indirectly contained in a program containing the INITIAL clause.
General rules for Format 1
The effect of the INITIAL clause is that the program is set to its initial state each time it is called (see section "Initial state for inter-program communication").
The COMMON clause causes the program to have the COMMON attribute. Such a program can be called not only by the directly superordinate program but also by its "sibling programs" and their "descendants".
The RECURSIVE clause specifies that the program and all programs contained within it are recursive. The program may be called while it is active and may call itself. If the RECURSIVE clause is not specified in a program or implied for a program, the program may not be called while it is active.
General rule for Format 2
program-prototype-name-1 specifies the program prototype.
Additional rules, depending on the module format
The following applies to program-name and program-prototype-name-1 when generating the *OMF format (see the "COBOL2000 User Guide" [1]):
The 8th character must not be a hyphen.
The operating system uses only the first eight characters of the module identification. Therefore, these characters should be unique for every name in a particular module/program library.
Only the first 7 characters of the name are used when generating shared code.
Example 5-1
of the effect of the INITIAL clause
Calling program:
IDENTIFICATION DIVISION. PROGRAM-ID. MAIN. ... DATA DIVISION. WORKING-STORAGE SECTION. ... PROCEDURE DIVISION. ... CALL "UPROG1" USING... ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯(1) ... ... CALL "UPROG1" USING... ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯(2)
Called program:
IDENTIFICATION DIVISION. PROGRAM-ID. UPROG1 IS INITIAL PROGRAM. ... DATA DIVISION. WORKING-STORAGE SECTION. 01 USER-DATE PIC X(8) VALUE SPACE. ... PROCEDURE DIVISION USING ... ... MOVE "26.10.49" TO USER-DATE. ... EXIT PROGRAM.
(1) (2) | UPROG1 is called for the first time by MAIN. UPROG1 is called for the second time by MAIN. UPROG1 is again in its initial state: the content of USER-DATE, for example, is again SPACE, even if it was changed during the first call of UPROG1. |
Example 5-2
of the effect of the COMMON clause
Structure of a nested program A:
Valid call options within the nested program shown above:
Called | Calling program | |||||||||||||||
A | B | C | D | E | F | G | H | J | K | L | M | N | O | P | Q | |
A | ||||||||||||||||
B | x | |||||||||||||||
C | x | |||||||||||||||
D | x | x | ||||||||||||||
E | x | |||||||||||||||
F | x | |||||||||||||||
G | x | x | x | x | x | x | x | x | x | |||||||
H | x | x | x | x | x | x | ||||||||||
J | x | |||||||||||||||
K | x | |||||||||||||||
L | x | |||||||||||||||
M | x | x | ||||||||||||||
N | x | |||||||||||||||
O | x | x | x | |||||||||||||
P | x | |||||||||||||||
Q | x |
x = permitted call