WRITE

Write is used to create a new record on a file or database. It corresponds to SQLs INSERT and COBOLs WRITE statement.

Examples

PROGRAM CopyIN1 BATCH;

COPY IN1;

COPY out1;

PROCESS in1;

Out1.* = In1.*;

#207 I Region, District, Name, BillingCycle included in generic assignment

WRITE out1;

#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: -

PROGRAM Copy2;

DEFINE InFile VB DATA(

    Field1 ,
    Field2 ,,,

    Field3 );

DEFINE OutFile TYPE(...)

PROCESS Infile WHERE condition;

    WRITE Outfile (Infile.*);

END PROCESS Infile;

Format

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 files 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.

 

Parking

Write failure.

Writing variable-length records.

Stuff from the INSERT statement (SQL).