Escolar Documentos
Profissional Documentos
Cultura Documentos
VSAM
VSAM
VSAM means virtual storage access method
High performance access method and dataset organization designed specifically for VS environment. It resides in virtual storage Organizes and maintains data via a cataloged structure
VSAM
VSAM HISTORY
A] Standard VSAM. Only ESDS & KSDS
MVS/XA Ver. 1 Changes were compatible with DF/EF VSAM MVS/XA Ver. 2 LDS were added
VSAM
FEATURES OF VSAM
VSAM
ADVANTAGES OF VSAM
Protection of Data Cross-system (MVS & VSE) Compatibility Device Independence (Access Via Catalog) IDCAMS commands can be included in JCL to handle VSAM Used by CICS (OLTP) to store and retrieve data VSCOBOL II/PL-I/ASSMB. Long can access VSAM dataset
VSAM
KSDS
ESDS RRDS LDS
All the four methods contain a data area in which data records are placed For KSDS, there is an index area in addition to data area
VSAM 6
CLUSTERS
VSAM files are often called clusters
A cluster is the set of catalog entries that represent a file A cluster consists of one or two components, a data component, which contains the actual records of a file, and for a KSDS only, an index component, which contains the indexes used to access records in the data component.
Must be defined for each dataset
VSAM 7
CLUSTERS
I. KSDS CLUSTER
INDEX COMPONENT
DATA COMPONENT
II.
VSAM RECORDS
Can be fixed or variable length Records can also be spanned A Linear dataset has no records
CONTROL INTERVAL
A control interval is the unit of data VSAM transfers between virtual and disk storage
CONTROL INTERVAL
A control Interval contains
Logical Records Control Information Free Space Control Interval Descriptor Field(CIDF) contains information about available space with in CI. Record Descriptor Field (RDF) contains the length of each record and how many adjacent records are of the same length. One RDF for each record in variable length files Only two RDFs per CI in case of fixed length files VSAM
11
CONTROL INTERVAL
Logical Record Area (LRA) Freespace
Rec 1
Rec 2
Rec 3
FSPS
U S
CF
CONTROL AREA(CA)
CONTROL INTERVAL CONTROL INTERVAL CONTROL INTERVAL CONTROL INTERVAL
VSAM groups control intervals into contiguous, fixed length areas of storage called control areas.
Maximum of 1 cylinder
SPANNED RECORDS
Spanned records are records larger than CI size. So one spanned record is stored in several CIs Each CI that contains a record segment of a spanned record has two RDFs. The right RDF gives the length of the segment and the left gives the update number of the segment
VSAM
14
ESDS
ESDS is a sequential dataset:
Records are retrieved in the order in which they are written to the dataset Additions are made always at the end of the file Records can be retrieved randomly by using RBA(Relative Byte Address) RBA is an indication of how far, in bytes, each record is displaced from the beginning of the file High-Used-RBA (HURBA)points to the end of the data High-Allocated-RBA (HARBA)is the highest byte that can be VSAM 15 used
HARBA
HURBA
VSAM
16
VSAM
17
KSDS
It is similar in many ways to ISAM file, with better index structure and improved overflow handling Can be processed sequentially and randomly
VSAM
18
DATA Component
Control Areas
I II III
IV V VI
Data Component
Control Intervals
VSAM 19
INDEX COMPONENT
Index Component Index Set Sequence Set
Points to control Intervals * There will be 1 record per CI (lower level of Indexing)
Points to Sequence Set * There will be one record per Sequence Set (higher level of indexing)
VSAM 20
KSDS STRUCTURE
Index Set and control areas for a KSDS
Key Ptr Key Ptr Index Set Index Compone nt Key Ptr Key Data Component
Sequence Set 1
Ptr Key Ptr Key
Control Areas
CI3
CI5
VSAM
21
KSDS STRUCTURE
Index Set Record
Binary Zeroes Hdr 48424 (SS-REC-1) Sequence Set Records Hdr 48011 (CI - 1) SS-Rec-1 48303 (CI - 2) 48424 (CI - 3) Hdr 91761 (CI - A) SS-Rec-2 95651 (CI - B) 95651 (SS-REC-2)
Horizontal pointers
VSAM
22
KSDS STRUCTURE
CI-1 CI-2 48012 CI-3 48304 48013 48416 FSPC 48424 FSPC FSPC
Data Records
44012
44039
44136
FSPC
48525 91762
90403 95651
FSPC FSPC
CONTROL AREA 2
VSAM
23
100
FSPC
CF
200
Rec G
Rec I
FSPC
CF
300
Rec D
Rec E
FSPC
CF
400
Rec J
Control Interval 4
Rec K
Rec L
FSPC
CF
VSAM
24
Record 1
Record 2
Record 3
FSPC
CF
VSAM
25
Record 3
FSPC
U S
CF
After Deletion:
Record 1 Record 2 Record 3 FSPC
U S
CF
VSAM
26
Record 1
Record 2
Record 3
Record 4
FSPC
U S
CF
VSAM
27
Record 3
Record 4
FSPC
CF
VSAM
28
Sequence set
K
Record C
100
Data Component
Record A
100 Record J 200
Record B
Record F
Record G
U S
CF
Record K
FSPC
U S
CF
FSPC
U S
CF
VSAM
29
200
100
CF
CF
VSAM
30
061
181
100
190
145
170
145
170
025
Seq Set 024 001 025 050 012 030 018 050
DATA AREA
030
050
190 170
110
VSAM
31
IDCAMS COMMANDS
VSAM
32
IDCAMS
How VSAM is used by Application Programmers: Write IDCAMS utility program commands & execute them to create VSAM dataset Write application programs (in COBOL, PL/I Assembler Language, in CICS) Using the statements provided by these languages to write and read VSAM datasets Use IDCAMS utility program commands to list, examine, print, tune, backup, and export/import VSAM datasets
VSAM
33
IDCAMS
Can be invoked In batch mode with JCL Interactively with TSO commands With JCL can print/display program and sys messages and return codes can code multiple commands per job can specify IF-THEN-ELSE logic to execute command/s selectively based on condition codes LASTCC, MAXCC
VSAM 34
IDCAMS
Commands FUNCTIONAL Commands DEFINE BUILDINDEX REPRO PRINT DELETE VERIFY ALTER LISTCAT MODAL Commands IF-THEN-ELSE SET
VSAM 35
IDCAMS
// jobname JOB (parameters) // stepname EXEC PGM=IDCAMS // SYSPRINT DD SYSOUT = * [// ddname DD DSN=datasetname, DISP= SHR/ OLD ] //SYSIN DD * IDCAMS command/s coded freely between 2 to 72 cols. /* //
VSAM 36
IDCAMS
Optionally: // JOBCAT DD DSN = catalogname, DISP= SHR // STEPCAT DD DSN = catalogname, DISP = SHR
may be used to indicate catalog names for a job/step, in which concerned dataset may be cataloged
VSAM
37
IDCAMS
FORMAT OF IDCAMS COMMAND verb object (parameters) Example : DEFINE CLUSTER NAME(DA0001T.LIB.KSDS.CLUSTER) CYLINDERS(5, 1) VOLUMES (BS3013) INDEXED ) Comment /* comment */
VSAM
38
IF Syntax
VSAM
40
IF Syntax
ELSE is optional
VSAM
41
IF Syntax Example
.........
REPRO INFILE (INDD) OUTFILE (OUTDD) ................ IF LASTCC EQ 0 THEN PRINT OUTFILE (INDD) ELSE PRINT INFILE (OUTDD)
VSAM
42
USE OF DO/END
VSAM
43
SET COMMAND
LASTCC and MAXCC can be set to a value between 0-16
setting MAXCC has no effect on LASTCC setting LASTCC changes the value of MAXCC, if LASTCC is set to a value larger than MAXCC setting MAXCC = 16 terminates the job
DEFINE CLUSTER IF LASTCC > 0 THEN SET MAXCC = 16 ELSE REPRO
e.g.
-
VSAM
44
DEFINING A CLUSTER
VSAM
45
The DEFINE CLUSTER Command This command tells IDCAMS to create and name a VSAM cluster. Format: Abbreviation: Used for: DEFINE CLUSTER (NAME (cluster name) parameters) DEF CL ESDS, KSDS, RRDS
Default:
Example:
None
DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER)) DATA (NAME (DA0004T.LIB.KSDS.DATA)) INDEX (NAME (DA0004T.LIB.KSDS.INDEX)) -
VSAM
46
The NAME parameter This is a required positional parameter. Format: (NAME (cluster name) cluster name: The name to be assigned to the cluster. None ESDS, KSDS, RRDS Yes
Example:
DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER)) DATA (NAME (DA0004T.LIB.KSDS.DATA)) INDEX (NAME (DA0004T.LIB.KSDS.INDEX))
VSAM
47
The DATA parameter The DATA parameter tells IDCAMS that you going to create a separate data component. DATA is optional, but if coded must follow all of the parameters that apply to the cluster as a whole. Format: DATA (NAME (data name) parameters) NAME parameter is optional, but you should usually code it. If coded, it must the first DATA parameter. data name: The name you choose to name the data component.
Abbreviation:
Used for: Required: Default: Example:
None
ESDS, KSDS, RRDS No None DATA (NAME (DA0004T.LIB.KSDS.DATA)) INDEX (NAME (DA0004T.LIB.KSDS.INDEX))
VSAM
48
Format:
IX KSDS No
Default:
Example:
None
INDEX (NAME (DA0004T.LIB.KSDS.INDEX))
VSAM
49
The SPACE ALLOCATION parameter The space allocation parameter specifies space allocation values in the units shown below: Format: Code only one of the following: CYLINDERS (primary secondary) or TRACKS (primary secondary) or RECORDS (primary secondary) or KILOBYTES (primary secondary) or MEGABYTES (primary secondary) CYL, TRK, REC, KB, MB KSDS, ESDS, RRDS Yes None
Example:
VSAM
50
Remark: It is best to apply space allocation to the entire cluster or to the data component, because VSAM then calculates the amount of space needed for the index, generally the most efficient technique; for example:
DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER) CYLINDERS (5 3) ) DATA (NAME (DA0004T.LIB.KSDS.DATA)) INDEX (NAME (DA0004T.LIB.KSDS.INDEX))
Or DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER) DATA (NAME (DA0004T.LIB.KSDS.DATA) CYLINDERS (5 3) ) INDEX (NAME (DA0004T.LIB.KSDS.INDEX))
VSAM
51
DEFINE CLUSTER
Primary : Allocated once when the dataset is created Secondary : Allocated a maximum of 122 times as needed during the life of the dataset
VSAM
52
The VOLUMES parameter The VOLUMES parameter assigns one or more storage volumes to your dataset. Multiple volumes must be of the same device type (3390, for example). Format: VOLUMES (vol ser) or VOLUMES (vol ser ........ vol ser) vol ser: The six-digit volume serial number of a volume. VOL KSDS, ESDS, RRDS Yes None VOLUMES (BS3011) VOLUMES (BS3011 BS3040 BS3042)
VSAM
53
DEFINE CLUSTER
You can store the data and index on separate volumes and this may provide a performance advantage for large dataset.
VSAM
54
The RECORDSIZE parameter This parameter tells VSAM what size records to expect. The avg and max are average and maximum values for variable-length records If records are of fixed length, avg and max should be the same.
Format:
RECORDSIZE (avg max) avg : Average length of records max : Maximum length of records
RECSZ KSDS, ESDS, RRDS No RECORDSIZE (4086 4086) RECORDSIZE (80 80) [Fixed Length records] RECORDSIZE (80 120) [Variable Length records]
RECORDSIZE can be assigned at the cluster or data level. For a KSDS, VSAM calculates the RECORDSIZE of the index based on the KEYS parameter.
VSAM
55
The KEYS parameter This parameter defines the length and offset of the primary key in a KSDS record. The offset is the primary keys displacement (in bytes) from the beginning of the record. Format: KEYS (length offset) length: length in bytes of the primary key offset: Offset in bytes of the primary key with records (0 to n)
Abbreviation:
Used for: Required: Default: Example:
None
KSDS No KEYS (64 1) KEYS (8 0)
VSAM
56
The dataset-type parameter This parameter specifies whether the dataset is INDEXED (KSDS), NONINDEXED (ESDS), or NUMBERED (RRDS).
Format:
IXD| NIXD | NUMD KSDS, ESDS, RRDS Yes INDEXED INDEXED NONINDEXED NUMBERED
VSAM
57
//DA0001TA JOB LA2719, PCS,MSGLEVEL=(1,1), MGCLASS=A,NOTIFY=DA0001T // * Define Cluster for ESDS VSAM Dataset //STEP1 EXEC PGM=IDCAMS // SYSPRINT DD SYSOUT=* // SYSIN DD * DEFINE CLUSTER (NAME (DA0001T.LIB.ESDS.CLUSTER) NONSPANNED REUSE NOERASE VOLUMES (BS3005) RECORDSIZE (80 80) RECORDS (30 50) CISZ (4096) SHR (1 3) ) DATA (NAME (DA0001T.LIB.KSDS.DATA)) /* //
VSAM
58
//DA0001TA JOB LA2719, PCS,MSGLEVEL=(1,1), MGCLASS=A,NOTIFY=DA0001T // * Define Cluster for KSDS VSAM Dataset //STEP1 EXEC PGM=IDCAMS // SYSPRINT DD SYSOUT=* // SYSIN DD * DEFINE CLUSTER (NAME (DA0001T.LIB.KSDS.CLUSTER) INDEXED KEYS (4 0) FSPC (10 20) NONSPANNED NOREUSE NOERASE VOLUMES (BS3005) SHR (1 3) ) DATA (NAME (DA0001T.LIB.KSDS.DATA) RECORDSIZE (80 80) RECORDS (30 50) CISZ (4096) ) INDEX (NAME (DA0001T.LIB.KSDS.INDEX)) VSAM /* //
59
The CONTROLINTERVALSIZE parameter This parameter specifies the Control Interval size. It is usually abbreviated CISZ.
Format:
CONTROLINTERVALSIZE (bytes)
bytes: The size of control interval in bytes. It should be a multiple of 512 or 2048 bytes, depending upon the type of catalog (ICF or VSAM) and the length of the record. VSAM rounds the CISZ value up to the next highest multiple of 512 Or 2048 if necessary.
CISZ KSDS, ESDS, RRDS No, because of the default Calculated by VSAM CISZ (4096)
Note: If omitted VSAM calculates CISZ based on record size and other control information
VSAM
60
Format:
FREESPACE (ci% ca%) ci%: - Percentage of control interval to leave free for expansion ca%: - Percentage of control area to leave free for expansion
FSPC KSDS No, because of default. FREESPACE (0 0) FREESPACE (20 10) FREESPACE (20) FREESPACE (0 30)
VSAM
61
DEFINE CLUSTER
This FREESPACE parameter, which applies to the KSDS, allocates some percentage of control interval and control area for planned freespace. This freespace can be used for adding new records or for expanding existing variable records.
VSAM
62
DEFINE CLUSTER
Too much freespace results in more i/o, especially when doing sequential processing. Too little results in excessive control interval and control area split
VSAM
63
The BUFFERSPACE parameter Buffer space represents the amount of storage (in bytes) required to process the contents of a minimum of one control intervals worth of data. Format: BUFFERSPACE (bytes) Bytes: The number of bytes to allocate to each buffer.
Abbreviation:
Used for: Required: Default: buffer for KSDS. Example:
BUFSP
KSDS, ESDS, RRDS No, because of default. Two data buffers for all types of datasets, plus one additional index
BUFSP (8704)
VSAM
64
The following example shows the AMP parameter specifying additional data buffers to accommodate sequential and random processing.
//DD1
//DD1 //
DD
DD
DSN=DA0001T.LIB.KSDS.CLUSTER,DISP=SHR,AMP=(BUFND=10)
DSN=DA0001T.LIB.KSDS.CLUSTER,DISP=OLD, AMP=(BUFND=10,BUFNI=3)
VSAM
65
The RECOVERY | SPEED parameter These parameters are mutually exclusive. RECOVERY, the default, reformats the control areas during your initial dataset load, so that you can restart the job if it abends for some reason. The disadvantage of this parameter is that programmer has to write recovery routine to restart the job. SPEED is faster and does not pre-format the control areas. You must reload the dataset from the beginning if the job fails during initial loading.
Format:
Abbreviation: Used for: Required: Default: Example:
RECOVERY | SPEED
RCVY | None KSDS, ESDS, RRDS No, because of default. RECOVERY RECOVERY SPEED
VSAM
66
The SPANNED | NONSPANNED parameter This parameter allows large record to span more than one control interval. However records cannot span Control Areas. The resulting free space in the spanned control interval is unusable by other records, even if they fit logically in the unused bytes. [NONSPANNED is the default] and it means that records cannot span control intervals Format: Abbreviation: Used for: Required: Default: Example: SPANNED | NONSPANNED SPND | NSPND KSDS, ESDS No, because of default. NONSPANNED NONSPANNED SPANNED
VSAM
67
The REUSE | NOREUSE parameter The REUSE parameter specifies that the cluster can be opened a second time as a reusable cluster. NOREUSE is the default, and specifies the cluster as non-reusable. Format: Abbreviation: REUSE | NOREUSE RUS | UNRUS
Used for:
Required: Default: Example:
VSAM
68
DEFINE CLUSTER
Some application call for temporary dataset or workfile that must be created, used and deleted each time the application run. To simplify these applications, VSAM lets you create reusable files.
VSAM
69
This parameter tells VSAM whether you want to let two or more jobs to process your file at the same time. It specifies how a VSAM dataset can be shared among different users.
Format: SHAREOPTIONS (cr value cs value) cr value : Specifies the value for cross region sharing. Cross region sharing is defined as different jobs running on the same system using Global Resource Serialization (GRS), a resource control facility available only under MVS/XA and ESA cs value : Specifies the value for cross system sharing means different jobs running on different system in a NONGRS environment Value 1 multiple read OR single write 2 multiple read AND single write 3 multiple read AND multiple write Abbreviation: Used for: Required: Default: Example: SHR KSDS, ESDS, RRDS No, because of default. SHR (1 3) SHR (1) SHR (2 3)
VSAM
70
DEFINE CLUSTER
cr value : Specifies the value for cross region sharing. Cross region sharing is defined as different jobs running on the same system using Global Resource Serialization(GRS), a resource control facility available only under MVS/XA and ESA cs value : Specifies the value for cross system sharing means different jobs running on different system in a NONGRS environment
VSAM
71
The ERASE | NOERASE parameter The ERASE parameter instructs VSAM to overwrite sensitive data component with binary zeros when the cluster is deleted. NOERASE is the default and means that the deleted cluster is not to be overwritten with binary zeros. Format: Abbreviation: Used for: Required: Default: Example: ERASE | NOERASE ERAS | NERAS KSDS, ESDS, RRDS No, because of default. NOERASE NOERASE ERASE
VSAM
72
The Password Protection Parameter VSAM provides a hierarchical list of parameters that you can specify for a non-DFSMS-managed VSAM dataset. However DFSMS-managed dataset you must use a security package like RACF. Format: MASTERPW (password) Allows the highest level of access to all cluster components, including DELETE and ALTER authority. UPDATEPW (password) Allows write authority to the cluster. READPW (password) Allows read-only access to the cluster. Abbreviation: Used for: Required: MRPW, UPDPW, RDPW KSDS, ESDS, RRDS No
Default: Example:
73
LISTCAT
VSAM
74
LISTCAT
LISTCATs basic function is to list information about VSAM and NONVSAM objects
VSAM
75
Format:
LISTCAT LEVEL (level) options entry name: The generic name of each entry to list. level: The level of qualification at which to begin listing. Abbreviation: LISTC ENT LIST LVL KSDS, ESDS, RRDS and non-VSAM No, because of default. All entries are listed if just LISTCAT is coded LISTCAT ENTRIES (da0001t.lib.ksds.cluster)
VSAM
76
VSAM
77
//STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * LISTCAT ENTRIES (DA0001T.LIB.KSDS.CLUSTER) ALL /* Example 4.2 LISTCAT Example LISTCAT LVL (DA0001T.*.KSDS) ALL
VSAM
78
LISTCAT
Example 1 : (in JCL) //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * LISTCAT ENTRIES(DA0001T.LIB.KSDS.CLUSTER) ALL /* Example 2 : (from TSO prompt) LISTCAT ENTRIES (LIB.KSDS.CLUSTER) ALL
VSAM
79
ALTERNATE INDEXES
VSAM
80
ALTERNATE INDEX
other fields of a record
Book No.
1 2 3 4 5 6 7 8 9 10 11 12 ... ... ... ... ... ... ... ... ... ... ... ...
Author
x y x z t x q z y b c t Data set having Book No as a Primary Key
VSAM
81
ALTERNATE INDEX
BASE CLUSTER (KSDS)
3 6 9 12 Index Component
1 ... x
2 ... y
3 ... x
us
C F C F C F C F
Data Component
4 ... Z
7 ... q 10 .. .b
5 ... t
8 ... z 11 ... c
6 ... x
9 ... y 12 ... t
us
us us
VSAM
82
ALTERNATE INDEX
Author Book No.
b
c
...
...
10
11
q
t x y z
...
... ... ... ...
7
5, 12 1, 3, 6 2, 9 4, 8
VSAM
83
Index Component
b 10
c 11
q 7
C F C F C F
12
Data Component
VSAM
84
ALTERNATE INDEX
Key Ptr Key Ptr
Index Component :
Control Interval 1
Hdr
Key
Ptr1
Ptr2
Ptr3
Hdr
Key Ptr 4
FSPC
U S
CF
Control Interval 2
Hdr
Key
Ptr9
Ptr10
Ptr11
Hdr
Key
Ptr12
FSPC
U S
CF
The pointers point to a control interval in the data component of the base cluster that contains the record
VSAM 85
DATA COMPONENT :
ALT-INDX-KEY SOC_SEC_NUM 9 PRM-KEY EMP_NUM 8
RECORDSIZE(22 22) <-------------- PRM_KEY (S) -------------> HK 5 AUTH-LAST_NAME 25 LIB_NUM 8 RECORDSIZE(54 110) LIB_NUM 8 LIB_NUM 8
ESDS :
VSAM
86
ALTERNATE INDEX(S)
May be defined on one or more than one Alternate Key(s) i.e. Field(s) other than primary key Alternate Key(s) need not be unique Separate cluster is defined A path is also defined for connection between base cluster and alternate index cluster Each ALT. Index itself is a KSDS Consists of both data component and an index component Alternate Index upgradation is by default For ESDS, Vsam builds ALT. index by mapping one field to the records RBA.
VSAM 87
ALTERNATE INDEX(S)
Supported only for assembler or online CICS
Creating an alternate index requires three separate steps: Define the alternate index using the IDCAMS DEFINE AIX command Define an alternate index path using the IDCAMS DEFINE PATH command Build the alternate index and populate it with records using the IDCAMS BLDINDEX command The above three steps need to repeated for each alternate index built over the base cluster.
VSAM
89
STEP 1: Defining the Alternate Index The first step in creating an alternate index is to define with the DEFINE AIX command The DEFINE ALTERNATEINDEX Command
Define the Alternate Index Cluster using the IDCAMS DEFINE AIX command. Format: Abbreviation: Use: Required: Default: Example: DEFINE ALTERNATEINDEX DEF AIX Alternate index over a KSDS, ESDS Yes, if an alternate index is defined. None DEFINE AIX
VSAM
90
The NAME parameter It is mandatory parameter that names the alternate index. Format: Abbreviation: Use: Required: Default: Example: NAME (index cluster name) None Alternate index over a KSDS, ESDS Yes, if an alternate index is defined. None NAME (da0001t.lib.ksds.ename.aix)
VSAM
91
The VOLUMES parameter The VOLUMES parameter specifies the volume (or volumes) where the alternate index is to be stored.
Format:
VOLUMES (vol ser) or VOLUMES (vol ser ... vol ser) Vol ser: The six-digit volume serial number of a volume.
VOL
Abbreviation:
Used for:
Required: Default: Example:
VSAM
92
The RELATE parameter This parameter establishes the relationship between the base cluster and the alternate index via the use of the base cluster name. It is unique to the DEFINE AIX command, and it is required. Format: Abbreviation: Use: Required: Default: RELATE (base cluster name) REL Alternate index over a KSDS, ESDS Yes, if an alternate index is defined. None
Example:
RELATE (da0001t.lib.ksds.cluster)
VSAM
93
The UPGRADE parameter Format: Abbreviation: Use: Required: Default: Example: UPGRADE | NOUPGRADE UPG | NUPG Alternate index over a KSDS, ESDS No, because of default. UPGRADE UPGRADE NOUPGRADE
VSAM
94
Changes made to the base cluster would be reflected automatically in all the alternates indexes provided you have specified UPGRADE option in each of the base clusters alternate indexes (DEFINE AIX command). For this to happen the application program has to open the base cluster The set of alternate indexes VSAM updates automatically is called Upgrade set
VSAM 95
The KEYS parameter This parameter defines the length and offset of the alternate index key. Format: KEYS (length offset) length: length in bytes of the alternate key offset: The offset is the keys displacement (in bytes) from the beginning of the record. None Alternate index over a KSDS, ESDS. No, because of the default. KEYS (64 0) KEYS (30 4)
VSAM
96
The RECORDSIZE parameter specifies the average and maximum of each alternate index record.
Format: Abbreviation: Use: Required: RECORDSIZE (avg max) RECSZ Alternate index over a KSDS, ESDS. No
Default:
Example:
VSAM
97
DATA COMPONENT :
ALT-INDX-KEY SOC_SEC_NUM 9 PRM-KEY EMP_NUM 8
RECORDSIZE(22 22) <-------------- PRM_KEY (S) -------------> HK 5 AUTH-LAST_NAME 25 LIB_NUM 8 RECORDSIZE(54 110) LIB_NUM 8 LIB_NUM 8
ESDS :
VSAM
98
The FREESPACE parameter This FREESPACE parameter, allocates some percentage of both the control interval and control area for planned free space. This free space can be used for adding new records. FREESPACE applies only to the data component Format: FREESPACE (ci% ca%) ci%: - Percentage of control interval to leave free for expansion ci%: - Percentage of control area to leave free for expansion Abbreviation: Use: FSPC Alternate index over KSDS, ESDS.
Required:
Default: Example:
VSAM
99
Other DEFINE AIX Parameters You can also add the following parameters to your DEFINE AIX command. These parameters have been described in DEFINE CLUSTER command. BUFFERSPACE (bytes) CISZ (bytes) ERASE | NOERASE REUSE | NOREUSE SHAREOPTIONS UNIQUEKEY | NONUNIQUEKEY
VSAM
100
//STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT =* //SYSIN DD * DEFINE AIX (NAME (DA0001T.LIB.KSDS.EMPNAME.AIX) VOLUMES (BS3013) RELATE (DA0001T.LIB.KSDS.CLUSTER) UPGRADE SHR (1 3) NOERASE NOREUSE KEYS (30 8) NONUNIQUEKEY FREESPACE (20 10) ) DATA (NAME (DA000A1T.LIB.KSDS.EMPNAME.DATA) TRACKS (10 1) RECORDSIZE (75 125) ) INDEX (NAME (DA0001T.LIB.KSDS.EMPNAME.INDEX)) /* //
VSAM
101
VSAM
102
DEFINE PATH Command A path is considered a VSAM object that does not contain any records. The path name is specified in the JCL for applications that access records via the alternate index. Format: Abbreviation: Use: Required: DEFINE PATH (NAME (path name) parameters) DEF PATH Alternate index over a KSDS, ESDS. Yes, for an alternate index.
Default:
Example:
None
DEFINE PATH (NAME (da0001t.lib.ksds.ename.path))
VSAM
103
The PATHENTRY parameter The PATHENTRY parameter specifies the alternate index cluster name. This establishes the pathentry between alternate index cluster and the path. Format: PATHENTRY (entry name) entry name: The name assigned to the alternate index cluster
Abbreviation:
Use: Required: Default: Example:
PENT
Alternate index over a KSDS, ESDS. Yes, for an alternate index. None PATHENTRY (da0001t.lib.ksds.ename.aix)
VSAM
104
The UPDATE parameter Format: Abbreviation: Use: Required: Default: Example: UPDATE | NOUPDATE UPD | NUPD Alternate index over a KSDS, ESDS. Yes, for an alternate index. UPDATE UPDATE NOUPDATE
VSAM
105
Changes made to the base cluster would be reflected automatically in all other alternates indexes provided you have specified UPDATE in DEFINE PATH and UPGRADE in DEFINE AIX command
For this to happen the application program has to open the alternate index path
VSAM
106
//STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT =* //SYSIN DD * DEFINE PATH (NAME (DA0001T.LIB.KSDS.EMPNAME.PATH) PATHENTRY (DA0001T.LIB.KSDS.AUTHNAME.AIX) UPDATE ) /* // Example JCL to define PATH for the AIX
VSAM
107
The BLDINDEX command Format: BLDINDEX INFILE (ddname) OUTFILE (ddname) INTERNALSORT | EXTERNALSORT INFILE and OUTFILE to DD statements. BLDINDEX INDATASET (dataset name) OUTDATASET (dataset name) INTERNALSORT | EXTERNALSORT Abbreviation: Use: Required: Default: BIX Alternate index over a KSDS, ESDS. Yes, for an alternate index. None
VSAM
109
The INFILE/INDATASET parameters The INFILE parameter specifies a DD statement that refers to the input dataset. The INDATASET parameter names the dataset. Format: Abbreviation: Use: Required: INFILE (ddname) | INDATASET (dataset name) IFILE | IDS KSDS, ESDS. Yes, you must code one or the other.
Default:
Example:
None
INFILE (dd1) INDATASET (da0001t.lib.ksds.cluster)
VSAM
110
The OUTFILE/OUTDATASET parameters The OUTFILE parameter specifies a DD statement that refers to the output dataset. The OUTDATASET parameter names the dataset. Format: Abbreviation: Use: Required: Default: Example: OUTFILE (ddname) | OUTDATASET (dataset name) OFILE | ODS KSDS, ESDS. Yes, you must code one or the other. None
VSAM
111
EXEC PG=IDCAMS DD SYSOUT =* DD DSN=DA0001T.LIB.KSDS.CLUSTER, DISP=OLD DD UNIT=SYSDA,SPACE=(TRK, (2, 1)) DD UNIT=SYSDA,SPACE=(TRK, (2, 1)) DD * BLDINDEX INFILE (DD1) OUTDATASET (da0001t.lib.ksds.empname.aix) INTERNALSORT
/* //
VSAM
112
VSAM
113
INDEX(NAME(DA0001T.LIB.KSDS.EMPNAME.INDEX)
VSAM
114
/*
VSAM 115
REPRO COMMAND
VSAM
117
REPRO
Loads empty VSAM cluster with records. Creates backup of a dataset Merges data from two datasets (REPLACE) Catalog information is not copied Incase of KSDS, data and index component are build automatically
VSAM
118
REPRO
Example Loading Dataset: //DD1 DD DSN=DA0001T.INPUT.KSDS,DISP=OLD //DD2 DD DSN=DA0001T.OUTPUT.KSDS, DISP=OLD //SYSIN DD * REPRO INFILE(DD1) OUTFILE(DD2) FROMKEY(A001) TOKEY(A069)
VSAM
119
REPRO
Backup Considerations
Easy to transport data to another system
DELETE-DEFINE-REPRO sequence required to restore the cluster incase of KSDS, CI & CA splits are eliminated, Primary index is rebuild, freespace redistributed. Alternate Indexes to be redefined
VSAM
120
DELETE-DEFINE-REPRO
Example :
//DD1 DD DSN=DA0001T.LIB.KSDS.BACKUP(0), // DISP=OLD, UNIT=TAPE,LABEL=(1,SL) //SYSIN DD * DELETE DA0001T.LIB.KSDS.CLUSTER DEFINE CLUSTER (NAME(DA0001T.LIB.KSDS.CLUSTER) INDEXED KEYS(4 0) RECORDSIZE(80 80) VOLUMES(BS3013) ) DATA(NAME(DA0001T.LIB.KSDS.DATA)) INDEX(NAME(DA0001T.LIB.KSDS.INDEX)) REPRO INFILE(DD1) VSAM OUTDATASET(DA0001T.LIB.KSDS.CLUSTER)
121
REPRO Command Format: REPRO INFILE (ddname) | INDATASET (dsname) OUTFILE (ddname) | OUTDATASET (dsname) optional parameters None KSDS, ESDS. RRDS Yes. None REPRO INFILE (dd2) OUTDATASET (da0001t.lib.ksds.empname.aix) -
VSAM
122
FROMKEY specifies the key of the input record at which to begin reading. TOKEY specifies the key of th record to write. You can code either or both parameters. Format: FROMKEY (key)
TOKEY (key) key: You can code an asterisk (*) as the last character. Copying starts or stops if a record is enco that matches all the characters up to *. Abbreviation: Use: Required: Default: Example: FKEY, TKEY KSDS, ISAM No First record in dataset for FROMKEY and last record in dataset for TOKEY. FROMKEY (PAI) TOKEY (PAI*)
VSAM
123
The FROMADDRESS and TOADDRESS parameters FROMADDRESS specifies the relative byte address (RBA) value of the key of the input record at which to begin copying. TOADDRESS specifies the relative byte address (RBA) value of the key of the last input record to copy. You can code either or both parameters. Format: FROMADDRESS (address)
TOADDRESS (address) address: The RBA address of the first or last record to copy.
Abbreviation: Use: Required: Default: dataset Example: FADDR, TADDR KSDS, ESDS No First record in dataset for FROMADDRESS and last record in for TOADDRESS.
VSAM
124
The FROMNUMBER and TONUMBER parameters FROMNUMBER specifies the relative record number of the first RRDS record to copy. TONUMBER specifies the relative record number of the last record to copy. You can code either or both parameters. Format:
FROMNUMBER (relative number) TONUMBER (relative number) relative number: The relative record number of the first or last to copy. The first record is number 0. FNUM, TNUM
record
Abbreviation:
Use:
Required: Default:
RRDS
No First record in dataset for FROMNUMBER and last record in dataset for TONUMBER.
VSAM
125
Example:
FROMNUMBER (10)
The SKIP and COUNT parameters SKIP specifies the number of input records to skip before beginning to copy. COUNT specifies the number of output records to skip to copy. You can code either or both parameters. Fomat: SKIP (number) COUNT (number) number: The number of records to skip or copy. Abbreviation: Use: Required: None KSDS, ESDS, RRDS, non-VSAM datasets No
Default: SKIP defaults to the first record in dataset, and COUNT defaults to all the records in the dataset.
Example:
SKIP (10)
126
DD DSN=DA0001T.INPUT.KSDS,DISP=OLD DD DSN=DA0001T.OUTPUT.KSDS, DISP=OLD DD * REPRO INFILE (DD1) OUTFILE (DD2) FROMKEY (A001) TOKEY (A069) Example JCL for Loading Dataset:
/*
VSAM
127
The REPRO command can also be used to merge two datasets into one. The target dataset can be a nonempty KSDS, ESDS or RRDS. If the target dataset is an ESDS, the merged records are added to the end of the existing dataset. You specify the REPLACE option as part of the REPRO command with duplicate primary keys (in case of a KSDS) or duplicate relative record numbers (in case of an RRDS) Format: Abbreviation: Use: Required: Default: Example: REPLACE REP KSDS, ESDS, RRDS No matching records are not replaced. REPLACE COUNT (500) -
VSAM
128
The VERIFY command Judicious use of the verify command is important for preserving data integrity. VERIFY verifies and updates the catalog with information from the physical end of the data in the cluster via a field called the HURBA (High Used Relative Address). VERIFY verifies that the catalog HURBA field stores the true values from the control block HURBA field in the data component. Format: VERIFY FILE (ddname /password) Or
Example:
129
The DELETE command The DELETE command can be used to delete both VSAM and non-VSAM objects. Format: DELETE entry name DELETE entry name/password options
Entry name: The name of the entry to delete. An asterisk can be coded as a wild card character in place of a name. Password: The password for the entry if there is one. Omit the /password if the entry doesnt have a password. Abbreviation: DEL
Use:
Required: Default: None.
VSAM
130
VSAM
131
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1),NOTIFY=DA0001T //* Deletes VSAM Dataset //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT = * //SYSIN DD * DELETE DA0001T.LIB.KSDS.CLUSTER ERASE /* //
VSAM
132
The PRINT command The PRINT command is used to view the contents of the dataset. Format: PRINT INDATASET (entry name/password) options PRINT INFILE (ddname/password) Entry name: The name of the entry to print Password: The password for the entry if there is one. Omit the /password if the entry doesnt have a password. ddname: The name of a DD statement
Abbreviation: PRINT IDS (entry name /password) PRINT IFILE (ddname /password) Use: Required: KSDS, ESDS, RRDS, non-VSAM No
Default: None. Example: PRINT da0001t.lib.ksds.cluster PRINT INDATASET (da0001t.lib.ksds.cluster) VSAM PRINT INFILE (dd1)
133
Options CHAR | DUMP | HEX COUNT (number) FROMADDRESS, [TOADDRESS] FROMKEY, [TOKEY] FROMNUMBER, [TONUMBER] OUTFILE (ddname) SKIP (number)
VSAM
134
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1),NOTIFY=DA0001T //* Print VSAM Dataset //PRG1 EXEC PGM=IDCAMS //FILE1 DD DSN=DA0001T.LIB.KSDS.CLUSTER, DISP=SHR //SYSPRINT DD SYSOUT = * // SYSIN DD * PRINT INFILE (FILE1) CHARACTER /* // Example Print VSAM Dataset
VSAM
135
If you want the printed output directed to other than SYSPRINT, such as another dataset, you can the OUTFILE parameter.
Format:
ddname: written. Abbreviation: Use: Required: Default: Example:
OUTFILE (ddname/password)
The name of a DD statement specifying where the output is to be
OFILE KSDS, ESDS, RRDS, non-VSAM No, because of default. OUTFILE (SYSPRINT) PRINT da0001t.lib.ksds.cluster OUTFILE (dd1) PRINT INDATASET (da0001t.lib.ksds.cluster)
VSAM
OUTFILE (dd1)
136
The ALTER command The general form of the ALTER command is as follows: Format: ALTER entry name/password parameters PRINT INFILE (ddname/password) Entry name: The name of the entry to alter
Password: The password for the entry if there is one. Omit the password if the entry doesnt have a password. parameters Abbreviation: None
Use:
Required: Default: None.
137
Change name of the object Add volumes/Remove volumes Change Keys and uniqueness Change record size Change Upgrade option Change % of FREESPACE etc.
VSAM
138
Options: ADDVOLUMES (volumes) AUTHORIZATION (entry string) BUFFERSPACE (size) ERASE | NOERASE FREESPACE (ci% ca%) MASTERPW (password) NEWNAME (newname) READPW (password) SCRATCH | NOSCRATCH (for GDG) SHAREOPTIONS (cross region cross system) TO (date) |FOR (days) UPDATE | NOUPDATE UPDATEPW (password) UPGRADE | NOUPGRADE
VSAM
139
ALTER DA0001T.LIB.KSDS.CLUSTER ADDVOLUMES (BS3001 BS3005) Example 7.7 Adding additional volumes
VSAM
140
The following attributes are unalterable. You have to DELETE the cluster and redefine it with new attributes. CISZ Cluster type, IMBED/REPLICATE REUSE | NOREUSE
VSAM
141
VSAM
142
Format:
VSAM
143
There are actually two HURBAs: one in the VSAM control block of the cluster and one in the catalog entry for the cluster. The danger is that if the catalog HURBA field is incorrect, theres a possibility that if that previously added records may be overwritten, especially in the event of this relationship.
Example 7.1
VERIFY
Remark: VERIFY can be issued from a TSO or within a JCL statement either the FILE or DATASET parameter.
VSAM
144
End of data
CA splits
Catalog
VSAM
145
Entry name: The name of the entry to delete. An asterisk can be coded as a wild card character in place of a name. Password: The password for the entry if there is one. Omit the /password if the entry doesnt have a password.
DELETE da0001t.lib.ksds.cluster
VSAM
146
VSAM
147
VSAM
148
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1),NOTIFY=DA0001T //* Deletes VSAM Dataset //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT = * //SYSIN DD * DELETE DA0001T.LIB.KSDS.CLUSTER ERASE /* //
VSAM
149
VSAM
150
The default output destination for PRINT is SYSPRINT. The following options are allowed: CHARACTER | DUMP | HEX or CHAR Options
CHAR | DUMP | HEX COUNT (number) FROMADDRESS, [TOADDRESS] FROMKEY, [TOKEY] FROMNUMBER, [TONUMBER] OUTFILE (ddname) SKIP (number)
VSAM
151
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1),NOTIFY=DA0001T //* Print VSAM Dataset //PRG1 EXEC PGM=IDCAMS //FILE1 DD DSN=DA0001T.LIB.KSDS.CLUSTER, // //SYSPRINT DD SYSOUT = * // SYSIN DD * PRINT INFILE (FILE1) CHARACTER /* //
DISP=SHR
If you want the printed output directed to other than SYSPRINT, such as another dataset, you can the OUTFILE parameter.
VSAM
152
Format:
OUTFILE (ddname/password)
ddname: The name of a DD statement specifying where the output is to be written. Abbreviation: Use: Required: Default: Example: PRINT da0001t.lib.ksds.cluster OUTFILE (dd1) PRINT INDATASET (da0001t.lib.ksds.cluster) OFILE KSDS, ESDS, RRDS, non-VSAM No, because of default. OUTFILE (SYSPRINT)
OUTFILE (dd1)
VSAM
153
ALTER da0001t.lib.ksds.cluster
VSAM
154
You can use this powerful command to change certain (but by no means all) attributes of a previously defined VSAM object. These objects include a base cluster and its data or index component, an alternate index cluster and its data or index component. The following is a list of common attributes that are completely alterable.
Options:
ADDVOLUMES (volumes) AUTHORIZATION (entry string) BUFFERSPACE (size) ERASE | NOERASE FREESPACE (ci% ca%) MASTERPW (password) NEWNAME (newname) READPW (password) SCRATCH | NOSCRATCH (for GDG) SHAREOPTIONS (cross region cross system) TO (date) |FOR (days) UPDATE | NOUPDATE UPDATEPW (password) UPGRADE | NOUPGRADE
VSAM
156
ALTER
ALTER
VSAM
157
The following attributes are unalterable. You have to DELETE the cluster and redefine it with new attributes.
VSAM
158
VSAM
159
VERIFY
Verify - preserves data integrity (HURBA) Format : VERIFY FILE(ddname/passwd) or VERIFY DATASET(entryname/passwd) VERIFY entryname/passwd (TSO) Example : VERIFY DATASET(DA0001T.LIB.KSDS.CLUSTER) Remark : 1. VERIFY can be issued from a TSO or within a JCL statement. 2. It is valid only for VSAM dataset except LDS.
VSAM 160
DELETE
- logically deletes dataset - catalog entry deleted
Format : DELETE entryname/passwd optional parameters Example : DELETE DA0001T.LIB.KSDS.CLUSTER ERASE Optional parameters are : - AIX - ERASE | NOERASE - CLUSTER - FORCE | NOFORCE - NONVSAM - PURGE | NOPURGE - PATH - SCRATCH | NOSCRATCH
VSAM
161
PRINT
default O/P destinations is SYSPRINT prints in CHAR/HEX/DUMP format limiting parameters like REPRO are available Format 1 : PRINT INDATASET (entryname/passwd) options Format 2 : PRINT INFILE (ddname/passwd) options
VSAM
162
PRINT
Options
FROMADDRESS, [TOADDRESS]
FROMKEY, [TOKEY] FROMNUMBER, [TONUMBER] OUTFILE (ddname) SKIP (number)
VSAM 163
ALTER
Used to change certain attributes of a previously defined VSAM object Following can be done with ALTER change names Add volumes/Remove volumes Change Keys and uniqueness Change record size Change Upgrade option Change % of freespace etc.
Format :
VSAM
164
ALTER
Options :
ADDVOLUMES (volumes)
BUFFERSPACE (size)
ERASE | NOERASE FREESPACE(ci% ca%) MASTERPW(password) NEWNAME(newname)
READPW (password)
VSAM
165
ALTER
SCRATCH | NOSCRATCH
VSAM
166
ALTER
Examples
ALTER DA0001T.LIB.KSDS.CLUSTER NEWNAME(A2000.MY.CLUSTER) ALTER DA0001T.LIB.KSDS.INDEX FREESPACE(30 30) -
ALTER
The following attributes are unalterable. You have to DELETE the cluster and redefine it with new attributes.
- CISZ
- Cluster type,
- IMBED/REPLICATE
- REUSE | NOREUSE
VSAM
168
SAMPLE PROGRAMS
VSAM
169
SAMPLE PROGRAM
//DA0001TA JOB LA1279,PCS,MSGLEVEL=(1,1), // MSGCLASS=A, NOTIFY=DA0001T //* Input instream Data into ESDS VSAM Dataset // STEP1 EXEC PGM=IDCAMS // SYSPRINT DD SYSOUT = * // DD1 DD * 123456789123456789 AAAAAAAABBBBBBCCCC /* //DD2 DD DSN=DA0001T.ESDS.CLUSTER //SYSIN DD * REPRO INFILE(DD1) OUTFILE(DD2) VSAM /*
170
SAMPLE PROGRAM
//DA0001TA JOB LA2719,PCS,MSGLEVEL= (1,1),
// MSGCLASS=A, NOTIFY=DA0001T //* Load Data from a file into ESDS VSAM Dataset
//STEP1
//SYSPRINT //DD1
EXEC PGM=IDCAMS
DD SYSOUT = * DD DSN=DA0001T.ESDS.CLUSTER1
//DD2
//SYSIN
DD DSN=DA0001T.ESDS.CLUSTER2
DD * REPRO INFILE(DD1 OUTFILE(DD2) -
/*
VSAM
171
SAMPLE PROGRAM
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1) ,
//
//* Print VSAM Dataset //PRG1
NOTIFY=DA0001T
EXEC PGM=IDCAMS
//FILE1
//
DD DSN=DA0001T.LIB.KSDS.CLUSTER,
DISP=SHR DD SYSOUT = *
//SYSPRINT
// SYSIN
/* //
DD *
VSAM
172
SAMPLE PROGRAM
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1) ,
//
//STEP1
NOTIFY=DA0001T
EXEC PGM=IDCAMS
//SYSPRINT
//SYSIN
DD SYSOUT = *
DD *
DELETE DA0001T.TRAIN.ITMFOIV
/*
//
VSAM
173
VSAM
174
VSAM
175
VSAM
176
VSAM
178
VSAM
184
FEATURES OF GDGs
All datasets within a GDG will have the same name Generation number of a dataset within a GDG is automatically assigned by OS when created Datasets within a GDG can be referenced by there relative generation number Generation 0 always references current generation
VSAM
185
GDGs
CREATION OF GDGs Create and catalog the index Use IDCAMS statement DEFINE GDG for creating Index Parameters for creating index SPECIFICATION Name of GDG Number of generations Uncataloging oldest generation once limit reached Uncataloging all generations when limit reached Physical deletion of entry Uncataloging entry without physical deletion VSAM 186 Defining a model for the GDG.
GDGs
VSAM
187
GDGs
JCL for creating index
//STEP1 EXEC PGM=IDCAMS
//SYSIN
DD
DEFINE GDG (NAME(DA0001T.ACCOUNTS.MONTHLY) LIMIT(5) EMPTY SCRATCH ) -
/*
//
VSAM
188
GDGs
Modifying Features of GDG Can be modified by the ALTER command
Example : //STEP1 EXEC PGM=IDCAMS //SYSIN DD ALTER DA0001T.ACCOUNTS.MONTHLY NOSCRATCH EMPTY /* //
VSAM
189
GDGs
Deleting GDG Index Can be deleted by the DELETE parameter of IDCAMS Will result in an error on reference to any generation datasets of the GDG
/STEP1 EXEC PGM=IDCAMS //SYSIN DD DELETE DA0001T.ACCOUNTS.MONTHLY GDG /* //
VSAM
190
GDGs
Adding a Dataset to a GDG Name of the model containing the GDG DCB parameters is coded in the DCB parameter of the DD statement
Example :
//STEP1 //FILE1 // // // // EXEC PGM=GDG1 DD DSN=DA0001T.ACCOUNTS.MONTHLY(+1), DISP=(NEW,CATLG,DELETE),UNIT=SYSDA, SPACE=(TRK,(30,10),RLSE), DCB=(MODEL.DCB,RECFM=FB,LRECL=80, BLKSIZE=800)
VSAM
191
GDGs
Deleting GDG Index and Datasets FORCE parameter in the DELETE statement of IDCAMS can be used
Example :
/STEP1 EXEC PGM=IDCAMS //SYSIN DD DELETE DA0001T.ACCOUNTS.MONTHLY GDG FORCE /* //
VSAM
192
VSAM
193
COBOL-VSAM CONSIDERATIONS
SELECT CLAUSE
SELECT file ASSIGN TO DDNAME / AS-DDNAME ORGANIZATION IS SEQUENTIAL/INDEXED/RELATIVE ACCESS MODE IS SEQUENTIAL/DYNAMIC/RANDOM RECORD KEY IS <primary Key Dataname> ALTERNATE KEY IS <Alternate Key Dataname> [WITH DUPLICATES] FILE STATUS IS status-key
Note: A prefix AS- has to be attached to DDNAME to indicate to COBOL that the file selected is an ESDS dataset.
VSAM 194
VSAM
195
COBOL-VSAM CONSIDERATIONS
Alternate index processing : In your JCL there must be a DD statement for base cluster and one or more DD statement for alternate index path name. Note: There is no COBOL standard for assigning ddnames to alternate indexes,so a quasi-standard has emerged whereby a sequential number is appended to the eighth character of the base cluster ddname.
VSAM
196
COBOL-VSAM CONSIDERATIONS
For e.g : //LIBMAST DD DSN=DA0001T.LIB.KSDS.CLUSTER, // DISP=SHR
//LIBMAST1 DD DSN=DA0001T.LIB.KSDS.NAME.PATH,
//
DISP=SHR
In the example above LIBMAST is the base cluster and LIBMAST1, LIBMAST2 are path names of Alternate Indexes built on the base cluster
VSAM 197
COBOL-VSAM CONSIDERATIONS
REMARK: No matter how many alternate indexes you specify in the program, there is only one ASSIGN clause pointing to the ddname of the base cluster.
SELECT file ASSIGN TO LIBMAST RECORD KEY IS ............ ALTERNATE KEY IS ......... [WITH DUPLICATES] ALTERNATE KEY IS ......... [WITH DUPLICATES]
FD : Should
have record description having primary key dataname and alternate key VSAM dataname
198
COBOL-VSAM CONSIDERATIONS
Key of Reference The key that is currently being used to access records. primary key becomes, by default, the key of reference. To access records by an alternate index key, you merely change the key of reference by using the KEY phrase as part of one of the following statements. A random READ statement, for example
READ EMP-MAST KEY IS EMP-NAME
VSAM
200
For these status key values,bypass the record,display pertinent information, and continue processing : 21 Input record out of sequence. 22 duplicate primary key or unique alternate key encountered(un-expected). 23 record (or Key) not found.
VSAM 201
You may want to have the program count the number of times these key values are returned and terminate the program if the counter reaches an unacceptable number, which is likely to indicate that your input is bad
VSAM
202
VSAM
203
96
97
If your shop has enabled the implicit VERIFY command, this means that the dataset was opened after and implicit VERIFY, and you can continue processing.
VSAM
204
BIBLIOGRAPHY
MVS/VSAM for Application Programmer by Brown and Smith
VSAM
205