Você está na página 1de 37

1.

INTRODUCTION TO VSAM

VSAM stands for Virtual Storage Access Method, is IBM high performance access method which allows you to access files of different organization such as sequential, indexed, relative record and linear datasets Features of VSAM VSAM is one coherent file storage system used to store and retrieve data It is not a data!ase management system li"e I#MS or #B$ It does not provide for relationships among the data %he existing data!ases li"e IMS or #B$ may !e implemented using VSAM VSAM is not a programming language But you can access VSAM dataset through programming languages li"e &'B'( or )(*I It is not a communication system li"e V%AM or &I&S It has no equivalent for a +)#S, type of file organization Advantages of VSAM )rovides protection of #ata against unauthorized access through password facility &ross-system .MVS / VS01 &mpati!ility VSAM datasets can !e imported and imported in MVS and VS0 systems #evice Independence .Access Via &atalog1 %he application programmer need not !e concerned with Bloc" size ,volume and other control information, as access to VSAM dataset it always through the &atalog and all control information are stored in the catalog entry of the dataset I#&AMS commands can !e included in 2&( to handle VSAM datasets Types of VSAM Datasets 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 All VSAM datasets consist of a data component in which data records are placed 3or 4S#S, there is an additional index component, which contains the indexes used to access records in the data component 0S#S 55#S and (#S have data component only and no index component VSAM clusters are categorized into 6 type,s ! ased on the way we store and access the records7 SDS ntry Se!uen"ed dataset.

%hese are sequential datasets that can !e read in the sequence in which they were created 5ecords can !e added only to the end of the dataset #SDS #ey Se!uen"ed dataset. %hese datasets are stored in sequence of some "ey field in the record %he data component and index component are separated %he "eys are stored in a separate index and records are accessed through the index Individual records can !e accessed randomly on the !asis of the record "ey (ocating the record is a two stage process

3irst search for the "ey in the index 8se the information in the index to locate the record

RRDS Relat$ve re"ord dataset. %hese datasets associate a num!er to each record %here is no "ey field !ut records are accessed !y deriving the relative position of the record in the dataset %DS %$near dataset. %hese datasets consist of a stream of !ytes which are accessed and written as 6" !loc"s accessed !y 5elative Byte Address VSAM &$story

VSAM was introduced in 9:;< %his version had only 0ntry Sequence #atasets and 4ey Sequenced #atasets In 9:;= 5elative 5ecord #atasets and alternate indexes for 4S#S was added In 9:;: #3*03 VSAM was introduced with Integrated &atalog 3acility .I&31 #3)*VSAM Ver 9 was introduced in 9:>; to run under the MVS*?A architecture #3)*VSAM version $ introduced (inear #atasets .(#S1 #3)*VSAM version < was introduced to run under MVS*0SA architecture In 9::9 version < < supported varia!le-length records for 55#S '. VSAM Catalogs

VSAM is totally catalog-driven &atalogs are special purpose files residing on #AS# .#irect Access Storage #evice1 serving as a central repository for information a!out all datasets under its control %here are two types of catalogs used Master catalog 8ser catalog

%here,s only one Master catalog per system %he entries in the master catalog may point to VSAM or nonVSAM dataset, user catalogs, system datasets or other o!@ects 8ser catalogs contain same type of information as master catalog All user catalogs must !e cataloged into master catalog Access to a dataset can only !e made through a master or user catalog %herefore all VSAM datasets have to !e cataloged Aon-VSAM datasets can also !e cataloged &atalogs are protected !y 5A&3

MAST R CATA%O)

8S05 &A%A('D

8S05 8S05 &A%A(' &A%A('D D

8S05 &A%A('D

8S05 &A%A('D

Figure 2.1

VSAM Catalog

Vsa( "atalog &atalogs maintain the following information Aame and physical location of datasets password information required to access protected datasets Statistics a!out datasets 0xample Ao of records added, read, deleted or no of &ontrol Interval*&ontrol Area splits Information a!out dataset itself 0xample 0S#S, 4S#S, 55#S, &SIB0, 40C(0AD%E (ocation of catalog recovery area Vsa( re"ords VSAM records can !e fixed or varia!le length 5ecords can also !e spanned Vsa( spa"e allo"at$on VSAM space allocation depends on whether the dataset is cataloged in an I&3 or the older VSAM type catalog 3or VSAM datasets cataloged in the newer I&3-type catalogs, dedicated space is allocated dynamically when the cluster is created with the #03IA0 &(8S%05 command

0ach VSAM dataset cataloged in an I&3 catalog has its own V%'& entry %hese VSAM datasets can have 9 primary and 9$$ secondary allocation unli"e 'S dataset which can have only 9 primary and 9= secondary extends on a volume Vsa( spa"e (anage(ent VSAM maintains detailed information in its catalogs a!out #AS# space allocated to VSAM files %his allocation information stored in the catalog is more comprehensive and flexi!le than the equivalent information stored for a non-VSAM file in V%'& Su* Allo"at$on 'nce the space has !een allocated, VSAM has complete control over su!sequent allocations within that space Fithin that space, VSAM can create su!allocated files Fhenever a su!allocated files need to !e created, extended or deleted, VSAM uses it own space management facilities

Un$!ue Allo"at$on
Alternatively an entire VSAM space can !e allocated to single VSAM file In that case allocation for the file called 8AIG80 file, is managed !y #A#SM rather than !y VSAM Allocation information for the unique files is maintained in two places 7 the VSAM catalog entry for the file and the V%'& entry for the space that contains unique file %he figure !elow shows two #AS# volumes %he first volume has a VSAM dataspace contains two su!allocated files Aotice that there,s unused space within the dataspace too Eowever, that space is not availa!le to non-VSAM files !ecause it,s already under VSAM,s control %he second #AS# volume contains two unique VSAM datasets All of the unused space on the volume is availa!le to !oth VSAM and Aon-VSAM datasets 8nder VS0*VSAM / 'S*VS VSAM most VSAM datasets are su!-allocated 8nder I&3, there is no VSAM space All VSAM files are 8nique

VOLUME 1
Non-VSAM File I

VOLUME II
Non-VSAM

VSAM datasets under VSAMs control

File III Non-VSAM File IV Non-VSAM

uniqu e VSAM file

Available Space File II

Available Space Non-VSAM


Figure 2.2 Space Allocation +.

Ins$de VSAM Datasets

Control Interval A control interval is the unit of data VSAM transfers !etween virtual and dis" storage It is similar to the concept of !loc"ing in non-VSAM files 0ach control interval can contain more than one logical record %he size of &I must !e !etween =9$ !ytes to <$4 8pto >4 !ytes it must !e multiple of =9$, !eyond this it is multiple of $4 %he length of the &I is specified at file creation time 3or index component, the size of &I is =9$, 94, $4 or 64 !ytes

<

A &ontrol Inverval consists of records, free space and control field information as shown !elow

5ec9 5ec$
Figure 3.1

5ec<

3ree Space

8nused Space

&ontrol 3ield

Contents of Control Interval

In th &ontrol Interval shown a!ove 5ec9, 5ec$, 5ec< are records 3ree Space is where new records can !e inserted

&3
5#3 Figure 3.2 Contents of Control Field &I#3

&ontrol Interval #escriptor 3ield.&I#31 contains information a!out availa!le space within &I 5ecord #escriptor 3ield .5#31 contains the length of each record and how many ad@acent records are of the same length %here,s one 5#3 for each record in varia!le length records %here will !e only two 5#3s per &I in case of fixed length files 'ne 5#3 specifies the length of the record and the second 5#3 specifies how many records are there in the &I 0ach 5#3 is of < !ytes VSAM groups control intervals into contiguous, fixed length areas of storage called &ontrol Areas Maximum size of a &A is 9 cylinder Cou can also specify freespace in &A %he total num!er of &I*&A in a &luster is determined !y VSAM

&'A%5'( A50A
CONTROL INTERVAL CONTROL INTERVAL CONTROL INTERVAL CONTROL INTERVAL CONTROL INTERVAL Figure 3.3 Control Area

Spanned Re"ords Spanned records are records larger than the specified &I size %hat is they span more than one &I So one spanned record may !e stored in several &Is 0ach &I that contains a record segment of a spanned record has two 5#3s %he right 5#3 gives the length of the segment and the left gives the update num!er of the segment Spanned records can exist only in 0S#S and 4S#S A &I that contains a record segment of a spanned record contains no other data 5ecords can span Control Intervals !ut not Control Areas. 3or 4S#S the entire "ey field of the spanned record must !e in the first Control Interval

(ogical 5ecord 9 5ecord9 Segment9 5& 5ecord9 Segment$ 5& 5ecord9 Segment< 5&

Figure 3.4 SDS

Spanned Record

0S#S is a sequential dataset 5ecords are retrieved in the order in which they are written to the dataset Additions are made always at the end of the file 5ecords can !e retrieved randomly !y using 5BA.5elative Byte Address1 5BA is an indication of how far, in !ytes, each record is displaced from the !eginning of the file #SDS In 4ey Sequenced #atasets logical records are placed in the dataset in the ascending collating sequence !y the "ey field 5ules for "ey 4ey must !e unique in a record 4ey must !e in same position in each record and "ey data must !e contiguous Fhen a new record is added to a dataset it is inserted in its collating sequence !y "ey A 4S#S consists of two components index component and data component #A%A &omponent 7- &ontains control areas which in turn contains &ontrol Intervals as shown in

3igure < =

&ontrol Areas

Data Co ponent
Figure 3.5 #SDS Stru"ture Contents of Control Area

Cont!ol Inte!val"

Inde, Set Se!uen"e Set


Figure 3. Contents of !S"S Inde# %he first level of index is called a Sequence set %he Sequence set consists of )rimary "eys and pointers to the Control Intervals holding records with these primary "eys %he Sequence set is always in sequential order of the primary "eys %he &ontrol Intervals may !e in any order VSAM uses the Sequence Set to access records in the 4S#S sequentially %he index component is a separate entity with a different CI size , a different name and can !e stored on a different volume &ontrol interval splits can occur in Indexes also Se!uen"e Set

4ey )tr 4ey )tr

4ey )tr 4ey )tr

&I

&I

&I

&I

Figure 3.$

Contents of Se%uence Set Index Set

Index component Sequence Set Sequence Set

&I

&I

&I

&I

&I

&I

&I

&I

CA1

CA2

Figure 3.$

Contents of Inde# Set

Ne% &eco!d

5ecord9

5ecord$

5ecord<

3S)&

8S

&3

A$te! In"e!tin'

5ecord9

5ecord$

Aew 5ecord 5ecord <

3S)&

8S

&3

Figure 3.&

Inserting a ne' record into a !S"S #e$o!e Cont!ol Inte!val Split

Aew 5ecord 5ec9 5ec$ 5ec< 5ec6 5ec= 8S

3ull &ontrol Interval

&3

3S)&

8S

&3

0M)%IC &I
Figure 3.( Inserting a ne' record into a full CI

5ecord9

5ecord$

Aew 5ecord

3S)&

8S

&3

5ecord<
Figure 3.1)

