v2_1_vsam_ppt

205
VSAM 1 VIRTUAL STORAGE ACCESS METHOD (VSAM) Version 2.1

Upload: deepugowda89

Post on 26-Oct-2014

124 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: V2_1_VSAM_ppt

VSAM 1

VIRTUAL STORAGE ACCESS METHOD(VSAM)Version 2.1

Page 2: V2_1_VSAM_ppt

VSAM 2

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

Page 3: V2_1_VSAM_ppt

VSAM 3

VSAM HISTORY

B] A+RRDS & AIX, Catld. Facility Enhanced VSAM

C] DF/EF VSAMICF Cataloging

MVS/XA Ver. 1Changes were compatible

with DF/EF VSAM

A] Standard VSAM. Only ESDS & KSDS

MVS/XA Ver. 2LDS were added

Page 4: V2_1_VSAM_ppt

VSAM 4

FEATURES OF VSAM• One coherent file storage system

(Stores and Retrieves Data)

• Not a database management system

• Not a programming language

• Not a communication system

• VSAM has no equivalent for a ‘PDS’

• Introduction by IBM in 1973

DFP/VSAM Ver 1 in 1989

Page 5: V2_1_VSAM_ppt

VSAM 5

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

Page 6: V2_1_VSAM_ppt

VSAM 6

TYPES OF VSAM DATASETS

• Based on the way in which we store and access the records:

KSDS Key Sequenced dataset

ESDS Entry Sequenced dataset

RRDS Relative record dataset

LDS Linear dataset

• 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

Page 7: V2_1_VSAM_ppt

VSAM 7

• 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

CLUSTERS

Page 8: V2_1_VSAM_ppt

VSAM 8

CLUSTERS

INDEX COMPONENT

DATACOMPONENT

I. KSDS CLUSTER

DATACOMPONENT

II. ESDS, RRDS Cluster

Page 9: V2_1_VSAM_ppt

VSAM 9

VSAM RECORDS

• Can be fixed or variable length

• Records can also be spanned

• A Linear dataset has no records

Note : LDS - Linear dataset

(Newest Type)

It is just a long string of bytes divided into 4k pages. Accessed by Relative Byte Address

Page 10: V2_1_VSAM_ppt

VSAM 10

CONTROL INTERVAL

• A control interval is the unit of data VSAM transfers between virtual and disk storage

• Is similar to the concept of blocking in non-VSAM files.

• Generally contains more than one record

• The size of CI must be between 512 bytes to 32K

• Upto 8K bytes it must be multiple of 512, beyond this it is multiple of 2K.

• Fixed length, selected at file creation time

• For index, the size of CI is 512, 1K, 2K or 4K bytes

Page 11: V2_1_VSAM_ppt

VSAM 11

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

• RDF is of 3 bytes long

Page 12: V2_1_VSAM_ppt

VSAM 12

CONTROL INTERVAL

FSPSUS CF

Logical Record Area (LRA)Freespace Unused Control

Space Field

Rec 1 Rec 3Rec 2

<------------------- CISZ ------------------------>

RDF<---3 bytes--->

CIDF<---4 bytes---->

Record definitionField

Control IntervalDefinition Field

CF

Logical Record Area (LRA)

Page 13: V2_1_VSAM_ppt

VSAM 13

• VSAM groups control intervals into contiguous, fixed length areas of storage called control areas.

• Maximum of 1 cylinder

• Can specify freespace in CA

• Number of CI/CA is fixed by VSAM.

CONTROL AREA(CA)

CONTROL INTERVAL

CONTROL INTERVAL

CONTROL INTERVAL

CONTROL INTERVAL

Page 14: V2_1_VSAM_ppt

VSAM 14

• 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

• Can only be used in ESDS and KSDS

• A CI that contains a record segment of a spanned record contains no other data

SPANNED RECORDS

Page 15: V2_1_VSAM_ppt

VSAM 15

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 used

Page 16: V2_1_VSAM_ppt

VSAM 16

HURBA AND HARBA

HARBA

HURBA

VSAM clusterData space allocated but empty

Data space loaded with records

Page 17: V2_1_VSAM_ppt

VSAM 17

VSAM DATASET STRUCTURE

Page 18: V2_1_VSAM_ppt

VSAM 18

KSDS

• It is similar in many ways to ISAM file, with better index structure and improved overflow handling

• Can be processed sequentially and randomly

• A KSDS consists of two components:

• Index component

• Data component

Page 19: V2_1_VSAM_ppt

VSAM 19

DATA Component

I

II

III

IV

V

VI

Data Component Control Intervals

Control Areas

Page 20: V2_1_VSAM_ppt

VSAM 20

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)

Page 21: V2_1_VSAM_ppt

VSAM 21

Key Ptr Key Ptr

CI1 CI2 CI3 CI3 CI4 CI5

Index Set and control areas for a KSDS

Control Area 1 Control Area 2

Sequence Set 1 Sequence Set 2

IndexSet

Index C

ompone

ntD

ata C

omponent

Control

Areas

Key Ptr Key Ptr Key PtrKey Ptr Key Ptr Key Ptr

Sequence Set

KSDS STRUCTURE

Page 22: V2_1_VSAM_ppt

VSAM 22

KSDS STRUCTURE

48424(SS-REC-1)

95651(SS-REC-2)

Hdr

Hdr 48011(CI - 1)

48303(CI - 2)

48424(CI - 3)

Hdr 91761(CI - A)

95651(CI - B)

SS-Rec-1 SS-Rec-2

Binary

Zeroes

SequenceSet Records

Index Set Record

Horizontal pointers

Page 23: V2_1_VSAM_ppt

VSAM 23

KSDS STRUCTURE

CONTROL AREA 2

44012 44039 44136 FSPC 48012 48013 FSPC FSPC

48304 48416 48424 FSPC

CI-1

CI-2

CI-3

48525 90064 90403 FSPC 91762 92373 95651 FSPC

FREE SPACE

CI-A

CI-B

CI-C

Da

ta R

eco

rds

CONTROL AREA 1

Page 24: V2_1_VSAM_ppt

VSAM 24

SEQUENCE SET OF KSDSKey Ptr C 100

Key PtrF 300

Key Ptr I 200

Key Ptr L 400

RecA

RecB

RecC FSPC

RecE

RecJ

RecK

RecL

FSPC

FSPC

FSPC

RecD

RecG

RecH

RecI

Control Interval 4

Control Interval 3

Control Interval 2

Control Interval 1100

200

300

400

CF

CF

CF

CF

Page 25: V2_1_VSAM_ppt

VSAM 25

NewRecord

Before Inserting

After Inserting

Record 1 Record 2 Record 3 FSPC US

CF

Record 1 Record 2 Record 3 FSPCUS

CFNew Record

INSERTION & DELETION OF RECORDS

CONTROL INTERVAL SPLIT

Page 26: V2_1_VSAM_ppt

VSAM 26

Record 1

Record 2

NewRecord

Record 3

US CFFSPC

To Delete

After Deletion:

Before Deletion:

Record 1

Record 2

Record 3

US CFFSPC

CONTROL INTERVAL SPLIT

INSERTION & DELETION OF RECORDS

Page 27: V2_1_VSAM_ppt

VSAM 27

CONTROL INTERVAL SPLIT

NewRecord

Record1

Record2

