Using the SORT and MERGE Statements
9.3 Sample Programs Using the SORT and MERGE Statements
Example 9–9 (Cont.) Using the INPUT PROCEDURE and OUTPUT
PROCEDURE Phrases
MOVE "N" TO INITIAL-SORT-READ
GO TO 400-READ-SORT-FILE.
450-COMPARE-ACCOUNT-NUM.
IF S-ACCOUNT-NUM = SR-ACCOUNT-NUM
ADD S-AMOUNT TO SR-AMOUNT
GO TO 400-READ-SORT-FILE.
500-WRITE-THE-OUTPUT.
MOVE SAVE-SORT-REC TO OUT-REC.
WRITE OUT-REC.
ADD 1 TO OUTPUT-COUNT.
550-GET-A-REC.
MOVE SORT-REC TO SAVE-SORT-REC.
GO TO 400-READ-SORT-FILE.
600-DONE-CREATE SECTION.
650-EXIT-PARAGRAPH.
EXIT.
Example 9–10 shows how to use the COLLATING SEQUENCE IS phrase.
Example 9–10 Using the COLLATING SEQUENCE IS Phrase
IDENTIFICATION DIVISION.
PROGRAM-ID. SORTD.
**************************************************
*
This program sorts a file into a non-ASCII
*
*
collating sequence. The collating sequence
*
*
is defined by the alphabet-name MYSEQUENCE
*
*
in the SPECIAL-NAMES paragraph of the
*
*
ENVIRONMENT DIVISION.
*
*
The collating sequence is:
*
*
1. The letters A to Z
*
*
2. The digits 0 to 9
*
**************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
ALPHABET MYSEQUENCE IS
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ".
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO "INPFIL".
SELECT OUTPUT-FILE ASSIGN TO "OUTFIL".
SELECT SORT-FILE ASSIGN TO "SRTFIL".
DATA DIVISION.
FILE SECTION.
SD
SORT-FILE.
01
SORT-REC.
03
S-KEY-1.
05
S-ACCOUNT-NAME
PIC X(23).
03
S-KEY-2.
05
S-AMOUNT
PIC S9(5)V99.
(continued on next page)
9–16 Using the SORT and MERGE Statements
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......