5ecord6

5ecord=

3S)&

8S

&3

After Control Interval Split

I
Sequence Set

4 9JJ
Ne% &eco!d

5ecordA
J

5ecordB

5ecord3

5ecordD

3S)&

8S

&3

5ecord2

5ecord4
FS(C

3S)&

8S
US CF

&3

9JJ

$JJ Figure 3.11a

*ffect of Control Interval Split on Se%uence Set

0
J

$JJ

9JJ FS/C US CF

Re"ordA

Re"ord0

Re"ordC

9JJ

Re"ord.

Re"ord#

FS/C

US

CF

$JJ

Re"ordF

Re"ord)

FS/C

US

CF

Figure 3.11+

*ffect of Control Interval split on Se%uence Set -. IDCAMS COMMANDS

Cou can write I#&AMS utility program 9 %o create VSAM dataset $ %o list, examine, print, tune, !ac"up, and export*import VSAM datasets %he I#&AMS utility can !e in vo"ed in !atch mode with 2&( or interactively with %S' commands Fith 2&( you can print*display datasets and system messages and return codes Multiple commands can !e coded per @o! Cou can use I3-%E0A-0(S0 statement to execute command*s selectively !ased on condition codes returned !y previous commands (isted !elow are the I#&AMS commands to !e discussed in this course

>

D FIN MODA% COMMANDS IF S T /ARM

0UI%DIND 1 R /RO /RINT D % T V RIF2 IM/ORT3 1/ORT A%T R %ISTCAT

%he example 6 9 shown !elow is a s"eleton 2&( for executing I#&AMS commands %he )DM parameter specifies that the program to !e executed is I#&AMS utility program %he statements that follow SCSIA ## K are I#&AMS commands %he end of data is specified !y *K 'ptionally 2'B&A% and S%0)&A% statements may !e coded to indicate catalog names for a @o!*step, in which concerned dataset may !e cataloged

)) *obna e +O# ,pa!a ete!")) "tepna e E.EC (/M0IDCAMS )) S1S(&IN2 DD S1SOU2 0 3 4)) ddna e DD DSN0data"etna e5 DIS(0 S6&) OLD 7 ))S1SIN DD 3 IDCAMS co and)" coded $!eel8 bet%een 9 to :9 col"; )3 )) Optionall8< )) +O#CA2 DD DSN 0 catalo'na e5 DIS(0 S6& )) S2E(CA2 DD DSN 0 catalo'na e5 DIS( 0 S6&

