Sequential file creation and rewriting, COBOL Programming

SEQUENTIAL FILE CREATION AND REWRITING:

We have to write a program to create a student file with just two fields: sno i.e. Student Number and same i.e. Student Name. Add a few records. Modify the record with sno=1 assno=10. You can use sequential file I-O.

 identification division.

  program- id. s2.

  environment division.

  input-output section.

  file-control.

    select stu- file assign to disk

    organization is line sequential

    access mode is sequential

    file status is fs.

  data division.

  file section.

  fd stu- file

    label records are standard

    value of file- id is 'stu.dat'

                data record is stu-rec.

01  stu-rec.

    02  sno   pic 9(2).

    02  sname pic x(10).

  working-storage section.

01   ans pic x value space.

01   fs  pic x(2) value spaces.

01   eof pic x value space.

procedure division.

p-1.

  display(1 1) erase.

  open extend stu- file.

  perform g-w-para until ans = "n".

  close stu-file.

  open i-o stu-file.

       if fs = '30'

      open output stu-file

      close stu-file

      open i-o stu-file.

  read stu- file at end move 'y' to eof.

  perform rewrite-para until eof = 'y'.

  close stu-file.

  stop run.

g-w-para.

  display(1 1) erase.

  display(3 5) "Sno : ".

  accept sno.

  display(5 5) "Sname : ".

  accept sname.

  write stu-rec.

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

  accept ans.

rewrite-para.

  if sno="01"

    move 10 to sno

    rewrite stu-rec.

  read stu- file at end move 'y' to eof.

 

Posted Date: 10/18/2012 1:22:23 AM | Location : United States







Related Discussions:- Sequential file creation and rewriting, Assignment Help, Ask Question on Sequential file creation and rewriting, Get Answer, Expert's Help, Sequential file creation and rewriting Discussions

Write discussion on Sequential file creation and rewriting
Your posts are moderated
Related Questions
What is the difference between subscript and index

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 t

I need help with a COBOL programming assingment. I have started the program but I need help completing the program. I have 5 errors. Here is the question. 10. Suppose your company

Second form of Divide verb: The second form of this verb is as shown below: In this situation the identifier-1 or numeric- literal-1 will be divided by identifier-2 or

MULTI-DIMENSIONAL TABLES: The type of table which has been considered above is known as one-dimensional table. Whenever a table is such that each of its elements in turn is a

File- Section &Working-Storage Section: a) FILE SECTION: The FILE SECTION includes the explanation of all data items that must be read from or written onto some external

WRITE Statement:      The WRITE statement for a relative file has the format which is as shown below.          WRITE  record-name   [ FORM   identifier ]

WRITE statement: The WRITE statement for tape and sequential-disk files has the syntax shown below. WRITE            record-name      [  FROM    identifier   ] As a resu

Format for COBOL Programs: The COBOL is a high-level language. Therefore, a COBOL program can be executed on a computer for which a COBOL compiler exists. The compiler transla

Identification Division: The Identification Division is the first division of each and every COBOL source program. The paragraph PROGRAM-ID is necessary in most of the mac