Write is used to create a new record on a file or database. It corresponds to SQL’s INSERT and COBOL’s WRITE statement.
PROGRAM CopyIN1 BATCH;
Out1.* = In1.*;
#207 I Region, District, Name, BillingCycle included in generic assignment
#378 W Batch WRITE used - you may need to edit the JCL
END PROCESS in1;
DATA is a default keyword, so you can write WRITE Outfile (Infile.*); instead of WRITE Outfile DATA (Infile.*); If a DATA option is used (or implied), then the DEFINE statement for the output file does not need a DATA option. For example, to write a subset of the records from Infile without reformatting them: -
DEFINE InFile VB DATA(
DEFINE OutFile TYPE(...)
PROCESS Infile WHERE condition;
WRITE Outfile (Infile.*);
END PROCESS Infile;
For VSAM and Physical-sequential Files: -
WRITE FileName [DATA (field-name | group-name)]
For SQL tables WRITE has format: -
WRITE FileName [DATA (field-name [, field-name]…)]
FileName names a file that has been defined in a preceding DEFINE statement. The file must have type VSAM, F, FB, V, VB, U, XIO, SQL, or TS. Other types (WorkingData, SCREEN, Parameter, etc) are not permitted.
If DATA is omitted from the WRITE statement: -
· VSAM and Physical-sequential Files: A record consisting of the record defined in the file’s DATA option is written. If there are redefinitions within this, then the longest possible record is written.
· SQL: all the fields defined in the DATA option that have non-NULL values will be written.
Writing variable-length records.
Stuff from the INSERT statement (SQL).