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
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

Valid and Invalid Word - Cobol words: Valid Word             Invalid Word & Reason emp-sal                  -pay   ( it starts with a hyphen)  TOTAL MARK (blank space em

SPECIAL-NAMES: This paragraph is used to associate some hardware names to the user-specified mnemonic names. This paragraph is elective in all compilers. The format of this pa

Rules for apply for the condition name: The rules below apply for the condition name. (i) The Condition names should be explained at level 88. The level number starts in ma

NESTED IF STATEMENT:   The then and else statement of an IF statement can hold other IF statements. The involved IF statements in their turn may also hold other IF statements

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

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

PROGRAM FOR INDEXED SEQUENTIAL FILE CREATION (RANDOM MODE): We have to write a program to create an Indexed Sequential File in random mode for Student particulars. Suppose jus

DISPLAY STATEMENT:   The function of the DISPLAY statement is just opposite to that of the ACCEPT statement. It is used to display the low-volume results on the operator's co

Evaluate is like a case statement & Evaluate  stamenet can be used to replace nested Ifs. The difference b/w EVALUATE and case is that there is no 'break' is required for EVALUATE