145 pts.
 Can you find out the name of the job calling a REXX program?
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.

Software/Hardware used:
ASKED: March 6, 2009  4:07 PM
UPDATED: March 11, 2009  4:58 PM

Answer Wiki:
That's difficult to do. You can use the REXX <i>userid </i>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: <pre>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 </pre> 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: <pre> 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 </pre> You can find out more about z/OS control blocks in this <a href="http://www.longpelaexpertise.com.au/ezine/CtBlksBeginners1.html">Control Blocks for Beginners article</a>. Hope this helps.
Last Wiki Answer Submitted:  March 11, 2009  12:51 pm  by  Dzs   235 pts.
All Answer Wiki Contributors:  Dzs   235 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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.

http://publib.boulder.ibm.com/infocenter/zos/v1r9/index.jsp?topic=/com.ibm.zos.r9.iead100/iea2d18066.htm

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 pts.

 

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 pts.

 

David,
That worked very nice for the job id! Thanks so much for your help!
Karl

 145 pts.