COBOL/400 Language Help

Format 2 (Indexed and Relative Files)

Description
The WRITE statement releases a logical record for an output or input/output file. When the WRITE statement is executed, the associated indexed and relative files must be open in OUTPUT, I-O, or EXTEND mode.
Format 2 (Indexed and Relative Files)
 
->->---WRITE record-name-1--*-----------------*------------->
                          *FROM identifier-1*
 
->----*--------------------------------*------------------->
     *-FORMAT-*----*-*-identifier-2-*-*
              *-IS-* *-literal-1----*
 
->----*-----------------------------------------*---------->
     *-INVALID--*-----*-imperative-statement-1-*
                *-KEY-*
 
->----*--------------------------------------*-*---------*-><-
     *NOT INVALID*---*imperative-statement-2* *END-WRITE*
                 *KEY*
 

identifier-2 or literal-1

Literal-1 or identifier-1 specifies the name of the record format to use for the write operation. If you specify literal-1 it must be uppercase and 10 characters or less in length. If you specify identifier-1, it must be a character-string of 10 characters or less, and it must name one of the following:

A value of all blanks is treated as though the FORMAT phrase were not specified.

INVALID KEY Phrase

The INVALID KEY phrase must be specified for files for which there is not an appropriate EXCEPTION/ERROR procedure.

When an attempt is made to write beyond the externally defined boundaries of the file, WRITE statement execution is unsuccessful and an EXCEPTION/ERROR condition exists.

For indexed files, an invalid key condition is caused by any of the following:

For relative files, an invalid key condition is caused by any of the following:

When the invalid key condition is recognized, WRITE statement execution is unsuccessful, and the contents of the record are unaffected. Program execution proceeds according to the rules described under invalid key condition.

KEY, NOT INVALID, or imperative-statement-2

If you specify the NOT INVALID KEY phrase and a valid key condition exists at the end of the execution of the WRITE statement, control passes to the imperative statement associated with this phrase.

Click here for further information about the invalid key condition.


[ Top of Page | Previous Page | Next Page | Table of Contents ]