Module 8: JCL Sort & Merge
The SORT command is used to specify sorting criteria and features.
Syntax of SORT command:
SORT FIELDS= (sort-key1, sort-key2,…., sort-keyN)
Where, each sort-key consist of below four paramaters:-
Let’s understand SORT with help of example
Requirement: Sort above file on columns 1 to 5 in ascending order
The SORT control statement with FIELDS=COPY defines the application as a COPY application.
Where,SKIPREC indicates the number of records to be skippedSTOPAFT indicates the number of records to processCKPT/CHKPT indicates a checkpoint is desired at the end of volume of a SORTOUT data set when OUTFIL is not used.
Below are few more requirement which can be addressed using SORT command:
Requirement:To sort input file on column 1 to 5 on in descending order and 31 to 45 in ascending order SYSIN Control card:
Requirement: To copy all records from SORTIN to SORTOUT without sorting it SYSIN Control card:
Requirement: To copy records from row number 5 to 7 as it is from SORTIN to SORTOUT SYSIN Control card:
Requirement: To concatenate two or more sorted or unsorted datasets into one sorted dataset on column 1 to 5 in ascending order SYSIN Control card: IMP NOTE: In SORTIN card three datasets are concatenated