51214566 VSAM Handout

Embed Size (px)

Citation preview

  • 7/27/2019 51214566 VSAM Handout

    1/60

    Mainframe VSAM

    CHAPTER - 1: Introduction to VSAM

    Virtual Storage Access Method - VSAM - is a data management systemintroduced by IBM in the 1970s as part of the OS/VS1 and OS/VS2 operating

    systems. Although there are still datasets that are best managed with the severalother (non-VSAM) data management methods, VSAM is a major component of

    modern IBM operating systems. VSAM is a high performance access method used toorganize data and to maintain information about that data in an index or library

    called a catalog.

    VSAM acts as interface between Operating System and Application Program.VSAM is an access method used to organize data and maintain information about the

    data in a catalog.

    All VSAM data sets reside on DASD Devices and must be defined in a catalog.

    There are two major parts to VSAM:

    Catalog management

    Record management

    Catalog Management

    The catalog contains information about the VSAM data sets. The catalog canbe an ICF Catalog or a VSAM catalog (older versions of the operating

    system). DFSMS/MVS deals only with ICF catalogs.

    All VSAM data set information is maintained in the ICF catalog and it can be

    easily retrieved using AMS commands (Access Method Services).

    Record management

    The purpose of record management is to maintain records in a VSAM data set

    for an application or a system program. VSAM supports five data set organizations:

    Key-sequenced data set (KSDS)

    Entry-sequenced data set (ESDS)

    Fixed-length relative record data set (RRDS)

    Variable-length relative record data set (VRRDS)

    Linear data set (LDS)

    The primary difference between the VSAM data set organizations is in the way

    the records are stored and accessed.

    VSAM HISTORY

    In the year 1973 VSAM was introduced with ESDS & KSDS only and in theyear 1975 the concept of Alternate Index, RRDS, and Catalog Recovery featureswere introduced. VSAM was re-introduced with a facility called as Integrated Catalog

    Facility (ICF). In the year 1983 VSAM was introduced with DFP/VSAM (Data FacilityProduct) which can run under MCS/XA. Later in the year 1987 the DFP/VSAM 2.3

    with LDS facility was introduced and another VSAM 3.1 under MVS/ESA with DFSMS(Data Facility Storage Management System). In the year 1991, VSAM 3.3 was

    introduced with variable length records for RRDS

    iFrames Technologies 1

  • 7/27/2019 51214566 VSAM Handout

    2/60

    Mainframe VSAM

    STRUCTURE OF VSAM

    VSAM provides a comprehensive catalog facility that stores information aboutVSAM data sets and other files.

    There are two types of catalogs:

    Master Catalogs

    User Catalogs

    Master Catalog

    Every system that uses VSAM has one, and only one, master catalog. The

    master catalog contains entries about system datasets and VSAM structures used tomanage the operation of VSAM. The master catalog is created during the System

    Generation process and usually resides on the System Residence volume. The

    master catalog "owns" all other VSAM resources in a computer system, and this isdenoted by the position of the master catalog.

    User Catalogs

    A user catalog is a catalog created to contain entries about application specific

    datasets. The information defining a user catalog is stored into a catalog entry in themaster catalog. A production system might have any number of user catalogs, with

    the datasets cataloged in a specific user catalog related by application type.

    ADVANTAGES & DISADVANTAGES OF VSAM

    Advantages:

    The retrieval of records is faster because of an efficiently organized index. The

    index is small because of a key compression algorithm used to store andretrieve its records.

    Imbedded free space makes the insertion of records easy, and data setstherefore require less reorganization.

    The deletion of records in VSAM, unlike that in ISAM, means that they are

    physically deleted, thus allowing the reclaiming of free space within the data

    set.

    VSAM data sets are device-independent.

    VSAM catalogs and data sets are portable between operating systems.

    Records can be accessed randomly by key or by address and can also be

    accessed sequentially at the same time.

    Disadvantages: To take advantage of the partial self-reorganization capabilities of VSAM data

    sets, free space must deliberately be left. For data sets that are used for readonly purposes, no free space is required.

    Except for read-only data sets, the integrity of VSAM data sets in cross-

    system and cross region sharing must be controlled by the user. Dataintegrity must be a prime consideration in the initial design of applications

    that will be shared across systems.

    iFrames Technologies 2

  • 7/27/2019 51214566 VSAM Handout

    3/60

    Mainframe VSAM

    MAJOR AREAS WHERE VSAM IS USED

    It can be used as a stand-alone product. VSAM data sets can be created and

    processed by a powerful software product called IDCAMS.

    Batch application programs in COBOL, PL/I, Assembler, etc. can access VSAM

    data sets.

    In data set management, PDS directories, catalogs, and generation datagroups can be manipulated through specific IDCAMS commands. GDGs andcatalogs are themselves VSAM data sets, Also, the IDCAMS utility can be used

    to process older, non-VSAM data set organizations.

    Many major IBM software products, such as CICS, IMS, DB2 and TSO, useVSAM data sets in a majority of applications. In some of them, VSAM data

    sets are the only ones that are compatible.

    VSAM is available under all IBMs Mainframe operating systems; MVS, VM,

    and VSE. The MVS implementation of VSAM is the most comprehensive. Also, VSAMdata sets can be stored on almost all standard disk drives, such as 3390, 3380,

    3350, 3370, etc. Present and future mainframe software released by IBM will bedesigned to process records storage in VSAM data sets. VSAM is going to be around

    for a long time to come.

    VSAM TERMINOLOGY

    Before we discuss VSAM data set organizations in detail, we need to reviewsome terms that will be used throughout the book.

    Logical record

    Control interval

    Control area

    Logical record (LR)

    A logical record is a unit of information used to store data in a VSAM data set.

    Logical records in VSAM data sets are stored differently than logical records in non-

    VSAM data sets.

    A LR is comparable to the logical-record length (lrecl) for a Non-Vsam dataset, as in

    the DCB Parameter of JCL.

    Control Interval (CI)

    Logical records are contained in a control interval (CI). A group of LRs will

    make one CI.

    The fundamental building block of every component of a VSAM data set is thecontrol interval. A control interval is the unit of information that VSAM transfers

    between the storage device and the virtual storage. One CI can be made of one or

    more physical blocks of DASD.

    iFrames Technologies 3

    LR

    LR LR LR LR

  • 7/27/2019 51214566 VSAM Handout

    4/60

    Mainframe VSAM

    A CI consists

    Logical records stored from beginning to end

    Unused space, referred to as free space, for data records to be inserted intoor lengthened

    The maximum size of a CI is 32k and the minimum size is 512 bytes.

    Control information, which is made up of two types of fields; one Control

    Interval Definition Field (CIDF) per CI, and one or more Record DefinitionFields (RDF) per logical record.

    1. CIDF is a 4-byte field. It contains information about the length of data

    in the CI and the amount and location of free space.

    2. RDF is a 3-byte field. It describes the length of records and how manyadjacent records are of the same length.

    Control area (CA)

    A control area (CA) is one or more CIs put together into fixed-lengthcontiguous areas of DASD. A VSAM data set is composed of one or more CAs.

    The number of CIs in a CA is fixed by VSAM. The CA size is implicitly definedwhen you specify the size of a data set at data set definition.

    The maximum size of a CA is one cylinder and the minimum size is one track.

    iFrames Technologies 4

    Control Interval Format for a Non- LDS Cluster.

    RDF1

    RDF2

    RECORD 1 RECORD 2

    Logical RecordArea

    Free space Area

    ControlInterval

    Definition

    field

    Recorddefinition

    field

  • 7/27/2019 51214566 VSAM Handout

    5/60

    Mainframe VSAM

    Figure 1-2 shows the structure of a CA.

    REVIEW QUESTIONS

    1. What is VSAM?

    2. What are the major parts in VSAM?

    3. What are the two Catalogs available in VSAM?

    4. What is Control Interval?

    5. What is Control Area?

    6. How many Bytes occupied for RDF and CIDF?

    7. The Maximum and minimum size of a Control Area is __________,

    _________.

    8. What are the advantages and disadvantages of VSAM?

    9. What are the different datasets supported by VSAM?

    10.What is a logical record?

    11.What's the biggest disadvantage of using a VSAM dataset?

    iFrames Technologies 5

    LR1 LR2 FREE SPACE RDF2 RDF1 CIDF

    LR3 LR4

    LR5 LR6 FREE SPACE

    FREE SPACE RDF4 RDF1 CIDF

    RDF RDF CIDF

    CA1

    CA2

    CA3

    CA 1

  • 7/27/2019 51214566 VSAM Handout

    6/60

    Mainframe VSAM

    CHAPTER --- 2 : Dataset Organization

    VSAM DATASET ORGANIZATION

    Whenever a record is retrieved from DASD, the entire CI containing the

    record is read into a VSAM I/O buffer in virtual storage. From the VSAM buffer, thedesired record is transferred to a user defined buffer or work area.

    The physical organization of VSAM data sets differs considerably from those

    used by other access methods. VSAM data sets are held in control intervals andcontrol areas; the size of these is normally determined by the access method, and

    the way in which they are used is not visible to you.

    TYPES OF DATASET ORGANISATION

    VSAM supports 5 different organizations. They are as follows:

    Linear Data Set LDS with no record organization

    Entry-Sequenced Data Set ESDS - is like a standard sequential data set.

    Fixed-length Relative-Record Data Set - FRRDS - Fixed length RRDS

    Variable-length Relative Record Data Set - VRRDS - Variable length RRDS

    Key-Sequenced Data Set KSDS- is like an indexed sequential accessmethod file.

    The VSAM data set organizations are superior to the native access methods.

    VSAM provides for alternate indexes, a feature not available in native accessmethods. It has an admirable catalog facility that stores more information about

    VSAM and other data sets. The powerful AMS utility in VSAM provides a variety ofservices dealing with catalogs, files, security, file management, etc. It provides

    iFrames Technologies 6

    WORK AREA

    CI

    LR1 LR2 LR3

    LR2

  • 7/27/2019 51214566 VSAM Handout

    7/60

    Mainframe VSAM

    comprehensive support for application development in many environments such asCOBOL, PL/I, FORTRAN, Assembler and CICS.

    LINEAR DATA SET (LDS)

    A linear data set (LDS) contains data that can be accessed as byte-addressablestrings in virtual storage. It is a VSAM data set with a control interval size of 4096

    bytes.

    An LDS has no imbedded control information in its CI, which is, no RDFs and

    CIDFs. All LDS bytes are data bytes. Logical records must be blocked and de blockedby the application program, but records do not exist from the point of view of VSAM.

    An LDS contains a data component only.

    LDS are generally used for fast random access to data that has nohierarchical structure - i.e., for data, that is a large flat file, such as a table or array.

    A relational database is just this. You specify the LDS organization with the IDCAMSDEFINE command specifying the LINEAR parameter.

    ENTRY SEQUENCED DATA SET (ESDS)

    An ESDS is a sequential file, in which records are typically retrieved in theorder in which they were written to the data set and additions are always made at

    the end of the file. Each record can be identified by a relative byte address or RBA.Records cannot be physically deleted. Since records in an ESDS are not sequenced

    on any key field, there is no primary key index component. Imbedded free space isnot allocated at the time of allocation of an ESDS, since records are not added to the

    middle of the file. Records in an ESDS may be of variable length.

    iFrames Technologies 7

    DATADATA CA

    DATA CA

    DATA

    DATA

    DATA

    DATA

    DATA

  • 7/27/2019 51214566 VSAM Handout

    8/60

    Mainframe VSAM

    Records can be updated, but without length change. To change the length of

    a record, you must either store it at the end of the data set as a new record, oroverride an existing record of the same length that you have flagged as inactive.

    A record can be accessed sequentially or directly by its RBA:

    Relative Byte Address (RBA) is the address of a record in a dataset. Records

    can be accessed sequentially or by relative byte address (RBA).The RBA of the firstlogical record is 0. The second record has an RBA equal to the length of the first

    record and so on.

    TYPICAL ESDS PROCESSING

    Sequential processing:VSAM automatically retrieves records in stored sequence. Sequential

    processing can be started from the beginning or somewhere in the middle of a dataset. If processing is to begin in the middle of a data set, positioning is necessary

    before sequential processing can be performed.

    Direct processing:

    When a record is loaded or added, VSAM indicates its RBA. To retrieve recordsdirectly, you must supply the RBA for the record as a search argument. Although an

    ESDS does not contain an index component, you can build an alternate index to keeptrack of these RBAs.

    Empty spaces in the CI are referred to as unused space because they can

    never be used.

    You specify ESDS organization using the IDCAMS DEFINE command andspecifying the NONINDEXED parameter.

    iFrames Technologies 8

    RECORD1 RECORD2 RECORD3 RECORD4

    RECORD5 RECORD6RECORD7 RECORD8

    UNUSED SPACE

    RBA

    0

    RBA

    4096

    RBA 8192

    CI 1

    CI 2

    CI 3

  • 7/27/2019 51214566 VSAM Handout

    9/60

    Mainframe VSAM

    RELATIVE RECORD DATASET (RRDS)

    1) FIXED LENGTH RECORDS

    In an RRDS the entire data set is a string of fixed length slots. Each slot occupies a

    fixed position and is identified by its position relative to the first slot of the data set.

    The relative position of each slot is called relative record number (RRN). An

    RRN is an integer that identifies the position of the slot no the value of a particularfield within the slot. Each slot of an RRDS may or may not contain a record. Records

    in an RRDS may be inserted, retrieved, updated, and deleted both sequentially andrandomly. Records in an RRDS are always fixed in the length. RRDS has only data

    component. When a record is deleted from a particular slot, the slot remains in thesame physical location although a record does not exist in that slot anymore

    You specify the RRDS organization using the IDCAMS DEFINE command with

    the NUMBERED option.

    TYPICAL RRDS PROCESSING

    CONTROL AREA 2

    SLOT 8

    CONTROL AREA 1

    Slot8

    iFrames Technologies 9

    RECORD1 RECORD2 RECORD3 RECORD4

    RECORD5 RECORD6 RECORD7 RECORD8

    RECORD9 RECORD10 RECORD11 RECORD12

    RECORD13 RECORD14 RECORD15 RECORD16

    RECORD17 RECORD18 RECORD19 RECORD20

    RECORD21 RECORD22 RECORD23 RECORD24

    DATACA

    DATACA

    APPLICATION

    PROGRAM

    GET RECORD 25

    CI

    29 30 31 32

    CI

    25 26 27 28

    CI

    21 22 23 24

    CI

    17 18 19 20

    CI13 14 15 16

    CI

    9 10 11 12 CI

    5 6 7 8

    CI

    1 2 3 4

  • 7/27/2019 51214566 VSAM Handout

    10/60

    Mainframe VSAM

    The relative record number can be used as a search argument. Theapplication program inputs the relative record number of the target record and VSAM

    is able to find its location quickly using an internal algorithm. An RRDS can beprocessed sequentially, directly or skip-sequentially.

    RRDS sequential processing is treated the same way as ESDS sequentialprocessing. Empty slots are automatically skipped by VSAM.

    An RRDS can be processed directly by supplying the relative record number

    as a key. VSAM accesses the appropriate slot and returns the record to theusers buffer. RRDS direct address processing by supplying the RBA is not

    supported.

    Skip-sequential processing is treated like an RRDS direct processing request,but the position is maintained. Records must be in ascending sequence.

    2. VARIABLE RELATIVE RECORD DATA SET (VRRDS)

    A VRRDS is similar to a fixed-length RRDS, except that it contains variable-

    length records. Each record has a unique relative record number, and is placed inascending relative record number order. Each record is stored and retrieved using its

    relative record number. VRRDS has no preformatted slots.

    The relative record number of a record cannot change. When that record iserased, the relative record number can be reused for a new record.

    You can specify free space for inserting records and increasing the length of a

    record. VRRDS is a KSDS processed as an RRDS, so an index will be created.

    You specify the VRRDS organization with the IDCAMS DEFINE command withthe NUMBERED option and variable length record.

    REVIEW QUESTIONS.

    1. Which VSAM cluster support only fixed length records?

    a) LDS

    b) RRDS

    c) ESDS

    d) KSDS

    2. FREESPACE can be specified for which type of cluster?

    a) LDS

    b) B. RRDS

    c) C. ESDS

    d) D. KSDS

    3. For a KSDS, the larger the data CA size, the smaller the number of index CIs.

    A. TRUE

    B. FALSE.

    iFrames Technologies 10

  • 7/27/2019 51214566 VSAM Handout

    11/60

    Mainframe VSAM

    4. VSAM control intervals containing data records have at least one RDF and one

    CIDF.

    A. TRUE

    B. FALSE

    5. In which cluster type are records always added at the end of the data set?

    a) LDS

    b) RRDS

    c) ESDS

    d) KSDS

    6. Which VSAM clusters support only fixed length records?

    a) LDS

    b) RRDS

    c) ESDS

    d) KSDS

    7. The types of processing supported by RRDS are

    a) sequential

    b) skip-sequential

    c) direct

    d) a and b

    e) a, b and c

    8. The types of processing supported by ESDS are

    a) Sequential

    b) skip-sequential

    c) Direct

    d) a and b

    e) a and c

    9. What is the Difference between LDS & ESDS?

    10. How Many Times Secondary Space Allocated?

    11. What is the RRN for the first record in RRDS?

    iFrames Technologies 11

  • 7/27/2019 51214566 VSAM Handout

    12/60

    Mainframe VSAM

    CHAPTER - 3: KSDS

    KEY SEQUENCED DATASET (KSDS)

    In a KSDS, records are placed in the data set in ascending collating sequenceby key. The records for KSDS can be fixed-length or variable-length records. The key

    of the record contains a unique value that determines the record's collating positionin the data set. The key must be in the same position in each record.

    The key data must be contiguous and each record's key must be unique. After

    it is specified, the value of the key cannot be altered, but the entire record can bedeleted. When a new record is added to the data set, it is inserted in its collating

    sequence by key.

    A KSDS has a data and an Index Component. The Index Component keepstrack of the used keys and is used by VSAM to retrieve quickly a record from the

    data component, when a request is made for a record with a certain key. A KSDS

    can have fixed or variable length records. A KSDS can be accessed eithersequentially or directly or skip-sequentially.

    You specify the KSDS organization using the IDCAMS DEFINE command with theINDEXED parameter.

    DATA / INDEX RELATIONSHIP

    A KSDS has an index that relates key values to the relative locations of thelogical records in a data set. This index is called the Prime Index. It has two uses:

    Locate the collating position when inserting records.

    Locate records for retrieval.

    When initially loading a data set, records must be presented to VSAM in keysequence. The Index is built automatically by VSAM as the data set is loaded withrecords. When a data CI is loaded with records, VSAM makes an entry in the index.

    The entry consists of the highest possible key in the data CI and a pointer to thebeginning of that CI.

    VSAM index can consists of more than one index level. Each level contains a

    set of records with entries giving The location of the records in the next lower level.

    iFrames Technologies 12

    INDEX COMPONENT

    DATA COMPONENT

  • 7/27/2019 51214566 VSAM Handout

    13/60

    Mainframe VSAM

    Sequence Set: contains the index CIs at the lowest level.

    There is one CI in the sequence set for each data CA. It contains pointers and high

    key information for each CI within the data CA. It contains also horizontal pointersfrom one sequence set CI to the next sequence set CI.

    Index Set: remainder of the index component.

    If there is more than one sequence set level record, VSAM automatically buildsanother index level. Each CI in the index set contains pointers and high key

    information for CIs in the next lower level of the index.

    TYPICAL KSDS PROCESSING:

    INDEX COMPONENT

    DATA COMPONENT

    iFrames Technologies 13

    IS1

    IS2IS3

    SS1 SS2 SS3 SS4 SS5

    CI1

    CI2

    CI3

    CI1

    CI2

    CI3

    CI1

    CI2

    CI3

    CI1

    CI2

    CI3

    CI1

    CI2

    CI3

    CA5CA4CA3CA2CA1

    IndexComponent

    DataComponent

    Index set

    Sequence set

    079 236

    007 021 079 FS 099 124 236 FS

    001 002 004 007

    008 012 018 021

    067 079

  • 7/27/2019 51214566 VSAM Handout

    14/60

    Mainframe VSAM

    CONTROL AREAS

    There are threemethods by which to

    access a KSDS. These aresequential, direct, or skip-

    sequential.

    Sequential accessis used to load a KSDS,

    and to retrieve, update,add and delete records in

    an existing data set.Sequential access means that records are retrieved one-by-one, starting from the

    first record, in the order that they are placed in the dataset.. When retrievingrecords, you do not need to specify key values because VSAM automatically obtains

    the next logical record in sequence. The sequence set is used to find the next logicalCI. Sequential access allows you to avoid searching the index more than once.

    Sequential is faster than direct for accessing multiple data records in ascending key

    order.

    Direct access is used to retrieve, update, add and delete records in an

    existing data set. You need to supply a key value for each record to be processed.You can supply the full key or a generic key. The generic key is the high order

    portion of a full key. For example, you might want to retrieve all records whose keysbegin with XY (where XY is the generic key), regardless of the full key value. VSAM

    searches the index from the highest-level index set CI to the sequence set for arecord to be accessed. Vertical pointers in the sequence set CI are used to access the

    data CA containing the record. Direct access saves you a lot of overhead by notretrieving the entire data set sequentially to process a small percentage of the total

    number of records.

    Skip-sequential access is used to retrieve, update, add and delete records inan existing data set. In skip-sequential method of access, the record pointer can be

    placed anywhere within the dataset (by giving the key) and records can then beretrieved sequentially from that point.

    LOADING A KSDS:

    When loading a KSDS, logical records are stored in ascending key sequence

    within a data CI. The data component for a KSDS can contain user specifiedFREESPACE. This free space is used later, when records are inserted or expanded.

    CI Free Space: Percentage of CI left empty / unused at load time.

    CA Free Space: Percentage of CIs in each data CA empty / unused at loadtime.

    iFrames Technologies 14

    084 087 099

    111 124

    2

    38

    SEQUENCE SET CI

    FS

    407740654037

  • 7/27/2019 51214566 VSAM Handout

    15/60

    Mainframe VSAM

    UPDATING A KSDS CLUSTER:

    Insertion:

    While Inserting a Record in the KSDS Cluster, the records are placed in logical

    sequence. The CI free space is used. The Index Component is not altered.

    Deletion:While deleting a record from the KSDS Cluster, the records are physically removed

    from CI. The records in CI with higher keys are shifted left and the available freespace in the CI is increased. The Index Component is not altered.

    INSERT 4058

    SEQUENCE SET CI

    CI 0

    CI 1

    DATA CA CI 2

    CI 3

    CONTROL INTERVAL SPLIT

    When inserting a record in the CI, if there is no enough free space in the CI,

    then the CI will be split as follows:

    iFrames Technologies 15

    4012 4023 4034 4037 FREE SPACE

    4041 4050 4052 4085 FREE SPACE

    4072 4073 4075 4077 FREE SPACE

    FREESPACE

    CI 0

    CI 1

    CI 2

    CI 3

    4037 4065 4077 FS

    4012 4023 4034 4037 FREESPACE

    4041 4050 4052 4058 4065

    FREE SPACE

    4072 4073 4075 4077 FREESPACE

  • 7/27/2019 51214566 VSAM Handout

    16/60

    Mainframe VSAM

    Half of the full CI is moved to an empty / free CI within same CA. So, CA free

    space is used.

    A new index entry is inserted in the sequence set record.

    The existing index entry is updated in the sequence set record.

    As a result of the CI split, the physical sequence of the data is no longer the

    same as the logical sequence.This will be illustrated by the following diagram.

    .

    INSERT 4046

    SEQUENCE SET

    CI 0

    CI 1

    DATA CA

    CI 2

    CI 3

    CONTROL AREA SPLIT

    When there are no more free CI s in the CA then VSAM performs a controlarea split.

    o VSAM allocates a new CA at the end of the data component

    o Approximately half of the data CI s are moved from the full CA to the

    new CA.

    o A new sequence set CI is created for the new data CA.

    o The old sequence set CI is modified

    o The index set is updated. In the given below example a new index set

    CI will be created that will be the highest-level index set CI. Then VSAM

    performs a control Interval split.

    This will be illustrated by the following diagram.

    iFrames Technologies 16

    4037 4050 4065 4077

    4012 4023 4034 4037 FREE SPACE

    4041 4046 4050 FREE SPACE

    4072 4073 4075 4077 FREE SPACE

    4052 4058 4065 FREE SPACE

  • 7/27/2019 51214566 VSAM Handout

    17/60

    Mainframe VSAM

    TO INSERT 4074

    CA1

    4076 4077 4075

    CA2

    SPANNED RECORDS

    Spanned records are records with a record size greater than the CI sizespecified.

    iFrames Technologies 17

    BEFOREAFTER

    4077406540504037

    SEQUENCE SET CI INDEX SET CI

    40774065

    SEQUENCE SET CI

    4037 4050 4065

    4037403440234012

    405040464041

    407740764073 4075

    4072

    406540584052

    4037403440234012

    4050

    40464041

    FREE SPACE

    406540584052

    407440734072

    FREE SPACE

    FREE SPACE

  • 7/27/2019 51214566 VSAM Handout

    18/60

    Mainframe VSAM

    Spanned records can only be used in ESDS or KSDS organizations.

    Spanned records can span control intervals, but not control areas. So, onespanned record is stored in several CIs.

    As in the above diagram, the spanned record spans three CIs. The segmentof the first CI contains part of data along with two RDFs and one CIDF. The right

    RDF gives the length of the segment. The left RDF gives the update number of thesegment (used to maintain update consistency of all segments during an update).

    A CI that contains the records segment of a spanned record contains controlinformation. However a new record cannot be inserted into the same CI. As in the

    diagram, the third CI contains the spanned data, and the rest of the space becomes

    unused space. A new record would move into the fourth CI.

    ACCESSING SPANNED RECORDS

    Spanned records must be accessed in MOVE mode. The application program must

    contain a work area as the largest spanned record in the data set.

    iFrames Technologies 18

    RECORD 1

    RECORD 1 R R CSEGMENT1 D D I

    F F D2 1 F

    RECORD 1 R R CSEGMENT2 D D I

    F F D2 1 F

    RECORD 1 UNUSED R R CSEGMENT3 SPACE D D I

    F F D2 1 F

  • 7/27/2019 51214566 VSAM Handout

    19/60

    Mainframe VSAM

    REVIEW QUESTIONS:

    1. Specifying CISZ (4096) at the cluster level for a KSDS results in

    a) VSAM ignoring the specification

    b) Data and index CISZ 4k each

    c) Data CISZ 4k; index CISZ selected by VSAM

    2. What is the use of Free Space in KSDS?

    3. How do you define a KSDS?

    4. VS COBOL II supports SKIP processing.

    a) TRUE

    b) FALSE

    5. VSAM request macros (e.g., GET, PUT) point to which other macro(s)?

    a) OPEN

    b) ACB

    c) RPL

    d) CLOSE

    e) (B) and (C)

    6. NONSPANNED records may be accessed in either MOVE mode or LOCATE

    mode.

    a) TRUE

    b) FALSE

    7. What does a file status of 02 on a VSAM indicate?

    8. Explain CI split and CA split

    iFrames Technologies 19

    CI 1

    CI 2

    CI 3

    DATA BUFFERS

    WORK AREA

    ADDRESS SPACE

  • 7/27/2019 51214566 VSAM Handout

    20/60

    Mainframe VSAM

    CHAPTER - 4: ACCESS METHOD SERVICES (AMS)

    One of VSAMs strength is that a single set of data management facilities

    called Access Method Service (AMS) manages both VSAM and non-VSAM datasets.

    IDCAMS is a general-purpose utility program, used with VSAM, to establish

    and maintain catalogs and data sets. It provides the services described above, andmore.

    AMS uses a command processor called IDCAMS to handle a variety of

    functions such as creating, reproducing, printing datasets and listing catalogcontents. These functions of AMS are performed thru functional commands.

    A functional command can have one or more parameters that can be

    positional or keyword. Positional parameters are identified by its position in relationto other parameters: a keyword parameters can be used in any place in relation to

    other keyword parameters because it is identified by the particular keyword used.

    Types of AMS commands

    Functional commands

    Modal commands

    Commonly used AMS commandsAMS command Function

    Functional commands

    ALTER Changes information specified for a catalog, cluster,alternate index, or path at define time.

    BLDINDEX Builds an alternate index.

    DEFINE ALTERNATE

    INDEX

    Defines an alternate index.

    LISTCAT List information about data sets

    REPRO Copies records from one file to another. The input and

    output files can be VSAM or non-VSAMPRINT Prints the contents of a VSAM or non-VSAM file.

    DEFINE CLUSTER Defines a VSAM file, whether its KSDS, ESDS, or RRDS

    DEFINE MASTER

    CATALOG

    Defines a master catalog

    DEFINE PATH Defines a path that relates an alternate index to its basecluster

    DEFINE USERCATALOG Defines a user catalog.

    DELETE Removes a catalog entry for a catalog, cluster, alternate

    index or path

    EXPORT Produces a transportable file.IMPORT Copies a previously exported file.

    iFrames Technologies 20

  • 7/27/2019 51214566 VSAM Handout

    21/60

    Mainframe VSAM

    Modal commands

    IF Controls the flow of command execution by testingcondition codes returned by functional commands

    SET Controls the flow of command execution by altering

    condition codes returned by functional commandsPARM Sets options values that effect the way AMS executes.

    AMS PERFORMANCE PARAMETERS

    1) CONTROL INTERVAL SIZE

    Syntax : CONTROLINTERVALSIZE (bytes)

    Abbr : CISZ or CISIZE

    Default : Calculated by VSAM

    Control Interval size (CIDF & RDF) & FREESPACE must be taken into account

    Thumb Rule for CISIZE

    If the record length is =8192, multiples of 2048

    2) FREESPACE

    Syntax : FREESPACE (CI% CA%)

    Default : FREESPACE(0 0)

    High Free space results in more I/O & consumes larger DASD space

    Very low FREESPACE results in CI splits and degrades performance

    Amount of FREESPACE depends ono Rate of growth of records

    o Expected number of records to be deleted

    o Reorganization frequency

    o Performance consideration

    o

    o 3) BUFFERSPACE

    o Syntax : BUFFERSPACE (bytes)

    o Abbr : BUFSP

    o

    Default : Two data buffers plus oneadditional index buffer for KSDS

    o Used to improve Input/output performance

    o Can also be specific in JCL EXEC parameter

    o

    o //DD1 DD DSNAME=ANYVSAM1,

    o // AMP=('BUFND=4,BUFNI=4,STRNO=2')

    iFrames Technologies 21

  • 7/27/2019 51214566 VSAM Handout

    22/60

    Mainframe VSAM

    o

    o More on VSAM Buffers

    o

    Strings (STRNO in AMP parameter)

    o Defines number of concurrent access

    o For batch processing, a string of 1 is enough

    o For online processing more strings is required

    Data Buffers (BUFND in AMP parameter)

    Random Access

    o Minimum of 2 (One for normal access and one for split

    processing) is required

    Sequential Access

    Ideal to process a track

    Allocate number of buffers based on the number of CI/TRK

    For READ add 1 more buffer and for WRITE add 2 more buffers

    Index Buffers (BUFNI in AMP parameter)

    Default of 1 index buffer is enough

    Random Access

    Ideal to keep the index set in virtual memory

    Determine the number of levels (using LISTCAT)

    Allocate number of levels + 1 buffer

    o

    o 4) RECOVERY / SPEED

    Mutually ExclusiveRECOVERY allows you to recover if the job initially loading the dataset fails

    SPEED is faster, but does not provide restart feature

    Default:RECOVERY

    5) SPANNED

    Syntax:

    SPANNED/NONSPANNED

    Default:

    NONSPANNED

    Allows large records to span more than one Control Interval

    However, the records cannot span across Control areas

    RRDS does not support spanned records.

    iFrames Technologies 22

  • 7/27/2019 51214566 VSAM Handout

    23/60

    Mainframe VSAM

    6) KEYRANGES

    Syntax: KEYRANGES (Low - Val; High - Val)

    Default : None (No range assumed)

    Example :

    KEYRANGES ((000001 100000)+

    100001 200000))

    The Key Ranges correspond to VOLUMES if ORDERED clause is specified.

    7) ORDERED

    Syntax: ORDERED / UNORDERED

    Default: UNORDERED

    Goes together with KEYRANGES clause specifies the volume to which

    the key values should go.

    8) REUSE

    Syntax : REUSE/NOREUSE Default : NOREUSE

    REUSE specifies that the cluster can be loaded with fresh records with

    an implicit delete of existing RECORDS

    REUSE cannot be used under following circumstances and hence not

    recommended

    When KEYRANGES parameter is coded

    When alternate indexed are defined

    9) REPLICATE

    Directs the VSAM to duplicate each index as many times as it will fit onits assigned track

    Applies only to KSDS index component

    To reduce rotational delay and to make I/O faster

    Syntax: Replicate / No replicate

    Default : No replicate

    10) VOLUMES

    Can specify different volumes for

    Data component

    Index component

    11) IMBED

    Directs the VSAM to place the sequence set (the lowest level of indexnext to the data component) on the first track of the data control area and

    duplicate it as many times as it will fit. This process will reduce rotationaldelay because the desired sequence set record is found faster

    Default: NO IMBED

    iFrames Technologies 23

  • 7/27/2019 51214566 VSAM Handout

    24/60

    Mainframe VSAM

    Syntax : IMBED / NO IMBED

    Note:

    IMBED applies to the index component. Hence it is limited to a KSDS.

    IMBED places the sequence set CI for a data control area within the controlarea.

    Uses IMBED only with large control area sizes.

    IMBED requires additional DASD space.

    IMBED should provide faster access to data.

    12) SHARE OPTION

    Syntax: SHAREOPTIONS (Cross-region-value Cross-system-Val)

    Cross-region : Concurrent data access on a standalone system(ex: TSO&CICS accessing same data)

    Cross-system : Data access for multiple computers (Twodifferent computers that are inter-connected)

    Default : SHAREOPTIONS (1 3)

    Multiple jobs can read only if no update takes place - Complete data integrity

    Multiple jobs can read and at the same time one job can update - Write, butnot read integrity

    Multiple jobs can read & write simultaneously - No integrity

    Same as option 3, but refreshes buffer after every read

    Share options 1 & 2 are not allowed for cross-system

    For cross region sharing, each batch job must have DISP=SHR

    For cross system sharing DISP parameter in the JCL is immaterial

    13) ERASE / NOERASE

    Default : NOERASE

    ERASE instructs VSAM to move zeroes to all the bytes once the cluster isdeleted.

    INVOKING IDCAMS

    //MYJOB JOB

    //STEPA EXEC PGM = IDCAMS

    //SYSPRINT DD SYSOUT = *

    //SYSIN DD * DEFINE CLUSTER

    .

    .

    IDCAMS commands can be processed as a job or job step (byspecifying PGM=IDCAMS) on the EXEC card.

    iFrames Technologies 24

  • 7/27/2019 51214566 VSAM Handout

    25/60

    Mainframe VSAM

    BASIC IDCAMS COMMANDS

    The following are the commands which will be used with IDCAMS procedure.

    BUILDINDEX

    DEFINE

    IMPORT/EXPORT

    LISTCAT

    REPRO

    VERIFY

    AMS COMMAND SYNTAX

    Margins Default to 2&72

    Separators BLANK,COMMA

    Comments /*----------------*/

    Continuation HYPEN, PLUS SIGN

    Terminator SEMICOLON or Absence of Continuation mark

    There are two possible continuation characters:

    The PLUS sign (+): ignores the leading blanks on the next line. The HYPEN sign (-): doesnt ignore the leading blanks on the next line.

    DEFINE SPECIFICATONS

    When defining a VSAM cluster using the DEFINE CLUSTER command, the

    following must or can be specified.

    iFrames Technologies 25

    COMMAND PARAMETERS TERMINATOR

    SERVICEFURTHER END OF COMMANDREQUESTED DESCRIBES COMMAND

    Data Set Name

    Data Set Type

    Space Allocation

    Where?

    How much?

    Data Set Attributes

  • 7/27/2019 51214566 VSAM Handout

    26/60

    Mainframe VSAM

    The data set name:

    The cluster name is required.

    Component name(s) is/are optional.

    The type of the date set type:

    KSDS, ESDS, RRDS, LDS.

    The data set attributes:

    Record size and control interval size.

    For a KSDS: Key information and free space distribution.

    BASIC DEFINE COMMAND SYNTAX FOR CLUSTER:

    The DEFINE CLUSTER Command

    DEFINE CLUSTER ( NAME(entry name)

    [ OWNER(owner id) ]

    [ FOR(days) | TO(date) ]

    [ INDEXED | NONINDEXED | NUMBERED ] [ RECORDSIZE (avg max) ]

    [ CISZ(size)]

    [ SPANNED | NONSPANNED]

    [ KEYS (length offset)]

    [ FREESPACE ( ci ca) ]

    [ VOLUMES ( vol-ser no..)]

    [ FILE (ddname) ]

    [ { cylinders /kilobytes/megabytes/tracks/records} (primary

    secondary)}]

    [ UNIQUE | SUBALLOCATION]

    [ REUSE | NOUSE]

    [ SHAREOPTIONS ( a b)]

    [ IMBED | NOIMBED]

    [ STORAGECLASS(storage class)]

    [ DATACLASS(data-class)]

    [MANAGEMENTCLASS (management- class)]

    [ DATA ( [ NAME (entry name) ]

    [ VOLUMES (vol ser .)]

    [ FILE (ddname) ] [ { cylinders/kilobytes/megabytes/tracks/ records} (primary

    secondary) ] ) ]

    [ INDEX ( [ NAME( entry name) ]

    [ VOLUMES ( Vol ser .)]

    [ { cylinders/kilobytes/megabytes/tracks/ records} (primarysecondary) ] ) ]

    iFrames Technologies 26

  • 7/27/2019 51214566 VSAM Handout

    27/60

    Mainframe VSAM

    [CATALOG ( name [/ password]) ]

    Explanation

    NAME (entry name) Specifies the name of the cluster or

    component

    OWNER (owner id) Specifies a 1 to 8 character owner-id.

    FOR (days) TO (date) Specifies a retention period ( in the formatdddd) or an expiration date (in the format

    yyddd)

    INDEXED / NONINDEXED/NUMBERED Specifies the file organization: SDS

    INDEXED), SDS NONINDEXED), OR RRDS

    NUMBERED). The default is INDEXED.

    RECORDSIZE ( avg max) Specifies the average and maximumrecord size.

    CISZ (Size) Specifies the size of the control intervals.

    SPANNED / NONSPANNED Specifies whether records can cross

    control interval boundaries. The

    default is NONSPANNED.

    KEYS (length offset) Specifies the length and offset of the

    primary key.

    FREESPACE (ci ca) specifies the percentage of free space to

    reserve in the control intervals andcontrol areas.

    VOLUMES (Vol-ser) Specifies one or more volumes that willcontain the cluster or component.

    FILE (dd name) Specifies a dd name that identifies a DDstatement that allocates the

    volumes .Required only for mountableDASD volumes.

    Primary Specifies the amount of space to initially

    allocate, expressed in terms of cylinders,kilobytes, megabytes, tracks or

    records.

    Secondary Specifies the secondary space allocation.

    UNIQUE/SUBALLOCATION Specifies whether the file is unique or sub

    allocated. The default is

    SUBALLOCATION. REUSE / NOREUSE Specifies whether a file is reusable. The

    default is NOREUSE.

    SHAREOPTIONS ( a b) Specifies the level of the file sharingpermitted.

    IMBED / NOIMBED Specifies whether sequence set recordsshould be imbedded in the data component of

    a KSDS. The default is NOIMBED.

    iFrames Technologies 27

  • 7/27/2019 51214566 VSAM Handout

    28/60

    Mainframe VSAM

    CATLOG (name[/password]) Specifies the name and password of the

    catalog that will own the cluster. Ifomitted, the high- level qualifier of the

    cluster name or the stepcat, jobcat,or master catalog identifies the catalog.

    NAME is a positional keyword parameter and must be coded first. Other

    keywords can be placed anywhere

    EXAMPLES OF THE DEFINE CLUSTER:

    Example #1

    Define a key-sequenced data set (KSDS)

    DEFINE CLUSTER ( NAME (MTRG.CUSTOMER.MASTER) -

    OWNER(MTRG) -

    INDEXED -

    RECORDSIZE(80 80) -

    KEYS(6 0) - VOLUMES(SMS007) -

    UNIQUE -

    SHAREOPTIONS( 2 3) -

    IMBED) -

    DATA ( NAME(MTRG.CUSTOMER.MASTER.DATA) -

    CYLINDERS(50 5) -

    CISZ(4096) ) -

    INDEX ( NAME(MTRG.CUSTOMER.MASTER.INDEX))

    Example #2

    Define an entry-sequenced data set (ESDS)

    DEFINE CLUSTER (NAME (MTRG.CUSTOMER.MASTER) -

    OWNER (MTRG) -

    NONINDEXED -

    RECORDSIZE (180 80) -

    VOLUMES (SMS007) -REUSE)

    -

    DATA ( NAME (MTRG.CUSTOMER.MASTER.DATA) -

    CYLINDERS (50 5) )

    Example #3

    Define an relative-record data set (RRDS)

    DEFINE CLUSTER (NAME (MTRG.CUSTOMER.MASTER) -

    OWNER (MTRG) -

    NUMBERED -

    iFrames Technologies 28

  • 7/27/2019 51214566 VSAM Handout

    29/60

    Mainframe VSAM

    RECORDSIZE (180 80) -

    VOLUMES (SMS007) -UNIQUE)

    -

    DATA (NAME (MTRG.CUSTOMER.MASTER.DATA) -

    CYLINDERS (50 5) )

    REVIEW QUESTIONS:

    1. What is IDCAMS? And what is the purpose of it?

    2. What is the significance of the SHAREOPTIONS parameter?

    3. What is the use of REPRO command?

    4. What are the different types of AMS commands?

    5. What are the basic IDCAMS commands?

    6. AMS will generate a data component name if it is not explicitly coded.

    a) TRUE

    b) FALSE

    7. What are the parameters used in AMS commands?

    8. Can AMS commands be run from the TSO prompt?

    9. What is the base cluster?

    CHAPTER - 5: Creation of Clusters

    CREATION OF VSAM DATA SETS THROUGH JCL

    A Data Class is a description of data set characteristics under control

    of SMS.

    JCL parameter overrides the specifications from a Data Class. VSAMaccomplishes JCL simplification by centralizing functions such as defining,

    iFrames Technologies 29

    // DD statement

    with new parameters

    and/orinfo from DATA CLASS

  • 7/27/2019 51214566 VSAM Handout

    30/60

    Mainframe VSAM

    deleting, and altering file characteristics in the AMS Utility program. VSAMhas much simpler JCL requirements than files of other access methods.

    How to allocate existing VSAM files

    The DSNAME parameter

    The DUMMY parameter

    The DISP parameter

    The AMP Parameter

    How to create VSAM files using JCL.

    The DD statement for allocating existing VSAM File

    //ddname dd DSNAME={data-set-name}

    {Dummy}[,Disp={old/shr},Normal-disp,Abnormal-disp]

    [,AMP=(option,option.)]

    Explanation:

    DSNAME Specifies the name of the VSAM dataset. Normally, the high

    level qualifier of the name identifies the owning catalog.

    DUMMY Specifies that a VSAM file should not be allocated; instead, MVS

    should simulate a VSAM FILE.

    DISP Specifies the files status and, the files normal & abnormal

    disposition. The valid status options are OLD for exclusive accessand SHR for shared access. All of the disposition options

    except UNCATLG are valid for VSAM files.

    AMP Specifies one or more processing options for VSAM files.

    The AMP parameter

    The AMP parameter is for VSAM files & the DCB parameter is for non-VSAM files. It specifies execution time information that affects how the file is

    processed.

    The AMORG sub parameter

    AMORG indicates that the files being accessed is a VSAM file.

    Normally, MVS realizes that a VSAM file is being processed when it retrievesthe catalog information for the file. So we need to specify AMP=AMORG when

    MVS doesnt search the catalog.

    The AMP parameter

    AMP=[ AMPORG]

    [,BUFND=n]

    [,BUFNI=n]

    [,BUFSP=n]

    iFrames Technologies 30

  • 7/27/2019 51214566 VSAM Handout

    31/60

    Mainframe VSAM

    [,OPTCD=OPTIONS]

    [,RECFM=FORMAT]

    [,STRNO=N]

    Explanation

    AMORG Specifies that the data set is a VSAM file. Normally not

    required.

    BUFND Specifies the number of buffers to allocate for the data

    component.

    BUFNI Specifies the number of buffers to allocate for the index

    component.

    BUFSP Specifies the total amount of space in bytes to allocate for the

    data and index buffers.

    OPTCD options for the ISAM interface. Code I , L, or IL. I means that

    if OPTCD=L is specified for the file in the processingprogram, records marked for deletion by hex FF in the first

    byte should be physically deleted from the file. If OPTCD=L

    is not specified in the program, Specify OPTCD=IL in the DDstatement for the same effect.

    RECFM Specifies the format in which the ISAM program expects to

    process records.

    STRNO Specifies the number of concurrent requests the program may

    issue against the file.

    Example #1

    //CUSTMAST DD DSNAME=MTRG.CUSTOMER.MASTER, DISP=SHR,

    // AMP=(BUFND=2,BUFNI=6)

    Allocate a VSAM file for shared access, specifying that 2 data buffersand 6 index buffers should be used.

    Example # 2

    //CUSTISAM DD DSNAME=MTRG.CUSTOMER.MASTER,DISP=SHR,

    // AMP=(AMORG,OPTCD=IL,RECFM=FB)

    Allocate VSAM file using the ISAM interface program, AMORG identifiesthe file as VSAM, OPTCD specifies how logically deleted records should be

    handled and RECFM specifies that the program expects fixed-length blockedrecords.

    NEW PARAMETER USED IN VSAM

    RECORG =

    KEYOFF = offset-to-key

    iFrames Technologies 31

    ESKSRRLS

  • 7/27/2019 51214566 VSAM Handout

    32/60

    Mainframe VSAM

    (for KSDS Only)

    KEYLEN =Bytes

    (for KSDS and some non-VSAM data sets)

    RECORG parameter

    o KS specifies a VSAM key-sequenced data set

    o ES specifies a VSAM entry-sequenced data set

    o RR specifies a VSAM relative record data set.

    o LS specify a VSAM linear space data set.

    o

    o KSDS (EX1)

    o

    o

    o

    o

    o

    o

    o

    o

    o ESDS (EX2)

    o

    o

    o

    o

    o

    o

    o RRDS (EX3)

    o

    o

    o

    o

    o

    o

    o Not all VSAM options can be specified in the JCL, more options

    and defaults may come from a Data class.

    EX1 shows a JCL statement containing all required information for a KSDS

    data set.

    iFrames Technologies 32

    KSDS //DD1 DD DSNAME = MY.KSDATA,// DISP=(NEW,CATLG),// SPACE=(400,(50,5)),// AVGREC=K,// RECORG =KS// KEYLEN= 15,// KEYOFF=0,// LRECL=250

    // DD2 DD DSNAME=MY.ESDATA// DISP=(NEW,CATLG),

    // SPACE=(100,(10,8)),// RECORG =ES// LRECL=50

    LINEAR //DD3 DD DSNAME=&LIN,// DISP=(NEW,PASS),// SPACE=(1,(10)),// AVGREC=M,// RECORG=LS

  • 7/27/2019 51214566 VSAM Handout

    33/60

    Mainframe VSAM

    Ex2 shows a JCL statement containing all required information for an ESDS

    data set.

    Ex 3 shows a JCL statement of a temporary linear data set. This example

    requires the assignment of a so-called storage Class.

    REPRO Command REPRO is an all-purpose load and backup utility command .

    It loads an empty VSAM cluster with records. The data and index components

    (for a KSDS) are build automatically.

    It creates a backup of a VSAM dataset on a physical sequential dataset, andthen restore and rebuilds the VSAM dataset using this dataset as input

    It merges data from two VSAM datasets.

    REPRO terminates if One physical I/O error while writing to the outputdataset.

    A total of four errors encountered in any combination: A logical error while writing to the output data set.

    A logical error while reading the input data set.

    A physical error while reading the input data set.

    CREATION OF ESDS CLUSTER

    The definition of an ESDS cluster with the parameters describedabove.

    //IFMAIN2 JOB (12345678),IFMAIN2,MSGCLASS=H,

    // MSGLEVEL=(1,1),CLASS=A,NOTIFY=&SYSUID //STEP1 EXEC PGM=IDCAMS

    //SYSOUT DD SYSOUT=*

    //SYSPRINT DD SYSOUT=*

    //SYSIN DD *

    DEFINE CLUSTER -

    (NAME (IFMAIN2.esds.CLUST) -

    RECORDSIZE (80,80) -

    TRACKS(5, 1) -

    CISZ(4096) -

    NONINDEXED -

    REUSE) -

    DATA (NAME(IFMAIN2.IFRAME.CLUST.DATA))

    /*

    //

    iFrames Technologies 33

  • 7/27/2019 51214566 VSAM Handout

    34/60

    Mainframe VSAM

    The above example shows the creation of an ESDS cluster. After the

    execution of this JCL the blank cluster will be created and it will be in the usercatalog for usability.

    COPYING ENTIRE DATA SETS

    The following screen shot will copy the EMP1.PS content to the abovecreated ESDS cluster, KSDS

    In this example, an entire input data set is copied to the output data set.

    Two parameters of REPRO are used.

    INDATASET (or IDS) Name of the entry to be copied or of the user catalog tobe merged.

    OUTDATASET (or ODS) Name of the target data set.

    Both INDATASET and OUTDATASET can be used to reference VSAM or non-

    VSAM data sets.

    Example:

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //DD1 DD DSN=IFMAIN2.EMP1.PS,DISP=SHR

    //DD2 DD DSN=IFMAIN2.ESDS.CLUSTER,DISP=SHR

    //SYSIN DD *

    REPRO INDATASET(IFMAIN2.EMP1.PS) -

    OUTDATASET(IFMAIN2.ESDS.CLUSTER) /*

    //

    CREATION OF KSDS CLUSTER WITH REUSE OPTION.

    REUSE specifies that the cluster can be loaded with fresh records withan implicit delete of existing records. The REUSE parameter can be specified

    on both the DEFINE CLUSTER and the REPRO command.

    Example:

    //ifmain2 job notify=&sysuid

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //SYSIN DD *

    DEFINE CLUSTER(NAME(IFMAIN2.KSDS.CLUSTER)-

    TRACKS(2,5)-

    RECORDSIZE(80,80)-

    iFrames Technologies 34Here the KSDS

    cluster is

    created withREUSE option

  • 7/27/2019 51214566 VSAM Handout

    35/60

    Mainframe VSAM

    CONTROLINTERVALSIZE(512)-

    FREESPACE(20,20)-

    KEYS(4,0)-

    REUSE-

    INDEXED))-

    DATA(NAME(IFMAIN2.KSDS.DATA))-

    INDEXED(NAME(IFMAIN2.KSDS.INDEX)) /*

    //

    REUSE cannot be used under following circumstances and hence not

    recommended

    When KEYRANGES parameter is coded

    When alternate indexed are defined

    CREATION OF RRDS CLUSTER

    The following screenshot shows the definition of an KSDS cluster withthe parameters described above

    Example:

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //SYSIN DD *

    DEFINE CLUSTER(NAME(IFMAIN2.RRDS.CLUSTER)-

    TRACKS(2,5)-

    RECORDSIZE(80,80)- CONTROLINTERVALSIZE(512)-

    NUMBERED))-

    DATA(NAME(IFMAIN2.RRDS.DATA))

    /*

    //

    REPRO RECORD SELECTION

    DATA set can be copied partially using starting and ending delimiterparameters on the REPRO command

    number = Number of records

    key-value = Record key for a KSDS

    rba = relative byte address for a record in a KSDS or ESDS

    rrn = Relative record number(slot) for RRDS records

    Where to start Whereto stop

    KSDS FROMKEY (rec-key) TOKEY (rec-key)

    iFrames Technologies 35Here thEMP1.PS is

    entirely copied toESDS.CLUSTER

  • 7/27/2019 51214566 VSAM Handout

    36/60

    Mainframe VSAM

    KSDS, ESDS FROMADDRESS(rba) TOADDRESS(rba)

    RRDS FROMNUMBER (rrn) TONUMBER (rrn)

    KSDS, ESDS SKIP(number) COUNT(number)

    RRDS, ISAM

    The Following The Selection Of Records In Different VSAM Files.

    ESDS CLUSTER

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //INPUT DD DSN=IFMAIN2.ESDS.CLUSTER,DISP=SHR

    //SYSIN DD *

    PRINT-

    INFILE(INPUT)-

    CHAR-

    FROMADDRESS(0)TOADDRESS(160)

    /*

    //

    The above program will display only the selected RBA address records whichare shown by the following screenshots.

    KSDS CLUSTER

    The following use the keys to select the particular records from the kSDS

    cluster

    Example:

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //INPUT DD DSN=IFMAIN2.KSDS.CLUSTER,DISP=SHR

    //SYSIN DD *

    PRINT-

    iFrames Technologies 36

  • 7/27/2019 51214566 VSAM Handout

    37/60

    Mainframe VSAM

    INFILE(INPUT)-

    CHAR-

    FROMKEY(1000)TOKEY(1004)

    /*

    //

    RRDS CLUSTER

    The following screen shots use the keys to select the particular records fromthe kSDS cluster

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //INPUT DD DSN=IFMAIN2.RRDS.CLUSTER,DISP=SHR

    //SYSIN DD *

    PRINT-

    INFILE(INPUT)-

    CHAR-

    FROMNUMBERED(1000)TONUMBERED(1004)

    /*

    //

    REVIEW QUESTIONS:

    1. Which of the following repro selection parameters can be specified for anLDS?

    a) From key b) from address

    c) From number d) skip e) none of the above.

    2. REPRO will stop processing records when a total of four physical I/O errors

    occur while writing to the output data set.

    A. TRUE

    B. FALSEC.

    D. 3. REPRO REUSE against a non-empty target data set with NOREUSE willreset target data set.

    A. TRUE

    B. FALSE

    C.

    D. 4. AMS will generate a data component name if it is not explicitly coded.

    iFrames Technologies 37

  • 7/27/2019 51214566 VSAM Handout

    38/60

    Mainframe VSAM

    A. TRUE

    B. FALSE

    C.

    D. 5. When defining a KSDS, which of the following parameters is not required?

    E.

    A. Space allocation (either CYL, REC or TRK)

    B. VOLUMES

    C. KEYS

    D. NAME

    E.

    F. 6. DEFINE CLUSTER for a KSDS will generate CLUSTER, DATA and INDEXinformation even if only CLUSTER information is specified.

    A. TRUE

    B. FALSE

    C.

    D. 7. A candidate volume is not used when the data set is initially loaded.

    A. TRUE

    B. FALSE

    C.

    D. 8. If the key of a KSDS record begins in the second field (first field is 25 bytes

    long), the offset in the KEYS parameter is:

    E.

    F. a) 24 b) 25 c) 26 d) None of the above.

    G.

    H. 9. Suppose TEST.DATASET is a KSDS. The following statement will printCLUSTER information only: LISTCAT ENTRIES (TEST.DATASET) ALL

    a. TRUE

    b. FALSE.

    c.

    d.

    e.

    f.

    g.

    h.

    i.j.

    k.

    l.

    m.

    n.

    o.

    iFrames Technologies 38

  • 7/27/2019 51214566 VSAM Handout

    39/60

    Mainframe VSAM

    p.

    q.

    r. CHAPTER --- 6 : Print and Additional Commands

    s.

    t. PRINT COMMAND

    u. The PRINT command of Access Method Services is used to printthe contents of both VSAM and non-VSAM data sets. The command

    syntax is similar to that of REPRO. While REPRO copies an input dataset into another output data set, PRINT dumps an input data set to a

    printer. This command is versatile and can be used to print a completedata set or only a selected part of it.

    v.

    w. The PRINT command

    x.

    y. PRINT { INDATASET(entry-name [/ password])}

    z. [{CHARACTER/HEX/DUMP}]

    aa. [{SKIP(count)/

    FROMKEY(key)/FROMNUMBER(number)/FROMADDRESS(address)}]

    bb.

    [{COUNT(count)/TOKEY(key)/TONUMBER(number)/TOADDRESS(address)]

    cc.

    dd.Explanation

    ee. CHARACTER/HEX/DUMP -Specifies the format of the output.

    CHARACTER & HEX print the data in character or hex format. DUMPprints data in both character and hex format. DUMP is default.

    ff.

    gg.Example

    hh.To print records 29, 30 & 31 in character format.

    ii. PRINT INDATASET(MTRG.CUSTOMER.MASTER) -

    jj. CHARACTER -

    kk. SKIP(28) -

    ll. COUNT(3)

    mm.

    nn.To print records 29,30 & 31 in dump format.

    oo. PRINT INDATASET (MTRG.CUSTOMER.MASTER) -pp. DUMP -

    qq. SKIP(28) -

    rr. COUNT(3)

    ss.

    tt. Example:

    uu. //ifmain2 job notify=&sysuid

    iFrames Technologies 39

  • 7/27/2019 51214566 VSAM Handout

    40/60

    Mainframe VSAM

    vv. //step1 exec pgm=idcams

    ww. //sysprint dd sysout=*

    xx. //sysout dd sysout=*

    yy. //input dd dsn=ifmain2.rrds.cluster,disp=shr

    zz. //sysin dd *

    aaa. Print-

    bbb. Infile(input)-

    ccc. Char-

    ddd. Skip(1)-

    eee. Count(3)

    fff. /*

    ggg. //

    hhh.

    iii. EXPORT/IMPORT COMMAND

    jjj. Export extracts catalog information and creates a copy of thedata records. When a base cluster and its alternate index are

    permanently exported, the alternate index must be exported beforethe base cluster. When exporting a data set for backup purpose specify

    TEMPORARY to preserve the original data set.

    kkk.

    lll. EXPORT IMPORT

    mmm.

    nnn. Advantages

    Used for backup and recovery

    Catalog information also exported along with the data, unlike REPRO

    DFSMS classes are preserved

    iFrames Technologies 40

  • 7/27/2019 51214566 VSAM Handout

    41/60

    Mainframe VSAM

    Cluster deletion and redefinition are not necessary during the import

    Can be easily ported to other systems

    Disadvantages

    The EXPORTED file not reusable until it is imported

    Slower than REPRO

    SYNTAX FOR EXPORT

    EXPORT entryname[/password] -

    {outfile(ddname) outdataset(entryname)} -

    [CIMODE | RECORDMODE] -

    [TEMPORARY | PERMANENT] -

    [INHIBITSOURCE

    NOINHIBITSOURCE] -

    [INHIBITTARGET

    |NOINHIBITTARGET] -

    [ERASE | NOERASE] -

    [PURGE | NOPURGE]

    RECORD MODE RECORDS ARE EXPORTED ONE LOGICAL RECORD AT A

    TIME.

    RECORDMODE is the default for ESDS, KSDS, and RRDS.

    CIMODE CI rather than logical record exports data. CIMOD isdefault for LDS.

    TEMPORARY The data set is not deleted after export.

    PERMANENT- The data set is deleted after export.

    iFrames Technologies 41

    Catalog Data set

    EXPORT

  • 7/27/2019 51214566 VSAM Handout

    42/60

    Mainframe VSAM

    INHIBITSOURCE The original data set becomes read-only.

    NOINHIBITSOURCE- The original data can be updated.

    INHIBITTARGET- The copy data set becomes read-only.

    NOINHIBITTARGET- The target data set can be updated.

    ERASE - Causes the exported item to be overwritten with zeros

    when it is deleted.

    NOERASE Override whatever was specified for the item when it

    was created.

    Example:

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //DD1 DD DSN=IFMAIN2.BACKUP.PS,

    // DISP=(NEW,CATLG,DELETE),

    // UNIT=SYSDA,

    // SPACE=(TRK,(2,3),RLSE), // DCB=(LRECL=80,RECFM=FB,BLKSIZE=800,DSORG=PS)

    //SYSIN DD *

    EXPORT-

    IFMAIN2.KSDS.CLUSTER-

    OUTFILE(DD1)

    /*

    //

    Now the above exported file is not available in user catalog. It ispermanently exported to the new PS which is created. To get back the

    exported cluster we want to use import option to get back it in our usercatalog. This is illustrated in the following snapshots.

    SYNTAX OF IMPORT

    IMPORT-

    {INFILE(DDNAME) | INDATASET(ENTERYNAME)}

    {OUTFILE(DDNAME) | UTDATASET(ENTERYNAME)} -

    [OBJECTS((ENTERYNAME - [NEWNAME(NAME)] -

    VOLUMES(VOLSER])[ENTRYNAME.)])]

    [INTOEMPTY]

    NEWNAME Objects beginning imported can be renamed.

    VOLUMES Specifies the volume on which the cluster is to reside ifomitted the original volume is the receiving

    volume

    INTOEMPTY Indicates that the receiving dataset is empty.

    iFrames Technologies 42

  • 7/27/2019 51214566 VSAM Handout

    43/60

    Mainframe VSAM

    On IMPORT the existing catalog entry is deleted unless the receiving data set

    is empty.

    The following procedure provides backup and recovery capabilities and alsopermits the modification of data set attributes when the data set is imported

    during recovery or reorganization.

    iFrames Technologies 43

    Catalog Data set

    IMPORT

  • 7/27/2019 51214566 VSAM Handout

    44/60

    Mainframe VSAM

    Example:

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //DD1 DD DSN=IFMAIN2.BACKUP.PS, //SYSIN DD *

    IMPORT-

    INFLIE(DD)-

    OUTDATASET(IFMAIN2.KSDS.CLUSTER)

    /*

    //

    VERIFY COMMAND

    Verifies the catalog HURBA (High Used Relative Byte Address) field and storesthe true values from the control block HURBA field.

    It should be used against cluster name only and not against data or indexcomponents.

    It is used to rectify some of the problems due to data corruption

    It can be issued from TSO or from a JCL

    Syntax: VERIFY FILE ()

    iFrames Technologies 44

    STEP 1EXPORT

    STEP 4IMPORTINTOEMPTY

    ORIGINALMASTER

    STEP 2DELETE

    STEP 3DEFINE NEW

    MASTER

  • 7/27/2019 51214566 VSAM Handout

    45/60

    Mainframe VSAM

    VERIFY DATASET ()

    Compares Catalog Information with the Data Set

    Corrects Catalog If A Disagreement Is Found

    Run VERIFY after a system failure.

    When sharing data sets, run VERIFY before opening a data set.

    VERIFY cannot be used for an empty data set or an LDS.

    Example:

    //IFMAIN2 JOB NOTIFY=&SYSUID

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

    //SYSOUT DD SYSOUT=*

    //SYSIN DD *

    VERIFY DATASET(IFMAIN2.KSDS.CLUSTER)

    /*

    //

    LISTCAT

    LISTCAT Command identify the catalog, the names of the entries to be

    listed, the types of entries to be listed, and the amount of information about

    each entry to be listed.

    LISTCAT [ CATALOG (name) ]

    [ ENTRIES (name - of - entries) ]

    [LEVEL (generic-level-names)]

    [ NAME/HISTORY/VOLUME/ALLOCATION/ALL}]

    iFrames Technologies 45

    TEST.DATA.SETEND-OF-DATA

    END-OF-KEY-RANGE

    END-OF-DATA

    END-OF-KEY-RANGE

    ?

  • 7/27/2019 51214566 VSAM Handout

    46/60

    Mainframe VSAM

    Catalog(name[/password]) Specifies the name and if, required,

    password of the catalog from whichentries are to be listed.

    ENTRIES(entry-name[/password]) Specifies the names of the entries youwant to list. If omitted, all entries in

    the specified catalog are listed.

    LEVEL(level) Specifies one or more levels of

    qualifications. Any data sets whose namematches those levels are listed.

    Entry type Specifies the type of entries you wantlisted. If both ENTRIES / LEVEL and

    entry-type are omitted, all

    entries of all types in thespecified catalog are listed. Code one of these

    values: ALIAS, CLUSTER, DATA, INDEX, & PATH

    NAME Specifies that only the names and types ofthe specified entries are to be listed.

    Name is the default. HISTORY Specifies that the information listed by

    NAME, Plus the history information(such as creation and expiration dates) is

    to be listed.

    VOLUME Specifies that the information listed by

    HISTORY, plus the volume locations ofthe specified entries, is to be listed.

    ALLOCATION Specifies that the information listed byVOLUME, plus detailed extent

    information, is to be listed.

    ALL Specifies that all available catalog

    information for the specified entries is to be

    listed.

    Examples

    To list the catalog entry for a VSAM file namedMTRG.CUSTOMER.MASTER

    ENTRIES (MTRG.CUSTOMER.MASTER)

    To list information for more than one file, just code several file names

    in a single ENTRIES parameter, like this:

    ENTRIES (MTRG.CUSTOMER.MASTER -

    MTRG.SUPPLIER.MASTER -

    MTRG.ITEM.TRANS)

    We can specify a generic entry name by replacing one or more levels

    of the file name with an asterisk.

    ENTRIES (MTRG.*.MASTER)

    All files whose names consists of three levels with MTRG as the firstlevel and MASTER as the third level, are listed. MTRG.CUSTOMER.MASTER

    AND MTRG.SUPPLIER.MASTER meet these criteria, so they would be listed.

    iFrames Technologies 46

  • 7/27/2019 51214566 VSAM Handout

    47/60

    Mainframe VSAM

    Example:

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //SYSIN DD *

    LISTCAT ENTRIES(IFMAIN2.VSAM.PDS)

    LISTCAT ENTRIES(IFMAIN2.VSAM.*)

    /*

    //

    ALTER

    We can use this powerful command to change certain attributes of

    previously defined VSAM object. These objects include base cluster and itsdata and index component and even alternate index cluster and its data or

    index component and even a VSAM or ICF catalog. If you are properlyauthorized you can ALTER NON-VSAM data set attributes also.

    SYNTAX OF ALTER COMMAND

    ALTER entryname[/password] -

    SHAREOPTION(cross region cross system)

    Examples: ALTER MTRG.CUSTOMER.MASTER -

    NEWNAME(MTRG.CUSTMAST)

    ALTER EMPLOYEE.KSDS.CLUSTER

    FREESPACE(25,25)

    Change the filename of MTRG.CUSTOMER.MASTER to MTRG.CUSTMAST

    iFrames Technologies 47

    ALTER EXAMPLE.KSDS

    SHAREOPTIONS(2 3)

    CATALOG CATALOG

    EXAMPLE.KSDS

    SHAREOPTIONS(13)

    EXAMPLE.KSDS

    SHAREOPTIONS(23)

  • 7/27/2019 51214566 VSAM Handout

    48/60

    Mainframe VSAM

    ALTER MTRG.CUSTOMER.MASTER.DATA -

    ADDVOLUMES(VOL291 VOL292) -

    REMOVEVOLUMES(VOL 281 VOL 282)

    Add VOL291 and VOL292 to list of eligible volumes forMTRG.CUSTOMER.MASTER.DATA and remove VOL281 and VOL282.

    Example:

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //SYSIN DD *

    ALTER IFMAIN2.KSDS.DATA

    NEWNAME(IFMAIN2.VSAM.KSDS)

    /*

    //

    Likewise we can alter the other data attributes like:

    ADDVOLUME

    ATTEMPTS

    SHAREOPTIONS

    BUFFERSPACE

    FREESPACE

    PASSWORD

    ENTRY NAME is the cluster, data or index component name.

    PASSWORD is the master password if the VSAM data set is passwordprotected

    ALTERcan also be used as a migration path to change an ESDS to LDS

    ALTER with ADDVOLUME/REMOVEVOLUME

    ADD VOLUME:

    //ALTJOB JOB ,,NOTIFY=userid //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSIN DD *

    ALTER -

    USER1.KSDS.DATA -

    ADDVOLUMES(VS012)

    iFrames Technologies 48

  • 7/27/2019 51214566 VSAM Handout

    49/60

    Mainframe VSAM

    REMOVE VOLUME:

    ALTER

    USER1.KSDS.DATA -

    REMOVEVOLUME(RTD2)

    ALTER WITH FREESPACE

    ALTER entryname[/password] -

    FREESPACE(CI-percent[ CA-percent]))

    Example:

    //ALTJOB JOB .

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSIN DD *

    ALTER - USER1.KSDS.DATA -

    FREESPACE(30 30)

    Entryname must be the name of the clusters data component.

    This procedure has the following advantages.

    It prevents wasting space.

    It minimizes CI and CA splits.

    ALTERING PASSWORD

    Adding/Changing PASSWORD

    ALTER entryname[/password] -

    [READPW (password)] -

    [UPDATEPW (password)] -

    [CONTROLPW (password)]-

    [MASTERPW (password)]

    Nullifying PASSWORD

    ALTER entryname[/password] -

    NULLIFY - [READPW] -

    [UPDATEPW] -

    [CONTROLPW] -

    [MASTERPW ]

    DELETE COMMAND

    iFrames Technologies 49

  • 7/27/2019 51214566 VSAM Handout

    50/60

    Mainframe VSAM

    DELETE command is used to remove entries from a VSAM catalog. To

    delete more than one file, list the names in parentheses. The IDCAMS DELETEcommand can be used to delete both VSAM and non-VSAM objects

    SYNTAX:

    DELETE entry name/password

    Example 1 We can specify a generic name in a DELETE command by replacing

    ONE level of the entry name with an asterisk, like this

    DELETE MTRG.CUSTOMER.*

    Example 2

    To delete MTRG.CUSTOMER.MASTER, whether or not it is expired.

    DELETE MTRG.CUSTOMER.MASTER

    PURGE

    Example 3

    To delete the 3 named files.

    DELETE ( MTRG.CUSTOMER.MASTER -

    MTRG.CUSTMAST.AIX -

    MTRG.CUSTMAST.PATH)

    Example:

    //IFMAIN2 JOB NOTIFY=&SYSUID

    //STEP1 EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT=*

    //SYSOUT DD SYSOUT=*

    //SYSIN DD *

    DELETE IFMAIN2.KSDS.CLUSTER

    /*

    //

    Some other options for Delete are:

    ALIAS

    ALTERNATEIND

    CLUSTER

    SPACE

    PURGE

    PATH

    REVIEW QUESTIONS:

    1. The default print format is:a. character

    b. dump

    c. hexadecimal

    d. none of the above.

    e. 2. Which of the following repro selection parameters can be specified

    for an LDS?

    A. from key

    iFrames Technologies 50

  • 7/27/2019 51214566 VSAM Handout

    51/60

    Mainframe VSAM

    B. from address

    C. from number

    D. skip

    E. none of the above

    F. 3. The replace parameter causes:

    a. KSDS records to be replaced by an input record with the same key

    b. ESDS records to be replaced by an input record with the same RBA

    c. RRDS records to be replaced by an input record with the same RRN

    d. a) and c)

    e. all of the above

    f. 4. Generic keys can be specified in PRINT FROM KEY and TOKEY

    A. TRUE

    B. FALSE

    C. 5. REPRO will stop processing records when a total of four

    physical I/O errors occur while writing to the output data set.

    A. TRUE

    B. FALSE

    C. 6. Which of the following is not a valid command?

    a. IF

    b. THEN

    c. ELSE

    d. DO

    e. GOTO

    f. 7. REPRO REUSE against a non-empty target data set with NOREUSEwill reset the target data set.

    A. TRUE

    B. FALSE

    C. 8. Can VSAM files be deleted with the DELETE option of the

    DISPOSITION parameter of JCL?

    D. 9. During processing of a VSAM file, some system erroroccurs and it is subsequently unusable What do you do?

    E.

    F.

    G. CHAPTER --- 7 : Alternate Indexes

    H. An alternate index is used to an access the records of aVSAM key-sequenced data set in an order other than the files

    primary key (or base key). The data set over which analternate index exists is called a base cluster. Even we can

    use an entry-sequenced data set as the base cluster for analternate index, most alternate indexes are built over KSDS

    clusters. Used whenever the data is required to be retrieved

    iFrames Technologies 51

  • 7/27/2019 51214566 VSAM Handout

    52/60

    Mainframe VSAM

    on the basis of other field (than primary key field). Analternate index cannot be defined for RRDS or LDS

    I.

    J.

    K. MULTIPLE ALTERNATE INDEXES (AIXs) may be defined over a

    base cluster.

    L. If the user is sequentially retrieving records using AIX1,then department number retrieves records in logical sequence

    Access via AIX2 with an alternate key of social security

    number results in the retrieval of base cluster records insocial security number sequence.

    M. ADVANTAGES

    Can be defined for both KSDS & ESDS

    Reduce data redundancy

    Can have duplicates Easy to define using IDCAMS

    Allow datasets to be accessed sequentially or randomly

    Can be updated automatically

    DISADVANTAGES

    Performance degradation

    Complex update logic

    iFrames Technologies 52

    ALTERNATEINDEX 1(DEPT NO)

    ALTERNATEINDEX 2(SOCIAL SECNO)

    3235 NEWTON $3240 WRIGHT $..3247 ADAMS $..3247 PETTY $

    ADAMS 3247 $ARNOLD 4711 $KINNEY 3247 $NEWTON 3235 $..

    015-35-78183-96-41

    234-04-23

    BASECLUSTER(NAME)

  • 7/27/2019 51214566 VSAM Handout

    53/60

    Mainframe VSAM

    NEED FOR ALTERNATE INDEX:

    Alternate Indexes save sorting or maintaining duplicate data thatmight otherwise be required.An alternate index cannot be defined for an

    RRDS or LDS

    KSDS

    A. ACCESS A KSDS BY KEY OTHER THAN THE PRIMARY KEY

    1. SOCIAL SECURITY NUMBER

    2. DEPARTMENT NUMBER

    3. EMPLOYEE NUMBER4. ZIP CODE

    5. B. ACCESS AN ESDS BY KEY

    6.

    7. ALTERNATE INDEX DATA RECORD FORMAT

    8.

    9.

    10.

    11.

    12.

    13.

    14.

    15.

    16.

    17.

    18. Each AIX data record is variable length and contains system

    header information, the alternate key and at least one pointer to the

    iFrames Technologies 53

    PRIME KEY LENGTH *

    NUMBER NONUNIQUE

    PRIME KEYSRECORD = 5 + ALTERNATE KEY + -0R-

    SIZE LENGTH 4 *NUMBER

    NONUNI UE POINTERS

    INDEX:EMPLOYEE NAME

    DATA:

    EMPLOYEE RECORDS

  • 7/27/2019 51214566 VSAM Handout

    54/60

    Mainframe VSAM

    base cluster. AIX s are spanned record data sets, since there may bemany base cluster records associated with a given alternate key.

    19. Pointers to the base cluster are of two forms, either an RBA (foran ESDS base cluster)or a prime key for a ksds base cluster).The

    pointers are the same type throughout the entire AIX.

    20.

    21.ALTERNATE INDEX ORGANIZATION

    Alternate Indexes are KSDS by themselves and have their own data and indexcomponents

    AIX data components contain the alternate index key values and pointers toeach record containing the key value

    AIX index components contain highest key value in an AIX data CI and a

    pointer to that CI

    AIX data component has variable length records if duplicate is allowed (due tomultiple pointers)

    STEPS FOR CREATING ALTERNATE INDEX

    Define AIX using IDCAMS DEFINE AIX

    Build AIX & populate it using IDCAMS BLDINDEX

    Specify Alternate Index Path using IDCAMS DEFINE PATH

    CREATING AN ALTERNATE INDEX

    DEFINE ALTERNATEINDEX-

    (NAME(AIX NAME)-

    RELATE(BASE CLUSTER NAME)-

    KEYS (LENGTH OFFSET)- UNIQUEKEY/NONUNIQUEKEY-

    UPGRADE/ NOUPGRADE

    RECORDSIZE (AVG MAX)-

    VOL (VOLSER)

    CYL/TRK/REC(PRI SEC))

    NAME

    Syntax: NAME

    Required parameter: Specifies the name of AIX

    VOLUMES

    Syntax: Volumes (Vol-ser-1 ..... vol-ser-n)

    Required parameter: Assigning base cluster & AIX in different volumesimproves performance

    RELATE

    Syntax: RELATE (base cluster name)

    iFrames Technologies 54

  • 7/27/2019 51214566 VSAM Handout

    55/60

    Mainframe VSAM

    Required parameter: Establishes relationship between the base cluster & AIX

    UPGRADE/NOUPGRADE

    Syntax: UPGRADE/NOUPGRADE

    UPGRADE specifies that records in AIX are to be updated automatically

    whenever the base cluster is updated .The use of UPGRADE makes thealternate index part of the clusters so called UPGRADE SET

    Default: UPGRADE

    AIX 1

    AIX 2 AIX 3

    Base cluster

    KEYS

    Syntax: KEYS (length offset)

    Optional: primary key values are taken as default, if not specified.Defeats the

    purpose of Alternate Index, if not specified

    RECORD SIZE

    Syntax: RECORD SIZE (average maximum)

    Default: RECORDSIZE (4086 32600)

    Abbr: RECSZ

    Average & max. Are same for UNIQUEKEY AIX and may be different forNONUNIQUEKEY

    HOW TO CALCULATE THE RECORD SIZE?

    iFrames Technologies 55

  • 7/27/2019 51214566 VSAM Handout

    56/60

    Mainframe VSAM

    AIX for a KSDS RECSZ = 5 + AIXKL + (n x BCKL)

    AIX for ESDS RECSZ = 5 + AIXKL + (n x 4)

    Where:

    AIXKL is the alternate-key length

    BCKL is the base cluster's prime-key length

    n = 1 when UNIQUEKEY is specified

    n = the number of data records in the base cluster that contain the

    same alternate-key value, when NONUNIQUEKEY is specified.

    Other AIX parameter

    ATTEMPTS

    AUTH (entry point)

    BUFFERSPACE (bytes)

    CATALOG (catalog/pw)

    CODE (code) CISZ (bytes)

    CONTROLPW (password)

    ERASE (NOERASE)

    EXCEPTIONEXIT (entry point)

    KEYRANGES (low-key high key)

    MASTERPW (password)

    ORDERED/UNORDERED

    READPW (password)

    REPLICATE/NOREPLICATE

    REUSE/NOREUSE

    SHAREP[TOPMS

    SPEED/RECOVERY

    UNIQUEKEY/NONUNIQUEKEY

    UPDATEPW (password)

    WRITECHECK/NOWRITECHECK

    EXAMPLE:

    //STEP1 EXEC PGM =IDCAMS

    //SYSPRINT DD SYSOUT = *

    //SYSIN DD * DEFINE ALTERNATEINDEX(USER1.KSDS.AIX)-

    VOLUME(V001) -

    RELATE(USER1.KSDS.CLUSTER)-

    UPGRADE-

    CYLINDERS(2 1)-

    KEYS(25 9)-

    iFrames Technologies 56

  • 7/27/2019 51214566 VSAM Handout

    57/60

    Mainframe VSAM

    RECORDSIZE(70 110)-

    FREESPACE(20 10)-

    NONUNIQUEKEY-

    DATA

    (NAME(USER1.KSDS.AIX.DATA))-

    INDEX

    (NAME(USER1.KSDS.AIX.INDEX))

    BUILD INDEX

    SYNTAX:

    BLDINDEX

    {INFILE(ddname) / INDATASET (base cluster name)} -

    {OUTFILE(ddname) / OUTDATASET (AIX NAME)} -

    [EXTERNALSORT / INTERNALSORT] -

    [WORKFILES(ddname ddname) ] INFILE /INDATASET IDENTIFIES THE BASE CLUSTER.

    OUTFILE / OUTDATASET IDENTIFIES THE AIX TO BE LOADED

    INTERNALSORT Requires AMS to build the Alternate Index Records

    within the users address space if possible

    EXTERNALSORT Indicates that two ESDS work Files are to be used by

    AMS for the sort

    WORKFILES Specifies The DD names to be used instead of the defaultNames

    EXAMPLE BLDINDEX INDATASET(USER1.KSDS.CLUSTER)-

    OUTDATASET(USER1.KSDS.AIX)

    CREATION OF PATH

    Once you have defined any alternate indexes, You must define a separatepath for each one, using the IDCAMS DEFINE PATH command.

    This path name is the dataset name that you use in the jcl when processingan alternate index. It is a separate catalog entry and forms a logical

    connection(path) through the alternate index to the base cluster

    A path is a catalog record. It is normally used to relate the alternate index

    and the base cluster

    IDCAMS DEFINE PATH is used to create a path record in the catalog.

    SYNTAX:

    DEFINE PATH(NAME(PATH NAME) -

    PATHENTRY(AIX NAME) -

    iFrames Technologies 57

  • 7/27/2019 51214566 VSAM Handout

    58/60

    Mainframe VSAM

    UPDATE / NOUPDATE)

    NAME specifies the name of the PATH.

    PATHENTRY associates the AIX with the path name.

    UPDATE / NOUPDATE specifies whether all of the upgrade setshould be maintained by VSAM when accessing through this path

    EXAMPLE:

    DEFINE PATH ( -

    NAME(USER1.KSDS.PATH)

    PATHENTRY(USER1.KSDS.AIX)-

    UPDATE )

    ALTERNATE INDEX FOR ESDS

    Same syntax & parameters as KSDS

    Not supported in Batch COBOL (OS/VS & VSII)

    Used under CICS environment Step 2: BUILDING THE INDEX

    BLDINDEX Command actually builds the index and populates it with

    records

    //BLDINDX EXEC PGM=IDCAMS

    //SYSPRINT DD SYSOUT = *

    //DD1 DD DSN=XIND.NLT.VSAM,DISP=OLD

    //DD2 DD DSN=XIND.NLT.VSAM.DEPT.AIX,DISP=OLD

    //IDCVT1 DD DSN=XIND.NLT.WRKFILE1, DISP=OLD

    //IDCVT2 DD DSN=XIND.NLT.WRKFILE2, DISP=OLD //SYSIN DD *

    BLDINDEX INFILE (DD1) OUTFILE (DD2) -

    INTERNALSORT

    /*

    Step 3: SPECIFYING THE ALTERNATE INDEX PATH

    Example:

    DEFINE PATH -

    (NAME(XIND.NLT.VSAM.DEPT.PATH) -

    PATHENTRY -

    (XIND.NLT.VSAM.DEPT.AIX) UPDATE)

    - Path is a VSAM object though it doesnt contain any records

    - Same command for KSDS & ESDS

    - Path is used to link JCL DSN to VSAM AIX (specifies that the given AIX is tobe used).

    NAME

    Syntax: NAME (pathname). Pathname becomes the DSN in the run JCL

    iFrames Technologies 58

  • 7/27/2019 51214566 VSAM Handout

    59/60

    Mainframe VSAM

    PATHENTRY

    Syntax: PATHENTRY (entry name/password).

    Entry name: name assigned to alternate index cluster. Required for an

    alternate index

    RESTRICTIONS FOR ALTERNATE INDEX

    No Alternate Index For RRDS and LDS.

    Base Cluster Must Not Be Empty For Buildindex.

    Length Of The Alternate Index Not Exceed 255

    Maximum Number Of Alternate Key Pointers Is 32k.

    Records Larger Than 32760 Not Supported By Repro/Export.

    For A Base Cluster With Alternate Index(Es) And Path(S),Delete Cluster

    Deletes Not Only The Base Cluster But Also The Associated Alternate Index

    Maximum Alternate Indexes Can Be 253 For A Single Dataset(ESDS&KSDS)

    REVIEW QUESTIONS:

    1. An alternate index can be defined for which cluster type(s)?

    a.) KSDS AND RRDS

    b) KSDS AND ESDS

    c) KSDS only

    d) KSDS,ESDS AND RRDS.

    2. The size of an alternate index is about the same of its base cluster.

    a) true

    b)false

    iFrames Technologies 59

  • 7/27/2019 51214566 VSAM Handout

    60/60

    Mainframe VSAM

    3. If an application program accesses a base cluster in alternate key

    sequence,

    then DD statements are needed for which data set(s)?

    a) Base cluster

    b) alternate index

    c) path

    d) (a) and(b)

    e) (a) and c

    4. An alternate index itself is which cluster type?

    a) LDS

    b) RRDS

    c) ESDS

    d) KSDS

    e) NONE OF THE ABOVE.

    5 An alternate index is a spanned record dataset. a) true

    b)false

    6) A path is required so that an application program base cluster keysand retrieve alternate records.

    a) true

    b) false

    7) Is it slower if you access a record through ALTERNATIVE INDEX as

    compared to Primary INDEX?

    8) What could be the maximum number of the AIXs per base cluster?

    9) Can AIX be defined over an ESDS, which does not have any Key?

    10) What is an Alternate Index?

    11) What are the steps used to create an Alternate Index?

    12) What are the restrictions to be considered while creating an Alternate

    Index?