You define a VSAM data set by using the IBM Access Method Services
(AMS) IDCAMS utility, which is invoked from JCL. The following example
uses IDCAMS to delete, allocate, and define a KSDS, an RRDS, and an
ESDS. Note that the IDCAMS DEFINE parameters are generally self-explanatory
by name. Make special note of the parameters RECORDSIZE (average
maximum) and KEYS (length offset), where the keys offset is relative
to the beginning of the record.
//VSAMDEF JOB job information
//DEFINE EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN DD *
DELETE (dsname.K1719) PURGE CLUSTER
DEFINE CLUSTER (NAME(dsname.K1719) INDEXED VOLUMES(xxxxxx) -
TRACKS(1) KEYS(17 19) RECORDSIZE(40 110) NONSPANNED) -
DATA (NAME(dsname.K1719.DATA)) INDEX (NAME(dsname.K1719.INDEX))
DELETE (dsname.R002) PURGE CLUSTER
DEFINE CLUSTER (NAME(dsname.R002) NUMBERED VOLUMES(xxxxxx) TRACKS(1) -
RECORDSIZE(120 120) NONSPANNED) DATA (NAME(dsname.R002.DATA))
DELETE (dsname.E002) PURGE CLUSTER
DEFINE CLUSTER (NAME(dsname.E002) NONINDEXED VOLUMES(xxxxxx) -
TRACKS(1) RECORDSIZE(80 80)) DATA (NAME(dsname.E002.DATA))
/*
//
If the VSAM data sets
do not already exist, this example produces a return code of 8 for
the DELETE operation.
You can also define
a VSAM data set in two other ways:
-
by building a SAS macro variable
-
by issuing a TSO DEFINE command
in the Program Editor with the X statement
The following is an
example of a macro variable:
options vsamload vsamupdate;
/* Delete the cluster if it exists. */
x "delete ('dsname.esds.student') purge cluster";
/* Build a macro variable containing the commands */
/* that define a VSAM ESDS. */
%let def=%str(define cluster %(name('dsname.esds.student') );
%let def=&def %str(records(10 5) );
%let def=&def %str(recsz(90 90) );
%let def=&def %str(shareoptions(2,3) );
%let def=&def %str(volumes( xxxxxx ) );
%let def=&def %str(reuse );
%let def=&def %str(cisz(2048) );
%let def=&def %str(nonindexed %) );
/* Submit the macro variable for execution. */
%sysexec &def;
run;
The example defines
an ESDS that is named
dsname.ESDS.STUDENT. If the ESDS already exists, this
example deletes the data set and redefines it. The necessary SAS system
options VSAMLOAD and VSAMUPDATE are included in the beginning of the
example. The first qualifier of the data set name,
dsname, represents a value that the user supplies.
The following is an
example of a TSO DEFINE command:
X DEFINE CLUSTER
(
NAME('dsname.TEST.VSAMFILE.CLUSTER')
VOLUME(xxxxxx)
TRACKS(5,1)
CONTROLINTERVALSIZE(4096)
FREESPACE(10,20)
KEYS(4,0)
RECORDSIZE(80,80)
)
DATA
(
NAME('dsname.TEST.VSAMFILE.DATA')
)
INDEX
(
NAME('dsname.TEST.VSAMVILE.INDEX')
CONTROLINTERVALSIZE(1024)
)
;