z/OS DFSORT: Getting Started
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Splitting

z/OS DFSORT: Getting Started
SC23-6880-00

Suppose you don't know how many records are in a data set, but you want to divide the records as equally as possible between two output data sets. You can use OUTFIL's SPLIT parameter to put the first record into OUTPUT1, the second record into OUTPUT2, the third record into OUTPUT1, the fourth record into OUTPUT2, and so on until you run out of records. SPLIT splits the records one at a time among the data sets specified by FNAMES. The following statements split the records between two OUTFIL data sets:
  OPTION COPY
  OUTFIL FNAMES=(OUTPUT1,OUTPUT2),SPLIT
With 17 input records, the results produced for OUTPUT1 are:
Record 01
Record 03
Record 05
Record 07
Record 09
Record 11
Record 13
Record 15
Record 17
The results produced for OUTPUT2 are:
Record 02
Record 04
Record 06
Record 08
Record 10
Record 12
Record 14
Record 16
Similarly, OUTFIL's SPLITBY=n parameter splits the records n at a time among the data sets specified by FNAMES. The following statements split the records four at a time between three OUTFIL data sets:
  OPTION COPY
  OUTFIL FNAMES=(OUT1,OUT2,OUT3),SPLITBY=4
With 17 input records, the results produced for OUT1 are:
Record 01
Record 02
Record 03
Record 04
Record 13
Record 14
Record 15
Record 16
The results produced for OUT2 are:
Record 05
Record 06
Record 07
Record 08
Record 17
The results produced for OUT3 are:
Record 09
Record 10
Record 11
Record 12

SPLIT and SPLITBY=n both start over with the first ddname after writing records to the last ddname. This can give you non-contiguous records in one or more of the OUTFIL data sets. For example, in the previous example with SPLITBY=4, OUT1 has records 1-4 and 13-16. If instead, you only want contiguous records in each OUTFIL data set, you can use OUTFIL's SPLIT1R=n parameter which writes n records to each OUTFIL data set and then writes the remaining records to the last OUTFIL data set. Thus, whereas SPLIT and SPLITBY=n rotate many times among the OUTFIL data sets, SPLIT1R=n only rotates once among the OUTFIL data sets.

The following statements ensure that the records are split with only contiguous records in each OUTFIL data set:
   OPTION COPY
   OUTFIL FNAMES=(OUTA,OUTB,OUTC),SPLIT1R=5 
With 17 input records, the results produced for OUTA are:
Record 01 
Record 02 
Record 03 
Record 04 
Record 05
The results produced for OUTB are:
Record 06 
Record 07 
Record 08 
Record 09 
Record 10
The results produced for OUTC are:
Record 11 
Record 12 
Record 13 
Record 14 
Record 15 
Record 16 
Record 17
So far
So far, you have learned how to create multiple identical copies of an input data set; select and sample input records by relative record number for output; include, omit or save selected input records for output; and reformat, repeat and split input records for output. Next, you will learn about creating various types of reports.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014