Module 8: JCL Sort & Merge
In day-to-day applications, records in the dataset are added, updated, or deleted as necessary. After these kind of modifications, records in dataset becomes disordered. Then, when it comes time to update this dataset, finding the record in question takes longer than if records had been ordered. Hence, the need to periodically sort datasets.
There are various MVS utility tool that are available which allow you to sort and merge datasets:-
The basic commands are the same in both products. SORT is program that is embedded in DFSORT/SYNCSORT tools. PGM = SORT can point to either DFSORT or SYNCSORT depending on the installation.
The SORT program can also be used to MERGE existing sorted files and combine them into one sequential file. Since SORT program can do both, record sorting and file merging, it is referred to as SORT / MERGE utility.
JCL requirement for SORT/MERGE
While using SORT program, JCL needs to be coded with below datasets
- SYSOUT: The message listing
- SYSOUT Processing
- SYSIN: To specify control statements
- In-stream data, here we specify control statements which is used to define how datasets needs to be sorted/merged
- Most frequently used control statements are SORT, INREC, INCLUDE, SUM, OMIT, OUTREC and their order of invocation is as below:-
- SORTIN: Input file
- SORTINnn: Input file for merge operation
- SORTOUT: Output file for sort or merge operation
- SORTWKnn: Sort work files. Mostly one or two files