45211518-vsam

Upload: anbarasan2006

Post on 04-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 45211518-VSAM

    1/37

    1. INTRODUCTION TO VSAM

    VSAM stands for Virtual Storage Access Method, is IBM high performance access method which allows you toaccess 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 managementsystem li"e I#MS or #B$ It does not provide for relationships among the data %he existing data!ases li"e IMSor #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 offile 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 VS0systems

    #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 allcontrol information are stored in the catalog entry of the datasetI#&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 consistsof one or two components All VSAM datasets consist of a data component in which data records are placed3or 4S#S, there is an additional index component, which contains the indexes used to access records in the datacomponent 0S#S 55#S and (#S have data component only and no index componentVSAM clusters are categorized into 6 types !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 addedonly 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 componentare separated %he "eys are stored in a separate index and records are accessed through the index Individualrecords 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 therelative position of the record in the dataset

    %DS %$near dataset.%hese datasets consist of a stream of !ytes which are accessed and written as6" !loc"s accessed !y 5elative Byte Address

    VSAM &$story

    9

  • 8/13/2019 45211518-VSAM

    2/37

    VSAM 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 architectureIn 9::9 version

  • 8/13/2019 45211518-VSAM

    3/37

    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= secondaryextends 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 informationstored 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 spaceFithin 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 filecalled 8IG80 file, is managed !y #A#SM rather than !y VSAM Allocation information for the unique filesis 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 otice that theres unused space within the dataspace too Eowever, that space is not availa!le tonon-VSAM files !ecause its already under VSAMs control %he second #AS# volume contains two uniqueVSAM datasets All of the unused space on the volume is availa!le to !oth VSAM and on-VSAM datasets8nder VS0*VSAM / 'S*VS VSAM most VSAM datasets are su!-allocated 8nder I&3, there is no VSAMspace All VSAM files are 8nique

    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 theconcept 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 !ytes it must !e multiple of =9$, !eyond this it ismultiple of $4 %he length of the &I is specified at file creation time3or index component, the size of &I is =9$, 94, $4 or 64 !ytes

    5ecord2 5ecord4 3S)& 8S &3

    5ecordA 5ecordB 5ecord3 5ecordD 3S)& 8S &3

    I J 4 9JJ

    Ne%&eco!d

    FS(C US CF

    Re"ord Re"ord# FS/C US CF

    Re"ordA Re"ord0 Re"ordC FS/C US CF

    0 J I $JJ 4 9JJ

    Re"ordF Re"ord) FS/C US CF

  • 8/13/2019 45211518-VSAM

    9/37

    DFIN

    MODA% COMMANDS

    IF

    ST

    /ARM

    0UI%DIND

    R/RO

    /RINT

    D%T

    VRIF2

    IM/ORT3/ORT

    A%TR

    %ISTCAT

    %he example 69 shown !elow is a s"eleton 2&( for executing I#&AMS commands %he )DM parameterspecifies that the program to !e executed is I#&AMS utility program %he statements that follow SCSI ## Kare 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 whichconcerned dataset may !e cataloged

    )) *obnae +O# ,pa!aete!")) "tepnae E.EC (/M0IDCAMS)) SS(&IN2 DD SSOU2 0 34)) ddnae DD DSN0data"etnae5

    DIS(0 S6&) OLD7))SSIN DD 3

    IDCAMS coand)" coded $!eel8 bet%een 9 to :9 col";)3))

    Optionall8>>=2;LI#;?SDS;CLUS2E&5DIS(0S6&

    %he high-level qualifier is important !ecause in most installations this technique ensures that VSAM datasetsare cataloged in the appropriate user catalog

    Rules for Na($ng Cluster

    &an have 9 to 66 alphanumeric characters&an include the national characters , N, OSegmented 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 !elow7For(at4

    CLINDE&S,(!i Sec2&AC?S,(!i Sec

    99

  • 8/13/2019 45211518-VSAM

    12/37

    &ECO&DS,(!i Sec?ILO#2ES,(!i SecME/A#2ES,(!i Sec

    )rimary 7 um!er of units of primary space to allocate %his amount is allocated once when the dataset iscreatedSecondary 7 um!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 ofone cylinder usually yields !est performance %o ensure control area size of one cylinder you must allocatespace in &C(I#05S

    Allocating space ine 50&'5#S must !e avoided as this might result in an inefficient &ontrol Area size

    T&e VO%UMS para(eter

    %his V'(8M0S parameter assigns one or more storage volumes to your dataset Multiple volumesmust !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,#S>11VOLUMES,#S>11 #S>=> #S>=9

    Cou can store the data and index .in case of 4S#S clusters1 on separate volumes as this may provide aperformance advantage for large datasetT&e Re"ords$5e para(eter

    %his parameter tells VSAM what size records to expect %he avg and max are average and maximumvalues for varia!le length record If records are of fixed length, avgand max should !e the sameFor(at4

    &ECO&DSIE,av' axavg 7 Average length of recordsmax 7 Maximum length of recordse;'; G> 4Fixed Len'tH !eco!d"7&ECO&DSIE,G> 19> 4Va!iable Len'tH !eco!d"7

    50&'5#SI0 can !e assigned at the cluster or data level

    Note 4

    %his is an optional parameter, if omitted default is 50&'5#SI0.6J>H 6J>H1

    T&e S/ANND para(eter

    %his parameter allows large record to span more than one control interval Eowever records cannot span &ontrolAreas %he resulting free space in the spanned control interval is unusa!le !y other records, even if they fitlogically in the unused !ytes P'S)A0# is the defaultQ / it means that records cannot span controlintervals

    T&e DATAST6T2/ para(eter

    %his parameter specifies whether the dataset isINDE.ED,?SDS5NONINDE.ED,ESDS5 o! NUM#E&ED,&&DS;

    For(at< INDE.ED NONINDE.ED NUM#E&ED

    I#0?0# 7- Specifies a 4S#S and is the default'I#0?0# 7- Specifies an 0S#S o index is created and records are accessed sequentially or

    !y relative !yte address8MB050# 7- Specifies an 55#S

    9$

  • 8/13/2019 45211518-VSAM

    13/37

    (I0A5 7- Specifies a (I0A5 dataset

    %he default dataset %ype is INDE.ED;

    ))DA>>>12A +O# LA9:1J5 (CS5MS/LEVEL0,1515)) M/CLASS0A5NO2IF0DA>>>12)) 3 Delete)De$ine Clu"te! $o! ESDS VSAM Data"et

    ))S2E(1 E.EC (/M0IDCAMS)) SS(&IN2 DD SSOU2 0 3)) SSIN DD 3

    DELE2E DA>>>12;LI#;ESDS;CLUS2E&

    DEFINE CLUS2E& -,NAME,DA>>>12;LI#;ESDS;CLUS2E& -NONINDE.ED -&ECO&DSIE,19@ 19@ -&ECO&DS,1>> 1> -NONS(ANNED -VOLUMES ,#S>1 -

    &EUSE - -DA2A,NAME,DA>>>12;LI#;ESDS;DA2A

    Exaple =;= +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, I#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 isoptional for 0S#S and 55#S datasets Cou should code the AM0 parameter of #A%A for 4S#S datasets, inorder to operate on the data component !y itself

    For(at :DA2A,NAME,datanae (a!aete!"dataname 7- %he name you choose to name the data component

    T&e IND para(eter

    %he I#0? parameter creates a separate index component

    For(at 4

    INDE.,NAME,indexnae (a!aete!"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 I#0? parameters, you usually coda a AM0 parameter for them If you omitthe AM0 parameter for #A%A and I#0? , VSAM appends #A%A or I#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 "eys displacement .in !ytes1 from the !eginning of the record

    For(at 4

    ?ES,len'tH o$$"etlength 7 length in !ytes of the primary "eyoffset 7 'ffset in !ytes of the primary "ey with records ,> to n

    9

  • 8/13/2019 45211518-VSAM

    14/37

    ,a(ple 4

    ?ES,G >VSAM records !egin in position zero

    Note :

    Default is !"S#$% &' (ey is in bytes ) t*ru $+,

    ))DA>>>12A +O# LA9:1J5 (CS5MS/LEVEL0,1515)) M/CLASS0A5NO2IF0DA>>>12)) elete!efine "luster for #SS VSAM ataset))3))S2E(1 E.EC (/M0IDCAMS)) SS(&IN2 DD SSOU203)) SSIN DD 3

    DELE2EDA>>>12;LI#;?SDS;CLUS2E& DEFINE CLUS2E&, NAME,DA>>>12;LI#;?SDS;CLUS2E& - INDE.ED - ?ES,= > - FS(C,1> 9> - &ECO&DSIE,19@ 19@ - &ECO&DS,1>> 1> -

    NONS(ANNED - VOLUMES ,#S>1 - NO&EUSE - -DA2A,NAME,DA>>>12;LI#;?SDS;DA2A INDE.,NAME,DA>>>12;LI#;?SDS;INDE.)3

    Exaple =;@ +CL $o! De$inin' a ?SDS Clu"te!

    T&e FRS/AC para(eter

    %his 3500S)A&0 parameter, which applies to the 4S#S, allocates some percentage of control interval andcontrol area for planned free space %his free space can !e used for adding new records or for expandingexisting varia!le records 3500S)A&0 applies only to the data component

    For(atJNote :If omitted -SA calculates CIS/ based on record si0e.

    Re(ar; 4 &ontrol Interval is VSAMs equivalent of a !loc" and it is the unit of data that is actually transmittedwhen records are read or written

    )u$del$nes for deter($n$ng t&e CIS:

    0S#S is processed sequentially, so the &IS should !e relatively large, depending on the size of the record 3orsequential processing with larger records you may choose a &IS of >"

    3or datasets processed randomly as well as sequentially .for !ac"up at night1 choose a &IS for randomprocessing and then allocate extra !uffers for sequential processing with the AM) 2&( parameter

    55#S is usually processed randomly, so the &IS should !e relatively small, depending on the size of the

    record

    S

  • 8/13/2019 45211518-VSAM

    16/37

    0%5I0S .0%1 requires you to specify each level of qualification, either explicitly or implicitly, using anasteris" as a wild card character

    ,a(ples4

    LIS2CA2EN2,DA>>>12;VSAM;?SDS;CLUS2E& -

    CLUS2E& -ALL -

    Exaple @;1 LIS2CA2%he a!ove command will only display the !ase cluster

    LIS2CA2EN2,DA>>>12;VSAM;?SDS;CLUS2E& -

    DA2A -ALL -

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

    LIS2CA2EN2,DA>>>12;VSAM;?SDS;CLUS2E& -

    ALL

    %he a!ove command will display all catalog information

    ))S2E(1 E.EC (/M0IDCAMS))SS(&IN2 DD SSOU203))SSINDD 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 listevery 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 and4S#S in the third-level qualifier %hat is it would list #AJJJ9%AB&4S#S and #AJJJ9%%0S%4S#SAI?,

    #AJJJ9%%0S%4S#S#A%A

    9H

  • 8/13/2019 45211518-VSAM

    17/37

    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' information which shows twofields 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 %hisvalue reflects the total space allocation for the data componentEIDE-8S0#-5BA indicates the 5elative Byte Address.plus 91 of the last used data control area %his valuereflects 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 forthe clusterCou 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

    Figure 5.1 8-R9A and 8AR9A

    >. Creat$ng Alternate Inde,es

    An Alternate Index AI? provides a view of data different from the one offered !y the primary "ey 3orexample for a 4S#S dataset 0mployee, you may have a 5ecord 4ey index on 0mployee-no and an AlternateIndex on 0mployee-ame Cou can now !rowse and even update the same 4S#S in logical sequence !y0mployee-ame

    Alternate Indexes may !e defined on one or more than one Alternate 4ey.s1 ie 3ield.s1 other than primary "eyAlternate 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"e0mployees Social Security o %he records may !e accessed sequentially or randomly !ased on the alternaterecord "eys

    %hey can !e updated automatically when the !ase cluster is updated

    Alternate Indexes do not support a reusa!le !ase cluster So '508S0 which is the default, should !especified

    %oo many Alternate Indexes !uilt on a 4S#S may lead to performance #egradation as access !y alternate "eyrequires 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 records 5BA

    9;

    6AA

    6UA

    VSAM clu"te!

    Data "paceallocatedbut ept8

    Data "paceloaded %itH!eco!d"

  • 8/13/2019 45211518-VSAM

    18/37

    Steps for def$n$ng and *u$ld$ng alternate $nde,es4

    DFIN AI Co((and

    #efine the Alternate Index &luster using the I#&AMS #03I0 AI? command

    ))S2E(1 E.EC (/M0IDCAMS))SS(&IN2 DD SSOU2 03))SSIN DD 3

    DEFINE AI. -,NAME,DA>>>12;LI#;?SDS;AU26NAME;AI.

    -VOLUMES ,#S>1 -&ELA2E,DA>>>12;LI#;?SDS;CLUS2E&

    -U(/&ADE -2&AC?S,1> 1

    -?ES,9@ J -&ECO&DSIE,:> 11>F&EES(ACE,9> 1>

    -S6A&EO(2IONS,1 -NONUNIBUE?E -

    DA2A,NAME,DA>>>A12;LI#;?SDS;AU26NAME;DA2A -INDE.,NAME,DA>>>12;LI#;?SDS;AU26NAME;INDE.)3))

    Exaple ;1 +CL to de$ine AI.

    )athname is the dataset name in 2&( .#SL)A%EAM01

    R%AT /ara(eter

    For(at7&ELA2E,+ase cluster nae

    %his parameter esta!lishes the relationship !etween the !ase cluster and the alternate index via the use of thebase cluster name It is unique to the #03I0 AI? command, and it is required

    T&e RCORDSI: /ara(eter

    For(at7&ECO&DSIE,avg a#

    %his parameter specifies the average and maximum length of each alternate index record %here are two types ofalternate indexes

    #SDS un$!ue alternate $nde,7 Cou can create a unique alternate index !y specifying the 8IG8040Cparameter %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

    9>

    E'8S0400)ID Soc-Sec-o 0mp-o = : >

  • 8/13/2019 45211518-VSAM

    19/37

    Figure .1 Contents of !S"S uni%ue alternate inde#

    3or example if an unique alternate index on Soc-Sec-o is !uilt on our 4S#S cluster 0mployee then the

    50&'5#SI0 will !e calculated as follows7-

    = Bytes fro Eouse4eeping size of alternate "ey Size of )rimary 4ey that the alternate

    L = : > L $$

    %herefore recordsize parameter will !e coded as 50&'5#SI0.$J $J1

    4S#S non-unique alternate index7 An alternate index created with a '8IG8040C parameter has varia!lelength records %he 50&'5#SI0 is calculated as follows7-

    Avgerage 5ecord length L = !ytes for Eouse 4eeping size of the alternate "ey size of the primary "ey xaverage no of records the alternate index "ey can point to

    Maximum 5ecord length L = !ytes for Eouse 4eeping size of the alternate "ey size of the primary "ey xmaximum no of records the alternate index "ey can point to

    DFIN /AT< Co((and4

    #efine an Alternate Index )ath using the I#&AMS #03I0 )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 containany records %he path name is specified in the 2&( for applications that access records via the alternate index

    ))S2E(1 E.EC (/M0IDCAMS

    ))SS(&IN2 DD SSOU2 03))SSIN DD 3 DEFINE (A26 - NAME,DA>>>12;LI#;?SDS;AU26NAME;(A26 -

    (A26EN2&,DA>>>12;LI#;?SDS;AU26NAME;AI. -U(DA2E -

    )3))

    Exaple ;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 Insuch cases any changes made to data will !e reflected in the alternate index records if the 8)#A%0 option isspecified If '8)#A%0 is specified then the alternate index records will not !e automatically updated

    U/)RAD vs. NOU/)RAD

    %he 8)#A%0*'8)#A%0 option of #03I0 )A%E wor"s in tandem with the 8)D5A#0 * '8)D5A#0of the #03I0 AI? command

    8)D5A#0 specifies that any changes made in the !ase cluster records will !e reflected immediately in thealternate 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:

  • 8/13/2019 45211518-VSAM

    20/37

    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(#I#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 '8IG8040C option is specified then a merge operation ta"es place, which will merge allrecords with the same alternate "ey into a single record

    %hese records are the data component of the Alternate Index VSAM now constructs the indexcomponent @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))SS(&IN2 DD SSOU2 03))DD1 DD DSN0DA>>>12;LI#;?SDS;CLUS2E&5)) DIS(0OLD))IDCU21 DD UNI20SSDA5S(ACE0,2&?5 ,95 1))IDCU29 DD UNI20SSDA5S(ACE0,2&?5 ,95 1)) SSIN DD 3 #LDINDE. - INFILE,DD1 -

    OU2DA2ASE2,DA>>>12;LI#;?SDS;AU26NAME;AI. - IN2E&NALSO&2)3))

    Exaple ; +CL to build Alte!nate Index

    #isposition of !ase cluster is DIS/?O%Das the B(#I#0? needs a!solute control of the !ase cluster'utputdataset can !e Alternate index cluster or pathname

    %he I%05A(S'5% uses virtual storage whereas 0?%05A( S'5% uses dis" space I%05A(S'5% isthe default If you want an external sort to !e performed then include I#&8%9 and I#&8%$ ## statements inyour 2&( and specify 0?%05A(S'5% in the B(#I#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&,DA>>>12;LI#;?SDS;AU26NAME;AI.

    ;

    #LDINDE.INDA2ASE2,DA>>>12;LI#;?SDS;CLUS2E&OU2DA2ASE2,DA>>>12;LI#;?SDS;AU26NAME;AI.

    ;

    $J

  • 8/13/2019 45211518-VSAM

    21/37

    Exaple ;= 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 datasets50)5' command can operate on non-VSAM datasets It is an all-purpose load and !ac"up utility commandand can !e used in place of I0BD005

    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 508S0in the #03I0 &(8S%05 command

    Incase of 4S#S, data and index component are !uild automaticallyR/RO Co((and Synta,

    For(at 4

    &E(&O INFILE,ddnae INDA2ASE2,d"nae - OU2FILE,ddnae OU2DA2ASE2,d"nae -

    'ptional parameters are>>12;LI#;?SDS;#AC?U(,>5

    )) DIS(0OLD5 UNI202A(E5LA#EL0,15SL))SSIN DD 3

    $$

  • 8/13/2019 45211518-VSAM

    23/37

    DELE2E DA>>>12;LI#;?SDS;CLUS2E&)3 DEFINE CLUS2E& NAME,DA>>>12;LI#;?SDS;CLUS2E& -

    INDE.ED -?ES,= > -&ECO&DSIE,G> G> -VOLUMES,#S>1 - -

    DA2A,NAME,DA>>>12;LI#;?SDS;DA2A -INDE.,NAME,DA>>>12;LI#;?SDS;INDE.

    &E(&O -INFILE,DD1 -OU2DA2ASE2,DA>>>12;LI#;?SDS;CLUS2E&)3

    Exaple :; DELE2E-DEFINE-&E(&O

    Merg$ng datasets $t& R/RO

    %he 50)5' command can also !e used to merge two datasets into one %he target dataset can !e a nonempty4S#S, 0S#S or 55#S If the target dataset is an 0S#S, the merged records are added to the end of theexisting dataset

    /ORT3IM/ORT Co((ands

    %he 0?)'5%*IM)'5% commands can !e used for !ac"up and recovery Cou can export a dataset, alternateindex 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 cataloginformation

    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

    /ORT

    FORMAT 4

    E.(O&2 ent!8nae pa""%o!d

    OU2FILE,ddnae OU2DA2ASE2,d"nae

    '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

    $

  • 8/13/2019 45211518-VSAM

    24/37

    IM/ORT

    For(at 4

    IM(O&2 - INFILE,ddnae INDA2ASE2,d"nae - OU2FILE,ddnae OU2DA2ASE2,d"nae -

    'ptional parameters7

    IM(O&2 INFILE ,DD9 - OU2DA2ASE2,DA>>>12;LI#;?SDS;CLUS2E&

    Imports only 0?)'5%0# dataset

    ))DA>>>12A +O# LA19:J5(CS5MS/LEVEL0,1515)) MS/CLASS0A5 NO2IF0DA>>>12))3 Input in"t!ea Data into ESDS VSAM Data"et

    )) S2E(1 E.EC (/M0IDCAMS)) SS(&IN2 DD SSOU2 0 3)) DD1 DD 319=@:GJ19=@:GJAAAAAAAA######CCCC)3))DD9 DD DSN0DA>>>12;ESDS;CLUS2E&))SSIN DD 3

    &E(&O -INFILE,DD1 -OU2FILE,DD9

    )3))

    Exaple :;= Input in"t!ea Data into ESDS

    ))DA>>>12A +O# LA9:1J5(CS5MS/LEVEL0 ,1515)) MS/CLASS0A5 NO2IF0DA>>>12))3 Load Data $!o a $ile into ESDS VSAM Data"et))S2E(1 E.EC (/M0IDCAMS))SS(&IN2 DD SSOU2 0 3))DD1 DD DSN0DA>>>12;ESDS;CLUS2E&1))DD9 DD DSN0DA>>>12;ESDS;CLUS2E&9))SSIN DD 3

    &E(&O -INFILE,DD1 -

    OU2FILE,DD9)3))

    Exaple :;@ Load Data $!o a $ile into ESDS

    1-. VRIF2 B /RINTB D%TB A%TR Co((and

    VRIF2

    Ver$fy - preserves data integrity .E85BA1

    $6

  • 8/13/2019 45211518-VSAM

    25/37

    For(at 4

    VE&IF FILE,ddnae)pa""%do!

    VE&IF DA2ASE2,ent!8nae)pa""%dVE&IF ent!8nae)pa""%d ,2SO

    VE&IF DA2ASE2,DA>>>12;LI#;?SDS;CLUS2E&

    Exaple G;1 VE&IF

    Re(ar; 4

    V05I3C can !e issued from a %S' or within a 2&( statementIt is valid only for VSAM dataset except (#S

    D%T

    - logically deletes dataset- catalog entry deleted

    For(at 4

    DELE2E ent!8nae)pa""%d - optional pa!aete!"

    DELE2E DA>>>12;LI#;?SDS;CLUS2E& - E&ASE

    Exaple G;9 Deletin' a Clu"te!

    Opt$onal para(eters are 4

    AI.

    CLUS2E&

    NONVSAM

    (A26 E&ASE NOE&ASE

    FO&CE NOFO&CE

    (U&/E NO(U&/E

    SC&A2C6 NOSC&A2C6

    ))DA>>>12A +O# LA91:J5(CS5MS/LEVEL0,15 1 5)) NO2IF0DA>>>12))3 Delete" VSAM Data"et))S2E(1 E.EC (/M0IDCAMS))SS(&IN2 DD SSOU2 0 3))SSIN DD 3

    DELE2E DA>>>12;2&AIN;I2MFOIV

    )3

    Exaple G; Delete VSAM Data"et

    /RINT

    %he default output destination for )5I% is SCS)5I%prints in &EA5*E0?*#8M) formatlimiting

    For(at 1 4

    (&IN2 INDA2ASE2 ,ent!8nae)pa""%d -

    For(at ' 4

    (&IN2 INFILE ,ddnae)pa""%d -

    $=

  • 8/13/2019 45211518-VSAM

    26/37

    parameters li"e 50)5' are availa!le

    Opt$ons

    C6A& DUM( 6E.

    COUN2 ,nube!

    F&OMADD&ESS5 42OADD&ESS7

    F&OM?E5 42O?E7 F&OMNUM#E&5 42ONUM#E&7

    OU2FILE ,ddnae

    S?I( ,nube!

    ))DA>>>12A +O# LA91:J5(CS5MS/LEVEL0,15 1 5)) NO2IF0DA>>>12))3 (!int VSAM Data"et))(&/1 E.EC (/M0IDCAMS))FILE1 DD DSN0DA>>>12;LI#;?SDS;CLUS2E&5)) DIS(0S6&))SS(&IN2 DD SSOU2 0 3)) SSIN DD 3

    (&IN2 INFILE,FILE1 C6A&AC2E&)3))

    Exaple G;= (!int VSAM Data"et

    A%TR

    8sed to change certain attri!utes of a previously defined VSAM o!@ect3ollowing can !e done with A(%05change names

    Add volumes*5emove volumes

    &hange 4eys and uniqueness

    &hange record size

    &hange 8pgrade option

    &hange R of 3500S)A&0 etcFor(at :

    AL2E& ent!8nae)pa""%d pa!aete!"

    Opt$ons 4

    ADDVOLUMES ,volue"

    AU26O&IA2ION,ent!8 "t!in'

    #UFFE&S(ACE ,"iPe

    E&ASE NOE&ASE

    F&EES(ACE,ciK caK MAS2E&(,pa""%o!d

    NENAME,ne%nae

    &EAD( ,pa""%o!d

    SC&A2C6 NOSC&A2C6

    S6A&EO(2IONS

    ,c!o"" !e'ion c!o"" "8"te

    2O,date FO&,da8"

    U(DA2E NOU(DA2E

    U(DA2E(,pa""%o!d

    U(/&ADE NOU(/&ADE

    T&e ORDRD /ara(eter

    $H

  • 8/13/2019 45211518-VSAM

    27/37

    %he '5#050# )arameter tells VSAM to assign the 40C5AD0S values to the volumes, one !y one, in theorder in which the 40C5AD0S and V'(8M0S are specified

    For(at 4

    O&DE&ED UNO&DE&ED

    ,a(ple 4

    ?E&AN/ES, ,>>>1 1>>> - ,1>>1 9>>> -

    ,9>>1 >>> -VOLUMES ,#S>1 -

    #S>1= - #S>>1

    Note : 2*en you code 34D!4!D5 you must code t*e same no. of -367!S as !"4AN8!S.

    T&e IM0D /ara(eter

    %he IMB0# )arameter directs VSAM to place the sequence set on the first trac" of the #ata &ontrol Area andduplicate it as many times as it will fit

    Advantage 7 reduces rotational delayFor(at>>92;MAS2E&;DALIMI2,@SC&AC6EM(2

    )3

    Exaple J;9 De$inin' a /D/ Index

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

    ))DA>>>2A +O#!!$%A&' '('" %)M*%A+,..))OLDMAS2 DD DSN0MMA9;(A;MAS2,>5DIS(0OLD))NEMAS2 DD DSN0MMA9;(A;MAS2,15

    DIS(0 ,NE5CA2L/5UNI20>>5VOL0SE&0#S>>15DC#0,L&ECL0G>5#L?SIE01>>

    ))(A2&AN DD DSN0MMA9;(A;2&AN5DIS(0OLD))(ALIS2 DD SSOU203!!/'%0/& '('" %)M*%A+,,..))(AMAS2 DD DSN0MMA9;(A;MAS2,15DIS(0OLD

    ))(A&(2 DD SSOU203

    Exaple J;a Addin' data"et" to a /D/

    Follo%in' code contain" 9 *ob";;;;;;;;;

    !!1023 102))U(DA2E E.EC (/M0(A9>>))OLDMAS2 DD DSN0MMA9;(A;MAS2,>5DIS(0OLD))NEMAS2 DSN0MMA9;(A;MAS2,15

    DIS(0,NE5 CA2L/5 UNI20>>5 VOL0SE&0#S>>15

    DC#0,L&ECL0G>5 #L?SIE01>>

    ))(A2&AN DD DSN0MMA9;(A;2&AN5DIS(0OLD))(ALIS2 DD SSOU2 03

    !!102 102 44444444444))&E(O&2 E.EC (/M0(A>>))(AMAS2 DD DSN0MMA9;(A;MAS2,>5DIS(0OLD))(A&(2 DD SSOU203

    Exaple J;b Addin' data"et" to a /D/

    D#Ds are agroup of datasets which are related to each other chronologically and functionallyDenerations can continue until a specified limit is reached %he (IMI% parameterspecifies total num!er of generations that can exist at any one time'nce limit is reached the oldest generation is deleted

  • 8/13/2019 45211518-VSAM

    31/37

    D#D Indexhave to !e created using the I#&AMS command +#03I0 D#D !efore datasets that are to !e included inthem can !e made a part of themModel containing parameter information of the datasets to !e included in the D#D has to !e specifiedAll datasets within a D#D will have the same name Deneration num!er of a dataset, within a D#D isautomatically 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 index8se I#&AMS statement #03I0 D#D for creating Index)arameters for creating index

    Spe"$f$"at$on

    ame of D#Dum!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 refers to the name of the D#D Index

    LIMI2 ;; refers to the maximum no of datasets in a D#D

    NOEM(2EM(2 SC&A2C6 ;NOSC&A2C6

    Mod$fy$ng Features of )D)

    Cou can modify a D#D only with the A(%05 command

    ))S2E(1 E.EC (/M0IDCAMS))SSINDD

    AL2E& DA>>>12;ACCOUN2S;MON26L -NOSC&A2C6 -EM(2

    )3))

    Exaple J;= Modi$8in' a /D/

    Delet$ng )D) Inde,

    &an !e deleted !y the #0(0%0 parameter of I#&AMSFill result in an error on reference to any generation datasets of the D#D

  • 8/13/2019 45211518-VSAM

    32/37

    )S2E(1 E.EC (/M0IDCAMS))SSINDD

    DELE2E DA>>>12;ACCOUN2S;MON26L /D/)3))

    Exaple J;@ Deletin' /D/ Index

    Add$ng a Dataset to a )D)

    ame of the model containing the D#D #&B parameters is coded in the #&B parameter of the ## statement

    ))S2E(1 E.EC (/M0/D/1))FILE1 DD)) DSN0DA>>>12;ACCOUN2S;MON26L,15)) DIS(0,NE5CA2L/5DELE2E5UNI20SSDA5)) S(ACE0,2&?5,>51>5&LSE5)) DC#0,MODEL;DC#5)) &ECFM0F#5L&ECL0G>5

    )) #L?SIE0G>>Exaple J; 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))SSINDD

    DELE2E DA>>>12;ACCOUN2S;MON26LT -/D/ -FO&CE

    )3))

    Exaple J;: Deletin' /D/ Index and Data"et"

    1>. CO0O% VSAM Cons$derat$ons

    SELEC2 CLAUSE

    SELEC2 $ile ASSI/N 2O DDNAME ) AS-DDNAME

    O&/ANIA2ION IS SEBUEN2IAL)INDE.ED)&ELA2IVEACCESS MODE IS SEBUEN2IAL)INDE.ED)DNAMIC&ECO&D ?E IS p!ia!8 ?e8 DatanaeAL2E&NA2E ?E IS Alte!nate ?e8 Datanae 4itH Duplicate"7FILE S2A2US IS "tatu"-e8;

    Exaple 1>;1 SELEC2 clau"e $o! VSAM data"et"status "eyL&o!ol, VSAM

    x.$1 :.$1 - 5eturn code:.91 - 2unction code:.

  • 8/13/2019 45211518-VSAM

    33/37

    FD ntry

    Should have the record structure

    If 4S#S then "ey field must match with length and position of 40CS parameter in #03I0 &(8S%05information

    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 pathname

    Note: 1*ere is no C3936 standard for assigning ddnames to alternate indexes5 so a quasistandard *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&

    Exaple 1>;9 +CL to acce"" AI.

    Re(ar;4

    o matter how many alternate indexes you specify in the program, theres only one ASSID clause pointing tothe ddname of the !ase cluster

    SELEC2 $ile ASSI/N 2O LI#MAS2

    &ECO&D ?E IS ;;;;;;;;;;;;AL2E&NA2E ?E IS ;;;;;;;;;

    4I26 DU(LICA2ES7

    Exaple 1>; 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# filename40C IS primary*alternate "eydataname

    #ey of Referen"e.

    %he "ey that is currently !eing used to access records is called the "ey of reference Fhen the program opensthe dataset, the primary "ey !ecomes, !y default, the "ey of reference %he primary "ey remains the "ey ofreference when accessing records until it is changed %o start accessing records !y an alternate index "ey, youmerely 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 ?E IS EM(-NAME

    Exaple 1>;= &EADA sequential 50A# statement, for example

    &EAD EM(-MAS2 NE.2

    ?E IS EM(-NAMEA

  • 8/13/2019 45211518-VSAM

    34/37

    Exaple 1>;@ &EAD $o! Acce""in' AI.S%A5% statement, for example

    S2A&2 EM(-MAS2?E IS EBUAL 2O EM(-NAME;

    Exaple 1>; S2A&2 ve!b

    ;ey61 ;ey6' Cause

    Successful &ompletion7J J o further information,

    $ #uplicate "ey detected 6 Frong fixed-length record

    = #ata set created when penedFithsequential VSAM datasets,J is returned

    ; &('S0 with ' 50FI# or 500(, for non-tape

    0nd-of-file9 J o further information 6 5elative record 50A# outside

    dataset !oundary

    Invalid "ey$ 9 Sequence error

    $ #uplicate "ey< o record found6 4ey outside !oundary of dataset

    )ermanent I*' error 7< J o further information

    6 5ecord outside dataset !oundary= ')0 and required dataset not found; ')0 with invalid mode

    > ')0 of dataset closed with ('&4: ')0 unsuccessful !ecause of

    conflicting dataset attri!utes

    (ogic error 76 9 ')0 of dataset already open

    $ &('S0 for dataset not open< 50A# not executed !efore 50F5I%06 50F5I%0 of different-record sizeH 50A# after 0'3 reached; 50A# attempted for dataset not opened I-'

    or I)8%> F5I%0 for dataset not opened '8%)8%,I-'

    or 0?%0#: #0(0%0 or 50F5I%0 for dataset not opened I-'

    Specific compiler-defined conditions 7: J o further information

    9 VSAM password failure$ (ogic error< VSAM resource not availa!le6 VSAM sequential record not availa!le= VSAM invalid or incomplete dataset information

    : H VSAM-no ## statement; VSAM ')0 successful#ataset integrity verified

  • 8/13/2019 45211518-VSAM

    35/37

    VSAM I*' error processing

    I*' error handling is one vital area where VSAM dataset processing differs from non-VSAM dataset processingFhen 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 ot so when processingVSAM 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 tochec" 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 aninformative message and continue processing3or these status "ey values, continue processing normally 7

    JJ successful I*'J$ duplicate alternate "ey encountered .expected19J 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 out-of-space condition .4S#S or 55#S1

  • 8/13/2019 45211518-VSAM

    36/37

    c )opulate the 4S#S cluster !y using a &'B'( program 8sing (IS%&A% command list the attri!utesof the created cluster

    d Frite a program to populate an indexed master file from transaction records %here are three datasets

    )5'#8&%-MAS%05 5ecord (ayout

    9 = H 9J

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

    9 = H $= $H $> $:

  • 8/13/2019 45211518-VSAM

    37/37

    9 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

    Gty$: