ICETOOL - MERGE Operator


Merges one or more input data sets into one or more output data sets.

Up to 10 FROM operands can be used in Merge function.

Merges the indd data sets to the outdd data sets using the DFSORT control statements in xxxxCNTL.

DFSORT MERGE statement must supply in xxxxCNTL to indicate the control fields for the MERGE.

The records in each input data set to be merged must already sorted as specified by the control field in the supplied DFSORT MERGE statement.


Syntax: -



Required Operands: -


FROM -

Specifies the ddnames of 1 to 50 input data sets.

DD statements must supply for the ddnames specified.


USING -

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

DD statement must supply for xxxxCNTL.

DFSORT MERGE statement must supply in xxxxCNTL.


Optional Operands: -


TO -

Specifies the ddnames of 1 to 10 output data sets.

DD statements must supply for the ddnames specified.


VSAMTYPE -

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


Example: -

Below example to Merges the employee details and separate employees based on the country code “IN”, “US”.


Input: -

MTHUSR.INPUT.DATASET -


MTHUSR.INPUT.DATASET1 -


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                         
//INDD1    DD DSN=MTHUSR.INPUT.DATASET1,DISP=SHR                        
//OUTDD1   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)              
//OUTDD2   DD DSN=MTHUSR.OUTPUT.DATASET2,                               
//            DISP=(NEW,CATLG,DELETE),                                  
//            SPACE=(TRK,(1,1),RLSE),UNIT=SYSDA,                        
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)              
//TOOLIN   DD *                                                         
  MERGE FROM(INDD,INDD1) USING(CTL1)                                    
/*                                                                      
//CTL1CNTL DD *                                                         
  MERGE FIELDS=(1,3,ZD,A)                                               
  OUTFIL FNAMES=OUTDD1,INCLUDE(60,2,CH,EQ,C'IN')                        
  OUTFIL FNAMES=OUTDD2,INCLUDE(60,2,CH,EQ,C'US')                        
/*                                                                      
//TOOLMSG  DD SYSOUT=*                                                  
//DFSMSG   DD SYSOUT=*                                                  
//                                                                      
**************************** Bottom of Data ****************************


OUTPUT: -

TOOLMSG –


MTHUSR.OUTPUT.DATASET1 -


MTHUSR.OUTPUT.DATASET2 –


Explaining Solution: -

  • INDD,INDD1 - Specifies the ddname for input dataset.
  • OUTDD1,OUTDD2 - 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.
  • MERGE FROM(INDD,INDD1) USING(CTL1) - Merges the datasets INDD, INDD1 based on the CTL1 condition.
  • MERGE FIELDS=(1,3,ZD,A) - Merges the records based on the field exists at 1 to 3 characters.
  • OUTFIL FNAMES=OUTDD1,INCLUDE(60,2,CH,EQ,C'IN') - Separates the records which are having ‘IN’ from 60-62 columns and copies them to OUTDD1 dataset.
  • OUTFIL FNAMES=OUTDD2,INCLUDE(60,2,CH,EQ,C'US') - Separates the records which are having ‘US’ from 60-62 columns and copies them to OUTDD2 dataset.