Access Method Services (AMS) - IBM Mainframe

As mentioned briefly before. Access Method Services (AMS) is used to perform various functions on VSAM data sets and catalogs. AMS has a utility program called IDCAMS that can be invoked through a standard JCL and will perform the various functions of the AMS through its commands. The most commonly used AMS commands are:

  • DEFINE USERCATALOG/MASTERCATALOG - This command is used by system programmers to define a VSAM catalog. A user catalog has to be allocated and cataloged in a master catalog prior to defining VSAM data sets in it.
  • DEFINE SPACE - This command allocates VSAM space on a particular disk pack. This space is subsequently used to define sub-allocated VSAM data sets within it.
  • DEFINE CLUSTER - This command allocates and catalogs a VSAM data set. For a KSDS, it allocates both the data and index components.
  • REPRO - This command is used to load records into a VSAM data set. It is similar in some respects to the IEBGENER utility.
  • DEFINE ALTERNATE INDEX - This command is used to define an alternate index for a KSDS or an ESDS. This command only allocates the space for the alternate index and the records can be loaded into only by using the BLDINDEX command. The base cluster has to be defined to prior to defining the alternate index.
  • BLDINDEX - As mentioned before, the alternate key-pointer pair records are loaded into the alternate index cluster by this command. Therefore, the base cluster has to be defined and loaded and the alternate index defined before using this command.
  • PRINT - This command can be used to print a VSAM data set. It can also be used to print physical sequential, partitioned data set members, etc.
  • VERIFY - During abnormal terminations of the system, VSAM files open at that time will be left open. This command closes the files, brings the index component in sync with the data components and updates the catalog.
  • DELETE - As the name of the command implies, this command can be used to delete a VSAM cluster. It can also be used to delete non-VSAM files. VSAM files cannot be deleted with the DELETE option of the DISPOSITION parameter of JCL.
  • ALTER - This command can be used to alter certain parameters used while creating a VSAM cluster without actually delete-defining the data set.
  • DEFINE GDG - You can define* Generation Data Group (GDG) index using this command. A GDG is a logical grouping of sequential files under the GDG index. For example, the monthly payroll file for each month can be defined as a GDG index XYZ.COMPANY.PAYROLL.MONTHLY. Then you can use the following references in a JCL:
  • XYZ.COMPANY.PAYROLLMONTHLY(O) would refer to the latest generation of this Generation Data Group
  • XYZ.COMPANY.PAYROLLMONTHLY(-I) would refer to the previous generation of this Generation Data Group
  • XYZ.COMPANY.PAYROLL.MONTHLY(+1) will allocate a new generation for the next month
  • LISTCAT - This command lists the different attributes of a VSAM data set.

JCL for Invoking Access Method Services

A skeleton JCL to invoke IDCAMS is given below.

JCL for Invoking Access Method Services

The IDCAMS functional commands with all the right parameters are specified in the SYSIN DD part of the JCL as illustrated above. It can be specified in-stream or in a data set. All functional commands and their parameters must start in or after the second column and cannot extend beyond the 72nd column. The AMS messages will go to the SYSPRINT data set.

If a functional command extends to the next line, a continuation character, in AMS a hyphen must be entered on the previous line. Comments can also be given within a functional command if enclosed within a "/*" and a "*/".

Defining a KSDS Cluster

The update routine is an example of KSDS clusters, and the display routine is an example of both KSDS clusters and alternate indexes.

For these examples, the clusters and alternate indexes should be defined as follows:

  • The KSDS cluster has a record size of 150 with a key length of 4 with offset 0.
  • The unique KSDS AIX has a key length of 20 with an offset of 10.
  • The non-unique KSDS AIX has a key length of 40 with an offset of 30.

The update routine is passed the following:

  • data_ptr, which points to the information that is to be updated
  • orig_data_ptr, which points to the information that was originally displayed using the display option
  • A file pointer to the KSDS cluster

The display routine is passed the following:

  • data_ptr, which points to the information that was entered on the screen for the search query
  • orig_data_ptr, which is returned with the information for the record to be displayed if it exists
  • File pointers for the primary cluster, unique alternate index and non-unique alternate index

By definition, the primary key is unique and therefore the employee number was chosen for this key. The user_id is also a unique key; therefore, it was chosen as the unique alternate index key. The name field may not be unique; therefore, it was chosen as the non-unique alternate index key.

Suppose you want to define a KSDS data set for an Customer Information system.

Let us say the layout of each customer record is:

  • Customer number - A 6 digit number that uniquely identifies a customer - Primary Key
  • Customer name -10 characters
  • Customer address -15 characters
  • Sex -1 character - M or F
  • Date of Birth - 10 characters - dd/mm/yyyy

