FRom() [Sysid( ) ] [ Length() ] [ Token() ] END-EXEC
EXEC CICS REWRITE FILE (‘FL001’) FROM (ES-REC) END-EXEC
Example:
REWRITE updates a record in a file on a local or a remote system. You must always precede this command with a read with the UPDATE option.
Notes:
REWRITE updates a record in a file on a local or a remote system. You must always precede this command with a read with the UPDATE option.
For VSAM data sets, you must not change the key field in the record.
When this command is used to update a record in a CICS-maintained data table, the update is made to both the source VSAM KSDS and the in-memory data table. The details of the command for a CICS- maintained table are the same as for a VSAM KSDS.
When this command is used to update a record in a user-maintained data table, the update is made to the in-memory data table.
When this command is used to update records in a coupling facility data table, the update is made only to the data table in the coupling facility.
Note: The only VSAM data sets greater than 4GB supported by CICS are KSDS, and then only if they are accessed by key. CICS does not support ESDS or RRDS data sets defined with the extended attribute.
Options
FILE(filename)
specifies the of the file to be accessed. If SYSID is specified, the data set to which this file refers is assumed to be on a remote system irrespective of whether the name is defined in the FCT. Otherwise, the FCT entry is used to find out whether the data set is on a local or a remote system.
FROM(data-area)
specifies the record that is to be written to the data set referred to by this file.
LENGTH(data-value)
specifies the length, as a halfword binary value, of the data area where the record is written from. This option must be specified if SYSID is specified.
If the file is on a remote system, the LENGTH parameter need not be set here but must be set in the file resource definition.
If the file is on a local system, the LENGTH parameter must be set for variable-length records, using the INTO option, but not for fixed-length records. It is, however, advisable to specify the length for fixed- length records because it causes a check to be made that the record being written is not longer than that defined for the data set.
NOSUSPEND (RLS only)
The request does not wait if VSAM is holding an active lock against the record, including records locked as the result of a DEADLOCK. Generally, you should not need this option because, for example, when re-writing a record to a base-only data set, the active lock was acquired when the task issued the READ UPDATE.
However, lock contention can occur if the update involves changes made in RLS mode to records in a VSAM data set that has one or more alternate indexes, and an alternate index is defined with unique keys.
SYSID(systemname)
specifies the name of the system to which the request is directed.
TOKEN(data-area)
specifies as a fullword binary value a unique request identifier for a REWRITE, used to associate it with a previous READ, READNEXT, or READPREV command that specified UPDATE. TOKEN can be function shipped. However, if a request specifying TOKEN is function shipped to a member of the CICS family of products that does not support the TOKEN option, the request fails
UNLOCK
EXEC CICS Unlock File( ) [ Sysid( ) ] [ Token( ) ] END-EXEC
EXEC CICS UNLOCK FILE(‘FL001') END-EXEC
Example:
UNLOCK releases the exclusive control established in response to a read command with the UPDATE option.
Notes:
UNLOCK releases the exclusive control established in response to a read command with the UPDATE option. You use it if you retrieve a record for update, and then decide that you do not want to update the record after all. However, for a recoverable file (other than one that refers to a coupling facility data table), the resource remains locked until either a syncpoint command is executed or the task is terminated. The record can be in a data set, or in a CICS or user-maintained data table, on a local or a remote system. If the UNLOCK command refers to a record in a recoverable coupling facility data table the record lock is released immediately provided that the task has not made any previous change to the same record (or added it as a new record) within the current unit of work. If changes have been made to the record, or it is a new record added to the table, it remains locked until either a syncpoint command is executed or the task is terminated.
If an UNLOCK command does not have a token, an attempt is made to match it to either a read with the UPDATE option that also does not have a token, or to a WRITE MASSINSERT. If neither of these is found, no action is taken and a NORMAL response is returned.
Use this command to terminate a VSAM WRITE MASSINSERT operation against a VSAM file.
Releasing locks when updating in browse: The UNLOCK command does not release locks held against
records locked in response to READNEXT or READPREV commands that specify the update option. It only invalidates the TOKEN value so that it cannot be used to complete an update.
Options
FILE(filename)
specifies the name of the file to be released. If SYSID is specified, the data set to which this file refers is assumed to be on a remote system irrespective of whether the name is defined in the FCT. Otherwise, the FCT entry is used to find out whether the data set is on a local or a remote system.
SYSID(systemname)
specifies the name of the system to which the request is directed.
TOKEN(data-area)
specifies as a fullword binary value a unique request identifier for an UNLOCK, used to associate it with a previous READ, READNEXT, or READPREV command that specified the UPDATE option. If you specify UNLOCK with the TOKEN returned on a READNEXT UPDATE or READPREV UPDATE command for a file accessed in RLS mode, the unlock command simply invalidates the TOKEN value so that it cannot be used to complete an update. It does not release the record lock.
TOKEN can be function shipped. However, if a request specifying TOKEN is function shipped to CICS region that does not support this keyword, the request fails.