Anda di halaman 1dari 187

VIRTUAL STORAGE ACCESS METHOD (VSAM)

VSAM

VSAM means virtual storage access method High performance access method and dataset organizatio environment. It resides in virtual storage. Organizes and maintains data via a cataloged structure

VSAM HISTORY
A] Standard VSAM. Only ESDS & KSDS

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

C] DF/EF VSAM ICF Cataloging

MVS/XA Ver. 1 Changes were compatible with DF/EF VSAM MVS/XA Ver. 2 LDS were added

FEATURES of VSAM

Single coherent file storage system- (Stores and Retriev Not a database management system. Not a programming language. Not a communication system. VSAM no equivalent for a PDS. Introduction by IBM in 1973, DFP/VSAM Ver 1 in 1989

has

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

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.

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.

CLUSTERS
I. KSDS CLUSTER

INDEX COMPONENT

DATA COMPONENT

II. ESDS, RRDS Cluster

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.

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.

10

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.

11

CONTROL INTERVAL

12

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.

13

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.

14

ESDS

ESDS is a sequential dataset:


Records are retrieved in the order in which they are written to the

dataset.
Additions are made always at the end of the file. Records can be retrieved randomly by using RBA(Relative Byte

Address).
RBA is an indication of how far, in bytes, each record is displaced from

the beginning of the file .


High-Used-RBA (HURBA) points to the end of the data. High-Allocated-RBA (HARBA) is the highest byte that can be used.

15

HURBA and HARBA

VSAM cluster HARBA Data space allocated but empty HURBA Data space loaded with records

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

16

VSAM DATASET STRUCTURE

17

KSDS

It is similar in many ways to ISAM file, with better index structure and improved overflow handling. Can be processed sequentially and randomly . A KSDS consists of two components: Index component. Data component.

18

Data Component

Control Areas

I II III

IV V VI

Data Component

Control Intervals

19

20

KSDS STRUCTURE

21

Insertion of a Record

22

Deletion of a Record

23

CONTROL INTERVAL SPLIT

24

CONTROL INTERVAL SPLIT (Cont)

25

CONTROL INTERVAL SPLIT

26

CONTROL INTERVAL SPLIT (Cont)

27

CONTROL INTERVAL SPLIT (Cont)

28

IDCAMS COMMANDS

29

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.

30

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.

31

IDCAMS

Commands: FUNCTIONAL Commands: DEFINE BUILDINDEX PRINT VERIFY LISTCAT MODAL Commands: IF-THEN-ELSE SET REPRO DELETE ALTER

32

IDCAMS

// jobname // stepname [// ddname ] //SYSIN /* //

JOB (parameters) EXEC PGM=IDCAMS DD DSN=datasetname, DISP= SHR/ OLD DD *

// SYSPRINT DD SYSOUT = *

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

33

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 dataset may be cataloged.

34

IDCAMS

FORMAT OF IDCAMS COMMAND verb object (parameters) Example : DEFINE CLUSTER(NAME(TRG.LIB.KSDS.CLUSTER) CYLINDERS(5, 1) VOLUMES (DEVB32) INDEXED ) Comment /* comment */

35

IDCAMS RETURN CODES

CONDITION CODE: 0 4 8 12 16 : 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.

36

IF Syntax

IF LASTCC|MAXCC compared value THEN IDCAMS command [ELSE IDCAMS command]

37

IF Syntax

Comprehends are : EQ/NE/GT/LT/GE/LE Hyphen is the continuation character Comment is assumed as Null statement ELSE is optional

38

IF Syntax Example

REPRO INFILE (INDD) OUTFILE (OUTDD) ................ IF LASTCC EQ 0 THEN PRINT OUTFILE (INDD) ELSE PRINT INFILE (OUTDD)

39

USE of DO/END

IF MAXCC LT 4 THEN DO /* COMMENT */ IDCAMS command IDCAMS command END ELSE IDCAMS command

40

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 -

41

Defining a Cluster

42

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

43

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

44

The DATA Parameter The DATA parameter tells IDCAMS that you going to create a separate data component. DATA is optional, but if coded must follow all of the parameters that apply to the cluster as a whole. Format: DATA (NAME (data name) parameters) NAME parameter is optional, but you should usually code it. If coded, it must the first DATA parameter. data name: The name you choose to name the data component. Abbreviation: Used for: Required: Default: Example: None ESDS, KSDS, RRDS No None DATA (NAME (TRG.LIB.KSDS.DATA)) INDEX (NAME (TRG.LIB.KSDS.INDEX))

45

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: Abbreviation: Used for: Required: Default: Example: INDEX (NAME (index name) parameters) index name: The name you choose for the index component. IX KSDS No None INDEX (NAME (TRG.LIB.KSDS.INDEX))

46

The Space Allocation Parameter The space allocation parameter specifies space allocation values in the units shown below: Format: Code only one of the following: CYLINDERS (primary secondary) or TRACKS (primary secondary) or RECORDS (primary secondary) or KILOBYTES (primary secondary) or MEGABYTES (primary secondary) CYL, TRK, REC, KB, MB KSDS, ESDS, RRDS Yes None CYLINDERS (10 4)|RECORDS (400 500)

Abbreviation: Used for: Required: Default: Example:

47

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

48

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.

49

The VOLUMES Parameter The VOLUMES parameter assigns one or more storage volumes to your dataset. Multiple volumes must be of the same device type (3390, for example). Format: VOLUMES (vol ser) or VOLUMES (vol ser ........ vol ser) vol ser : The six-digit volume serial number of a volume. VOL KSDS, ESDS, RRDS Yes None VOLUMES (DEVB32) VOLUMES (DEVB2B DEVB16 DEVB45)

Abbreviation: Used for: Required: Default: Example:

50

DEFINE CLUSTER

Note:

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

51

The RECORDSIZE parameter This parameter tells VSAM what size records to expect. The avg and max are average and maximum values for variable-length records If records are of fixed length, avg and max should be the same. Format: RECORDSIZE (avg max) avg : Average length of records max : Maximum length of records RECSZ KSDS, ESDS, RRDS No RECORDSIZE (4086 32600) RECORDSIZE (80 80) [Fixed Length records] RECORDSIZE (80 120) [Variable Length records]

Abbreviation: Used for: Required: Default: Example:

52

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.

53

The KEYS Parameter This parameter defines the length and offset of the primary key in a KSDS record. The offset is the primary keys displacement (in bytes) from the beginning of the record. Format: KEYS (length offset) length: length in bytes of the primary key offset: Offset in bytes of the primary key with records (0 to n) None KSDS No KEYS (64 1) KEYS (8 0)

Abbreviation: Used for: Required: Default: Example:

VSAM records begin in position zero

54

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 default NONINDEXED - Specifies an ESDS. No index is created and records are accessed sequentially or by relative byte address NUMBERED - Specifies an RRDS LINEAR - Specifies a LINEAR dataset Abbreviation: Used for: Required: Default: Example: IXD| NIXD | NUMD KSDS, ESDS, RRDS No INDEXED INDEXED|NONINDEXED|NUMBERED

55

//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) NONSPANNED REUSE NOERASE VOLUMES (DEVB1D) RECORDSIZE (80 80) RECORDS (30 50) CISZ (4096) SHR (1 3) ) DATA (NAME (TRG.LIB.KSDS.DATA)) /* //

56

//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) INDEXED KEYS (4 0) FSPC (10 20) NONSPANNED NOREUSE NOERASE VOLUMES(DEVB1D) SHR(1 3)) DATA(NAME(TRG.LIB.KSDS.DATA) RECORDSIZE(80 80) RECORDS(30 50) CISZ(4096)) INDEX (NAME (TRG.LIB.KSDS.INDEX)) /* //
57

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: Used for: Required: Default: CISZ KSDS, ESDS, RRDS No, because of the default Calculated by VSAM

58

The CONTROLINTERVALSIZE Parameter (Cont)

Example:

CISZ (4096)

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

59

The FREESPACE Parameter Format: FREESPACE (ci% ca%) ci% - Percentage of control interval to leave free for expansion ca% - 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 only Control area only

60

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.

61

The BUFFERSPACE Parameter Buffer space represents the amount of storage (in bytes) required to process the contents of a minimum of one control intervals worth of data. Format: BUFFERSPACE (bytes) bytes: The number of bytes to allocate to each buffer. Abbreviation: BUFSP Used for: Required: Default: KSDS, ESDS, RRDS No, because of default. Two data buffers for all types of datasets, plus one additional index buffer for KSDS. BUFSP (8704)

Example:

62

The BUFFERSPACE Parameter (Cont)

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

63

The RECOVERY | SPEED Parameter These parameters are mutually exclusive. RECOVERY, the default, reformats the control areas during your initial dataset load, so that you can restart the job if it abends for some reason. The disadvantage of this parameter is that programmer has to write recovery routine to restart the job. SPEED is faster and does not pre-format the control areas. You must reload the dataset from the beginning if the job fails during initial loading. Format: Abbreviation: Used for: Required: Default: RECOVERY | SPEED RCVY | None KSDS, ESDS, RRDS No, because of default. RECOVERY

64

The RECOVERY | SPEED Parameter (Cont)

Example:

RECOVERY|SPEED

65

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

66

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

67

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.

68

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 ESA cs value : Specifies the value for cross system sharing means different jobs running on different system in a NONGRS environment Value 1 2 3 multiple read OR single write multiple read AND single write multiple read AND multiple write

69

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)

