× Home About AS400 Files on AS400 Bit Operations Compile Commands EBCDIC Table Edit Codes Message Subfile Reg. Expressions Sort Contact us


RPG - LANGUAGE

Sort




ARRAY SORT: The ARRAY SORT operation code - SORTA - in RPG sorts an array into ascending or descending sequence. The ASCEND or DESCEND keyword is specified with the array definition on the D specification. If neither is specified, ASCEND is assumed. SORTA can be specified in both fixed and free form specifications. SORTA takes one parameter - the name of the array to be sorted or %SUBARR. All the array elements are sorted with SORTA.
Alternatively, %SUBARR can be specified with SORTA to specify a subset of elements in an array. The elements specified in %SUBARR must be contiguous.
Documentation is available from the IBM Knowledge Center on this link

DDS KEY SORT: In physical and logical files, the records can be read in a key sequence by specifying one or more key fields. The default is for the records to be in ascending sequence. The DESCEND keyword puts the records in the opposite sequence. There is no ascend keyword. When using a signed numeric field as a key field with the DESCEND keyword, negative numbers are equivalent to positive numbers unless the SIGNED keyword is also specified. Select and omit parameters can be specified on a logical file to filter records.
Documentation is available from the IBM Knowledge Center on this link

OPNQRYF: allows you to select and join records from a number of files, members and record formats. You can sort, group and sum records. While this is similar to what you can do with SQL, OPNQRYF creates a data path of its own which exists as an independent entity.
Documentation is available from the IBM Knowledge Center on this link

QLGSORT API: will sort data from one or more input files or input buffers into one or more output files. This is really a C api, but can be coded within RPG.
Documentation is available from the IBM Knowledge Center on this link

QSORT API: will sort an array into ascending or descending sequence. This is really a C api, but can be coded within RPG.
Documentation is available from the IBM Knowledge Center on this link

SORT: Sort Specifications are used to sort one or more input files into one output file. The specifications are keyed into a source member and processed by the FMTDTA command. These specifications use from and to positions - they do not connect to the external specifications (if any) of a physical file.
Documentation is available from the IBM Knowledge Center on this link

SORT SEQUENCE: Also known as ALTERNATE COLLATING SEQUENCE, this determines the sequence of characters, numbers, etc. for example, B follows A, C follows B. One reason to change sequence is to ensure that upper case characters are sorted alongside lower case characters i.e. AaBbCc... instead of ABC... abc.
Documentation is available from the IBM Knowledge Center on this link

SQL: There are a number of ways to order or sort data in SQL. The first is to use the ORDER BY clasue in the SELECT statement. CREATE VIEW and CREATE INDEX to set up data sequences which lie between the databvas eand any SELCT statements.<
Documentation is available from the IBM Knowledge Center on this link

SUBFILE SORT: This source member illustrates how to use a physical file with RPG-ile to sort records in a subfile. This is a bare-bones example - only the RPG source statements are given. The included documentation is comprehensive. It is useful for those who do not wish to use the QSORT api. Although is is designed for subfile records, it can be changed to sort arrays.
Use this link to download the source member as a text file

USER INDEX: A USER INDEX is an index which exists as a stand-alone object type *USRIDX. It is an ordered list which is maintained through a set of API's. Compared with a database file, a user index is faster for searching large sets of simple lookup data such as a list of abbreviations or a telephone directory.
Documentation is available from the IBM Knowledge Center on this link





You can email us here or use the Contact Us menu tab.




a mckaysoftware website