OUTFIL: Including, omitting Records
OUTFIL: Including, omitting Records
Summary
- OUTFIL can be used with INCLUDE or OMIT parameters to include or omitting records.
- Different INCLUDE or OMIT parameters can be used for different OUTFIL statements.
- All of the logical expressions that are valid for the INCLUDE and OMIT parameters of OUTFIL. However, the FORMAT parameter cannot specify with the OUTFIL statement.
- VB data set considerations also apply to the INCLUDE and OMIT parameters.
Syntax -
SORT FILEDS=(Starting position, length, data-format, A/D)
OUTFIL FNAMES=DDNAME1, INCLUDE/OMIT COND=(….)
OUTFIL FNAMES=DDNAME2, INCLUDE/OMIT COND=(….)
…..
OUTFIL FNAMES=DDNAMEn, INCLUDE/OMIT COND=(….)
DDNAMEn | DDNAME is eight character’s name that representing the actual dataset in JCL. |
INCLUDE/OMIT | Specifies the INCLUDE/OMIT condition for specific OUTFIL |
Example -
Scenario - Create three output files like below.
dept1 records to file1
dept2 records to file2
records other than dept1 to file3
Input File - MTHUSER.SORT.INPUT01 - FB file of 80 length
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001 student1 dept1 560
00003 student3 dept2 520
00004 student4 dept1 540
00005 student5 dept2 500
00002 student2 dept3 510
00006 student6 dept3 550
00008 student8 dept1 530
00007 student7 dept3 510
00009 student9 dept2 520
00010 student10 dept2 505
******************************** Bottom of Data ********************************
JCL -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//Job-card
//*
//**********************************************************************
//*
//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR
//OUTPUT1 DD DSN=MTHUSER.SORT.OUTPT01,
// SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,
// DISP=(NEW,CATLG,DELETE)
//OUTPUT2 DD DSN=MTHUSER.SORT.OUTPT02,
// SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,
// DISP=(NEW,CATLG,DELETE)
// SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,
// DISP=(NEW,CATLG,DELETE)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,5,ZD,A)
OUTFIL FNAMES=OUTPUT1,INCLUDE=(30,5,CH,EQ,C'dept1')
OUTFIL FNAMES=OUTPUT2,INCLUDE=(30,5,CH,EQ,C'dept2')
OUTFIL FNAMES=OUTPUT3,OMIT=(30,5,CH,EQ,C'dept1')
/*
**************************** Bottom of Data ****************************
Output File1 - MTHUSER.SORT.OUTPT01 - FB file of 80 length
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001 student1 dept1 560
00004 student4 dept1 540
00008 student8 dept1 530
******************************** Bottom of Data ********************************
Output File2 - MTHUSER.SORT.OUTPT02 - FB file of 80 length
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00003 student3 dept2 520
00005 student5 dept2 500
00009 student9 dept2 520
00010 student10 dept2 505
******************************** Bottom of Data ********************************
Output File3 - MTHUSER.SORT.OUTPT03 - FB file of 80 length
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00002 student2 dept3 510
00003 student3 dept2 520
00005 student5 dept2 500
00006 student6 dept3 550
00007 student7 dept3 510
00009 student9 dept2 520
00010 student10 dept2 505
******************************** Bottom of Data ********************************
Explaining Example -
- SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.
- OUTFIL FNAMES=OUTPUT1,INCLUDE=(30,5,CH,EQ,C'dept1') - All the records marching with "dept1" from the 30th position of length 5 will be copied to output1 file.
- OUTFIL FNAMES=OUTPUT2,INCLUDE=(30,5,CH,EQ,C'dept2') - All the records marching with "dept2" from the 30th position of length 5 will be copied to output2 file.
- OUTFIL FNAMES=OUTPUT3,OMIT=(30,5,CH,EQ,C'dept1') - All the records marching with "dept1" from the 30th position of length 5 will be ignored and remaining all records will be copied to output3 file.