OUTFIL Including, omitting Records
OUTFIL parameter is used with INCLUDE or OMIT parameters to include or omitting records. All of the logical conditons are valid for the INCLUDE and OMIT parameters with OUTFIL. However, the FORMAT parameter can't code with the OUTFIL statement.
Syntax -
//SYSIN DD *
SORT FILEDS=...
OUTFIL FNAMES=DDname-n,INCLUDE/OMIT COND=(….)
/*
Examples -
Scenario1 - Including Records Based on a Condition
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,INCLUDE=(1,3,CH,EQ,C'ABC')
/*
Only records where the first 3 characters (starting at position 1) equal 'ABC' are included in the output file SORTOUT.
Scenario2 - Omitting Records Based on a Condition.
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,OMIT=(5,4,ZD,GT,5000)
/*
Records where the 4-byte zoned decimal field starting at position 5 is greater than 5000 are omitted from the output file SORTOUT.
Scenario3 - Including Records with Multiple Conditions.
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,INCLUDE=(1,3,CH,EQ,C'XYZ',AND,10,2,CH,NE,C'99')
/*
Records where the first 3 characters equal 'XYZ', and the 2-character field starting at position 10 is not equal to '99' are included in the output.