Record3

Record4

Record5

Before Control Interval Split

US

CF

US

CF

FullControlInterval

EmptyControlInterval

FSPC

Page 28: V2_1_VSAM_ppt

VSAM 28

CONTROL INTERVAL SPLIT

After Control Interval Split

Record 2

NewRecord FSPC

Record 1

US CF

Record 4

Record5 FSPC

Record 3

US CF

Page 29: V2_1_VSAM_ppt

VSAM 29

Before Control Interval Split

Sequence set

RecordC

RecordB

RecordA

RecordF

RecordG

US

CF

RecordK

RecordJ FSPC

US

CF

FSPC US

CF

0

100

200

Dat

a C

ompo

nent

CONTROL INTERVAL SPLIT

I 0 K 100

Page 30: V2_1_VSAM_ppt

VSAM 30

FSPC US

CFRecord

FRecord

G

CONTROL INTERVAL SPLIT

Sequence set

RecordB

RecordA

RecordC

FSPC US

CF

RecordK

RecordJ FSPC

US

CF

0

100

200

Dat

a C

ompo

nent

E 0 I 200 K 100

Page 31: V2_1_VSAM_ppt

VSAM 31

CONTROL AREA SPLIT

060 180 190

001 012 018

061 100 145 170

025 050

181 190

02 06 18 19

001 012 018

145

025 030 050

181 190

170

After adding 030 and 110

024 050

001 012 018

025 030 050

CA split after adding 111

111 145 170

061 100 110

061 110

110 180 190

100

181 190

Seq Set

DA

TA

AR

EA

DA

TA

AR

EA

Seq Set

Page 32: V2_1_VSAM_ppt

VSAM 32

IDCAMS COMMANDS

Page 33: V2_1_VSAM_ppt

VSAM 33

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

IDCAMS

Page 34: V2_1_VSAM_ppt

VSAM 34

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

Page 35: V2_1_VSAM_ppt

VSAM 35

IDCAMS

Commands

FUNCTIONAL Commands

DEFINE

BUILDINDEX REPRO

PRINT DELETE

VERIFY ALTER

LISTCAT

MODAL Commands

IF-THEN-ELSE

SET

Page 36: V2_1_VSAM_ppt

VSAM 36

// 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.

/*

//

IDCAMS

Page 37: V2_1_VSAM_ppt

VSAM 37

IDCAMSOptionally:

// 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

Page 38: V2_1_VSAM_ppt

VSAM 38

FORMAT OF IDCAMS COMMAND

verb object (parameters)

Example :

DEFINE CLUSTER - NAME(DA0001T.LIB.KSDS.CLUSTER) -

CYLINDERS(5, 1) -

VOLUMES (BS3013) -

INDEXED -

)

Comment

/* comment */

IDCAMS

Page 39: V2_1_VSAM_ppt

VSAM 39

CONDITION CODE:

0 : command executed with no errors

4 : warning - execution may go successful

8 : serious error - execution may fail

12 : serious error - execution impossible

16 : fatal error - job step terminates

• condition codes are stored in LASTCC/MAXCC

• both LASTCC and MAXCC contain zero by default at the start of IDCAMS execution

IDCAMS RETURN CODES

Page 40: V2_1_VSAM_ppt

VSAM 40

IF LASTCC/MAXCC comparand VALUE -

THEN -

command

ELSE

command

IF Syntax

Page 41: V2_1_VSAM_ppt

VSAM 41

• Comparands are : EQ/NE/GT/LT/GE/LE

• Hyphen is the continuation character

• Comment is assumed as Null statement

• ELSE is optional

IF Syntax

Page 42: V2_1_VSAM_ppt

VSAM 42

IF Syntax Example.........

REPRO INFILE (INDD) -

OUTFILE (OUTDD)

................

IF LASTCC EQ 0 -

THEN -

PRINT OUTFILE (INDD)

ELSE

PRINT INFILE (OUTDD)

Page 43: V2_1_VSAM_ppt

VSAM 43

IF MAXCC LT 4 -

THEN -

DO

/* COMMENT */

Command

Command

END

ELSE

Command

USE OF DO/END

Page 44: V2_1_VSAM_ppt

VSAM 44

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

e.g.

DEFINE CLUSTER

IF LASTCC > 0 THEN -

SET MAXCC = 16

ELSE REPRO

SET COMMAND

Page 45: V2_1_VSAM_ppt

VSAM 45

DEFINING A CLUSTER

Page 46: V2_1_VSAM_ppt

VSAM 46

The DEFINE CLUSTER Command This command tells IDCAMS to create and name a VSAM cluster. Format: DEFINE CLUSTER (NAME (cluster name) parameters)

Abbreviation: DEF CL

Used for: ESDS, KSDS, RRDS

Default: None Example: DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER)) -

DATA (NAME (DA0004T.LIB.KSDS.DATA)) - INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

Page 47: V2_1_VSAM_ppt

VSAM 47

The NAME parameter This is a required positional parameter. Format: (NAME (cluster name)

cluster name: The name to be assigned to the cluster. Abbreviation: None Used for: ESDS, KSDS, RRDS Default: Yes Example: DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER)) -

DATA (NAME (DA0004T.LIB.KSDS.DATA)) - INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

Page 48: V2_1_VSAM_ppt

VSAM 48

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: None Used for: ESDS, KSDS, RRDS Required: No Default: None Example: DATA (NAME (DA0004T.LIB.KSDS.DATA)) INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

Page 49: V2_1_VSAM_ppt

VSAM 49

The INDEX parameter The INDEX parameter creates a separate index component. INDEX is optional, but if coded must follow all of the parameters that apply only to the data component. Format: INDEX (NAME (index name) parameters) 

index name: The name you choose for the index component. Abbreviation: IX Used for: KSDS Required: No Default: None Example: INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

Page 50: V2_1_VSAM_ppt

VSAM 50

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) orTRACKS (primary secondary) orRECORDS (primary secondary) or

KILOBYTES (primary secondary) orMEGABYTES (primary secondary)

 Abbreviation: CYL, TRK, REC, KB, MB  Used for: KSDS, ESDS, RRDS Required: Yes Default: None Example: CYLINDERS (10 4)

RECORDS (400 500)

Page 51: V2_1_VSAM_ppt

VSAM 51

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))

Page 52: V2_1_VSAM_ppt

VSAM 52

• Primary : Allocated once when the dataset is created• Secondary : Allocated a maximum of 122 times as needed

during the life of the dataset

DEFINE CLUSTER

Page 53: V2_1_VSAM_ppt

VSAM 53

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. Abbreviation: VOL  Used for: KSDS, ESDS, RRDS Required: Yes Default: None Example: VOLUMES (BS3011)

VOLUMES (BS3011 BS3040 BS3042)

Page 54: V2_1_VSAM_ppt

VSAM 54

You can store the data and index on separate volumes and

this may provide a performance advantage for large dataset.

DEFINE CLUSTER

Page 55: V2_1_VSAM_ppt

VSAM 55

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 Abbreviation: RECSZ  Used for: KSDS, ESDS, RRDS Required: No Default: RECORDSIZE (4086 4086) Example: 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.

Page 56: V2_1_VSAM_ppt

VSAM 56

