Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

SORT

&pagelevel(3)&pagelevel

POSIX files can be assigned as input files (INPUT-FILES operand) or as output files (OUTPUT-FILES operand) in the SORT control statement ASSIGN-FILES or in the SORT-FILE command.

To distinguish them from BS2000 file names, POSIX file names must be specified in single quotes in the INPUT-FILES and OUTPUT-FILE operands.

Work files and auxiliary files must not be POSIX files.

The data in POSIX files is in text format, which cannot be processed directly by SORT. Before it is processed by the sort routine, this data is converted by SORT into variable-length records, each prefixed by a record length field.

After the sort process, SORT converts the sorted output file back into text format if it is to be stored in the POSIX file system.

The internal use of variable-length records causes the position of the user data in the record to be displaced by the record length field, but this does not normally have any consequence for POSIX file users. With records from POSIX files, SORT calculates the field positions by default relative to the beginning of the user data.

However, if the user wants to access the internal record length field, e.g. in order to sort the records according to their length, the IGNORE-LENGTH-FIELD operand is available in the SET-SORT-OPTIONS statement and the SORT-FILE command.

Specifying IGNORE-LENGTH-FIELD=*NO causes the positions within the record to be calculated from the start of the record, both with variable-length records in BS2000 files and with records in POSIX files. The user data thus begins at position 5 in the record.

The encoding of the end-of-record identifier is determined by the CODE operand in the ASSIGN-FILES statement and the SORT-FILE command. If CODE=EBCDIC is specified, the end-of-record identifier is encoded as X'0A' and if CODE=ASCII is specified, as X'15'.

If POSIX files are used as output files, you must make sure that the output records do not contain characters which might be interpreted as end-of-record identifiers. More specifically:

  • No constant fields containing end-of-record identifiers may be specified in the SORT-RECORDS statement or the SORT-FILE command.

  • The records of a BS2000 input file must not contain end-of-record identifiers if the output file is to be a POSIX file.

  • The sort type “tag sort” must not be used because it cannot be guaranteed that the address fields do not contain characters which could be interpreted as end-of-record identifiers.

Using the sort command, which can be called in a POSIX shell, is not the same as calling the product SORT.

More detailed information can be found in the "SORT" [34] manual.