Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Rules for program names

A program is called via the name of the program declared in the PROGRAM-ID paragraph of the IDENTIFICATION DIVISION.

The following basic rules apply to program names:

  1. A program name may be referenced only by the CALL statement, the CANCEL statement and the end program header.

  2. All separately compiled programs of a run unit must have different program names.

  3. All programs of a nested program must have different names.

  4. The contained programs of a nested program are "invisible" to all the separately compiled programs of a run unit; i.e. a separately compiled program cannot call any contained program of another separately compiled program.

  5. The contained programs of a nested program may have the same name as the separately compiled programs of the run unit. The procedure provided for determining the valid program name in this instance is discussed in the following section ("Selecting the valid program name").

  6. Within a nested program, one program can normally only call another program that is contained directly in it.

  7. The call facilities in a nested program can be expanded with respect to the normal case when the COMMON attribute is applied to a contained program by means of the COM-MON clause in the PROGRAM-ID paragraph.
    A program provided with the COMMON attribute can be called not only by the directly superordinate program but also by any "sibling program" and its "descendants" (see "Common clause" on PROGRAM-ID paragraph ).

Selecting the valid program name

When a program is called in a nested program, the relevant valid program name is then selected from the sum total of all the program names present in the run unit in accordance with the following rules of precedence:

  1. The call applies to the name of a program that is directly contained in the calling program.

  2. If 1) does not apply, the call applies to a COMMON program, i.e. to a program that can be called by its "sibling programs" and their "descendants".

  3. If neither 1) nor 2) applies, the call applies to a separately compiled program of the run unit.

     


Example 12-3

This example illustrates selection of the relevant valid program name.

A CALL statement for a program "A-PROG" within this nested program would be inadmissible since this call would apply to a further separately compiled program called "A-PROG" that may not be present in the run unit.