|
You can use ICETOOL's SORT operator to create sorted
output data
sets. A single SORT operator can be used to create one output data
set or up to 10 identical output data sets. Using INCLUDE or OMIT
statements, you can select a subset of the input records. Using INREC
or OUTREC statements, you can rearrange the fields of the input records.
Using OUTFIL statements, you can create any number of output data
sets with different subsets of records or arrangements of fields.
For
this example, we will use both the sample bookstore data set
(SORT.SAMPIN) and the additional bookstore data set (SORT.SAMPADD)
as input.
A SORT operator that selects the books from publishers
VALD and
WETH, sorts them by publisher and title, and writes them to disk and
print data sets, looks like this:
Here are the steps for writing
this SORT operator:
Table 1. Steps to Create
the SORT OperatorStep |
Action |
---|
1 |
Write a comment statement (optional):
* Books from VALD and WETH
|
2 |
Type SORT after the comment
statement |
3 |
Leave at least one blank and type FROM(BKS) BKS
specifies the ddname for the input data sets you want to sort.
|
4 |
Leave at least one blank and type TO(DAPUBS,PRPUBS) TO
specifies the ddnames for the output data sets to contain the sorted
subset of records. You can create up to 10 identical output data
sets of any type that DFSORT allows (permanent, temporary, disk, tape,
print, etc).
In this case, DAPUBS is the ddname chosen for
the temporary disk data set and PRPUBS is the ddname chosen for the
print data set. You can use any valid 1-8 character ddnames you like.
ICETOOL
will automatically use OUTFIL to create both output data sets from
a single pass over the input data set.
|
5 |
Leave
at least one blank and type USING(SPUB) USING
specifies the first four characters of the ddname for the data set
containing the DFSORT control statements. In this case, the four
characters chosen are SPUB, but you can use any four characters you
like as long as they are valid for a ddname. The last four characters
of the ddname are always CNTL, so in this case the full ddname is
SPUBCNTL.
For the SORT operator, you must specify a SORT control
statement in the DFSORT control statement data set (SPUBCNTL) in order
to tell DFSORT how to sort the input data set. You can also specify
additional DFSORT control statements, like INCLUDE, OMIT, INREC, OUTREC
and OUTFIL, as appropriate.
|
To write the JCL statements that go with the SORT operator:
Table 2. Steps to Create
JCL Statements for the SORT OperatorStep |
Action |
---|
1 |
Write DD statements for the input
data sets and place them at the end of the job. In order to "concatenate"
the two input data sets together, you must leave the ddname field
blank in the second DD statement: //BKS DD DSN=A123456.SORT.SAMPIN,DISP=SHR
// DD DSN=A123456.SORT.SAMPADD,DISP=SHR
|
2 |
Write DD statements for the disk
and print output data sets and place them at the end of the job:
//DAPUBS DD DSN=&&DSRT,DISP=(,PASS),SPACE=(CYL,(2,2)),UNIT=SYSDA
//PRPUBS DD SYSOUT=A
|
3 |
Write a DD
statement for the DFSORT
control statement data set and place it at the end of the job:
//SPUBCNTL DD *
|
4 |
Write
the SORT control statement
to sort the input data sets by publisher and title, and the INCLUDE
statement to select only the books by publishers VALD and WETH, and
place them after the SPUBCNTL statement: SORT FIELDS=(106,4,A,1,75,A),FORMAT=CH
INCLUDE COND=(106,4,EQ,C'VALD',OR,106,4,EQ,C'WETH'),
FORMAT=CH
|
When complete, the TOOLIN statements and DD statements for this
SORT operator look like this:
* Books from VALD and WETH
SORT FROM(BKS) TO(DAPUBS,PRPUBS) USING(SPUB)
/*
//BKS DD DSN=A123456.SORT.SAMPIN,DISP=SHR
// DD DSN=A123456.SORT.SAMPADD,DISP=SHR
//DAPUBS DD DSN=&&DSRT,DISP=(,PASS),SPACE=(CYL,(2,2)),UNIT=SYSDA
//PRPUBS DD SYSOUT=A
//SPUBCNTL DD *
SORT FIELDS=(106,4,A,1,75,A),FORMAT=CH
INCLUDE COND=(106,4,EQ,C'VALD',OR,106,4,EQ,C'WETH'),
FORMAT=CH
/*
Tip: Instead of writing the previous INCLUDE
statement using two conditions joined by OR, you could write it with
one condition using INCLUDE's substring search feature, as you learned
in Substring search for INCLUDE and OMIT, like this: INCLUDE COND=(106,4,SS,EQ,C'VALD,WETH')
Table 3 shows the Book Title and Publisher
fields for the records as they would appear in the resulting output
data sets. The actual records contain all of the fields.
Table 3. Books
from publishers VALD and WETHBook
Title |
Publisher |
---|
1 75
|
106 109
|
CELLS AND HOW THEY WORK
COMPLETE SPANISH DICTIONARY
EDITING SOFTWARE MANUALS
FREUD'S THEORIES
INTRODUCTION TO BIOLOGY
NOVEL IDEAS
SHORT STORIES AND TALL TALES
STRATEGIC MARKETING
VIDEO GAME DESIGN
ZEN BUSINESS
ANTICIPATING THE MARKET
CIVILIZATION SINCE ROME FELL
COMPUTERS: AN INTRODUCTION
EIGHTEENTH CENTURY EUROPE
GUIDE TO COLLEGE LIFE
GUNTHER'S GERMAN DICTIONARY
REBIRTH FROM ITALY
SYSTEM PROGRAMMING
THE INDUSTRIAL REVOLUTION
|
VALD
VALD
VALD
VALD
VALD
VALD
VALD
VALD
VALD
VALD
WETH
WETH
WETH
WETH
WETH
WETH
WETH
WETH
WETH
|
|