187

Click here to load reader

VSAM- Virtual Storage Access Method

Embed Size (px)

DESCRIPTION

This is a ppt of entire VSAM file organisation

Citation preview

Page 1: VSAM- Virtual Storage Access Method

1

VIRTUAL STORAGE ACCESS METHOD (VSAM)

Page 2: VSAM- Virtual Storage Access Method

2

VSAM

VSAM means virtual storage access methodHigh performance access method and dataset organization designed specifically for VSenvironment.

• It resides in virtual storage.• Organizes and maintains data via a cataloged structure.

Page 3: VSAM- Virtual Storage Access Method

3

VSAM HISTORY

A] Standard VSAM. Only ESDS & KSDS

B] A+RRDS & AIX, Catld. FacilityEnhanced VSAM

C] DF/EF VSAM ICF Cataloging

MVS/XA Ver. 1Changes were compatible

with DF/EF VSAM

MVS/XA Ver. 2LDS were added

Page 4: VSAM- Virtual Storage Access Method

4

FEATURES of VSAM

• Single 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: VSAM- Virtual Storage Access Method

5

ADVANTAGES of VSAM

• Protection of Data against unauthorized users.• Cross-system (MVS & VSE) Compatibility.• Device Independence (access always via Catalog).• IDCAMS commands can be included in JCL to handle VSAM.• Used by CICS (OLTP) to store and retrieve data.• VS COBOL II / PL-I / ASSMB. Lang can access VSAM dataset.

Page 6: VSAM- Virtual Storage Access Method

6

TYPES of VSAM DATASETS

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

KSDS

ESDS

RRDS

LDS

Key Sequenced dataset

Entry Sequenced dataset

Relative record dataset

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: VSAM- Virtual Storage Access Method

7

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 , an index component, which contains the indexes used to access

records in the data component.

• Must be defined for each dataset.

Page 8: VSAM- Virtual Storage Access Method

I.

II.

8

CLUSTERS

KSDS CLUSTER

INDEX COMPONENT

DATA COMPONENT

ESDS, RRDS Cluster

Page 9: VSAM- Virtual Storage Access Method

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 stream of bytes divided into 4k pages.

Accessed by Relative Byte Address.

Page 10: VSAM- Virtual Storage Access Method

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: VSAM- Virtual Storage Access Method

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 eachrecord 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: VSAM- Virtual Storage Access Method

12

CONTROL INTERVAL

Page 13: VSAM- Virtual Storage Access Method

13

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.

• Can specify free space in CA.

• Number of CI/CA is fixed by VSAM.

Page 14: VSAM- Virtual Storage Access Method

14

SPANNED RECORDS

• Spanned records are records larger than CI size. So one spanned

record is stored in several control intervals.

• Each control interval 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 control interval that contains a record segment of a spanned record

contains no other data.

Page 15: VSAM- Virtual Storage Access Method

15

ESDS

ESDS is a sequential dataset:

• Records are retrieved in the order in which they are written to thedataset.

• 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: VSAM- Virtual Storage Access Method

16

HURBA and HARBA

VSAM clusterHARBA

Data space allocated butempty

HURBA

Data space loaded withrecords

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

Page 17: VSAM- Virtual Storage Access Method

17

VSAM DATASET STRUCTURE

Page 18: VSAM- Virtual Storage Access Method

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: VSAM- Virtual Storage Access Method

19

Data Component

Control Areas

I

II

III

Data Component Control Intervals

IV

V

VI

Page 20: VSAM- Virtual Storage Access Method

20

Page 21: VSAM- Virtual Storage Access Method

21

KSDS STRUCTURE

Page 22: VSAM- Virtual Storage Access Method

22

Insertion of a Record

Page 23: VSAM- Virtual Storage Access Method

23

Deletion of a Record

Page 24: VSAM- Virtual Storage Access Method

24

CONTROL INTERVAL SPLIT

Page 25: VSAM- Virtual Storage Access Method

25

CONTROL INTERVAL SPLIT (Cont…)

Page 26: VSAM- Virtual Storage Access Method

26

CONTROL INTERVAL SPLIT

Page 27: VSAM- Virtual Storage Access Method

27

CONTROL INTERVAL SPLIT (Cont…)

Page 28: VSAM- Virtual Storage Access Method

28

CONTROL INTERVAL SPLIT (Cont…)

Page 29: VSAM- Virtual Storage Access Method

29

IDCAMS COMMANDS

Page 30: VSAM- Virtual Storage Access Method

30

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.

Page 31: VSAM- Virtual Storage Access Method

31

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 32: VSAM- Virtual Storage Access Method

32

IDCAMS

Commands:

FUNCTIONAL Commands:

DEFINE

BUILDINDEX

PRINT

VERIFY

REPRO

DELETE

ALTER

LISTCAT

MODAL Commands:

IF-THEN-ELSE

SET

Page 33: VSAM- Virtual Storage Access Method

33

IDCAMS

// jobname

// stepname

JOB (parameters)

EXEC PGM=IDCAMS

// SYSPRINT DD SYSOUT = *

[// ddname DD DSN=datasetname,

DISP= SHR/ OLD

]

//SYSIN DD *

IDCAMS command(s) coded freely between 2 to 72 columns.

/*

//

Page 34: VSAM- Virtual Storage Access Method

34

IDCAMS

Optionally:

// JOBCAT DD DSN=catalog name,DISP=SHR

// STEPCAT DD DSN=catalog name,DISP=SHR

May be used to indicate catalog names for a job/step, in which concerned datasetmay be cataloged.

Page 35: VSAM- Virtual Storage Access Method

-

-

-

-

35

IDCAMS

FORMAT OF IDCAMS COMMAND

verb object (parameters)

Example :

DEFINE CLUSTER(NAME(TRG.LIB.KSDS.CLUSTER)

CYLINDERS(5, 1)

VOLUMES (DEVB32)

INDEXED

)

Comment

/* comment */

Page 36: VSAM- Virtual Storage Access Method

0

4

8

12

16

36

IDCAMS RETURN CODES

CONDITION CODE:

: command executed with no errors

: warning - execution may go successful

: serious error - execution may fail

: serious error - execution impossible

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

Page 37: VSAM- Virtual Storage Access Method

-

-

37

IF Syntax

IF LASTCC|MAXCC compared value

THEN

IDCAMS command

[ELSE

IDCAMS command]

-

-

Page 38: VSAM- Virtual Storage Access Method

38

IF Syntax

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

• Hyphen is the continuation character

• Comment is assumed as Null statement

• ELSE is optional

Page 39: VSAM- Virtual Storage Access Method

