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

one terminated (see Expired Time Limit (page 256)). If error message 42 or 90 is returned after
the declarative procedure executes, the run unit terminates abnormally.
Interaction of LOCKFILE and READ LOCK Statements
If your process executes a READ LOCK statement on a file that it or any other process has
locked with a LOCKFILE statement, or your process executes a LOCKFILE statement against a
file that has an outstanding READ LOCK, the TIME LIMIT phrase determines what happens.
If the second statement attempting to lock the file has a TIME LIMIT phrase, it keeps trying to
lock the file until the time limit expires. Either it fails and then times out or it succeeds in locking
the file.
If the second statement attempting to lock the file has no TIME LIMIT phrase, it suspends
execution until the statement succeeds because the contending lock is removed or until the
program is terminated by an external agency (such as the TACL command STOP).
Example 111 LOCKFILE Statement With TIME LIMIT Phrase
SELECT IN-MASTER-FILE
ASSIGN ...
...
FILE STATUS IS IN-MASTER-STATUS.
...
FD IN-MASTER-FILE.
...
PROCEDURE DIVISION.
DECLARATIVES.
DECL SECTION.
USE AFTER ERROR PROCEDURE ON IN-MASTER-FILE.
DECL-ROUTINE.
IF GUARDIAN-ERR NOT = 40
STOP RUN
END-IF
END DECLARATIVES.
...
OPEN INPUT IN-MASTER-FILE WITH TIME LIMITS SHARED
LOCKFILE IN-MASTER-FILE
TIME LIMIT WAIT-TIME
IF IN-MASTER-STATUS NOT = "00"
IF GUARDIAN-ERR = 40
PERFORM RECOVER-MASTER-LOCK
END-IF
END-IF
PERFORM UP-DATE-MASTER UNTIL DONE
MOVE 0 TO M-FLAG
UNLOCKFILE IN-MASTER-FILE
...
MERGE
MERGE combines two or more files into another file, ordered by the same key. MERGE is performed
by the FastSort utility, using files that are not open to the COBOL program. MERGE opens, reads,
writes, and closes these files. MERGE can return records to an output procedure that can then write
them to some file that is open to the COBOL program.
360 Procedure Division Verbs