IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Only Deletes the dataset every othe run


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
wasubi

New User


Joined: 20 Aug 2007
Posts: 4
Location: PA

PostPosted: Mon Aug 20, 2007 11:08 pm
Reply with quote

Hello all

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:                                       
                                                   
  "ALLOC F("INFILE") DA('"DNAME"')SHR REUSE"       
  "EXECIO * DISKR INFILE (STEM LINEIN."           
  "EXECIO 0 DISKR INFILE (FINIS"                   
  "FREE DA('"DNAME"')"                             
                                                   
  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
                                                                       
  ADDRESS TSO                                                         
"ALLOC F(DUMMY) DA('"TEMP"') SHR SPACE(5,5) CYL DIR(0)",               
"DSORG("DSORG") RECFM("RECFM") LRECL("LRECL") BLKSIZE("BLKSZ")",       
 "UNIT(SYSDA) NEW CATALOG"             
 "EXECIO * DISKW DUMMY (STEM LINEOUT." 
 "FREE DA ('"TEMP"') "                 
 address syscall 'sleep 180'           
 CALL FTP_SENDFILE                     
 "DELETE '"TEMP"' "                     
 END                                   

 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.

Wasubi
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Tue Aug 21, 2007 10:59 am
Reply with quote

Have you tried running it with TRACE?

O.
Back to top
View user's profile Send private message
wasubi

New User


Joined: 20 Aug 2007
Posts: 4
Location: PA

PostPosted: Tue Aug 21, 2007 5:02 pm
Reply with quote

I do have trace on and it does everything it is expected to from what I can tell in trace output.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Aug 21, 2007 6:40 pm
Reply with quote

Some changes I'd suggest:

IF SWITCH = 1 THEN CALL LEG_REPORT
/*IF SWITCH = 0 THEN CALL NON_REPORT*/
"FREE F(SYSFTPD)" <= PUT FREE BEFORE THE EXIT
exit 0
/*file=*/

LEG_REPORT:

"ALLOC F("INFILE") DA('"DNAME"') SHR REUSE" <= ADD A SPACE
"EXECIO * DISKR INFILE (STEM LINEIN. FINIS" <= COMBINE INTO ONE
"FREE DA('"DNAME"')"

FILE_NAME = "'"||DNAME||"'"
X = OUTTRAP("DSINFO.","*")
LISTDS FILE_NAME
X = OUTTRAP("OFF") <= You're missing the OFF for the OUTTRAP

"ALLOC F(DUMMY) DA('"TEMP"') SPACE(5,5) CYL", <= REMOVE SHR & DIR(0)
"DSORG("DSORG") RECFM("RECFM") LRECL("LRECL") BLKSIZE("BLKSZ")",
"UNIT(SYSDA) NEW REUSE CATALOG" <= ADD REUSE
"EXECIO * DISKW DUMMY (STEM LINEOUT. FINIS" <= ADD FINIS
"FREE DA ('"TEMP"') "

"ALLOC F(MSGFILE) DA("MSGNAME") REUSE", <= REMOVE OLD
"DSORG("DSORG") RECFM("RECFM") LRECL("LRECL") BLKSIZE("BLKSZ")",
"UNIT(SYSDA) NEW CATALOG"

"EXECIO * DISKW MSGFILE (STEM FTPMSGOUT. FINIS" <= COMBINE LINES
"FREE DA ("MSGNAME")"

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:

put_cmd = "put //dd:dummy "||rfile
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Allocated cylinders of a dataset DB2 12
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
Search our Forums:

Back to Top