Module 8: JCL Sort & Merge
OUTREC IF THEN clauses
Reformat different records in different ways by specifying how build, overlay, find/replace, or group operation items are applied to records that meet given criteria. IFTHEN clauses let you use sophisticated conditional logic to choose how different record types are reformatted.
Requirement: If input file have day-of-week as SUN or MON, then write ‘YES’ at 33 position of output file else write ‘NO’
JCL Code Solution:
- Statement ‘SORT FIELDS=COPY’ is used here to indicate that all records will be copied from input file to output file.
- Next statement OUTREC IFTHEN is coded to specify that if field at position (11-13 i.e. length-3) contains string ‘SUN’ or ‘MON’ then it should write string ‘YES’ at 33 position of output file. If it is not matching, then string ‘NO' will be written.