FastSort Manual

Sorting Programmatically
FastSort Manual429834-003
4-14
Sorting From COBOL85 Programs
Example 4-2. COBOL85 Example of a Serial Sort Run (page1of2)
*---------------------------------------------------------
* FastSort Serial Sort Run Program
*---------------------------------------------------------
* This program sorts an input file specified by the TACL
* DEFINE =INFILE and writes the sorted records to an output
* file specified by the TACL DEFINE =OUTFILE. The program
* uses a temporary scratch file on the user's default volume.
*---------------------------------------------------------
?SYMBOLS, INSPECT
?LIBRARY $SYSTEM.SYSTEM.COBOLLIB
IDENTIFICATION DIVISION.
PROGRAM-ID. FASTSORT-SERIAL-SORT.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT-FILE
ASSIGN TO "=INFILE"
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT OUTPUT-FILE
ASSIGN TO "=OUTFILE"
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT SCRATCH-FILE
ASSIGN TO "#TEMP".
DATA DIVISION.
FILE SECTION.
FD INPUT-FILE
LABEL RECORDS ARE OMITTED
RECORD CONTAINS 25 CHARACTERS.
01 IN-RECORD.
05 EMPLOYEE-NAME PIC X(20).
05 EMPLOYEE-NUMBER PIC 9(5).
FD OUTPUT-FILE
LABEL RECORDS ARE OMITTED
RECORD CONTAINS 25 CHARACTERS.
01 OUT-RECORD.
05 EMPLOYEE-NAME PIC X(20).
05 EMPLOYEE-NUMBER PIC 9(5).
SD SCRATCH-FILE
RECORD CONTAINS 25 CHARACTERS.
01 SORT-RECORD.
05 EMPLOYEE-NAME PIC X(20).
05 EMPLOYEE-NUMBER PIC 9(5).
*---------------------------------------------------------
* Main program: Open files and initiate SORTPROG.
*---------------------------------------------------------
PROCEDURE DIVISION.
OPEN-FILES.
DISPLAY "Starting FastSort serial sort run...".
OPEN INPUT INPUT-FILE.
OPEN OUTPUT OUTPUT-FILE.
SORT SCRATCH-FILE
ON ASCENDING KEY EMPLOYEE-NAME OF SORT-RECORD,
INPUT PROCEDURE IS SORTIN-PROCEDURE
OUTPUT PROCEDURE IS SORTOUT-PROCEDURE.
DISPLAY "FastSort serial sort run completed.".
STOP RUN.