INCLUDE Coding Constants Example


Scenario - From the below data, filter the records having name 'Srinivas'. The NAME starts from 11th and ends at 28th 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----+----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
     INCLUDE COND=(11,15,CH,EQ,C'Srinivas')
/*

Output -

----+----1----+----2---+----3---+----4---+---5---+----6---+---7---+----8
00002     Srinivas            Employee

Explaining Example -

  1. As a first step, need to get the position of the NAME in the file. The NAME starting from 11th and ends at 25th column as per the input record layout provided. So the length of NAME field is 15.
  2. As a Second step, need to get the type of the NAME. From the Input record layout declaration, NAME field is alpha-numeric. So the type is character (CH).
  3. Lastly, the job requirement is to filter the data with the NAME as Srinivas. So the constant is "Srinivas".
  4. INCLUDE COND=(11,15,CH,EQ,C'Srinivas') 
    - specifies that include the records where the NAME is "Srinivas" and copied to output file.
  5. The output would have the records which contains the NAME as "Srinivas" from 11th position.