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

Procedure Division Verbs
HP COBOL Manual for TNS/E Programs520347-003
9-112
MERGE
The PROGRAM COLLATING SEQUENCE clause affects merge operations.
Output Procedure
The output procedure is outproc-1 or outproc-1 through outproc-2. The
output procedure must have a RETURN statement. An output procedure can be
any procedure needed to select, modify, or copy the records that the RETURN
statement makes available to merge-file one at a time in merged order.
The range of an output procedure includes statements that execute due to transfer
of control by CALL, EXIT, GO TO, and PERFORM statements in the range of the
output procedure and statements in declarative procedures that execute as a result
of execution of statements in the range of the output procedure. The range of an
output procedure must not cause the execution of any of these statements:
°
A MERGE, RELEASE, or SORT statement
°
A RETURN statement that specifies a sort-merge file other than merge-file
°
A statement that manipulates merge-in-1, merge-in-2, merge-in-n, or
merge-out or uses the record area associated with one of these files
If the MERGE statement is in a section that is not in an independent segment (a
segment whose segment-number is from 00 through 49), then any output
procedures must either be totally within dependent segments or they must be
wholly contained in a single independent segment.
If the MERGE statement is in an independent segment (a segment whose
segment-number is from 50 through 99), then any output procedures must either
be totally within dependent segments or they must be wholly contained in the same
independent segment that contains the MERGE statement.
Execution Phases
The execution of a MERGE statement consists of an input-and-merge phase and
an output phase.
Input-and-Merge Phase
The input-and-merge phase transfers records from the input files merge-in-1,
merge-in-2, and merge-in-n to merge-file in the order specified by the
merge keys and the collating sequence alphabet-name.
When the MERGE statement begins execution, merge-file and the input files
must be closed but not locked. The input-and-merge phase performs an implicit
OPEN statement on merge-file and each of the input files. The input-and-
merge phase opens each input file in INPUT mode, performs implicit READ NEXT
statements to retrieve their records, and performs implicit RELEASE statements to
release the records to the merge-file.