PROGRAM-ID paragraph

The PROGRAM-ID paragraph specifies the name by which the program is known and assigns selected program attributes to that program. It is required and must be the first paragraph in the IDENTIFICATION DIVISION.

program-name
A user-defined word or alphanumeric literal, but not a figurative constant, that identifies your program. It must follow the following rules of formation, depending on the setting of the PGMNAME compiler option:
PGMNAME(COMPAT)
The name can be up to 30 characters in length.

Only the hyphen, underscore, digits 0-9, and alphabetic characters are allowed in the name when it is specified as a user-defined word.

At least one character must be alphabetic.

The hyphen cannot be the first or last character.

If program-name is an alphanumeric literal, the rules for the name are the same except that the extension characters $, #, and @ can be included in the name of the outermost program and the underscore can be the first character.

PGMNAME (LONGUPPER)
If program-name is a user-defined word, it can be up to 30 characters in length.

If program-name is an alphanumeric literal, the literal can be up to 160 characters in length. The literal cannot be a figurative constant.

Only the hyphen, underscore, digits 0-9, and alphabetic characters are allowed in the name when the name is specified as a user-defined word.

At least one character must be alphabetic.

The hyphen cannot be the first or last character.

If program-name is an alphanumeric literal, the underscore character can be the first character.

External program-names are processed with alphabetic characters folded to uppercase.

PGMNAME (LONGMIXED)
program-name must be specified as an alphnumeric literal, which can be up to 160 characters in length. The literal cannot be a figurative constant.

program-name can consist of any character in the range X'41' to X'FE'.

For information about the PGMNAME compiler option and how the compiler processes the names, see PGMNAME in the Enterprise COBOL Programming Guide.

RECURSIVE
An optional clause that allows COBOL programs to be recursively reentered.

You can specify the RECURSIVE clause only on the outermost program of a compilation unit. Recursive programs cannot contain nested subprograms.

If the RECURSIVE clause is specified, program-name can be recursively reentered while a previous invocation is still active. If the RECURSIVE clause is not specified, an active program cannot be recursively reentered.

The WORKING-STORAGE SECTION of a recursive program defines storage that is statically allocated and initialized on the first entry to a program and is available in a last-used state to any of the recursive invocations.

The LOCAL-STORAGE SECTION of a recursive program (as well as a nonrecursive program) defines storage that is automatically allocated, initialized, and deallocated on a per-invocation basis.

Internal file connectors that correspond to an FD in the FILE SECTION of a recursive program are statically allocated. The status of internal file connectors is part of the last-used state of a program that persists across invocations.

The following language elements are not supported in a recursive program:

  • ALTER
  • GO TO without a specified procedure-name
  • RERUN
  • SEGMENT-LIMIT
  • USE FOR DEBUGGING

The RECURSIVE clause is required for programs compiled with the THREAD option.

COMMON
Specifies that the program named by program-name is contained (that is, nested) within another program and can be called from siblings of the common program and programs contained within them. The COMMON clause can be used only in nested programs. For more information about conventions for program names, see Conventions for program-names.
INITIAL
Specifies that when program-name is called, program-name and any programs contained (nested) within it are placed in their initial state. The initial attribute is not supported for programs compiled with the THREAD option.

A program is in the initial state:

  • The first time the program is called in a run unit
  • Every time the program is called, if it possesses the initial attribute
  • The first time the program is called after the execution of a CANCEL statement that references the program or a CANCEL statement that references a program that directly or indirectly contains the program
  • The first time the program is called after the execution of a CALL statement that references a program that possesses the initial attribute and that directly or indirectly contains the program

When a program is in the initial state:

  • The program's internal data contained in the WORKING-STORAGE SECTION is initialized. If a VALUE clause is used in the description of the data item, the data item is initialized to the defined value. If a VALUE clause is not associated with a data item, the initial value of the data item is undefined.
  • Files with internal file connectors associated with the program are not in the open mode.
  • The control mechanisms for all PERFORM statements contained in the program are set to their initial states.
  • An altered GO TO statement contained in the program is set to its initial state.

For the rules governing nonunique program names, see Rules for program-names.