Merging Files - 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–11 (Cont.) Creating a New Sort Key
120-WRITE.
RETURN SORT-FILE AT END
CLOSE OUT-FILE
GO TO 130-DONE.
MOVE SORT-LENGTH TO OUT-LENGTH.
WRITE OUT-REC.
GO TO 120-WRITE.
130-DONE.
EXIT.
Example 9–12 merges three identically sequenced files into one file.
Example 9–12 Merging Files
IDENTIFICATION DIVISION.
PROGRAM-ID.
MERGE01.
******************************************************
*
This program merges three identically sequenced *
*
regional sales files into one total sales file. *
*
The program adds sales amounts and writes one
*
record for each product code.
******************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT REGION1-SALES ASSIGN TO "REG1SLS".
SELECT REGION2-SALES ASSIGN TO "REG2SLS".
SELECT REGION3-SALES ASSIGN TO "REG3SLS".
SELECT MERGE-FILE
SELECT TOTAL-SALES
DATA DIVISION.
FILE SECTION.
FD REGION1-SALES
LABEL RECORDS ARE STANDARD.
01 REGION1-RECORD
FD REGION2-SALES
LABEL RECORDS ARE STANDARD.
01 REGION2-RECORD
FD REGION3-SALES
LABEL RECORDS ARE STANDARD.
01 REGION3-RECORD
SD MERGE-FILE.
01 MERGE-REC.
03 M-REGION-CODE
03 M-PRODUCT-CODE
03 M-SALES-AMT
03 FILLER
Using the SORT and MERGE Statements
ASSIGN TO "MRGFILE".
ASSIGN TO "TOTLSLS".
PIC X(100).
PIC X(100).
PIC X(100).
PIC XX.
PIC X(10).
PIC S9(7)V99.
PIC X(79).
Using the SORT and MERGE Statements 9–19
*
*
(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

Table of Contents