-

39

IF Syntax Example

REPRO INFILE (INDD) -

OUTFILE (OUTDD)

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

IF LASTCC EQ 0

THEN -

PRINT OUTFILE (INDD)

ELSE

PRINT INFILE (OUTDD)

Page 40: VSAM- Virtual Storage Access Method

-

40

USE of DO/END

IF MAXCC LT 4 THEN

DO

/* COMMENT */

IDCAMS command

IDCAMS command

END

ELSE

IDCAMS command

Page 41: VSAM- Virtual Storage Access Method

-

41

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

e.g.

DEFINE CLUSTER

IF LASTCC > 0 THEN

SET MAXCC = 16

ELSE REPRO

Page 42: VSAM- Virtual Storage Access Method

42

Defining a Cluster

Page 43: VSAM- Virtual Storage Access Method

--

43

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:

Default:

Example:

ESDS, KSDS, RRDS

None

DEFINE CLUSTER (NAME (TRG.LIB.KSDS.CLUSTER))DATA (NAME (TRG.LIB.KSDS.DATA))INDEX (NAME (TRG.LIB.KSDS.INDEX))

Page 44: VSAM- Virtual Storage Access Method

--

44

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:

Default:

Example:

ESDS, KSDS, RRDS

Yes

DEFINE CLUSTER (NAME (TRG.LIB.KSDS.CLUSTER))DATA (NAME (TRG.LIB.KSDS.DATA))INDEX (NAME (TRG.LIB.KSDS.INDEX))

Page 45: VSAM- Virtual Storage Access Method

45

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 (TRG.LIB.KSDS.DATA))INDEX (NAME (TRG.LIB.KSDS.INDEX))

Page 46: VSAM- Virtual Storage Access Method

46

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:

Used for:

Required:

Default:

Example:

IX

KSDS

No

None

INDEX (NAME (TRG.LIB.KSDS.INDEX))

Page 47: VSAM- Virtual Storage Access Method

47

The Space Allocation Parameter

The space allocation parameter specifies space allocation values in the unitsshown below:

Format: Code only one of the following:CYLINDERS (primary secondary) orTRACKS (primary secondary) orRECORDS (primary secondary) orKILOBYTES (primary secondary) orMEGABYTES (primary secondary)

Abbreviation:

Used for:

Required:

Default:

Example:

CYL, TRK, REC, KB, MB

KSDS, ESDS, RRDS

Yes

None

CYLINDERS (10 4)|RECORDS (400 500)

Page 48: VSAM- Virtual Storage Access Method

--

-

---

48

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 (TRG.LIB.KSDS.CLUSTER)CYLINDERS (5 3)

)DATA (NAME (TRG.LIB.KSDS.DATA))INDEX (NAME (TRG.LIB.KSDS.INDEX))

Or

