Sequential Files
When an attempt is made to write beyond the externally defined boundaries of the file, the processing of the WRITE statement is unsuccessful and an EXCEPTION/ERROR condition exists. The contents of record-name are unaffected. Processing then follows the rules for error handling as described under USE Statement Programming Notes.
- The standard ending volume label procedure is run.
- A volume switch occurs.
- The standard beginning volume label procedure is run.
No indication that an end-of-volume has occurred is returned to the program.
WRITE Statement - Format 1 - Sequential Files >>-WRITE--record-name-1--+--------------------+-----------------> '-FROM--identifier-1-' >--+------------------------------------------------------------+--> '-+-BEFORE-+--+-----------+--+-+-identifier-2-+--+-------+-+-' '-AFTER--' '-ADVANCING-' | '-integer-1----' +-LINE--+ | | '-LINES-' | +-mnemonic-name-1-------------+ '-PAGE------------------------' >--+------------------------------------+-----------------------> | (1) | '-NULL-MAP------+----+--identifier-9-' '-IS-' >--+-------------------------------------------------+----------> '-+----+--+-END-OF-PAGE-+--imperative-statement-1-' '-AT-' '-EOP---------' >--+------------------------------------------------------+-----> '-NOT--+----+--+-END-OF-PAGE-+--imperative-statement-2-' '-AT-' '-EOP---------' >--+-----------+----------------------------------------------->< '-END-WRITE-'
- IBM® Extension.
- record-name-1
- Must
be defined in a Data Division FD entry. Record-name-1 may be qualified.
It must not be associated with a sort or merge file.
You must ensure that the size of an OCCURS DEPENDING ON (ODO) array has been set to a valid numeric value before doing a WRITE of a record containing the ODO array.
IBM ExtensionIBM Extension Record-name-1 can be a floating-point data item. End of IBM Extension
End of IBM ExtensionIBM ExtensionIBM Extension Record-name-1 can define a DBCS data item. Identifier-1 must be a DBCS data-item if record-name-1 is a DBCS data item. End of IBM Extension
End of IBM Extension - FROM
- When FROM is specified, the result is the same as:
MOVE identifier-1 TO record-name-1 WRITE record-name-1The move is performed according to the rules of the MOVE statement, without the CORRESPONDING phrase.
After the WRITE statement is executed, the information is still available in identifier-1, even though it may not be in record-name-1. (See INTO/FROM Identifier Phrase.)
- identifier-1
- Must be an alphanumeric or numeric-edited data item. Data is transferred
from this field to the receiving fields.
Identifier-1 can be the name of an alphanumeric or DBCS function identifier.
IBM ExtensionIBM Extension Identifier-1 can be a floating-point or date-time data item. End of IBM Extension
End of IBM Extension - identifier-2
- Must be an integer data item.
The maximum record size for the file is established at the time the file is created, and cannot subsequently be changed.
Record-name-1 and identifier-1 must not refer to the same storage area.
- The associated file is named in a SAME RECORD AREA clause (in which case, the record is also available as a record of the other files named in the SAME RECORD AREA clause), or
- The WRITE statement is unsuccessful because of a boundary violation.
In either of these two cases, the record is still available in record-name-1.
The file position indicator is not affected by execution of the WRITE statement.
The number of character positions required to store the record in a file may or may not be the same as the number of character positions defined by the logical description of that record in the COBOL program. (See PICTURE Clause Editing and USAGE Clause.)
If the FILE STATUS clause is specified in the File-Control entry, the associated status key is updated when the WRITE statement is executed, whether or not execution is successful.
The WRITE statement cannot be executed for a sequential file opened in I-O mode.
