Using the COBOL SORT and MERGE verbs

This topic contains a high-level overview of COBOL SORT and MERGE verbs. It is designed to introduce you to concepts that help you understand some of the special considerations for using these COBOL statements in Language Environment. For a detailed description of how to use SORT and MERGE, see the appropriate version of the COBOL programming guide in the COBOL library at Enterprise COBOL for z/OS library.

A COBOL program that contains a sort operation can be organized so that an input procedure reads and operates on one or more input files before the files are actually sorted. To specify the input procedure:
SORT...INPUT PROCEDURE
You can also specify an output procedure that processes the files after they are sorted:
SORT...OUTPUT PROCEDURE

These input and output procedures can be used to add, delete, alter, edit, or otherwise modify the records.

You can also sort records under COBOL without any processing by the input and output procedures. For example, to read records into a new file for sorting without any preliminary processing, specify:
SORT...USING
To transfer sorted records to a file without any further processing, specify:
SORT...GIVING