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

Structure of a cobol program, Structure of a COBOL Program: Every COBO...

Structure of a COBOL Program: Every COBOL program should have the 4 divisions in the order in which they are specified below: 1. Identification division 2. Environment D

Rules of redefines clause, RULES OF REDEFINES CLAUSE The rules shown be...

RULES OF REDEFINES CLAUSE The rules shown below govern the use of the REDEFINES clause: (i) The level-number of data-name-1 and data-name-2 should be identical. (ii) Exce

Declarative and file status clause, DECLARATIVE and FILE STATUS Clause: ...

DECLARATIVE and FILE STATUS Clause: The input-output exception condition in the situation of a direct access files can be handled by a declarative procedure in a manner simila

Program for renames clause, PROGRAM FOR RENAMES CLAUSE: identification...

PROGRAM FOR RENAMES CLAUSE: identification division. program- id. environment division. data division. working-storage section. 01 emp.      02 empdet.

Read statements - relative files, READ STATEMENTS: The common format f...

READ STATEMENTS: The common format for the read statements is as shown bellow. Format 1: READ file-name RECORD [ INTO   identifier ] [  ;  AT   END     imperative-s

Program for add corresponding, PROGRAM FOR ADD CORRESPONDING: We have ...

PROGRAM FOR ADD CORRESPONDING: We have to write a simple program to demonstrate Add Corresponding.   identification division.   program- id.   environment division.

Program for condition names , PROGRAM FOR CONDITION NAMES: We have to ...

PROGRAM FOR CONDITION NAMES: We have to write a simple program to demonstrate Condition names usage.  identification division.   program- id.   environment division.

Example of move corresponding, Example of Move corresponding: Consider...

Example of Move corresponding: Consider the DATA DIVISION entries shown below. Suppose it is needed that the data stored in the 4 fields of the PAY_REC should be

Comparison of nonnumeric operands - relational condition, Comparison of Non...

Comparison of Nonnumeric Operands: A nonnumeric operand can be compared to the other nonnumeric operand according to the rules as shown below: (i) Fields of Equal Sizes:

Add verb, ADD VERB: The ADD Verb can be used to find the sum of two or ...

ADD VERB: The ADD Verb can be used to find the sum of two or more numbers and to store the sum.  The ADD verb takes any one of the two forms as shown below:

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