How to REORG an IAM File

IAM files may be reorganized after they are closed to any production applications using them.
 
The following JCL may be used to REORG (reorganize the data) in an IAM file:
 
  STEP010 Defines a new IAM file using the existing IAM file as a model.  
          Specify the amount of space needed in the CYLINDERS(XX) parameter.
  STEP020 Copies the data from the existing IAM file into the new file that  
          was created in STEP010.
  STEP030 Uses IDCAMS to rename the existing file to a backup version and then 
          renames the new, reorganized file to the original name of your file.

 
//************************************************************
//* STEP010 - DEFINE NEW IAM FILE USING CURRENT FILE AS MODEL
//************************************************************
//STEP010  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  DEFINE CLUSTER ( -
          NAME(MY.IAM.FILE.REORG       ) -
         MODEL(MY.IAM.FILE             ) -
         CYLINDERS(XX) -
         OWNER($IAM))
/*
//************************************************************
//* STEP020 - COPY DATA TO NEW IAM FILE TO REORG DATA
//************************************************************
//STEP020  EXEC PGM=IDCAMS
//SYSUDUMP DD SYSOUT=Z
//SYSPRINT DD SYSOUT=*
//INFILE   DD DISP=SHR,DSN=MY.IAM.FILE
//OUTFILE  DD DISP=SHR,DSN=MY.IAM.FILE.REORG
//SYSIN    DD *
  REPRO    INFILE  (INFILE)     OUTFILE (OUTFILE)
/*
//************************************************************
//* STEP030 - RENAME FILES, SAVE OLD FILE AS BACKUP
//************************************************************
//STEP030  EXEC PGM=IDCAMS
//SYSUDUMP DD SYSOUT=Z
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  SET MAXCC=0
    ALTER   MY.IAM.FILE                -
    NEWNAME(MY.IAM.FILE.BACKUP        )
  IF MAXCC NE 0 THEN CANCEL
    ALTER   MY.IAM.FILE.REORG          -
    NEWNAME(MY.IAM.FILE               )
/*
//


© 2008 by the Rector and Visitors of the University of Virginia.

The information contained on the University of Virginia’s Department of Information Technology and Communication (ITC) website is provided as a public service with the understanding that ITC makes no representations or warranties, either expressed or implied, concerning the accuracy, completeness, reliability or suitability of the information, including warrantees of title, non-infringement of copyright or patent rights of others. These pages are expected to represent the University of Virginia community and the State of Virginia in a professional manner in accordance with the University of Virginia’s Computing Policies.