IBM Extension
IBM Extension

Transaction (Subfile) Format

The REWRITE statement is used to replace a subfile record that already exists in the subfile.

Read syntax diagramSkip visual syntax diagram
REWRITE Statement - Format 2 - Transaction (Subfile)

>>-REWRITE SUBFILE--record-name-1--+--------------------+------->
                                   '-FROM--identifier-1-'   

>--+----------------------------------+------------------------->
   '-FORMAT--+----+--+-identifier-2-+-'   
             '-IS-'  '-literal-1----'     

>--+------------------------------------+----------------------->
   '-TERMINAL--+----+--+-identifier-3-+-'   
               '-IS-'  '-literal-2----'     

>--+---------------------------------------+-------------------->
   '-+-INDICATOR--+--+-----+--identifier-4-'   
     +-INDICATORS-+  +-IS--+                   
     '-INDIC------'  '-ARE-'                   

>--+------------------------------------------+----------------->
   '-INVALID--+-----+--imperative-statement-1-'   
              '-KEY-'                             

>--+----------------------------------------------+------------->
   '-NOT INVALID--+-----+--imperative-statement-2-'   
                  '-KEY-'                             

>--+-------------+---------------------------------------------><
   '-END-REWRITE-'   

The number of character positions in the record referenced by record-name-1 must be equal to the number of character positions in the record being replaced. A successful read operation on the record must be done prior to the rewrite operation. The record replaced in the subfile is that record accessed by the previous read operation.
FORMAT Phrase
Multiple data records, each with a different format, can be concurrently active for a Transaction file. If the FORMAT phrase is specified, it must specify a valid format name that is defined to the system, and the I-O operation must be performed on a data record of the same format. If the format is an invalid name or if it does not exist, the FILE STATUS data item, if specified, is set to a value of 9K and the contents of the record area are undefined.
Note:
  1. The record format specified in the FORMAT phrase must be the record format accessed on the previous read operation.
  2. Literal-1 or the contents of identifier-2 must be the name of the subfile format accessed on the previous READ.
TERMINAL Phrase
The TERMINAL phrase indicates which program device’s subfile is to have a record rewritten. If the TERMINAL phrase is specified, literal-2 or identifier-3 must refer to a workstation that has been acquired by the Transaction file. If literal-2 or identifier-3 contains blanks, the TERMINAL phrase has no effect. The program device specified by the TERMINAL phrase must have been acquired, either explicitly or implicitly, and must have a subfile associated with the device.

Literal-2 or identifier-3 must be a valid program device name. Literal-2, if specified, must be nonnumeric and 10 characters or less. Identifier-3, if specified, must refer to an alphanumeric data item, 10 characters or less in length.

If the TERMINAL phrase is omitted from a Transaction file that has acquired multiple program devices, the subfile used is the subfile associated with the last program device from which a READ of the Transaction file was attempted.

The REWRITE statement cannot be used for communications devices. If the REWRITE statement is used for a communications device, the operation fails and a file status of 90 is set.

INDICATOR Phrase, INDICATORS Phrase, INDIC Phrase
Specifies which indicators are to be used when a data record is rewritten. Indicators can be used to pass information about the data record and how it was entered into the program.

For detailed information on the INDICATORS phrase, refer to Using Indicators with Transaction Files in the IBM® Rational® Development Studio for i: ILE COBOL Programmer's Guide .

Identifier-4 must be either an elementary Boolean data item specified without the OCCURS clause or a group item that has elementary Boolean data items subordinate to it.

INVALID KEY Phrase
If, at the time of the rewrite operation, the RELATIVE KEY data item contains a value that does not correspond to the relative record number of the record from the previous read operation, the INVALID KEY condition exists.

The INVALID KEY phrase should be specified for files for which an appropriate USE procedure is not specified. Undesirable results may occur if the INVALID KEY phrase is not specified, and no USE procedure is specified.

NOT INVALID KEY Phrase
After the successful completion of a REWRITE statement with the NOT INVALID KEY phrase, control transfers to the imperative statement associated with the phrase.
END-REWRITE Phrase
This explicit scope terminator serves to delimit the scope of the REWRITE statement. END-REWRITE permits a conditional REWRITE statement to be nested in another conditional statement. END-REWRITE may also be used with an imperative REWRITE statement. For more information, see Delimited Scope Statements.
End of IBM Extension
End of IBM Extension