Tuesday, May 19, 2009

Program in cobol that merges the two inventory file into a single file.

A store has two branches:
Branch A and Branch B. Both the branches of the store sells many products. Some of these products are common to both the branches, while some are available in one branch. Both the store keeps the unsorted inventory file in the following format:
01-05 Product Code
06-25 Product name
26-30 Quantity
However due to some reason the store decided to merge the two branches. Thus the inventory files are also be merged. Write a program in cobol that merges the two inventory file into a single file.




IDENTIFICATION DIVISION.
PROGRAM-ID. SORTPROG.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT_FILE-1 ASSIGN TO DISK1.
SELECT INPUT_FILE-2 ASSIGN TO DISK2.
SELECT MERGE-THEM ASSIGN TO DISK ‘WORK’.
SELECT OUTPUT FILE ASSIGN TO DISK ‘DISK’.

DATA DIVISION.
FD INPUT-FILE-1
LABEL RECORDS ARE STANDARD.
01 IN-REC-1
FD INPUT-FILE-1
01 INPUT_REC
02 PCODE PIC X(100).
02 PNAME PIC X(100).
02 QUANTITY PIC X(100).
FD INPUT-FILE-2
LABEL RECORDS ARE STANDARD.
01 INPUT_REC.
02 IPCODE-NO PIC X(100).
02 IPNAME PIC X(100).
02 IQUANTITY PIC X (100).
SD MERGE-THEM.
01 MERGE-REC.
05 M-PCODE-NO PIC X(100).
05 M-PNAME PIC X(100).
05 M-QUANTITY PIC X(100).
FD OUTPUT-FILE.
LABEL RECORD ARE STANDARD.
01 OUT-REC PIC X(100).
PROCEDURE DIVISION.
100-MAIN-MODULE.
ON ASSCENDING KEY KEY-FIELD
USING INPUT-FILE-1, INPUT-FILE-2
GIVING OUTPUT-FILE
STOP RUN.

No comments:

Post a Comment