Compaq COBOL AAQ2G1FTK User Manual page 293

Compaq computer accessories user manual
Table of Contents

Advertisement

9.3 Sample Programs Using the SORT and MERGE Statements
Example 9–9 (Cont.) Using the INPUT PROCEDURE and OUTPUT
PROCEDURE Phrases
PROCEDURE DIVISION.
000-START SECTION.
005-DO-THE-SORT.
SORT SORT-FILE ON ASCENDING KEY
S-KEY-1
S-KEY-2
INPUT PROCEDURE IS 010-GET-INPUT
OUTPUT PROCEDURE IS 300-CREATE-OUTPUT-FILE
********************************************************
*
Notice the use of DISPLAY and record counters to
*
produce sort statistics.
********************************************************
DISPLAY "TOTAL FIRST-FILE RECORDS IS
DISPLAY "TOTAL SECOND-FILE RECORDS IS
DISPLAY "TOTAL NUMBER OF SORTED RECORDS IS
DISPLAY "TOTAL NUMBER OF OUTPUT RECORDS IS
************************************************************
*
At this point, you could transfer control to another
*
section of the program and continue processing.
************************************************************
DISPLAY "END OF PROGRAM SORTC".
STOP RUN.
010-GET-INPUT SECTION.
050-OPEN-FILES.
OPEN INPUT FIRST-FILE.
100-READ-FIRST-FILE.
READ FIRST-FILE AT END
CLOSE FIRST-FILE
OPEN INPUT SECOND-FILE
GO TO 150-READ-SECOND-FILE.
ADD 1 TO FILE01-COUNT.
IF R1-STATUS-CODE = "D"
GO TO 100-READ-FIRST-FILE.
RELEASE SORT-REC FROM RECORD1.
GO TO 100-READ-FIRST-FILE.
150-READ-SECOND-FILE.
READ SECOND-FILE AT END
CLOSE SECOND-FILE
GO TO 200-DONE-INPUT-GET.
ADD 1 TO FILE02-COUNT.
IF R2-STATUS-CODE = "D"
GO TO 150-READ-SECOND-FILE.
RELEASE SORT-REC FROM RECORD2.
GO TO 150-READ-SECOND-FILE.
200-DONE-INPUT-GET SECTION.
250-EXIT-PARAGRAPH.
EXIT.
300-CREATE-OUTPUT-FILE SECTION.
350-OPEN-OUTPUT.
OPEN OUTPUT OUTPUT-FILE.
400-READ-SORT-FILE.
RETURN SORT-FILE AT END
PERFORM 500-WRITE-THE-OUTPUT
CLOSE OUTPUT-FILE
GO TO 600-DONE-CREATE.
ADD 1 TO SORT-COUNT.
IF INITIAL-SORT-READ = "Y"
MOVE SORT-REC TO SAVE-SORT-REC
Using the SORT and MERGE Statements
THRU 200-DONE-INPUT-GET
THRU 600-DONE-CREATE.
Using the SORT and MERGE Statements 9–15
*
*
" FILE01-COUNT.
" FILE02-COUNT.
" SORT-COUNT.
" OUTPUT-COUNT.
*
*
(continued on next page)

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?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents