Use the VSAM() function to perform I/O operations on VSAM data sets.
The VSAM() function has this syntax:
Form 1:
acb = VSAM(OBTAIN,[scope],cbtype)
Form 2:
VSAM(option1,acb)
Form 3:
status = VSAM(STATUS,acb)
Form 4:
VSAM(MODCB,acb,modopt1)
Form 5:
VSAM(MODCB,rpl,modopt2)
Form 6:
dsname = VSAM(DSNAME,acb)
Form 7:
VSAM(POINT,rpl,key)
Form 8:
record = VSAM(act1,rpl,[key])
Form 9:
VSAM(act2,rpl,record)
Form 10:
VSAM(act3,rpl)
The VSAM() function takes these arguments:
ID for a VSAM ACB and an associated internal workspace.
Obtains a new RPL or ACB.
Specify one of these values:
Indicates that the file is local to the IMOD. The RPL or ACB is automatically released at the end of the IMOD.
Indicates that you can share this file across IMODs. The RPL or ACB must be released explicitly.
Default: LOCAL
Specify one of these values:
Obtains an ACB control block.
Obtains an RPL control block.
Specify one of these values:
Opens a file for processing.
Completes processing.
Temporarily closes the file. This option writes all information to disk and updates all pointers. However, the file remains open and processing may continue.
Returns handle value to the system to free storage used.
Current status of data set (OPEN or CLOSED) as returned by the STATUS operation.
Returns the status of the ACB.
Modifies the VSAM RPL or ACB.
Specify one of these values:
Modifies the ACB's DDNAME value. Only effective if the data set is currently closed.
Modifies the ACB's MACRF values. Choose one or more of the following values, separated by commas: SEQ, OUT, RST, NRS, DIR, KEY, IN. Descriptions of these options can be found in the IBM VSAM reference manuals.
rpl
ID for a VSAM RPL and an associated internal workspace.
modopt2
Specify one of these values:
Modifies the RPL's ACB value. Before you can use an RPL for operations on a data set, it must be linked to an open ACB.
Modifies the RPL's KEY field. You may set this field directly in the RPL without using the POINT, GET, or DELETE operations.
Modifies the RPL's OPTCD values. Choose one or more of these values, separated by commas: FWD, BWD, SEQ, DIR, KEY, FKS, GEN, UPD, NUP, NSP, KEQ, KGE.
Data set name of an open data set. This is the cluster name.
Returns the cluster name of an open data set.
Useful in sequential mode, a POINT operation positions the file to the record that matches key. Subsequent GETs then retrieve records, beginning with the desired one.
Key of the desired record. For KSDS processing, the full key or partial key, and the match must be exact or not less than the key value, depending on the processing mode. For RRDS and ESDS processing, key is the numeric relative record number or RBA, respectively.
Record text. For keyed records, this includes the key.
act1
Specify one of these values:
Obtains a record. For sequential mode processing, returns next logical record. For direct mode processing, returns record whose key is in the RPL. Direct mode processing permits specification of the key with GET.
Deletes the specified record (by key). This is an extension of VSAM functions. Normally, you must first read the record to be erased and then erase it. DELETE eliminates the need to perform the GET.
Specify one of these values:
Writes a record. Depending upon the update status, a new record is inserted or the current record is replaced. For RRDS and ESDS processing, the key argument is required for a non-update write. For KSDS processing, the key is embedded in the record.
Replaces the specified record (by key). This is an extension of VSAM functions. Normally, you must first read the record to be updated and then replace it. UPDATE eliminates the need to perform the GET. If the record to be updated does not exist, it will be added.
Specify one of these values:
In UPDATE mode, causes the last read record to be deleted from the file.
Terminates any operation in progress on an RPL. For example, if you have read a record for update and then change your mind, you must issue an ENDREQ to free the RPL. Otherwise, you must either update or erase the record to complete the operation.
The VSAM() function produces these return codes:
ARG n MISSING OR INVALID
DELETE NOT MATCHED
ADD AND UPDATE FOR RECORD BOTH FAILED
NOT RPL
NO RPL
NOT ACB
NO ACB
DATASET IS OPEN
DATASET NOT OPEN
PHASE: phase RETURN: ret REASON rea
This is returned for an RPL-based error. phase indicates the failing operations (for example, GET), ret is the value returned in the RPLRET field, and rea is the value returned in the RPL FDBK2 field. These values are explained in detail in the IBM VSAM reference manuals.
PHASE: phase R15: ret REASON: rea
This is returned for a non-RPL-based error. phase indicates the failing operation (for example, CLOSE), ret is the value returned (by VSAM) in register 15, and rea is the value returned (by VSAM) in register 0. These values are explained in detail in the IBM VSAM reference manuals.
OPEN ERROR. CODE=code
code is the VSAM error code, as explained in the IBM VSAM reference manuals.
Example
/* DDname JUNK was already allocated */
acb = vsam('OBTAIN','ACB') /* Obtain an ACB */
rpl = vsam('OBTAIN','RPL') /* Obtain an RPL */
x = vsam('MODCB',acb,'DDNAME=JUNK','MACRF=SEQ,DIR,OUT')
/* Modify the ACB for the desired
file*/
x = vsam('MODCB',rpl,'ACB='||acb)
/* Point the RPL back to the ACB */
x = vsam('OPEN',acb) /* Open the file */
x = vsam('MODCB',rpl,'OPTCD=DIR,FKS,KEQ,UPD')
/* Modify the RPL to perform direct
I/O,full key,key equal,and fetch
for update */
record = vsam('GET',rpl,key)
/* Fetch the record that matches the
value found in "key" */
record = key||newdata /* construct new record, retaining the
key */
x = vsam('PUT',rpl,record) /* Write the updated record */
x = vsam('CLOSE',acb) /* Close the file */
/* The next two calls are automatic at
IMOD end */
vsam('release',acb) == '' /* Clean up */
vsam('release',rpl) == '' /* Clean up */
| Copyright © 2012 CA. All rights reserved. | Tell Technical Publications how we can improve this information |