Module 8: JCL Sort & Merge
INREC statement is used to reformat input dataset before sort. In other words INREC statement is used to add, delete or to rearrange the fields of dataset before records are sorted, merged or copied.
- FIELDS or BUILD
- IF THEN clauses
IMP NOTE: Explanation for all these parameters are already detailed in previous articles 'OUTREC FIELDS or BUILD', 'OUTREC OVERLAY', 'OUTREC FINDREP', 'OUTREC IF THEN clauses'. The only difference is that, when we use INREC, records are formatted before they are sorted.
Requirement: Give sequence number to each records of input file and then sort it based on ascending order of employee-name.
JCL Code Solution:
- As mentioned earlier INREC is used to reformat data before sort, thus in above case first each records will be created by appending sequence number at 36th position and then it will be sorted in ascending order based on employee-name. If you observer output file shown above, the sequence number at position 36 indicates original position sequence when record was in input file