Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


Sorting and merging files

You can arrange records in a particular sequence by using a SORT or MERGE statement. You can mix SORT and MERGE statements in the same COBOL program.

SORT statement
Accepts input (from a file or an internal procedure) that is not in sequence, and produces output (to a file or an internal procedure) in a requested sequence. You can add, delete, or change records before or after they are sorted.
MERGE statement
Compares records from two or more sequenced files and combines them in order. You can add, delete, or change records after they are merged.

A program can contain any number of sort and merge operations. They can be the same operation performed many times or different operations. However, one operation must finish before another begins.

With Enterprise COBOL, your IBM licensed program for sorting and merging must be DFSORT™ or an equivalent. Where DFSORT is mentioned, you can use any equivalent sort or merge product.

COBOL programs that contain SORT or MERGE statements can reside above or below the 16-MB line.

The steps you take to sort or merge are generally as follows:

  1. Describe the sort or merge file to be used for sorting or merging.
  2. Describe the input to be sorted or merged. If you want to process the records before you sort them, code an input procedure.
  3. Describe the output from sorting or merging. If you want to process the records after you sort or merge them, code an output procedure.
  4. Request the sort or merge.
  5. Determine whether the sort or merge operation was successful.

Restrictions:

related concepts  
Sort and merge process

related references   
CICS SORT application restrictions
  
SORT statement (Enterprise COBOL Language Reference)  
MERGE statement (Enterprise COBOL Language Reference)


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)