Module 8: JCL Sort & Merge
MERGE FIELDS
It is used to combine one or more sorted input files into a single, ordered, sequential file.
Syntax of MERGE command:
MERGE FIELDS= (sort-key1, sort-key2,…., sort-keyN)
Where, each sort-key consist of below four paramaters:-
Important note: MERGE command will fail if any of the input file is not sorted for the condition you specify on MERGE FILEDS control statement For example, if you are going to merge files using controls card “MERGE FIELDS=(1,5,CH,A)”, then all input files must be in ascending order for column 1 to 5. If input files are not already in sorted based on these conditions, job will fail.
Example:-
Requirement:-Need to MERGE two sorted files into one sorted file in ascending order of column 1 to 5
Input file SORTIN01 :-
Input file SORTIN02 :-
JCL CODE:-
Output file SORTOUT:-