Dual Nature: Server Libraries and Ordinary Programs
COBOL74 object code files are structured in a special way that allows them to be executed either as server libraries or as ordinary processes. Every program written in this language is available for use as a server library, except for programs that
-
Specify in the data division that a parameter is RECEIVED BY CONTENT (that is, received as a call-by-value parameter).
-
Specify parameters in the USING clause of the PROCEDURE division that are not allowed for libraries. Each data item in the USING phrase must be defined as level 01 or level 77, and the data item must not redefine another data item. Further, the parameters must be of data types that are allowed for library parameters. For a list of the allowed library parameter types for COBOL74, refer to COBOL74 Parameters.
-
Are compiled with a LEVEL compiler control option that specifies a lexical level greater than 2.
Library-Capable Programs
A program that does not use any of these restricted features is said to be library-capable. A library-capable COBOL74 program freezes if it is initiated through the library linkage mechanism. If the program is initiated by a process-initiation statement, then the program runs as an ordinary process and does not freeze. For a discussion of the library linkage mechanism, refer to Initiating Server Library Processes later in this section.
Circular Linkage Disallowed
Circular library linkages are not allowed for COBOL74 libraries. If a COBOL74 library invokes itself, the operating system discontinues the library with a run-time error. If a COBOL74 library invokes a procedure in another library that in turn invokes the original library, both libraries freeze successfully but the client process hangs indefinitely in the state WAITING ON AN EVENT.
EXIT PROGRAM Versus STOP RUN
An EXIT PROGRAM statement must be used to exit a COBOL74 library and to return to the calling program. By contrast, a STOP RUN statement causes the client process to terminate at the point of the statement that invoked the library procedure.
Sharing in COBOL74
The system prevents multiple clients of a shared COBOL74 library from executing the exported procedure at the same time. Refer to Controlling Connection Library Sharing earlier in this section.
Global Nature of Declarations
Because only the PROCEDURE DIVISION of a COBOL74 library is exported, most objects declared in the DATA DIVISION or ENVIRONMENT DIVISION are considered as global to the exported procedure. Within each library instance, these objects retain their values from one procedure call to the next. In a shared library, any changes made to the values of these objects by a client process are visible to all other client processes.
Objects in USING Clause
One exception to this behavior occurs for objects that are referred to in the USING clause of the PROCEDURE DIVISION. This clause causes the objects to be treated as parameters to the PROCEDURE DIVISION. Each client process receives a separate instance of these objects, and the values of the objects are not retained from one procedure call to the next.
No Initiation or Termination Code
Another limitation arises from the fact that the entire PROCEDURE DIVISION is exited. There is no place in a COBOL74 library to specify initialization or termination code. By contrast, the outer block of an ALGOL library can contain statements that execute before the FREEZE statement or that execute after the library unfreezes.

