Example 6–23 Creating a Line Sequential File
By default, Compaq COBOL assumes sequential access mode when the line
sequential organization is specified. (See Example 6–23.)
Statements for Sequential and Line Sequential File Processing
Processing a sequential or line sequential file involves the following:
1. Opening the file
2. Processing the file with valid I/O statements
3. Closing the file
Table 6–3 lists the valid I/O statements for sequential files, and Table 6–4 lists
the valid I/O statements for line sequential files. Both tables illustrate the
following relationships:
•
Organization determines valid access modes.
•
Organization and access mode determine valid open modes.
•
All three (organization, access, and open mode) enable or disable I/O
statements.
Table 6–3 Valid I/O Statements for Sequential Files
File
Access
Organization
Mode
SEQUENTIAL SEQUENTIAL
Writing a Sequential File
Each WRITE statement appends a logical record to the end of an output file,
thereby creating an entirely new record in the file. The WRITE statement
appends records to files that are OPEN for the following modes:
IDENTIFICATION DIVISION.
PROGRAM-ID. LINESEQ01.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT LINESEQ-FILE ASSIGN TO "LINESEQ.DAT".
DATA DIVISION.
FILE SECTION.
FD LINESEQ-FILE.
01 LINESEQ-RECORD
PIC X(25).
PROCEDURE DIVISION.
A000-BEGIN.
OPEN OUTPUT LINESEQ-FILE.
CLOSE LINESEQ-FILE.
STOP RUN.
Statement
INPUT
READ
Yes
REWRITE
No
WRITE
No
UNLOCK
Yes
Processing Files and Records
6.3 Creating and Processing Files
Open Mode
OUTPUT I/O
EXTEND
No
Yes
No
No
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Processing Files and Records 6–27
Need help?
Do you have a question about the COBOL AAQ2G1FTK and is the answer not in the manual?