Software AG Products 2.4.1 | Reference Guide | Execution Commands | Detailed Syntax | @SORT
 
@SORT
The @SORT command sorts an ISN list created using the @FIND or @COMPARE commands. Two types of sorting are available:
*In ascending ISN sequence.
*In the order of the values of a user-specified descriptor or descriptors (de1-de3). This may done in descending sequence by specifying the DESCENDING keyword.
The syntax of the command is as follows:
syntax of sort
The result of the command is a sorted ISN list in the ISN buffer and on the WORK data set, and also the reading of the first record.
The ISN list to be sorted should be stored on the WORK data set referenced by COMMAND-IDxxxx, where xxxx is the identification of the command that created the list with the SAVE option.
In the following example, records are found according to the selection criteria defined in @ADADCL6. The records are then sorted in descending order of PERSONNELID and then read. The records are in accordance with the logical record definition in @ADADCL7.
Note that @ADADCL6 specifies only the search-criteria and not the field-expression. @ADADCL7 only specifies the field-expressions.
@FIND6 SAVE.
@SORT7 BY PERSONNEL-ID DESCENDING COMMAND-ID6.
PERFORM READING UNTIL EOF7.
.
.
.
READING.
.
.
.
@READNEXT7.
The SAVE option causes the entire ISN list created by the command to be stored on the WORK data set.
If the file is protected, the PASSWORD parameter should be used.
If the file is ciphered, the CIPHER parameter should be used.
Note that the first record is read automatically by the command and the EOF indication is turned on in case of no resulting ISNs or the end of the ISN list is reached. The remaining records may be read by the @READNEXT command. In case of a need to hold the first record, the NOREAD option should be used followed by the @READNEXT HOLD statement.
The NOREAD option causes the command to be executed without reading the first record. This record will be read during the execution of the first @READNEXT command.
The GETNEXT option causes Adabas Pre-Compiler to generate code to work with the Adabas GETNEXT option. In this case, the ISN buffer is not used, and the user may use PREFETCH and SECURITY BY VALUE.