RPG/400 Help
*---------*---------------*-----------------*----------------*---------------*
| CODE | FACTOR 1 | FACTOR 2 | RESULT | INDICATORS |
| | | | FIELD | |
*---------*---------------*-----------------*----------------*---------------*
| UPDAT | | File name | Data | _ ER _ |
| | | | structure | |
*---------*---------------*-----------------*----------------*---------------*
The UPDAT operation modifies the last record retrieved for processing from
an update disk file or subfile. No other operation should be performed
on the file between the input operation that retrieved the record and the
UPDAT operation.
Factor 2 must contain the name of a file or record format to be
updated. A record format name in factor 2 is required with an
externally described file. The record format name must be the name of
the last record read from the file; otherwise, an error occurs. A
file name in factor 2 is required with a program described file.
The result field must contain a data structure name if factor 2 contains a
file name. The updated record is written directly from the data
structure to the file. The result field must be blank if factor 2
contains a record format name.
You can specify a resulting indicator in positions 56 and 57 to be set on
if the UPDAT operation is not completed successfully.
Remember the following when using the UPDAT operation:
- When a record format name is specified in factor 2, the current values in
the program for the fields in the record definition are used to modify the
record.
- If some but not all fields in a record are to be updated, use the output
specifications and not the UPDAT operation.
- Before UPDAT is issued to a file or record, a valid input operation with
lock (READ, READC, READE, READP, REDPE, CHAIN, or primary/secondary file) must
be issued to the same file or record. If the read operation returns
with an error condition or if it was read without locking, the record is not
locked and UPDAT cannot be issued. The record must be read again with
the default of blank in position 53 to specify a lock
request.
- Consecutive UPDAT operations to the same file or record are not
valid. Intervening successful read operations must be issued.
- Beware of using the UPDAT operation on primary or secondary files during
total calculations. At this stage in the RPG/400 cycle, the fields from
the current record (the record that is about to be processed) have not yet
been moved to the processing area. Therefore, the UPDAT operation
updates the current record with the fields from the preceding record.
Also, when the fields from the current record are moved to the processing
area, they are the fields that were updated from the preceding record.
- For multiple device files, specify a subfile record format in factor
2. The operation is processed for the program device identified in the
field specified in the ID entry of the file specifications continuation
line. (If there is no such entry, the device for the last successful
input operation is used.) This device must be the same one you
specified for the input operation that must precede the UPDAT
operation. You must not process input or output operations to other
devices in between the input and UPDAT operations. If you do, your
UPDAT operation will fail.
- For a display file which has multiple subfile record formats, you must not
process read-for-update operations to one subfile record in between the input
and UPDAT operations to another subfile in the same display file. If
you do, the UPDAT operation will fail.
[ Top of Page | Previous Page | Next Page | Table of Contents ]
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.