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


Example 9 - Create a report showing if needed parts are on-hand - advanced

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

This example is a more complex variation of Example 8 - Create a report showing if needed parts are on-hand. It shows how you can use the WITHALL, KEEPBASE, and KEEPNODUPS operands to tell ICETOOL to compare the ON fields in a list of needed parts to the ON fields in a list of on-hand parts, and produce a report showing if each needed part is on-hand or not. However, it also has duplicate parts in the NEEDED data set, and produces a report with more information from the ONHAND and NEEDED records.

//S9       EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//ONHAND DD *
P62 Blue           Dallas
G73 Blue           San Jose
A27 Green          Vancouver
/*
//NEEDED DD *
 Rachel       A27 Green       Phoenix
 Monica       P62 Blue        Phoenix
 Phoebe       A27 Blue        Toronto
 Chandler     M92 Yellow      Los Angeles
 Joey         M92 Yellow      Paris
 Ross         A27 Green       Paris
/*
//COMBINED DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//TEMP1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//RPT  DD SYSOUT=*
//TOOLIN   DD *
* Reformat the ONHAND records for splicing.
* Add 'Yes' for found and 'D' for delete record.
  COPY FROM(ONHAND) TO(COMBINED) USING(CTL1)
* Reformat the NEEDED records for splicing.
* Add 'No' for missing and 'K' for keep record.
  COPY FROM(NEEDED) TO(COMBINED) USING(CTL2)
* Splice ONHAND and NEEDED records.
* Splice in Requested by, Ship to and id fields.
* Eliminate spliced records with 'D'.
  SPLICE FROM(COMBINED) TO(TEMP1) -
    ON(1,12,CH) WITHALL KEEPBASE KEEPNODUPS USING(CTL3) -
    WITH(24,10) WITH(53,13) WITH(66,1)
* Print report.
  DISPLAY FROM(TEMP1) LIST(RPT) -
   INDENT(2) BETWEEN(2) BLANK -
   HEADER('Part') ON(1,12,CH) -
   HEADER('On-Hand') ON(15,3,CH) -
   HEADER('Requested by') ON(24,12,CH) -
   HEADER('Ship from') ON(38,13,CH) -
   HEADER('Ship to') ON(53,13,CH)
/*
//CTL1CNTL DD *
* Reformat ONHAND records with Part in 1-12, 'Yes' for found in
* 15-17, From City in 38-50 and 'D' in 66.
  OUTREC FIELDS=(1:1,12,15:C'Yes',38:20,13,66:C'D')
/*
//CTL2CNTL DD *
* Reformat NEEDED records with Part in 1-12, 'No  ' for missing in
* 15-17, Requester Name in 24-35, 'n/a' for From City in 38-40,
* To City in 53-65 and 'K' in 66.
  OUTREC FIELDS=(1:15,12,15:C'No ',24:2,10,38:C'n/a',
                  53:31,13,66:C'K')
/*
//CTL3CNTL DD *
* Eliminate ONHAND parts that do not appear in NEEDED list.
  OUTFIL FNAMES=TEMP1,OMIT=(66,1,CH,EQ,C'D')
/*
The base records originate from the ONHAND data set. They are copied and reformatted to the COMBINED data set. The reformatted records look like this:
P62 Blue      Yes                    Dallas                      D
G73 Blue      Yes                    San Jose                    D
A27 Green     Yes                    Vancouver                   D
The overlay records originate from the NEEDED data set and are copied and reformatted to the COMBINED data set. The reformatted records look like this
A27 Green     No       Rachel        n/a            Phoenix      K
P62 Blue      No       Monica        n/a            Phoenix      K
A27 Blue      No       Phoebe        n/a            Toronto      K
M92 Yellow    No       Chandler      n/a            Los Angeles  K
M92 Yellow    No       Joey          n/a            Paris        K
A27 Green     No       Ross          n/a            Paris        K

The base and overlay records from the COMBINED data set are sorted and spliced.

However, we need to make sure that all parts which appear in more than one NEEDED record, but do not appear in the ONHAND list, will appear in the report. For example, we have two M92 Yellow parts in the NEEDED data set that do not appear in the ONHAND data set. These two records are reformatted and appear in the COMBINED data set as follows:
M92 Yellow    No       Chandler      n/a            Los Angeles  K
M92 Yellow    No       Joey          n/a            Paris        K
ICETOOL would normally treat the first record as the base record and the second record as the overlay record. As a result, these two records would be spliced together into one record instead of two. To prevent this, and ensure that we keep both M92 Yellow parts, we must specify KEEPBASE. As a result, two records are kept: the unchanged first M92 Yellow record, and the spliced first and second M92 Yellow records (which in this case looks identical to the unspliced second record).
The records look like this after they are sorted on the 1,12,CH field, but before they are spliced. As a visual aid, the WITH fields in the overlay records are shown in bold.:
A27 Blue      No       Phoebe        n/a            Toronto      K
A27 Green     Yes                    Vancouver                   D
A27 Green     No       Rachel        n/a            Phoenix      K
A27 Green     No       Ross          n/a            Paris        K
G73 Blue      Yes                    San Jose                    D
M92 Yellow    No       Chandler      n/a            Los Angeles  K
M92 Yellow    No       Joey          n/a            Paris        K
P62 Blue      Yes                    Dallas                      D
P62 Blue      No       Monica        n/a            Phoenix      K
The spliced records look like this:
A27 Blue      No       Phoebe        n/a            Toronto      K
A27 Green     Yes                    Vancouver                   D
A27 Green     Yes      Rachel        Vancouver      Phoenix      K
A27 Green     Yes      Ross          Vancouver      Paris        K
G73 Blue      Yes                    San Jose                    D
M92 Yellow    No       Chandler      n/a            Los Angeles  K
M92 Yellow    No       Joey          n/a            Paris        K
P62 Blue      Yes                    Dallas                      D
P62 Blue      Yes      Monica        Dallas         Phoenix      K
Records with 'D' are not needed, so we use the OUTFIL statement for SPLICE to omit them. The TEMP1 records look like this:
A27 Blue      No       Phoebe        n/a            Toronto      K
A27 Green     Yes      Rachel        Vancouver      Phoenix      K
A27 Green     Yes      Ross          Vancouver      Paris        K
M92 Yellow    No       Chandler      n/a            Los Angeles  K
M92 Yellow    No       Joey          n/a            Paris        K
P62 Blue      Yes      Monica        Dallas         Phoenix      K
Although we could have used the OUTFIL statement for SPLICE to print the report, we've chosen instead to use a separate DISPLAY operator. DISPLAY requires an extra pass over the spliced records in TEMP1, but is easier to use than OUTFIL for reports. The resulting RPT data set looks like this:
  Part          On-Hand  Requested by  Ship from      Ship to
  ------------  -------  ------------  -------------  -------------
  A27 Blue      No       Phoebe        n/a            Toronto
  A27 Green     Yes      Rachel        Vancouver      Phoenix
  A27 Green     Yes      Ross          Vancouver      Paris
  M92 Yellow    No       Chandler      n/a            Los Angeles
  M92 Yellow    No       Joey          n/a            Paris
  P62 Blue      Yes      Monica        Dallas         Phoenix

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014