COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

Time Limits
If you include a TIME LIMITS phrase in an OPEN statement, you can then include a TIME LIMIT
phrase in a LOCKFILE, READ, or START statement to cause the statement to be abandoned if it
does not finish executing in a certain amount of time. The TIME LIMIT phrase in a LOCKFILE, READ,
or START statement sets the file’s status code so that the requester can tell that the data is not
currently accessible. This action helps avoid deadlock.
Reading Files From Called Programs
Two separately compiled programs cannot share files; that is, if one program opens the file and
then calls another separately compiled program, the caller cannot pass the file (or access to the
file) to the called program. A pair of separately compiled calling and called programs can both
have the same disk file open, but each has its own record area, its own current record pointer, its
own file status data item, and so on.
When an HP COBOL run unit opens a file, the file remains open until one of these happens:
The run unit explicitly closes the file.
The calling program cancels the called program that has the file open (with the CANCEL
statement).
The run unit terminates execution.
A well-structured program unit has all the file activity for a certain file within one called program.
The other programs in the run unit call that program to open, read, write, position, or close the
file.
In the called program, include a data item whose initial value indicates that the file is not open.
When the program opens the file, set the data item to a value that indicates that the file is open.
When the program closes the file, set the data item to a value that indicates that the file is closed.
The value of the data item is retained between calls to that program unless a CANCEL statement
intervenes.
Sharing Files Among HP COBOL Programs
Two programs in a run unit can refer to common file connectors in these circumstances:
Any program that has described an external file connector can refer to that file connector.
If a program G is contained within another program H, both programs can refer to a common
file connector. They do so by referring to an associated global file name (or associated global
record-name, in the case of the WRITE statement) described in either:
The containing program H
Any program that directly or indirectly contains H
If several programs define a file connector as external (causing its storage location to be a single
location outside all programs) and they also define the file connector as having a global name,
then all such programs and all programs nested within each of them have access to the file
connector.
Sharing Files Among Different-Language Modules
If your program consists of modules written in different languages, the modules can share the
standard files—the predefined files called “standard input,” “standard output,” and “standard
log.
For more information about mixed-language programs sharing standard files, see the CRE
Programmer’s Guide.
860 Disk Input and Output