BEGINBUCKET DIRECTORYCHECK
#/ ------------------------------------------------------------------
#/ This template generates the job steps to copy any PDS that had to
#/ be reallocated with more directory blocks to the new dataset, and
#/ then swap the new dataset with the production dataset.
#/ ------------------------------------------------------------------
#BEGINDEFS
#/ ------------------------------------------------------------------
#/EXCEPTIONFORMISSINGSYMBOL
#/ ------------------------------------------------------------------
#BEGININSTANCEQUALIFIERS
#TABLEFIX {MVS2BDSCODE} #/ Fix ds table row from the instance.
#SET [DSLANGCODE] {LANG2BCODE}
#IFNOTEQ [DATASETTYPE] PDS #THEN SKIP
#DIRBLOCKSNEEDED /# Gets directory blocks needed from SPACEPARMS
#DIRBLOCKSACTUAL [CUSTPRODQUAL].[LOQUAL] /# Gets actual number of directory blocks
#IFEQ [DIRBLOCKSNEEDED] [DIRBLOCKSACTUAL] #THEN SKIP
#INSTANCEUNIQUEKEY {MVS2BDSCODE}[OUTPDDNAME] [LOQUAL] #NOTUNIQUE SKIP
#CREATEINSTANCEFROMENTRY
#SKIP
#ENDQUALIFIERS
#BEGINPREFIX
#BEGININSTANCE
//* [CUSTPRODQUAL].[LOQUAL] has [DIRBLOCKSACTUAL] directory
//* blocks, needs [DIRBLOCKSNEEDED]. This step copies the
//* data set to a new one that has the required number of
//* directory blocks.
//*
#IFEQ [DSLANGCODE] EN #THEN COPYEN
//COPY{MVS2BDSCODE}{LANG2BCODE} EXEC PGM=IEBCOPY,COND=(0,LT)
#THEN COPYALL
#COPYEN
//COPY{MVS2BDSCODE} EXEC PGM=IEBCOPY,COND=(0,LT)
#COPYALL
//SYSPRINT DD SYSOUT=*
//SYSUT3   DD UNIT=SYSALLDA,SPACE=(TRK,(1,1))
//SYSUT4   DD UNIT=SYSALLDA,SPACE=(TRK,(1,1))
//[INPDDNAME] DD DISP=SHR,
//      DSN=[CUSTPRODQUAL].[LOQUAL]
//[OUTPDDNAME] DD DISP=SHR,
//      DSN=[CUSTPRODQUAL].PL.[LOQUAL]
//SYSIN    DD DATA,DLM='@@'
COPY{MVS2BDSCODE} COPY INDD=[INPDDNAME],OUTDD=[OUTPDDNAME]
@@
//*
//* If the previous step succeeded, replace the old production
//* data set with the new one that has sufficient directory blocks.
//*
#IFEQ [DSLANGCODE] EN #THEN SWAPEN
//SWAP{MVS2BDSCODE}{LANG2BCODE} EXEC PGM=IDCAMS,COND=(0,LT,COPY{MVS2BDSCODE}{LANG2BCODE})
#THEN SWAPALL
#SWAPEN
//SWAP{MVS2BDSCODE} EXEC PGM=IDCAMS,COND=(0,LT,COPY{MVS2BDSCODE})
#SWAPALL
//SYSPRINT DD SYSOUT=*
//SYSIN    DD DATA,DLM='@@'
 DELETE '[CUSTPRODQUAL].[LOQUAL]' NONVSAM PURGE
 ALTER '[CUSTPRODQUAL].PL.[LOQUAL]' -
    NEWNAME('[CUSTPRODQUAL].[LOQUAL]')
@@
#BEGINSUFFIX
#ENDBUCKET DIRECTORYCHECK
