COBOL Manual for TNS and TNS/R Programs

Source Program Organization and Format
HP COBOL Manual for TNS and TNS/R Programs522555-006
2-14
Common Programs
Index-Name
If a data item is external and/or global and includes a table accessed with an index,
that index is also external and/or global (respectively); therefore, the scope of an index-
name is identical to that of the data-name that names the table whose index is named
by that index-name, and the scope rules for data-names apply. Index-names cannot be
qualified.
Common Programs
A common program is one that includes the COMMON clause in its Identification
Division. A common program can be called by any program directly or indirectly
contained in the program that directly contains the common program (except for the
called program itself and the programs that it contains). In Example 2-2, if program Aaa
includes the COMMON clause, the programs Bbb, Ccc, and Ddd can call it.
Programs in the Same Run Unit
A program and the programs that it contains are always in the same run unit, but
separate programs (not contained in that program and not containing it) can also be in
the same run unit.
Initial Programs
An initial program has an INITIAL clause in its Identification Division. An initial
program’s program state is initialized whenever the program is called. If program X is
an initial program, whenever a program calls X, the program state of X is the same as
when X was first called in that run unit. During the process of initializing an initial
program:
The program’s internal data items are initialized (see Initializing Data Items).
Files with internal file connectors associated with the program are not in the open
mode.
The control mechanisms for all PERFORM and ALTER statements contained in the
program are set to their initial states.
The CANCEL and NOCANCEL directives, which determine whether a program is
initialized the first time it is called after having been canceled by a CANCEL statement,
do not affect initial programs. Initial programs are initialized every time they are called,
whether or not they were cancelled.
The LESS-CODE directive, which determines which parts of a program are initialized,
and how, handles initial programs as special cases (see LESS-CODE).