JCL Session 7
IDCAMS
AMS = Access Method Services utility program
that handles VSAM files.
it is also a multipurpose utility that can
process VSAM and non-VSAM datasets.
VSAM - Virtual
Storage Access Method
KEY SEQUENCE DATA SET (KSDS)
A VSAM cluster (cluster
is another name for a VSAM file) can be accessed
- sequentially (by serially processing records
in data component of base cluster)
- by its primary index (use unique key values
of index to locate records in base cluster)
- by an alternate index (use unique/non-unique
keys) to locate records in base cluster)
Data records
are allocated to control intervals (similar
to block sizes) and
contained within a control areas (cylinder).
A VSAM KSDS
-
can have free space in control intervals and
control areas to provide room
for the insertion of new records in
the primary key order of the file.
-
will modify itself as records are inserted.
If there is not enough space
available when inserting a new record,
VSAM will create space by expanding the file.
For VSAM datasets, use only the first positional
parameter of DISP=
Do not use the second or third positional
DISP= parameter to alter the status of a VSAM dataset.
DISP=(OLD,X,X)
or DISP=(SHR,X,X)
Use the IDCAMS program for
deleting or defining VSAM datasets.
Data component and primary index component
form a base cluster.
Data Component (has the data records) and can
be processed sequentially.
EID |
Name |
SSN |
011 |
Harris, Stanley |
499-35-5069 |
022 |
Lloyd, Harold |
293-74-9932 |
033 |
Constantine, Joe |
889-43-1283 |
044 |
Little, John |
559-23-1245 |
055 |
Siebert, E.R. |
599-22-1133 |
066 |
Small, Marie |
115-76-9322 |
077 |
McDonald, Ronald |
113-77-1135 |
(Note that the order of the data component
is by its primary key (EID)
-------------------------------------------------------------------------------------------------------------------------------
Index Component extracts the primary key from
the Data Component.
EID
|
011
|
022
|
033
|
044
|
055
|
066
|
077
|
(Note that the order of the index component is
by primary key (EID)
An Alternate Index is a separate KSDS where
the data record is the extracted
Alternate Key and Primary Key from the data
component of the original KSDS.
The data record can be searched by its alternate
key to find the primary key.
Alternate Key |
Primary Key |
SSN |
EID |
113-77-1135 |
077 |
115-76-9322
|
066 |
293-74-9932
|
022
|
499-35-5069
|
011
|
559-23-1145
|
044
|
599-22-1133
|
055
|
889-43-1283
|
033
|
(Note that the sequence of the alternate index
component is by the alternate key -- SSN)
JCL to invoke AMS
//stepname EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
<--prints SYSIN input plus results of AMS processing
//SYSIN
DD * <--points to dataset
containing AMS input commands
(AMS COMMANDS)
AMS Command Format
- anywhere in columns 2 through 72
- use hyphens to continue a command to next
line
- comments begin with /* and end with */
Sample list of AMS Command Verbs
ALTER - Change
the current information specified for a catalog, cluster, alternate index
or path.
BLDINDEX - Build
an alternate index.
DEFINE ALTERNATEINDEX -
Define an alternate index
DEFINE CLUSTER - Define
a VSAM file.
DEFINE PATH - Define
the path that relates an alternate index to its base cluster
DELETE - Remove
a catalog entry for cluster, alternate index or path.
LISTCAT - List
information about datasets.
PRINT - Print
the contents of a VSAM or non-VSAM file.
REPRO - Copy records
from one file to another.
Parameters for DEFINE CLUSTER Command
NAME(filename)
Specifies the name of the cluster or component.
(required)
INDEXED
Default value identifies creation of a KSDS.(Valid
at cluster level only)
RECORDSIZE(avg max)
RECSZ
KEYS(length offset)
What is key definition if key is in bytes
13-21 of record?
Entry for length and offset of primary key
based on its position within the base
cluster. Offset values start with zero.
VOLUMES(vol-ser, ......)
VOL
One or more volumes to contain the component.
CYLINDERS | TRACKS | RECORDS | BLOCKS (primary
secondary)
Select one of the above
UNIQUE
File occupies its own data
space.
FREESPACE (control_interval_% control_area_%)
FSPC
IMBED
Sequence set index records are stored in the
first track of the data storage area.
Also duplicates the index records as many
times as possible on that track.
The effect is that rotational delay is reduced
and a single arm movement seek will get
the index as well as the data.
SHAREOPTIONS(Option)
SHR
1 - Process by multiple concurrent reads
2 - Process by multiple reads / one update
3 - Process by multiple reads / multiple updates
Also used for files
with alternate indexes or for CICS processing.
CONTROLINTERVALSIZE(bytes)
CISZ
Example of DEFINE CLUSTER Command Creating
a KSDS
Defines the data and primary index components
//DELDEF EXEC
PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN
DD *
DELETE filename CLUSTER
–
DEFINE CLUSTER -
(NAME(filename) -
INDEXED -
RECSZ(avg max) -
KEYS(length offset)
-
VOL(volid)) -
storage_unit(primary
secondary) -
UNIQUE -
FSPC(ci% ca%) -
IMBED -
SHR(shareoption)
-
CISZ(bytes) -
DATA (NAME(filename.DATA))
-
INDEX (NAME(filename.INDEX))
//****************************************************************
//*
//* USING IDCAMS TO LOAD
A VSAM FILE
//*
//****************************************************************
//*
//REPRO EXEC
PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INDATA DD
DSN=userid.CSC.CNTL(memname),DISP=SHR
//OUTDATA DD DSN=filename,DISP=OLD
//SYSIN
DD *
REPRO INFILE(INDATA)
OUTFILE(OUTDATA)
//****************************************************************
//*
//* USING IDCAMS TO DUMP
(PRINT) A FILE
//*
//****************************************************************
//*
//DUMP
EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INDATA DD
DSN=filename,DISP=SHR
//SYSIN
DD *
PRINT INFILE(INDATA)
CHARACTER
Parameters for DEFINE ALTERNATEINDEX
(AIX) Command
Defines an alternate index component
NAME(DSN-name)
Specifies the name of the alternate index
RELATE(DSN-name)
Specifies name of the base cluster to which
alternate index is dependent.
CYLINDERS | TRACKS | RECORDS | BLOCKS (primary
secondary)
VOLUME(vol-ser, ......)
One or more volumes to contain the cluster/component.
KEYS( length offset)
Position within the base data cluster. Offset
values start with zero.
UNIQUEKEY | NONUNIQUEKEY
Specifies whether duplicate alternate key
values are allowed
SHAREOPTIONS(Option)
Parameter of BLDINDEX Command
Populates the alternate index with data from
the base cluster.
BLDINDEX
Use INFILE(ddname) DDNAME of base cluster
or INDATASET(VSAM base cluster name)
Use OUTFILE(ddname) DDNAME of alternate index
or path to be built.
or OUTDATASET(VSAM base cluster name)
Parameters for DEFINE PATH Command
Creates an access route using the alternate
index
to primary index to data record.
PATH
NAME(filename)
Specifies the name of the path
PATHENTRY(alt_index_name)
Name of the alternate index related to this
path.
Example of DEFINE Alternate Index & Path
Defines the data and primary index components
//******************************************************************
//* THIS STEP DEFINES AN
ALTERNATE INDEX
//******************************************************************
//STEPA EXEC
PGM=IDCAMS
//SYSPRINT DD SYSOUT=X
//SYSIN
DD *
DEFINE
AIX(NAME(filename.AIX) -
RELATE(filename)
-
RECORDS
(primary secondary) VOLUME (volid) -
KEYS
(length offset) SHAREOPTIONS(option) -
NONUNIQUEKEY)
//********************************************************************
//* THIS STEP BUILDS AN
ALTERNATE INDEX
//********************************************************************
//STEPB EXEC
PGM=IDCAMS
//SYSPRINT DD SYSOUT=X
//PRIMEI DD
DSN=filename,DISP=SHR
//ALTERI DD
DSN=filename.AIX,DISP=SHR
//SYSIN
DD *
BLDINDEX
INFILE (PRIMEI) OUTFILE (ALTERI)
//****************************************************************
//* THIS STEP DEFINES A
PATH FOR THE ALTERNATE INDEX
//****************************************************************
//STEPC EXEC
PGM=IDCAMS
//SYSPRINT DD SYSOUT=X
//SYSIN
DD *
DEFINE
PATH (NAME(filename.PATH) -
PATHENTRY
(filename.AIX) )
//******************************************************************
//* THIS STEP PRINTS ALTERNATE
INDEXES & PATHS
//******************************************************************
//PRINT EXEC
PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INDATA DD
DSN=filename.AIX,DISP=SHR
//INDATA2 DD DSN=filename.PATH,DISP=SHR
//SYSIN
DD *
PRINT
INFILE(INDATA) CHARACTER
PRINT
INFILE(INDATA2) CHARACTER
/*
EXERCISE: (VALUE 30 points)
Create a single JOB with multiple steps which will accomplish the
following:
-
Create and define a VSAM Key Sequenced Data Set (KSDS)
-
Copy JPETLIC.CSC.CNTL(GRADES) to your dataset.
The student code, in columns 7 - 10, is the primary key.
-
Define a new student VSAM file using the student code as the key.
( use IDCAMS. Model from member IDCDEDEF in JPETLIC.CSC.CNTL.)
-
Load sorted GRADES into your student VSAM file.
( use IDCAMS. Model from member IDCREPRO)
-
Print a character dump of the VSAM student file.
( use IDCAMS. Model from member IDCDUMP)
-
Create an alternate index based on the student names in the VSAM student
file
-
PRINT a character dump of the alternate index
-
PRINT the base cluster data sequenced by name by using path reference.
( use IDCAMS. Model from member ALTCRE)