6.2.34.1 ASCENDING/DESCENDING KEY Phrase
This phrase specifies that records are to be processed in ascending or
descending sequence (depending on the phrase specified), based on the
specified sort keys.
-
data-name-1
-
Specifies a KEY data item on which the SORT statement will be based.
Each such data-name must identify a data item in a record associated
with file-name-1. The data-names following the word KEY are listed
from left to right in the SORT statement in order of decreasing
significance without regard to how they are divided into KEY phrases.
The left-most data-name is the major key, the next data-name is the
next most significant key, and so forth. The following rules apply:
- A specific KEY data item must be physically located in the same
position and have the same data format in each input file.
However, it need not have the same data-name.
- If file-name-1 has more than one record description, then the KEY
data items need be described in only one of the record
descriptions.
- If file-name-1 contains variable-length records, all of the KEY
data-items must be contained within the first n character
positions of the record, where n equals the minimum records size
specified for file-name-1.
- KEY data items must not contain an OCCURS clause or be subordinate
to an item that contains an OCCURS clause.
- KEY data items can be qualified.
- KEY data items cannot be group items that contain variable
occurrence data items.
- X KEY data items can be floating-point items.
- X KEY data items cannot be variably-located.
- X >_Workstation_> Under AIX, OS/2, and Windows, KEY data items
X cannot be windowed date fields. <_Workstation_<
X >_Host_> Under OS/390 and VM, KEY data items can be windowed date
X fields, under these conditions:
- X The GIVING phrase must not specify an indexed file, because
X the (binary) ordering assumed or imposed by the file system
X conflicts with the windowed date ordering provided in the sort
X output. Attempting to write the windowed date merge output to
X such an indexed file will either fail or re-impose binary
X ordering, depending on how the file is accessed (the ACCESS
X MODE in the file-control entry).
- X If an alphanumeric windowed date field is specified as a KEY
X for a SORT statement, the collating sequence in effect for the
X merge operation must be EBCDIC. Thus the COLLATING SEQUENCE
X phrase of the SORT statement or, if this phrase is not
X specified, then any PROGRAM COLLATING SEQUENCE clause in the
X OBJECT-COMPUTER paragraph, must not specify a collating
X sequence other than EBCDIC or NATIVE.
X If the SORT statement meets these conditions, then the sort
X operation takes advantage of SORT Year 2000 features, assuming
X that the execution environment includes a sort product that
X supports century windowing.
| A year-last windowed date field can be specified as a KEY for a
| SORT statement, and can thereby exploit the corresponding century
| windowing capability of the sort product.
X For more information on using windowed date fields as KEY data
X items, see the IBM COBOL Programming Guide for your platform.
X <_Host_<
If file-name-3 references an indexed file, the first specification of
data-name-1 must be associated with an ASCENDING phrase and the data item
referenced by that data-name-1 must occupy the same character positions in
this record as the data item associated with the major record key for that
file.
The direction of the sorting operation depends on the specification of the
ASCENDING or DESCENDING key words as follows:
- When ASCENDING is specified, the sequence is from the lowest key value
to the highest key value.
- When DESCENDING is specified, the sequence is from the highest key
value to the lowest.
- If the KEY data item is alphabetic, alphanumeric, alphanumeric-edited,
or numeric-edited, the sequence of key values depends on the collating
sequence used (see "COLLATING SEQUENCE Phrase" in topic 6.2.34.3).
- X >_Host_> Under OS/390 and VM, if the KEY is a DBCS item, the sequence
X of the KEY values is based on the binary collating sequence of the
X hexadecimal values of the DBCS characters. <_Host_<
- X >_Workstation_> Under AIX, OS/2, and Windows, if the KEY is a DBCS
X item, then the sequence of the KEY values is based on a collation
X sequence according to the COLLSEQ compiler option:
X <_Workstation_<
- X If the KEY is an external floating-point item, the compiler will treat
X the data item as character data, rather than numeric data. The
X sequence in which the records are sorted depends on the collating
X sequence used.
- X If the KEY data item is internal floating-point, the sequence of key
X values will be in numeric order.
- The key comparisons are performed according to the rules for
comparison of operands in a relation condition (see "Relation
Condition" under "Conditional Expressions" in topic 6.1.6).
© Copyright IBM Corp. 1991, 1998
IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.
Return to library:
z/OS |
z/OS.e |
TPF |
z/VSE |
z/VM |
IBM Hardware |
IBM System z Redbooks
Glossary:
IBM terminology
Publications:
How to order publications
Readers:
Download IBM Library Reader |
Download IBM Softcopy Reader |
Download Adobe® Acrobat® Reader®
Library management:
Download IBM Softcopy Librarian
Contacts:
Contact z/OS
Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks
of Adobe Systems incorporated.