IDCAMS (Integrated Data Catalog Management System) is a versatile utility program for IBM z/OS environments. It serves as the primary tool for working with Virtual Storage Access Method (VSAM) datasets, catalogs, and other dataset types. IDCAMS provides a comprehensive set of commands for dataset management and maintenance.
Here's the basic JCL structure for running IDCAMS commands:
12345678//IDCJOB JOB (ACCT),'IDCAMS EXAMPLE',CLASS=A,MSGCLASS=X //* //STEP010 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * IDCAMS commands go here /* //
The required DD statements for IDCAMS are:
The DEFINE command creates VSAM datasets, alternate indexes, and catalogs.
1234567DEFINE CLUSTER(NAME(MY.VSAM.KSDS) - INDEXED - RECORDSIZE(80 80) - KEYS(10 0) - CYLINDERS(5 1) - FREESPACE(20 10) - SHAREOPTIONS(2 3))
This example creates a Key Sequenced Data Set (KSDS) with fixed 80-byte records, a 10-byte key starting at position 0, primary allocation of 5 cylinders, secondary allocation of 1 cylinder, 20% free space per control interval, and 10% free space per control area.
The DELETE command removes datasets, catalogs, or catalog entries.
1DELETE MY.VSAM.KSDS CLUSTER PURGE ERASE
This example deletes a VSAM cluster. The PURGE option forces deletion even if the retention period hasn't expired. The ERASE option overrides the dataset before deletion for security.
The REPRO command copies data between datasets.
1REPRO INFILE(INPUT) OUTFILE(OUTPUT) COUNT(1000)
This example copies 1000 records from INPUT to OUTPUT. The DD statements INPUT and OUTPUT must be defined in the JCL.
The PRINT command displays dataset contents.
1PRINT INFILE(MYFILE) CHAR
This example prints the contents of MYFILE in character format. Other options include HEX (hexadecimal) and DUMP (both character and hex).
The LISTCAT command displays information about datasets in the catalog.
1LISTCAT ENTRIES(MY.VSAM.KSDS) ALL
This example displays detailed information about MY.VSAM.KSDS, including space allocation, record format, and other attributes.
IDCAMS is primarily used to manage VSAM datasets, which come in several types:
Type | Description | Use Cases |
---|---|---|
KSDS | Key Sequenced Data Set Organized by key value | Customer databases, lookup tables, any dataset requiring direct access by key |
ESDS | Entry Sequenced Data Set Organized sequentially by entry order | Log files, transaction histories, any dataset accessed primarily sequentially |
RRDS | Relative Record Data Set Organized by relative record number | Arrays, fixed-slot datasets, any dataset accessed by numeric position |
LDS | Linear Data Set Byte-addressable with no record structure | DB2 tablespaces, memory-mapped datasets, specialized applications |
123456789101112131415161718//STEP010 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER (NAME(MY.CUSTOMER.FILE) - INDEXED - RECORDSIZE(200 200) - KEYS(10 0) - CYLINDERS(10 5) - FREESPACE(20 10) - SHAREOPTIONS(2 3) - SPEED - REUSE - RECOVERY - CONTROLINTERVALSIZE(4096) - VOLUMES(VOLSER1)) - DATA (NAME(MY.CUSTOMER.FILE.DATA)) - INDEX (NAME(MY.CUSTOMER.FILE.INDEX)) /*
Key parameters explained:
1234567891011121314151617//STEP010 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE ALTERNATEINDEX (NAME(MY.CUSTOMER.AIX) - RELATE(MY.CUSTOMER.FILE) - KEYS(20 50) - RECORDSIZE(40 100) - CYLINDERS(5 2) - NONUNIQUEKEY - UPGRADE) BLDINDEX INFILE(BASE) OUTFILE(AIX) - INDATASET(MY.CUSTOMER.FILE) - OUTDATASET(MY.CUSTOMER.AIX) /* //BASE DD DSN=MY.CUSTOMER.FILE,DISP=SHR //AIX DD DSN=MY.CUSTOMER.AIX,DISP=OLD
This example creates an alternate index for MY.CUSTOMER.FILE with a 20-byte key starting at position 50. The NONUNIQUEKEY option allows duplicate key values. The UPGRADE option ensures the alternate index is updated whenever the base cluster is modified. The BLDINDEX command populates the alternate index.
12345678910111213141516171819202122//STEP010 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //INFILE DD DSN=MY.INPUT.FILE,DISP=SHR //OUTFILE DD DSN=MY.OUTPUT.FILE,DISP=OLD //SYSIN DD * IF MAXCC = 0 THEN - DO REPRO INFILE(INFILE) - OUTFILE(OUTFILE) END - ELSE - DO SET LASTCC = 0 SET MAXCC = 0 LISTCAT ENTRIES(MY.INPUT.FILE) ALL PRINT INFILE(INFILE) CHAR COUNT(10) END IF LASTCC > 0 THEN - CANCEL /*
This example demonstrates conditional processing in IDCAMS. If the maximum condition code is 0, it copies data from INFILE to OUTFILE. Otherwise, it resets the condition codes, displays catalog information, and prints the first 10 records. If the last operation fails, it cancels further processing.
123456789101112//STEP010 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //INPUT DD DSN=MY.INPUT.FILE,DISP=SHR //OUTPUT DD DSN=MY.OUTPUT.FILE,DISP=OLD //SYSIN DD * REPRO INFILE(INPUT) - OUTFILE(OUTPUT) - SKIP(100) - COUNT(5000) - REPLACE - REUSE /*
This example uses REPRO with advanced options: SKIP(100) skips the first 100 records, COUNT(5000) processes only 5000 records, REPLACE overwrites the existing output file, and REUSE reuses the output dataset without reallocating it.
IDCAMS (Integrated Data Catalog Management System) is a multi-purpose utility program provided by IBM for z/OS environments. It is primarily used for creating, modifying, and maintaining catalogs and datasets, especially VSAM datasets. IDCAMS provides functions for dataset management, catalog maintenance, data conversion, and dataset copying through commands like DEFINE, DELETE, REPRO, PRINT, and VERIFY.
The main IDCAMS commands include:
To create a VSAM file using IDCAMS, use the DEFINE command with the appropriate parameters. For example, to create a KSDS (Key Sequenced Data Set):
123456789//STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER(NAME(MY.VSAM.FILE) - INDEXED - RECORDSIZE(80 80) - KEYS(10 0) - CYLINDERS(2 1)) /*
This defines a KSDS with 80-byte records, a 10-byte key starting at position 0, with primary allocation of 2 cylinders and secondary of 1 cylinder.
To copy data between datasets using IDCAMS, use the REPRO command. For example:
1REPRO INFILE(INPUT) OUTFILE(OUTPUT)
The INFILE parameter specifies the input dataset, and OUTFILE specifies the output dataset. You can use additional parameters like COUNT(n) to limit the number of records copied, SKIP(n) to skip records from the beginning, or REPLACE to overwrite an existing output dataset.
To delete a VSAM file using IDCAMS, use the DELETE command. For example:
1DELETE MY.VSAM.FILE CLUSTER PURGE
This command deletes the VSAM cluster specified. The CLUSTER keyword indicates that all components (data and index) should be deleted. The PURGE option forces deletion even if the retention period has not expired. You can also use options like ERASE to securely overwrite the data before deletion.
To view VSAM file information, use the LISTCAT command.
For basic information:
1LISTCAT ENTRIES(MY.VSAM.FILE)
For more detailed information:
1LISTCAT ENTRIES(MY.VSAM.FILE) ALL
To list all entries in a catalog:
1LISTCAT CATALOG(CATALOG.NAME) ALL
The ALL parameter shows complete information including space allocation, record sizes, and other attributes. To print the actual contents of a VSAM file, use the PRINT command:
1PRINT INFILE(DDNAME) CHAR