Writing records to a Sequential File


ACCEPT, DISPLAY,  WRITE, PERFORM..UNTIL

Introduction

Using Seqread.Cbl as a starting point, write a program called SeqWrite.Cbl to accept student records from the user and write them to a file (MyStudents.Dat).  The program should keep accepting records from the user until spaces are entered instead of a record (i.e.the Enter key is pressed without having entered any data).  No error checking on the data entered is required.

The program should prompt the user for each record and should provide a template to make it more easy to enter the data correctly (see Example Run below).
 

Output File

The student records accepted from the user must be written to a file.  Each record will have the following description.
 
Field
Type
Length
Value
Student Id
9
7
0-9999999
Student Name
.
.
Group
Surname
X
8
-
Initials
X
2
-
Gender
X
1
M/F
 

Further Work

Add code to your program to read the file you have just created and display the records.  Display the records as shown in the example run below

Example Program

When you have written your program and have compiled it and have it working correctly, you may wish to compare it with this sample solution.
 
WARNING
Do not look at the solution until you have finished your own or at least have made a substantial effort to complete it.
 
 

Back to COBOL Exercises page To COBOL Exercises Please fill out our evaluation form Evaluation Form Search the CSIS Web Site Search CSIS Web Site
Selectable Site Contents


Last updated :March 1997
e-mail : CSISwebeditor@ul.ie