Exa ple =;1 For(at of IDCAMS "o((and ver! o!@ect .parameters1

+CL $o! executin' IDCAMS co

and"

0very I#&AMS command starts with a ver! followed !y o!@ect which ta"es some parameters In the code listing 6 $ DEFINE is the ver! CLUS2E& is the o!@ect which ta"es a dataset DA>>>12;LI#;?SDS;CLUS2E& as parameter DEFINE CLUS2E& NAME,DA>>>12;LI#;?SDS;CLUS2E&C1LINDE&S,@5 1VOLUMES ,#SA>1AINDE.ED -

Exa ple =;9 Co((ents4

C!eatin' a clu"te!

&omments in I#&AMS can !e specified in the following manner )3 co ent 3) o! )3 ----3) IDCAMS return "odes %he I#&AMS &ommands return certain codes which have the following interpretation

Cond$t$on "ode4 J 6 > 9$ 9H 7 command executed with no errors 7 warning - execution may go successful 7 serious error - execution may fail 7 serious error - execution impossi!le 7 fatal error - @o! step terminates

%he condition codes are stored in (AS%&&*MA?&& (AS%&& stores the condition code for the previous command and MA?&& stores the maximum code returned !y all previous commands Both (AS%&& and MA?&& contain zero !y default at the start of I#&AMS execution Cou can chec" the condition code of the previous command and direct the flow of execution or terminate the 2&( Syntax of IF statement IF LAS2CC)MA.CC co pa!and 26EN co and ELSE Co and &omparand.s1 are 7 0G*A0*D%*(%*D0*(0 VA,-* -

Eyphen is required after then to indicate the continuation of the command on the next line &omment is assumed as null command ELSE is optional (AS%&& and MA?&& values can !e changed using the S0% command Note . ,AS/CC and MA0CC can also be set to any value between )11 e;'; S0% (AS%&& L 6 Setting MA?&& has no effect on (AS%&& Setting (AS%&& changes the value of MA?&&, if (AS%&& is set to a value larger than MA?&& Setting MA?&& L 9H terminates the @o!

9J

;;;;;;;;; &E(&O INFILE ,INDDOU2FILE ,OU2DD;;;;;;;;;;;;;;;; IF LAS2CC EB > 26EN (&IN2 OU2FILE ,INDDELSE (&IN2 INFILE ,OU2DD-

IF MA.CC L2 = 26EN DO

)3 COMMEN2 3) Co22and Co22and

END ELSE Co and

*#a2ple 4.3a DEFINE CLUS2E& C; IF LAS2CC D > 26EN SE2 MA.CC 0 1E ELSE &E(&O CC

3C, using MA0CC and ,AS/CC

Exa ple =;Ab Def$n$ng an SDS Cluster

+CL u"in' MA.CC and LAS2CC

D FIN C%UST R &lusters are created and named with the #03IA0 &(8S%05 command T&e NAM para(eter %his is a required positional parameter For(at < NAME,Clu"te!-Na e&luster name 7- %he name to !e assigned to the cluster ,a(ple: NAME,DA>>>=2;LI#;?SDS;CLUS2E&%he cluster Aame !ecomes the dataset name in any 2&( that invo"es this cluster either as an input or output ))IN(U2 DD DSN0DA>>>=2;LI#;?SDS;CLUS2E&5DIS(0S6& %he high-level qualifier is important !ecause in most installations this technique ensures that VSAM datasets are cataloged in the appropriate user catalog Rules for Na($ng Cluster &an have 9 to 66 alphanumeric characters &an include the national characters M, N, O Segmented into level of eight or fewer characters, separated !y periods %he first character must !e either alpha!etic or national character T&e S/AC Allo"at$on para(eter %he space allocation parameter specifies space allocation values in the units shown !elow7 For(at4 C1LINDE&S,(!i Sec2&AC?S,(!i Sec-

99

&ECO&DS,(!i Sec?ILO#12ES,(!i SecME/A#12ES,(!i Sec)rimary 7 Aum!er of units of primary space to allocate %his amount is allocated once when the dataset is created Secondary 7 Aum!er of units of secondary space to allocate %his amount is allocated a maximum of 9$$ times as needed during the life of the dataset VSAM calculates the control area size for you A control area size of one cylinder usually yields !est performance %o ensure control area size of one cylinder you must allocate space in &C(IA#05S Allocating space ine 50&'5#S must !e avoided as this might result in an inefficient &ontrol Area size T&e VO%UM S para(eter %his V'(8M0S parameter assigns one or more storage volumes to your dataset Multiple volumes must !e of the same device type For(at 4 VOLUMES,vol"e!- o! VOLUMES,vol"e! ;;;;;;;; vol"e!volser 7 %he H digit volume serial num!er of a volume ,a(ple 4 VOLUMES,#SA>11VOLUMES,#SA>11 #SA>=> #SA>=9Cou can store the data and index .in case of 4S#S clusters1 on separate volumes as this may provide a performance advantage for large dataset T&e Re"ords$5e para(eter %his parameter tells VSAM what size records to expect %he avg and max are average and maximum values for varia!le length record If records are of fixed length, avg and max should !e the same For(at4 &ECO&DSIFE,av' axavg 7 Average length of records max 7 Maximum length of records e;'; < &ECO&DSIFE,G> G>- 4Fixed Len'tH !eco!d"7 &ECO&DSIFE,G> 19>- 4Va!iable Len'tH !eco!d"7 50&'5#SIB0 can !e assigned at the cluster or data level Note 4 %his is an optional parameter, if omitted default is 50&'5#SIB0.6J>H 6J>H1 T&e S/ANN D para(eter %his parameter allows large record to span more than one control interval Eowever records cannot span &ontrol Areas %he resulting free space in the spanned control interval is unusa!le !y other records, even if they fit logically in the unused !ytes PA'AS)AAA0# is the defaultQ / it means that records cannot span control intervals T&e DATAS T6T2/ para(eter %his parameter specifies whether the dataset is INDE.ED,?SDS-5 NONINDE.ED,ESDS-5 o! NUM#E&ED,&&DS-; For(at < INDE.EDI NONINDE.ED I NUM#E&ED IA#0?0# 7- Specifies a 4S#S and is the default A'AIA#0?0# 7- Specifies an 0S#S Ao index is !y relative !yte address A8MB050# 7- Specifies an 55#S created and records are accessed sequentially or

9$

(IA0A5 7- Specifies a (IA0A5 dataset %he default dataset %ype is INDE.ED; ))DA>>>12A +O# LA9:1J5 (CS5MS/LEVEL0,151-5 )) M/CLASS0A5NO2IF10DA>>>12 )) 3 Delete)De$ine Clu"te! $o! ESDS VSAM Data"et ))S2E(1 E.EC (/M0IDCAMS )) S1S(&IN2 DD S1SOU2 0 3 )) S1SIN DD 3 DELE2E DA>>>12;LI#;ESDS;CLUS2E& DEFINE CLUS2E& ,NAME,DA>>>12;LI#;ESDS;CLUS2E&NONINDE.ED &ECO&DSIFE,19@ 19@&ECO&DS,1>> 1>NONS(ANNED VOLUMES ,#SA>1A&EUSE DA2A,NAME,DA>>>12;LI#;ESDS;DA2A-Exa ple =;=

+CL $o! De$inin' an ESDS Clu"te!

Def$n$ng #SDS Cluster Fhile defining a 4S#S &luster it is essential to code the #A%A, IA#0? and 40CS parameter T&e DATA para(eter %he #A%A parameter tells I#&AMS that you are going to create a separate data component %his parameter is optional for 0S#S and 55#S datasets Cou should code the AAM0 parameter of #A%A for 4S#S datasets, in order to operate on the data component !y itself For(at : DA2A,NAME,datana e- (a!a ete!"dataname 7- %he name you choose to name the data component T&e IND 1 para(eter %he IA#0? parameter creates a separate index component For(at 4 INDE.,NAME,indexna e- (a!a ete!"indexname 7 %he name you choose to name the index component INDE.,NAME,DA>>>=2;LI#;?SDS;INDE.-Fhen you code the #A%A and IA#0? parameters, you usually coda a AAM0 parameter for them If you omit the AAM0 parameter for #A%A and IA#0? , VSAM appends #A%A or IA#0? as the low-level qualifier T&e # 2S para(eter %his parameter defines the length and offset of the primary "ey in a 4S#S record %he offset is the primary "ey,s displacement .in !ytes1 from the !eginning of the record For(at 4 ?E1S,len'tH o$$"etlength 7 length in !ytes of the primary "ey offset 7 'ffset in !ytes of the primary "ey with records ,> to n-

9<

,a(ple 4 ?E1S,G >VSAM records !egin in position zero Note : Default is !"S#$% &' ( ey is in bytes ) t*ru $+, ))DA>>>12A +O# LA9:1J5 (CS5MS/LEVEL0,151-5 )) M/CLASS0A5NO2IF10DA>>>12 )) 4 elete! efine "luster for #S S VSAM ataset ))3 ))S2E(1 E.EC (/M0IDCAMS )) S1S(&IN2 DD S1SOU203 )) S1SIN DD 3 DELE2EDA>>>12;LI#;?SDS;CLUS2E& DEFINE CLUS2E&, NAME,DA>>>12;LI#;?SDS;CLUS2E&INDE.ED ?E1S,= >FS(C,1> 9>&ECO&DSIFE,19@ 19@&ECO&DS,1>> 1>NONS(ANNED VOLUMES ,#SA>1ANO&EUSE DA2A,NAME,DA>>>12;LI#;?SDS;DA2A-- INDE.,NAME,DA>>>12;LI#;?SDS;INDE.-)3 Exa ple =;@ +CL $o! De$inin' a ?SDS Clu"te!

--

T&e FR S/AC para(eter %his 3500S)A&0 parameter, which applies to the 4S#S, allocates some percentage of control interval and control area for planned free space %his free space can !e used for adding new records or for expanding existing varia!le records 3500S)A&0 applies only to the data component For(at < F&EES(ACE,KCI KCAR&I 7- )ercentage of control interval to leave free for expansion R&A 7- )ercentage of control area to leave free for expansion ,a(ple 4 FR S/AC 7'8 189 %oo much free space results in more i*o, especially when doing sequential processing %oo little results in excessive control interval and control area split Note : Default is FR**S5AC*6) )7 T&e R US para(eter %he 508S0 parameter specifies that the cluster can !e opened a second time as a reusa!le cluster A'508S0 is the default, and specifies the cluster as non-reusa!le For(at < &EUSEINO&EUSE Some application call for temporary dataset or wor"file that must !e created, used and deleted each time the application runs %o simplify these applications, VSAM lets you create reusa!le files %he reusa!le file is a standard VSAM 4S#S, 0S#S or 55#S %he only difference is that, if you open an existing reusa!le file for output processing, VSAM treats the file as if were empty Any records already present in the file are ignored T&e CONTRO% INT RVA% SI: para(eter %his parameter specifies the &ontrol Interval size It is usually a!!reviated &ISB

96

For(at 7 CISF,b8te",a(ple 4 CISF,=>JENote : If omitted -SA. calculates CIS/ based on record si0e. Re(ar; 4 &ontrol Interval is VSAM,s equivalent of a !loc" and it is the unit of data that is actually transmitted when records are read or written )u$del$nes for deter($n$ng t&e CIS: 0S#S is processed sequentially, so the &ISB should !e relatively large, depending on the size of the record 3or sequential processing with larger records you may choose a &ISB of >" 3or datasets processed randomly as well as sequentially .for !ac"up at night1 choose a &ISB for random processing and then allocate extra !uffers for sequential processing with the AM) 2&( parameter 55#S is usually processed randomly, so the &ISB should !e relatively small, depending on the size of the record S<AR O/TIONS %his parameter tells VSAM whether you want to let two or more @o!s to process your file at the same time It specifies how a VSAM dataset can !e shared For(at 4 S6A&E O(2IONS,c! value c" value"r value 7 Specifies the value for cross region sharing &ross region sharing is defined as different @o!s running on the same system using Dlo!al 5esource Serialization.D5S1, a resource control facility availa!le only under MVS*?A and 0SA "s value 7 Specifies the value for cross system sharing means different @o!s running on different system in a A'AD5S environment Values 7 multiple read '5 single write multiple read AA# single write multiple read AA# multiple write #efault 7- SEA50')%I'AS.9 <1 =. %ISTCAT

(IS%&A%,s !asic function is to list information a!out VSAM and A'AVSAM o!@ects Fith (IS%&A% you can also view password and security information, usage statistics, space allocation information, creation and expiration dates etc For(at 14 LIS2CA2 EN2&IES,ent!8na e- option" 'ptions are 7 6IS2O&1 VOLUME ALLOCA2ION ALL

9=

0A%5I0S .0A%1 requires you to specify each level of qualification, either explicitly or implicitly, using an asteris" as a wild card character ,a(ples4 LIS2CA2 EN2,DA>>>12;VSAM;?SDS;CLUS2E&CLUS2E& ALL Exa ple @;1 %he a!ove command will only display the !ase cluster

LIS2CA2

LIS2CA2 EN2,DA>>>12;VSAM;?SDS;CLUS2E&DA2A ALL

%he a!ove command will only display the data component

LIS2CA2 EN2,DA>>>12;VSAM;?SDS;CLUS2E&ALL

%he a!ove command will display all catalog information

))S2E(1 E.EC (/M0IDCAMS ))S1S(&IN2 DD S1SOU203 ))S1SINDD 3 LIS2CA2 EN2&IES,DA>>>12;LI#;?SDS;CLUS2E&- ALL )3

For(at '4 LIS2CA2 LEVEL,level- option" (0V0( !y definition lists all lower levels VSAM assumes that qualifier to !e the high-level qualifier and list every entry with that high level qualifier 0xample

LIS2CA2 LVL,DA>>>12;3;?SDS- ALL

%he a!ove will list all entries with #AJJJ9% as high level qualifier , anything in the second-level qualifier and 4S#S in the third-level qualifier %hat is it would list #AJJJ9% AB& 4S#S and #AJJJ9% %0S% 4S#S AI?, #AJJJ9% %0S% 4S#S #A%A

9H

To e,e"ute %ISTCAT fro( TSO pro(pt LIS2CA2 EN2&IES ,LI#;?SDS;CLUS2E&- ALL If you analyze the output of the (IS%&A% command there is A(('&A%I'A information which shows two fields E85BA and EA5BA Eigh-8sed-5BA .E85BA1points to the end of the data Eigh-Allocated-5BA .EA5BA1is the highest !yte that can !e used EIDE-A(('&-5BA indicates the 5elative Byte Address.plus 91 of the last allocated data control area %his value reflects the total space allocation for the data component EIDE-8S0#-5BA indicates the 5elative Byte Address.plus 91 of the last used data control area %his value reflects the portion of the space allocation that is actually filled with data records %here are actually to E85BAs one in the VSAM control !loc" of the cluster and one in the catalog entry for the cluster Cou can write application programs .in &'B'(, )(*I Assem!ler (anguage, in &I&S1 and use the statements provided !y these languages to write and read VSAM datasets

VSAM clu"te!
Data "pace allocated but e pt8 Data "pace loaded %itH !eco!d"
Figure 5.1 8-R9A and 8AR9A >. Creat$ng Alternate Inde,es 6A&#A

6U&#A

An Alternate Index AI? provides a view of data different from the one offered !y the primary "ey 3or example for a 4S#S dataset 0mployee, you may have a 5ecord 4ey index on 0mployee-no and an Alternate Index on 0mployee-Aame Cou can now !rowse and even update the same 4S#S in logical sequence !y 0mployee-Aame Alternate Indexes may !e defined on one or more than one Alternate 4ey.s1 i e 3ield.s1 other than primary "ey Alternate 4ey.s1 need not !e unique 0ach alternate index itself is a 4S#S with data and index component Alternate Index greatly reduces redundancy %here is no need to "eep a separate dataset for different views li"e 0mployees, Social Security Ao %he records may !e accessed sequentially or randomly !ased on the alternate record "eys %hey can !e updated automatically when the !ase cluster is updated Alternate Indexes do not support a reusa!le !ase cluster So A'508S0 which is the default, should !e specified %oo many Alternate Indexes !uilt on a 4S#S may lead to performance #egradation as access !y alternate "ey requires twice as many I*',s VSAM first locates the primary "ey from the alternate index and then locates the &ontrol Interval information from the record "ey index 3or 0S#S, VSAM !uilds AI? !y mapping one field to the record,s 5BA

9;

Steps for def$n$ng and *u$ld$ng alternate $nde,es4 D FIN AI1 Co((and #efine the Alternate Index &luster using the I#&AMS #03IA0 AI? command

))S2E(1 E.EC (/M0IDCAMS ))S1S(&IN2 DD S1SOU2 03 ))S1SIN DD 3 DEFINE AI. ,NAME,DA>>>12;LI#;?SDS;AU26NAME;AI.VOLUMES ,#SA>1A&ELA2E,DA>>>12;LI#;?SDS;CLUS2E&U(/&ADE 2&AC?S,1> 1?E1S,9@ J&ECO&DSIFE,:> 11>F&EES(ACE,9> 1>S6A&EO(2IONS,1NONUNIBUE?E1DA2A,NAME,DA>>>A12;LI#;?SDS;AU26NAME;DA2A-INDE.,NAME,DA>>>12;LI#;?SDS;AU26NAME;INDE.)3 )) Exa ple E;1 )athname is the dataset name in 2&( .#SAL)A%EAAM01 R %AT /ara(eter For(at7 &ELA2E,+ase cluster na2e+CL to de$ine AI.

%his parameter esta!lishes the relationship !etween the !ase cluster and the alternate index via the use of the base cluster name It is unique to the #03IA0 AI? command, and it is required T&e R CORDSI: /ara(eter For(at7 &ECO&DSIFE,avg 2a#%his parameter specifies the average and maximum length of each alternate index record %here are two types of alternate indexes #SDS un$!ue alternate $nde,7 Cou can create a unique alternate index !y specifying the 8AIG8040C parameter %he records of unique alternate indexes are of fixed length %he length of a unique alternate index !uilt over a 4S#S is derived as follows7

E'8S0400)IAD =

Soc-Sec-Ao : 9>

0mp-Ao >

Figure .1

Contents of !S"S uni%ue alternate inde#

3or example if an unique alternate index on Soc-Sec-Ao is !uilt on our 4S#S cluster 0mployee then the 50&'5#SIB0 will !e calculated as follows7= Bytes fro Eouse4eeping S size of alternate "ey S Size of )rimary 4ey that the alternate L = S : S > L $$ %herefore recordsize parameter will !e coded as 50&'5#SIB0.$J $J1 4S#S non-unique alternate index7 An alternate index created with a A'A8AIG8040C parameter has varia!le length records %he 50&'5#SIB0 is calculated as follows7Avgerage 5ecord length L = !ytes for Eouse 4eeping S size of the alternate "ey S size of the primary "ey x average no of records the alternate index "ey can point to Maximum 5ecord length L = !ytes for Eouse 4eeping S size of the alternate "ey S size of the primary "ey x maximum no of records the alternate index "ey can point to D FIN /AT< Co((and4 #efine an Alternate Index )ath using the I#&AMS #03IA0 )A%E command %he path forms a connection !etween the alternate index and the !ase cluster )ath name !ecomes a catalog entry !ut path does not contain any records %he path name is specified in the 2&( for applications that access records via the alternate index

))S2E(1 E.EC (/M0IDCAMS ))S1S(&IN2 DD S1SOU2 03 ))S1SIN DD 3 DEFINE (A26 NAME,DA>>>12;LI#;?SDS;AU26NAME;(A26(A26EN2&1,DA>>>12;LI#;?SDS;AU26NAME;AI.U(DA2E )3 ))

Exa ple E;9

+CL to de$ine (A26 $o! tHe AI.

U/DAT vs NOU/DAT 5ecords may !e accessed !y applications !y the alternate index path alone, without opening the !ase cluster In such cases any changes made to data will !e reflected in the alternate index records if the 8)#A%0 option is specified If A'8)#A%0 is specified then the alternate index records will not !e automatically updated U/)RAD vs. NOU/)RAD %he 8)#A%0*A'8)#A%0 option of #03IA0 )A%E wor"s in tandem with the 8)D5A#0 * A'8)D5A#0 of the #03IA0 AI? command 8)D5A#0 specifies that any changes made in the !ase cluster records will !e reflected immediately in the alternate index records if the !ase cluster is opened in the application 3ortunately 8)D5A#0 and 8)#A%0 are defaults for their respective commands

9:

0u$ld$ng Alternate Inde,es %he final step in creating an alternate index is to actually !uild and populate it with records %he B(#IA#0? command does the following7 %he data component of the !ase cluster is read sequentially and pairs of "ey pointers are extracted %hese pairs consist of the alternate "ey field and its corresponding primary "ey field VSAM creates a temporary file with these records %his temporary file is sorted in ascending alternate "ey sequence If A'A8AIG8040C option is specified then a merge operation ta"es place, which will merge all records with the same alternate "ey into a single record %hese records are the data component of the Alternate Index VSAM now constructs the index component @ust as it does for the 4S#S

Note: 1*e Alternate Index can be built only after t*e base cluster *as been bot* defined and loaded wit* atleast & record.

))S2E(1 E.EC (/0IDCAMS ))S1S(&IN2 DD S1SOU2 03 ))DD1 DD DSN0DA>>>12;LI#;?SDS;CLUS2E&5 )) DIS(0OLD ))IDCU21 DD UNI20S1SDA5S(ACE0,2&?5 ,95 1-))IDCU29 DD UNI20S1SDA5S(ACE0,2&?5 ,95 1-)) S1SIN DD 3 #LDINDE. INFILE,DD1OU2DA2ASE2,DA>>>12;LI#;?SDS;AU26NAME;AI.- IN2E&NALSO&2 )3 )) Exa ple E;A +CL to build Alte!nate Index

#isposition of !ase cluster is DIS/?O%D as the B(#IA#0? needs a!solute control of the !ase cluster 'utput dataset can !e Alternate index cluster or pathname %he IA%05AA(S'5% uses virtual storage whereas 0?%05AA( S'5% uses dis" space IA%05AA(S'5% is the default If you want an external sort to !e performed then include I#&8%9 and I#&8%$ ## statements in your 2&( and specify 0?%05AA(S'5% in the B(#IA#0? command

DEFINE Clu"te! ,NAME,DA>>>12;LI#;?SDS;CLUS2E&; DEFINE AI. ,NAME,DA>>>12;LI#;?SDS;AU26NAME;AI.- &ELA2E,DA>>>12;LI#;?SDS;CLUS2E&; DEFINE (A26 ,NAME,DA>>>12;LI#;?SDS?;AU26NAME;(A26(A26EN2&1,DA>>>12;LI#;?SDS;AU26NAME;AI.; #LDINDE. INDA2ASE2,DA>>>12;LI#;?SDS;CLUS2E&OU2DA2ASE2,DA>>>12;LI#;?SDS;AU26NAME;AI.;

$J

Exa ple E;= Step" $o! c!eatin' and buildin' AI.

@. Reorgan$5$ng VSAM datasets %his chapter explains the commands used to !ac" up and restore existing datasets, protect the integrity of data R /RO %his command is used to7 (oads empty VSAM cluster with records &reates !ac"up of a dataset Merge data from two VSAM datasets 50)5' command can operate on non-VSAM datasets It is an all-purpose load and !ac"up utility command and can !e used in place of I0BD0A05 Fith 50)5' you can do the following &onvert an ISAM dataset to VSAM format &opy a non-VSAM dataset to a physical sequential or partitioned dataset &opy record from one type of VSAM datasets to another 3or example 4S#S to 0S#S

50)5' has following disadvantages7 (ittle control over the input data &atalog information is not copied with the data )rior #0(0%0 and redefinition is required !efore loading the cluster unless you have specified 508S0 in the #03IA0 &(8S%05 command Incase of 4S#S, data and index component are !uild automatically R /RO Co((and Synta, For(at 4 &E(&O INFILE,ddna eOU2FILE,ddna eI INDA2ASE2,d"na eI OU2DA2ASE2,d"na e-

'ptional parameters are < F&OM?E1 F&OMADD&ESS F&OMNUM#E& S?I( 2O?E1 2OADD&ESS 2ONUM#E& COUN2 IA3I(0 and '8%3I(0 are required parameters that point to ##9.input file1 and ##$ .output file1 respectively %$($t$ng Input and Output Re"ords46 Fhile it is not possi!le to edit the input to 50)5', you can limit the input !y providing the optional parameters FROM# 2 and TO# 2 para(eters7 35'M40C specifies the "ey of the input records at which to !egin reading %'40C specifies the "ey to stop reading or the last input record S4I) and &'8A% parameters S4I) specifies the num!er of input records to s"ip !efore !eginning to copy &'8A% specifies the num!er of output records to copy Cou can specify !oth 3or example s"ip 9J records and copy next 9J ))DD1 DD DSN0DA>>>12;IN(U2;?SDS5DIS(0OLD ))DD9 DD DSN0DA>>>12;OU2(U2;?SDS5 DIS(0OLD ))S1SINDD 3 &E(&O INFILE,DD1OU2FILE,DD9F&OM?E1,A>>12O?E1,A>EJ-

$9

Exa ple :;1 'ther parameter for filtering records7 F&OMADD&ESS ,&#A2OADD&ESS,&#AF&OMNUM#E& ,&&N2ONUM#E&,&&NCOUN2 ,NO;S?I(,NO0a";$ng up VSAM Datasets

+CL $o! Loadin' Data"et<

It is good to !ac"up VSAM datasets on a regular !asis 50)5' command is used to re!uild and restore VSAM cluster from the !ac"up copy Bac"ing up a VSAM dataset involves only one step ))+O#NAME DA>>>12AC ))S2E(1> E.EC (/M0IDCAMS ))S1S(&IN2 DD S1SOU2 0 3 ))DD9 DD DSN0DA>>>12;?SDS;INV;#AC?U(,L1-5 )) DIS(0,NEM5CA2L/5DELE2E-5UNI202A(E5 )) VOL0SE&0A9J:>5LA#EL0,15SL-5 )) DC#0,&ECFM0F#5L&ECL0G>))S1SIN DD 3 &E(&O INDA2ASE2,DA>>>12;?SDS;INV;CLUS2E&- N OU2FILE,DD9)3 )) Exa ple :;9 U"in' &ep!o $o! bacOup

In the example a!ove IA#A%AS0% is the input file and ##$ is the output tape dataset which is a part of the D#D while is more or less li"e a physical sequential file .5ef to chapter 9J for more on D#D,s 1

Restor$ng and re*u$ld$ng t&e *a";up

#0(0%0-#03IA0-50)5' sequence required to restore the cluster incase of 4S#S #elete the original cluster using I#&AMS #0(0%0 command 5edefine the cluster using I#&AMS #03IA0 &(8S%05 command (oad the empty cluster with data using the I#&AMS 50)5' command Fhen you #0(0%0-#03IA0-50)5' a VSAM dataset it has the following effects on the 4S#S %he dataset is reorganized that is the &ontrol Interval and &ontrol Area splits are eliminated 3ree space is redistri!uted throughout the dataset as specified in the 3500S)A&0 parameter )rimary index is re!uilt, however the #0(0%0 command deletes the !ase cluster as well as its indexes So the alternate indexes have to !e redefined 0S#S or 55#S need not !e reorganized !ecause the record position is fixed permanently !y sequence of entry or record num!er ))DD1 DD DSN0DA>>>12;LI#;?SDS;#AC?U(,>-5 )) DIS(0OLD5 UNI202A(E5LA#EL0,15SL))S1SIN DD 3

$$

DELE2E DA>>>12;LI#;?SDS;CLUS2E& )3 DEFINE CLUS2E& NAME,DA>>>12;LI#;?SDS;CLUS2E&INDE.ED ?E1S,= >&ECO&DSIFE,G> G>VOLUMES,#SA>1ADA2A,NAME,DA>>>12;LI#;?SDS;DA2A-INDE.,NAME,DA>>>12;LI#;?SDS;INDE.-&E(&O INFILE,DD1OU2DA2ASE2,DA>>>12;LI#;?SDS;CLUS2E&)3

Exa ple :;A Merg$ng datasets A$t& R /RO

DELE2E-DEFINE-&E(&O

%he 50)5' command can also !e used to merge two datasets into one %he target dataset can !e a nonempty 4S#S, 0S#S or 55#S If the target dataset is an 0S#S, the merged records are added to the end of the existing dataset 1/ORT3IM/ORT Co((ands %he 0?)'5%*IM)'5% commands can !e used for !ac"up and recovery Cou can export a dataset, alternate index or a catalog to a different system 0M)'5%*IM)'5% has several advantages as compared to 50)5' &atalog information is exported along with data &luster deletion and redefinition not required during import as input dataset already contains catalog information 0asily ported on other systems as catalog information availa!le with data (i"e 50)5' 4S#S datasets are reorganized however three steps of 50)5' are replaced !y one D$sadvantages4 0xported data cannot !e processed until Imported &an !e used only for VSAM dataset 1/ORT FORMAT 4 E.(O&2 ent!8na e I pa""%o!d OU2FILE,ddna e- I OU2DA2ASE2,d"na e'ptional parameters ,a(ple 4 E.(O&2 DA>>>12;LI#;?SDS;CLUS2E& OU2FILE,DD9%he output dataset from an 0?)'5% must always !e a sequential dataset .usually on a tape1

$<

IM/ORT For(at 4 IM(O&2 INFILE,ddna e- I INDA2ASE2,d"na eOU2FILE,ddna e- I OU2DA2ASE2,d"na e'ptional parameters7 IM(O&2 INFILE ,DD9OU2DA2ASE2,DA>>>12;LI#;?SDS;CLUS2E&Imports only 0?)'5%0# dataset ))DA>>>12A +O# LA19:J5(CS5MS/LEVEL0,151-5 )) MS/CLASS0A5 NO2IF10DA>>>12 ))3 Input in"t!ea Data into ESDS VSAM Data"et )) S2E(1 E.EC (/M0IDCAMS )) S1S(&IN2 DD S1SOU2 0 3 )) DD1 DD 3 19A=@E:GJ19A=@E:GJ AAAAAAAA######CCCC )3 ))DD9 DD DSN0DA>>>12;ESDS;CLUS2E& ))S1SIN DD 3 &E(&O INFILE,DD1OU2FILE,DD9)3 )) Exa ple :;= Input in"t!ea Data into ESDS -

))DA>>>12A +O# LA9:1J5(CS5MS/LEVEL0 ,151-5 )) MS/CLASS0A5 NO2IF10DA>>>12 ))3 Load Data $!o a $ile into ESDS VSAM Data"et ))S2E(1 E.EC (/M0IDCAMS ))S1S(&IN2 DD S1SOU2 0 3 ))DD1 DD DSN0DA>>>12;ESDS;CLUS2E&1 ))DD9 DD DSN0DA>>>12;ESDS;CLUS2E&9 ))S1SIN DD 3 &E(&O INFILE,DD1 OU2FILE,DD9)3 )) Exa ple :;@ Load Data $!o a $ile into ESDS

1-. V RIF2 B /RINTB D % T B A%T R Co((and V RIF2 Ver$fy - preserves data integrity .E85BA1

$6

For(at 4 VE&IF1 FILE,ddna e)pa""%do! VE&IF1 DA2ASE2,ent!8na e)pa""%dVE&IF1 ent!8na e)pa""%d ,2SOVE&IF1 DA2ASE2,DA>>>12;LI#;?SDS;CLUS2E&Exa ple G;1 Re(ar; 4 V05I3C can !e issued from a %S' or within a 2&( statement It is valid only for VSAM dataset except (#S D % T - logically deletes dataset - catalog entry deleted For(at 4 DELE2E ent!8na e)pa""%d optional pa!a ete!" DELE2E DA>>>12;LI#;?SDS;CLUS2E& E&ASE Exa ple G;9 Opt$onal para(eters are 4 AI. CLUS2E& NONVSAM (A26 E&ASE I NOE&ASE FO&CE I NOFO&CE (U&/E I NO(U&/E SC&A2C6 I NOSC&A2C6 ))DA>>>12A +O# LA91:J5(CS5MS/LEVEL0,15 1- 5 )) NO2IF10DA>>>12 ))3 Delete" VSAM Data"et ))S2E(1 E.EC (/M0IDCAMS ))S1S(&IN2 DD S1SOU2 0 3 ))S1SIN DD 3 DELE2E DA>>>12;2&AIN;I2MFOIV )3 Exa ple G;A Delete VSAM Data"et /RINT %he default output destination for )5IA% is SCS)5IA% prints in &EA5*E0?*#8M) format limiting For(at 1 4 (&IN2 INDA2ASE2 ,ent!8na e)pa""%dFor(at ' 4 (&IN2 INFILE ,ddna e)pa""%d- Deletin' a Clu"te! VE&IF1

$=

parameters li"e 50)5' are availa!le Opt$ons C6A& I DUM( I 6E. COUN2 ,nu be!F&OMADD&ESS5 42OADD&ESS7 F&OM?E15 42O?E17 F&OMNUM#E&5 42ONUM#E&7 OU2FILE ,ddna eS?I( ,nu be!))DA>>>12A +O# LA91:J5(CS5MS/LEVEL0,15 1- 5 )) NO2IF10DA>>>12 ))3 (!int VSAM Data"et ))(&/1 E.EC (/M0IDCAMS ))FILE1 DD DSN0DA>>>12;LI#;?SDS;CLUS2E&5 )) DIS(0S6& ))S1S(&IN2 DD S1SOU2 0 3 )) S1SIN DD 3 (&IN2 INFILE,FILE1- C6A&AC2E& )3 )) Exa ple G;= A%T R 8sed to change certain attri!utes of a previously defined VSAM o!@ect 3ollowing can !e done with A(%05 change names Add volumes*5emove volumes &hange 4eys and uniqueness &hange record size &hange 8pgrade option &hange R of 3500S)A&0 etc For(at : AL2E& ent!8na e)pa""%d pa!a ete!" Opt$ons 4 ADDVOLUMES ,volu e"AU26O&IFA2ION,ent!8 "t!in'#UFFE&S(ACE ,"iPeE&ASE I NOE&ASE F&EES(ACE,ciK caKMAS2E&(M,pa""%o!dNEMNAME,ne%na e&EAD(M ,pa""%o!dSC&A2C6 I NOSC&A2C6 S6A&EO(2IONS ,c!o"" !e'ion c!o"" "8"te 2O,date- IFO&,da8"U(DA2E I NOU(DA2E U(DA2E(M,pa""%o!dU(/&ADE I NOU(/&ADE (!int VSAM Data"et

T&e ORD R D /ara(eter

$H

%he '5#050# )arameter tells VSAM to assign the 40C5AAD0S values to the volumes, one !y one, in the order in which the 40C5AAD0S and V'(8M0S are specified For(at 4 O&DE&ED I UNO&DE&ED ,a(ple 4 ?E1&AN/ES, ,>>>1 1>>>,1>>1 9>>>,9>>1 A>>>-- VOLUMES ,#SA>1A #SA>1= #SA>>1Note : 2*en you code 34D!4!D5 you must code t*e same no. of -367.!S as !"4AN8!S. T&e IM0 D /ara(eter %he IMB0# )arameter directs VSAM to place the sequence set on the first trac" of the #ata &ontrol Area and duplicate it as many times as it will fit Advantage 7 reduces rotational delay For(at < IM#ED I NOIM#ED

T&e R /%ICAT /ara(eter %he 50)(I&A%0 )arameter directs VSAM to duplicate each index record as many times as it will fit on its assigned trac" It applies to a 4S#S index component only; For(at 4 &E(LICA2E I NO&E(LICA2E ,a(ple 4 INDE.,NAME,DA>>>12;LI#;?SDS;INDE.IM#ED &E(LICA2E T&e /assAord /rote"t$on /ara(eter VSAM provides a hierarchical list of parameters that you can specify for a non-#3SMS-managed VSAM dataset Eowever #3SMS-managed dataset you must use a security pac"age li"e 5A&3 For(at 4 MAS2E&(M,pa""%o!dAllows the highest level of access to all cluster components, including #0(0%0 and A(%05 authority For(at 4 U(DA2E(M,pa""%o!dAllows write authority to the cluster For(at 4 &EAD(M,pa""%o!dAllows read only access to the cluster

$;

Note 4 Valid only for 4S#S, 0S#S, 55#S )asswords are initially specified in the #03IA0 &(8S%05 ,a(ple 4 MAS2E&(M,2&/DE(2At the execution time, a password can !e coded explicitly in the )ASSF'5# clause of a &'B'( S0(0&% clause T&e AUT<ORI:ATION /ara(eter A8%E'5IBA%I'A provides additional security for a VSAM cluster !y naming and assem!ler user verification routine .8SV51 For(at 4 AU26O&IFA2ION ,ent!8-point pa""%o!dentry-point 7 the name of the entry point of a 8SV5 written in assem!ly language password 7 the password the routine is to verify Note : -alid only for SDS5 !SDS5 44DS. ,a(ple 4 AU26,M1&2N Q2&/DE(2RAL2E& DA>>>12;LI#;?SDS;CLUS2E& NEMNAME,A9>>>;M1;CLUS2E&-

Exa ple G;@ AL2E& DA>>>12;LI#;?SDS;INDE. F&EES(ACE,A> A>-

Alte!in' na e o$ a Data"et -

Exa ple G;E

Alte!in' F&EES(ACE o$ a Data"et

%he following attri!utes are altera!le only for empty clusters ?E1S,len'tH o$$"et &ECO&DSIFE,av' ax UNIBUE?E1 I NONUNIBUE?E1 %he following attri!utes are unaltera!le Cou have to #0(0%0 the cluster and redefine it with new attri!utes CISF Clu"te! t8pe5 IM#ED)&E(LICA2E &EUSE I NO&EUSE 1=. )enerat$on DataSets Although there are many different uses for sequential datasets, many sequential files have one characteristics in common 7 they are used in cyclical application

$>

for example, sequential dataset that contains transaction posted daily against a master file is cyclicalT each days transactions, along with the processing required to post them, from one cycle Similarly a sequential dataset used to hold the !ac"up copy of a master file is cyclical tooT each time a new !ac"up copy is made, new cycle is !egun In most of the cyclical applications, it,s good idea to maintain versions of the files used for several cycles %hat way if something goes wrong, you can recreate the processing that occurred during previous cycles to restore the affected files to a "nown point %hen the processing can continue from that point 3or this MVS provides a facility called generation data group, D#D is a collection of two or more chronologically related versions of the same file 0ach version of the file or mem!er of the D#D, is called a generation dataset A generation dataset may reside on tape or #AS# It is generally sequential .GSAM1 or direct.B#AM1 file ISAM and VSAM files can,t !e used in D#Ds As each processing cycle occurs a new generation of dataset is added to the generation data group %he new version !ecomes the current generationT it replaces the old current generation, which !ecomes a previous generation file c9.S91 file c9.J1 file c9.-91 file c9.-$1 file c9.-<1 Aext Deneration &urrent Deneration )revious Denerations

3igure a!ove is the structure of a generation data group %here are < previous generations, note that generations are num!ered relative to the current generation, file c9.J1 5elative generation num!ers are ad@usted when each processing cycle completes, so that the current generation is always referred to as relative generation J MVS uses the generation data group,s catalog entry to "eep trac" of relative generation num!ers As a result, D#Ds must !e cataloged and each generation dataset that,s a part of the group must !e cataloged too Fhen you create a generation data group,s catalog entry, you specify how many generations should !e maintained 0xample7 Cou might specify that five generations including the current generation should !e maintained %hen during each processing cycle, the new version of the file !ecomes the current version Although MVS lets you use relative generation num!ers to simplify cyclical processing, MVS uses UA!solute Deneration Aum!ersV in the form DnnnnVJJ to identify each generation dataset uniquely DnnnnVJJ represents the chronological sequence num!er of the sequence num!er of the generation, !eginning with DJJJJ VJJ is a version num!er, which lets you maintain more than one version of a generation 0ach time a new generation dataset is created, mvs adds one the sequence num!er %he sequence and version num!ers are stored as a part of the file,s dataset name, li"e this7 filename DnnnnVJJ <= chars : chars )) IN DD DSN0DA>>>92;MAS2E&5 DIS(0S6&

)) OU2 DD DSN0DA>>>92;MAS2E&;DA1,L1-5 DIS(0 ,NEM5CA2L/5DELE2E-5 UNI20AAJ>5 VOL0SE&0#(>>A15 S(ACE0 ,C1L5,1>5@-5&LSE-5 DC#0,(&OD;/D/MOD5 #L?SIFE09A==>5L&ECL0G>5&ECFM0F#-S Exa ple J;1 U"in' a /D/

$:

&elative Na e and Ab"olute Na e DA>>>92;MAS2E&;DA1J>- ---D &elative Na e DA>>>92;MAS2E&;DA1;/>>>>1V>> --DAb"olute Na e

)) Step1 )) S1S(&IN2 )) S1SIN

E.EC (/M0IDCAMS DD S1SOU2 0 3 DD 3 DEFINE /D/ ,NAME,DA>>>92;MAS2E&;DA1LIMI2,@SC&AC6 EM(21Exa ple J;9 De$inin' a /D/ Index

)3

Follo%in' code contain" 1 *ob %itH 9 "tep";;;;

))DA>>>A2A !!$% A&' ))OLDMAS2 ))NEMMAS2

