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
TO WRITE A QUADRATIC EQN ROOTS ARE COMPLEX IN COBOL PROGRAM

Literals: The actual values can too appear in a program. These values are termed as literals. For illustration, the statement MOVE 0 TO TOTAL indicates that the value zero wil

Point Location: The position of the decimal point is the other characteristic which can be specified in the case of the numeric data items. If the position is not specified, t

CONDITION - COBOL Programming: The condition is an entity which at one point of time can have only one of the two values - true or false. As we already know that, the IF verb

REDEFINES CLAUSE: At times it may be found that two or more storage regions defined in the DATA DIVISION are not in use concurrently. In such situations only one storage regio

Size: The number of characters or digits needed to store the data item in the memory in termed as the Size of the data item. All the 4 general characteristics explained can

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

START STATEMENT: The START statement places the files to the initial logical record whose record key satisfies the condition specified by the KEY phrase. The access mode shoul

Data Division: The Data Division is a part of the COBOL program where every data item processed by the program is described. It is very important to note that unless a data

OCCURS CLAUSE - PROGRAM: We have to write a program to demonstrate the occurs clause. Get names of the students and show them on the screen.  identification division.