IDCAMS



The IDCAMS (also known as Access Method Services) is a versatile utility that can be invoked in batch mode with JCL or interactively with TSO commands. With JCL one can print or display datasets and system messages and return codes. IF - THEN - ELSE constructs can be used to execute commands selectively based on condition codes returned by previous commands.

It can be used to perform following tasks:

·         Create a VSAM data set, VSAM alternate index, or catalog
·         List a catalog entry for a data set, file/catalog contents
·         Copy a file or catalog
·         Print all or part of a data set in character or hex format
·         Build a backup copy of a VSAM data set, catalog, non-VSAM data set, or an alternate index
·         Convert non-VSAM to VSAM data set, VSAM to SAM format, CVOLs to ICF catalogs, VSAM catalog entries to ICF catalog entries
·         Alter the attributes of a catalog or data set
·         Catalog or Uncatalog VSAM/non-VSAM data set and GDGs
·         Delete a VSAM or non-VSAM data set or volume records, catalog, path, GDG, alias, candidate volume, alternate index, pagespace, or true name catalog entry
·         Verify a VSAM data set's software end-of-file indicator
·         Attach a user catalog to the master catalog
·         Create a MVS paging space, generation data group (GDG)
·         Collect data set and volume info. on migration utility
·         Connect catalogs to one another
·         Import/Export VSAM data sets, catalogs
·         Load a VSAM file from SAM, ISAM, or VSAM records
·         Unload a VSAM data set
·         Merge ICF catalogs or recreate ICF entries
·         Rename VSAM data sets
·         Move a catalog and VSAM/non-VSAM data sets

Sample IDCAMS JCL:

//JS10    EXEC PGM=IDCAMS,REGION=1024K,PARM=parameters
//STEPCAT   DD DSN=...,DISP=SHR     Optional STEPCAT
//anyname   DD DSN=...              Optional file
//SYSPRINT  DD SYSOUT=*             IDCAMS Messages file
//SYSIN     DD *                    Control Statements file
 control statements...
/*

Below are some commonly used IDCAMS examples:

·         Uncatalog files


Non-VSAM files

//JS10   EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
 DELETE -
    TEST.WORK.DATABASE -    /* DATA SET TO BE UNCATALOGED */
    NOSCRATCH          /* TELLS IDCAMS TO UNCATALOG, NOT DELETE */

·         Delete files


Non-VSAM files

//STEPDEL1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD *
//SYSIN    DD *
  DELETE   G1SG00AT.OLDFILE1  -
  DELETE   G1SG00AT.OLDFILE2  -
  IF MAXCC = 08 THEN
     SET MAXCC = 00