+O# '('" %)M*%A+,-.. DD DSN0MMA9;(A1;MAS2,>-5DIS(0OLD DD DSN0MMA9;(A1;MAS2,L1-5 DIS(0 ,NEM5CA2L/-5UNI20AA>>5 VOL0SE&0#SA>>15 DC#0,L&ECL0G>5#L?SIFE01E>>DD DSN0MMA9;(A1;2&AN5DIS(0OLD DD S1SOU203 '('" %)M*%A+,,.. DD DSN0MMA9;(A1;MAS2,L1-5DIS(0OLD DD S1SOU203 Exa ple J;Aa Addin' data"et" to a /D/

))(A12&AN ))(A1LIS2 !!/'%0/& ))(A1MAS2 ))(A1&(2

Follo%in' code contain" 9 *ob";;;;;;;;; !!1023 ))U(DA2E ))OLDMAS2 ))NEMMAS2 102 E.EC (/M0(A1A9>> DD DSN0MMA9;(A1;MAS2,>-5DIS(0OLD DSN0MMA9;(A1;MAS2,L1-5 DIS(0,NEM5 CA2L/-5 UNI20AA>>5 VOL0SE&0#SA>>15 DC#0,L&ECL0G>5 #L?SIFE01E>>DD DSN0MMA9;(A1;2&AN5DIS(0OLD DD S1SOU2 03 102 44444444444 E.EC (/M0(A1AA>> DD DSN0MMA9;(A1;MAS2,>-5DIS(0OLD DD S1SOU203 Exa ple J;Ab Addin' data"et" to a /D/

))(A12&AN ))(A1LIS2 !!102))&E(O&2 ))(A1MAS2 ))(A1&(2

D#D,s are a group of datasets which are related to each other chronologically and functionally Denerations can continue until a specified limit is reached %he (IMI% parameter specifies total num!er of generations that can exist at any one time 'nce limit is reached the oldest generation is deleted

<J

D#D Index have to !e created using the I#&AMS command +#03IA0 D#D, !efore datasets that are to !e included in them can !e made a part of them Model containing parameter information of the datasets to !e included in the D#D has to !e specified All datasets within a D#D will have the same name Deneration num!er of a dataset, within a D#D is automatically assigned !y 'S when created #atasets within a D#D can !e referenced !y their relative generation num!er Deneration J always references current generation Creat$on of )D)s &reate and catalog the index 8se I#&AMS statement #03IA0 D#D for creating Index )arameters for creating index Spe"$f$"at$on Aame of D#D Aum!er of generations (imit W maximum no of datasets in a D#D Action to !e ta"en when limit is reached 8ncataloging oldest generation once limit reached 8ncataloging all generations when limit reached

)hysical deletion of entry 8ncataloging entry without physical deletion Def$n$ng a (odel for t&e )D). NAME CC LIMI2 C;; refers to the name of the D#D Index refers to the maximum no of datasets in a D#D