The KEYS parameter This parameter defines the length and offset of the primary key in a KSDS record.The offset is the primary key’s displacement (in bytes) from the beginning of the record. Format: KEYS (length offset)

length: length in bytes of the primary keyoffset: Offset in bytes of the primary key with records (0 to n)

 Abbreviation: None  Used for: KSDS Required: No Default: KEYS (64 1) Example: KEYS (8 0) VSAM records begin in position zero

Page 57: V2_1_VSAM_ppt

VSAM 57

The dataset-type parameterThis parameter specifies whether the dataset is INDEXED (KSDS), NONINDEXED (ESDS), or NUMBERED (RRDS). Format: INDEXED| NONINDEXED | NUMBERED

INDEXED: - Specifies a KSDS and is the defaultNONINDEXED: - Specifies an ESDS. No index is created and records are accessed sequentially or by relative byte addressNUMBERED: - Specifies an RRDS

LINEAR: - Specifies a LINEAR dataset Abbreviation: IXD| NIXD | NUMD  Used for: KSDS, ESDS, RRDS Required: Yes Default: INDEXED Example: INDEXED

NONINDEXEDNUMBERED

Page 58: V2_1_VSAM_ppt

VSAM 58

//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)) /*//

Page 59: V2_1_VSAM_ppt

VSAM 59

//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)) /*//

Page 60: V2_1_VSAM_ppt

VSAM 60

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.

 Abbreviation: CISZ Used for: KSDS, ESDS, RRDS Required: No, because of the default Default: Calculated by VSAM Example: CISZ (4096) Note: If omitted VSAM calculates CISZ based on record size and other control information

Page 61: V2_1_VSAM_ppt

VSAM 61

The FREESPACE parameter 

Format: FREESPACE (ci% ca%) 

ci%: - Percentage of control interval to leave free for expansionca%: - Percentage of control area to leave free for expansion

 Abbreviation: FSPC  Used for: KSDS Required: No, because of default. Default: FREESPACE (0 0) Example: FREESPACE (20 10)

FREESPACE (20) Control interval onlyFREESPACE (0 30) Control area only

Page 62: V2_1_VSAM_ppt

VSAM 62

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.

DEFINE CLUSTER

Page 63: V2_1_VSAM_ppt

VSAM 63

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

Page 64: V2_1_VSAM_ppt

VSAM 64

The BUFFERSPACE parameter Buffer space represents the amount of storage (in bytes) required to process the contents of a minimum of one control interval’s worth of data.  Format: BUFFERSPACE (bytes) 

Bytes: The number of bytes to allocate to each buffer. Abbreviation: BUFSP Used for: KSDS, ESDS, RRDS Required: No, because of default. Default: Two data buffers for all types of datasets, plus one additional index buffer for KSDS. Example: BUFSP (8704)

Page 65: V2_1_VSAM_ppt

VSAM 65

The following example shows the AMP parameter specifying additional data buffers to accommodate sequential and random processing. //DD1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,DISP=SHR,AMP=(‘BUFND=10’) //DD1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,DISP=OLD,// AMP=(‘BUFND=10’,BUFNI=3’)

Page 66: V2_1_VSAM_ppt

VSAM 66

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: RECOVERY | SPEED Abbreviation: RCVY | None Used for: KSDS, ESDS, RRDS Required: No, because of default. Default: RECOVERY Example: RECOVERY

SPEED

Page 67: V2_1_VSAM_ppt

VSAM 67

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: SPANNED | NONSPANNED

Abbreviation: SPND | NSPND  Used for: KSDS, ESDS Required: No, because of default. Default: NONSPANNED  Example: NONSPANNED

SPANNED

Page 68: V2_1_VSAM_ppt

VSAM 68

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: REUSE | NOREUSE

Abbreviation: RUS | UNRUS  Used for: KSDS, ESDS, RRDS Required: No, because of default. Default: NOREUSE Example: REUSE

NOREUSE

Page 69: V2_1_VSAM_ppt

VSAM 69

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.

DEFINE CLUSTER

Page 70: V2_1_VSAM_ppt

VSAM 70

The SHAREOPTIONS parameter 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 ESAcs value : Specifies the value for cross system sharing means different jobs running on different system in a NONGRS

environmentValue1 multiple read OR single write2 multiple read AND single write3 multiple read AND multiple write

Abbreviation: SHR  Used for: KSDS, ESDS, RRDS Required: No, because of default. Default: SHR (1 3)Example: SHR (1)

SHR (2 3)

Page 71: V2_1_VSAM_ppt

VSAM 71

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

DEFINE CLUSTER

Page 72: V2_1_VSAM_ppt

VSAM 72

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: ERASE | NOERASE

Abbreviation: ERAS | NERAS  Used for: KSDS, ESDS, RRDS Required: No, because of default. Default: NOERASE Example: NOERASE

ERASE

Page 73: V2_1_VSAM_ppt

VSAM 73

The Password Protection ParameterVSAM 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: MRPW, UPDPW, RDPW  Used for: KSDS, ESDS, RRDS Required: No Default: NoneExample: MASTERPW (PATNI)

UPDATEPW (XYZ) or READPW (ABC)

Page 74: V2_1_VSAM_ppt

VSAM 74

LISTCAT

Page 75: V2_1_VSAM_ppt

VSAM 75

LISTCATs basic function is to list information about VSAM and NONVSAM objects

LISTCAT

Page 76: V2_1_VSAM_ppt

VSAM 76

Format: LISTCAT ENTRIES (entry name) options 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  Used for: KSDS, ESDS, RRDS and non-VSAM Required: No, because of default. Default: All entries are listed if just LISTCAT is coded Example: LISTCAT ENTRIES (da0001t.lib.ksds.cluster) 

LISTCAT LEVEL (da0001t.lib.ksds. *) 

Page 77: V2_1_VSAM_ppt

VSAM 77

Options are:         HISTORY or HIST         VOLUME or VOL         ALLOCATION or ALLOC         ALL

Examples:   

LISTCAT ENTRIES (DA0001T.VSAM.KSDS.CLUSTER) - CLUSTER - ALL 

Page 78: V2_1_VSAM_ppt

VSAM 78

//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

Page 79: V2_1_VSAM_ppt

VSAM 79

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

LISTCAT

Page 80: V2_1_VSAM_ppt

VSAM 80

ALTERNATE INDEXES

Page 81: V2_1_VSAM_ppt

VSAM 81

ALTERNATE INDEX

1 ... x2 ... y3 ... x4 ... z5 ... t6 ... x7 ... q8 ... z9 ... y10 ... b11 ... c12 ... t

Book No. Author

other fields of a record

Data set having‘Book No’ as aPrimary Key

Page 82: V2_1_VSAM_ppt

VSAM 82

3 6 9 12

1 ... x 2 ... y 3 ... x usCF

4 ... Z 5 ... t 6 ... x usCF

10 .. .b 11 ... c 12 ... t usCF

7 ... q 8 ... z 9 ... y usCF

IndexComponent

DataComponent

ALTERNATE INDEX

BASE CLUSTER (KSDS)

Page 83: V2_1_VSAM_ppt

VSAM 83

b ... 10

c ... 11

q ... 7

t ... 5, 12

x ... 1, 3, 6

y ... 2, 9

z ... 4, 8

Author Book No.

ALTERNATE INDEX

Page 84: V2_1_VSAM_ppt

VSAM 84

