Example 10 - Create spliced variable-length records from two files
This example shows how you can splice data together for each pair
of records with the same ON field in two different VB input data sets,
even when records are of different lengths.
//S10 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=VAR.INPUT1,DISP=SHR
// DD DSN=VAR.INPUT2,DISP=SHR
//OUT DD DSN=VAR.OUTPUT,DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,5)),UNIT=SYSDA
//TOOLIN DD *
* Splice the needed data from the two VB files together
SPLICE FROM(CON) TO(OUT) ON(5,5,CH) WITHALL -
WITH(12,5) WITH(22,20) VLENMAX
/*
VAR.INPUT1 has RECFM=VB and LRECL=25. It contains the base records
which look like this:
Length | Data
25 | DIV01 L2
15 | DIV02
25 | DIV03 L6
25 | DIV05 L8
VAR.INPUT2 has RECFM=VB and LRECL=50. It contains the overlay
records which look like this:
Length | Data
42 | DIV01 83201 FERN BROTHERS INTL
33 | DIV01 73268 ROSS INC.
39 | DIV02 00589 ACME PAINT SHOP
19 | DIV05 57003
47 | DIV05 01381 FLOWERS BY RENEE
43 | DIV06 37982 EVERYTHING FOR PETS
Because some of the overlay records are longer than their corresponding base records, we use VLENMAX to ensure that none of the data from the overlay records is lost. VLENMAX ensures that the larger length between the base record and overlay record is used for the spliced record, and that blanks are added to the end of the spliced record when needed.
The base and overlay records from the concatenated data sets are
sorted and spliced. VAR.OUTPUT has RECFM=VB and LRECL=50. It contains
the spliced records, which look like this:
Length | Data
42 | DIV01 83201 L2 FERN BROTHERS INTL
33 | DIV01 73268 L2 ROSS INC.
39 | DIV02 00589 ACME PAINT SHOP
25 | DIV05 57003 L8
47 | DIV05 01381 L8 FLOWERS BY RENEE
Notice that VLENMAX
prevented any data from being lost. Without VLENMAX, data would have
been lost; the spliced records would have looked like this: Length | Data
25 | DIV01 83201 L2 FERN
25 | DIV01 73268 L2 ROSS
15 | DIV02 0058
25 | DIV05 57003 L8
25 | DIV05 01381 L8 FLOW