NOEM(21C EM(21 C SC&A2C6 C; NOSC&A2C6 C

Mod$fy$ng Features of )D) Cou can modify a D#D only with the A(%05 command ))S2E(1 E.EC (/M0IDCAMS ))S1SINDD AL2E& DA>>>12;ACCOUN2S;MON26L1 NOSC&A2C6 EM(21 )3 )) Exa ple J;= Modi$8in' a /D/ Delet$ng )D) Inde, &an !e deleted !y the #0(0%0 parameter of I#&AMS Fill result in an error on reference to any generation datasets of the D#D

<9

)S2E(1 E.EC (/M0IDCAMS ))S1SINDD DELE2E DA>>>12;ACCOUN2S;MON26L1 /D/ )3 )) Exa ple J;@ Deletin' /D/ Index Add$ng a Dataset to a )D) Aame of the model containing the D#D #&B parameter,s is coded in the #&B parameter of the ## statement

))S2E(1 E.EC (/M0/D/1 ))FILE1 DD )) DSN0DA>>>12;ACCOUN2S;MON26L1,L1-5 )) DIS(0,NEM5CA2L/5DELE2E-5UNI20S1SDA5 )) S(ACE0,2&?5,A>51>-5&LSE-5 )) DC#0,MODEL;DC#5 )) &ECFM0F#5L&ECL0G>5 )) #L?SIFE0G>>Exa ple J;E Addin' a Data"et to a /D/ Delet$ng )D) Inde, and Datasets 3'5&0 parameter in the #0(0%0 statement of I#&AMS can !e used ,a(ple 4

)S2E(1 E.EC (/M0IDCAMS ))S1SINDD DELE2E DA>>>12;ACCOUN2S;MON26L1T /D/ FO&CE )3 )) Exa ple J;: Deletin' /D/ Index and Data"et" 1>. CO0O% VSAM Cons$derat$ons SELEC2 CLAUSE SELEC2 $ile ASSI/N 2O DDNAME ) AS-DDNAME O&/ANIFA2ION IS SEBUEN2IAL)INDE.ED)&ELA2IVE ACCESS MODE IS SEBUEN2IAL)INDE.ED)D1NAMIC &ECO&D ?E1 IS p!i a!8 ?e8 Datana e AL2E&NA2E ?E1 IS Alte!nate ?e8 Datana e 4MitH Duplicate"7 FILE S2A2US IS "tatu"-Oe8;