ALTERNATE INDEX CLUSTER

FOR NON UNIQUE ALTERNATE KEY

S X Z

Index Component

DataComponent

b 10 c 11 q 7 CF

t 5 12 x 1 3 6 CF

y 2 9 z 4 8 CF

Page 85: V2_1_VSAM_ppt

VSAM 85

Key Ptr Key Ptr

ALTERNATE INDEX

Hdr Key Ptr 4 FSPC

U CFS

Index Component :

Control Interval 1

Control Interval 2

The pointers point to a control interval in the data component of the base cluster that contains the record

Hdr Key Ptr1 Ptr2 Ptr3

Hdr Key Ptr12 FSPC

U CFS

Hdr Key Ptr9 Ptr10 Ptr11

Page 86: V2_1_VSAM_ppt

VSAM 86

ORGANIZATION OF AN ALTERNATE INDEX

HK5

AUTH-LAST_NAME25

LIB_NUM8

LIB_NUM8

LIB_NUM8

<-------------- PRM_KEY (S) ------------->

RECORDSIZE(54 110)

ESDS :

ALT-INDX-KEY PRM-KEYKSDS :

HOUSE KEEPING5

SOC_SEC_NUM9

EMP_NUM8

RECORDSIZE(22 22)

HK5

TIMESTAMP12

RBA4

- Occupies Less Space- RBA-Access is Faster

DATA COMPONENT :

Page 87: V2_1_VSAM_ppt

VSAM 87

• 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 record’s RBA.

ALTERNATE INDEX(S)

Page 88: V2_1_VSAM_ppt

VSAM 88

• Supported only for assembler or online CICS

• Do not support a reusable base cluster

• Greatly reduce data redundancy

• May lead to performance Degradation

• Build the ALT. index after the base cluster has been both defined and loaded with atleast 1 record.

ALTERNATE INDEX(S)

Page 89: V2_1_VSAM_ppt

VSAM 89

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.

Page 90: V2_1_VSAM_ppt

VSAM 90

STEP 1: Defining the Alternate IndexThe 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: DEFINE ALTERNATEINDEX

Abbreviation: DEF AIX  Use: Alternate index over a KSDS, ESDS Required: Yes, if an alternate index is defined. Default: None Example: DEFINE AIX

Page 91: V2_1_VSAM_ppt

VSAM 91

The NAME parameter It is mandatory parameter that names the alternate index. Format: NAME (index cluster name)

Abbreviation: None  Use: Alternate index over a KSDS, ESDS Required: Yes, if an alternate index is defined. Default: None Example: NAME (da0001t.lib.ksds.ename.aix)

Page 92: V2_1_VSAM_ppt

VSAM 92

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. Abbreviation: VOL  Used for: Alternate index over a KSDS, ESDS.  Required: Yes, if an alternate index is defined. Default: None Example: VOLUMES (BS3011)

VOLUMES (BS3011 BS3040 BS3042)

Page 93: V2_1_VSAM_ppt

VSAM 93

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: RELATE (base cluster name)

Abbreviation: REL  Use: Alternate index over a KSDS, ESDS Required: Yes, if an alternate index is defined. Default: None Example: RELATE (da0001t.lib.ksds.cluster)

Page 94: V2_1_VSAM_ppt

VSAM 94

The UPGRADE parameter

Format: UPGRADE | NOUPGRADE

Abbreviation: UPG | NUPG Use: Alternate index over a KSDS, ESDS Required: No, because of default. Default: UPGRADE Example: UPGRADE

NOUPGRADE

Page 95: V2_1_VSAM_ppt

VSAM 95

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 cluster’s 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

Page 96: V2_1_VSAM_ppt

VSAM 96

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 keyoffset: The offset is the key’s displacement (in bytes) from the beginning of the record.

 Abbreviation: None  Used for: Alternate index over a KSDS, ESDS. Required: No, because of the default. Default: KEYS (64 0) Example: KEYS (30 4)

Page 97: V2_1_VSAM_ppt

VSAM 97

The RECORDSIZE parameter The RECORDSIZE parameter specifies the average and maximum of each alternate index record. Format: RECORDSIZE (avg max) Abbreviation: RECSZ  Use: Alternate index over a KSDS, ESDS. Required: No Default: RECORDSIZE (4086 32600) Example: RECORDSIZE (80 120)

Page 98: V2_1_VSAM_ppt

VSAM 98

ORGANIZATION OF AN ALTERNATE INDEX

HK5

AUTH-LAST_NAME25

LIB_NUM8

LIB_NUM8

LIB_NUM8

<-------------- PRM_KEY (S) ------------->

RECORDSIZE(54 110)

ESDS :

ALT-INDX-KEY PRM-KEYKSDS :

HOUSE KEEPING5

SOC_SEC_NUM9

EMP_NUM8

RECORDSIZE(22 22)

HK5

TIMESTAMP12

RBA4

- Occupies Less Space- RBA-Access is Faster

DATA COMPONENT :

Page 99: V2_1_VSAM_ppt

VSAM 99

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 expansionci%: - Percentage of control area to leave free for expansion

 Abbreviation: FSPC  Use: Alternate index over KSDS, ESDS. Required: No, because of default. Default: FREESPACE (0 0) Example: FREESPACE (20 10)

Page 100: V2_1_VSAM_ppt

VSAM 100

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

Page 101: V2_1_VSAM_ppt

VSAM 101

//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))/*//

Page 102: V2_1_VSAM_ppt

VSAM 102

Note :

• Path is defined for each ALT. Index

• Path is a separate catalog entry

• Path is a logical connection thru the ALT. Index to the base cluster

• Pathname is the dataset name in JCL (DSN=PATHNAME)

DEFINE AN ALTERNATE INDEX PATH

Page 103: V2_1_VSAM_ppt

VSAM 103

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: DEFINE PATH (NAME (path name) parameters) Abbreviation: DEF PATH  Use: Alternate index over a KSDS, ESDS. Required: Yes, for an alternate index. Default: None Example: DEFINE PATH (NAME (da0001t.lib.ksds.ename.path))

Page 104: V2_1_VSAM_ppt

VSAM 104

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: PENT  Use: Alternate index over a KSDS, ESDS. Required: Yes, for an alternate index. Default: None Example: PATHENTRY (da0001t.lib.ksds.ename.aix)

Page 105: V2_1_VSAM_ppt

VSAM 105

The UPDATE parameter

Format: UPDATE | NOUPDATE Abbreviation: UPD | NUPD Use: Alternate index over a KSDS, ESDS. Required: Yes, for an alternate index. Default: UPDATE Example: UPDATE

NOUPDATE

Page 106: V2_1_VSAM_ppt

VSAM 106

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

Page 107: V2_1_VSAM_ppt

VSAM 107

//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

Page 108: V2_1_VSAM_ppt

VSAM 108

Note :

• To populate the data component of ALT. index with records

• VSAM constructs the index component of ALT. Index as it does for any KSDS

• Assume absolute control of base cluster by DISP=OLD

• Output dataset can be ALT. index cluster or pathname

BUILD THE ALTERNATE INDEX

Page 109: V2_1_VSAM_ppt

VSAM 109

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: BIX Use: Alternate index over a KSDS, ESDS. Required: Yes, for an alternate index. Default: None 

Page 110: V2_1_VSAM_ppt

