Specifying the sorting field

This topic describes the required PL/I statements that you must specify to use Sort from PL/I. The SORT statement is the first argument to PLISRTx.

The syntax of the SORT statement must be a character string expression that takes the form:
'bSORTbFIELDS=(start1,length1,form1,seq1,
...startn,lengthn,formn,seqn)[,other options]b'
See the following example:
' SORT FIELDS=(1,10,CH,A) '
b
Represents one or more blanks. Blanks shown are mandatory. No other blanks are allowed.
start,length,form,seq
Defines a sorting field. You can specify any number of sorting fields, but there is a limit on the total length of the fields. If more than one field is to be sorted on, the records are sorted first according to the first field, and then those that are of equal value are sorted according to the second field, and so on. If all the sorting values are equal, the order of equal records will be arbitrary unless you use the EQUALS option. (See later in this definition list.) Fields can overlay each other.
For DFSORT (5740-SM1), the maximum total length of the sorting fields is restricted to 4092 bytes and all sorting fields must be within 4092 bytes of the start of the record. Other sort products might have different restrictions.
start
Specifies the starting position within the record. Specify the value in bytes except for binary data where you can use a byte.bit notation. The first byte in a string is considered to be byte 1, and the first bit is bit 0. (Thus the second bit in byte 2 is referred to as 2.1.) For varying length records, you must include the 4-byte length prefix, making 5 the first byte of data.
length
Specifies the length of the sorting field. Specify the value in bytes except for binary where you can use byte.bit notation. The length of sorting fields is restricted according to their data type.
form
Specifies the format of the data. This is the format assumed for the purpose of sorting. All data passed between PL/I routines and Sort must be in the form of character strings. The main data types and the restrictions on their length are shown below. Additional data types are available for special-purpose sorts. See the DFSORT Application Programming Guide or the equivalent publication for your sort product.
Code Data type and length
CH Character 1–4096
ZD Zoned decimal, signed 1–32
PD Packed decimal, signed 1–32
FI Fixed point, signed 1–256
BI Binary, unsigned 1 bit to 4092 bytes
FL Floating-point, signed 1–256

The sum of the lengths of all fields must not exceed 4092 bytes.

seq
Specifies the sequence in which the data will be sorted:
A
Ascending (that is, 1,2,3,...)
D
Descending (that is, ...,3,2,1)
Note: You cannot specify E, because PL/I does not provide a method of passing a user-supplied sequence.
other options
You can specify a number of other options, depending on your Sort program. You must separate them from the FIELDS operand and from each other by commas. Do not place blanks between operands.
FILSZ=y
Specifies the number of records in the sort and allows for optimization by Sort. If y is only approximate, E should precede y.
SKIPREC=y
Specifies that y records at the start of the input file are to be ignored before Sort starts sorting the remaining records.
CKPT or CHKPT
Specifies that checkpoints are to be taken. If you use this option, you must provide a SORTCKPT data set. In addition, when you install DFSORT, you must specify the 16NCKPT=NO installation option.
EQUALS|NOEQUALS
Specifies whether the order of equal records will be preserved as it was in the input (EQUALS) or will be arbitrary (NOEQUALS). You could improve sort performance by using the NOEQUALS. The default option is chosen when Sort is installed. The IBM-supplied default is NOEQUALS.
DYNALLOC=(d,n)
(OS/VS Sort only) Specifies that the program dynamically allocates intermediate storage.
d
Specifies the device type (3380, and so on).
n
Specifies the number of work areas.