MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trapping the return code of a JCL through REXX

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Fri Dec 06, 2002 7:14 am    Post subject: Trapping the return code of a JCL through REXX Reply with quote

Hi,

I am writing and submitting a JCL through a REXX routine. I need to trap the return code of the JCL into my REXX routine and do further processing in the REXX routine accordingly. How can I trap the return code?. Please suggest me the trapping mechanism for both the cases - when I am using Queues as well as FT Skels to prepare and submit the job.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
tidda
Beginner


Joined: 02 Dec 2002
Posts: 24
Topics: 6
Location: India

PostPosted: Sat Dec 14, 2002 4:14 pm    Post subject: Reply with quote

for some reason, i feel that i'm a bit fascinated with the capabilities of the 'outtrap' command Smile ... manas, is it possible to trap the job notification to a variable and process that ? you might have to parse that message properly to get the return code.

hmmm ... i was just wondering. Is it possible to make the rexx program 'sleep' for sometime ?

tidda
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Sat Dec 14, 2002 5:28 pm    Post subject: Reply with quote

Tidda,

You can use STIMER which allows you to wait until a certain time or aletrnatively you can call "ILBOWAT0" COBOL pgm from rexx and it will delay the execuetion.

ex:
Code:


/*REXX*/
CBL_PARM = '0000003C'X /*60 SECONDS*/
ADDRESS LINKPGM "ILBOWAT0 CBL_PARM"
SAY 'ILBOWAT0 RETURN CODE = ' RC


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Mon Dec 16, 2002 12:11 am    Post subject: Reply with quote

Hi Tidda,
I don't think you can use the outtrap function to trap the return code of the job. OUTTRAP is used to trap TSO messages but the return code is generated by SDSF.
Whenever you submit a job, you get a message like -
Code:

IKJ56250I JOB FDI1525X(JOB02128) SUBMITTED

You can trap this message by OUTTRAP because it is a TSO message.

After your job ends, you will get a message like -
Code:

10.39.58 JOB02128 $HASP165 FDI1525X ENDED AT CPAC  MAXCC=12 CN(INTERNAL)

You cannot trap this message using OUTTRAP because it is not a TSO message.
Please correct me if I am wrong.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Mon Dec 16, 2002 7:11 am    Post subject: Reply with quote

Try this REXX to get the return code. It's a bit messy, I would normally use a ptr() function but I can't be bothered to convert it.

Code:

/* REXX - Job Step information */                         
                                                           
  cvt     = storage(10,4)                                 
  tcbp    = storage(d2x(x2d(c2x(cvt))+x2d(0)),4)           
  tcb     = storage(d2x(x2d(c2x(tcbp))+x2d(4)),4)         
  jscb    = storage(d2x(x2d(c2x(tcb))+x2d(b4)),4)         
  ssib    = storage(d2x(x2d(c2x(jscb))+x2d(13c)),4)       
  tct     = storage(d2x(x2d(c2x(tcb))+x2d(a4)),4)         
  tct     = bitand(tct,x2c('7FFFFFFF'))                   
  lct     = storage(d2x(x2d(c2x(tct))+x2d(98)),4)         
  jct     = storage(d2x(x2d(c2x(lct))+x2d(10)),4)         
  jobname = storage(d2x(x2d(c2x(jct))+x2d(08)),8)         
  jobid   = storage(d2x(x2d(c2x(ssib))+x2d(0c)),8)         
  sct     = storage(d2x(x2d(c2x(jct))+x2d(20)),3)         
                                                           
  do while c2d(sct) <> 0                                   
    stepname = storage(d2x(x2d(c2x(sct))+x2d(3c)),8)       
    procstep = storage(d2x(x2d(c2x(sct))+x2d(44)),8)       
    lastcc   = c2x(storage(d2x(x2d(c2x(sct))+x2d(18)),2)) 
    say procstep stepname lastcc                           
    sct      = storage(d2x(x2d(c2x(sct))+x2d(24)),3)       
  end                                                     
                                                           
  exit(0)                                                 
                                                           

_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Mon Dec 16, 2002 11:47 pm    Post subject: Reply with quote

Hi Daveyc,

Thanks for the code. I had also got this code from some search on google. But frankly I am not able to make head or tail out of it. I can simply copy the code and run it but I don't want to do it that way. Can you please provide me some details about the storage function and how it works.
What is d2x, c2x etc. Can you please spare some time to explain a little about it. I did a lot of search on google for STORAGE function but didn't find anything useful.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Tue Dec 17, 2002 4:09 am    Post subject: Reply with quote

What I will do is tell you that the REXX Reference manual contains detailed explanations of these functions and does a better job than I possibly can. But the conversion functions are simple D2X = Decimal to Hex, X2D = Hex to Decimal etc, etc.

STORAGE returns the value from a location in storage. It's the only way in REXX that you can chase control blocks and do similar things to assembler, C etc. As far as understanding what the REXX does, well you will have to read up on the MVS data areas manuals. Start with the CVT, TCB, ASCB etc and work out the control block chains.

It's system programming... Getting to know the control blocks takes experience and practice.
_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Tue Dec 17, 2002 4:30 am    Post subject: Reply with quote

Hi Dave,

Thanks a lot for your advice. As I understand, this code basically accesses some internal storage of MVS to get the return code of the job. I just want to know where in the code, do you actually specify the jobname(or anything to uniquely identify a job) for which you want the return code. Of course, learning all this will take time and I am preapared for the long haul but if you can point out where I can specify the job name in the code, then at least I can start working.

It will be great Dave if you can suggest me some links to start with MVS data areas manuals.
Thanks again for your time and patience.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Tue Dec 17, 2002 6:49 am    Post subject: Reply with quote

In that code you cannot specify a jobname. It gets the jobname after chaining down from the TCB. The TCB is the TASK CONTROL BLOCK and is specific to the task that is currently running. To get return codes from other jobs is non-trivial.

Data Areas manuals
_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Tue Dec 17, 2002 7:48 am    Post subject: Reply with quote

Hi Dave,

After I have submitted a job from my REXX program, I have no control on when the job ends. How will I make sure that the task for that job is running when I use this code. Will this code give me the return code of the last job that I had run. Will it be specific to my userid.

Thanks for the link again. Smile

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Tue Dec 17, 2002 7:59 am    Post subject: Reply with quote

The TCB that is running is the batch job, so all the steps will be from that batch job. A batch job has a TCB. To create a new TCB you use the ATTACH macro to run a program as a new task. You may choose to multi-task but that's out of our scope at the moment.

Here is a very simple program that mimicks the userid() REXX function. See if you can work it out.

Code:

/* REXX */                                   
                                             
  ascb     = ptr( 548 )                       
  ascx     = ptr( ascb + 108 )               
                                             
  userid   = string( ascx + 192, 8 )         
                                             
  say userid                                 
                                             
  exit                                       
                                             
ptr: arg addr                                 
                                             
  return c2d( storage( d2x( addr ), 4 ) )     
                                             
string: arg addr, len                         
                                             
  return storage( d2x( addr ), len )         
                                             

_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Tue Dec 17, 2002 11:37 pm    Post subject: Reply with quote

Thanks Dave for your time. I suppose I will have to go through the manuals before attempting anything. That will be the best thing to do.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
dorkhead
Beginner


Joined: 07 Jan 2003
Posts: 25
Topics: 0
Location: Lux

PostPosted: Tue Jan 07, 2003 11:44 am    Post subject: Reply with quote

Manas,

but the return code is generated by SDSF.

I think the PGM generates the Return Code and not SDSF as u implie
_________________
Dorkhead
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group