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

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

Program using occurs clause, PROGRAM USING OCCURS CLAUSE: We have to w...

PROGRAM USING OCCURS CLAUSE: We have to write a simple program to demonstrate Occurs Clause. Get the employee details for 3 persons and compute the total salary. identifica

ACCEPT VERB, When using the accept verb in cobol is it possible to assign s...

When using the accept verb in cobol is it possible to assign something other then "SYSIN" for a ddname?

Picture specification - picture clause, PICTURE specification: The siz...

PICTURE specification: The size of a group item is equivalent to the total of the sizes of all the subordinate elementary items. The group item class is alphanumeric. The i

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,

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

Renames clause, RENAMES CLAUSE: At times re-grouping of an elementary ...

RENAMES CLAUSE: At times re-grouping of an elementary data items in a record may be essential so that they can belong to the original as well as to the latest group. This is o

Comparison of the numeric operand with nonnumeric operand, Comparison of th...

Comparison of the Numeric Operand with Nonnumeric Operand: The numeric operand can be compared to the nonnumeric operand subject to the restrictions which are as follows.

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

Numeric literals - cobol program, Numeric -   Literals : The numeri...

Numeric -   Literals : The numeric literal can be created with the help of digits only. It can have a sign (+ or -) and can also have a decimal point. If no sign is specifi

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