INCLUDE Alphanumeric Tests Example


Scenario - Filter the records having the ID data is alphanumeric and only numeric. The ID starts from 1st and ends at 5th column in the file.

Input File - MTH.SORT.INPUT

----+----1----+----2----+----3----+----4----+----5---+---6---+---7---+---8
00002     Srinivas            Employee
test3     test3               test3
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=MTH.SORT.INPUT,DISP=SHR
//SYSIN    DD *
     SORT FIELDS=COPY
     INCLUDE COND=(1,05,BI,EQ,MN)
/*
//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=*

Output -

---+---1---+---2----+---3----+----4---+---5---+---6----+----7---+---8
00002     Srinivas            Employee
test3     test3               test3
00001     pawan kumar         student

Explaining Example -

  1. As a first step, we need to get the position of the ID in the file. The names starting from 1st position and ends at 5th position as per the input record layout. So the length of ID field is 5.
  2. As a second step, we need to get the type of the ID. From the input record layout declaration, ID field is alpha-numeric. For alpha-numeric test, use BI instead of the actual field type.
  3. Lastly, the job requirement is to filter the data with the ID having alphanumeric and only numeric. So the keyword MN should use to match the condition.
  4. INCLUDE COND=(1,05,BI,EQ,MN)
    - The output would have the records where the IDs are alphanumeric and only numeric at first 5 positions.