The SORT control statement must be used when a sorting application
is performed; this statement describes the control fields in the input
records on which the program sorts. A SORT statement can also be used
to specify a copy application. User labels will not be copied to the
output data sets.
The way in which DFSORT processes short SORT control fields depends
on the setting for VLSHRT/NOVLSHRT. A short field is one where the
variable-length record is too short to contain the entire field, that
is, the field extends beyond the record. For details about sorting
short records, see the discussion of the VLSHRT and NOVLSHRT options
in OPTION control statement.
The options available on the SORT statement can be specified in
other sources as well. A table showing all possible sources for these
options and the order of override is given in Specification/override of DFSORT options.
When an option can be specified on either the SORT or OPTION statement,
it is preferable to specify it on the OPTION statement.
DFSORT accepts but does not process the following SORT operands:
WORK=value and ORDER=value.
DFSORT's collating behavior can be modified according to your cultural
environment. The cultural environment is established by selecting
the active locale. The active locale's collating rules affect SORT
processing as follows:
DFSORT produces sorted records for output according to the collating
rules defined in the active locale. This provides sorting for single-
or multi-byte character data, based on defined collating rules that
retain the cultural and local characteristics of a language.
If locale processing is to be used, the active locale will only
be used to process character (CH) control fields.
DFSORT's Unicode collation behavior can be modified according to your cultural environment. The cultural environment is established by selecting the active collation version. The active collation version rules affects SORT processing as follows:
DFSORT produces sorted records for output according to the collating version rules defined in the active collation version. This provides sorting for single-or multi-byte character data based on defined collating version rules that retain the cultural and local characteristics of a language.
Requires four facts about each control field in the input
records: the position of the field within the record, the length of the field, the format of the
data in the field, and the sequence into which the field is to be sorted. These facts are
communicated to DFSORT by the values of the FIELDS operand, represented by p, m, f, and s.
The value for f can optionally be specified by the FORMAT=f parameter as explained later in this
section.
All control fields must be located within the first 32752 bytes
of a record.
The maximum length of the collected control fields for which Blockset can be used
is 4088 bytes. However, the maximum length can be less than 4088 for various situations, such as the
use of certain formats (for example, PD), the EQUALS option, and so on. If this maximum is exceeded,
Blockset cannot be used.
The FIELDS operand can be written in two ways.
The program
examines the major control field first, and it must be specified first. The minor control fields are
specified following the major control field. p, m, f, and s describe the control fields. The text
that follows gives specifications in detail.
p
specifies the first byte of a control field relative to the beginning of the input record. 1
The first data byte of a fixed-length record has relative
position 1. The first data byte of a variable-length record has relative position 5. The first 4
bytes contain the record descriptor word. All control fields, except binary, must begin on a byte
boundary. The first byte of a floating-point field is interpreted as a signed exponent; the rest of
the field is interpreted as the fraction.
Fields containing binary values are described in a
bytes.bits notation as follows:
First, specify the byte location relative to the beginning of the record and follow it with a
period.
Then, specify the bit location relative to the beginning of that byte. Remember that the first
(high-order) bit of a byte is bit 0 (not bit 1); the remaining bits are numbered 1 through 7.
Thus, 1.0 represents the beginning of a record. A binary field beginning on the third
bit of the third byte of a record is represented as 3.2. When the beginning of a binary field falls
on a byte boundary (say, for example, on the fourth byte), you can write it in one of three ways:
4.0
4.
4
Other examples of this notation are shown in Figure 1:
m
specifies the length of the control field. Values for all control fields except binary fields
must be expressed in integer numbers of bytes. Binary fields can be expressed in the notation
“bytes.bits”. The length of a binary control field that is an integer value (d) can be expressed in
one of three ways:
d.0
d.
d
The number of bits specified must not
exceed 7. A control field 2 bits long would be represented as 0.2.
The total number of bytes
occupied by all control fields must not exceed 4092 (or, when the EQUALS option is in operation,
4088 bytes). When you determine the total, count a binary field as occupying an entire byte if it
occupies any part of it. For example, a binary field that begins on byte 2.6 and is 3 bits long
occupies two bytes. All fields must be completely contained within the first 32752 bytes of the
record.
f
specifies the format of the data in the control field. Acceptable control field lengths (in
bytes) and available formats are shown in Table 1.
AUF, ASF, CSF, FS, UFF, SFF, Y2 and PD0 format fields can only be used if
Blockset is selected.
For Y2 format fields, real dates are collated using the century window
established by the Y2PAST option in effect, but the century window is not used for special
indicators. Thus the Y2 formats will collate real dates and special indicators as follows:
Y2T and Y2W:
Ascending:
BI zeros, blanks, CH/ZD zeros, lower century dates (for example, 19yy), upper century dates (for
example, 20yy), CH/ZD nines, BI ones.
Descending:
BI ones, CH/ZD nines, upper century dates (for example, 20yy), lower century dates (for example,
19yy), CH/ZD zeros, blanks, BI zeros.
Y2U, Y2V, Y2X and Y2Y:
Ascending:
PD zeros, lower century dates (for example, 19yy), upper century dates (for example, 20yy), PD
nines.
Descending:
PD nines, upper century dates (for example, 20yy), lower century dates (for example, 19yy), PD
zeros.
Y2C, Y2Z, Y2P, Y2D and Y2B:
Ascending:
Lower century years (for example, 19yy), upper century years (for example, 20yy).
Descending:
Upper century years (for example, 20yy), lower century years (for example, 19yy).
Y2S:
Ascending:
BI zeros, blanks, lower century years (for example, 19yy), upper century years (for example,
20yy), BI ones.
Descending:
BI ones, upper century years (for example, 20yy), lower century years (for example, 19yy),
blanks, BI zeros.
The AC format sequences EBCDIC data using the ASCII collating sequence shown in
Appendix D. For example, if AC is used with ascending sequence, the EBCDIC numbers (0-9) will
collate before the EBCDIC uppercase letters (A-Z) which in turn will collate before the EBCDIC
lowercase letters (a-z).
You can use p,m,s rather than p,m,f,s if you use FORMAT=f to supply
the format for the field, as described later in this section.
All floating-point data must be normalized before the program can collate it
properly. You can use an E15 or E61 user exit to do this during processing. If you use E61, specify
the E option for the value of s in the FIELDS operand for each control field you are going to modify
with this user exit.
s
specifies how the control field is to be ordered. The valid codes are:
A
ascending order
D
descending order
E
control fields to be modified
Specify E if you include an E61 user exit to modify control fields before the program sorts
them. After an E61 user exit modifies the control fields, DFSORT collates the records in ascending
order using the formats specified. 3
FORMAT=f can be used to specify a particular format
for one or more control fields. f from FORMAT=f is used for p,m,s
fields. f from FORMAT=f is ignored for p,m,f,s fields. For example,
the following are all equivalent:
The
permissible field formats are shown under the description of 'f' for
fields.
If you have specified the COPY operand, FORMAT=f cannot
be specified.
Default: None; FORMAT=f must be specified
if any field is specified as p,m,s rather than p,m,f,s. See Specification/override of DFSORT options for full override details.
Note: CENTURY=value and CENTWIN=value
can be used instead of Y2PAST=value.
1 If INREC is specified, p must refer to the record as reformatted by INREC. If your E15
user exit reformats the record, and INREC is not specified, p must refer to the record as
reformatted by your E15 user exit.
3 With a conventional merge or a tape work data set sort, control fields for which E
is specified are treated as binary byte format regardless of the actual formats
specified.