OMIT Substring Search
OMIT Substring Search Example
Scenario - Filter the records not having 'Srinivas' text in the entire 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----+----6----+----7--
//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,80,SS,EQ,C'Srinivas')
/*
Output -
--+----1----+----2----+----3---+----4----+----5----+---6---+---7---+----8 test test test 00001 pawan kumar student
Explaining Example -
- As a first step, need to get the position NAME in the file. As per requirement, the string can be anywhere in the file. So the starting position is file starting position and the length is the file length which is 80.
- As a second step, need to get the type of the String. From the requirement,the string is alphabetic. So the type is character (CH).
- Lastly, the job requirement is to ignore the data with Srinivas. So the constant is "Srinivas".
OMIT COND=(1,80,SS,EQ,C'Srinivas')
- specifies that ignore the records where the string found as Srinivas. The remaining records will be copied to output file.- The output would have the records where the record not contains Srinivas anywhere in the record.