VSAM 110

The INFILE/INDATASET parameters The INFILE parameter specifies a DD statement that refers to the input dataset. The INDATASET parameter names the dataset. Format: INFILE (ddname) | INDATASET (dataset name) Abbreviation: IFILE | IDS Use: KSDS, ESDS. Required: Yes, you must code one or the other. Default: None Example: INFILE (dd1)

INDATASET (da0001t.lib.ksds.cluster)

Page 111: V2_1_VSAM_ppt

VSAM 111

The OUTFILE/OUTDATASET parametersThe OUTFILE parameter specifies a DD statement that refers to the output dataset. The OUTDATASET parameter names the dataset. Format: OUTFILE (ddname) | OUTDATASET (dataset name) Abbreviation: OFILE | ODS Use: KSDS, ESDS. Required: Yes, you must code one or the other. Default: None Example: OUTFILE (dd2)

OUTDATASET (da0001t.lib.ksds.empname.aix) IDS and ODS dynamically allocate the input and output datasets and ensure that the job contains exclusive contro.

Page 112: V2_1_VSAM_ppt

VSAM 112

//STEP1 EXEC PG=IDCAMS//SYSPRINT DD SYSOUT =*//DD1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,// DISP=OLD//IDCUT1 DD UNIT=SYSDA,SPACE=(TRK, (2, 1))//IDCUT2 DD UNIT=SYSDA,SPACE=(TRK, (2, 1)) // SYSIN DD * BLDINDEX - INFILE (DD1) - OUTDATASET (da0001t.lib.ksds.empname.aix) - INTERNALSORT/*//

Page 113: V2_1_VSAM_ppt

VSAM 113

//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 -

KEYS(25 9) -

FREESPACE(20 10) -

SHAREOPTIONS(1) -

NONUNIQUEKEY) ) -

DATA(NAME(DA000A1T.LIB.KSDS.EMPNAME.DATA) -

TRACKS(10 1) -

RECORDSIZE(70 110) -

CISZ(4096) -

) -

INDEX(NAME(DA0001T.LIB.KSDS.EMPNAME.INDEX)

/*

DEFINE AN ALTERNATE INDEX

Page 114: V2_1_VSAM_ppt

VSAM 114

JCL://STEP1 EXEC PGM=IDCAMS

//SYSPRINT DD SYSOUT =*

//SYSIN DD *

DEFINE PATH -

NAME(DA0001T.LIB.KSDS.EMPNAME.PATH) -

PATHENTRY(DA0001T.LIB.KSDS.EMPNAME.AIX) -

UPDATE -

)

/*

//

DEFINE AN ALTERNATE INDEX

Page 115: V2_1_VSAM_ppt

VSAM 115

JCL://STEP1 EXEC PG=IDCAMS

//SYSPRINT DD SYSOUT =*

//DD1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,

// DISP=OLD

//IDCUT1 DD UNIT=SYSDA,SPACE=(TRK, (2, 1))

//IDCUT2 DD UNIT=SYSDA,SPACE=(TRK, (2, 1))

// SYSIN DD *

BLDINDEX -

INFILE(DD1) -

OUTDATASET(DA0001T.LIB.KSDS.AUTHNAME.AIX) -

INTERNALSORT

/*

BUILD THE ALTERNATE INDEX

Page 116: V2_1_VSAM_ppt

VSAM 116

• DEFINE CLUSTER (NAME(DA0001T.LIB.KSDS.CLUSTER)

.

)

• DEFINE AIX (NAME(DA0001T.LIB.KSDS.AUTHNAME.AIX) RELATE(DA0001T.LIB.KSDS.CLUSTER)

.

)• DEFINE PATH (NAME(DA0001T.LIB.KSDSK.AUTHNAME.PATH)

PATHENTRY(DA0001T.LIB.KSDS.AUTHNAME.AIX).)

• BLDINDEXINDATASET(DA0001T.LIB.KSDS.CLUSTER) OUTDATASET(DA0001T.LIB.KSDS.AUTHNAME.AIX).)

SEQUENCE FOR BUILDING INDEX

Page 117: V2_1_VSAM_ppt

VSAM 117

REPRO COMMAND

Page 118: V2_1_VSAM_ppt

VSAM 118

• 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

REPRO

Page 119: V2_1_VSAM_ppt

VSAM 119

Example Loading Dataset:

//DD1 DD DSN=DA0001T.INPUT.KSDS,DISP=OLD

//DD2 DD DSN=DA0001T.OUTPUT.KSDS, DISP=OLD

//SYSINDD *

REPRO -

INFILE(DD1) -

OUTFILE(DD2) -

FROMKEY(A001) -

TOKEY(A069)

REPRO

Page 120: V2_1_VSAM_ppt

VSAM 120

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

Page 121: V2_1_VSAM_ppt

VSAM 121

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) -

OUTDATASET(DA0001T.LIB.KSDS.CLUSTER)

/*

DELETE-DEFINE-REPRO

Page 122: V2_1_VSAM_ppt

VSAM 122

REPRO Command  Format: REPRO INFILE (ddname) | INDATASET (dsname) -

OUTFILE (ddname) | OUTDATASET (dsname) - optional parameters

 Abbreviation: None Use: KSDS, ESDS. RRDS Required: Yes. Default: None Example: REPRO -

INFILE (dd2) -OUTDATASET (da0001t.lib.ksds.empname.aix)

Page 123: V2_1_VSAM_ppt

VSAM 123

Limiting Input and Output Records 

The FROMKEY and TOKEY parameters FROMKEY specifies the key of the input record at which to begin reading. TOKEY specifies the key of the last input 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 encountered that matches all the characters up to *. Abbreviation: FKEY, TKEY Use: KSDS, ISAM Required: No Default: First record in dataset for FROMKEY and last record in dataset for TOKEY. Example: FROMKEY (PAI) TOKEY (PAI*)

Page 124: V2_1_VSAM_ppt

VSAM 124

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: FADDR, TADDR Use: KSDS, ESDS Required: No Default: First record in dataset for FROMADDRESS and last record in dataset for TOADDRESS. Example: FROMADDRESS (6250)

TOADDRESS (12684)

Page 125: V2_1_VSAM_ppt

VSAM 125

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 record to copy. The first record is number 0. Abbreviation: FNUM, TNUM Use: RRDS Required: No Default: First record in dataset for FROMNUMBER and last record in

dataset for TONUMBER. Example: FROMNUMBER (10) TONUMBER (1000)

Page 126: V2_1_VSAM_ppt

VSAM 126

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: None Use: KSDS, ESDS, RRDS, non-VSAM datasets Required: No Default: SKIP defaults to the first record in dataset, and COUNT defaults to all the records in the dataset. Example: SKIP (10)

COUNT (1000)

Page 127: V2_1_VSAM_ppt

VSAM 127

//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)/*

Example JCL for Loading Dataset:

Page 128: V2_1_VSAM_ppt

VSAM 128

The REPLACE Parameter for Merge Operations with REPRO 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: REPLACE Abbreviation: REP Use: KSDS, ESDS, RRDS Required: No Default: matching records are not replaced. Example: REPLACE -

COUNT (500)

Page 129: V2_1_VSAM_ppt

VSAM 129

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 VERIFY DATASET (entry name /password) Abbreviation: VFY Use: KSDS, ESDS, RRDS (not valid for an LDS) Required: No Default: None. Example: VERIFY da0001t.lib.ksds.cluster VERIFY DATASET (da0001t.lib.ksds.cluster)

VERIFY FILE (dd1)

Page 130: V2_1_VSAM_ppt

VSAM 130

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 doesn’t have a password.  Abbreviation: DEL Use: KSDS, ESDS, RRDS, non-VSAM Required: No Default: None. Example: DELETE da0001t.lib.ksds.cluster

Page 131: V2_1_VSAM_ppt

VSAM 131

Optional parameters are:          ALIAS         AIX         CLUSTER         NONVSAM         PATH         GDG         ERASE | NOERASE         FORCE | NOFORCE         PURGE | NOPURGE         SCRATCH | NOSCRATCH

Page 132: V2_1_VSAM_ppt

VSAM 132

//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/*//

Page 133: V2_1_VSAM_ppt

VSAM 133

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 doesn’t have a password.

 ddname: The name of a DD statement Abbreviation: PRINT IDS (entry name /password) PRINT IFILE (ddname /password) Use: KSDS, ESDS, RRDS, non-VSAM Required: No Default: None. Example: PRINT da0001t.lib.ksds.cluster

PRINT INDATASET (da0001t.lib.ksds.cluster) PRINT INFILE (dd1)

The default output destination for PRINT is SYSPRINT.

Page 134: V2_1_VSAM_ppt

VSAM 134

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)

