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

Data record clause - and code-set clause, DATA RECORD CLAUSE: The DATA...

DATA RECORD CLAUSE: The DATA RECORD clause, documents the record names defined for the file. For illustration, DATA RECORDS ARE REC-1, REC-2, REC-3 that means there are 3diffe

Illustration of simple sort verb, Illustration of simple sort verb: Il...

Illustration of simple sort verb: Illustration: Suppose that we have a card file with the following records description in the data division. The names of the work fil

Program for inventory , PROGRAM FOR INVENTORY  We have to write a progr...

PROGRAM FOR INVENTORY  We have to write a program to update the inventory file. Consider 2 files,viz, invfile an tranfile. Invfile has 3 fields pno,name,qty. Tranfile has 3 fil

Cobol words, COBOL Words: The COBOL word can be formed by using the ch...

COBOL Words: The COBOL word can be formed by using the characters as shown below: 0-9 A-Z (a-z) - (hyphen) The rules below should be hold in forming the COBOL words.

Program for output file that can be our vsam file, We have input file, reco...

We have input file, record layout is EMP ID (6 char) , EMP NAME (20 char), Designation (3 char),Salary (5 digit) Base Branch (10char) Grade (3 Alphanumeric). This is the input f

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)

Special-names - configuration section, SPECIAL-NAMES: This paragraph i...

SPECIAL-NAMES: This paragraph is used to associate some hardware names to the user-specified mnemonic names. This paragraph is elective in all compilers. The format of this pa

Example of condition names, Example of condition names: The illustrati...

Example of condition names: The illustration below is of the use of the condition names  77  MARITAL-STATUS     PIC    9   88  SINGLE    VALUE    IS     ZERO   88  MA

On size error option, ON SIZE ERROR OPTION:   If after an arithmetic ...

ON SIZE ERROR OPTION:   If after an arithmetic expression, the result exceeds the highest value which can be accommodated in the result; this error is termed as size error. T

Use of evaluate statement, Evaluate is like a case statement & Evaluate  s...

Evaluate is like a case statement & Evaluate  stamenet can be used to replace nested Ifs. The difference b/w EVALUATE and case is that there is no 'break' is required for EVALUATE

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