Exa ple 1>;1 SELEC2 clau"e $o! VSAM data"et" status "eyL&o!ol, VSAM x.$1 :.$1 - 5eturn code :.91 - 2unction code :.<1 - 3eed!ac" code

<$

FD ntry Should have the record structure If 4S#S then "ey field must match with length and position of 40CS parameter in #03IA0 &(8S%05 information F$le /ro"ess$ng 5egular &'B'( file handling commands Alternate $nde, pro"ess$ng 4 In 2&( there must !e a ## statement for !ase cluster and one or more ## statement for alternate index path name Note: 1*ere is no C3936 standard for assigning ddnames to alternate indexes5 so a quasi:standard *as emerged w*ereby a sequential number is appended to t*e eig*t* c*aracter of t*e base cluster ddname. ))LI#MAS2 DD DSN0DA>>>12;LI#;?SDS;CLUS2E&5 )) DIS(0S6& ))LI#MAS21 DD DSN0DA>>>12;LI#;?SDS;NAME;(A265 )) DIS(0S6& ))LI#MAS29 DD DSN0DA>>>12;LI#;?SDS;DE(2;(A265 )) DIS(0S6& Exa ple 1>;9 +CL to acce"" AI. Re(ar;4 Ao matter how many alternate indexes you specify in the program, there,s only one ASSIDA clause pointing to the ddname of the !ase cluster SELEC2 $ile ASSI/N 2O LI#MAS2