Page 135: V2_1_VSAM_ppt

VSAM 135

//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

Page 136: V2_1_VSAM_ppt

VSAM 136

If you want the printed output directed to other than SYSPRINT, such as another dataset, you can the OUTFILE parameter.  Format: OUTFILE (ddname/password) ddname: The name of a DD statement specifying where the output is to be written. Abbreviation: OFILE Use: KSDS, ESDS, RRDS, non-VSAM Required: No, because of default. Default: OUTFILE (SYSPRINT) Example: PRINT da0001t.lib.ksds.cluster -

OUTFILE (dd1)  PRINT INDATASET (da0001t.lib.ksds.cluster)

- OUTFILE (dd1)

Page 137: V2_1_VSAM_ppt

VSAM 137

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 doesn’t have a password. parameters Abbreviation: None

Use: KSDS, ESDS, RRDS, non-VSAM Required: No Default: None. Example: ALTER da0001t.lib.ksds.cluster -

FSPC (30 20)

Page 138: V2_1_VSAM_ppt

VSAM 138

The following is a list of common attributes that are completely alterable. 

•Change name of the object•Add volumes/Remove volumes•Change Keys and uniqueness•Change record size•Change Upgrade option•Change % of FREESPACE etc.

Page 139: V2_1_VSAM_ppt

VSAM 139

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

Page 140: V2_1_VSAM_ppt

VSAM 140

ALTER DA0001T.LIB.KSDS.CLUSTER -NEWNAME (DA0001T.MY.CLUSTER)

 Example 7.6 Altering name of a Dataset  

ALTER DA0001T.LIB.KSDS.CLUSTER -ADDVOLUMES (BS3001 BS3005)

Example 7.7 Adding additional volumes

Page 141: V2_1_VSAM_ppt

VSAM 141

The following attributes are alterable only for empty clusters

•KEYS (length offset)•RECORDSIZE (avg max)•UNIQUEKEY | NONUNIQUEKEY The following attributes are unalterable. You have to DELETE the cluster and redefine it with new attributes.

•CISZ•Cluster type, •IMBED/REPLICATE•REUSE | NOREUSE

Page 142: V2_1_VSAM_ppt

VSAM 142

ALTER PRINT DELETE COMMANDS

Page 143: V2_1_VSAM_ppt

VSAM 143

Format: VERIFY FILE (ddname /password) Or VERIFY DATASET (entry name /password)

 Abbreviation: VFY Use: KSDS, ESDS, RRDS (not valid for an LDS) Required: No Default: None. Example: VERIFY da0001t.lib.ksds.cluster VERIFY DATASET (da0001t.lib.ksds.cluster)

VERIFY FILE (dd1)

Page 144: V2_1_VSAM_ppt

VSAM 144

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, there’s a possibility that if that previously added records may be overwritten, especially in the event of this relationship.   

VERIFY DATASET (DA0001T.LIB.KSDS.CLUSTER) 

Example 7.1 VERIFY

 Remark: VERIFY can be issued from a TSO or within a JCL statement either the FILE or DATASET parameter.

Page 145: V2_1_VSAM_ppt

VSAM 145

End of data

CA splits

Control block HURBACatalog HURBA

VSAM cluster

     

Catalog

 

 

 

Fig: 7.2 Relationship between HURBA in catalog and cluster.

Page 146: V2_1_VSAM_ppt

VSAM 146

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 doesn’t have a password.  Abbreviation: DEL Use: KSDS, ESDS, RRDS, non-VSAM Required: No Default: None. Example: DELETE da0001t.lib.ksds.cluster

Page 147: V2_1_VSAM_ppt

VSAM 147

  

DELETE DA0001T.LIB.KSDS.CLUSTER - ERASE

Example 7.3 Deleting a Cluster

Page 148: V2_1_VSAM_ppt

VSAM 148

Optional parameters are:          ALIAS         AIX         CLUSTER         NONVSAM         PATH         GDG         ERASE | NOERASE         FORCE | NOFORCE         PURGE | NOPURGE         SCRATCH | NOSCRATCH

Page 149: V2_1_VSAM_ppt

VSAM 149

//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/*//

Example 7.4 Delete VSAM Dataset

Page 150: V2_1_VSAM_ppt

VSAM 150

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 doesn’t have a password. ddname: The name of a DD statement Abbreviation: PRINT IDS (entry name /password)

PRINT IFILE (ddname /password) Use: KSDS, ESDS, RRDS, non-VSAM Required: No Default: None. Example: PRINT da0001t.lib.ksds.cluster

PRINT INDATASET (da0001t.lib.ksds.cluster) PRINT INFILE (dd1)

Page 151: V2_1_VSAM_ppt

VSAM 151

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)

Page 152: V2_1_VSAM_ppt

VSAM 152

//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 7.5 Print VSAM Dataset 

If you want the printed output directed to other than SYSPRINT, such as another dataset, you can the OUTFILE parameter.

Page 153: V2_1_VSAM_ppt

VSAM 153

Format: OUTFILE (ddname/password) ddname: The name of a DD statement specifying where the output is to be written. Abbreviation: OFILE Use: KSDS, ESDS, RRDS, non-VSAM Required: No, because of default. Default: OUTFILE (SYSPRINT) Example: PRINT da0001t.lib.ksds.cluster -

OUTFILE (dd1) 

PRINT INDATASET (da0001t.lib.ksds.cluster) -

OUTFILE (dd1)

Page 154: V2_1_VSAM_ppt

VSAM 154

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 doesn’t have a password. parameters Abbreviation: None

Use: KSDS, ESDS, RRDS, non-VSAM Required: No Default: None. Example: ALTER da0001t.lib.ksds.cluster -

FSPC (30 20)

Page 155: V2_1_VSAM_ppt

VSAM 155

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. 

•Change name of the object

•Add volumes/Remove volumes•Change Keys and uniqueness•Change record size•Change Upgrade option•Change % of FREESPACE etc.

