COBOL Program to implement
Sequential File Concept.
PROGRAM:
IDENTIFICATION DIVISION.
PROGRAM-ID. SEQUENTIAL.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT SEQ1-FILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD SEQ1-FILE
LABEL RECORDS ARE STANDARD VALUE OF
FILE-ID IS "SEQ1.DAT".
01 SEQ1-REC.
02 REGNO PIC X(8).
02 STUNAME PIC X(25).
02 MARKS PIC 9(3).
WORKING-STORAGE SECTION.
77 CH PIC X.
77 CH1 PIC 9.
77 EOF PIC X.
PROCEDURE DIVISION.
MAIN-PARA.
DISPLAY "A PROGRAM TO CREATE
AND PROCESS SEQUENTIAL FILE".
OPEN OUTPUT SEQ1-FILE.
MOVE 'Y' TO CH.
PERFORM ACCEPT-PARA UNTIL CH = 'N'.
CLOSE SEQ1-FILE.
COMPUTE CH1 = 1.
PERFORM MENU-PARA UNTIL CH1 = 3.
STOP RUN.
ACCEPT-PARA.
DISPLAY " ENTER REG NUMBER
:".
ACCEPT REGNO.
DISPLAY " ENTER THE STUDENT
NAME ".
ACCEPT STUNAME.
DISPLAY "ENTER THE STUDENT
MARKS ".
ACCEPT MARKS.
WRITE SEQ1-REC.
DISPLAY " ARE THERE ANY MORE
RECORDS (Y/N) ?".
ACCEPT CH.
DISPLAY(1 1) ERASE.
MENU-PARA.
DISPLAY "1. DISPLAY
RECORDS".
DISPLAY "2. APPEND
RECORDS".
DISPLAY "3. EXIT".
ACCEPT CH1.
IF CH1 = 1
PERFORM DISP-PARA ELSE IF CH1 = 2
OPEN EXTEND SEQ1-FILE MOVE 'Y' TO CH
PERFORM APP-PARA UNTIL CH = 'N'
CLOSE SEQ1-FILE.
DISP-PARA.
OPEN INPUT SEQ1-FILE.
MOVE 'N' TO EOF.
READ SEQ1-FILE AT END MOVE 'Y' TO
EOF.
DISPLAY "REGNO STUDENTNAME
MARKS".
PERFORM READ-PARA UNTIL EOF = 'Y'.
CLOSE SEQ1-FILE.
READ-PARA.
DISPLAY REGNO STUNAME MARKS.
READ SEQ1-FILE AT END MOVE 'Y' TO
EOF.
APP-PARA.
DISPLAY " ENTER REG NUMBER
:".
ACCEPT REGNO.
DISPLAY " ENTER THE STUDENT
NAME ".
ACCEPT STUNAME.
DISPLAY "ENTER THE STUDENT MARKS
".
ACCEPT MARKS.
WRITE SEQ1-REC.
DISPLAY "DO U WISH TO CONTINUE
: ".
ACCEPT CH.
No comments:
Post a Comment