Coding the input procedure
To process the records in an input file before they are
released to the sort program, use the INPUT PROCEDURE
phrase of the format 1 SORT statement.
About this task
You can use an input procedure to:
- Release data items to the sort file from
WORKING-STORAGEorLOCAL-STORAGE. - Release records that have already been read elsewhere in the program.
- Read records from an input file, select or process them, and release them to the sort file.
Each input procedure must be contained in either paragraphs
or sections. For example, to release records from a table in WORKING-STORAGE or LOCAL-STORAGE to
the sort file SORT-WORK-2, you could code as follows:
SORT SORT-WORK-2
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-WORK-2-AREA FROM TABLE-ENTRY (X1)
END-PERFORM.
To
transfer records to the sort program, all input procedures must contain
at least one RELEASE or RELEASE FROM statement.
To release A from X, for example, you can code:
MOVE X TO A.
RELEASE A.
Alternatively, you can code:
RELEASE A FROM X.
The following table compares the RELEASE and RELEASE
FROM statements.
RELEASE |
RELEASE FROM |
|---|---|
|
|
Related references
Restrictions on input and output procedures
RELEASE statement (Enterprise COBOL for z/OS® Language Reference)
Restrictions on input and output procedures
RELEASE statement (Enterprise COBOL for z/OS® Language Reference)