The 4 important lines are preceded by !! but this will give you an idea of what I'm trying to do.
!!//*TTTTTTT JOB (X9999),'LOCATE FILES',CLASS=T,MSGCLASS=Y,
!!//* NOTIFY=&SYSUID,REGION=0M
//**********************************************************************
//* JOB WILL LOCATE AND TRANSFER THE RELEVANT FILES AS SPECIFIED BY THE
//* SCHID SELECTED AT RUN TIME.
//* CHANGE THE FILEDATE SYMBOLIC TO THE JULIAN DATE THAT THE FILES WERE
//* CREATED
//*____________________________________________________________________*
//*****************_FILEDATE_FORMAT_IS_JULIAN_=_YYDDD_******************
//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
// EXPORT SYMLIST=(FILEDATE,INPTFILE,OUTFILE)
// SET FILEDATE=15110
// SET INPTFILE=TTTTTTT.REXXFIN(XFRVSAIN)
// SET OUTFILE=TTTTTTT.REXXOUT
//**********************************************************************
/*ROUTE PRINT ELOIGNE
/*ROUTE XEQ PROD
//S001 EXEC PGM=IEFBR14
//REXXLIB DD DSN=TTTTTTT.REXX,DISP=SHR
//**********************************************************************
//S002 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUT2 DD DSN=TTTTTTT.REXX(RXPGM),DISP=(SHR,PASS,KEEP)
//SYSUT1 DD *,SYMBOLS=JCLONLY
/*REXX*/
/* PARSE THE FILE DATE */
FILEDATE = LEFT(&FILEDATE,2)'.'RIGHT(&FILEDATE,3)
/* DELETE THE OUTPUT DATASET */
IF SYSDSN("'"&OUTFILE"'") = "OK" THEN
"DEL '&OUTFILE'"
"ALLOCATE SHR F(OUT) DATASET('&OUTFILE') NEW SPACE(5,1)",
"DSORG(PS) RECFM(F B) LRECL(80) BLKSIZE(8000)"
/* WRITE THE FIRST LINES OF THE OUTPUT FILE */
FIRSTLINE.0 = 1
FIRSTLINE.1 = 'SCANCPIN PROCESS PNODE=&PNODE SNODE=&SNODE NOTIFY=%USER'
"EXECIO * DISKW OUT (STEM FIRSTLINE."
/* SET UP THE OUTPUT LINES THAT WILL BE REPEATED; FOR LATER USE */
FOUTPUT = ' STORCLAS=SCGDG'
CALL FORMATOUTPUT
OUTREC.5 = FOUTPUT
OUTREC.6 = ' DISP=(NEW,CATLG,DELETE))'
/* READ THE INPUT FILE CONTAINING THE GDGS TO LOCATE */
"ALLOCATE SHR F(INPUTF) DATASET('&INPTFILE') SHR"
"EXECIO * DISKR INPUTF (FINIS STEM IN."
/* STRIP THE SPACES FROM THE FILENAMES SO THEY ARE USEABLE */
DO REC = 1 TO IN.0
GDG.REC = STRIP(SUBSTR(IN.REC,1,40))
GDGOUT.REC = STRIP(SUBSTR(IN.REC,41,40))
END
/* BEGIN MAIN PROCESSING */
PROCESS = TRUE
FNUM = 1
DO GCOUNT = 1 TO IN.0 BY 1
BASE = STRIP(GDG.GCOUNT" **GDG BASE** ") /* DEFAULT IF NOT EXIST */
X=OUTTRAP(LST.) /* LISTCAT GDG BASE */
" LISTC ENT('"GDG.GCOUNT"') ALL"
X=OUTTRAP(OFF)
IF POS('NOT FOUND',LST.1) = 0 THEN DO /*CHECK IF FILE IS VALID */
CALL LOCATEFILES /* ONLY EXECUTES IF FILE IS VALID */
IF FN > 1 THEN DO
CALL OPENFILES /* ONLY EXECUTES IF FILES ARE FOUND */
END
ELSE DO
PROCESS = FALSE
SDSFOUT.FNUM = BASE,
"--- NO FILES FOUND --- CHECK INPUT DATE ---"
END
END
ELSE DO
PROCESS = FALSE
SDSFOUT.FNUM = BASE,
'FILENAME APPEARS TO BE INVALID'
END
FNUM = FNUM + 1
END
FNUM.0 = FNUM - 1
DO FNUM = 1 TO FNUM.0 BY 1
SAY SDSFOUT.FNUM
END
"EXECIO 0 DISKW OUT (FINIS"
"FREE FILE(OUT)"
IF PROCESS = FALSE THEN
RETURN 7
ELSE
RETURN 0
EXIT
LOCATEFILES:
FN = 1 /* KEEPS TRACK OF FILES */
DO A = 1 TO LST.0 BY 1 /* LOOPS THE LISTC */
SELECT
WHEN POS('NONVSAM',LST.A) = 4 THEN DO /*NEED DATE TOO!!*/
DSN = SUBSTR(LST.A,POS('NONVSAM',LST.A)+13,LENGTH(GDG.GCOUNT)+9)
END
WHEN POS('CREATION',LST.A) > 0 THEN DO
CRDT = SUBSTR(LST.A,POS('CREATION',LST.A)+16,8)
IF RIGHT(CRDT,6) = FILEDATE THEN DO
FILENAME.FN = DSN
FN = FN + 1
END
ELSE
IF LEFT(RIGHT(CRDT,6),2) = LEFT(FILEDATE,2) THEN
IF RIGHT(CRDT,3) > RIGHT(FILEDATE,3) THEN
RETURN
END
OTHERWISE
END
END
RETURN
OPENFILES:
RECCOUNT = 0
FILENAME.0 = FN - 1
DO FN = 1 TO FILENAME.0 BY 1
IF SYSDSN("'"FILENAME.FN"'") = "OK" THEN DO
TEMPFILE = "'"FILENAME.FN"'"
"ALLOC F(IN) DS("TEMPFILE") SHR"
TOTAL_LINES = 0
READ_RC = 0
DO UNTIL READ_RC > 0
ADDRESS TSO "EXECIO 1000000 DISKR IN (STEM LINES."
TOTAL_LINES = TOTAL_LINES + LINES.0
IF TOTAL_LINES > 0 THEN
SAY FILENAME.FN TOTAL_LINES 'RECORDS READ'
READ_RC = RC
DROP LINES.
END
IF TOTAL_LINES > RECCOUNT THEN DO
RECFILE = FN
RECCOUNT = TOTAL_LINES
END
"EXECIO 0 DISKW IN (FINIS"
"FREE FILE(IN)"
"DELSTACK"
END
ELSE
SAY 'BAD FILE'
END
OUTREC.0 = 6
FOUTPUT = 'STEP'FNUM' COPY FROM (&FRNODE'
CALL FORMATOUTPUT
OUTREC.1 = FOUTPUT
FOUTPUT = ' DSN='FILENAME.RECFILE
CALL FORMATOUTPUT
OUTREC.2 = FOUTPUT
FOUTPUT = ' DISP=SHR)'
CALL FORMATOUTPUT
OUTREC.3 = FOUTPUT
FOUTPUT = ' TO(DSN='GDGOUT.FNUM
CALL FORMATOUTPUT
OUTREC.4 = FOUTPUT
SDSFOUT.FNUM = FILENAME.RECFILE 'RECORD COUNT:',
RECCOUNT 'FILEDATE:' FILEDATE
"EXECIO * DISKW OUT (STEM OUTREC."
RETURN
FORMATOUTPUT:
DO X = LENGTH(FOUTPUT) TO 70
FOUTPUT = FOUTPUT' '
END
FOUTPUT = FOUTPUT'-'
RETURN
/*
//**********************************************************************
//S003 EXEC PGM=IKJEFT01,PARM='RXPGM'
//SYSPROC DD DSN=TTTTTTT.REXX,DISP=(SHR,PASS,KEEP)
//SYSTSIN DD *,SYMBOLS=JCLONLY
//SYSTSPRT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//**********************************************************************
//S004IF IF (S003.RC < 7) THEN
//**********************************************************************
//S005 EXEC PGM=IEBGENER
//DD01 DD DSN=&OUTFILE,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSUT1 DD DATA,DLM=ZZ,SYMBOLS=JCLONLY
!!//*TTTTTTTT JOB (X9999),'TRANSFER TO UAT',CLASS=T,MSGCLASS=Y,
!!//* REGION=0M,NOTIFY=&SYSUID
/*XEQ PROD2
//*-----------------------------------------------------------*
//SXB1 EXEC PROC=X35CDBAT,COND.P01A=(8,GT,P01)
//DMPUBLIB DD DSN=TTTTT.TTT.TT.PROCESS.LIB,DISP=SHR
//NDMCMDS DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SIGNON
SUBMIT PROC=DSCCD MAXDELAY=QUEUED -
&PNODE=FBSPRD2 -
&SNODE=USB2MSP -
&FRNODE=SNODE -
&DSNI=&OUTFILE -
&DSNO=&OUTFILE -
&CD_SC=STORCLAS=SCPROD -
&DISP=(SHR)
SIGNOFF
/*
//*************************************************************
//SXB2 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSUT1 DD DSN=&OUTFILE,DISP=SHR
//SYSUT2 DD DSN=TTTTTTT.LIB.JCL(COPYPROC),DISP=SHR
//*************************************************************
//SXB3 EXEC PROC=X35CDBAT,COND.P01A=(8,GT,P01)
//DMPUBLIB DD DSN=TTTTTTT.LIB.JCL,DISP=SHR
//NDMCMDS DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SIGNON
SUBMIT PROC=COPYPROC MAXDELAY=QUEUED -
&PNODE=FBSPRD2 -
&SNODE=USB2MSP -
&FRNODE=SNODE
SIGNOFF
/*
//*************************************************************
//*-----------------------------------------------------------*
ZZ
//SYSUT2 DD SYSOUT=(B,INTRDR)
//SYSPRINT DD SYSOUT=*
/*
//**********************************************************************
//S004EIF ENDIF
//**********************************************************************
!!//* NOTIFY=&SYSUID,REGION=0M
//**********************************************************************
//* JOB WILL LOCATE AND TRANSFER THE RELEVANT FILES AS SPECIFIED BY THE
//* SCHID SELECTED AT RUN TIME.
//* CHANGE THE FILEDATE SYMBOLIC TO THE JULIAN DATE THAT THE FILES WERE
//* CREATED
//*____________________________________________________________________*
//*****************_FILEDATE_FORMAT_IS_JULIAN_=_YYDDD_******************
//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
// EXPORT SYMLIST=(FILEDATE,INPTFILE,OUTFILE)
// SET FILEDATE=15110
// SET INPTFILE=TTTTTTT.REXXFIN(XFRVSAIN)
// SET OUTFILE=TTTTTTT.REXXOUT
//**********************************************************************
/*ROUTE PRINT ELOIGNE
/*ROUTE XEQ PROD
//S001 EXEC PGM=IEFBR14
//REXXLIB DD DSN=TTTTTTT.REXX,DISP=SHR
//**********************************************************************
//S002 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSUT2 DD DSN=TTTTTTT.REXX(RXPGM),DISP=(SHR,PASS,KEEP)
//SYSUT1 DD *,SYMBOLS=JCLONLY
/*REXX*/
/* PARSE THE FILE DATE */
FILEDATE = LEFT(&FILEDATE,2)'.'RIGHT(&FILEDATE,3)
/* DELETE THE OUTPUT DATASET */
IF SYSDSN("'"&OUTFILE"'") = "OK" THEN
"DEL '&OUTFILE'"
"ALLOCATE SHR F(OUT) DATASET('&OUTFILE') NEW SPACE(5,1)",
"DSORG(PS) RECFM(F B) LRECL(80) BLKSIZE(8000)"
/* WRITE THE FIRST LINES OF THE OUTPUT FILE */
FIRSTLINE.0 = 1
FIRSTLINE.1 = 'SCANCPIN PROCESS PNODE=&PNODE SNODE=&SNODE NOTIFY=%USER'
"EXECIO * DISKW OUT (STEM FIRSTLINE."
/* SET UP THE OUTPUT LINES THAT WILL BE REPEATED; FOR LATER USE */
FOUTPUT = ' STORCLAS=SCGDG'
CALL FORMATOUTPUT
OUTREC.5 = FOUTPUT
OUTREC.6 = ' DISP=(NEW,CATLG,DELETE))'
/* READ THE INPUT FILE CONTAINING THE GDGS TO LOCATE */
"ALLOCATE SHR F(INPUTF) DATASET('&INPTFILE') SHR"
"EXECIO * DISKR INPUTF (FINIS STEM IN."
/* STRIP THE SPACES FROM THE FILENAMES SO THEY ARE USEABLE */
DO REC = 1 TO IN.0
GDG.REC = STRIP(SUBSTR(IN.REC,1,40))
GDGOUT.REC = STRIP(SUBSTR(IN.REC,41,40))
END
/* BEGIN MAIN PROCESSING */
PROCESS = TRUE
FNUM = 1
DO GCOUNT = 1 TO IN.0 BY 1
BASE = STRIP(GDG.GCOUNT" **GDG BASE** ") /* DEFAULT IF NOT EXIST */
X=OUTTRAP(LST.) /* LISTCAT GDG BASE */
" LISTC ENT('"GDG.GCOUNT"') ALL"
X=OUTTRAP(OFF)
IF POS('NOT FOUND',LST.1) = 0 THEN DO /*CHECK IF FILE IS VALID */
CALL LOCATEFILES /* ONLY EXECUTES IF FILE IS VALID */
IF FN > 1 THEN DO
CALL OPENFILES /* ONLY EXECUTES IF FILES ARE FOUND */
END
ELSE DO
PROCESS = FALSE
SDSFOUT.FNUM = BASE,
"--- NO FILES FOUND --- CHECK INPUT DATE ---"
END
END
ELSE DO
PROCESS = FALSE
SDSFOUT.FNUM = BASE,
'FILENAME APPEARS TO BE INVALID'
END
FNUM = FNUM + 1
END
FNUM.0 = FNUM - 1
DO FNUM = 1 TO FNUM.0 BY 1
SAY SDSFOUT.FNUM
END
"EXECIO 0 DISKW OUT (FINIS"
"FREE FILE(OUT)"
IF PROCESS = FALSE THEN
RETURN 7
ELSE
RETURN 0
EXIT
LOCATEFILES:
FN = 1 /* KEEPS TRACK OF FILES */
DO A = 1 TO LST.0 BY 1 /* LOOPS THE LISTC */
SELECT
WHEN POS('NONVSAM',LST.A) = 4 THEN DO /*NEED DATE TOO!!*/
DSN = SUBSTR(LST.A,POS('NONVSAM',LST.A)+13,LENGTH(GDG.GCOUNT)+9)
END
WHEN POS('CREATION',LST.A) > 0 THEN DO
CRDT = SUBSTR(LST.A,POS('CREATION',LST.A)+16,8)
IF RIGHT(CRDT,6) = FILEDATE THEN DO
FILENAME.FN = DSN
FN = FN + 1
END
ELSE
IF LEFT(RIGHT(CRDT,6),2) = LEFT(FILEDATE,2) THEN
IF RIGHT(CRDT,3) > RIGHT(FILEDATE,3) THEN
RETURN
END
OTHERWISE
END
END
RETURN
OPENFILES:
RECCOUNT = 0
FILENAME.0 = FN - 1
DO FN = 1 TO FILENAME.0 BY 1
IF SYSDSN("'"FILENAME.FN"'") = "OK" THEN DO
TEMPFILE = "'"FILENAME.FN"'"
"ALLOC F(IN) DS("TEMPFILE") SHR"
TOTAL_LINES = 0
READ_RC = 0
DO UNTIL READ_RC > 0
ADDRESS TSO "EXECIO 1000000 DISKR IN (STEM LINES."
TOTAL_LINES = TOTAL_LINES + LINES.0
IF TOTAL_LINES > 0 THEN
SAY FILENAME.FN TOTAL_LINES 'RECORDS READ'
READ_RC = RC
DROP LINES.
END
IF TOTAL_LINES > RECCOUNT THEN DO
RECFILE = FN
RECCOUNT = TOTAL_LINES
END
"EXECIO 0 DISKW IN (FINIS"
"FREE FILE(IN)"
"DELSTACK"
END
ELSE
SAY 'BAD FILE'
END
OUTREC.0 = 6
FOUTPUT = 'STEP'FNUM' COPY FROM (&FRNODE'
CALL FORMATOUTPUT
OUTREC.1 = FOUTPUT
FOUTPUT = ' DSN='FILENAME.RECFILE
CALL FORMATOUTPUT
OUTREC.2 = FOUTPUT
FOUTPUT = ' DISP=SHR)'
CALL FORMATOUTPUT
OUTREC.3 = FOUTPUT
FOUTPUT = ' TO(DSN='GDGOUT.FNUM
CALL FORMATOUTPUT
OUTREC.4 = FOUTPUT
SDSFOUT.FNUM = FILENAME.RECFILE 'RECORD COUNT:',
RECCOUNT 'FILEDATE:' FILEDATE
"EXECIO * DISKW OUT (STEM OUTREC."
RETURN
FORMATOUTPUT:
DO X = LENGTH(FOUTPUT) TO 70
FOUTPUT = FOUTPUT' '
END
FOUTPUT = FOUTPUT'-'
RETURN
/*
//**********************************************************************
//S003 EXEC PGM=IKJEFT01,PARM='RXPGM'
//SYSPROC DD DSN=TTTTTTT.REXX,DISP=(SHR,PASS,KEEP)
//SYSTSIN DD *,SYMBOLS=JCLONLY
//SYSTSPRT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//**********************************************************************
//S004IF IF (S003.RC < 7) THEN
//**********************************************************************
//S005 EXEC PGM=IEBGENER
//DD01 DD DSN=&OUTFILE,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSUT1 DD DATA,DLM=ZZ,SYMBOLS=JCLONLY
!!//*TTTTTTTT JOB (X9999),'TRANSFER TO UAT',CLASS=T,MSGCLASS=Y,
!!//* REGION=0M,NOTIFY=&SYSUID
/*XEQ PROD2
//*-----------------------------------------------------------*
//SXB1 EXEC PROC=X35CDBAT,COND.P01A=(8,GT,P01)
//DMPUBLIB DD DSN=TTTTT.TTT.TT.PROCESS.LIB,DISP=SHR
//NDMCMDS DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SIGNON
SUBMIT PROC=DSCCD MAXDELAY=QUEUED -
&PNODE=FBSPRD2 -
&SNODE=USB2MSP -
&FRNODE=SNODE -
&DSNI=&OUTFILE -
&DSNO=&OUTFILE -
&CD_SC=STORCLAS=SCPROD -
&DISP=(SHR)
SIGNOFF
/*
//*************************************************************
//SXB2 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSUT1 DD DSN=&OUTFILE,DISP=SHR
//SYSUT2 DD DSN=TTTTTTT.LIB.JCL(COPYPROC),DISP=SHR
//*************************************************************
//SXB3 EXEC PROC=X35CDBAT,COND.P01A=(8,GT,P01)
//DMPUBLIB DD DSN=TTTTTTT.LIB.JCL,DISP=SHR
//NDMCMDS DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SIGNON
SUBMIT PROC=COPYPROC MAXDELAY=QUEUED -
&PNODE=FBSPRD2 -
&SNODE=USB2MSP -
&FRNODE=SNODE
SIGNOFF
/*
//*************************************************************
//*-----------------------------------------------------------*
ZZ
//SYSUT2 DD SYSOUT=(B,INTRDR)
//SYSPRINT DD SYSOUT=*
/*
//**********************************************************************
//S004EIF ENDIF
//**********************************************************************