&ECO&D ?E1 IS ;;;;;;;;;;;; AL2E&NA2E ?E1 IS ;;;;;;;;; 4MI26 DU(LICA2ES7 Exa ple 1>;A Cobol SELEC2 clau"e $o! AI.

3# 7 Should have record description having primary "ey dataname and alternate "ey dataname 40C of reference 7 50A# filename 40C IS primary*alternate "ey dataname #ey of Referen"e. %he "ey that is currently !eing used to access records is called the "ey of reference Fhen the program opens the dataset, the primary "ey !ecomes, !y default, the "ey of reference %he primary "ey remains the "ey of reference when accessing records until it is changed %o start accessing records !y an alternate index "ey, you merely change the "ey of reference !y using the 40C phrase as part of one of the following statements A random 50A# statement, for example &EAD EM(-MAS2 ?E1 IS EM(-NAME Exa ple 1>;= A sequential 50A# statement, for example &EAD EM(-MAS2 NE.2 ?E1 IS EM(-NAMEA

&EAD

<<

Exa ple 1>;@ S%A5% statement, for example S2A&2 EM(-MAS2 ?E1 IS EBUAL 2O EM(-NAME; Exa ple 1>;E ;ey61 ;ey6' Successful &ompletion7 J J $ 6 = ; 0nd-of-file 9 J 6 Cause

&EAD $o! Acce""in' AI.

S2A&2 ve!b

Ao further information, #uplicate "ey detected Frong fixed-length record #ata set created when pened Fith sequential VSAM datasets,J is returned &('S0 with A' 50FIA# or 500(, for non-tape Ao further information 5elative record 50A# outside dataset !oundary Sequence error #uplicate "ey Ao record found 4ey outside !oundary of dataset Ao further information 5ecord outside dataset !oundary ')0A and required dataset not found ')0A with invalid mode ')0A of dataset closed with ('&4 ')0A unsuccessful !ecause of conflicting dataset attri!utes

Invalid "ey $

9 $ < 6

)ermanent I*' error 7 < J 6 = ; > : (ogic error 7 6 9 $ < 6 H ; > :

')0A of dataset already open &('S0 for dataset not open 50A# not executed !efore 50F5I%0 50F5I%0 of different-record size 50A# after 0'3 reached 50A# attempted for dataset not opened I-' or IA)8% F5I%0 for dataset not opened '8%)8%,I-' or 0?%0A# #0(0%0 or 50F5I%0 for dataset not opened I-'

Specific compiler-defined conditions 7 : J Ao further information 9 VSAM password failure $ (ogic error < VSAM resource not availa!le 6 VSAM sequential record not availa!le = VSAM invalid or incomplete dataset information : H VSAM-no ## statement ; VSAM ')0A successful #ataset integrity verified

<6

VSAM I*' error processing I*' error handling is one vital area where VSAM dataset processing differs from non-VSAM dataset processing Fhen processing non-VSAM datasets, most programmers code their application programs to ignore errors, !ecause the access method would a!end the program if a serious I*' error occurs Aot so when processing VSAM datasets %he &'B'( 3I(0 S%A%8S 4ey VSAM places program control in the hands of the programmer, not the '*S 3or this reason, it is important to chec" the &'B'( status "ey designated in the 3I(0 S%A%8S clause after every I*' operation 3or some error "eys youXll want to a!end the program immediatelyT for others you can @ust display the "ey, the record, and an informative message and continue processing 3or these status "ey values, continue processing normally 7 JJ successful I*' J$ duplicate alternate "ey encountered .expected1 9J end of file 3or these status "ey values, !ypass the record, display pertinent information, and continue processing 7 $9 $$ $< Input record out of sequence duplicate primary "ey or unique alternate "ey encountered .un-expected1 record .or 4ey1 not found

Note: "ou may want to *ave t*e program count t*e number of times t*ese ;ey values are returned and terminate t*e program if t*e counter reac*es an unacceptable number5 w*ic* would li;ely to indicate t*at your input is bad 3or the following status "ey values, terminate the program 7 $6 <J <6 6: :J :$ :< :6 := :H :; out-of-space condition .4S#S or 55#S1 Aonspecific I*' pro!lem out-of-space condition.0S#S1 50F5I%0 attemptedT dataset not opened for I-' #ataset unusa!le or logic error logic error 5esource not availa!le current record pointer undefined Aonzero E85BA for ')0A '8%)8% Ao corresponding 2&( ## statement If your shop has ena!led the implicit V05I3C command, this means that the dataset was opened after and implicit V05I3C, and you can continue processing 1@. Append$,6A

VSAM ASSI)NM NT a ! #efine an 0S#S cluster )opulate the 0S#S cluster !y using a &'B'( program 8sing (IS%&A% command list the attri!utes of the created cluster #efine a 4S#S cluster with the following options7 Allocation for <JJJ records primary, secondary allocations for 9JJ records 3ixed record length of >J !ytes each 4ey !eginning in the =th position with length of = !ytes Volume parameters

<=

c d

)opulate the 4S#S cluster !y using a &'B'( program 8sing (IS%&A% command list the attri!utes of the created cluster Frite a program to populate an indexed master file from transaction records %here are three datasets )5'#8&%-MAS%05 5ecord (ayout

)rodno
9 =H

unit price
9J

)85&EAS0-%5AAS 5ecord (ayout

&ustno
9 = H

Aame
$= $H

Gty
$> $:

)rodno
<<

