IDCAMS (Integrated Data Cluster Access Method Services) is the mainframe utility that provides Access Method Services (AMS) for VSAM. It is the single utility used to create, alter, delete, list, copy, and manage VSAM datasets and catalog entries. You run IDCAMS in batch jobs (with PGM=IDCAMS and commands in SYSIN), from TSO, or from a program via the Problem Program Interface. Understanding what IDCAMS is and what it can do is essential for anyone who defines or maintains VSAM files. This page explains what IDCAMS is, what functions it provides, how you run it, and how to interpret return codes.
Access Method Services (AMS) is the set of commands and functions that operate on VSAM objects: clusters, alternate indexes, paths, and catalog entries. IDCAMS is the program that implements AMS. So when someone says "run IDCAMS" or "use AMS," they mean the same thing: run the IDCAMS program and pass it AMS commands. IDCAMS is the only standard way to define a VSAM cluster (you cannot use JCL DISP=NEW with space parameters for VSAM the way you do for non-VSAM datasets). It is also the way you alter attributes, delete clusters, copy data (REPRO), list catalog entries (LISTCAT), build alternate indexes (BLDINDEX), define paths, and perform verification (VERIFY) or export/import. So for VSAM administration, IDCAMS is central.
IDCAMS supports a wide set of commands. The following table summarizes the main ones you will use for everyday VSAM work.
| Command | Purpose |
|---|---|
| DEFINE CLUSTER | Creates a VSAM cluster (and its data and index components). You specify name, organization type (INDEXED, NONINDEXED, NUMBERED, LINEAR), RECORDSIZE, KEYS, FREESPACE, space allocation, etc. |
| ALTER | Changes alterable attributes of an existing cluster, AIX, or path (e.g. SHAREOPTIONS, FREESPACE, passwords). |
| DELETE | Removes a cluster, alternate index, or path from the catalog and frees space. Use PURGE to delete before retention expires. |
| REPRO | Copies records from one VSAM (or non-VSAM) dataset to another. Used for backup, load, or migration. |
| LISTCAT | Lists catalog entries: clusters, components, AIXs, paths. Useful for checking existence and attributes. |
| DEFINE ALTERNATEINDEX / DEFINE PATH | Creates an alternate index (AIX) and a path that links the AIX to the base cluster. BLDINDEX builds the AIX from the base data. |
| VERIFY | Checks and corrects catalog and dataset status (e.g. after abnormal termination). FILE(ddname) or DATASET(name). |
| EXPORT / IMPORT | Export backs up a cluster (and optionally its AIXs) to a sequential or VSAM file; import restores it. Used for migration and backup. |
There are additional commands (e.g. PRINT to print records, EXAMINE and DIAGNOSE for diagnostics, RENAME). Your installation's IDCAMS documentation or the IBM z/OS DFSMS Access Method Services manual has the full list and syntax. For learning VSAM, DEFINE CLUSTER, ALTER, DELETE, REPRO, LISTCAT, and the alternate index commands (DEFINE ALTERNATEINDEX, DEFINE PATH, BLDINDEX) are the most important.
IDCAMS can be invoked in three ways: batch (JCL), TSO, or from a program. In batch, you run a job step with EXEC PGM=IDCAMS. You allocate SYSPRINT (usually to SYSOUT or a dataset) so that IDCAMS can write messages and listing output. You pass the commands in SYSIN—either instream data (//SYSIN DD *) or a dataset containing the commands. IDCAMS reads the commands from SYSIN and executes them in order. Each command can span multiple lines using the continuation character (often -). After the step completes, the job's condition code (or MAXCC) reflects the result of the run.
| Method | How |
|---|---|
| Batch (JCL) | EXEC PGM=IDCAMS, SYSPRINT for messages, SYSIN for commands. Most common for defining, altering, deleting, and copying VSAM datasets. |
| TSO | From TSO ready prompt or ISPF command shell: run IDCAMS and enter commands interactively or from a dataset. Useful for quick LISTCAT or small operations. |
| Program (PPI) | A program can call IDCAMS via the Problem Program Interface to run AMS commands from within an application. Less common than batch or TSO. |
123456//STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * LISTCAT ENTRIES(USERID.MY.VSAM.CLUSTER) ALL /*
This job runs IDCAMS with one command: LISTCAT ENTRIES(USERID.MY.VSAM.CLUSTER) ALL. LISTCAT lists the catalog entry for the named object and the ALL option requests detailed information. The output goes to SYSPRINT (here SYSOUT=*). To define a cluster instead, you would put a DEFINE CLUSTER command in SYSIN with the appropriate parameters (NAME, INDEXED or NONINDEXED, RECORDSIZE, KEYS, etc.). Multiple commands can be placed in SYSIN one after another; IDCAMS executes them in sequence.
After each command, IDCAMS sets a condition code (LASTCC). For the whole run, it maintains MAXCC (the maximum condition code that occurred). Typical values are: 0 (success), 4 (warning—e.g. optional step failed or minor issue), 8 (error), 12 (more serious error), 16 (severe error). In JCL you can check the step condition code (e.g. with IF/THEN/ELSE or a subsequent step that abends on non-zero). Many shops consider 0 or 4 as acceptable and treat 8 or higher as failure. The SYSPRINT output explains what went wrong when the return code is non-zero.
IDCAMS works with the VSAM catalog (and with the integrated catalog facility, ICF, on z/OS). When you DEFINE CLUSTER, the new cluster and its components are cataloged—that is, their names and attributes are stored in the catalog and their space is allocated on the volumes you specify (or managed by SMS). When you DELETE, the catalog entries are removed and the space is freed. LISTCAT reads from the catalog. So IDCAMS is both a "define/delete/copy" utility and the primary interface to the catalog for VSAM objects. The job must have access to the correct catalog (via JOBCAT, STEPCAT, or the default catalog) for the operations to succeed.
IDCAMS is like the manager of a filing room. When you want a new cabinet (cluster), you tell the manager to create it (DEFINE CLUSTER). When you want to change a rule about the cabinet (ALTER) or throw the cabinet away (DELETE), you tell the manager. When you want to copy everything from one cabinet to another (REPRO) or list what's in the room (LISTCAT), the manager does that too. You don't build or remove the cabinets yourself—you always go through the manager. IDCAMS is that manager for VSAM files.
1. What is IDCAMS used for?
2. How do you pass commands to IDCAMS in a batch job?
3. What does REPRO do in IDCAMS?