Can you find out the name of the job calling a REXX program?

145 pts.
I am using REXX in TSO, and I would like to get information about the Batch job that called the REXX. I was hoping to get the Job name and the job number, but I can't find anything. I've looked in the MVSVAR() and SYSVAR() functions, which is where I thought it'd be available, but couldn't find what I need.

Answer Wiki

Thanks. We'll let you know when a new response is added.

That’s difficult to do. You can use the REXX userid function if you’re running under an interactive TSO/E session, but falls down if you call your REXX in batch.

The only way I can think of is to use the REXX STORAGE function to hop through z/OS Control Blocks. Here’s some code that will do it for you:

ASCB_Addr = C2D(Storage(224,4)) /* Get address of ASCB */

/* --- First check ASCBJBNI for Jobname ----------------------- */
Interpret "JobAddr = Storage("D2X(ASCB_ADDR+172)",4)"
If C2D(JobAddr) = 0 Then
/* --- Not running in initiator, so get jobname from ASCBJBNS - */
Interpret "JobAddr = Storage("D2X(ASCB_ADDR+176)",4)"

Interpret "Job = Storage("C2X(JobAddr)",8)"
say "Jobname: " Job

This looks in the ASCBJBNI field for a jobname. If not there, goes to ASCBJBNS to get the Started Task name. You still need to ADDRESS TSO to use the STORAGE function.

You can also find out the JES JobID using the following REXX code:

TCB_Addr = C2D(Storage(21C,4)) /* Current TCB Addr */
JSCB_Addr = C2D(Storage(D2X(TCB_Addr+180),4)) /* JSCB Addr */
SSIB_Addr = C2D(Storage(D2X(JSCB_Addr+316),4)) /* SSIB Addr */
JobID = Storage(D2X(SSIB_Addr+12),8)
say "Jobid: " JobID

Hope this helps.

Discuss This Question: 3  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Kwkanne
    Dzs, Thank you so much for the prompt answer! This really does help. The first call, using the +172, is the one that worked. Would I be pushing my luck if I asked for help in getting the JOBID as well? I did look at the Beginners article above, and I also found the following site, which lays out the ASCB pretty well, but I couldn't find JOBID anywhere. So I'm getting the impression from the Beginners article that I could create my own controld block to pass a block of data from one REXX program to another? I've always hated having to write data to a file and read it back in from the called program. Thanks again for your help! Karl Kanne
    145 pointsBadges:
  • Dzs
    I've updated the answer with some REXX that will find the JobID for you. Most high level languages give you facilities to use control blocks, though they may call them something different (like structures in C). So in theory, you could create a control block in one REXX, and pass the address to another one. The problem is that I'm not aware of any way in REXX to 'get' a block of storage for a control block. Some application environments provide other facilities to pass information between REXX programs (like safes and global variables in Netview), but with TSO you're pretty well stuck with passing parameters, and receiving answers in the RESULT. Hope this helps, David
    235 pointsBadges:
  • Kwkanne
    David, That worked very nice for the job id! Thanks so much for your help! Karl
    145 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: