Writing to record I/O files
To write new records to a VSAM data set opened with type=record, use the
Standard C fwrite() library function. If you set size to 1 and
count to the desired record size, fwrite() returns the number of
bytes written successfully. For more information on fwrite() and the
type=record parameter, see z/OS XL C/C++ Runtime Library Reference.
In general, C I/O does not allow a write operation to follow a
read operation without an intervening reposition or fflush(). z/OS® XL C/C++ counts
a call to a write function writing 0 bytes or a write
request that fails because of a system error as a write operation.
However, z/OS XL C/C++ VSAM
record I/O allows a write to directly follow a read. This feature
has been provided for compatibility with earlier releases.
The process of writing to a data set for the first time is known
as initial loading. Using the fwrite() function,
you can write to a new VSAM file in initial load mode just
as you would to a file not in initial load mode. Writing to
a KSDS PATH or an ESDS PATH in initial load mode is not supported.
fwrite() call does not try to write more
bytes than the maximum record size, fwrite() writes
a record of the length you asked for and returns your request. If
your fwrite() call asks for more than the maximum
record size, fwrite() writes the maximum record size,
sets errno, and returns the maximum record size.
In either case, the next call to fwrite() writes
to the following record. fwrite() fails,
you must reposition the file before you try to read or write again.- KSDS, KSDS AIX®
Records are written to the cluster according to the value stored in the field designated as the prime key.
You can load a KSDS in any key order but it is most efficient to perform the
fwrite()operations in key sequence. - ESDS, ESDS AIX
Records are written to the end of the file.
- RRDS
Records are written according to the value stored in the relative record number field.
fwrite()is called with the RRDS record structure.By default, in record mode,
fwrite()andfupdate()must be called with a pointer to an RRDS record structure. The__rrds_key_typefields__filland__recnummust be set.__fillis set to0or 1 to indicate the type of the structure. The__recnumfield specifies the RRN to write, and is required forfwrite()but notfupdate(). Thecountargument must include the length of the__rrds_key_type.fwrite()andfupdate()include the length of the__rrds_key_typein the return value.