Page 156: V2_1_VSAM_ppt

VSAM 156

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

Page 157: V2_1_VSAM_ppt

VSAM 157

ALTER DA0001T.LIB.KSDS.CLUSTER -NEWNAME (DA0001T.MY.CLUSTER)

 

Example 7.6 Altering name of a Dataset  

ALTER DA0001T.LIB.KSDS.CLUSTER -ADDVOLUMES (BS3001 BS3005)

Example 7.7 Adding additional volumes

Page 158: V2_1_VSAM_ppt

VSAM 158

The following attributes are alterable only for empty clusters

•KEYS (length offset)•RECORDSIZE (avg max)•UNIQUEKEY | NONUNIQUEKEY The following attributes are unalterable. You have to DELETE the cluster and redefine it with new attributes.

•CISZ•Cluster type, •IMBED/REPLICATE

REUSE | NOREUSE

Page 159: V2_1_VSAM_ppt

VSAM 159

Page 160: V2_1_VSAM_ppt

VSAM 160

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.

VERIFY

Page 161: V2_1_VSAM_ppt

VSAM 161

- logically deletes dataset- catalog entry deleted

Format :DELETE entryname/passwd -

optional parametersExample :DELETE DA0001T.LIB.KSDS.CLUSTER - ERASEOptional parameters are :

DELETE

- ERASE | NOERASE- FORCE | NOFORCE- PURGE | NOPURGE- SCRATCH | NOSCRATCH

- AIX- CLUSTER- NONVSAM- PATH

Page 162: V2_1_VSAM_ppt

VSAM 162

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

PRINT

Page 163: V2_1_VSAM_ppt

VSAM 163

PRINT

Options

• CHAR | DUMP | HEX

• COUNT (number)

• FROMADDRESS, [TOADDRESS]

• FROMKEY, [TOKEY]

• FROMNUMBER, [TONUMBER]

• OUTFILE (ddname)

• SKIP (number)

Page 164: V2_1_VSAM_ppt

VSAM 164

• 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 :

ALTER entryname/passwd parameters

ALTER

Page 165: V2_1_VSAM_ppt

VSAM 165

ALTER

Options :

• ADDVOLUMES (volumes)

• BUFFERSPACE (size)

• ERASE | NOERASE

• FREESPACE(ci% ca%) -

• MASTERPW(password)

• NEWNAME(newname)

• READPW (password)

Page 166: V2_1_VSAM_ppt

VSAM 166

ALTER

•SCRATCH | NOSCRATCH

• SHR(cross region cross system)

• TO(date) |FOR(days)

• UPDATE | NOUPDATE

• UPDATEPW(password)

• UPGRADE |NOUPGRADE

Page 167: V2_1_VSAM_ppt

VSAM 167

Examples

ALTER -

DA0001T.LIB.KSDS.CLUSTER -

NEWNAME(A2000.MY.CLUSTER)

ALTER -

DA0001T.LIB.KSDS.INDEX -

FREESPACE(30 30)

The following attributes are alterable only for empty clusters

• KEYS(length offset)

• RECORDSIZE(avg max)

• UNIQUEKEY | NONUNIQUEKEY

ALTER

Page 168: V2_1_VSAM_ppt

VSAM 168

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

Page 169: V2_1_VSAM_ppt

VSAM 169

SAMPLE PROGRAMS

Page 170: V2_1_VSAM_ppt

VSAM 170

//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)

