Can we change the name of an IBM VSAM data set?
Use the access method services program IDCAMS and the ALTER function to change the name of a data set in IBM's mainframe OS Virtual Storage Access Method (Listing 1).
Listing 1. An example of changing the name of a VSAM data set.
//IDCAMS JOB ... //RENAME EXEC PGM=IDCAMS,REGION=2M //SYSPRINT DD SYSOUT=* //SYSIN DD * ALTER HLQ.ORIGINAL.NAME - NEWNAME(HLQ.NEW.NAME) ALTER HLQ.ORIGINAL.NAME.DATA - NEWNAME(HLQ.NEW.NAME.DATA) ALTER HLQ.ORIGINAL.NAME.INDEX - NEWNAME(HLQ.NEW.NAME.INDEX) /*
More on VSAM
Duplicates and the alternative index
Tips for optimizing VSAM data sets
Keeping VSAM files updated
A word of caution when altering VSAM names: The alias for the high level qualifier (HLQ) for the new name must relate to the same catalog as the original name. If the new name's HLQ does not relate to the catalog, the data set will be rendered inaccessible. However, the HLQ doesn't need to be exactly the same.
If the alias for the HLQ does not relate to the same catalog as the original name, use IDCAMS command REPRO MERGECAT to put the entries into the proper catalog (Listing 2).
//IDCAMS JOB //MERGECAT EXEC PGM=IDCAMS,REGION=2M //SYSPRINT DD SYSOUT=* //INCAT DD DSN=SYS1.ICFCAT.ORIGINAL,DISP=SHR //OUTCAT DD DSN=SYS1.ICFCAT.NEW,DISP=SHR //SYSIN DD * REPRO - INFILE (INCAT) - OUTFILE (OUTCAT) - ENT(HLQ.NEW.NAME) - MERGECAT /*
It almost goes without saying that the data set can't be in use while you are doing the ALTER or MERGECAT. More information is available in the DFSMS Access Method Services for Catalogs.
Dig Deeper on IBM system z and mainframe systems
Related Q&A from Mark Zelden
When initial program load stalls out on a mainframe logical partition, the culprit is often consoles. Connectivity is one of many potential causes. Continue Reading
I want to write a COBOL program that will run in z/OS and create a sequential file that can then be FTP'd to a network drive and opened with MS-Word ... Continue Reading
Mainframes don't always operate as they should. In extreme circumstances, the FORCE command can help close down a stuck program. Continue Reading