Program for master file maintenance , COBOL Programming

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.

Posted Date: 10/18/2012 2:06:45 AM | Location : United States







Related Discussions:- Program for master file maintenance , Assignment Help, Ask Question on Program for master file maintenance , Get Answer, Expert's Help, Program for master file maintenance Discussions

Write discussion on Program for master file maintenance
Your posts are moderated
Related Questions
OCCURS CLAUSE - PROGRAM: We have to write a program to demonstrate the occurs clause. Get names of the students and show them on the screen.  identification division.

INDEXED SEQUENTIAL FILES: In the indexed sequential files which are also known as indexed files, the records are stored in the sequence order generally in ascending order. In

UPDATING OF THE RELATIVE AND INDEXED FILES: The Sequential files are updated by creating a new master file from an existing old master file and a transaction file. Such an Upda

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

PROGRAM FOR PERFORM - VARYING: We have to write a program to elaborate PERFORM ...VARYING Identification division. Program- id. PerfVary. Environment division. Dat

Illustration of the abbreviation: A few illustration of the abbreviation are given below: Illustration: The compound condition  AMOUNT GREATER THAN 499 AND AMOUNT L

PROGRAM FOR SUBTRACT VERB: We have to write a simple program to elaborate the SUBTRACT verb. You can also use edit characters in the program. Identification division. Pr

Selection of file Organization: While designing a file, the programmer should select an appropriate association for a file. The order in which the choice is to be made is as s

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

PROCEDURE DIVISION statements for the indexed files: All the statements which are available for a relative file are also available for an indexed file. READ STTATEMENT :