SELECT Operator (for Experienced)


Summary

For basic information, go through the SELECT Operator (for Beginners)

  • The SELECT operator selects 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 specified with DISCARD.
  • 1 to 10 ON fields can be coded with the SELECT operator.
  • DISCARD(savedd) saves records that do not meet the criteria.
  • DISCARD(savedd) may be used with or without TO(outdd).
  • The DFSORT control statements in xxxxCNTL are used if USING(xxxx) is specified.

Syntax -

SELECT Operator

Required Operands


FROM -

  • FROM parameter specifies ddname of the input file.
  • indd DD statement is mandatory if FROM operand specified.

LIST -

  • listdd specifies the list dataset ddname to be created by ICETOOL LIST operation.
  • A listdd DD statement should be provided.

ON -

  • ON operator specifies the field(s) used for DISPLAY operation.
  • 1 to 50 ON fields can be specified with the DISPLAY operation.
    • (p,m,f) gives the position, length, and format of a numeric or character field. The field should not be beyond position 32752 or the end of the record.
    • (p,m,f, formatting) gives a numeric or character field's position, length, and format. It also specifies how the data is to be formatted for printing for this field. The field should not be beyond position 32752 or the end of the record.
    • VLEN is equivalent to ON(1,2, BI) for variable-length records, representing each record's record length.

DISCARD -

  • DISCARD specifies the ddname of the output data set for the not selected records.
  • DD statement should provide for the ddname used.
  • TO(outdd) and DISCARD(savedd) may be used together or separately.

Optional Operands


VSAMTYPE -

  • VSAMTYPE operand specifies the record format for a VSAM input file (F or V).

UZERO -

  • Causes -0 to be treated as unsigned, that is, as 0.

USING -

  • USING operand specifies the first 4-characters of the ddname (xxxxCNTL) for the DFSORT control statement file.
  • XXXX name is the user-defined name.
  • xxxxCNTL DD statement is mandatory if USING(xxxx) is specified.
  • 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

 BROWSE    MATEPK.INPUT.PSFILE                        Line 00000000 Col 001 080 
 Command ===>                                                  Scroll ===> CSR  
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
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                   
******************************** Bottom of Data ********************************

JCL -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEPKS  JOB (123),'MATEPK',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),        
//             NOTIFY=&SYSUID                                           
//*                                                                     
//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)                      
/*                                                                      
//TOOLMSG  DD SYSOUT=*                                                  
//DFSMSG   DD SYSOUT=*                                                  
//                                                                      
**************************** Bottom of Data ****************************

OUTPUT - MATEPK.OUTPUT.PSFILES

 BROWSE    MATEPK.OUTPUT.PSFILES                      Line 00000000 Col 001 080 
 Command ===>                                                  Scroll ===> CSR  
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
001  PAWAN         MAINFRAME           JPM       AP        IN                   
002  SRINIVAS      TESTING             ORACLE    TG        IN                   
003  SRIDHAR       SAS                 CG        OR        US                   
005  RAVI          HADOOP              CTS       FL        US                   
******************************** Bottom of Data ********************************

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

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9
********************************* TOP OF DATA ********************************************
1ICE600I 0 DFSORT ICETOOL UTILITY RUN STARTED                                   
                                                                                
 ICE650I 0 VISIT http://www.ibm.com/storage/dfsort FOR ICETOOL PAPERS, EXAMPLES AND MORE 
                                                                                
 ICE632I 0 SOURCE FOR ICETOOL STATEMENTS:  TOOLIN                               
                                                                                
                                                                                
 ICE630I 0 MODE IN EFFECT:  STOP                                                
                                                                                
             SELECT FROM(INDD) TO(OUTDD) ON(60,2,CH) FIRST(2)               
 ICE627I 0 DFSORT CALL 0001 FOR SORT FROM INDD     TO OUTDD    COMPLETED    
 ICE628I 0 RECORD COUNT:  000000000000007                                   
 ICE638I 0 NUMBER OF RECORDS RESULTING FROM CRITERIA:  000000000000004      
 ICE602I 0 OPERATION RETURN CODE:  00                                       
                                                                                
                                                                                
 ICE601I 0 DFSORT ICETOOL UTILITY RUN ENDED - RETURN CODE:  00                  
******************************** BOTTOM OF DATA ******************************************

Explaining Solution -

  • INDD - Specifies the ddname for input file.
  • OUTDD - Specifies the ddname for output file.
  • 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.
  • SELECT FROM(INDD) TO(OUTDD1) ON(60,2,CH) FIRST(2) - Selects the first two records for each individual key(2 character length from 60th position) specified in the criteria.