Sorting Variable Length Records

Files with variable length records have a minimum record length and a maximum record length, rather than a single record length.

If variable length records are being sorted or merged, all of the data items referenced by key data-names must be contained within the first n character positions of the record, where n is equal to the minimum record size specified for the file.

When processing the SORT statement, the ILE COBOL compiler will issue an error message if any KEY specified in the SORT statement falls in the record length beyond the minimum record size.

Sort records will be truncated when:
  • The maximum record length of the input file record is greater than the maximum record length of the sort file record
  • The maximum record length of the sort file record is greater than the maximum record length of the output file record.

A compile time error message is issued when truncation will occur; a diagnostic message is issued at run time.

Sort records will be padded with blanks when:
  • The minimum record length of the input file record is less than the minimum record length of the sort file record
  • The minimum record length of the sort file record is less than the minimum record length of the output file record.

A compile time informational message is issued when records will be padded with blanks; no message is issued at run time.