WRITE
Writes a record to a specified sequential or partitioned data set. When you open an existing file with the WRITE function, the contents of the file are deleted. If you want to append records to a file without deleting the existing content, use the WRITEA function to initially open the file. Once a file has been opened with WRITEA, you can use WRITE to append records to the file without overwriting the existing records. For more information, see WRITEA.
For EngageOne™ Enrichment on a mainframe system, use the WRITEV function to write information to KSDS VSAM files. For more information, see WRITEV.
Syntax
WRITE(filename,record,[format,length,size])
Arguments
Argument | Description | Default | |
---|---|---|---|
filename | The name of the data set to write to. The data set is only opened once, before processing the first document. You can only use this data set for the WRITE function. Specify * for SYSOUT. You can use the same data set in multiple WRITE calls. Specify filename in the same manner for all calls to the same data set. filename may be up to 255 characters in length. | None | |
record | The string to write to filename. Each WRITE call creates a complete record in filename. | None | |
[format] | The record format of filename. format is used to: | None | |
Open the data set | format must match the format of the data set to create or that already exists. | ||
Write the records | If format is fixed, EngageOne™ Enrichment pads the record with blanks so that it is length characters long | ||
Valid format options are: | |||
F | Fixed | ||
FB | Fixed block | ||
FBA | Fixed block with ANSI print control. | ||
FBM | Fixed block with machine print control. | ||
U | Undefined | ||
V | Variable | ||
VB | Variable block. | ||
VBA | Variable block with ANSI print control. | ||
VBM | VBM—Variable block with machine print control. | ||
format must match the data set’s record format. If you do not specify format, the data set is opened without specifying a record format. If the data set already exists, the existing setting is used. Otherwise, format U is used. If format defaults, the contents of record must be valid for the type of data set written. Errors may occur if the data set’s record format is fixed, you allow format to default, and you do not write the proper number of bytes in each record. Do not specify format if filename already exists with record format V or record is the same size as length. | |||
[size] | The block size (greater than 0) of filename. size is used to open the data set. It must match the format of the data set to create or that already exists. size is necessary only if the JCL does not specify a block size. size must match the block size used to create the data set. You should not specify size if filename already exists and its record format is V or the size of record is the same as length. |
None |
Results
Result | Description |
---|---|
Return | Null string. If WRITE is unsuccessful, EngageOne™ Enrichment writes the error message to %%RM. |
%%RC | One of the following:
|
%%RM | Error message if an error occurred. |
%%RV | The C Error Number from the WRITE operation if it failed. Otherwise, 0. |
Examples
EngageOne™ Enrichment is to append an existing data set using the following layout for customer statements containing more than 20 pages. The data set will be a 100-byte variable record data set. EngageOne™ Enrichment is to write the names of all customers whose statements were not over 20 pages to SYSOUT.
Record 1:
- Columns 1 through 6: Customer number.
- Columns 7 through 9: Branch office ID.
- Column 10: Special customer status.
Record 2:
- Columns 1 through 40: Customer name.
- Columns 40 through 100: Address.
To achieve the desired result, rule file syntax might resemble that shown below:
IF %%num_pages>20 THEN
%%rec1=%%custno|%%branchid|%%special
%%rec2=%%custname|%%custaddress
WRITE('DD:REPORT',%%rec1,V,100)
WRITE('DD:REPORT',%%rec2,V,100)
ELSE
WRITE(*,%%custname) /* Write to SYSOUT */
ENDIF