The WRITE statement releases a logical record to an output or input-output file. It can also position lines vertically on a logical page.
1 – 1format_sequential
The WRITE statement releases a logical record to an output or input-output file. It can also position lines vertically on a logical page. Format 1 - WRITE rec-name [ FROM src-item ] [ ALLOWING NO OTHERS ] [ { advance-num [ LINE ] } ] [ { BEFORE } { [ LINES ] } ] [ { AFTER } ADVANCING { top-name } ] [ { PAGE } ] [ AT { END-OF-PAGE } stment ] [ { EOP } ] [ NOT AT { END-OF-PAGE } stment ] [ { EOP } ] [ END-WRITE ]
1.1 – rec-name
is the name of a logical record described in the Data Division File Section. It cannot be qualified. The logical record cannot be in a sort-merge file description entry.
1.2 – src-item
is the identifier of the data item that contains the data. If src-item is a function-identifier, it must reference an alphanumeric function.
1.3 – advance-num
is an integer or the identifier of an unsigned data item described as an integer. Its value can be zero.
1.4 – top-name
is a mnemonic-name equated to "C01" in the SPECIAL-NAMES paragraph of the Environment Division. It represents top-of-page and is equivalent to the PAGE phrase.
1.5 – stment
is an imperative statement.
2 – 2format_relative_indexed
The WRITE statement releases a logical record to an output or input-output file. It can also position lines vertically on a logical page. Format 2 - WRITE rec-name [ FROM src-item ] [ ALLOWING NO OTHERS ] [ INVALID KEY stment ] [ NOT INVALID KEY stment ] [ END-WRITE ]
2.1 – rec-name
is the name of a logical record described in the Data Division File Section. It cannot be qualified. The logical record cannot be in a sort-merge file description entry.
2.2 – src-item
is the identifier of the data item that contains the data. If src-item is a function-identifier, it must reference an alphanumeric function.
2.3 – stment
is an imperative statement.