Sequential file creation and rewriting, COBOL Programming

Assignment Help:

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.

 


Related Discussions:- Sequential file creation and rewriting

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

Character set - cobol programming, Character Set: To study any languag...

Character Set: To study any language, first one should know the alphabets of the language and they are termed as character set in general. There are 50 different characters in

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

Read statement, READ STATEMENT: The aim of this verb is to make availa...

READ STATEMENT: The aim of this verb is to make available the next logical record from the input file. It is important to note the meaning of the "next" logical record in the

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

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

Illustration of the abbreviation - compound condition, Illustration of the ...

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

Example of if- else statement, Example of If- else statement Illustrat...

Example of If- else statement Illustration:   IF   QUANTITY IS NUMERIC AND QUANTITY IS POSITIVE          MOVE ZERO TO ERROR-CODE. COMPUTE SALES VALUE=QUANTITY*RATE

Illustration of perform with varying option, Illustration of Perform with v...

Illustration of Perform with varying option: A) Perform para-3 varying the k from 1 by 1 until k > 10. Here para-3 will be constantly executed 10 times (For k=1,2,3, .....1

Why 77 level used for, 77 level used for- It is Elementary level item. it C...

77 level used for- It is Elementary level item. it Cannot be subdivisions of other items or cannot be qualified, or they can be subdivided themselves.

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