Wednesday, 20 March 2019

Syncsort Command - SORT

The SORT statement can be used sort a dataset or concatenated datasets. The SORT statement requires the sort sequence for the data. 

The list of fields and their formats must be specified for this statement. The output records are sorted in the specified sequence.

The multiple records contain the same sort sequence key, then the options specified will determine if the input order is maintained for such records. The format of the SORT statement is as follows.

SORT FIELDS=({begcol},{length},{fieldtype},{D|A}[,{begcol}, {length},{fieldtype},{D|A}]...)
SORT FIELDS=({begcol},{length},{D|A}[,{begcol},{length}, {D|A}]...),{fieldtype}

The beginning column is specified in bytes, starting with 1 for the first byte. The length of the field must be specified in bytes, irrespective of the field type.

There are many field types. The frequently used ones are CH for the character, BI for binary (COMP fields of COBOL), PD for packed decimal (COMP-3 fields of COBOL), ZD for zone decimal and AQ for the alternate collating sequence (refer to later section on alternate collating sequence).

The second form of the SORT statement can be used when all the fields specified for the sort sequence are of the same type.

No comments:

Post a comment