WRITE—Write a logical record or block of records (BISAM)

The WRITE macro adds or replaces a record or replaces an updated block in an existing indexed sequential data set. Control might be returned to the problem program before the block or record is written. The output operation must be tested for completion using a WAIT or CHECK macro. A data event control block, shown in Status information following an input/output operation, is constructed as part of the macro expansion.

The standard form of the WRITE macro is written as follows (the list and execute forms are shown following the descriptions of the standard form):

decb name—symbol
specifies the name that is assigned to the data event control block that is created as part of the macro expansion.
type{K|KN}
specifies the type of write operation:
K
specifies that either an updated unblocked record or a block containing an updated record is to be written. If the record is read using a READ KU macro, the data event control block for the READ macro must be used as the data event control block for the WRITE macro, using the execute form of the WRITE macro.
KN
specifies that a new record is to be written, or a variable-length record is to be rewritten with a different length. All records or blocks of records read using READ KU macros for the same data control block must be written back before a new record can be added, except when the READ KU and WRITE KN refer to the same DECB.
dcb address—A-Type Address or (2-12)
specifies the address of the data control block for the opened existing indexed sequential data set. If a block is written, the data control block address must be the same as the dcb address in the corresponding READ macro.
area address—A-Type Address, (2-12), or 'S'
specifies the address of the area containing the logical record or block of records to be written. The first 16 bytes of this area are used by the system and should not contain your data. The area address must specify a different area than the key address. When new records are written (or when variable-length records arerewritten with a different length), the area address of the new record must always be supplied by the problem program. The addressed area might be altered by the system. 'S' can be coded instead of an address only if the block of records is contained in an area provided by dynamic buffering. That is, 'S' is coded for the area address in the associated READ KU macro. The addressed area is released after execution of a WRITE macro using the same DECB. The area can also be released by a FREEDBUF macro.

The following illustration shows the format of the area:

Control Program Use followed by Logical Record (WRITE KN) or Block of Records (WRITE K)

Indexed sequential buffer and work area requirements are discussed in z/OS DFSMS Using Data Sets.

length—symbol, decimal digit, absexp, (2-12) or 'S'
specifies the number of data bytes to be written, up to a maximum of 32760. Specify 'S' unless a variable-length record is to be rewritten with a different length.
key address—A-Type Address or (2-12)
specifies the address of the area containing the key of the new or updated record. The key address must specify a different area than the area address. For blocked records, this is not necessarily the high key in the block. For unblocked records, this field should not overlap with the work area specified in the MSWA of the DCB macro.
Note: When new records are written, the key area might be altered by the system.