Program for sequential file creation & rewriting , COBOL Programming

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.

Posted Date: 10/18/2012 1:22:54 AM | Location : United States







Related Discussions:- Program for sequential file creation & rewriting , Assignment Help, Ask Question on Program for sequential file creation & rewriting , Get Answer, Expert's Help, Program for sequential file creation & rewriting Discussions

Write discussion on Program for sequential file creation & rewriting
Your posts are moderated
Related Questions
Label Records / Disk Directory: The most important information stored in the header label is what is termed as the file title. In the situation of magnetic-disk files the labe

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.

Data Names and Identifiers:   The Data name provides reference to the storage space in the memory where the real value is stored. This value takes part in the operation whene

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

Concept of a two-dimensional table: Concept of a two-dimensional table can be easily extended to tables having three or more dimensions. The Handling of tables up to three dim

FILE STATUS clause: This clause has been involved in the above syntax for completeness. The ORGANIZATION, REVERSE, ACCESS and STATUS clause can be specified in any order.

PROGRAMS FOR REDEFINES CLAUSE: We have to write a simple program to explain the REDEFINES clause at 01 level. identification division. program- id. Redef. environment

calculate simple interest

File Activity: The file activity is a measure of the proportion of records processed during an update run. Therefore we define the activity ration as shown below. Activi

Non numeric: The nonnumeric literal is used in normal to output messages or headings. The Characters which are enclosed between " " constitute nonnumeric literal. The maximum