OMIT Records
OMIT Records Example
Scenario - Filter the records not having the id is 00001. The ID starts from 1st and ends at 5th column in the file
Input File - MATEPK.SORT.INPUT
---+----1----+----2----+---3----+---4----+---5---+---6----+----7---+---8 00002 Srinivas Employee test test test 00001 pawan kumar student
JCL -
----+----1----+----2----+----3----+----4----+----5----+
//MATEPKD JOB (123),'MTH',NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=MATEPK.SORT.INPUT,DISP=SHR
//SORTOUT DD DSN=MATEPK.MERGE.OUTPUT,
// DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
// SPACE=(CYL,(1,4),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OMIT COND=(1,05,CH,EQ,C'00001')
/*
Output -
----+----1----+---2----+---3---+----4---+---5---+---6---+----7----+----8 00002 Srinivas Employee test test test
Explaining Example -
- As a first step, need to get the position of the ID in the file. The ID starting from 1st position and ends at 5th position as per the input record layout provided. So the length of ID field is 5.
- As a second step, need to get the type of the ID. From the Input record layout declaration, ID field is alpha-numeric. So the type is character (CH).
- Lastly, the job requirement is to ignore the data with the ID as 00001 and other records should be copied. So the constant is 00001.
OMIT COND=(1,05,CH,EQ,C'00001')
- The above condition specifies that ignore the records where the ID is 00001. The output would have the records where the IDs not equal to00001 at first 5 positions.