COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-231
SORT
The swap file is a temporary file with a volume but no subvolume. If you specify a
swap file, the file-id you specify is not used, only the volume. If you specify
only the file-id, the default volume is used.
In this explanation, if a swap file is specified but its value is all spaces, assume that
no swap file was specified.
If COBOL_SET_SORT_PARAM_TEXT_ specifies a SWAP-FILE, then the swap
file is created on that file’s volume.
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).