&8S%'M05-MAS%05 5ecord (ayout

&ustno
9 =H

Amount )rodno
9< 96 9>

<H

9 $ < 6 e

A ta!le of product num!ers and corresponding unit prices is to !e created in storage from )5'#8&%MAS%05 %here are =J product num!ers &ustomer num!er is the "ey field for the &8S%'M05-MAS%05 file Amount owed L Guantity )urchased x 8nit )rice .from ta!le1 )erform a ta!le loo" up using the product num!er from the )85&EAS0-%5AAS record to find the corresponding unit price in the )5'#8&%-MAS%05 ta!le

An indexed file contains the following ta!le records7 9$ <6 =; > 99 State num!er &ounty num!er %ax rate Aot used

%he "ey field is a com!ined group item consisting of state num!er and country num!er &reate a 4S#S cluster and populate the cluster from the following transaction records 9= H $= $H $> $: << <6 <= <H <; <; &ustomer num!er &ustomer name Gty )rice per unit State num!er &ounty num!er Aot used

%he output master file is also an indexed file with following record layout 9 <; Same as positions 9-<; in the transaction record <> 6= Amount 'wed 6H Aot used Amount 'wed L Gty x )rice per unit S %ax rate x .Gty x )rice per unit 1

<;

Você também pode gostar