Wednesday, May 20, 2009

Program in COBOL that combines the two files to create a single file.

A University has database of students at two different places: its administrative office and College of the student. However, over a period of time it was found that the information stored about the student in college database is most recent, but it does not store the information about the students who have not paid the fee. As per the University policy the data of such student should also be maintained along with other students, but indicating proper status. The student information is stored in the following format:

01-09 Student code
10-35 Student name
36-50 Programme
51-70 Address

Write a Program in COBOL that combines the two files to create a single file. The combined file will have same structure till 70th position and on 71st position a status information code is added about the student. Please note that the latest student addresses are available in College file and the status will be ascertained from the fact that the student name does not appear in college file but exists in administrative office file.



*USED TO MERGE COLLEGE AND ADMINISTRATIVE DATABASE
*INTO A NEW DATABASE
IDENTIFICATION DIVISION.
PROGRAM-ID. QUESTION-2 PROJECT.
AUTHOR GYAN AND CHANDRA.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT COLL-FILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
SELECT ADMIN-FILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
SELECT MERGE-FILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
SELECT WORK-FILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
DATA-DIVISION.
FILE-SECTION.
FD COLL-FILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID”COLLEGE.TXT”.
01 COLLEGE-RECORDS.
02 ST-CODE PIC X(9).
02 ST-NAME PIC X(26).
02 PROG PIC X(15).
02 ADDRS PIC X(20).
02 FILLER PIC X(10).
FD ADMIN-FILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID”OFFICE.TXT”.
01 ADMINS-RECORDS.
02 ST-CODE PIC X(9).
02 ST-NAME PIC X(26).
02 PROG PIC X(15).
02 ADDRS PIC X(20).
02 FILLER PIC X(10).
FD MERGE-FILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID”MAIN.TXT”.
01 MERGE-RECORDS.
02 STUD-CODE PIC X(9).
02 STUD-NAME PIC X(26).
02 PROGRA PIC X(15).
02 ADDRESS PIC X(20).
02 STATS PIC X(5).
02 FILLER PIC X(5).
SD WORK-FILE.
01 WORK-RECORDS.
02 SCODE PIC X(9).
02 SNAME PIC X(26).
02 PR PIC X(15).
02 ADS PIC X(20).
02 STAT PIC X(5).
02 FILLER PIC X(5).
WORKING-STORAGE SECTION.
01 LINING PIC X(80) VALUEALL’-’.
PROCEDURE DIVISION.
OPEN-PARA.
OPEN OUTPUT COLL-FILE ADMIN-FILE.
DISPLAY “ *********COLLEGE RECORDS*********”.
DISPLAY LINING.
PERFORM COLL-PARA 2 TIMES.
DISPLAY “ ***ADMINISTRATIVE OFFICE RECORDS***”.
DISPLAY LINING.
PERFORM ADMIN-PARA 2 TIMES.
CLOSE COLL-FILE ADMIN-FILE.
COLL-PARA.
DISPLAY “STUDENT CODE:”ACCEPT S-CODE.
DISPLAY “STUDENT NAME:”ACCEPT S-NAME.
DISPLAY “PROGRAMME:”ACCEPT PROGR.
DISPLAY “ADDRESS:”ACCEPT ADDR.
WRITE ADMINS-RECORDS.
MERGE-PARA.
MERGE WORK-FILE ON ASCENDING KEYSCODE
USING COLL-FILE ADMIN-FILE
GIVING MERGE-FILE.

No comments:

Post a Comment