Actually, the answer to the question you reference first states "The best solution for this is to use the features of your job scheduler." That remains the best answer. That I showed how something could be done was not intended to imply I thought it was the best or most maintainable method.
You could do this with Rexx, or a Unix System Services shell script, or an awk script, or Perl, again constructing an ALTER statement to be used in a subsequent step to rename a statically-named dataset to one containing the date qualifier you desire.
There are some other techniques here.
But, if you have a job scheduler package available, you really should be using its capabilities.
Examples of the above proposed solutions follow.
Rexx program MKALTR
dsn = Arg(1)
Parse Value Date('O') With yy '/' mm '/' dd
If mm = 1 Then
If yy > 0 Then
yy = yy - 1
Else
yy = 99
outLine.1 = ' ALTER ' || dsn || ' - '
outLine.2 = ' NEWNAME(' || dsn || yy || ')'
outLine.0 = 2
Address TSO 'EXECIO * DISKW OUTPUT01 ( STEM' outLine. 'FINIS )'
Exit
JCL to run Rexx program MKALTR
//*
// SET &DS=MY.DATASET.NAME
//*
//CATLG EXEC PGM=IEFBR14
//STDOUT DD DISP=(,CATLG),
// DSN=&DS,
// AVGREC=U,
// LRECL=80,
// RECFM=FB,
// SPACE=(80,(1,1))
//*
//MKALTER EXEC PGM=IKJEFT1B,PARM='MKALTR &DS'
//SYSEXEC DD DISP=SHR,DSN=dataset.where.rexx.code.resides
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSTSIN DD DUMMY
//OUTPUT01 DD DISP=(,PASS),
// AVGREC=K,
// LRECL=80,
// RECFM=FB,
// SPACE=(80,(2,1))
//*
//DOALTER EXEC PGM=IDCAMS
//SYSIN DD DISP=(OLD,DELETE),DSN=*.MKALTER.OUTPUT01
//SYSPRINT DD SYSOUT=*
//*
Shell script mkaltr
let "mon=`date +'%m'`"
let "yr=`date +'%y'`"
if [ $mon -eq 01 ]
then
let "outyr=$yr-1"
fi
echo \ ALTER $1 -
echo \ \ NEWNAME\($1$outyr\)
JCL to run shell script mkaltr
//*
// SET &DS=MY.DATASET.NAME
//*
//CATLG EXEC PGM=IEFBR14
//STDOUT DD DISP=(,CATLG),
// DSN=&DS,
// AVGREC=U,
// LRECL=80,
// RECFM=FB,
// SPACE=(80,(1,1))
//*
//MKALTER EXEC PGM=BPXBATCH,
// PARM='SH /path/to/script/mkaltr &DS'
//STDOUT DD DISP=(,PASS),
// AVGREC=U,
// LRECL=80,
// RECFM=FB,
// SPACE=(80,(2,1))
//STDERR DD SYSOUT=*
//*
//DOALTER EXEC PGM=IDCAMS
//SYSIN DD DISP=(OLD,DELETE),DSN=*.MKALTER.STDOUT
//SYSPRINT DD SYSOUT=*
//*
Shell script mkaltr using awk
date +"$1 %m %y" | awk '
{
yr = $3
if ( $2 = 1 ) yr -= 1
if ( yr > 100 ) yr -= 100
printf( " ALTER %s -\n NEWNAME(%s%2d)\n", $1, $1, yr )
}'
JCL to run shell script mkaltr
//*
// SET &DS=MY.DATASET.NAME
//*
//CATLG EXEC PGM=IEFBR14
//STDOUT DD DISP=(,CATLG),
// DSN=&DS,
// AVGREC=U,
// LRECL=80,
// RECFM=FB,
// SPACE=(80,(1,1))
//*
//MKALTER EXEC PGM=BPXBATCH,
// PARM='SH /path/to/script/mkaltr &DS'
//STDOUT DD DISP=(,PASS),
// AVGREC=U,
// LRECL=80,
// RECFM=FB,
// SPACE=(80,(2,1))
//STDERR DD SYSOUT=*
//*
//DOALTER EXEC PGM=IDCAMS
//SYSIN DD DISP=(OLD,DELETE),DSN=*.MKALTER.STDOUT
//SYSPRINT DD SYSOUT=*
//*
Perl program mkaltr
if ( @ARGV ) {
$dsn = shift( @ARGV );
} else {
die "dataset name required";
}
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($mon == 0) {
$year -= 1
}
if ($year >= 100) {
$year -= 100;
}
printf (" ALTER %s -\n NEWNAME(%s%2d)\n", $dsn, $dsn, $year);
JCL to run Perl program mkaltr
//*
// SET &DS=MY.DATASET.NAME
//*
//CATLG EXEC PGM=IEFBR14
//STDOUT DD DISP=(,CATLG),
// DSN=&DS,
// AVGREC=U,
// LRECL=80,
// RECFM=FB,
// SPACE=(80,(1,1))
//*
//MKALTER EXEC PGM=BPXBATCH,
// PARM='SH perl /path/to/perl/program/mkaltr &DS'
//STDOUT DD DISP=(,PASS),
// AVGREC=U,
// LRECL=80,
// RECFM=FB,
// SPACE=(80,(2,1))
//STDERR DD SYSOUT=*
//*
//DOALTER EXEC PGM=IDCAMS
//SYSIN DD DISP=(OLD,DELETE),DSN=*.MKALTER.STDOUT
//SYSPRINT DD SYSOUT=*
//*