ASCEND

The ASCEND keyword is used to describe the sequence of the data in any of the following:
  • An array
  • A table loaded at prerun-time or compile time
  • A prototyped parameter

See also DESCEND.

Ascending sequence means that the array or table entries must start with the lowest data entry (according to the collating sequence) and go to the highest. Items with equal value are allowed.

A prerun-time array or table is checked for the specified sequence at the time the array or table is loaded with data. If the array or table is out of sequence, control passes to the RPG IV exception/error handling routine. A run-time array (loaded by input and/or calculation specifications) is not sequence checked.

If there is insufficient data in the file to load a pre-run array or table, and the array or table is defined with the ASCEND keyword, an error with status code 1041 will be issued during the initialization of the RPG module if the elements at the end of the array have lower values than the elements loaded from the file.

When ALTSEQ(*EXT) is specified, the alternate collating sequence is used when checking the sequence of compile-time arrays or tables. If the alternate sequence is not known until run-time, the sequence is checked at run-time; if the array or table is out of sequence, control passes to the RPG IV exception/error handling routine.

A sequence (ascending or descending) must be specified if the LOOKUP operation, %LOOKUPxx built-in, or %TLOOKUPxx built-in is used to search an array or table for an entry to determine whether the entry is high or low compared to the search argument.

If the SORTA operation code is used with an array, and no sequence is specified, an ascending sequence is assumed.