The layout of the customer record is shown in the following figure.

Layout of the Customer Record

Layout of the Customer Record

The JCL for allocating the KSDS data set is given below:

Take a screenshot

The first 6 bytes, which is the customer no, is the primary key of the record. Note the use of hyphen (-) as the continuation character. This indicates that the AMS command is not yet complete and that the following line should be treated as a continuation of the previous line.

Let us examine the JCL line by line.

  • Line 1 - The JOB card may be different depending on installation standards
  • Line 2 - The EXEC statement invokes the Access method services
  • Line 3 - The SYSPRINT will contain all messages from the AMS program
  • Line 4 - The SYSIN card indicates that the in-stream data containing the functional commands and their parameters follow
  • Line 5 - DEFINE cluster is the functional command used to allocate a VSAM data set
  • Line 6 - The NAME parameter indicates the name of the KSDS VSAM cluster. Note that one of the parentheses is left open
  • Line 7 - The VOLUMES parameter indicates the volume serial on which the space for the cluster will be allocated
  • Line 8 - The CYLINDERS parameter indicates that 10 cylinders of primary space will be allocated. When this space is used up secondary space will be allocated in increments of 2 cylinders each
  • Line 9 - The CONTROLINTERVALSIZE (CISZ) for the cluster will be 4096 bytes
  • Line 10 - The FREESPACE parameter means that at the time of initial loading, each control interval will have 10 percent of its space left free and that 20 percent of control intervals in each control area will be left unused
  • Line 11 - The KEYS parameter indicates that the primary key is 6 bytes long and starts at position 0 (first byte) of the record
  • Line 12 - RECORDSIZE parameters indicate the average and maximum record lengths in that order. For fixed-length records, they will have the same value.
  • Line 13 - DATA indicates the beginning of the data component parameters
  • Line 14 - NAME indicates the name of the data component of the cluster
  • Line 15 - INDEX indicates the beginning of the index component parameters
  • Line 16 - NAME indicates the name of the index component of the cluster
  • Line 17 - CONTROLINTERVALSIZE specifies the control interval size of the index component. It is prudent to omit this parameter, as AMS would use the optimal value.
  • Line 18 - Note that the in-stream data is terminated with a "/*" delimiter

If this JCL were executed after being customized to your installation standards, a KSDS cluster CUSTOMER.KSDS.CLUSTER would be allocated. The allocation messages would be in the SYSPRINT device Note that we have just created the cluster and it will still be empty. You would have to load records into the cluster using a program or the REPRO command. This will be discussed in a later section. Note that there are more extensive options for allocation of a KSDS cluster. Refer to an IBM manual for details.

Defining an ESDS Cluster

Defining an ESDS is very similar to that of a KSDS except for the following differences. Since ESDS does not have imbedded free space, the FREESPACE parameter is not used

  • The KEYS parameter has no meaning in the context of KSDS
  • Since ESDS has no index component, the INDEX parameter is not used
  • An additional parameter, NONINDEXED is used to tell AMS that an ESDS is being allocated.

Defining an ESDS Cluster

If this JCL is executed after being customized to your installation standards, an ESDS cluster CUSTOMER.ESDS.CLUSTER would be allocated. Note that if the NONINDEXED parameter is omitted AMS would assume the default value INDEXED and allocate a KSDS cluster with default values for FREESPACE, KEYS, index component etc.

Defining an RRDS Cluster

Defining an RRDS is very similar to that of an ESDS except for the following differences.

  • You specify NUMBERED instead of NONINDEXED is used to tell AMS that an RRDS is being allocated.
  • Since RRDS does not support variable length records, the- average and maximum length of the records must be the same.

Defining an RRDS Cluster

If this JCL were executed after being customized to your installation standards, an RRDS cluster CUSTOMER.RRDS.CLUSTER would be allocated. Note that if the NUMBERED parameter were omitted AMS would assume the default value INDEXED and again allocate a KSDS cluster with default values for FREESPACE, KEYS, index component etc.

Defining an LDS Cluster

It should be recalled that an LDS is very similar to an ESDS except for that it doesn't have any control fields in a Control interval. Defining an LDS is very similar to that of an ESDS except for the following differences.

  • You specify LINEAR instead of NONINDEXED is used to tell AMS that an RRDS is being allocated.
  • You need not specify CONTROL1NTERVALSIZE since it can only be 4096 bytes.

Defining an LDS Cluster

If this JCL were executed after being customized to your installation standards, an LDS cluster CUSTOMER.LDS.CLUSTER would be allocated. Note that the RECORDS1ZE parameter is omitted because an LDS doesn't have any concept of a record. It is just a long stream of characters.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM Mainframe Topics