Error checking and further actions (MODE Operator) Example


Scenario -Separate employee details based on "IN", "US". If any error occurs in the first processing stops the second process.

INPUT - MATEPK.INPUT.PSFILE

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
001  PAWAN         MAINFRAME           JPM       AP        IN
002  SRINIVAS      TESTING             ORACLE    TG        IN
003  SRIDHAR       SAS                 CG        OR        US
004  VENKATESH     ABAP                CSC       CA        IN
005  RAVI          HADOOP              CTS       FL        US
006  PRASAD        HR                  INFOSYS   MI        US
007  RAJA          TESTING             IBM       CA        US

JCL -

----+----1----+----2----+----3----+----4----+----5----+
//MATEPKIT JOB (123),'MATEPK',CLASS=A,MSGCLASS=A,
//             MSGLEVEL=(1,1),NOTIFY=&SYSUID
//*
//STEP01   EXEC PGM=ICETOOL
//INDD     DD DSN=MATEPK.INPUT.PSFILE,DISP=SHR
//OUTDD1   DD DSN=MATEPK.OUTPUT.PSFILEM1,
//            DISP=(NEW,CATLG,DELETE),VOLUME=SER=DEVHD4,
//            SPACE=(TRK,(1,1),RLSE),UNIT=SYSDA,
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)
//OUTDD2   DD DSN=MATEPK.OUTPUT.PSFILEM2,
//            DISP=(NEW,CATLG,DELETE),VOLUME=SER=DEVHD4,
//            SPACE=(TRK,(1,1),RLSE),UNIT=SYSDA,
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)
//TOOLIN   DD * 
  COPY  FROM(INDD) TO(OUTDD1) USING(CTL1)
  MODE  STOP
  COPY  FROM(INDD) TO(OUTDD2) USING(CTL2)
/*
//CTL1CNTL DD * 
  INCLUDE COND=(60,2,CH,EQ,C'IN') 
/* 
//CTL2CNTL DD *
  INCLUDE COND=(60,2,CH,EQ,C'US')
/*
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//

OUTPUT1 - MATEPK.OUTPUT.PSFILEM1

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
001  PAWAN         MAINFRAME           JPM       AP        IN
002  SRINIVAS      TESTING             ORACLE    TG        IN
004  VENKATESH     ABAP                CSC       CA        IN

OUTPUT2 - MATEPK.OUTPUT.PSFILEM2

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
003  SRIDHAR       SAS                 CG        OR        US
005  RAVI          HADOOP              CTS       FL        US
006  PRASAD        HR                  INFOSYS   MI        US
007  RAJA          TESTING             IBM       CA        US

TOOLMSG (SDSF SPOOL) - Verify TOOLMSG for the return code of the submitted job.

MODE TOOLMSG

Explaining Example -

  • INDD - Specifies the ddname for input file.
  • OUTDD1,OUTDD2 - Specifies the ddnames for output files.
  • TOOLIN DD * - Specifies the ICETOOL statements for DFSORT.
  • TOOLMSG - Specifies where to write the ICETOOL processing messages.
  • DFSMSG - Specifies where to write the DFSORT processing messages.
  • COPY FROM(INDD) TO(OUTDD1) USING(CTL1) - Copies the data records which satisfies the selection criteria specified in CTL1 from INDD to OUTDD1.
  • MODE STOP - Stops the process if error occurs by the statement throws an error.
  • COPY FROM(INDD) TO(OUTDD2) USING(CTL2) - Copies the data records which satisfies the selection criteria specified in CTL2 from INDD to OUTDD2.
  • CTL1CNTL DD *, CTL2CNTL DD * - Specifies the DFSORT statements for processing.
  • INCLUDE COND=(60,2,CH,EQ,C'IN') - Selection criteria to copy the records which are having 'IN' from 60th byte of length 2 bytes.
  • INCLUDE COND=(60,2,CH,EQ,C'US') - Selection criteria to copy the records which are having 'US' from 60th byte of length 2 bytes.