ASCENDING/DESCENDING KEY Phrase

Data is arranged in ascending or descending order (depending on the keyword specified) according to the values contained in data-name-2. The data-names are listed in their descending order of significance.

Read syntax diagramSkip visual syntax diagram
ASCENDING/DESCENDING KEY Phrase - Format

   .------------------------------------------------------.   
   |                                      .-------------. |   
   V             (1)                      V             | |   
>>---+-ASCENDING------+--+-----+--+----+----data-name-2-+-+----><
     |            (1) |  '-KEY-'  '-IS-'                      
     '-DESCENDING-----'                                       

Notes:
  1. Cannot be used with boolean data type
The order is determined by the rules for comparison of operands (see Relation Condition). The ASCENDING and DESCENDING KEY data items are used in OCCURS clauses and the SEARCH ALL statement for a binary search of the table element.
data-name-2
Must be the name of the subject entry, or the name of an entry subordinate to the subject entry.

If data-name-2 names the subject entry, that entire entry becomes the ASCENDING/DESCENDING KEY, and is the only key that may be specified for this table element.

If data-name-2 does not name the subject entry, then data-name-2:
  • Must be subordinate to the subject of the table entry itself
  • Must not be subordinate to, or follow, any other entry that contains an OCCURS clause
  • Must not contain an OCCURS clause