Creating A New Sort Key - Compaq COBOL AAQ2G1FTK User Manual

Compaq computer accessories user manual
Table of Contents

Advertisement

9.3 Sample Programs Using the SORT and MERGE Statements
Example 9–10 (Cont.) Using the COLLATING SEQUENCE IS Phrase
FD INPUT-FILE
LABEL RECORDS ARE STANDARD.
01 IN-REC
FD OUTPUT-FILE
LABEL RECORDS ARE STANDARD.
01 OUT-REC
PROCEDURE DIVISION.
000-DO-THE-SORT.
SORT SORT-FILE ON ASCENDING KEY
S-KEY-1
S-KEY-2
COLLATING SEQUENCE IS MYSEQUENCE
USING INPUT-FILE GIVING OUTPUT-FILE.
************************************************************
*
At this point, you could transfer control to another
*
section of the program and continue processing.
************************************************************
DISPLAY "END OF PROGRAM SORTD".
STOP RUN.
Example 9–11 is an example of creating a new sort key.
Example 9–11 Creating a New Sort Key
IDENTIFICATION DIVISION.
PROGRAM-ID. SORTE.
************************************************
*
This program increases the size of the
*
variable input records by a new six-
*
character field and uses this field
*
as the sort key.
************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INFILE ASSIGN TO "INFILE".
SELECT SORT-FILE ASSIGN TO "SRTFIL".
SELECT OUT-FILE ASSIGN TO "OUTFILE".
DATA DIVISION.
FILE SECTION.
FD
INFILE
RECORD VARYING FROM 100 TO 490 CHARACTERS
DEPENDING ON IN-LENGTH.
01
INREC.
03 ACCOUNT
03 INCOME-FIRST-QUARTER
03 INCOME-SECOND-QUARTER
03 INCOME-THIRD-QUARTER
Using the SORT and MERGE Statements
PIC X(30).
PIC X(30).
*
*
*
*
PIC 9(5).
PIC 9(5)V99.
PIC 9(5)V99.
PIC 9(5)V99.
Using the SORT and MERGE Statements 9–17
*
*
(continued on next page)

Advertisement

Table of Contents
loading

Table of Contents