ICETOOL - SORT Operator


Sorts a data set to one or more output data sets.


Syntax: -



Sorts the indd data set to the outdd data sets (up to 10).

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

DFSORT control statements and options can be used to copy a subset of the input records, reformat records for output and so on.


Required Operands: -


FROM -

Specifies the ddname of the input data set.

DD statements must supply for the ddnames specified.


JKFROM -

Used for a JOINKEYS application.

JKFROM must provide a USING(xxxx) operand.

In xxxxCNTL, a JOINKEYS statement must provide with F1=ddname1 for the F1 file and a JOINKEYS statement with F2=ddname2 for the F2 file, as well as JOIN and REFORMAT statements as needed.


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.

TO, USING, or TO and USING must be specified.


Optional Operands: -


TO -

Specifies the ddnames of 1 to 10 output data sets.

DD statements must supply for the ddnames you specify.

TO, USING, or TO and USING must be specified.


VSAMTYPE -

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


Example: -

Below example to sort the employee records based on employee state(from 50th column of length 2).


Input: -

MTHUSR.INPUT.DATASET -


JCL: -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//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                         
//OUTDD    DD DSN=MTHUSR.OUTPUT.DATASET1,                               
//            DISP=(NEW,CATLG,DELETE),                                  
//            SPACE=(TRK,(1,1),RLSE),UNIT=SYSDA,                        
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)              
//TOOLIN   DD *                                                         
  SORT   FROM(INDD) TO(OUTDD) USING(CTL1)                               
/*                                                                      
//CTL1CNTL DD *                                                         
  SORT FIELDS=(50,2,CH,A)                                               
/*                                                                      
//TOOLMSG  DD DSN=MTHUSR.OUTPUT.TOOLMSG1,DISP=SHR                       
//DFSMSG   DD SYSOUT=*                                                  
//                                                                      
**************************** Bottom of Data ****************************


OUTPUT: -

TOOLMSG: -


MTHUSR.OUTPUT.DATASET1 -


Explaining Solution: -

  • INDD - Specifies the ddname for input dataset.
  • OUTDD - Specifies the ddname for output 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.
  • SORT FROM(INDD) TO(OUTDD) USING(CTL1) - Sorts the indd records and copies to OUTDD based on the selection criteria in CTL1.
  • SORT FIELDS=(50,2,CH,A) - Sorts the records in ascending order based on the data from 50th position of length 2.