Sorting Variable-Length Records - Compaq COBOL AAQ2G1FTK User Manual

Compaq computer accessories user manual
Table of Contents

Advertisement

Using the SORT and MERGE Statements
9.1 Sorting Data with the SORT Statement
Example 9–4 (Cont.) Using Two Sort Files
01 SORT-REC-2.
03 FILLER
03 S2-KEY-1
03 FILLER
03 S2-KEY-2
03 FILLER
PROCEDURE DIVISION.
000-SORT SECTION.
010-DO-FIRST-SORT.
SORT SORT-FILE1 ON ASCENDING KEY
020-DO-SECOND-REPORT.
SORT SORT-FILE2 ON ASCENDING KEY
030-END-JOB.
DISPLAY "PROGRAM ENDED".
STOP RUN.
050-CREATE-REPORT-1 SECTION.
**********************************************************
*
*
*
Use the RETURN statement to read the sorted records. *
*
*
**********************************************************
300-DONE-REPORT-1 SECTION.
310-EXIT-REPORT-1.
EXIT.
400-CREATE-REPORT-2 SECTION.
**********************************************************
*
*
*
Use the RETURN statement to read the sorted records. *
*
*
**********************************************************
700-DONE-REPORT-2 SECTION.
710-EXIT-REPORT.
EXIT.

9.1.8 Sorting Variable-Length Records

If you specify the USING phrase and the input 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 input file.
9–8 Using the SORT and MERGE Statements
PIC X(20).
PIC X(10).
PIC X(10).
PIC X(10).
PIC X(50).
.
.
.
S1-KEY-1
S1-KEY-2
WITH DUPLICATES IN ORDER
USING INPUT-FILE
OUTPUT PROCEDURE IS 050-CREATE-REPORT-1
THRU 300-DONE-REPORT-1.
S2-KEY-1
ON DESCENDING KEY
S2-KEY-2
USING INPUT-FILE
OUTPUT PROCEDURE IS 400-CREATE-REPORT-2
THRU 700-DONE-REPORT-2.
*
*
*
*
*
*
*
*

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COBOL AAQ2G1FTK and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents