COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-232
SORT
°
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.
If infile specifies a file whose SELECT clause does not include the OPTIONAL
phrase, the file must be present at execution time.
If an instance of outfile identifies an indexed or queue file, the major key must
be associated with the ASCENDING phrase and the first instance of key must
specify the same character positions in its record as are specified for the prime
record key for that file.
A COBOL program can sort to and from these types of files:
°
Disk files
°
Tape files
°
Multiple-reel tape files
°
Tape files on a multiple-file reel
No more than one file name from a multiple-file reel can be in a SORT statement.
Sort Input Procedures
The INPUT PROCEDURE phrase defines a sort input procedure that extends from
inproc-1 to inproc-2, each of which must identify a Procedure Division
section or paragraph. If THROUGH or THRU is omitted, the compiler assumes an
inproc-2 that specifies the same section or paragraph as inproc-1.