PROGRAM-ID Paragraph

General Format

[ PROGRAM-ID. program-name [ IS {INITIAL } PROGRAM ] . ]

Syntax Rule

program-name is a user-defined word or a reserved word. It must be unique among separately compiled programs. If a reserved word is used, it is treated as if it were not reserved. The maximum number of characters is 30.

General Rules

  1. The program-name identifies the name of the program. It is used by the run-time system and debugger to identify a program.
  2. The INITIAL clause specifies an initial program. Whenever an initial program is called, it is placed in its initial state. Data contained in an initial program is set to its starting value every time the program is called. Note that the -Zi compiler option causes the program to be compiled as if it had the IS INITIAL PROGRAM phrase specified.
  3. Files contained in the program are not in the open mode:
    1. The first time the program is called.
    2. The first time the program is called after it has been the target of a CANCEL statement.
    3. Every time the program is called if it is an INITIAL program.
  4. On all other entries, the files contained in the program are in the same state and position as when the program last exited.
  5. INITIAL programs are removed from memory when they exit. Non-initial programs remain in memory until they are the targets of a CANCEL statement.
  6. The RESIDENT clause specifies that the program is to remain resident in memory after its first execution. A program with the RESIDENT clause cannot be affected by a CANCEL statement. Note that the RESIDENT clause shields selected programs from the effects of a CANCEL Statement.
  7. The IBM DOS/VS COBOL -Cv compatibility mode allows the name to be enclosed in quotation marks.
  8. If you omit the PROGRAM-ID paragraph, the program's name is derived from the source file name as follows:
    1. All directory information is removed from the filename and only the base filename is used.
    2. If the filename includes a period (".") or space, that portion of the filename (including the period or space) is truncated.
    3. The name is translated to upper case for letters in the ASCII alphabet range.
    4. Characters not in the ASCII alphabet are left unchanged.
  9. If the PROGRAM-ID paragraph is omitted, the program does not have an INITIAL or RESIDENT state.