Introduction
What is AMS?
An access method represents the process that is used to store and retrieve data from the datasets or files. Access Method Services (AMS) is a utility mainly used to define and handle VSAM datasets and integrated catalogs.
What is IDCAMS?
IDCAMS (Integrated Data Cluster Access Method Services) is the utility program uses access method services (AMS) that is used to create, modify and delete the VSAM datasets. The functions of AMS are performed through the different functional commands of IDCAMS.
IDCAMS Functions -
IDCAMS is mainly a mainframe-related utility used to process or manipulate VSAM datasets or non-VSAM datasets with the help of JCL. It allows performing the following tasks -
- Define, alter, copy, and delete datasets.
- List catalogs, catalog entries, or datasets.
- Define and build alternate indexes.
- Back up and restore VSAM datasets.
- Print the contents of datasets.
- Collect information about datasets.
- Examine the structural consistency of VSAM KSDS.
- Set cache parameters for DASD devices.
- Retrieve Direct Access Storage Device (DASD) information.
- List tape volume (VOLCAT) catalog entries.
- Detect and diagnose catalog errors.
- Recover from catalog errors.
- Define system-managed libraries and volumes.
- Detect VSAM dataset problems.
- Encrypt and decrypt datasets.
- Turn VSAM Record Level Sharing (RLS) on and off.
Invoking IDCAMS Utility -
IDCAMS utility is invoked in the following three ways -
- Batch mode (With the help of JCL).
- With TSO commands.
- Call from the program - A program requires PPI (Problem Program Interface) to invoke IDCAMS.
Batch mode (With the help of JCL) -
We can run IDCAMS as a batch job with the help of JCL as shown below -
//JOBNAME JOB job-card-parameters
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN DD *
AMS commands and their parameters
/*
- SYSPRINT DD statement - contains the result of the coded AMS command.
- SYSIN DD statement - specifies a file or instream procedure that contains IDCAMS AMS commands.
With TSO commands -
The ISPF Command Shell (option 6 from the ISPF main menu) is the best option to use the IDCAMS command interactively. The command can be triggered like below -
The output is -
- NONVSAM - used to specify sequential or non-vsam files.
- VSAM - used to specify vsam files.
For example - to refer "MATEPK.IDCAMS.JCLLIB", it should code as "IDCAMS.JCLLIB".
How to validate the IDCAMS return code?
The return code or condition code are used to indicate the result of the command and helps in what to do next. There are two return codes to validate the job completion status, and those are -
Return Code | Description |
---|---|
Last Condition Code (LASTCC) | LASTCC provides the return code of the last executed AMS command. Each command executed has one dedicated LASTCC. |
Maximum Condition Code (MAXCC) | MAXCC provides the maximum return code of the entire JOB execution, which may contain one or more commands. One IDCAMS utility step may contain one or more commands. MAXCC is the highest return code of the multiple LASTCC. |
IDCAMS sets LASTCC at the command level and MAXCC at the step level. If JOB contains only one command with the IDCAMS, both LASTCC and MAXCC have the same return code.
Following are the return codes set by the IDCAMS -
- 0 (Normal Completion) - Specifies that the AMS command successfully finished its processing.
- 4 (Minor Error) - Specifies processing can continue further. However, a minor error occurred that resulted in issuing a warning message.
- 8 (Major Error) - Specifies processing can continue further. However, a more severe error resulted in major command specifications being bypassed.
- 12 (Logical Error) - Specifies that inconsistent parameters are coded, which causes the entire command to be bypassed.
- 16 (Severe Error) - Specifies a severe error that causes the entire AMS command stream to be flushed, not only the command causing the error.
Example -
Scenario - Let us take an example of creating ESDS and deleting the same in the same step to demonstrate the LASTCC and MAXCC.
JCL -
----+----1----+----2----+----3----+----4----+----5----+
//MATEPKE JOB (123),'MTH',CLASS=A,MSGCLASS=A,
// MSGLEVEL=(1,1),NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER(NAME(MATEPK.TEST.ESDS) -
RECORDSIZE(47,47) -
CYLINDERS(2,1) -
CISZ(4096) -
VOLUMES(DEVHD4) -
NONINDEXED -
REUSE ) -
DATA(NAME(MATEPK.TEST.ESDS.DATA))
DELETE 'MATEPK.TEST.ESDS'
/*
Output -