Using CICS commands to add records

Add new records to a file with the WRITE command. They must always be written from an area provided by the application program.

Adding to a KSDS

When adding a record to a KSDS, the base key of the record identifies the position in the data set where the record is to be inserted. Although the key is part of the record, CICS® also requires the application program to specify the key separately using the RIDFLD option on the WRITE command.

A record added to a KSDS by way of an alternate index path is also inserted into the data set in the position determined by the base key. However, the command must also include the alternate index key as the record identifier.

Adding to an ESDS

A record added to an ESDS is always added to the end of the file. You cannot insert a record in an ESDS between existing records. After the operation is completed, the relative byte address in the file where the record was placed is returned to the application program.

When adding a record to an ESDS by way of an alternate index path, the record is also placed at the end of the data set. The command must include the alternate index key in the same way as for a KSDS path.

Adding to an RRDS

To add a record to an RRDS, include the relative record number as a record identifier on the WRITE command. The record is then stored in the file in the position corresponding to the RRN.

Records that are already locked

The NOSUSPEND option, described in Read integrity (in RLS mode) also applies to the WRITE command for a file opened in RLS mode.

Specifying record length

When writing to a fixed-length file, the record length must match the value specified at the time the file was created. In this case, you need not include the length with the command, although you may do so to check whether the length agrees with that originally defined to VSAM. If the file is defined as containing variable-length records, the command must always include the length of the record.

Sequential adding of records (WRITE MASSINSERT command)

MASSINSERT on a WRITE command offers potential improved performance where there is more than one record to add to a KSDS, ESDS, or path. The performance improvement is only obtained when the keys in successive WRITE MASSINSERT requests are in ascending order.

A MASSINSERT is completed by the UNLOCK command. This ensures that all the records are written to the file and the position is released. Always issue an UNLOCK command before performing an update operation on the same data set (read update, delete with RIDFLD, or write). If you do not, you may get unpredictable results, possibly including a deadlock.

Without an UNLOCK command, the MASSINSERT is completed when a syncpoint is issued, or at task termination.

Note:
A READ command does not necessarily retrieve a record that has been added by an incomplete MASSINSERT operation.

See VSAM data sets for more information about MASSINSERT.

[[ Contents Previous Page | Next Page Index ]]