70

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

71

The Password Protection Parameter


VSAM provides a hierarchical list of parameters that you can specify for a non-DFSMS-managed VSAM dataset. However DFSMSmanaged 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

72

The Password Protection Parameter (Cont)

Required: Default: Example:

No None MASTERPW (GLTi) UPDATEPW (XYZ) or READPW (ABC)

73

LISTCAT

74

LISTCAT

LISTCATs basic function is to list information about VSAM and NON-VSAM objects

75

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: LISTC ENT LIST LVL Used for: Required: Default: KSDS, ESDS, RRDS and non-VSAM No, because of default. All entries are listed if just LISTCAT is coded

76

LISTCAT (Cont)

Example: LISTCAT ENTRIES (TRG.lib.ksds.cluster) LISTCAT LEVEL (TRG.lib.ksds. *)

77

LISTCAT (Cont)

Options are: HISTORY or HIST VOLUME or VOL ALLOCATION or ALLOC ALL Examples: LISTCAT ENTRIES (TRG.VSAM.KSDS.CLUSTER) ALL

78

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

79

LISTCAT (Cont)

Example 1 : (in JCL) //STEP1 //SYSPRINT //SYSIN EXEC PGM=IDCAMS DD SYSOUT=* DD *

LISTCAT ENTRIES(TRG.LIB.KSDS.CLUSTER) ALL /* Example 2 : (from TSO prompt) LISTCAT ENTRIES (LIB.KSDS.CLUSTER) ALL

80

ALTERNATE INDEXES

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

81

ALTERNATE INDEXES (Cont)

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

82

ALTERNATE INDEXES (Cont)

83

ALTERNATE INDEXES (Cont)

Author

Book No.

b c q t x y z

... 10 ... 11 ... 7 ... 5, 12 ... 1, 3, 6 ... 2, 9 ... 4, 8

84

ALTERNATE INDEX CLUSTER (Cont)

86

ALTERNATE INDEX(S)

May be defined on one or more than one Alternate Key(s) i.e. Field(s) other than primary key Alternate Key(s) need not be unique Separate cluster is defined A path is also defined for connection between base cluster and alternate index cluster Each ALT. Index itself is a KSDS Consists of both data component and an index component Alternate Index upgradation is by default For ESDS, VSAM builds ALT. index by mapping one field to the records RBA.

87

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

88

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.

89

STEP 1: Defining the Alternate Index The first step in creating an alternate index is to define with the DEFINE AIX command The DEFINE ALTERNATEINDEX Command Define the Alternate Index Cluster using the IDCAMS DEFINE AIX command. Format: Abbreviation: Use: Required: Default: Example: DEFINE ALTERNATEINDEX DEF AIX Alternate index over a KSDS, ESDS Yes, if an alternate index is defined. None DEFINE AIX

90

The NAME parameter It is mandatory parameter that names the alternate index. Format: Abbreviation: Use: Required: Default: Example: NAME (index cluster name) None Alternate index over a KSDS, ESDS Yes, if an alternate index is defined. None NAME (TRG.lib.ksds.ename.aix)

91

The VOLUMES Parameter The VOLUMES parameter specifies the volume (or volumes) where the alternate index is to be stored. Format: VOLUMES (vol ser) or VOLUMES (vol ser ... vol ser) Vol ser: The six-digit volume serial number of a volume. VOL Alternate index over a KSDS, ESDS. Yes, if an alternate index is defined. None VOLUMES (DEVB32) VOLUMES (DEVB32 DEVB2B DEVB16)

Abbreviation: Used for: Required: Default: Example:

92

The RELATE Parameter This parameter establishes the relationship between the base cluster and the alternate index via the use of the base cluster name. It is unique to the DEFINE AIX command, and it is required. Format: Abbreviation: Use: Required: Default: 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)

93

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

94

The UPGRADE Parameter (Cont)

Changes made to the base cluster would be reflected automatically in all the alternates indexes provided you have specified UPGRADE option in each of the base clusters alternate indexes (DEFINE AIX command).

For this to happen the application program has to open the base cluster.

The set of alternate indexes VSAM updates automatically is called Upgrade set.

95

The KEYS Parameter This parameter defines the length and offset of the alternate index key. Format: KEYS (length offset) length: length in bytes of the alternate key offset: The offset is the keys displacement (in bytes) from the beginning of the record. None Alternate index over a KSDS, ESDS. No, because of the default. KEYS (64 0) KEYS (30 4)

Abbreviation: Used for: Required: Default: Example:

96

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

97

ORGANIZATION of an ALTERNATE INDEX

98

ORGANIZATION of an ALTERNATE INDEX

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 expansion ci%: - Percentage of control area to leave free for expansion Abbreviation: Use: FSPC Alternate index over KSDS, ESDS.

100

The FREESPACE Parameter (Cont)

Required: No, because of default. Default: FREESPACE (0 0)

Example: FREESPACE (20 10)

101

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

102

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) UPGRADE SHR (1 3) NOERASE NOREUSE KEYS (30 8) NONUNIQUEKEY FREESPACE (20 10)) DATA(NAME(TRG.LIB.KSDS.EMPNAME.DATA) TRACKS (10 1) RECORDSIZE (75 125) CISZ(4096)) INDEX (NAME (TRG.LIB.KSDS.EMPNAME.INDEX)) /* //

103

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)

104

DEFINE PATH Command A path is considered a VSAM object that does not contain any records. The path name is specified in the JCL for applications that access records via the alternate index. Format: Abbreviation: Use: Required: 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))

105

The PATHENTRY Parameter

The PATHENTRY parameter specifies the alternate index cluster name. This establishes the pathentry between alternate index cluster and the path. Format: PATHENTRY (entry name) entry name: The name assigned to the alternate index cluster. Abbreviation: Use: Required: Default: Example: PENT Alternate index over a KSDS, ESDS. Yes, for an alternate index. None PATHENTRY (TRG.lib.ksds.ename.aix)

106

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

107

The UPDATE Parameter (Cont)

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.

108

//STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT =* //SYSIN DD * DEFINE PATH (NAME (TRG.LIB.KSDS.EMPNAME.PATH) PATHENTRY(TRG.LIB.KSDS.EMPNAME.AIX) UPDATE ) /* //

Example JCL to define PATH for the AIX

109

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.

110

The BLDINDEX Command Format: BLDINDEX INFILE (ddname) OUTFILE (ddname) INTERNALSORT | EXTERNALSORT

INFILE and OUTFILE refer to DD statements. BLDINDEX INDATASET (dataset name) OUTDATASET (dataset name) INTERNALSORT | EXTERNALSORT

111

The BLDINDEX Command (Cont)

Abbreviation: BIX Use: Required: Default: Alternate index over a KSDS, ESDS. Yes, for an alternate index. None

112

The INFILE/INDATASET parameters


The INFILE parameter specifies a DD statement that refers to the input dataset. The INDATASET parameter names the dataset. Format: Abbreviation: Use: Required: 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)

113

The OUTFILE/OUTDATASET parameters


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

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

114

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

115

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

116

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.

117

REPRO (Cont)
REPRO Command Format: REPRO INFILE (ddname) OUTFILE (ddname) None KSDS, ESDS. RRDS Yes. None REPRO INFILE (dd2) OUTDATASET (TRG.lib.ksds.empname.aix) | INDATASET (dsname) | OUTDATASET (dsname)

optional parameters

Abbreviation: Use: Required: Default: Example:

118

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. 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 *. FKEY, TKEY

Abbreviation:

119

REPRO (Cont)
Limiting Input and Output Records

Use:

KSDS, ISAM

Required: No Default: Example: First record in dataset for FROMKEY and last record in dataset for TOKEY. FROMKEY (PAI) TOKEY (PAI*)

120

REPRO (Cont)

The FROMADDRESS and TOADDRESS Parameters FROMADDRESS specifies the relative byte address (RBA) value of the key of the input record at which to begin copying. TOADDRESS specifies the relative byte address (RBA) value of the key of the last input record to copy. You can code either or both parameters. Format: FROMADDRESS (address) TOADDRESS (address) address: The RBA address of the first or last

record to copy. Abbreviation: Use: FADDR, TADDR KSDS, ESDS

121

REPRO (Cont)

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

Example: FROMADDRESS (6250) TOADDRESS (12684)

122

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 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. FNUM, TNUM

Abbreviation:

123

REPRO (Cont)

Use:

RRDS

Required: No Default: First record in dataset for FROMNUMBER and last record in dataset for TONUMBER.

Example: FROMNUMBER (10) TONUMBER (1000)

124

REPRO (Cont)

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. None KSDS, ESDS, RRDS, non-VSAM datasets No

Abbreviation: Use: Required:

125

REPRO (Cont)

Default:

SKIP defaults to the first record in dataset, and COUNT defaults to all the records in the dataset. SKIP (10) COUNT (1000)

Example:

126

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

127

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.

128

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

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 dataset can be a nonempty KSDS, ESDS or RRDS. If the target dataset is an ESDS, the merged records are added to the end of the existing dataset. You specify the REPLACE option as part of the REPRO command with duplicate primary keys (in case of a KSDS) or duplicate relative record numbers (in case of an RRDS) Format: Abbreviation: Use: Required: REPLACE REP KSDS, ESDS, RRDS No

130

REPRO for Merge Operations

Default: Example:

matching records are not replaced. REPLACE COUNT (500) -

131

The DELETE Command The DELETE command can be used to delete both VSAM and non-VSAM objects. Format: DELETE entry name DELETE entry name/password options Entry name: The name of the entry to delete. An asterisk can be coded as a wild card character in place of a name. Password: The password for the entry if there is one. Omit the password if the entry doesnt have a password. Abbreviation: DEL

132

The DELETE Command (Cont)

Use:

KSDS, ESDS, RRDS, non-VSAM.

Required: No Default: None.

Example: DELETE TRG.lib.ksds.cluster

133

The DELETE Command (Cont)

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

134

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

135

The PRINT command The PRINT command is used to view the contents of the dataset. Format: PRINT INDATASET (entry name/password) options PRINT INFILE (ddname/password) Entry name: The name of the entry to print Password: The password for the entry if there is one. Omit the password if the entry doesnt have a password. ddname: Abbreviation: The name of a DD statement

PRINT IDS (entry name /password) PRINT IFILE (ddname /password)

Use:

KSDS, ESDS, RRDS, non-VSAM

136

The PRINT Command (Cont)

Required: Default: Example:

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

The default output destination for PRINT is SYSPRINT.

137

The PRINT Command (Cont)

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)

138

The PRINT Command (Cont)

//TRG001A JOB 9927,HSBC,MSGLEVEL=(1, 1),NOTIFY=&SYSUID //* Print VSAM Dataset //PRG1 EXEC PGM=IDCAMS //FILE1 DD DSN=TRG.LIB.KSDS.CLUSTER, DISP=SHR //SYSPRINT DD SYSOUT = * // SYSIN DD * PRINT INFILE (FILE1) CHARACTER /* //

Example Print VSAM Dataset

139

The PRINT Command (Cont)

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: Use: Required: OFILE KSDS, ESDS, RRDS, non-VSAM No, because of default.

140

The PRINT Command (Cont)

Default: Example:

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

141

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 the password if the entry doesnt have a password parameters

Abbreviation:

None

142

The ALTER Command (Cont)

Use:

KSDS, ESDS, RRDS, non-VSAM

Required: No Default: Example: None. ALTER TRG.lib.ksds.cluster FSPC (30 20) -

143

The ALTER Command (Cont)

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

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

144

The ALTER Command (Cont)

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

145

The ALTER Command (Cont)

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

Example 1 Altering name of a Dataset

ALTER TRG.LIB.KSDS.CLUSTER ADDVOLUMES (DEVB31 DEVB38) Example 2 Adding additional volumes

146

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

CISZ Cluster type, IMBED/REPLICATE REUSE | NOREUSE

147

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) VFY KSDS, ESDS, RRDS (not valid for an LDS)

Abbreviation: Use:

148

The VERIFY Command (Cont)

Required: No Default: None.

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

149

The VERIFY Command (Cont)

There are actually two HURBAs: one in the VSAM control block of the cluster and one in the catalog entry for the cluster. The danger is that if the catalog HURBA field is incorrect, theres a possibility that if that previously added records may be overwritten, especially in the event of this relationship. VERIFY DATASET (TRG.LIB.KSDS.CLUSTER) Remark: VERIFY can be issued from a TSO or within a JCL statement either the FILE or DATASET parameter.

150

The VERIFY Command (Cont)

151

SAMPLE PROGRAMS

152

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

153

SAMPLE PROGRAM

//TRG001A JOB 9927,HSBC,MSGLEVEL= (1,1),MSGCLASS=U, // NOTIFY=&SYSUID 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) /* // //* Load Data from a file into ESDS VSAM Dataset //STEP1 //SYSPRINT //DD1 //DD2 //SYSIN

154

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

155

//STEP1 //SYSPRINT //SYSIN /* //

EXEC PGM=IDCAMS DD SYSOUT = * DD *

DELETE TRG.TDG.DETAILS

156

GENERATION DATA GROUP

MVS uses the generation data groups catalog entry to keep track of relative generation numbers. As a result, GDGs must be cataloged and each generation dataset thats a part of the group must be cataloged too. When you create a generation data groups 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.

157

GENERATION DATA GROUP (Cont)

file.c1(+1) file.c1(0) file.c1(-1) file.c1(-2) file.c1(-3)

Next Generation Current Generation Previous Generations

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.

158

GENERATION DATA GROUP (Cont)

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.

159

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)

160

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

161

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

162

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

163

CONSIDERATIONS for USING GDGs

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.

164

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.

165

FEATURES of GDGs

All datasets within a GDG will have the same name. Generation number of a dataset within a GDG is automatically assigned by OS when created. Datasets within a GDG can be referenced by there relative generation number. Generation 0 always references current generation.

166

GENERATION DATA GROUP (Cont)

CREATION OF GDGs Create and catalog the index. Use IDCAMS statement DEFINE GDG for creating Index. Parameters for creating index.

167

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.

168

GENERATION DATA GROUP (Cont)

NAME LIMIT NOEMPTY | EMPTY NOSCRATCH | SCRATCH

169

GENERATION DATA GROUP (Cont)

JCL for creating index: //STEP1 //SYSIN EXEC PGM=IDCAMS DD * -

DEFINE GDG(NAME(TRG.ACCOUNTS.MONTHLY) LIMIT(5) EMPTY SCRATCH ) /* //

170

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

171

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

172

GENERATION DATA GROUP (Cont)


Adding a Dataset to a GDG: Name of the model containing the GDG DCB parameters is coded in the DCB parameter of the DD statement. Example : //STEP1 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) // //

173

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

174

COBOL VSAM CONSIDERATIONS

175

Annexure-A

176

COBOL-VSAM Considerations

SELECT CLAUSE: SELECT file ASSIGN TO DDNAME | AS-DDNAME ORGANIZATION IS SEQUENTIAL/INDEXED/RELATIVE ACCESS MODE IS SEQUENTIAL/DYNAMIC/RANDOM RECORD KEY IS <primary Key Dataname> ALTERNATE KEY IS <Alternate Key Dataname> [WITH DUPLICATES] FILE STATUS IS status-key. Note: A prefix AS- has to be attached to DDNAME to indicate to COBOL so would cause S213-04 ABEND Failure. that the file selected is an ESDS dataset, failure to do

177

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.

178

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 a sequential number is appended to the eighth character of the base cluster ddname.

179

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 Alternate Indexes built on the base cluster.

180

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 LIBMAST RECORD KEY IS ............ ALTERNATE KEY IS ......... [WITH DUPLICATES] ALTERNATE KEY IS ......... [WITH DUPLICATES] alternate key dataname.

FD : Should have record description having primary key dataname and

181

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 example READ EMP-MAST KEY IS EMP-NAME Position record pointer on the desired record START EMP-MAST KEY IS EQUAL TO EMP-NAME.

182

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.

183

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

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

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

184

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.

185

FILE STATUS Codes (Cont) For the following status key values,terminate the program:
24 30 34 49 90 92 93 94 95

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. logic error. Resource not available. current record pointer undefined. Nonzero HURBA for OPEN OUTPUT.

186

FILE STATUS Codes (Cont)

96

No corresponding JCL DD statement. this means that the dataset was opened after

If your shop has enabled the implicit VERIFY command, 97 and implicit VERIFY and you can continue processing.

187

BIBLIOGRAPHY

MVS/VSAM for Application Programmer by Brown and Smith

VSAM by Doug Lowe

VSAM for COBOL Programmer by Doug Lowe

188

Anda mungkin juga menyukai