DFSORT has very sophisticated record selection capabilities, whether before any sort (INCLUDE / OMIT) or after the sort (OUTFIL INCLUDE / OMIT).
With OUTFIL INCLUDE / OMIT, you can use different criteria to send records to multiple output destinations, as in the below fig. In this example, records are selected before the actual sort with INCLUDE and then reformatted with INREC. Then, the sort data is written to the following destinations:
OUTFIL INCLUDE 1
OUTFIL INCLUDE 2
DFSORT has versatile record editing capabilities, whether using INREC on input or OUTREC or OUTFIL on output. Unless you are writing to multiple destinations or need some specific OUTFIL feature, it is recommended that you use the OUTREC statement rather than the OUTFIL statement.
Here are some examples of reformatting capabilities:
Adding fields at the end of records
Finding and replacing strings, both as substrings and as direct lookups
Manipulate timestamps and add the current time and date into records
Reformat fields, such as converting to and from hexadecimal, translating from lower case to upper case, and number reformatting
Perform arithmetic operations, such as adding two numeric fields together to create a new field
Inserting sequence numbers
Left- and right-justifying fields
Converting between variable-length and fixed-length records and vice versa
With IFTHEN, you can selectively reformat records, based on whether the record meets specific criteria.
Originally, DFSORT only reformatted records by explicitly specifying all the fields. With OVERLAY, you can now specify just the fields to be changed, which simplifies many reformatting applications.
Sample JCL for IFTHEN:
//COPY1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD SYSOUT=*
//SYSIN DD *