Displays the records count (COUNT Operator) Example


Scenario - Count the records whose country is 'IN' (from 60th byte of length 2).

INPUT - MATEPK.INPUT.PSFILE

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

JCL -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//MATEPKCO JOB (123),'MATEPK',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID
//*
//STEP01   EXEC PGM=ICETOOL
//INDD     DD DSN=MATEPK.INPUT.PSFILE,DISP=SHR
//TOOLIN   DD *
  COUNT FROM(INDD) USING(CTL1)
/*
//CTL1CNTL DD *
  INCLUDE COND=(60,2,CH,EQ,C'IN')
/*
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//

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

COUNT TOOLMSG

Explaining Example -

  • INDD - Specifies the ddname for input file.
  • TOOLIN DD * - Specifies the ICETOOL statements for DFSORT.
  • CTL1CNTL DD * - Specifies the DFSORT statements for processing.
  • TOOLMSG - Specifies where to write the ICETOOL processing messages.
  • DFSMSG - Specifies where to write the DFSORT processing messages.
  • COUNT FROM(INDD) USING(CTL1) - Counts the records from INDD based on the DFSORT statements specified in CTL1.
  • INCLUDE COND=(60,2,CH,EQ,C'IN') – condition to filter the rows that are having 'IN' from position 60 - 61.