z/OS DFSORT Application Programming Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example 5 - Create multiple spliced records for each match in two types of records

z/OS DFSORT Application Programming Guide
SC23-6878-00

This example shows how you can use the WITHALL operand to tell ICETOOL to splice data together for a single record of one type (A records) and multiple records of another type (H records), in the same input data set, that all have the same ON field (duplicate records). It also shows how to ensure that duplicates of the second type without a match of the first type are not written to the output data set. IFTHEN clauses are used in an INREC statement to reformat the two types of records appropriately before they are sorted and spliced

//S5    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//MAST DD *
A0000B0000KRSC0000D000000E0000F00G000
A1111B1111FLYC1111D111111E1111F11G111
H02KRSI000002J002K002L02
H03FLYI000003J003K003L03
H04VQXI000004J004K004L04
H05FLYI000005J005K005L05
H06KHNI000006J006K006L06
H07KRSI000007J007K007L07
H08FLYI000008J008K008L08
H09KHNI000009J009K009L09
/*
//OUT DD SYSOUT=*
//TOOLIN   DD *
* Splice needed base and overlay data together.
* Do NOT splice identifier.
  SPLICE FROM(MAST) TO(OUT) WITH(1,7) WITH(13,4) ON(20,3,CH) -
   WITH(23,3) WITH(26,3) WITHALL USING(CTL1)
/*
//CTL1CNTL DD *
* Before SPLICE:
* Set up fields in base (A) records.  Add 'B' id in position 33.
  INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'A'),
     BUILD=(8:14,5,17:31,3,20:11,3,29:34,4,33:C'B')),
* Set up fields in overlay (H) records.  Add 'V' id in position 33.
   IFTHEN=(WHEN=(1,1,CH,EQ,C'H'),
   BUILD=(1:7,7,13:18,4,20:4,3,23:1,3,26:22,3,33:C'V'))
* After SPLICE:
* Remove duplicate overlay records without matching base record.
* Remove base or overlay indicator.
  OUTFIL FNAMES=OUT,OMIT=(33,1,CH,EQ,C'V'),OUTREC=(1,32)
/*                                                                  
The base records are the records in MAST with an 'A' in column 1. They are reformatted by the INREC statement as 33 byte records that look like this:
       C0000    F00KRS      G000B
       C1111    F11FLY      G111B

We put a 'B' in position 33 to identify these records as base records.

The overlay records are the records in MAST with an 'H' in column 1. They are reformatted by the INREC statement as 33 bytes records that look like this:
I000002     K002   KRSH02L02    V
I000003     K003   FLYH03L03    V
I000004     K004   VQXH04L04    V
I000005     K005   FLYH05L05    V
I000006     K006   KHNH06L06    V
I000007     K007   KRSH07L07    V
I000008     K008   FLYH08L08    V
I000009     K009   KHNH09L09    V

We put a 'V' in position 33 to identify these records as overlay records.

The base and overlay records set up by the INREC statement are sorted and spliced.

The records look like this after they are sorted on the 20,3,CH field, but before they are spliced. As a visual aid, the WITH fields in the overlay records are shown in bold.
       C1111    F11FLY      G111B
I000003     K003   FLYH03L03    V
I000005     K005   FLYH05L05    V
I000008     K008   FLYH08L08    V
I000006     K006   KHNH06L06    V
I000009     K009   KHNH09L09    V
       C0000    F00KRS      G000B
I000002     K002   KRSH02L02    V
I000007     K007   KRSH07L07    V
I000004     K004   VQXH04L04    V
The spliced output records are 33 bytes long and look like this:
I000003C1111K003F11FLYH03L03G111B
I000005C1111K005F11FLYH05L05G111B
I000008C1111K008F11FLYH08L08G111B
I000009     K009   KHNH09L09    V
I000002C0000K002F00KRSH02L02G000B
I000007C0000K007F00KRSH07L07G000B

Note that the base record (type A) for FLY has been spliced together with each of the three overlay records (type H) for FLY. Likewise, the base record (type A) for KRS has been spliced together with each of the two overlay records (type H) for KRS.

But also note that the overlay records (type H) for KHN have been spliced together. Because KHN does not appear as a base record (type A) we don't want the KHN records to appear in the OUT data set. So we will use the 'V' we put in position 33 for the overlay records to identify and delete spliced overlay records without a matching base record. We only have to do this if we have duplicate overlay records without a matching base record. Single overlay records without a matching base record will be deleted automatically (unless you specify KEEPNODUPS).

After we eliminate the spliced overlay records and the position 33 indicator, the OUT records are 32 bytes long and look like this:
I000003C1111K003F11FLYH03L03G111
I000005C1111K005F11FLYH05L05G111
I000008C1111K008F11FLYH08L08G111
I000002C0000K002F00KRSH02L02G000
I000007C0000K007F00KRSH07L07G000
Note that if we had not specified WITHALL, only the first and last records for each set of duplicates would have been spliced, producing the following output:
I000008C1111K008F11FLYH08L08G111
I000007C0000K007F00KRSH07L07G000

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014