COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
If the SELECT statement associated with sd-name specifies the =_SORT_DEFAULTS DEFINE
as the define-name-literal, then:
◦ If the =_SORT_DEFAULTS DEFINE exists and specifies a swap file, then the swap file is
created on that file’s volume.
◦ If the =_SORT_DEFAULTS DEFINE exists but does not specify a swap file, then the swap
file is created on the volume used for the scratch file.
◦ If no =_SORT_DEFAULTS DEFINE exists, then the swap file is created on the volume used
for the scratch file.
◦ If the SELECT statement associated with sd-name does not specify the =_SORT_DEFAULTS
DEFINE as the define-name-literal, then the swap file is created on the volume of
the file that the SELECT statement specifies.
For instructions for creating the =_SORT_DEFAULTS DEFINE, see the FastSort Manual.
• Placement of SORT Statements
A SORT statement cannot appear in the Declaratives Portion of the Procedure Division. It can
appear anywhere in the other portion except within the range of a sort input procedure or a
sort or merge output procedure.
• File Descriptions
File sd-name must be described by a sort-merge file description entry (sort-merge file
description entry) in the File Section of the Data Division. The file can be described as having
fixed-length or variable-length records. Every file record must contain all of the sort key fields.
• Restrictions on Sort Keys
Each key identifies a sort key data item and is subject to these restrictions:
◦ The data item specified by key must be described within a record associated with
sd-name. When sd-name has more than one record description, a sort key item can
be defined within any one of those record descriptions.
◦ No sort key data item can have a variable size (have a subordinate described with an
OCCURS DEPENDING clause).
◦ No sort key data item can be described with an OCCURS clause or can be subordinate
to an item described with an OCCURS clause.
• Sort Input and Sort Output Files
Files specified by infile and outfile must be defined as data files; that is, none of them
can be defined in a sort-merge file description entry.
If the file identified by sd-name has variable-length records, the size of the records contained
in the file identified by infile must not be less than the size of the smallest record described
for sd-name; likewise, the size must not be greater than the size of the largest record described
for sd-name. If sd-name is described as having fixed-length records, the size of the records
contained in the file described by infile must not be larger than the largest record defined
for sd-name.
If the file identified by outfile has variable-length records, the size of the records contained
in the file identified by sd-name must not be less than the size of the smallest record described
for outfile ; likewise, the size must not be greater than the size of the largest record
described for outfile. If outfile is described as having fixed-length records, the size of
the records contained in the file described by sd-name must not be larger than the largest
record defined for outfile. The size of the records must be less than 4073 bytes for disk
files.
SORT 445










