Program for sequential file creation & rewriting , COBOL Programming

Assignment Help:

Program for Sequential File Creation & Rewriting 

We have to write a program to create a Length file with just two fields: l (Length) and l-c (Length-Code). Add a few records. Change the record with l-c =1 as l-c=5. Use sequential file I-O.

 identification division.

  program- id.

  environment division.

  input-output section.

  file-control.

    select len- file assign to disk.

  data division.

  file section.

  fd len- file

    label records are standard

    value of file- id is "len.dat".

01 len-rec.

  02   l   pic 9(2).

  02   l-c pic 9(1).

working-storage section.

01   ans pic x value space.

01   eof pic x value space.

screen section.

01  cls-screen. 

  02  blank screen.

01  get-screen.

  02  line 3 column 5 value "Length = ".

  02   column plus 3 pic 9(2) to l auto bell.

  02  line 5 column 5 value "Code = ".

  02  column plus 3 pic 9 to l-c bell reverse-video.

procedure division.

p-1.

  open output len-file.

  perform g-w-para until ans = 'n' or 'N'.

  close len- file.

  open i-o len- file.

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

  perform rewrite-para until eof = 'y'.

  close len- file.

  stop run.

g-w-para.

  display cls-screen.

  display get-screen.

  accept get-screen.

  write len-rec.

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

  accept ans.

rewrite-para.

  if l-c = 1 

    move 5 to l-c

    rewrite len-rec.

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


Related Discussions:- Program for sequential file creation & rewriting

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

Write statement, WRITE STATEMENT: The WRITE Statement verb releases a r...

WRITE STATEMENT: The WRITE Statement verb releases a record in an output file. The syntax for the WRITE statement can be unlike depending on the output device and the medium us

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 ]

Delete statement, DELETE STATEMENT: The format of the delete statement...

DELETE STATEMENT: The format of the delete statement is as shown below: DELETE   file-name RECORD   [  ;   INVALID   KEY  imperative-statement  ] Whenever the ACCESS MOD

Perform with varying option, PERFORM WITH VARYING OPTION: The format i...

PERFORM WITH VARYING OPTION: The format is as shown below:

Sequential files with the variable-length records, SEQUENTIAL FILES WITH TH...

SEQUENTIAL FILES WITH THE VARIABLE-LENGTH RECORDS: The Magnetic - tape or disk files can hold variable-length records. In this situation the file can have records with various

Illustration of renames clause, Illustration of Renames clause: In the...

Illustration of Renames clause: In the illustration, PAT-OTHER-THAN-BASIC will become a fresh group consisting of DEARNESS-ALLOWANCE, HOUSE-RENT & MTHLY-INCENTIVE. Keep in min

Declarative and file status clause, DECLARATIVE and FILE STATUS Clause: ...

DECLARATIVE and FILE STATUS Clause: The input-output exception condition in the situation of a direct access files can be handled by a declarative procedure in a manner simila

File-control - input-output section, FILE-CONTROL: The FILE-CONTROL pa...

FILE-CONTROL: The FILE-CONTROL paragraph names each and every file and identifies the first medium through file control entries. The basic format of a file control entry is gi

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