full details on vsam datasets

Upload: knpunith

Post on 04-Jun-2018

235 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Full details on VSAM datasets

    1/28

    Mainframe Refresher Part-1 VSAM-Page:1

    VSAM (Virtual Storage Access Method)

    HistoryAccess Method is an interface beteen the a!!lication !rogram and !hysical

    o!eration of storage de"ices# $t is a com!onent of o!erating system# VSAM is thefirst access method that efficiently uses the "irtual storage of MVS# $t can mani!ulate

    only the data that resides on a %AS%# (%irect access storage de"ice)

    $&M introduced VSAM in 1' as a re!lacement for se"eral e*isting access

    methods designed by it earlier#

    +S%S (+ey Se,uenced %ata Set) re!laced $SAM ($nde*ed Se,uential Access Method)RR%S (Relati"e Record %ata Set) re!laced &%AM (&asic %irect Access Method)

    S%S (ntry Se,uence %ata Set) !ro"ide same function as normal se,uential .SAM#(.ueued Se,uential Access Method)#

    $nitially VSAM had only S%S and +S%S# RR%S and Alternate $nde* to +S%S

    are introduced in 1''# %/0 / (%ata /acility e*tended /unction) VSAM as

    introduced in 1'' ith $ntegrated atalog /acility ($/) to re!lace the old VSAMcatalog of the !re"ious "ersions#

    2he latest "ersion of %/P0 VSAM released in 1''1 called %/P0VSAM #contains enhancements li3e "ariable record length su!!ort for RR%S and added

    %/SMS facilities#

    Ad"antages of VSAM o"er other access methods

    1#%ata retrie"al ill be faster because of an efficiently organi4ed inde*# 2he inde* issmall because it uses a 3ey com!ression algorithm#

    5#$nsertion of records is easy due to embedded free s!ace in the cluster#

    #Records can be !hysically deleted and the s!aces used by them can be used for

    storing other records ithout reorgani4ation#6#VSAM datasets can be shared across the regions and systems#

    7#%atasets can be !hysically distributed o"er "arious "olumes based on 3ey ranges#8#VSAM is inde!endent of storage de"ice ty!es#

    #$nformation about VSAM datasets is centrally stored in VSAM catalog#So referencing of any VSAM dataset need not be detailed in 9#

    %isad"antages of VSAM

    1#2o allo easy mani!ulation of records; free s!ace should be left in the dataset andthis increases the s!aces re,uired#

    5#$ntegrity of the dataset across the region and system need to be controlled byuser#

  • 8/13/2019 Full details on VSAM datasets

    2/28

    Mainframe Refresher Part-1 VSAM-Page:5

    Record %efinition /ield > bytes field# /or fi*ed length records; thereill be 5 R%/; first contains the number of records in the control inter"al and

    the second contains record length# /or "ariable length records; the number ofR%/ can "ary de!ending on ho many ad@acent records ha"e the same length

    in the $# $f no to ad@acent records are of the same length; then one R%/ is

    needed to describe each record#

    $nde* om!onent (Se,uence Set and $nde* Set)&esides the data com!onent; VSAM creates an inde* com!onent# $nde*

    com!onent consists of inde* set and se,uence set# 2he se,uence set is the loest

    le"el of the inde* is called the se,uence set and it contains !rimary 3eys and!ointers to the control inter"als of the data com!onent#

    2here is one se,uence set for one control area# 2he highest record 3ey ofe"ery control inter"al is stored in se,uence set# 2he highest record 3ey of the

    se,uence set is stored in first le"el of inde* set# &ased on the si4e of control inter"alof inde* com!onent; there ill be 1- le"els of inde* sets in the inde* com!onent of

    the dataset#

  • 8/13/2019 Full details on VSAM datasets

    3/28

    Mainframe Refresher Part-1 VSAM-Page:

    ontrol $nter"al and ontrol Area S!lit

    hen a VSAM dataset is created; the free s!ace !arameter defined can

    s!ecify a !ercentage of control inter"als to be left free during the load of VSAM file#ater; hen you add a record to the VSAM file; according to the 3ey se,uence; it is

    !laced in a s!ecific control inter"al#&ut if the s!ecific control inter"al is already full; then this cannot be !laced in

    the se,uence# 2he result is ontrol $nter"al s!lit# $t mo"es half of the records in thefilled control inter"al to any other free control inter"al a"ailable in the control areaand ma3es room for the ne record in the right !lace#

    $f there is no free control inter"al e*ist in the control area; then half thecontrol inter"als are mo"ed to ne control area and this is called control area s!lit#

    *am!le

    1# $n the e*am!le belo; there are four control areas and e"ery control area containsto control inter"als# ontrol fields are not shon in the diagram# 2here should be

    one se,uence for e"ery control area# So there are four se,uence sets# 2here are tole"els of inde* set# 2he second le"el of inde* set contains !ointers to se,uence set#

    5# ontrol $nter"al S!lit: hen a record ith 3ey 55 is added in the !rogram; itshould !hysically be stored beteen the e*isting records 51 and 5# 51 and 5 are inthe first control inter"al of control area-# 2here is no more s!ace a"ailable to store

    this record# So control s!lit ill occurs# Record 5B and 51 continue to e*ist in thecurrent control inter"al# Records 55 and 5 ill be mo"ed to any of the free control

    inter"als# $n our case control inter"al 5 is free# So they are mo"ed there and inde*set is accordingly u!dated#

    # ontrol Area S!lit: hen a record ith 3ey in the !rogram; it should be !laced

    beteen 5 and 6# 2hese records are in first control inter"al of first control area andthere is no free s!ace# So control inter"al s!lit is e*!ected# &ut there is no free

    control inter"al in the control area-1# So control area s!lit occur# Ce control area is

    allocated and half the records of control area-1 ill be mo"ed there and inde*es are

    !ro!erly u!dated#

    Ho inde* could ma3e the access fasterD$ faced an interesting ,uestion in an inter"ie# 2he ,uestion follos:

    My se,uential file has 7B records# 2o get the 7Bthrecord; $ ha"e to read 6'data records and by!ass# $nde*es store !rimary 3eys ith actual location# So to read

    7Bthrecord using inde*ed organi4ation; $ ha"e to get the location of 7Bthrecord frominde*# So $ ha"e to read and by!ass the location of 6' records# 2he only difference is

    in the second case is $ am doing se,uential read in inde* set instead of dataset# Hodo you say my inde* access ould be fasterD

    2o anser this ,uestion; you should 3no ho inde*es are organi4ed and

    read# e ha"e already seen ho they are organi4ed# $n the e*am!le belo; to readthe 7Bthrecord; first root inde* is read and identified that the record should be in the

    right hand side# $n the second $-?; $ ill get the se,uence and in third $-?; $ ill getthe location of the record# $ ill get my record in the fourth $-? instead 71 $-?# (7B

    $? in inde* and 1 $-? for getting the data)

    $f $ am accessing the first record; then se,uential read needs only one $-? butob"iously my random read needs more# So e !refer inde*ed organi4ation only hen

    the number of records is significant#

  • 8/13/2019 Full details on VSAM datasets

    4/28

    Mainframe Refresher Part-1 VSAM-Page:6

    Root $nde*

    /irst e"el $nde*

    Se,uence set

    %ata om!onent

    A-1 A-5 A- A-6

    Pro!erties of VSAM datasets

    Pro!erties of S%S; +S%S and RR%S are listed a tabular format in the ne*t!age# 2hough the table says RR%S records should be of fi*ed length; MVS0%/P VSAM

    Version # allos "ariable length RR%S# VSAM internally im!lements it using +S%S#

    VSAM %S Pro!erties: inear datasets ha"e no records# 2hey are @ust long strings ofbytes# Since it is a long string of bytes an %S has no /SP;

  • 8/13/2019 Full details on VSAM datasets

    5/28

    Mainframe Refresher Part-1 VSAM-Page:7

    om!arison of S%S; +S%S and RR%S

    haracteristics S%S +S%S RR%S

    ntry Se,uence &ased on entry

    se,uence

    &ased on collating

    se,uence by 3ey

    field

    &ased on relati"e

    record number

    orderAccess ?nly Se,uential

    access is !ossible#Se,uential andrandom access is

    !ossible# Randomaccess is thru

    !rimary0alternate3ey#

    an be accesseddirectly using

    relati"e recordnumber; hich

    ser"es as address#

    Alternate $C% May ha"e one or morealternate inde*es# &ut

    cannot be used in&A2H ?&?# an

    be used in $S

    ?&?#

    May ha"e one ormore alternate

    inde*es#

    Cot a!!licable

    ocation of the

    record

    A record R&A cannot

    be changed

    A record R&A can

    be changed#

    A relati"e record

    number can bechanged#

    /ree S!ace *ist at the end of the

    dataset to addrecords#

    %istributed free

    s!ace for insertingrecords in beteen

    or change thelength of e*isting

    record#

    /ree slots are

    a"ailable for addingrecords at their

    location#

    %eletion annot be deleted#

    RR$2 of samelength is !ossible#

    %2 is !ossible# %2 is !ossible#

    Record Si4e /i*ed or Variable /i*ed or Variable /i*ed#

    SPACC%

    records

    Possible Possible Cot !ossible

    S!eciality ?ccu!ies less S!ace asy RAC%?Maccess and most

    !o!ular method

    /astest accessmethod#

    Preference A!!lication thatre,uire se,uential

    access only#*: PAIR?

    PR?SS$CJ#

    A!!lications thatre,uire each record

    to ha"e a 3ey fieldand re,uire both

    direct and

    se,uential access#

    *: &an3inga!!lication

    A!!lications thatre,uire only direct

    access# 2hereshould be a field in

    the record that can

    be easily ma!!ed

    to RRC#

  • 8/13/2019 Full details on VSAM datasets

    6/28

  • 8/13/2019 Full details on VSAM datasets

    7/28

    Mainframe Refresher Part-1 VSAM-Page:

    %/$C

  • 8/13/2019 Full details on VSAM datasets

    8/28

    Mainframe Refresher Part-1 VSAM-Page:G

    %/$C

  • 8/13/2019 Full details on VSAM datasets

    9/28

    Mainframe Refresher Part-1 VSAM-Page:'

    &est control inter"al si4e selection

    /or se,uential !rocessing of a +S%S; a relati"ely large $SE ill reduce!hysical $0? by 3ee!ing more records accessible in the buffers# ?n the other hand;

    for random !rocessing of a +S%S a smaller $SE ould re,uire lesser data transfertime and feer buffers; thus ma3ing $0? faster#

    /or an S%S (since it is !rocessed se,uentially) the $SE should be relati"ely largede!ending on the si4e of the record#

    Since an RR%S is !rocessed randomly the $SE should be relati"ely small#

    2he /RSPA Parameter (/SP)

    2he /RSPA !arameter is a!!licable to the +S%S and the "ariable-lengthRR%S only# /RSPA cannot be assigned to an S%S because all ne records are

    added to the end of the dataset#2his !arameter allocates some !ercentage of both the $ and A for !lanned

    free s!ace; hich can be used for adding ne records or e*!anding e*isting "ariable

    records# 2he !arameter is coded as follos

    /RSPA(ciN caN)

    /RSPA(ciN ) control inter"al only/RSPA(B caN) control area only

    /RSPA(B B) is the default#/RSPA(1BB 1BB) means only one record ill be loaded in e"ery control inter"al

    and only one control inter"al ill be loaded in e"ery control area#

    $n order to effecti"ely allocate /RSPA the folloing factors ha"e to be ta3en intoconsideration#

    1# 2he e*!ected rate of groth: $f e"en groth is e*!ected a!!ly /RSPA to both

    $ and A# $f une"en groth is e*!ected a!!ly /RSPA only to the A#5# 2he e*!ected number of records to be deleted#

    # Ho often the dataset ill be reorgani4ed ith RPR?#6# 2he !erformance re,uirements#

    2he $ /RSPA allocation should be enough to co"er the length of one

    record !lus any additional R%/s that may result from a "ariable record length#

    %/$C

  • 8/13/2019 Full details on VSAM datasets

    10/28

    Mainframe Refresher Part-1 VSAM-Page:1B

    2he &

  • 8/13/2019 Full details on VSAM datasets

    11/28

    Mainframe Refresher Part-1 VSAM-Page:11

    %/$C

  • 8/13/2019 Full details on VSAM datasets

    12/28

    Mainframe Refresher Part-1 VSAM-Page:15

    %/$C

  • 8/13/2019 Full details on VSAM datasets

    13/28

    Mainframe Refresher Part-1 VSAM-Page:1

    About A2A?J !arameterMost of the AMS commands !ro"ide A2A?J o!tion# $f the command is

    %/$C; then the dataset being defined ill be !laced in the catalog; mentioned inthe A2A?J !arameter# Similarly hile accessing the dataset;

    1# 2he dataset is first searched in the catalog mentioned in A2A?J !arameter#5# $f A2A?J is not coded; then the dataset is searched into the catalog coded inS2PA2 or 9?&A2 catalog#

    # $f there is no S2PA2 and 9?&A2; then the dataset is searched in the usercatalog corres!onding to the high le"el ,ualifier of the dataset#

    6# $f there is no user catalog found; then the dataset is loo3ed into system catalog#7# $f the dataset is not listed in system catalog also; then you ill get the error

    message of dataset not found#2here ill be one master catalog and n number of user catalogs in the

    system# "ery user catalog should ha"e an entry in master catalog#

    +S%S-S%S-RR%S-%S Sam!le %efinitions

    KSDS Definition//KSDSMAKE EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=A

    //SYSIN DD*

    DEFINE CLUSTER -

    (NAME(EMPLOYEEKSDSCLUSTER! - "OLUMES("SAM#$! -

    CYLINDERS($%&! -

    CONTROL INTER"AL SI'E(#)! -

    FREESPACE(10,20) -

    KEYS(9,0) - RECORDSI'E(+#%+#!! -

    DATA -

    (NAME(EMPLOYEEKSDSDATA!! -

    INDEX - (NAME(EMPLOYEEKSDSINDEX!! - CONTROL INTER"AL SI'E($! -

    CATALOG("SAMUSERCATT,O!

    /*

    ESDS Definition//ESDSMAKE EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=A

    //SYSIN DD*

    DEFINE CLUSTER -

    (NAME (EMPLOYEEESDSCLUSTER! - "OLUMES ("SAM#$! -

    CYLINDERS ($%&! -

    CONTROLINTER"ALSI'E (#)! -

    RECORDSI'E (+#%+#! -

    NONINDEXED! -DATA -

    (NAME (EMPLOYEEKSDSDATA!! -

    CATALOG ("SAMUSERCATT,O!

    /*

    RRDS Definition

    //RRDSMAKE EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=A

    //SYSIN DD*

    DEFINE CLUSTER -(NAME(EMPLOYEERRDSCLUSTER! -

    "OLUMES("SAM#$! -

    CYLINDERS($%&! -

    CONTROL INTER"AL SI'E(#)! -

    RECORDSI'E(+#%+#! - NUMBERED! -

    DATA -

    (NAME(EMPLOYEEKSDSDATA!! -

    CATALOG("SAMUSERCATT,O!

    /*

    LDS Definition

    //LDSMAKE EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=A

    //SYSIN DD*

    DEFINE CLUSTER -(NAME(EMPLOYEERRDSCLUSTER! -

    "OLUMES("SAM#$! -

    CYLINDERS($%&! -

    LINEAR! -

    DATA -(NAME(EMPLOYEEKSDSDATA!! -

    CATALOG("SAMUSERCATT,O!

    /*

  • 8/13/2019 Full details on VSAM datasets

    14/28

    Mainframe Refresher Part-1 VSAM-Page:16

    $%AMS - RPR? command$t is the general-!ur!ose command that can o!erate on both VSAM and non-

    VSAM datasets# $t !erforms three basic functions:1# $t loads an em!ty VSAM cluster ith records# 2he data and inde* com!onents for

    +S%S are built automatically#5# $t creates a bac3u! of a VSAM dataset on a !hysical se,uential dataset and laterit can be used for restore0rebuild the VSAM dataset#

    # $t merges data from to VSAM datasets#

    ommand Synta*RPR? -

    $C/$(%%CAM) Q $C%A2AS2(%A2AS2-CAM) -?

  • 8/13/2019 Full details on VSAM datasets

    15/28

    Mainframe Refresher Part-1 VSAM-Page:17

    $%AMS - PR$C2 ommand$t is used to !rint the contents of a dataset# 2he out!ut can be made a"ailable

    in "arious formats# 2his section deals ith the PR$C2 command and its "ariousmutually e*clusi"e o!tions#

    PR$C2 $C%A2AS2(data set-name) Q $C/$(dd-name)o!tions

    PR$C2 - HAR0 H0%

  • 8/13/2019 Full details on VSAM datasets

    16/28

    Mainframe Refresher Part-1 VSAM-Page:18

    $%AMS - %2 ommand2he %2 command can be used to delete both VSAM and non-VSAM

    ob@ects#Synta*: %2 C2RI CAM ?&92 o!tional-!arameters

    ?&92-

  • 8/13/2019 Full details on VSAM datasets

    17/28

  • 8/13/2019 Full details on VSAM datasets

    18/28

    Mainframe Refresher Part-1 VSAM-Page:1G

    $%AMS - P?R2 and $MP?R2 commands

    2he P?R2 0 $MP?R2 commands can be used for1# &ac3u! and reco"ery#

    5# *!orting a dataset; an alternate inde* or a catalog to a different (butcom!atible) system#

    Ad"antages o"er RPR?1# atalog information is e*!orted along ith the data#

    5# luster deletion and redefinition are not necessary during the im!ort ste!because in!ut dataset already contains catalog information#

    # Also since the dataset contains catalog information it can be easily !ortedto other systems# An e*!orted dataset has cross-system !ortability#

    &ut P?R2 0 $MP?R2 can be used ith VSAM datasets only and the datasetcreated by P?R2 can ha"e only a se,uential organi4ation# 2he dataset created by

    the P?R2 ste! is not !rocess-able until it has gone through a corres!onding

    $MP?R2 ste!# 2hus !erforming an P?R20$MP?R2 ta3es u! more time#

    Synta*: P?R2 entry-name ?

  • 8/13/2019 Full details on VSAM datasets

    19/28

    Mainframe Refresher Part-1 VSAM-Page:1'

    P?R2 - RASQC?RAS

    2his s!ecifies hether the data com!onent of the cluster or alternate inde* tobe e*!orted is to be erased or not (o"erritten ith binary 4eros)#

    ith RAS s!ecification; the data com!onent is o"erritten ith binary 4eroshen the cluster or alternate inde* is deleted#

    ith C?RAS s!ecification; the data com!onent is not o"erritten ith

    binary 4eros hen the cluster or alternate inde* is deleted#

    *am!le:00P?R2 PJMK$%AMS

    00%%5 %% %SCKSMSG8#$+S%S#&A+

  • 8/13/2019 Full details on VSAM datasets

    20/28

  • 8/13/2019 Full details on VSAM datasets

    21/28

  • 8/13/2019 Full details on VSAM datasets

    22/28

    Mainframe Refresher Part-1 VSAM-Page:55

    1# +S%S dataset is currently accessed using a !rimary 3ey# e ant to access

    the dataset RAC%?MI ith another 3ey#

    5# e ant to access S%S file RAC%?MI based on 3ey#

    Ste!s $n"ol"ed

    Ste!1# %efine A$#%/$C A2RCA2$C% command defines an alternate inde*# $m!ortant

    !arameters of this command are:

    Parameter Meaning

    RA2 Relates A$ ith base cluster

    C?C

  • 8/13/2019 Full details on VSAM datasets

    23/28

    Mainframe Refresher Part-1 VSAM-Page:5

    $m!ortant !arameters of this command are:

    1# $C/$ and ?

  • 8/13/2019 Full details on VSAM datasets

    24/28

  • 8/13/2019 Full details on VSAM datasets

    25/28

    Mainframe Refresher Part-1 VSAM-Page:57

    AMP is most often used to allocate $0? buffers for the inde* and data com!onents for

    o!timi4ing !erformance#

    Synta*: AMPK(sub !arameter; sub !arameter;)

    orAMPK(sub !arameter; sub !arameter;)

    Single a!ostro!hes are re,uired if the sub !arameter(s) contain s!ecial characters#

    AM?RJ

    2his !arameter; hich stands for Access Method ?RJani4ation; indicates thatthe !articular %% statement refers to a VSAM dataset#

    &

  • 8/13/2019 Full details on VSAM datasets

    26/28

    Mainframe Refresher Part-1 VSAM-Page:58

    00 RK1BB;+I?//K1B;+ICK15;R?RJK+S

    R?RJ can also be S(for ntry Se,uenced %atasets); RR(for Relati"e Recorddatasets) and S(for inear %atasets)# ?ther !arameters of %/$C

  • 8/13/2019 Full details on VSAM datasets

    27/28

    Mainframe Refresher Part-1 VSAM-Page:5

    C?2S

  • 8/13/2019 Full details on VSAM datasets

    28/28

    Mainframe Refresher Part-1 VSAM-Page:5G

    C?2S