ICETOOL - SPLICE Operator


Splices specified fields together from records that have the same specified numeric or character field values (duplicate values) but with different information.

Specified fields from two or more records can be combined to create an output record.

The fields to be joined can originate from records in different data sets.


Syntax: -



Splice makes it possible to join fields from different types of input records to create an output record with information from two or more records.

From 1 to 10 ON fields can be specified.

By default, the first duplicate is spliced with all the WITH fields from the last duplicate.

From 1 to 50 WITH fields can be specified.

WITHALL can be used to splice the first duplicate with all the WITH fields from the second and subsequent duplicates.

WITHANY can be used to splice the first duplicate with nonblank WITH fields from the second and subsequent duplicates.

WITHEACH can be used to splice the first duplicate with one WITH field from the second and subsequent duplicates in turn. By default, non-matching records are not kept.

KEEPNODUPS can be used to keep non-matching records. By default, the base record is not kept.

KEEPBASE can be used to keep the base record. By default, for variable-length records, the length of the base record is used as the length of the spliced record.


Required Operands: -


FROM -

Specifies the ddname of the input data set.

DD statement must supply for the ddname specified.


TO -

Specifies the ddname of the output data set for the selected records.

DD statement must supply for the ddname specified.


ON -

Specifies a field to be used for this operation.

From 1 to 10 ON fields can be specified.

(p,m,f) gives the position, length and format of a numeric or character field. A field must not extend beyond position 32752 or the end of the record.


WITH(p,m) -

Specifies a field to be spliced from the second or subsequent duplicate record to the first duplicate record.

From 1 to 50 WITH fields can be specified.

(p,m) gives the position and length of the field.


Optional Operands: -


WITHALL -

Specifies the first duplicate is spliced with all of the specified WITH fields from the second duplicate, and then from each subsequent duplicate in turn.


WITHANY -

Specifies the first duplicate is spliced with all of the specified nonblank WITH fields from each subsequent duplicate.


WITHEACH -

Specifies the first duplicate is spliced with one specified WITH field from each subsequent duplicate.


KEEPNODUPS -

Specifies non-duplicates are kept (unchanged) along with the spliced records.


KEEPBASE -

Specifies the base records are kept (unchanged) along with the spliced records.


VSAMTYPE -

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


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 data set.


Example: -

Below example to join the employee records(1 to 39 columns of first and last records) for each distinct employee country(from 60th 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                         
//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)              
//TOOLIN   DD *                                                         
  SPLICE FROM(INDD) TO(OUTDD1) ON(60,2,CH) WITH(1,39) KEEPBASE          
/*                                                                      
//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.
  • OUTDD1 - Specifies the ddname for output dataset.
  • TOOLIN DD * - Specifies the ICETOOL statements for DFSORT.
  • TOOLMSG - Specifies ICETOOL message data set.
  • DFSMSG - Specifies DFSORT message data set.
  • SPLICE FROM(INDD) TO(OUTDD1) ON(60,2,CH) WITH(1,39) KEEPBASE - Copies first and last records for each unique value based on the selection criteria from 60th position of length 2.