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.
In this example, records are selected before the actual sort with INCLUDE and then reformatted with INREC. Then, the sorted data is written to the following destinations:
- OUTFIL INCLUDE 1
- OUTFIL INCLUDE 2
Flow Chart of DFSORT Utility How it Works While Processing Input Files
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:
- Overlaying fields
- Adding fields at the end of records
- Moving fields
- 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 * AXLE BOX AERIAL DEPOT ASPIC CARROT /* //SORTOUT DD SYSOUT=* //SYSIN DD * OPTION COPY INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'A'),OVERLAY=(8:C'YES')), IFTHEN=(WHEN=NONE,OVERLAY=(8:C'NO')) /*
You must be logged in to post a comment.