Allocating VSAM files
You must predefine and catalog all VSAM data sets through
the access method services DEFINE
command. Most of
the information about a VSAM data set is in the catalog, so you need
to specify only minimal DD
or environment variable
information.
Allocation of VSAM files (indexed, relative, and sequential) follows the general rules for the allocation of COBOL files.
When you use an environment variable to allocate a VSAM file, the variable name must be in uppercase. Usually the input and data buffers are the only variables that you are concerned about. You must specify these options in the order shown, but no others:
DSN(
dsname)
, where dsname is the name of the base clusterOLD
orSHR
The basic DD
statement that you need for
VSAM files and the corresponding export
command are
these:
//ddname DD DSN=dsname,DISP=SHR,AMP=AMORG
export evname="DSN(dsname),SHR"
In either case, dsname must be
the same as the name used in the access method services DEFINE
CLUSTER
or DEFINE PATH
command. DISP
must
be OLD
or SHR
because the data set
is already cataloged. If you specify MOD
when using
JCL, the data set is treated as OLD
.
AMP
is a VSAM JCL
parameter that supplements the information that the program supplies
about the data set. AMP
takes effect when your program
opens the VSAM file. Any information that you set through the AMP
parameter
takes precedence over the information that is in the catalog or that
the program supplies. The AMP
parameter is required
only under the following circumstances:
- You use a dummy VSAM data set. For example,
//ddname DD DUMMY,AMP=AMORG
- You request additional index or data buffers. For example,
//ddname DD DSN=VSAM.dsname,DISP=SHR, // AMP=('BUFNI=4,BUFND=8')
You cannot specify AMP
if you allocate a
VSAM data set with an environment variable.
For a VSAM base
cluster, specify the same system-name (ddname or environment variable
name) that you specify in the ASSIGN
clause after
the SELECT
clause.
When you use alternate
indexes in your COBOL program, you must specify not only a system-name
(using a DD
statement or environment variable) for
the base cluster, but also a system-name for each alternate index
path. No language mechanism exists to explicitly declare system-names
for alternate index paths within the program. Therefore, you must
adhere to the following guidelines for forming the system-name (ddname
or environment variable name) for each alternate index path:
- Concatenate the base cluster name with an integer.
- Begin with 1 for the path associated with the first alternate
record defined for the file in your program (
ALTERNATE RECORD KEY
clause of theFILE-CONTROL
paragraph). - Increment by 1 for the path associated with each successive alternate record definition for that file.
For example, if the system-name of a base cluster is ABCD
,
the system-name for the first alternate index path defined for the
file in your program is ABCD1
, the system-name for
the second alternate index path is ABCD2
, and so
on.
If the length of the base cluster system-name together
with the sequence number exceeds eight characters, the base cluster
portion of the system-name is truncated on the right to reduce the
concatenated result to eight characters. For example, if the system-name
of a base cluster is ABCDEFGH
, the system name of
the first alternate index path is ABCDEFG1
, the tenth
is ABCDEF10
, and so on.