Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Open modes and types of processing (sequential processing)

The various language elements available for use in a COBOL program can be sequential files to be

  • created,

  • read,

  • extended (by adding new records at the end of the file), and

  • updated (by making changes in existing records)

The individual I-O statements that may be used in the program to process a given file are determined by its open mode, which is specified in the OPEN statement.

OPEN OUTPUT

WRITE is permitted as an I-O statement in the following format:

WRITE... [FROM...] [{BEFORE | AFTER} ...]
         [AT END-OF-PAGE...]
         [NOT AT END-OF-PAGE...]
         [END-WRITE]

In this mode, it is possible to create new sequential files (on tape or disk). Each WRITE statement places one record in the file. See section "Line-sequential files" for notes on the creation of print files.


OPEN INPUT or
OPEN INPUT...REVERSED

READ is permitted as an I-O statement in the following format:

READ...[NEXT] 
       [INTO...] 
       [AT END...] 
       [NOT AT END...] 
       [END-READ]

In this mode sequential files can be read (from disk or tape). Each READ statement reads one record from the file. 

The OPEN INPUT...REVERSED phrase causes the records to be read in reversed order, beginning with the last record in the file.

OPEN EXTEND

WRITE is permitted as an I-O statement in the following format:

 

WRITE... [FROM...] [{BEFORE | AFTER} ...]
         [AT END-OF-PAGE...]
         [NOT AT END-OF-PAGE...]
         [END-WRITE]

In this mode, new records can be appended to the end of a sequential file. Already existing records are not overwritten.

OPEN I-O

READ and REWRITE are permitted as I-O statements in the following formats:

READ   [NEXT]
       [INTO...]
       [AT END...]
       [NOT AT END...]
       [END-READ]

REWRITE...[FROM...]
          [END-REWRITE]

In this mode, records of a sequentially organized disk file can be retrieved (READ), updated by the program and subsequently written back (REWRITE) to disk. It must be noted, however, that a record can only be written back with REWRITE if

  • it was previously retrieved by a successful READ statement, and

  • its record length was not changed during the update.

The OPEN I-O phrase is only permitted for disk files.