/*


VSAM files

//STEPDEL1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD *
//SYSIN    DD *
  DELETE   G1SG00AT.OLDVSAM1  -
           PURGE              -
           CLUSTER
  IF LASTCC < 09 THEN
     SET MAXCC = 00
/*


·         Copy data

      
a) Example1: Copy a GDG to 2 flat files.

//STEPCOPY EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD *
//COPYIN   DD DSN=G1SG00AT.INGDG(0),DISP=SHR
//COPYOUT  DD DSN=G1SG00AT.FLATFIL1,
//         DISP=(NEW,CATLG,DELETE),
//         UNIT=SYSDA,
//         SPACE=(CYL(2,2),RLSE),
//         DCB=(LRECL=80,BLKSIZE=0,RECFM=FB,DSORG=PS),
//         MGMTCLAS=TSONORM
//COPYOUT1 DD DSN=G1SG00AT.FLATFIL2,
//         DISP=(NEW,CATLG,DELETE),
//         UNIT=SYSDA,
//         SPACE=(CYL(2,2),RLSE),
//         DCB=(LRECL=80,BLKSIZE=0,RECFM=FB,DSORG=PS),
//         MGMTCLAS=TSONORM
//SYSIN    DD *
  REPRO                                   -
        IFILE(COPYIN)                       -
           OFILE(COPYOUT)
  REPRO                                   -
        IFILE(COPYIN)                       -
           OFILE(COPYOUT1)
/*


b) Example2: Some records of input file are skipped & fixed count of records are copied only. 

//STEPCOPY EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD *
//INPFILE  DD DSN=G1SG00AT.INPUT,DISP=SHR
//OUTFILE  DD DSN=G1SG00AT.OUTPUT,DISP=SHR
//         DISP=(NEW,CATLG,DELETE),
//         UNIT=SYSDA,
//         SPACE=(CYL(2,2),RLSE),
//         DCB=(LRECL=80,BLKSIZE=0,RECFM=FB,DSORG=PS),
//         MGMTCLAS=TSONORM
//SYSIN    DD *
  REPRO                                         -
        IFILE(INPFILE)                -
        OFILE(OUTFILE)                -
        SKIP(100)                  -
        COUNT(500)
/*


a)    Example3: Extract a subset of a VSAM KSDS to a sequential file

//STEPCOPY EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD *
//INPFILE  DD DSN=G1SG00AT.INPUT.VSAM,DISP=SHR
//OUTFILE  DD DSN=G1SG00AT.OUTPUT.FLAT,DISP=SHR
//         DISP=(NEW,CATLG,DELETE),
//         UNIT=SYSDA,
//         SPACE=(CYL(2,2),RLSE),
//         DCB=(LRECL=80,BLKSIZE=0,RECFM=FB,DSORG=PS),
//         MGMTCLAS=TSONORM
//SYSIN    DD *
  REPRO                                         -
        INDATASET(INPFILE)      -
        OUTFILE(OUTFILE)        -
        FROMKEY(BZ0300A0)             -
        TOKEY(BZ0399A9)
/*


·         Allocate vsam files/indexes


To allocate vsam cluster

//STEPDEF1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD *
//SYSIN    DD *
  DEFINE   CLUSTER                        -
          (NAME(G1SG00AT.CLUSTER)        -
           MGMTCLAS(TSONORM)              -
           TRK(10 10)                     -
           SHR(2 3)                       -
           REUSE                          -
           SPEED                          -
           NOIMBED                        -
           RECSZ (40 40)                  -
           FSPC (0 0)                     -
           KEYS (12 14)                   -
          )                               -
           DATA                           -
          (NAME(G1SG00AT.CLUSTER.DATA)    -
           CISZ(20480)                    -
       )                              -   
        INDEX                         -
       (NAME(G1SG00AT.CLUSTER.INDEX)  -
        CISZ(512)                     -
       )
/*


·         Copy a sequential file to vsam & define alternate index


//STEPDEF1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD *
//INPFILE  DD DSN=G1SG00AT.INPUT,DISP=SHR
//OUTFILE  DD DSN=G1SG00AT.CLUSTER,DISP=SHR
//SYSIN    DD *
  REPRO    IFILE(INPFILE) OFILE(OUTFIL)
  DEFINE                                        -
           ALTERNATEINDEX                       -
          (NAME(G1SG00AT.CLUSTER.AIX)           -
           RELATE(G1SG00AT.CLUSTER.DATA)        -
           FSPC(0 0)                            -
           KEYS(34 06)                          -
           TRACKS(1000 750)                     -
           RECSZ(128 128)                       -
           UNIQUEKEY                            -
          )                                     -
        DATA                                -
          (NAME(G1SG00AT.CLUSTER.AIX.DATA)      -
       )                                    -
        INDEX                               -
          (NAME(G1SG00AT.CLUSTER.AIX.INDEX)     -
          )
  DEFINE                                        -
        PATH                                -
          (NAME(G1SG00AT.CLUSTER.AIX.PATH)      -
           PATHENTRY(G1SG00AT.CLUSTER.AIX)      -
          )
/*


·         Build alternate index from base cluster


//DS580416 EXEC PGM=IDCAMS,
//PRMINDEX DD DSN=DS.DS580412.AGGR,DISP=SHR
//ALTINDEX DD DSN=DS.DS580412.AGGR.AIX,DISP=SHR
//IDCUT1   DD DSN=DS.DS580416.TEMP1,DISP=OLD,UNIT=IDMP,
//         VOL=(,,,,SER=(PDS001))
//IDCUT2   DD DSN=DS.DS580416.TEMP2,DISP=OLD,UNIT=IDMP,
//         VOL=(,,,,SER=(PDS001))
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  BLDINDEX INFILE(PRMINDEX) OUTFILE(ALTINDEX)
/*

·         Define GDG base


//STEPDEF1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  DEFINE   GDG(NAME('G1SG00AT.GDGNAME1') -
               NOEMPTY,SCRATCH,LIMIT(30))
//STEPEMPT EXEC PGM=IEFBR14
//         IF ( STEPDEF = 0 ) THEN
//NEWVER01 DD DSN= G1SG00AT.GDGNAME1(+),
//            DISP=(,CATLG),
//            SPACE(TRK,(5,2))
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *

//         ENDIF

Comments

Popular posts from this blog

Date/time constants in JCL

JCL ABeND --

NDM