INCLUDE Substring Search
INCLUDE Substring Search Example
Scenario - Filter the records having 'Srinivas' 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 *
INCLUDE COND=(1,80,SS,EQ,C'Srinivas')
SORT FIELDS=COPY
/*
Output -
----+----1----+----2----+---3----+---4----+----5---+---6---+---7---+----8 00002 Srinivas Employee
Explaining Example -
- As a first step, need to get the position 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 filter the data with Srinivas. So the constant is "Srinivas".
- The output would have the records where the record contains Srinivas anywhere in the record from 1 to 80.
INCLUDE COND=(1,80,SS,EQ,C'Srinivas')- specifies that include the records where the string found is Srinivas.