Compaq AAQ2G1FTK Marine Radio User Manual


 
Using the SORT and MERGE Statements
9.1 Sorting Data with the SORT Statement
In contrast, the WITH DUPLICATES IN ORDER phrase guarantees that records
with duplicate sort keys remain in the same sequence as they were in the input
file.
9.1.6 Specifying Non-ASCII Collating Sequences with the COLLATING
SEQUENCE IS Alphabet-Name Phrase
This phrase lets you specify a collating sequence other than the ASCII default.
You define collating sequences in the Environment Division SPECIAL-NAMES
paragraph. A sequence specified in the COLLATING SEQUENCE IS phrase of
the SORT statement overrides a sequence specified in the Environment Division
PROGRAM COLLATING SEQUENCE IS phrase.
Example 9–3 shows the alphabet name NEWSEQUENCE overriding the
EBCDIC-CODE collating sequence.
Example 93 Overriding the COLLATING SEQUENCE IS Phrase
ENVIRONMENT DIVISION.
OBJECT-COMPUTER. FOO
PROGRAM COLLATING SEQUENCE IS EBCDIC-CODE.
SPECIAL-NAMES.
ALPHABET NEWSEQUENCE IS "ZYXWVUTSRQPONMLKJIHGFEDCBA"
ALPHABET EBCDIC-CODE IS EBCDIC.
.
.
.
PROCEDURE DIVISION.
000-DO-THE-SORT.
SORT SORT-FILE ON ASCENDING KEY
SORT-KEY-1
SORT-KEY-2
COLLATING SEQUENCE IS NEWSEQUENCE
USING INPUT-FILE GIVING OUTPUT-FILE.
9.1.7 Multiple Sorting
A program can contain multiple sort files, multiple SORT statements, or both
multiple sort files and multiple SORT statements. Example 9–4 uses two sort
files to produce two reports with different sort sequences.
Example 94 Using Two Sort Files
.
.
.
DATA DIVISION.
FILE SECTION.
SD SORT-FILE1.
01 SORT-REC-1.
03 S1-KEY-1 PIC X(5).
03 FILLER PIC X(40).
03 S1-KEY-2 PIC X(5).
03 FILLER PIC X(50).
SD SORT-FILE2.
01 SORT-REC-2.
(continued on next page)
Using the SORT and MERGE Statements 97