Selects specific records from input (SELECT Operator)


SELECT operator selects the specific records from an input file and writes in an output file based on selection criteria. Records that are not selected can save in a separate output file coded with DISCARD DD statement. DISCARD(savedd) saves records that do not meet the criteria. DISCARD(savedd) may be used with or without TO(outdd).

Syntax -

SELECT Operator

Required Operands


  • FROM - specifies ddname of the input file. It is mandatory when FROM operand is coded.
  • LIST - specifies the list dataset ddname to be created by ICETOOL LIST operation.
  • ON (p,l,f) - specifies the field(s) used for validation.
    • p - gives the starting position of field.
    • l - gives the length of the field. The field should not be beyond position 32752 or the end of the record.
    • f - gives the format of the data. The valid formats are PD(Signed Packed decimal - 1 to 16 bytes) and ZD (Signed Zoned decimal - 1 to 31 bytes).
  • DISCARD - specifies the ddname of the output file for the records not selected.

Optional Operands


  • VSAMTYPE - specifies the record format for a VSAM input file. It should be either F (fixed-length) or V (variable-length) record processing.
  • UZERO - Causes -0 to be treated as unsigned, that is, as 0.
  • USING - specifies the first 4-characters of the ddname (xxxxCNTL) for the DFSORT control statement. XXXX name is the user-defined name. Either TO, USING, or both operands can code at the same time.

Example -


Scenario - Select the first two records for each different value in the sorting criteria.

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----+
...
//STEP01   EXEC PGM=ICETOOL
//INDD     DD DSN=MATEPK.INPUT.PSFILE,DISP=SHR
//OUTDD    DD DSN=MATEPK.OUTPUT.PSFILES,
//            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 *
  SELECT FROM(INDD) TO(OUTDD) ON(60,2,CH) FIRST(2)
/*
...

OUTPUT - MATEPK.OUTPUT.PSFILES

----+----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
005  RAVI          HADOOP              CTS       FL        US