WRITE


1 WRITE(+ ,? ddname)

Writes a record to the specified data sets. If the WRITE function is successful, it returns a value of 0. If the WRITE function is unsuccessful, it raises the REXX syntax error condition.

The argument you can specify is:
ddname
Specifies a record is to be written to the data set identified by the specified ddname.
The record is written from the contents of one of the following REXX variables:
  • If it has been assigned a value by the procedure, the variable OUTREC.ddname, where ddname is the ddname specified in the WRITE function
  • If the variable OUTREC.ddname has not been assigned a value, or has been unassigned using the DROP instruction, the FM/Db2-defined variable, OUTREC

The length of the record written depends upon the data set attributes of the output data set. If the output data set contains variable-length records, the length of the record is determined from the length of the data in the REXX variable. If the length of the data is greater than the maximum record length specified in the data set attributes, the record is truncated. If the output data set contains fixed-length records, the length of the record written is the length specified in the data set attributes, truncated or padded as necessary.

If the record format of the output data set specifies that the records contain a carriage control character, depending on the output device, the first character of the record data in the REXX variable is interpreted as a carriage control character. For more information about records containing carriage control characters, see OS/390 DFSMS: Using Data Sets.

Example 1

If the current record is type 01, write it to the DD01 file.
if fld(1,2) = 01 then WRITE('DD01')

Example 2

If the current record is type 02, write it to the DD02 and DD02COPY files.
if fld(1,2) = 02 then WRITE('DD02','DD02COPY')