Sample JCL which show how to use the REXX procedure.
//JOB7 JOB MSGCLASS=X,CLASS=A,MSGLEVEL=(1,1),REGION=0M
//DSS EXEC PGM=ADRDSSU
//DD1 DD UNIT=3590,VOL=SER=TAPE04,
// LABEL=(1,SL),DISP=(NEW,CATLG),
// DSN=BACKUP.A&DATE.A&TIME
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DUMP OUTDD(DD1) -
DS(INCLUSER1.DATASET1)) -
CICSVRBACKUP
/*
Sample JCL to start REXX procedure, JCL1 (input/output files in the proc) and Sample JCL to start REXX procedure, JCL2 (input/output files in the JCL) show two samples of how to start a batch REXX procedure to modify and submit the JCL in Sample JCL to put date and time in the JCL and run DFSMSdss DUMP.
//JOB8 JOB MSGCLASS=X,CLASS=A,MSGLEVEL=(1,1),REGION=0M
//TSO EXEC PGM=IKJEFT01,PARM='JCL1'
//SYSPROC DD DSN=USER1.CLIST,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD DUMMY
//JOB9 JOB MSGCLASS=X,CLASS=A,MSGLEVEL=(1,1),REGION=0M
//TSO EXEC PGM=IKJEFT01,PARM='JCL2'
//SYSPROC DD DSN=USER1.CLIST,DISP=SHR
//DDI DD DSN=USER1.CNTL(DFDSS),DISP=SHR
//DDO DD DSN=USER1.CNTL(TEMP),DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD DUMMY
For both samples, the REXX procedure must be placed in the data set allocated to SYSPROC.
/*REXX: ***************************************************************/
/* */
/* This REXX procedure obtains the system date and time and replace */
/* &DATE and &TIME in the input member with current date and time */
/* and write all changed and unchanged lines to the output member. */
/* */
/* Input is taken from the data set specified in variable dsni and */
/* member specified in inmem. */
/* */
/* Output is written to the dataset specified in variable dsno and */
/* member specified in outmem. */
/* After conversion the output is submitted. */
/* */
/* The indd and outdd names are used to allocate the datasets to */
/* ddnames. They are freed in the end of this procedure. */
/* */
/* Customize the names below to get the correct input and output. */
/* */
/**********************************************************************/
/**********************************************************************/
/* DATASETNAMES */
/**********************************************************************/
dsni = "USER1.CNTL" /* INPUT LIBRARY */
dsno = "USER1.CNTL" /* OUTPUT LIBRARY */
indd = 'DDI' /* input ddname */
outdd = 'DDO' /* output ddname */
/**********************************************************************/
/* MEMBERS */
/**********************************************************************/
inmem = 'DFDSS' /* Input JCL */
outmem = 'TEMP' /* Output JCL */
/**********************************************************************/
/* Allocate datasets */
/**********************************************************************/
"ALLOC DSN('" || dsni || "(" || inmem || ")') FILE(" || indd || ")"
"ALLOC DSN('" || dsno || "(" || outmem || ")') FILE(" || outdd || ")"
/**********************************************************************/
/* Read all lines */
/**********************************************************************/
"EXECIO * DISKR" indd "1 (FINIS STEM IN.)"
/**********************************************************************/
/* Get system date and time. */
/* Date is saved as yymmdd */
/* Time is saved as hhmmss */
/**********************************************************************/
date = date('S')
date = substr(date,3)
time = time('N')
time = substr(time,1,2) || substr(time,4,2) || substr(time,7,2)
/**********************************************************************/
/* Check all lines for &DATE or &TIME and replace them with the */
/* saved values in date and time. */
/**********************************************************************/
o = 0 /* init */
do i = 1 to in.0 /* do for all input */
o = o + 1 /* one more line for output */
out.o = in.i /* copy to output */
ind = pos('&DATE',out.o) /* any date? */
do while ind > 0 /* do while date found */
out.o = insert(' ',out.o,ind,1) /* insert a blank since */
out.o = overlay(date,out.o,ind) /* overlay is one longer */
ind = pos('&DATE',out.o) /* any more? */
end /* */
ind = pos('&TIME',out.o) /* any time? */
do while ind > 0 /* do while time found */
out.o = insert(' ',out.o,ind,1) /* insert a blank since */
out.o = overlay(time,out.o,ind) /* overlay is one longer */
ind = pos('&TIME',out.o) /* any more? */
end /* */
end
/**********************************************************************/
/* Write all lines to output dataset */
/**********************************************************************/
"EXECIO * DISKW" outdd "(FINIS STEM OUT.)"
/**********************************************************************/
/* Free the allocated datasets */
/**********************************************************************/
"FREE FILE(" || indd || ")"
"FREE FILE(" || outdd || ")"
/**********************************************************************/
/* Submit the changed job and return */
/**********************************************************************/
"SUBMIT '" || dsno || "(" || outmem || ")'"
return
/*REXX: ***************************************************************/
/* */
/* This REXX procedure obtains system date and time and replace */
/* &DATE and &TIME in the input member with current date and time */
/* and write all changed and unchanged lines to the output member. */
/* */
/* Input is taken from the dataset specified in the JCL for the */
/* ddname given in variable indd, in this example DDI */
/* */
/* Output is written to the dataset specified in the JCL for the */
/* ddname given in variable outdd, in this example DDO */
/* After conversion the output is submitted and the member used */
/* for that is in variable outmem, in this example TEMP */
/* */
/* Customize the names below to get the correct input and output. */
/* */
/**********************************************************************/
/**********************************************************************/
/* DDNAMES and member */
/**********************************************************************/
outmem = 'TEMP' /* output member given in JCL */
indd = 'DDI' /* input ddname */
outdd = 'DDO' /* output ddname */
/**********************************************************************/
/* Read all lines */
/**********************************************************************/
"EXECIO * DISKR" indd "1 (FINIS STEM IN.)"
/**********************************************************************/
/* Get system date and time. */
/* Date is saved as yymmdd */
/* Time is saved as hhmmss */
/**********************************************************************/
date = date('S')
date = substr(date,3)
time = time('N')
time = substr(time,1,2) || substr(time,4,2) || substr(time,7,2)
/*********************************************************************/
/* Check all lines for DATE or TIME and replace them with the */
/* saved values in date and time. */
/*********************************************************************/
o = 0 /* init */
do i = 1 to in.0 /* do for all input */
o = o + 1 /* one more line for output */
out.o = in.i /* copy to output */
ind = pos('DATE',out.o) /* any date? */
do while ind > 0 /* do while date found */
out.o = insert(' ',out.o,ind,1) /* insert a blank since */
out.o = overlay(date,out.o,ind) /* overlay is one longer */
ind = pos('DATE',out.o) /* any more? */
end /* */
ind = pos('TIME',out.o) /* any time? */
do while ind > 0 /* do while time found */
out.o = insert(' ',out.o,ind,1) /* insert a blank since */
out.o = overlay(time,out.o,ind) /* overlay is one longer */
ind = pos('TIME',out.o) /* any more? */
end /* */
end
/*********************************************************************/
/* Write all lines to output dataset */
/*********************************************************************/
"EXECIO * DISKW" outdd "(FINIS STEM OUT.)"
/*********************************************************************/
/* Get datasetname for output */
/*********************************************************************/
x = LISTDSI(outdd "FILE")
/*********************************************************************/
/* Submit the changed job and return */
/*********************************************************************/
"SUBMIT '" || sysdsname || "(" || outmem || ")'"
return
//JOB10 JOB MSGCLASS=X,CLASS=A,MSGLEVEL=(1,1),REGION=0M
//DSS EXEC PGM=ADRDSSU
//DD1 DD UNIT=3480,VOL=SER=TAPE04,
// LABEL=(1,SL),DISP=(NEW,CATLG),
// DSN=BACKUP.A001103.A141213
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DUMP OUTDD(DD1) -
DS(INCL(USER1.DATASET1)) -
CICSVRBACKUP
/*