The FROM option specifies the element or aggregate variable from which the record is written. The FROM option must be used in the WRITE statement for any OUTPUT or DIRECT UPDATE file. It can also be used in the REWRITE statement for any UPDATE file.
If the variable is an aggregate, it must be in connected storage. Certain uses of unaligned nonvarying bit strings are disallowed (for details, see Data transmitted).
The FROM variable can be an element string variable of varying length. When using a WRITE statement with the FROM option, only the current length of a varying length string is transmitted to a data set. For a VARYINGZ string, the null terminator is attached and also transmitted. For a VARYING string, a 2-byte prefix specifying the length is attached only if the SCALARVARYING option of the ENVIRONMENT attribute is specified for the file.
Records are transmitted as an integral number of bytes. If a bit string (or a structure that starts or ends with a bit string) that is not aligned on a byte boundary is transmitted, the record is padded with bits at the start or the end of the string, and the result might be incorrect.
The FROM option can be omitted from a REWRITE statement for SEQUENTIAL UPDATE files. If the last record was read by a READ statement with the INTO option, REWRITE without FROM has no effect on the record in the data set. If the last record was read by a READ statement with the SET option, the record (updated by whatever assignments were made) is copied back onto the data set.
In the following examples, the statements specify that the value of the variable Mas_Rec is written into the output file Master.
write file (Master) from (Mas_Rec);
The REWRITE statement specifies that Mas_Rec replaces the last record read from an UPDATE file.
rewrite file (Master) from (Mas_Rec);