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

Blank when zero - edit characters for numeric data, BLANK WHEN ZERO: ...

BLANK WHEN ZERO: BLANK WHEN ZERO is an editing clause that may be used along with a picture. This will set the whole data item to blanks of its value is equal to zero. Though,

Block size - file characteristics , Block Size: The normal practice is...

Block Size: The normal practice is to group a number of consecutive records to form that is termed as a block or a physical record. The number of records in a block is frequen

Subtract verb, SUBTRACT VERB: The SUBTRACT verb is used to subtract on...

SUBTRACT VERB: The SUBTRACT verb is used to subtract one, or the sum of two or more numbers from one or more numbers and to store the result. The form of the SUBTRACT verb

Negated simple condition, NEGATED SIMPLE CONDITION: Any of the easy co...

NEGATED SIMPLE CONDITION: Any of the easy condition explained can be preceded by the logical operator NOT. The consequence of placing the operator NOT before an easy condition

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

Compound condition, COMPOUND CONDITION: The two simple conditions can ...

COMPOUND CONDITION: The two simple conditions can be connected by the logical operators AND or OR to form a compound condition (also termed as combined condition). When two co

If- else statement - cobol programming, IF ... ELSE STATEMENT: We are ...

IF ... ELSE STATEMENT: We are familiar with an easy form of the IF statement. The common form of the IF statement is as shown below: Each of the statement-1 and statem

Write statement - relative files, WRITE Statement:      The WRITE stat...

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

Filler clause - cobol programming, FILLER CLAUSE: Consider the stateme...

FILLER CLAUSE: Consider the statements as shown below: 1)  01    f    pic     x(80)  value    all "-". This statement origins a line of 80 characters filled with "-"

Rules for occurs clause, RULES FOR OCCURS CLAUSE: The rules apply for ...

RULES FOR OCCURS CLAUSE: The rules apply for the OCCURS clause and the subscripts are as shown below. (1) The integer in the OCCURS clause should be a positive integer.

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