SPLICE Operator
SPLICE Operator (for Experienced)
Summary
For basic information, go through the SPLICE Operator (for Beginners)
- SPLICE operator joins specified fields together from records with the same values (duplicate values) but with different information in other areas.
- It combines specified fields from two or more records to create an output record.
- The fields to be joined can originate from different datasets.
- SPLICE operator also makes it possible to join fields from different input records to create an output record with information from two or more records.
- SPLICE operator allows up to 10 ON fields and 50 WITH fields.
Syntax -

Required Operands
FROM -
- FROM parameter specifies ddname of the input file.
- indd DD statement is mandatory if FROM operand specified.
TO -
- TO operand specifies 1 to 10 ddnames of output files.
- outdd DD statement is mandatory if TO operand specified
- Either TO, USING, or both operands can code at the same time.
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.
Optional Operands
VSAMTYPE -
- VSAMTYPE operand specifies the record format for a VSAM input file (F or V).
WITHALL -
- WITHALL is used to splice the first duplicate with all the WITH fields from the second and subsequent duplicates.
WITHANY -
- WITHANY is used to splice the first duplicate with nonblank WITH fields from the second and subsequent duplicates.
WITHEACH -
- WITHEACH is used to splice the first duplicate with one WITH field from the second and subsequent duplicates.
- By default, non-matching records are not kept.
KEEPNODUPS -
- KEEPNODUPS is used to keep non-matching records.
- By default, the base record is not kept.
KEEPBASE -
- KEEPBASE is used to keep the base record.
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 - Create one spliced record for each match in two files.
In this example, we are joining employee details with employee salary based on employee number(columns 1-3).
INPUT1 - 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 ********************************
INPUT2 - MATEPK.INPUT.PSFILE3
BROWSE MATEPK.INPUT.PSFILE3 Line 00000000 Col 001 080
Command ===> Scroll ===> CSR
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
001 0000100000
002 0000095000
003 0000080000
004 0000053000
005 0000072000
006 0000066000
007 0000047000
******************************** Bottom of Data ********************************
JCL -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEPKSP JOB (123),'MATEPK',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=ICETOOL
//INDD1 DD DSN=MATEPK.INPUT.PSFILE,DISP=SHR
//INDD2 DD DSN=MATEPK.INPUT.PSFILE3,DISP=SHR
//TEMP DD DSN=&&TEMP,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA,
// DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)
//OUTDD DD DSN=MATEPK.OUTPUT.PSFILESP,
// 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 *
COPY FROM(INDD1) TO(TEMP) USING(CTL1)
COPY FROM(INDD2) TO(TEMP) USING(CTL2)
SPLICE FROM(TEMP) TO(OUTDD) ON(1,3,ZD) WITH(70,10)
/*
//CTL1CNTL DD *
OUTREC FIELDS=(1,69,70:X)
/*
//CTL2CNTL DD *
OUTREC FIELDS=(1:1,3,70:10,10)
/*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//
**************************** Bottom of Data ****************************
OUTPUT - MATEPK.OUTPUT.PSFILE
BROWSE MATEPK.OUTPUT.PSFILESP 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 0000100000
002 SRINIVAS TESTING ORACLE TG IN 0000095000
003 SRIDHAR SAS CG OR US 0000080000
004 VENKATESH ABAP CSC CA IN 0000053000
005 RAVI HADOOP CTS FL US 0000072000
006 PRASAD HR INFOSYS MI US 0000066000
007 RAJA TESTING IBM CA US 0000047000
******************************** 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
COPY FROM(INDD1) TO(TEMP) USING(CTL1)
ICE606I 0 DFSORT CALL 0001 FOR COPY FROM INDD1 TO TEMP USING CTL1CNTL COMPLETED
ICE602I 0 OPERATION RETURN CODE: 00
COPY FROM(INDD2) TO(TEMP) USING(CTL2)
ICE606I 0 DFSORT CALL 0002 FOR COPY FROM INDD2 TO TEMP USING CTL2CNTL COMPLETED
ICE602I 0 OPERATION RETURN CODE: 00
SPLICE FROM(TEMP) TO(OUTDD) ON(1,3,ZD) WITH(70,10)
ICE627I 0 DFSORT CALL 0003 FOR SORT FROM TEMP TO OUTDD COMPLETED
ICE628I 0 RECORD COUNT: 000000000000014
ICE638I 0 NUMBER OF RECORDS RESULTING FROM CRITERIA: 000000000000007
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.
- COPY FROM(INDD1) TO(TEMP) USING(CTL1) - Writes the records to the temp file using CTL1.
- OUTREC FIELDS=(1,69,70:X) - Format the record filling spaces from 70th column.
- COPY FROM(INDD2) TO(TEMP) USING(CTL2) - Writes the records to the temp file using CTL2.
- OUTREC FIELDS=(1:1,3,70:10,10) - Reformat the record moving data from 10-19 columns to 70-79 columns.
- SPLICE FROM(TEMP) TO(OUTDD) ON(1,3,ZD) WITH(70,10) - Joins the records from INDD1, INDD2 together based on the key value (1-3 columns).