Using CICS commands to update records

To update a record, you must first retrieve it using one of the file control read commands that specifies the UPDATE option. The record is identified in exactly the same way as for a direct read. In a KSDS or ESDS, the record may (as with a direct read) be accessed by way of a file definition that refers either to the base, or to a path defined to it. For files opened in RLS mode you can specify the NOSUSPEND option as well as the UPDATE option on an EXEC CICS® command to ensure that the request does not wait if the record is already locked by VSAM with an active lock.

After modification by the application program, the record is written back to the data set using the REWRITE command, which does not identify the record being rewritten. Within a unit of work, each REWRITE command should be associated with a previous READ UPDATE by a common keyword (TOKEN). You can have one READ UPDATE without a TOKEN outstanding at any one time. Attempts to perform multiple concurrent update requests within a unit of work, upon the same data set without the use of TOKENS, are prevented by CICS. If you want to release the string held by a READ UPDATE without rewriting or deleting the record, use the UNLOCK command. The UNLOCK command releases any CICS storage acquired for the READ command, and releases VSAM resources held by the READ command. If TOKEN is specified with the UNLOCK command, CICS attempts to match this with an outstanding READ UPDATE whose TOKEN has the same value. (For more explanation about the TOKEN option, see The TOKEN option.)

For both update and non-update commands, you must identify the record to be retrieved by the record identification field specified in the RIDFLD option. Immediately on completion of a READ UPDATE command, the RIDFLD data area is available for reuse by the application program.

A record retrieved as part of a browse operation can only be updated during the browse if the file is opened in RLS mode (see Updating and deleting records in a browse (VSAM RLS only)). For files opened in non-RLS mode, the application program must end the browse, read the desired record with a READ UPDATE command, and perform the update. Failure to end the browse before issuing the READ UPDATE command may cause a deadlock.

The record to be updated may (as in the case of a direct read) be read into an area of storage supplied by the application program or into storage set by CICS. For a READ UPDATE command, CICS SET storage remains valid until the next REWRITE, UNLOCK, DELETE without RIDFLD, or SYNCPOINT command, whichever is encountered first.

For a KSDS, the base key in the record must not be altered when the record is modified. Similarly, if the update is being made by way of a path, the alternate key used to identify the record must not be altered either, although other alternate keys may be altered. If the file definition allows variable-length records, the length of the record may be changed.

The length of records in an ESDS, a fixed-length RRDS, or a fixed-length KSDS must not be changed on update.

For a file defined to CICS as containing fixed-length records, the length of record being rewritten must equal the original length. For variable-length records, you must specify the LENGTH option with both the READ UPDATE and the REWRITE commands. The length must not be greater than the maximum defined to VSAM.

[[ Contents Previous Page | Next Page Index ]]