menu driven sequential file


       IDENTIFICATION DIVISION.
       PROGRAM-ID."MENU DRIVEN PROGRAM".
       AUTHOR."KUNAL"
       DATE-WRITTEN."15/02/12".
       DATE-COMPILED."15/02/12".
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. M8.
       OBJECT-COMPUTER. M8.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
       SELECT BOOK ASSIGN TO DISK
       ORGANIZATION IS SEQUENTIAL
       ACCESS MODE IS SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD BOOK
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "BOOK.DAT".
       01 BOOK-REC.
           02 B-NAME  PIC X(20).
  02 B-AUT PIC X(15).
           02 B-QTY PIC 9(2).
  02 PRIC PIC 9(5).
       WORKING-STORAGE SECTION.
       77 CH1 PIC 9.
       77 B-PRICE PIC 9(5).
       77 ROW1 PIC 99.
       77 NAME1 PIC X(20).
       77 NAME PIC X(20).
       77 AUT1 PIC X(15).
       77 QTY1 PIC 9(2).
       77 PRICE1 PIC 9(5).
       SCREEN SECTION.
         01 CLEAR-SCREEN.
  02 BLANK SCREEN.
          
       PROCEDURE DIVISION.
           MENU-PARA.
           DISPLAY " ".
  DISPLAY "PRESS..1.INSERT 2.UPDATE 3.DISPLAY 4.EXIT".
  ACCEPT CH1.
  IF CH1 = 1 GO TO INSERT-PARA ELSE
  IF CH1 = 2 GO TO EDIT-PARA ELSE
  IF CH1 = 3 GO TO DISP-PARA ELSE
  IF CH1 = 4 GO TO EXIT-PARA.
  END-PARA.
  INSERT-PARA.
           OPEN EXTEND BOOK.
           DISPLAY "Enter title of book".
  ACCEPT B-NAME.
  DISPLAY "Enter author of book:".
  ACCEPT B-AUT.
  DISPLAY "Enter quantity of book:".
  ACCEPT B-QTY.
  DISPLAY "Enter price of book:".
  ACCEPT B-PRICE.
  COMPUTE PRIC = B-PRICE * B-QTY.
  WRITE BOOK-REC.
  CLOSE BOOK.
  GO TO MENU-PARA.
  EDIT-PARA.
   DISPLAY "Enter title of book for editing".
   ACCEPT NAME.
   OPEN I-O BOOK.
   PARA-3.
    READ BOOK AT END GO TO LAST-PARA.
    IF NAME = B-NAME
    DISPLAY "Enter title,author,quantity & price of book"
    ACCEPT NAME1
    ACCEPT AUT1
    ACCEPT QTY1
    ACCEPT PRICE1
    MOVE NAME1 TO B-NAME
    MOVE AUT1 TO B-AUT
    MOVE QTY1 TO B-QTY
    COMPUTE PRIC = PRICE1 * QTY1
    REWRITE BOOK-REC ELSE GO TO PARA-3.
    LAST-PARA.
    CLOSE BOOK.
    GO TO MENU-PARA.
  DISP-PARA.
   DISPLAY CLEAR-SCREEN.
   OPEN INPUT BOOK.
    DISPLAY(1,1) "---------------------------------------------------------".
    DISPLAY(2,2) "TITLE".
    DISPLAY(2,20) "AUTHOR".
    DISPLAY(2,40) "QUANTITY".
    DISPLAY(2,50) "PRICE".
    DISPLAY(3,1) "---------------------------------------------------------".
    MOVE 4 TO ROW1.
   READ-PARA.
    READ BOOK AT END GO TO L-PARA.
    DISPLAY(ROW1,2) B-NAME.
    DISPLAY(ROW1,20) B-AUT.
    DISPLAY(ROW1,40) B-QTY.
    DISPLAY(ROW1,50) PRIC.
    ADD 1 TO ROW1.
    GO TO READ-PARA.
    L-PARA.
    CLOSE BOOK.
    GO TO MENU-PARA.
    EXIT-PARA.
    STOP RUN.  
Previous
Next Post »