WRITEV
Writes, updates, or deletes a record from a specified KSDS VSAM file. The WRITEV function is valid only on a mainframe system.
Use the WRITE function to write information to sequential or partitioned data sets.
Note: WRITEV can be used on a line by itself. It does not have to be assigned to a variable.
Syntax
WRITEV(filename,record,[method,length])
Arguments
Argument | Description | Default | |
---|---|---|---|
filename | The name of the file to write to. EngageOne™ Enrichment opens the file before processing the first document. You can use the same file in multiple WRITEV calls and in multiple LOOKUPV calls to read from the VSAM file. Specify filename in exactly the same manner for all calls to the same file. EngageOne™ Enrichment only opens the file once. filename may be up to 255 characters in length. | None | |
record | The string to write to filename. Each WRITEV call creates a complete record in filename. Ignores record if you set method to D. | None | |
[method] | One of the following processes to perform on record: | A | |
A | Add a new record with a new key. An add will fail if a record with the same key already exists (in which case method should be U) or if there is no room to insert the record in the file. | ||
U | Update the current record with the matching key. Before updating a record, the file must be positioned using the LOOKUPV function. | ||
D | Delete the current record with the matching key. Before deleting a record, the file must be positioned using the LOOKUPV function. | ||
[length] | The number of characters (greater than or equal to 0) to write (for method A or U). If record is larger than length, EngageOne™ Enrichment truncates record before writing to the file. If record is shorter than length, pads it with blanks. If length is 0, EngageOne™ Enrichment neither pads nor truncates record. | 0 |
Results
Result | Description | |
---|---|---|
Return | Null string. If WRITEV is unsuccessful, EngageOne™ Enrichment writes the error message to %%RM. | |
%%RC | One of the following: | |
0 | No error | |
1 | An error occurred writing to filename. EngageOne™ Enrichment did not write the complete record. The return will contain a string detailing how many bytes were written and how many were requested | |
2 | An error occurred writing to filename. EngageOne™ Enrichment wrote no data. The return contains the mainframe system error message | |
3 | Error opening output file. | |
%%RM | Error message if an error occurred. | |
%%RV | The C Error Number from the WRITEV operation if it failed. Otherwise, 0. |
Examples
EngageOne™ Enrichment is to update an existing file using the following layout:
Record 1:
- Columns 1 through 6: Customer number.
- Columns 7 through 9: Branch office ID.
- Column 10: Special customer status.
We want to:
- Add a record if the customer number does not exist.
- Update a record if the branch office ID changes.
- Delete a record if the status changes to N.
To achieve the desired result, rule file syntax might resemble that shown below (%%custno
, %%branchid
, and %%special
were read off the document with the control file):
%%newinfo=%%custno|%%branchid|%%special
%%custinfo=LOOKUPV('DD:VSAM',%%custno,10)
%%oldbranch=SUBSTR(%%custinfo,7,3)
IF %%rc<>0 THEN
WRITEV('DD:VSAM',%%newinfo,A,10)
ELSEIF (%%oldbranch<>%%branchid) THEN
WRITEV('DD:VSAM',%%newinfo,U,10)
ELSEIF (%%special='N') THEN
WRITEV('DD:VSAM',%%newinfo,D,10)
ENDIF