DEFINE CLUSTER (NAME (TRG.LIB.KSDS.CLUSTER)DATA (NAME (TRG.LIB.KSDS.DATA)

CYLINDERS (5 3))

INDEX (NAME (TRG.LIB.KSDS.INDEX))

-

-

Page 49: VSAM- Virtual Storage Access Method

49

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.

Page 50: VSAM- Virtual Storage Access Method

50

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:

Used for:

Required:

Default:

Example:

VOL

KSDS, ESDS, RRDS

Yes

None

VOLUMES (DEVB32)VOLUMES (DEVB2B DEVB16 DEVB45)

Page 51: VSAM- Virtual Storage Access Method

Note:

51

DEFINE CLUSTER

You can store the data and index on separate volumes and this may provide aperformance advantage for large dataset.

Page 52: VSAM- Virtual Storage Access Method

52

The RECORDSIZE parameter

This parameter tells VSAM what size records to expect. The avg and max are average andmaximum values for variable-length records If records are of fixed length, avg and max shouldbe the same.

Format: RECORDSIZE (avg max)avg : Average length of recordsmax : Maximum length of records

Abbreviation:

Used for:

Required:

Default:

Example:

RECSZ

KSDS, ESDS, RRDS

No

RECORDSIZE (4086 32600)

RECORDSIZE (80 80) [Fixed Length records]RECORDSIZE (80 120) [Variable Length records]

Page 53: VSAM- Virtual Storage Access Method

53

The RECORDSIZE Parameter (Cont…)

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 54: VSAM- Virtual Storage Access Method

54

The KEYS Parameter

This parameter defines the length and offset of the primary key in a KSDS record. The offset is theprimary 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:

Used for:

Required:

Default:

Example:

None

KSDS

No

KEYS (64 1)

KEYS (8 0)

VSAM records begin in position zero

Page 55: VSAM- Virtual Storage Access Method

55

The dataset-type Parameter

This 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 RRDSLINEAR - Specifies a LINEAR dataset

Abbreviation:

Used for:

Required:

Default:

Example:

IXD| NIXD | NUMD

KSDS, ESDS, RRDS

No

INDEXED

INDEXED|NONINDEXED|NUMBERED

Page 56: VSAM- Virtual Storage Access Method

---------

56

//TRG001A JOB 9927,HSBC,MSGLEVEL=(1,1),MSGCLASS=U,NOTIFY=&SYSUID// * Define Cluster for Reusable ESDS Dataset

//STEP1 EXEC PGM=IDCAMS//SYSPRINT DD SYSOUT=*//SYSIN DD *

DEFINE CLUSTER (NAME (TRG.LIB.ESDS.CLUSTER)NONSPANNEDREUSENOERASEVOLUMES (DEVB1D)RECORDSIZE (80 80)RECORDS (30 50)CISZ (4096)SHR (1 3)

/*//

)DATA (NAME (TRG.LIB.KSDS.DATA))

-

Page 57: VSAM- Virtual Storage Access Method

-------------

57

//TRG001A JOB 9927, HSBC,MSGLEVEL=(1,1),MSGCLASS=U,NOTIFY=&SYSUID// * Define Cluster for KSDS VSAM Dataset

//STEP1 EXEC PGM=IDCAMS//SYSPRINT DD SYSOUT=*//SYSIN DD *

DEFINE CLUSTER (NAME (TRG.LIB.KSDS.CLUSTER)INDEXEDKEYS (4 0)FSPC (10 20)NONSPANNEDNOREUSENOERASEVOLUMES(DEVB1D)SHR(1 3))

DATA(NAME(TRG.LIB.KSDS.DATA)RECORDSIZE(80 80)RECORDS(30 50)CISZ(4096))

INDEX (NAME (TRG.LIB.KSDS.INDEX))/*//

Page 58: VSAM- Virtual Storage Access Method

58

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

Abbreviation:

Used for:

Required:

Default:

CISZ

KSDS, ESDS, RRDS

No, because of the default

Calculated by VSAM

Page 59: VSAM- Virtual Storage Access Method

59

The CONTROLINTERVALSIZE Parameter (Cont…)

Example: CISZ (4096)

Note: If omitted VSAM calculates CISZ based on record size and other control information

Page 60: VSAM- Virtual Storage Access Method

60

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:

Required:

Default:

Example:

KSDS

No, because of default.

FREESPACE (0 0)

FREESPACE (20 10)FREESPACE (20)FREESPACE (0 30)

Control interval onlyControl area only

Page 61: VSAM- Virtual Storage Access Method

61

The FREESPACE Parameter (Cont…)

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.

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 62: VSAM- Virtual Storage Access Method

62

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:

Required:

Default:

Example:

KSDS, ESDS, RRDS

No, because of default.

Two data buffers for all types of datasets, plus one additional index buffer

for KSDS.

BUFSP (8704)

Page 63: VSAM- Virtual Storage Access Method

//DD1

//

63

The BUFFERSPACE Parameter (Cont…)

The following example shows the AMP parameter specifying additional

data buffers to accommodate sequential and random processing.

DD DSN=TRG.LIB.KSDS.CLUSTER,DISP=SHR,AMP=(‘BUFND=10’)

//DD1 DD DSN=TRG.LIB.KSDS.CLUSTER,DISP=OLD,

AMP=(‘BUFND=10’,BUFNI=3’)

Page 64: VSAM- Virtual Storage Access Method

64

The RECOVERY | SPEED Parameter

These parameters are mutually exclusive. RECOVERY, the default, reformats the control areasduring your initial dataset load, so that you can restart the job if it abends for some reason. Thedisadvantage of this parameter is that programmer has to write recovery routine to restart thejob.

SPEED is faster and does not pre-format the control areas. You must reload the dataset fromthe beginning if the job fails during initial loading.

Format:

Abbreviation:

Used for:

Required:

Default:

RECOVERY | SPEED

RCVY | None

KSDS, ESDS, RRDS

No, because of default.

RECOVERY

Page 65: VSAM- Virtual Storage Access Method

65

The RECOVERY | SPEED Parameter (Cont…)

Example: RECOVERY|SPEED

Page 66: VSAM- Virtual Storage Access Method

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

Page 67: VSAM- Virtual Storage Access Method

67

The REUSE | NOREUSE Parameter

The REUSE parameter specifies that the cluster can be opened in output mode second time.

NOREUSE is the default, and specifies the cluster as non-reusable.

Format:

Abbreviation:

Used for:

Required:

Default:

Example:

REUSE | NOREUSE

RUS | UNRUS

KSDS, ESDS, RRDS

No, because of default.

NOREUSE

REUSE | NOREUSE

Page 68: VSAM- Virtual Storage Access Method

68

The REUSE | NOREUSE Parameter (Cont…)

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.

Page 69: VSAM- Virtual Storage Access Method

123

69

The SHAREOPTIONS Parameter

This parameter tells VSAM whether you want to let two or more jobs to process your file at thesame 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 ondifferent system in a NONGRS environment

Valuemultiple read OR single writemultiple read AND single writemultiple read AND multiple write

Page 70: VSAM- Virtual Storage Access Method

70

The SHAREOPTIONS Parameter (Cont…)

Abbreviation: SHR

Used for:

Required:

Default:

Example:

KSDS, ESDS, RRDS

No, because of default.

SHR (1 3)

SHR (1)

SHR (2 3)

Page 71: VSAM- Virtual Storage Access Method

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

Page 72: VSAM- Virtual Storage Access Method

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:

MRPW, UPDPW, RDPW

KSDS, ESDS, RRDS

Page 73: VSAM- Virtual Storage Access Method

73

The Password Protection Parameter (Cont…)

Required:

Default:

Example:

No

None

MASTERPW (GLTi)

UPDATEPW (XYZ) or READPW (ABC)

Page 74: VSAM- Virtual Storage Access Method

74

LISTCAT

Page 75: VSAM- Virtual Storage Access Method

75

LISTCAT

LISTCATs basic function is to list information about VSAM and

NON-VSAM objects

Page 76: VSAM- Virtual Storage Access Method

76

LISTCAT (Cont…)

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:

Used for:

Required:

Default:

LISTC ENT

LIST LVL

KSDS, ESDS, RRDS and non-VSAM

No, because of default.

All entries are listed if just LISTCAT is coded

Page 77: VSAM- Virtual Storage Access Method

77

LISTCAT (Cont…)

Example: LISTCAT ENTRIES (‘TRG.lib.ksds.cluster’)

LISTCAT LEVEL (TRG.lib.ksds. *)

Page 78: VSAM- Virtual Storage Access Method

78

LISTCAT (Cont…)

Options are:

HISTORY or HIST

VOLUME or VOL

ALLOCATION or ALLOC

ALL

Examples: LISTCAT ENTRIES (‘TRG.VSAM.KSDS.CLUSTER’) ALL

Page 79: VSAM- Virtual Storage Access Method

79

LISTCAT (Cont…)

//STEP1 EXEC PGM=IDCAMS//SYSPRINT DD SYSOUT=*//SYSIN DD *

LISTCAT ENTRIES (TRG.LIB.KSDS.CLUSTER) ALL/*

Example:

Example:

LISTCAT

LISTCAT LVL (TRG.*.KSDS) ALL

Page 80: VSAM- Virtual Storage Access Method

-

80

LISTCAT (Cont…)

Example 1 : (in JCL)

//STEP1 EXEC PGM=IDCAMS

//SYSPRINT

//SYSIN

DD SYSOUT=*

DD *

LISTCAT

ENTRIES(TRG.LIB.KSDS.CLUSTER) ALL

/*

Example 2 : (from TSO prompt)

LISTCAT ENTRIES (LIB.KSDS.CLUSTER) ALL

Page 81: VSAM- Virtual Storage Access Method

81

ALTERNATE INDEXES

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

Page 82: VSAM- Virtual Storage Access Method

82

ALTERNATE INDEXES (Cont…)

© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved.

Page 83: VSAM- Virtual Storage Access Method

83

ALTERNATE INDEXES (Cont…)

Page 84: VSAM- Virtual Storage Access Method

t

x

84

ALTERNATE INDEXES (Cont…)

Author

b

c

q

y

z

Book No.

... 10

... 11

... 7

... 5, 12

... 1, 3, 6

... 2, 9

... 4, 8

Page 85: VSAM- Virtual Storage Access Method

86

ALTERNATE INDEX CLUSTER (Cont…)

Page 86: VSAM- Virtual Storage Access Method

87

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

Page 87: VSAM- Virtual Storage Access Method

88

ALTERNATE INDEX(S) (Cont…)

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

Page 88: VSAM- Virtual Storage Access Method

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 89: VSAM- Virtual Storage Access Method

90

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

Page 90: VSAM- Virtual Storage Access Method

91

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 (TRG.lib.ksds.ename.aix)

Page 91: VSAM- Virtual Storage Access Method

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:

Used for:

Required:

Default:

Example:

VOL

Alternate index over a KSDS, ESDS.

Yes, if an alternate index is defined.

None

VOLUMES (DEVB32)VOLUMES (DEVB32 DEVB2B DEVB16)

Page 92: VSAM- Virtual Storage Access Method

93

The RELATE Parameter

This parameter establishes the relationship between the base cluster and the alternate indexvia the use of the base cluster name. It is unique to the DEFINE AIX command, and it isrequired.

Format:

Abbreviation:

Use:

Required:

Default:

Example:

RELATE (base cluster name)

REL

Alternate index over a KSDS, ESDS

Yes, if an alternate index is defined.

None

RELATE (TRG.lib.ksds.cluster)

Page 93: VSAM- Virtual Storage Access Method

94

The UPGRADE Parameter

Format:

Abbreviation:

Use:

Required:

Default:

Example:

UPGRADE | NOUPGRADE

UPG | NUPG

Alternate index over a KSDS, ESDS

No, because of default.

UPGRADE

UPGRADENOUPGRADE

Page 94: VSAM- Virtual Storage Access Method

95

The UPGRADE Parameter (Cont…)

Changes made to the base cluster would be reflected automaticallyin all the alternates indexes provided you have specified UPGRADEoption in each of the base cluster’s alternate indexes (DEFINE AIXcommand).

For this to happen the application program has to open the basecluster.

The set of alternate indexes VSAM updates automatically is calledUpgrade set.

Page 95: VSAM- Virtual Storage Access Method

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

Abbreviation:

Used for:

Required:

Default:

Example:

None

Alternate index over a KSDS, ESDS.

No, because of the default.

KEYS (64 0)

KEYS (30 4)

Page 96: VSAM- Virtual Storage Access Method

97

The RECORDSIZE parameter

The RECORDSIZE parameter specifies the average and maximum of each alternate indexrecord.

Format:

Abbreviation:

Use:

Required:

Default:

Example:

RECORDSIZE (avg max)

RECSZ

Alternate index over a KSDS, ESDS.

No

RECORDSIZE (4086 32600)

RECORDSIZE (80 120)

Page 97: VSAM- Virtual Storage Access Method

98

ORGANIZATION of an ALTERNATE INDEX

Page 98: VSAM- Virtual Storage Access Method

99

ORGANIZATION of an ALTERNATE INDEX

Page 99: VSAM- Virtual Storage Access Method

100

The FREESPACE Parameter

This FREESPACE parameter, allocates some percentage of both the control intervaland control area for planned free space. This free space can be used for adding newrecords. 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:

Use:

FSPC

Alternate index over KSDS, ESDS.

Page 100: VSAM- Virtual Storage Access Method

101

The FREESPACE Parameter (Cont…)

Required: No, because of default.

Default: FREESPACE (0 0)

Example: FREESPACE (20 10)

Page 101: VSAM- Virtual Storage Access Method

••••••

102

Other DEFINE AIX Parameters

You can also add the following parameters to your DEFINE AIX command. Theseparameters have been described in DEFINE CLUSTER command.

BUFFERSPACE (bytes)CISZ (bytes)ERASE | NOERASEREUSE | NOREUSESHAREOPTIONSUNIQUEKEY | NONUNIQUEKEY

Page 102: VSAM- Virtual Storage Access Method

--------------

103

Alternate Index - Example

//STEP1 EXEC PGM=IDCAMS//SYSPRINT DD SYSOUT =*

//SYSIN DD *DEFINE AIX (NAME (TRG.LIB.KSDS.EMPNAME.AIX)

VOLUMES (DEVB11)RELATE (TRG.LIB.KSDS.CLUSTER)UPGRADESHR (1 3)NOERASENOREUSEKEYS (30 8)NONUNIQUEKEYFREESPACE (20 10))

DATA(NAME(TRG.LIB.KSDS.EMPNAME.DATA)TRACKS (10 1)RECORDSIZE (75 125)CISZ(4096))

INDEX (NAME (TRG.LIB.KSDS.EMPNAME.INDEX))/*//

Page 103: VSAM- Virtual Storage Access Method

104

DEFINE an ALTERNATE INDEX PATH

Note :

• Path is defined for each ALT. Index

• Path is a separate catalog entry that contains no data

• Path is a logical connection through the Alternate Index to the base cluster

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

Page 104: VSAM- Virtual Storage Access Method

105

DEFINE PATH Command

A path is considered a VSAM object that does not contain any records. The pathname is specified in the JCL for applications that access records via the alternateindex.

Format:

Abbreviation:

Use:

Required:

Default:

Example:

DEFINE PATH (NAME (path name) parameters)

DEF PATH

Alternate index over a KSDS, ESDS.

Yes, for an alternate index.

None

DEFINE PATH (NAME (TRG.lib.ksds.ename.path))

Page 105: VSAM- Virtual Storage Access Method

106

The PATHENTRY Parameter

The PATHENTRY parameter specifies the alternate index cluster name. This establishesthe 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 (TRG.lib.ksds.ename.aix)

Page 106: VSAM- Virtual Storage Access Method

107

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

UPDATENOUPDATE

Page 107: VSAM- Virtual Storage Access Method

108

The UPDATE Parameter (Cont…)

Changes made to the base cluster would be reflected automatically in all other alternatesindexes provided you have specified UPDATE in DEFINE PATH and UPGRADE inDEFINE AIX command.

For this to happen the application program has to open the alternate index path.

Page 108: VSAM- Virtual Storage Access Method

---

109

//STEP1//SYSPRINT//SYSIN

EXEC PGM=IDCAMSDD SYSOUT =*DD *

DEFINE PATH (NAME (TRG.LIB.KSDS.EMPNAME.PATH)PATHENTRY(TRG.LIB.KSDS.EMPNAME.AIX)UPDATE

)/*//

Example JCL to define PATH for the AIX

Page 109: VSAM- Virtual Storage Access Method

110

BUILD the ALTERNATE INDEX

Note :

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

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

• Assume absolute control of base cluster by DISP=OLD.

• Output dataset can be alternate index cluster or pathname.

Page 110: VSAM- Virtual Storage Access Method

-

-

111

The BLDINDEX Command

Format: BLDINDEXINFILE (ddname) -OUTFILE (ddname)INTERNALSORT | EXTERNALSORT

INFILE and OUTFILE refer to DD statements.

BLDINDEXINDATASET (dataset name) -OUTDATASET (dataset name)INTERNALSORT | EXTERNALSORT

Page 111: VSAM- Virtual Storage Access Method

112

The BLDINDEX Command (Cont…)

Abbreviation: BIX

Use:

Required:

Default:

Alternate index over a KSDS, ESDS.

Yes, for an alternate index.

None

Page 112: VSAM- Virtual Storage Access Method

113

The INFILE/INDATASET parameters

The INFILE parameter specifies a DD statement that refers to the input dataset. TheINDATASET parameter names the dataset.

Format:

Abbreviation:

Use:

Required:

Default:

Example:

INFILE (ddname) | INDATASET (dataset name)

IFILE | IDS

KSDS, ESDS.

Yes, you must code one or the other.

None

INFILE (dd1)INDATASET (TRG.lib.ksds.cluster)

Page 113: VSAM- Virtual Storage Access Method

114

The OUTFILE/OUTDATASET parameters

The OUTFILE parameter specifies a DD statement that refers to the output dataset. TheOUTDATASET 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

OUTFILE (dd2)OUTDATASET (TRG.lib.ksds.empname.aix)

IDS and ODS dynamically allocate the input and output datasets and ensure that the job containsexclusive control.

Page 114: VSAM- Virtual Storage Access Method

--

-

115

//STEP1//SYSPRINT//DD1//IDCUT1//IDCUT2// SYSIN

EXEC PG=IDCAMSDD SYSOUT =*DD DSN=TRG.LIB.KSDS.CLUSTER,DISP=OLDDD UNIT=SYSDA,SPACE=(TRK, (2, 1))DD UNIT=SYSDA,SPACE=(TRK, (2, 1))

DD *BLDINDEX

INFILE (DD1)OUTDATASET (TRG.lib.ksds.empname.aix)INTERNALSORT

/*//

Page 115: VSAM- Virtual Storage Access Method

116

SEQUENCE for BUILDING INDEX

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

.

)

• DEFINE AIX (NAME(TRG.LIB.KSDS.AUTHNAME.AIX)

RELATE(TRG.LIB.KSDS.CLUSTER)

.

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

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

)• BLDINDEX

INDATASET(TRG.LIB.KSDS.CLUSTER)OUTDATASET(TRG.LIB.KSDS.AUTHNAME.AIX)

.

Page 116: VSAM- Virtual Storage Access Method

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.

Page 117: VSAM- Virtual Storage Access Method

--

--

118

REPRO (Cont…)

REPRO Command

Format: REPROINFILE (ddname)OUTFILE (ddname)

| INDATASET (dsname)| OUTDATASET (dsname) optional parameters

Abbreviation:

Use:

Required:

Default:

Example:

None

KSDS, ESDS. RRDS

Yes.

None

REPROINFILE (dd2)OUTDATASET (TRG.lib.ksds.empname.aix)

Page 118: VSAM- Virtual Storage Access Method

119

REPRO (Cont…)

Limiting Input and Output Records

The FROMKEY and TOKEY parameters

FROMKEY specifies the key of the input record at which to begin reading. TOKEYspecifies 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

Page 119: VSAM- Virtual Storage Access Method

Default:

120

REPRO (Cont…)

Limiting Input and Output Records

Use: KSDS, ISAM

Required: No

First record in dataset for FROMKEY and last record in dataset for TOKEY.

Example: FROMKEY (PAI)TOKEY (PAI*)

Page 120: VSAM- Virtual Storage Access Method

121

REPRO (Cont…)

The FROMADDRESS and TOADDRESS Parameters

FROMADDRESS specifies the relative byte address (RBA) value of the key of the inputrecord 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:

FADDR, TADDR

KSDS, ESDS

Page 121: VSAM- Virtual Storage Access Method

122

REPRO (Cont…)

Required: No

Default: First record in dataset for FROMADDRESS and last record in datasetfor TOADDRESS.

Example: FROMADDRESS (6250)TOADDRESS (12684)

Page 122: VSAM- Virtual Storage Access Method

123

REPRO (Cont…)

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 codeeither or both parameters.

Format:

Abbreviation:

FROMNUMBER (relative number)TONUMBER (relative number)relative number: The relative record number of the first or last record tocopy. The first record is number 0.

FNUM, TNUM

Page 123: VSAM- Virtual Storage Access Method

Default:

124

REPRO (Cont…)

Use: RRDS

Required: No

First record in dataset for FROMNUMBER and last record in dataset forTONUMBER.

Example: FROMNUMBER (10)TONUMBER (1000)

Page 124: VSAM- Virtual Storage Access Method

Use:

125

REPRO (Cont…)

The SKIP and COUNT parameters

SKIP specifies the number of input records to skip before beginning to copy. COUNTspecifies the number of output records to skip to copy. You can code either or bothparameters.

Fomat: SKIP (number)COUNT (number)number: The number of records to skip or copy.

Abbreviation:

Required:

None

KSDS, ESDS, RRDS, non-VSAM datasets

No

Page 125: VSAM- Virtual Storage Access Method

Default:

126

REPRO (Cont…)

SKIP defaults to the first record in dataset, and COUNT defaults to all therecords in the dataset.

Example: SKIP (10)COUNT (1000)

Page 126: VSAM- Virtual Storage Access Method

-

-

-

127

REPRO (Cont…)

Example Loading Dataset:

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

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

//SYSIN DD *

REPRO

INFILE(DD1)

OUTFILE(DD2)

FROMKEY(A001) -

TOKEY(A069)

/*

//

Page 127: VSAM- Virtual Storage Access Method

128

REPRO (Cont…)

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 128: VSAM- Virtual Storage Access Method

//

-

-

-

-

-

-

-

-

-

129

DELETE-DEFINE-REPRO

Example :

//DD1 DD DSN=TRG.LIB.KSDS.BACKUP(0),

DISP=OLD,UNIT=TAPE,LABEL=(1,SL)

//SYSIN DD *

DELETE TRG.LIB.KSDS.CLUSTER

DEFINE CLUSTER (NAME(TRG.LIB.KSDS.CLUSTER)

INDEXED

KEYS(4 0)

RECORDSIZE(80 80)

VOLUMES(DEVB1D)

) -

DATA(NAME(TRG.LIB.KSDS.DATA))

INDEX(NAME(TRG.LIB.KSDS.INDEX))

REPRO

INFILE(DD1)

OUTDATASET(TRG.LIB.KSDS.CLUSTER)

/*

Page 129: VSAM- Virtual Storage Access Method

130

REPRO for Merge Operations

The REPLACE Parameter for Merge Operations with REPRO

The REPRO command can also be used to merge two datasets into one. The target datasetcan be a nonempty KSDS, ESDS or RRDS. If the target dataset is an ESDS, the mergedrecords are added to the end of the existing dataset. You specify the REPLACE option aspart of the REPRO command with duplicate primary keys (in case of a KSDS) or duplicaterelative record numbers (in case of an RRDS)

Format:

Abbreviation:

Use:

Required:

REPLACE

REP

KSDS, ESDS, RRDS

No

Page 130: VSAM- Virtual Storage Access Method

-

131

REPRO for Merge Operations

Default:

Example:

matching records are not replaced.

REPLACECOUNT (500)

Page 131: VSAM- Virtual Storage Access Method

132

The DELETE Command

The DELETE command can be used to delete both VSAM and non-VSAM objects.

Format: DELETE entry nameDELETE entry name/password -

options

Entry name: The name of the entry to delete. An asterisk can be coded as awild card character in place of a name.

Password: The password for the entry if there is one. Omit the password ifthe entry doesn’t have a password.

Abbreviation: DEL

Page 132: VSAM- Virtual Storage Access Method

133

The DELETE Command (Cont…)

Use: KSDS, ESDS, RRDS, non-VSAM.

Required: No

Default: None.

Example: DELETE TRG.lib.ksds.cluster

Page 133: VSAM- Virtual Storage Access Method

••

••••

134

The DELETE Command (Cont…)

Optional parameters are:

••

••

ALIASAIXCLUSTERNONVSAMPATHGDGERASE | NOERASEFORCE | NOFORCEPURGE | NOPURGESCRATCH | NOSCRATCH

Page 134: VSAM- Virtual Storage Access Method

135

The DELETE Command (Cont…)

//TRG001A JOB 9927,HSBC,MSGLEVEL=(1,1),NOTIFY=&SYSUID//* Deletes VSAM Dataset//STEP1 EXEC PGM=IDCAMS//SYSPRINT DD SYSOUT = *//SYSIN DD *

DELETE TRG.LIB.KSDS.CLUSTER ERASE/*//

Page 135: VSAM- Virtual Storage Access Method

136

The PRINT command

The PRINT command is used to view the contents of the dataset.Format: PRINT INDATASET (entry name/password) -

optionsPRINT INFILE (ddname/password)

Entry name: The name of the entry to printPassword: 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

Page 136: VSAM- Virtual Storage Access Method

137

The PRINT Command (Cont…)

Required:

Default:Example:

No

None.PRINT TRG.lib.ksds.clusterPRINT INDATASET (TRG.lib.ksds.cluster)PRINT INFILE (dd1)

The default output destination for PRINT is SYSPRINT.

Page 137: VSAM- Virtual Storage Access Method

•••••••

138

The PRINT Command (Cont…)

The following options are allowed:

CHARACTER | DUMP | HEX or CHAR

OptionsCHAR | DUMP | HEXCOUNT (number)FROMADDRESS, [TOADDRESS]FROMKEY, [TOKEY]FROMNUMBER, [TONUMBER]OUTFILE (ddname)SKIP (number)

Page 138: VSAM- Virtual Storage Access Method

139

The PRINT Command (Cont…)

//TRG001A JOB 9927,HSBC,MSGLEVEL=(1, 1),NOTIFY=&SYSUID//* Print VSAM Dataset//PRG1//FILE1

EXEC PGM=IDCAMSDD DSN=TRG.LIB.KSDS.CLUSTER, DISP=SHR

//SYSPRINT DD SYSOUT = *// SYSIN DD *

PRINT INFILE (FILE1) CHARACTER/*//

Example Print VSAM Dataset

Page 139: VSAM- Virtual Storage Access Method

140

The PRINT Command (Cont…)

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

Format:

Abbreviation:

Use:

Required:

OUTFILE (ddname/password)

ddname: The name of a DD statement specifying where the outputis to be written.

OFILE

KSDS, ESDS, RRDS, non-VSAM

No, because of default.

Page 140: VSAM- Virtual Storage Access Method

-

141

The PRINT Command (Cont…)

Default:

Example:

OUTFILE (SYSPRINT)

PRINT TRG.lib.ksds.cluster -OUTFILE (dd1)

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

Page 141: VSAM- Virtual Storage Access Method

142

The ALTER Command

The general form of the ALTER command is as follows:

Format: ALTER entry name/password parameters

Entry name:

Password:

The name of the entry to alter

The password for the entry if there is one. Omit thepassword if the entry doesn’t have a password parameters

Abbreviation: None

Page 142: VSAM- Virtual Storage Access Method

-

143

The ALTER Command (Cont…)

Use: KSDS, ESDS, RRDS, non-VSAM

Required: No

Default:

Example:

None.

ALTER TRG.lib.ksds.clusterFSPC (30 20)

Page 143: VSAM- Virtual Storage Access Method

••••••

144

The ALTER Command (Cont…)

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

Add volumes/Remove volumesChange Keys and uniquenessChange record sizeChange Upgrade optionChange % of FREESPACE etc.Change name of the object

Page 144: VSAM- Virtual Storage Access Method

••••••••••••••

145

The ALTER Command (Cont…)

Options:

ADDVOLUMES (volumes)AUTHORIZATION (entry string)BUFFERSPACE (size)ERASE | NOERASEFREESPACE (ci% ca%)MASTERPW (password)NEWNAME (newname)READPW (password)SCRATCH | NOSCRATCH (for GDG)SHAREOPTIONS (cross region cross system)TO (date) |FOR (days)UPDATE | NOUPDATEUPDATEPW (password)UPGRADE | NOUPGRADE

Page 145: VSAM- Virtual Storage Access Method

-

-

146

The ALTER Command (Cont…)

ALTER TRG.LIB.KSDS.CLUSTERNEWNAME (TRG.MY.CLUSTER)

Example 1 Altering name of a Dataset

ALTER TRG.LIB.KSDS.CLUSTERADDVOLUMES (DEVB31 DEVB38)

Example 2 Adding additional volumes

Page 146: VSAM- Virtual Storage Access Method

•••

147

The ALTER Command (Cont…)

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 redefineit with new attributes.

• CISZCluster type,IMBED/REPLICATEREUSE | NOREUSE

Page 147: VSAM- Virtual Storage Access Method

Use:

148

The VERIFY Command

Judicious use of the verify command is important for preserving data integrity. VERIFYverifies and updates the catalog with information from the physical end of the data in thecluster via a field called the HURBA (High Used Relative Address). VERIFY verifies thatthe catalog HURBA field stores the true values from the control block HURBA field in thedata component.

Format:

Abbreviation:

VERIFY FILE (ddname /password)Or

VERIFY DATASET (entry name /password)

VFY

KSDS, ESDS, RRDS (not valid for an LDS)

Page 148: VSAM- Virtual Storage Access Method

149

The VERIFY Command (Cont…)

Required: No

Default: None.

Example: VERIFY TRG.lib.ksds.clusterVERIFY DATASET (TRG.lib.ksds.cluster)VERIFY FILE (dd1)

Page 149: VSAM- Virtual Storage Access Method

150

The VERIFY Command (Cont…)

There are actually two HURBAs: one in the VSAM control block of the cluster and one in thecatalog entry for the cluster. The danger is that if the catalog HURBA field is incorrect, there’s apossibility that if that previously added records may be overwritten, especially in the event of thisrelationship.

VERIFY DATASET (TRG.LIB.KSDS.CLUSTER)

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

Page 150: VSAM- Virtual Storage Access Method

151

The VERIFY Command (Cont…)

Page 151: VSAM- Virtual Storage Access Method

152

SAMPLE PROGRAMS

Page 152: VSAM- Virtual Storage Access Method

//

-

-

153

SAMPLE PROGRAM

//TRG001A JOB 9927,HSBC,MSGLEVEL=(1,1),MSGCLASS=U,

NOTIFY=&SYSUID

//* Input instream Data into ESDS VSAM Dataset//STEP1 EXEC PGM=IDCAMS

//SYSPRINT DD SYSOUT = *

//DD1 DD *

123456789123456789

AAAAAAAABBBBBBCCCC

/*

//DD2

//SYSIN

DD DSN=TRG.ESDS.CLUSTER,DISP=OLD

DD *

REPRO

INFILE(DD1)

OUTFILE(DD2)

/*

Page 153: VSAM- Virtual Storage Access Method

//

-

-

154

SAMPLE PROGRAM

//TRG001A JOB 9927,HSBC,MSGLEVEL= (1,1),MSGCLASS=U,

NOTIFY=&SYSUID

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

//STEP1

//SYSPRINT

//DD1

//DD2

//SYSIN

EXEC PGM=IDCAMS

DD SYSOUT = *

DD DSN=TRG.ESDS.CLUSTER1,DISP=SHR

DD DSN=TRG.ESDS.CLUSTER2,DISP=OLD

DD *

REPRO

INFILE(DD1

OUTFILE(DD2)

/*

//

Page 154: VSAM- Virtual Storage Access Method

155

SAMPLE PROGRAM

//TRG001A JOB 9927,HSBC,MSGLEVEL=(1, 1),NOTIFY=&SYSUID

//* Print VSAM Dataset

//PRG1

//FILE1

//SYSPRINT

// SYSIN

EXEC PGM=IDCAMS

DD DSN=TRG.LIB.KSDS.CLUSTER,DISP=SHR

DD SYSOUT = *

DD *

PRINT INFILE(FILE1) CHAR

/*

//

Page 155: VSAM- Virtual Storage Access Method

156

//STEP1

//SYSPRINT

//SYSIN

EXEC PGM=IDCAMS

DD SYSOUT = *

DD *

DELETE TRG.TDG.DETAILS

/*

//

Page 156: VSAM- Virtual Storage Access Method

157

GENERATION DATA GROUP

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

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

Page 157: VSAM- Virtual Storage Access Method

158

GENERATION DATA GROUP (Cont…)

file.c1(+1)

file.c1(0)

file.c1(-1)

Next Generation

Current Generation

Previous Generations

file.c1(-2)

file.c1(-3)

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

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

Page 158: VSAM- Virtual Storage Access Method

159

GENERATION DATA GROUP (Cont…)

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

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

Page 159: VSAM- Virtual Storage Access Method

160

GENERATION DATA GROUP (Cont…)

filename.GnnnnV00

35 chars 9 chars

Example : Using GDG

// IN

// OUT

DD

DD

DSN=TRG.HSBC, DISP=SHR

DSN=TRG.HSBC.DAY(+1),

DISP= (NEW,CATLG,DELETE),

UNIT=SYSDA,VOL=SER=DEVB32,

SPACE= (CYL,(10,5),RLSE),DCB=(PROD.GDGMOD,BLKSIZE=23440,LRECL=80,RECFM=FB)

Page 160: VSAM- Virtual Storage Access Method

-

-

-

161

GENERATION DATA GROUP (Cont…)

Relative Name and Absolute Name

TRG.HSBC.DATA ---> Relative Name

TRG. HSBC.DATA .G00001V00 -->Absolute Name

Defining a GDG

// Step1

// SYSPRINT

EXEC PGM=IDCAMS

DD SYSOUT = *

// SYSIN DD *

DEFINE GDG(NAME(TRG. HSBC.DATA ) -

LIMIT(5)

SCRATCH

EMPTY

)

/*

//

Page 161: VSAM- Virtual Storage Access Method

//

//

//

162

GENERATION DATA GROUP (Cont…)

Following code contains 1 job with 2 steps....

//TRG001A JOB

//UPDATE EXEC PGM=PROD1

//OLDMAST DD DSN=TRG.HSBC.PAYMAST(0),DISP=OLD

//NEWMAST DD DSN=TRG. HSBC.PAYMAST(+1),

DISP= (NEW,CATLG,DELETE),UNIT=SYSDA,

VOL=SER=DEVB32,SPACE=(CYL,(1,3)),

DCB=(RECFM=FB,BLKSIZE=0)

//PAYLIST DD SYSOUT=*

//REPORT EXEC PGM=PAY3300

//PAYMAST DD DSN=TRG.HSBC.PAYMAST(+1),DISP=OLD

//PAYRPT DD SYSOUT=*

Page 162: VSAM- Virtual Storage Access Method

//

//

//

163

GENERATION DATA GROUP (Cont…)

Following code contains 2 jobs.........

//JOB1

//UPDATE

//OLDMAST

//NEWMAST

//PAYLIST

//*

//JOB2

//REPORT

//PAYMAST

//PAYRPT

JOB

EXEC PGM=PAY3200

DD DSN=TRG. HSBC.PAYMAST(0),DISP=OLD

DD DSN=TRG. HSBC.PAYMAST(+1),

DISP=(NEW, CATLG,DELETE),UNIT=SYSDA,

VOL=SER=DEVB32,SPACE=(CYL,(1,3)),

DCB=(RECFM=FB,BLKSIZE=0)

DD SYSOUT =*

JOB ...........

EXEC PGM=PAY3300

DD DSN=TRG. HSBC.PAYMAST(0),DISP=OLD

DD SYSOUT=*

Page 163: VSAM- Virtual Storage Access Method

164

CONSIDERATIONS for USING GDGs

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

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

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

Page 164: VSAM- Virtual Storage Access Method

165

SPECIFICATIONS for CREATING A GDG

• Name of the GDG.

• Number of generations that are to be retained.

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

Page 165: VSAM- Virtual Storage Access Method

166

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

• Datasets within a GDG can be referenced by there relative generation number.

• Generation 0 always references current generation.

Page 166: VSAM- Virtual Storage Access Method

167

GENERATION DATA GROUP (Cont…)

CREATION OF GDGs

• Create and catalog the index.

• Use IDCAMS statement DEFINE GDG for creating Index.

• Parameters for creating index.

Page 167: VSAM- Virtual Storage Access Method

168

GENERATION DATA GROUP (Cont…)

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.

Page 168: VSAM- Virtual Storage Access Method

169

GENERATION DATA GROUP (Cont…)

NAME

LIMIT

NOEMPTY | EMPTY

NOSCRATCH | SCRATCH

Page 169: VSAM- Virtual Storage Access Method

-

-

-

-

170

GENERATION DATA GROUP (Cont…)

JCL for creating index:

//STEP1 EXEC PGM=IDCAMS

//SYSIN DD *

DEFINE GDG(NAME(TRG.ACCOUNTS.MONTHLY)

LIMIT(5)

EMPTY

SCRATCH

)

/*

//

Page 170: VSAM- Virtual Storage Access Method

-

-

171

GENERATION DATA GROUP (Cont…)

Modifying Features of GDG:

Can be modified by the ALTER command

Example :

//STEP1 EXEC PGM=IDCAMS

//SYSIN DD *

ALTER TRG.HSBC.PAYMAST

NOSCRATCH

EMPTY

/*

//

Page 171: VSAM- Virtual Storage Access Method

172

GENERATION DATA GROUP (Cont…)

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.

/STEP1EXEC PGM=IDCAMS

//SYSIN DD *

DELETE TRG. TRG. HSBC.PAYMAST

/*

//

Page 172: VSAM- Virtual Storage Access Method

//

//

//

173

GENERATION DATA GROUP (Cont…)

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=TRG. HSBC.PAYMAST(+1),

DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,

SPACE=(TRK,(30,10),RLSE),

DCB=(MODEL.DCB,RECFM=FB,LRECL=80,BLKSIZE=800)

//

Page 173: VSAM- Virtual Storage Access Method

-

174

GENERATION DATA GROUP (Cont…)

Deleting GDG Index and Datasets:

FORCE parameter in the DELETE statement of IDCAMS can be used

Example :

/STEP1EXEC PGM=IDCAMS

//SYSIN DD *

DELETE TRG. HSBC.PAYMAST

/*

//

GDG

FORCE

-

Page 174: VSAM- Virtual Storage Access Method

175

COBOL – VSAM CONSIDERATIONS

Page 175: VSAM- Virtual Storage Access Method

176

Annexure-A

Page 176: VSAM- Virtual Storage Access Method

177

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> [WITHDUPLICATES]

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, failure to doso would cause S213-04 ABEND Failure.

Page 177: VSAM- Virtual Storage Access Method

178

COBOL-VSAM Considerations (Cont…)

FD Entry

• Should have the record structure. Other than STANDARD LABEL clause, no other clauses need to be mentioned.

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

Page 178: VSAM- Virtual Storage Access Method

179

COBOL-VSAM Considerations (Cont…)

Alternate index processing:

In your run 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 asequential number is appended to the eighth character of the base

cluster ddname.

Page 179: VSAM- Virtual Storage Access Method

180

COBOL-VSAM Considerations (Cont…)

For e.g ://LIBMAST DD DSN=TRG.LIB.KSDS.CLUSTER,DISP=SHR//LIBMAST1 DD DSN=TRG.LIB.KSDS.NAME.PATH,DISP=SHR//LIBMAST2 DD DSN=TRG.LIB.KSDS.DEPT.PATH,DISP=SHR

In the example above LIBMAST is the base cluster and LIBMAST1, LIBMAST2 are path names of AlternateIndexes built on the base cluster.

Page 180: VSAM- Virtual Storage Access Method

181

COBOL-VSAM Considerations (Cont…)

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

Page 181: VSAM- Virtual Storage Access Method

182

COBOL-VSAM Considerations (Cont…)

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 exampleREAD EMP-MAST

KEY IS EMP-NAME

Position record pointer on the desired recordSTART EMP-MAST

KEY IS EQUAL TO EMP-NAME.

Page 182: VSAM- Virtual Storage Access Method

183

FILE STATUS Codes

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.

Page 183: VSAM- Virtual Storage Access Method

02

2122

23

184

FILE STATUS Codes (Cont…)

• For these status key values,continue processing normally :00

10

successful I/O.duplicate alternate key encountered (expected).end of file.

For these status key values,bypass the record,display pertinent information, and continue processing :

Input record out of sequence.duplicate primary key or unique alternate keyencountered(un-expected).record (or Key) not found.

Page 184: VSAM- Virtual Storage Access Method

185

FILE STATUS Codes (Cont…)

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.

Page 185: VSAM- Virtual Storage Access Method

24

30

34

49

90

93

94

95

186

FILE STATUS Codes (Cont…)

For the following status key values,terminate the program:

out-of-space condition(KSDS or RRDS).Nonspecific I/O problem.out-of-space condition(ESDS).REWRITE attempted;dataset not opened for I-O.Dataset unusable or logic error.

92 logic error.Resource not available.current record pointer undefined.Nonzero HURBA for OPEN OUTPUT.

Page 186: VSAM- Virtual Storage Access Method

96

97

187

FILE STATUS Codes (Cont…)

No corresponding JCL DD statement.

If your shop has enabled the implicit VERIFY command, this means that the dataset was opened afterand implicit VERIFY and you can continue processing.

Page 187: VSAM- Virtual Storage Access Method

188

BIBLIOGRAPHY

• MVS/VSAM for Application Programmer by Brown and Smith

• VSAM by Doug Lowe

• VSAM for COBOL Programmer by Doug Lowe