COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-123
MERGE
When a key is in an ASCENDING phrase, the merged sequence is from the
record with the lowest value in the key to the record with the highest value. When
a key is in a DESCENDING phrase, the merged sequence is from the record with
the highest value in the key to the record with the lowest value. In both cases, the
rules for comparison of operands in a relation condition determine which value is
higher.
The results of the merge operation are predictable only when the records in each
of the input files are ordered as described in the key-specifier phrases.
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.