/*

//

SAMPLE PROGRAM

Page 171: V2_1_VSAM_ppt

VSAM 171

//DA0001TA JOB LA2719,PCS,MSGLEVEL= (1,1),

// MSGCLASS=A, NOTIFY=DA0001T

//* Load Data from a file into ESDS VSAM Dataset

//STEP1 EXEC PGM=IDCAMS

//SYSPRINT DD SYSOUT = *

//DD1 DD DSN=DA0001T.ESDS.CLUSTER1

//DD2 DD DSN=DA0001T.ESDS.CLUSTER2

//SYSIN DD *

REPRO -

INFILE(DD1 -

OUTFILE(DD2)

/*

//

SAMPLE PROGRAM

Page 172: V2_1_VSAM_ppt

VSAM 172

//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

/*

//

SAMPLE PROGRAM

Page 173: V2_1_VSAM_ppt

VSAM 173

//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1) ,

// NOTIFY=DA0001T

//* Deletes VSAM Dataset

//STEP1 EXEC PGM=IDCAMS

//SYSPRINT DD SYSOUT = *

//SYSIN DD *

DELETE DA0001T.TRAIN.ITMFOIV

/*

//

SAMPLE PROGRAM

Page 174: V2_1_VSAM_ppt

VSAM 174

GENERATION DATA GROUP

Page 175: V2_1_VSAM_ppt

VSAM 175

• Group of datasets which are related to each other chronologically and functionally

• Generations can continue until a specified limit is reached

• Limit specifies total number of generations that can exist at any one time

• Once limit is reached the oldest generation is deleted.

GENERATION DATA GROUP

Page 176: V2_1_VSAM_ppt

VSAM 176

• MVS uses the generation data group’s catalog entry to keep track of relative generation numbers. As a result, GDGs must be cataloged and each generation dataset that’s a part of the group must be cataloged too.

• When you create a generation data group’s catalog entry, you specify how many generations should be maintained eg. You may specify that five generations including the current generation, be maintained. During each processing cycle, the new version of the file becomes the current version.

GENERATION DATA GROUP

Page 177: V2_1_VSAM_ppt

VSAM 177

file.c1(+1)Next Generation

file.c1(0) Current Generation

file.c1(-1) Previous Generations

file.c1(-2)

file.c1(-3)

There are 3 previous generation, note that generations are numbered relative to the current generation, file.c1(0).

Relative generation numbers are adjusted when each processing cycle completes, so that the current generation is always referred to as relative generation 0.

GENERATION DATA GROUP

Page 178: V2_1_VSAM_ppt

VSAM 178

• MVS uses “Absolute Generation Numbers” in the form GnnnnV00 to identify each generation dataset uniquely. GnnnnV00 represents the chronological sequence number of the generation, beginning with G0000.

• V00 is a version number, which lets you maintain more than one version of a generation. Each time a new generation dataset is created, mvs adds one to the sequence number.

GENERATION DATA GROUP

Page 179: V2_1_VSAM_ppt

VSAM 179

filename.GnnnnV00

35 chars 9 chars

Example : Using GDG

// IN DD DSN=DA0001T.MASTER, DISP=SHR

// OUT DD DSN=DA0001T.MASTER.DAY(+1),

DISP= (NEW,CATLG,DELETE),

UNIT=3390, VOL=SER=BP0031,

SPACE= (CYL,(10,5),RLSE),

DCB=(PROD.GDGMOD,

BLKSIZE=23440,LRECL=80,RECFM=FB)

GENERATION DATA GROUP

Page 180: V2_1_VSAM_ppt

VSAM 180

Relative Name and Absolute NameDA0002T.MASTER.DAY90) ---> Relative Name

DA0002T.MASTER.DAY.G00001V00 -->Absolute Name

Defining a GDG

// Step1 EXECPGM=IDCAMS

// SYSPRINT DD SYSOUT = *

// SYSIN DD *

DEFINE GDG(NAME(DA0001T.MASTER.DAY) -

LIMIT(5) -

SCRATCH -

EMPTY)

/*

//

GENERATION DATA GROUP

Page 181: V2_1_VSAM_ppt

VSAM 181

Following code contains 1 job with 2 steps....//DA0003TA JOB

//UPDATE EXEC PGM=PAY3200

//OLDMAST DD DSN=DA0001T.MMA2.PAY.MAST(0),DISP=OLD

//NEWMAST DD DSN=DA0001T.MMA2.PAY.MAST(+1),

// DISP= (NEW,CATLG),UNIT=3300,

// VOL=SER=BS3001,

// DCB=(LRECL=80,BLKSIZE=1600)

//PAYTRAN DD DSN=DA0001T.MMA2.PAY.TRAN,DISP=OLD

//PAYLIST DD SYSOUT=*

//REPORT EXEC PGM=PAY3300

//PAYMAST DD DSN=DA0001T.MMA2.PAY.MAST(+1),DISP=OLD

//PAYRPT DD SYSOUT=*

GENERATION DATA GROUP

Page 182: V2_1_VSAM_ppt

VSAM 182

Following code contains 2 jobs.........//JOB1 JOB

//UPDATE EXEC PGM=PAY3200

//OLDMAST DD DSN=DA0001T.MMA2.PAY.MAST(0),DISP=OLD

//NEWMAST DD DSN=DA0001T.MMA2.PAY.MAST(+1),

// DISP=(NEW, CATLG), UNIT=3300,

// VOL=SER=BS3001,

// DCB=(LRECL=80, RECFM=FB,BLKSIZE=0)

//PAYTRAN DD DSN=DA0001T.MMA2.PAY.TRAN,DISP=OLD

//PAYLIST DD SYSOUT =*

//*

//JOB2 JOB ...........

//REPORT EXEC PGM=PAY3300

//PAYMAST DD DSN=DA0001T.MMA2.PAY.MAST(0),DISP=OLD

//PAYRPT DD SYSOUT=*

GENERATION DATA GROUP

Page 183: V2_1_VSAM_ppt

VSAM 183

• Have to be created before data sets that are to be included in them can be made a part of them

• Model containing parameter information of the datasets to be included in the GDG has to be specified

• System must be informed each time a new dataset added to or deleted from GDG

• System must be informed if the entire GDG is to be deleted

CONSIDERATIONS FOR USING GDGs

Page 184: V2_1_VSAM_ppt

VSAM 184

• Name of the GDG

• Number of generations that are to be retained

• Action when number of generations to be retained reaches the limit

SPECIFICATIONS FOR CREATING A GDG

Page 185: V2_1_VSAM_ppt

VSAM 185

• 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

FEATURES OF GDGs

Page 186: V2_1_VSAM_ppt

VSAM 186

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• Defining a model for the GDG.

GDGs

Page 187: V2_1_VSAM_ppt

VSAM 187

NAME

LIMIT

NOEMPTY

EMPTY

SCRATCH

NOSCRATCH

GDGs

Page 188: V2_1_VSAM_ppt

VSAM 188

GDGs

JCL for creating index

//STEP1 EXEC PGM=IDCAMS

//SYSIN DD

DEFINE GDG -

(NAME(DA0001T.ACCOUNTS.MONTHLY) -

LIMIT(5) -

EMPTY -

SCRATCH -

)

/*

//

Page 189: V2_1_VSAM_ppt

VSAM 189

Modifying Features of GDG

Can be modified by the ALTER command

Example :

//STEP1 EXEC PGM=IDCAMS

//SYSINDD

ALTER DA0001T.ACCOUNTS.MONTHLY -

NOSCRATCH -

EMPTY

/*

//

GDGs

Page 190: V2_1_VSAM_ppt

VSAM 190

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 EXECPGM=IDCAMS

//SYSIN DD

DELETE DA0001T.ACCOUNTS.MONTHLY GDG

/*

//

GDGs

Page 191: V2_1_VSAM_ppt

VSAM 191

Adding a Dataset to a GDG

Name of the model containing the GDG DCB parameter’s is coded in the DCB parameter of the DD statement

Example ://STEP1 EXEC PGM=GDG1

//FILE1 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)

GDGs

Page 192: V2_1_VSAM_ppt

VSAM 192

Deleting GDG Index and Datasets

FORCE parameter in the DELETE statement of

IDCAMS can be used Example :

/STEP1 EXECPGM=IDCAMS

//SYSIN DD

DELETE DA0001T.ACCOUNTS.MONTHLY -

GDG -

FORCE

/*

//

GDGs

Page 193: V2_1_VSAM_ppt

VSAM 193

COBOL – VSAM CONSIDERATIONS

Page 194: V2_1_VSAM_ppt

VSAM 194

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.

COBOL-VSAM CONSIDERATIONS

Page 195: V2_1_VSAM_ppt

VSAM 195

FD Entry

• Should have the record structure

• If KSDS then key field must match with length and position of KEYS parameter in DEFINE CLUSTER information

COBOL - VSAM CONSIDERATIONS

Page 196: V2_1_VSAM_ppt

VSAM 196

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.

COBOL-VSAM CONSIDERATIONS

Page 197: V2_1_VSAM_ppt

VSAM 197

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

//LIBMAST2 DD DSN=DA0001T.LIB.KSDS.DEPT.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

Page 198: V2_1_VSAM_ppt

VSAM 198

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

dataname

COBOL-VSAM CONSIDERATIONS

Page 199: V2_1_VSAM_ppt

VSAM 199

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

Position record pointer on the desired recordSTART EMP-MAST KEY IS EQUAL TO EMP-NAME.

COBOL-VSAM CONSIDERATIONS

Page 200: V2_1_VSAM_ppt

VSAM 200

VSAM I/O ERROR PROCESSING.

Most programmers ignore errors, because the access method will abend the program if a serious I/O error occurs. Not so when processing Vsam datasets.

VSAM places program control in the hands of the programmer,not the O/S. For this reason,it is important to check the COBOL status key designated in the FILE STATUS clause after every I/O operation.

FILE STATUS CODES

Page 201: V2_1_VSAM_ppt

VSAM 201

• For these status key values,continue processing normally :00 successful I/O.02 duplicate alternate key encountered (expected).10 end of file.

• 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.

FILE STATUS CODES

Page 202: V2_1_VSAM_ppt

VSAM 202

Note:

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

FILE STATUS CODES

Page 203: V2_1_VSAM_ppt

VSAM 203

For the following status key values,terminate the program :

24 out-of-space condition(KSDS or RRDS).

30 Nonspecific I/O problem.

34 out-of-space condition(ESDS).

49 REWRITE attempted;dataset not opened for I-O.

90 Dataset unusable or logic error.

92 logic error.

93 Resource not available.

FILE STATUS CODES

Page 204: V2_1_VSAM_ppt

VSAM 204

FILE STATUS CODES

94 current record pointer undefined.

95 Nonzero HURBA for OPEN OUTPUT.

96 No corresponding JCL DD statement.

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.

Page 205: V2_1_VSAM_ppt

VSAM 205

• MVS/VSAM for Application Programmer by Brown and Smith

• VSAM by Doug Lowe

• VSAM for COBOL Programmer by Doug Lowe

BIBLIOGRAPHY