The merge operation compares two or more sequenced files and combines them in sequential order.
You have access to output procedures, used after merging, that can modify the output records using the MERGE...OUTPUT PROCEDURE statement.
Unlike the SORT statement, you cannot specify an input procedure in the MERGE statement; you must use the MERGE...USING statement.
It is not necessary to sequence input files prior to a merge operation. The merge operation sequences and combines them into one sequenced file.
When the MERGE statement is encountered in the Procedure Division, it begins the merge processing. This merge operation compares keys within the records of the input files, and passes the sequenced records, one at a time, to the RETURN statement of an output procedure or to the file named in the GIVING phrase.
If you want to process the merged records, they can be made available to your ILE COBOL program, one at a time, through a RETURN statement in an output procedure. If you don't want to modify or process the merged records, the MERGE statement GIVING phrase names the merged output file into which the merged records will be written.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.