I am new here and I would like to thank everyone that took the time here to read my question. I am having a problem with this REXX program I am writing. The Program is called by a JCL which passes in some parameters. The main parameters is the dataset name that the Rexx program uses.
The REXX program takes the report and formats it to be veiwed on the internet. The new formated HTML report is save in a dataset which is allocated by the program. After that I call my sub-routine to FTP the file.
The problem I am having with it is it likes do to run correctly every other time. One time it will send the file and then delete the dataset that the program created. If I run it again it will send an empty file even though the file has been created and won't delete the dataset after it send the empty file. It is driving me nuts and I can't spend anymore time on it. It is a nasty logical error that I can not seem to find.
Here is the code:
Code:
"ALLOC F(SYSFTPD) DA('SYS1.TCPPARMS(FTPDATA)') SHR REU"
PARSE ARG SWITCH F T C SNAME DNAME
trace r
JDate=substr(DATE('S'),1,2)||DATE('J')
Y =2
a =0
b =0
PCHECK = 0
IF SWITCH = 1 THEN CALL LEG_REPORT
/*IF SWITCH = 0 THEN CALL NON_REPORT*/
exit 0
/*file=*/
"FREE F(SYSFTPD)"
LEG_REPORT:
LINEOUT.1 = "<HTML><BODY><BGCOLOR=white><PRE>"
DO X=1 to LINEIN.0
SPACER.X = substr(LINEIN.X,1,1)
END
DO X=1 to LINEIN.0
IF SPACER.X = ' ' THEN DO
LINEOUT.Y = LINEIN.X
Y = Y + 1
END
ELSE IF SPACER.X = '0' THEN DO
a = Y + 1
LINEOUT.Y = " "
LINEOUT.a = " " || right(LINEIN.X,(LENGTH(LINEIN.X) -1))
Y = Y + 2
END
ELSE IF SPACER.X = '1' THEN DO
PCHECK = PCHECK + 1
if PCHECK > 1 then do
a = Y + 1
LINEOUT.Y = "<HR>"
LINEOUT.a = right(LINEIN.X,(LENGTH(LINEIN.X) -1))
Y = Y + 2
end
else do
LINEOUT.Y = right(LINEIN.X,(LENGTH(LINEIN.X) -1))
Y = Y + 1
end
END
ELSE IF SPACER.X = '-' THEN DO
a = Y + 1
b = Y + 2
LINEOUT.Y = " "
LINEOUT.a = " "
LINEOUT.b = " " || right(LINEIN.X,(LENGTH(LINEIN.X) -1))
Y = Y + 3
END
END
LINEOUT.Y = "</P></PRE></BODY></HTML>"
FILE_NAME = "'"||DNAME||"'"
X = OUTTRAP("DSINFO.","*")
LISTDS FILE_NAME
RECFM = WORD(DSINFO.3,1)
LRECL = WORD(DSINFO.3,2)
BLKSZ = WORD(DSINFO.3,3)
DSORG = WORD(DSINFO.3,4)
SAY 'LRECL = '||LRECL||' RECFM = '||RECFM||' BLKSZ = '||BLKSZ
IF LENGTH(LRECL) > 0 THEN DO
xsname= SNAME
UPPER xsname
TEMP = "MFTP.RISC."||xsname
IF RECFM = 'FBA' THEN LRECL = LRECL - 1
IF RECFM = 'FBA' THEN RECFM = 'F B'
COUNT = 27920 % LRECL
BLKSZ = COUNT * LRECL
SAY 'LRECL='||LRECL||'RECFM ='||RECFM||'BLKSZ='||BLKSZ||'DS='||DSORG
FTP_SENDFILE:
trace r
Address TSO
id = "username"
pass = "password"
dir = "cd /h/"||t||"/"||SNAME
mode = "ASCII"
qcmd = "quit"
AYYYYDDD= substr(DATE('S'),1,4)||Date(D)
rfile= ''||SNAME||'_'||F||'_'||AYYYYDDD||'_wide_'||c||'.html'
put_cmd = "put '"||TEMP||"' "||rfile
QUEUE id
QUEUE pass
QUEUE dir
QUEUE mode
QUEUE put_cmd
QUEUE qcmd
"FTP *****Servername******** (EXIT"
FTPRC= RC
MSGNAME = "'MFTP.RISC.FTPMSG."||xsname"'"
"DELETE "MSGNAME" "
MSGOUT= "FTP for "||TEMP||" Finished RC="||FTPRC
MSGOUT2= "On="||Date(U)" 12:47"
"ALLOC F(MSGFILE) DA("MSGNAME") OLD REUSE",
"DSORG("DSORG") RECFM("RECFM") LRECL("LRECL") BLKSIZE("BLKSZ")",
"UNIT(SYSDA) NEW CATALOG"
FTPMSGOUT.1 = MSGOUT" " MSGOUT2
FTPMSGOUT.2 = "ID is username
FTPMSGOUT.3 = "Password is *********"
FTPMSGOUT.4 = "Directory is: " ||dir
FTPMSGOUT.5 = "Put is: " ||put_cmd
"EXECIO * DISKW MSGFILE (STEM FTPMSGOUT."
"EXECIO 0 DISKW MSGFILE (FINIS"
"FREE DA ("MSGNAME")"
if FTPRC > 0 then do
do Y = 1 to 5
Say "The number of things still Queued is: " ||NUMCOMMANDS
DELSTACK
address syscall 'sleep 180'
address TSO
SAY "An FTP Failed RC= "||FTPRC
SAY "See "||MSGNAME||" for details"
QUEUE id
QUEUE pass
QUEUE dir
QUEUE mode
QUEUE put_cmd
QUEUE qcmd
FTPRC = 0
FTPRC = 0
"FTP ***servername****(EXIT"
FTPRC = RC
IF FTPRC > 0 THEN Y=Y+1
DELSTACK
END
IF FTPRC > 0 THEN DO
SAY "An FTP failed RC " ||FTPRC
SAY "See "||MSGNAME||" for details"
DELSTACK
EXIT RC
END
END
NUMCOMMANDS = QUEUED()
SAY "The Number of things still Queued is: " ||NUMCOMMANDS
DELSTACK
RETURN
Code:
I can't find why it is only working correctly every other time. If anyone can help I would greatly appreciated.
Also, I don't see any logical reason to actually create a dataset for the DD DUMMY. I'd just use the DD as a temp dataset, and change the put command in the FTP step to: