Program for master file maintenance , COBOL Programming

Assignment Help:

PROGRAM FOR MASTER FILE MAINTENANCE:

We have to write a program to keep the stu-file for which a record has just 2 fields,viz., rno(Roll Number) and name(Student Name). Give the provisions to add, modify, delete the records in the file

identification division.

  program- id.

  environment division.

  input-output section.

  file-control.

    select stu- file assign to disk

    organization is indexed

    access mode is random

    record key is rno

    file status is fs.

  data division.

  file section.

  fd stu- file

    label records are standard

    value of file- id is "stu.dat".

  01 stu-rec.

    02 rno pic 9(3).

    02 name pic x(20).

working-storage section.

01 fs pic x(2) value spaces.

01 ans pic x value space.  

01 ch pic 9 value 0.

procedure division.  

open-para.

  open i-o stu-file.

  if fs = "30"

      open output stu-file

      close stu-file

      open i-o stu-file.

  p-1.

    display(1 1) erase.

    display(3 5) "Main Menu".

    display(5 5) "1 to Add".

    display(7 5) "2 to Modify".

    display(9 5) "3 to Delete".

    display(11 5) "4 to Exit".

    display(13 5) "Your Choice [1..4] : ".

    accept ch.

    if ch < 0 or ch > 4 go to p-1.

    go to add-para modi-para del-para exit-para

      depending on ch.

  add-para.

    display(1 1) erase.

    display(3 5) "Rno : ".

    accept rno.

    display(5 5) "Name : ".

    accept name.

    write stu-rec invalid key display(15 5) "Error!".

    display(20 5) "Continue Add Records [y/n] : ".

    accept ans.

    if ans = "y" go to add-para else go to p-1.

  modi-para.

    display(1 1) erase.

    display(3 5) "Enter Roll no to Modify".

    accept rno.

    read stu- file key is rno 

      invalid key display(13 5) "No Record Found"

            go to c-para.

    display(5 5) "Rno = " rno.

    display(7 5) "Name = " name.

    display(9 5) "Sure to Modify [y/n] : ".

    accept ans.

    if ans  = 'y'

      display(1 1) erase

      display(5 5) "Name : "

      accept name

            rewrite stu-rec.

  c-para.

    display(15 5) "Continue Modification [y/n] : ".

    accept ans.

    if ans = 'y' go to modi-para else go to p-1.

  del-para.

          display(1 1) erase.

    display(3 5) "Enter Roll no to Delete".

    accept rno.

    read stu- file key is rno 

    invalid key display(13 5) "No Record Found"

          go to c-para1.

  display(5 5) "Rno = " rno.

  display(7 5) "Name = " name.

  display(9 5) "Sure to Delete [y/n] : ".

  accept ans.

  if ans  = 'y'

    delete stu- file record.

c-para1.

  display(15 5) "Continue  Deletion  [y/n] : ".

  accept ans.

  if ans = 'y' go to del-para else go to p-1.

exit-para.

  close stu-file.

  stop run.


Related Discussions:- Program for master file maintenance

File-control paragraph for the relative files, FILE-CONTROL paragraph for t...

FILE-CONTROL paragraph for the relative files: The normal format for the SELECT clause for a relative file is as shown below. SELECT  file-name  ASSIGN  TO  implementor-nam

File-control - input-output section, FILE-CONTROL: The FILE-CONTROL pa...

FILE-CONTROL: The FILE-CONTROL paragraph names each and every file and identifies the first medium through file control entries. The basic format of a file control entry is gi

Example of write statement, Example of Write statement: Illustration:...

Example of Write statement: Illustration: (i) WRITE TRANS-RECORD AFTER ADVANCING 3 LINES. This WRITE statement specified that the TRANS-RECORD is a record name of a fi

Program for perform - thru, PROGRAM FOR PERFORM - THRU: We have to wri...

PROGRAM FOR PERFORM - THRU: We have to write a program to elaborate PERFORM ...THRU statement Identification division. Program- id.  Perfthru. Environment division.

Perform with until option, PERFORM WITH UNTIL OPTION: The format is as...

PERFORM WITH UNTIL OPTION: The format is as shown below: Illustration:  A) Perform p-3 until i > 5. Here p-3 will be executed whenever i B)  Perform p-2 thru

Transaction file - file updation, Transaction file : A transaction file...

Transaction file : A transaction file is a file which contains new records those changes to old records which are used to update the master file. The problem of file updatio

Numeric literals - cobol program, Numeric -   Literals : The numeri...

Numeric -   Literals : The numeric literal can be created with the help of digits only. It can have a sign (+ or -) and can also have a decimal point. If no sign is specifi

Occurs clause, Occurs Clause: Let us establish tables with the help of...

Occurs Clause: Let us establish tables with the help of an illustration. Assume that there are ten different types of income-tax rates that are read from some input medium and

Different data types available in cobol, Data types available in COBOL are ...

Data types available in COBOL are given below Alpha-numeric (X), numeric (9), alphabetic (A)

Open statement - sequential files, OPEN statement: We know that the pr...

OPEN statement: We know that the processing of a file should start with the execution of an OPEN statement. The file can be opened in any one of the 4 open modes - INPUT, OUTP

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd