Compaq AAQ2G1FTK Marine Radio User Manual


 
Using the SORT and MERGE Statements
9.1 Sorting Data with the SORT Statement
If you specify the GIVING phrase and the output file contains variable-length
records, the sort-file record must not be smaller than the smallest record, nor
larger than the largest record, described in the output file.
9.1.9 Preventing I/O Aborts
All I/O errors detected during a sort can cause abnormal program termination.
The Declarative USE AFTER STANDARD ERROR PROCEDURE, shown in
Example 9–5, specifies error-handling procedures should I/O errors occur.
Example 95 The Declarative USE AFTER STANDARD ERROR PROCEDURE
PROCEDURE DIVISION.
DECLARATIVES.
SORT-FILE SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON INPUT-FILE.
SORT-ERROR.
DISPLAY "I-O TYPE ERROR WHILE SORTING".
DISPLAY "INPUT-FILE STATUS IS " INPUT-STATUS.
STOP RUN.
END DECLARATIVES.
000-SORT SECTION.
010-DO-THE-SORT.
SORT SORT-FILE ON DESCENDING KEY
S-KEY-1
WITH DUPLICATES IN ORDER
USING INPUT-FILE
GIVING OUTPUT-FILE.
DISPLAY "END OF SORT".
STOP RUN.
Note
The USE PROCEDURE phrase does not apply to Sort Description (SD)
files.
9.1.10 Sorting Tables
The SORT statement can be used to order the elements in a table. This is
especially useful for tables used with SEARCH ALL. The table elements are
sorted based on the keys as specified in the OCCURS for the table unless you
override them by specifying keys in the SORT statement. If no key is specified,
the table elements are the SORT keys.
For the syntax and examples of table sorting, see the SORT statement description
in the Procedure Division chapter of the Compaq COBOL Reference Manual.
9.1.11 Sorting at the Operating System Level
On OpenVMS an alternative to using the SORT statement within COBOL is to
sort at the operating system level, using the bundled SORT utility.
On OpenVMS, you can choose between two sorting methods: Hypersort and
Sort-32. Sort-32 is the default. Consult the DCL online help (type $HELP SORT)
for details about the two methods, which have effects on optimization and other
differences, and information about how to switch between Sort-32 and Hypersort.
Using the SORT and MERGE Statements 99