Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

PROGRAM TO CREATE THE RELATIVE FILE AND ADD RECORD,UPDETE RECORD,DELETE PERTICULAR RECORD AND READ THE SPCIFY RECORD

Posted By: Caitlin Brown     Category: Cobol     Views: 7278

PROGRAM TO CREATE THE RELATIVE FILE AND ADD RECORD,UPDETE RECORD,DELETE PERTICULAR RECORD AND READ THE SPCIFY RECORD.

Code for PROGRAM TO CREATE THE RELATIVE FILE AND ADD RECORD,UPDETE RECORD,DELETE PERTICULAR RECORD AND READ THE SPCIFY RECORD in Cobol

       IDENTIFICATION DIVISION.
         PROGRAM-ID. index1.

       ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
         FILE-CONTROL.
           SELECT indfile1 ASSIGN TO DISK
           ORGANIZATION IS RELATIVE
           ACCESS MODE IS RANDOM RELATIVE KEY IS FNO1.

       DATA DIVISION.
        FILE SECTION.
         FD indfile1
          VALUE OF FILE-ID IS "RELATIVE.TXT".
          01 fileind1.
            05 fno PIC 99.
            05 fname PIC X(10).

         WORKING-STORAGE SECTION.
          01 FNO1 PIC 99.
          01 CHOICE PIC 9.
          01 CH1 PIC X VALUE 'Y'.
          01 UR PIC 99.
          01 REXIST PIC X.

       PROCEDURE DIVISION.
        PARA1.
          OPEN I-O indfile1.

         PERFORM UNTIL CH1='N'
          DISPLAY " "
          DISPLAY "MENU::"
          DISPLAY "   ENTER YOUR CHOICE"
          DISPLAY "   1=ADD RECORD"
          DISPLAY "   2=DELETE RECORD"
          DISPLAY "   3=UPDATE RECORD"
          DISPLAY "   4=READ PERTICULAR RECORD"
          DISPLAY "   0=EXIT"
          ACCEPT choice

          EVALUATE CHOICE
           WHEN 1 PERFORM ADD1
           WHEN 2 PERFORM DELETE1
           WHEN 3 PERFORM UPDATE1
           WHEN 4 PERFORM READ1
           WHEN OTHER MOVE 'N' TO CH1
          END-EVALUATE
         END-PERFORM.
         STOP RUN.

         ADD1.
          DISPLAY " ". 
          DISPLAY "ENTER THE ROLL NO".
          ACCEPT fno.
          DISPLAY "ENTER THE ROLL NAME".
          ACCEPT fname.
          MOVE fno TO fno1.
          WRITE fileind1
           INVALID KEY DISPLAY "RECORD IS ALREADY EXIST"
          END-WRITE.


         DELETE1.
            DISPLAY " ".
            DISPLAY "ENTER THE RECORD YOU WANT TO DELETE".
            ACCEPT fno1.
            DELETE indfile1
             INVALID KEY DISPLAY "  RECORD NOT EXIST"
            END-DELETE.
           


         UPDATE1.
            MOVE 'Y' TO REXIST.
            DISPLAY " ".
            DISPLAY "ENTER THE ROLL NO YOU WANT TO UPDATE".
            ACCEPT fno1.
            READ indfile1
             INVALID KEY MOVE 'N' TO REXIST
            END-READ.
            IF REXIST='N'
              DISPLAY "  RECORD NOT EXIST"
            ELSE
              DISPLAY "ENTER THE NAME YOU WANT TO UPDATE"
              ACCEPT fname
            END-IF.

            REWRITE fileind1
              INVALID KEY DISPLAY "  RECORD NOT READED"
            END-REWRITE.


         READ1.
          DISPLAY " ".
          DISPLAY "ENTER NO".
          ACCEPT FNO1.
           READ indfile1
              INVALID KEY MOVE 'N' TO REXIST
           END-READ.
            IF REXIST='N'
              DISPLAY "  RECORD NOT EXIST"
            ELSE
              DISPLAY "ROLL NO: " fno
              DISPLAY "NAME :" fname
            END-IF.
************************************************************
      *MENU::
      *     ENTER YOUR CHOICE
      *     1=ADD RECORD
      *     2=DELETE RECORD
      *     3=UPDATE RECORD
      *     4=READ PERTICULAR RECORD
      *     0=EXIT
      *1
      *ENTER THE ROLL NO
      *1
      *ENTER THE ROLL NAME
      *JOLLY

      *MENU::
      *     ENTER YOUR CHOICE
      *     1=ADD RECORD
      *     2=DELETE RECORD
      *     3=UPDATE RECORD
      *     4=READ PERTICULAR RECORD
      *     0=EXIT
      *3
      *ENTER THE ROLL NO YOU WANT TO UPDATE
      *2
      *ENTER THE NAME YOU WANT TO UPDATE
      *HITU

      *MENU::
      *     ENTER YOUR CHOICE
      *     1=ADD RECORD
      *     2=DELETE RECORD
      *     3=UPDATE RECORD
      *     4=READ PERTICULAR RECORD
      *     0=EXIT
      *2
      *ENTER THE RECORD YOU WANT TO DELETE
      *2

      *MENU::
      *     ENTER YOUR CHOICE
      *     1=ADD RECORD
      *     2=DELETE RECORD
      *     3=UPDATE RECORD
      *     4=READ PERTICULAR RECORD
      *     0=EXIT
      *2
      *ENTER NO 
      *2
      *RECORD NOT EXIST

************************************************************
  
Share: 



Caitlin Brown
Caitlin Brown author of PROGRAM TO CREATE THE RELATIVE FILE AND ADD RECORD,UPDETE RECORD,DELETE PERTICULAR RECORD AND READ THE SPCIFY RECORD is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!