ILE COBOL Programmer's Guide

Writing the Input Procedure

Use SORT...USING if you don't need to process the records in an input file(s) before they are released to the sort program. With SORT...USING file-name, the ILE COBOL compiler generates an input procedure to open the file, read the records, release the records to the sort program, and close the file.

The input file must not be open when the SORT statement is performed. If you want to process the records in the input file before they are released to the sort program, use the INPUT PROCEDURE option of the SORT statement.

Each input procedure must be represented as either a paragraph or a section. For example, to release records from a table in Working-Storage to the sort file, use the following:

 PROCEDURE DIVISION.
        
·
·
·
SORT SORT-FILE ON ASCENDING KEY SORT-KEY INPUT PROCEDURE 600-SORT3-INPUT-PROC  
·
·
·
600-SORT3-INPUT-PROC SECTION. PERFORM WITH TEST AFTER VARYING X1 FROM 1 BY 1 UNTIL X1 = 100 RELEASE SORT-RECORD FROM TABLE-ENTRY(X1) END-PERFORM.

An input procedure contains code for processing records and releasing them to the sort operation. You might want to use an input procedure to:

To transfer records to the sort file, all input procedures must contain at least one RELEASE or RELEASE FROM statement.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]