ICETOOL - COUNT Operator


Prints message in TOOLMSG containing the records count in a data set.

COUNT used to create an output data set containing text and the count.

COUNT used to set RC=12, RC=8, RC=4 or RC=0 based on meeting criteria for the number of records in a data set.


Syntax: -



The DFSORT control statements are coded in xxxxCNTL if USING(xxxx) is specified.

COUNT can also be used to -

  • subtract a value from the count.
  • add a value to the count.
  • create an output data set containing text and the count or just the count.
  • sets RC=12, RC=8 or RC=4 if the record count meets specified criteria or RC=0 if the record count does not meet specified criteria.

Required Operands


FROM

Specifies ddname of the input data set.

DD statements must supply for the ddnames specified.


Optional Operands


USING

Specifies the first 4 characters of the ddname (xxxxCNTL) for the DFSORT control statement data set.

DD statement must supply for xxxxCNTL if USING(xxxx) specified.


VSAMTYPE

Specifies the record format for a VSAM input data set (F or V).


EMPTY, NOTEMPTY, HIGHER, LOWER, EQUAL, NOTEQUAL

Defines the criteria against which the record count is to be matched.

ICETOOL sets RC=4 if RC4 is specified, RC=8 if RC8 is specified, or RC=12 if RC12 is specified or by default if the criteria is met.

ICETOOL sets RC=0 for this COUNT operator if the criteria is not met.

x, y, v and w must be specified as n or +n where n can be 0 to 562949953421310.


RC4

Sets RC=4 if the criteria is met (overriding the default of RC=12).


RC8

Sets RC=8 if the criteria is met (overriding the default of RC=12).


RC12

Sets RC=12 if the criteria is met (same as the default of RC=12).


SUB

Subtracts a value from the record count.

The record count is set to 0 if SUB reduces the record count below 0.

q must be specified as n or +n where n can be 1 to 999.


ADD

Adds a value to the record count.

“r” must be specified as n or +n where n can be 1 to 999.


WRITE

Specifies ddname of the count data set.

DD statement must supply for the ddname specified.


TEXT

Specifies a string to be printed before the count in the output count data set.

The string can be 1 to 50 characters.


DIGITS

Specifies the number of digits for the count in the output count data set.

‘d’ value can be 1 to 15.


EDCOUNT

Specifies how the count is to be formatted for printing.

The formatting items can be used are: mask, E'pattern', L'string', F'string', T'string', LZ and Udd.


WIDTH

Specifies the record length and LRECL for the count data set.

n can be 1 to 32760.


Example: -

Below example to count the employee records whose country is ‘IN’(from 60th byte of length 2) to output dataset.


Input: -


JCL: -

//MTHUSRR JOB (123),'MTHUSR',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1), 
//             NOTIFY=&SYSUID                                   
//*                                                             
//STEP01   EXEC PGM=ICETOOL                                     
//INDD     DD DSN=MTHUSR.INPUT.DATASET,DISP=SHR                 
//TOOLIN   DD *                                                 
  COUNT FROM(INDD) USING(CTL1)                                  
/*                                                              
//CTL1CNTL DD *                                                 
  INCLUDE COND=(60,2,CH,EQ,C'IN')                               
/*                                                              
//TOOLMSG  DD DSN=MTHUSR.OUTPUT.TOOLMSG1,DISP=SHR               
//DFSMSG   DD SYSOUT=*                                          
//  


TOOLMSG OUTPUT: -


Explaining Solution: -

  • INDD - Specifies the ddname for input dataset.
  • TOOLIN DD * - Specifies the ICETOOL statements for DFSORT.
  • CTL1CNTL DD * - Specifies the DFSORT statements for processing.
  • TOOLMSG - Specifies ICETOOL message data set.
  • DFSMSG - Specifies DFSORT message data set.
  • COUNT FROM(INDD) USING(CTL1) - Counts the data from INDD based on the USING condition specified in CTL1.
  • INCLUDE COND=(60,2,CH,EQ,C'IN') – CTL1 condition specified is the rows which had ‘IN’ from 60th position of length 2.