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

Issue with executing REXX in batch


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

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Thu Sep 18, 2014 12:41 pm
Reply with quote

Hi,
I have below code which will list the dataset name and writes the name in a new file.

Issue is, when I execute interactively using EX command, I am getting the output properly.

But when I execute it in batch, out put is not proper.

I/P: "ABC.XYZ.D1201409.D22323.D33233" (values after D1, D2 and D3 changes everytime)
expected O/P: "ABC.XYZ.20140923233233.ACK.CSV"
actual O/P from job: "ABC.XYZ. spaces .ACK.CSV"

Code:

  HLQ = "ABC.XYZ.D1*"                                           
PROCESS:                                                               
  "ISPEXEC LMDINIT LISTID(DSLISTID) LEVEL("HLQ")"                       
   IF  RC ¬= 0 THEN                                                     
     DO                                                                 
       SAY = "SORRY FILE NOT FOUND."                                   
     END                                                               
                                                                       
   "ISPEXEC LMDLIST LISTID("DSLISTID") OPTION(SAVEC)",                 
          "DATASET (DSNAME) STATS(YES)"                                 
                                                                       
   IF  RC ¬= 0 THEN                                                     
     DO                                                                 
       SAY = "DSLIST FAILED"                                           
     END                                                               
                                                                       
      SAY 'FILE NAME 'DSNAME                                           
                                                                       
  F2 = 'AAA.BBB.ACK'                                             
                                                                       
OUTL.1 = "ABC.XYZ."||SUBSTR(DSNAME,18,6)||SUBSTR(DSNAME,27,4)||,
       SUBSTR(DSNAME,34,4)||".ACK.CSV"                                 
      SAY 'FILE1     'F1                                               
      SAY 'FILE2     'F2                                               
      ADDRESS TSO "ALLOC FI(INDD) DA('"||F2||"') NEW",                 
      "TRACK SPACE(1 1) RECFM(F B) LRECL(80) BLKSIZE(800) REUS",       
      "UNIT(SYSDA) DSORG(PS)"                                           
      ADDRESS TSO 'EXECIO 0 DISKW INDD(OPEN '                           
      ADDRESS TSO 'EXECIO * DISKW INDD(STEM OUTL.'                     
      ADDRESS TSO 'EXECIO * DISKW INDD(FINIS '                         
      ADDRESS TSO 'FREE FI(INDD)'                                       
EXIT       
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Sep 18, 2014 1:13 pm
Reply with quote

what do You expect to find at SUBSTR(DSNAME,34,4)

when the dsname is just 30 chars ?

why not run it with a TRACE ON to see what is going on ?

check also Your TSO profile PREFIX setting
I guess that it works under TSO because of the PREFIX being turned on
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Sep 18, 2014 2:28 pm
Reply with quote

it would have been nice if You had posted something better than a snippet that does not make any sense whiteout knowing more details

JUST LOOKING AT THE SNIPPET POSTED

the

LMDINIT does not care about dataset existence ( TESTED )

SAVEC option saves also the catalog ...
DATASET(DSNAME) tells where to start saving

and You use the DSNAME variable without having it initialised nowhere
so when using it on the right side of a statement it contains DSNAME

and worst of all , even if You check the return codes You just keep going on

and...
and...
and...

pretty sloppy coding

if You want good answers, learn to post meaningful data
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Sep 18, 2014 8:50 pm
Reply with quote

And: do not do a 'EXECIO * DISKW' use the actual count as held in OUTL.0 (which you appear not to have maintained). Actually, it looks as though you are using a stem when you do not need one: instead of assigning th OUTL.1 assign to OUTL1 and pass that to EXECIO and use 'EXECIO 1 DISKW '
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Fri Sep 19, 2014 10:51 am
Reply with quote

Hi Enrico,

I have corrected the code as you pointed out.

I did trace on and see that, its giving FILE NOT FOUND error.

Code:

"ISPEXEC LMDINIT LISTID(DSLISTID) LEVEL("HLQ")"                       
   IF  RC ¬= 0 THEN                                                     
     DO                                                                 
       SAY = "SORRY FILE NOT FOUND."                                   
     END                                                               


So. its failing here itself. Do I need to remobe ISPEXEC while running in batch?

Hi, Nic
Thanks for poiting it out. I will change it accordingly.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Sep 19, 2014 11:29 am
Reply with quote

Quote:
I did trace on and see that, its giving FILE NOT FOUND error.


why not display the return code and ...RTFM !
LMDINIT DOES NOT CARE ABOUT THE "HLQ" EXISTANCE

if You display an error message at least You should display it with the right description
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Fri Sep 19, 2014 12:00 pm
Reply with quote

RC is 20.

Code:

READY                       
 %LISTDD                   
SORRY FILE NOT FOUND, RC=  20   
READY                       
END                         
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Sep 19, 2014 12:02 pm
Reply with quote

RTFM
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Fri Sep 19, 2014 5:14 pm
Reply with quote

Please show the JCL you use to start ispf and execute your rexx.

P.S. There is a major hint within the request
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Sep 22, 2014 5:01 pm
Reply with quote

pshongal wrote:
expected O/P: "ABC.XYZ.20140923233233.ACK.CSV"
Is that a dsname ???
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 Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top