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


Example 6

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

  SELECT FROM(MASTPULL) TO(MATCH) ON(5,8,CH) FIRSTDUP

This example shows how you can use a list of account numbers in a "pull" data set to only select records with those account numbers from a "master" data set. The MASTPULL DD would have the "master" data set and "pull" data set concatenated together (in that order).

The SELECT operator sorts the concatenated data sets and selects only the first record of those with characters in positions 5-12 that occur more than once (that is, one record for each duplicate ON field value). Because the "master" data set is first in the concatenation, the selected records will come from the "master" data set.

If the "master" data set looked like this:
A52 RB172832 2001/03/15
N92 MX328126 2001/01/27
B12 LB018725 2000/12/28
J73 AB007231 2001/02/13
Q28 SP973004 2000/11/19
and the "pull" data set looked like this:
   AB007231
   RS859276
   QN005001
   MX328126
the MATCH data set would look like this:
J73 AB007231 2001/02/13
N92 MX328126 2001/01/27
   
Note: This example assumes that there are not any duplicate account numbers in either the "master" or "pull" data sets. If that is not true, you can use SELECT with FIRST or LAST, for the appropriate data set, to make it true. For example, if your "master" data set has duplicate account numbers and you want to select the first account number from the "master" data set for each account number in the "pull" data set, you could use the following statements:
  SELECT FROM(MASTER) TO(TEMP) ON(5,8,CH) FIRST
  SELECT FROM(TEMPPULL) TO(MATCH) ON(5,8,CH) FIRSTDUP
    

The TEMPPULL DD would have the temporary data set and "pull" data set concatenated together (in that order).

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014