On 12/4/2012 5:19 PM, Charles Mills wrote:
1. What would be the best way for a program running z/OS batch to answer the
question "Am I the jobstep program, the PGM= program, or was I LOADed and
CALLed or ATTACHed (let's ignore XCTL for now) by another program?
2. In addition, if the answer to (1.) is "another program," where would I
find its entry point name? In other words, "who loaded me?"
It's probably not documented because there is no easy answer.
The PGM= entry is the jobstep program, unless you're processing a TSO
command (but you specified batch...).
Get the current TCB, run the RB chain to find the oldest PRB. That
corresponds to the program on an ATTACH(X) (note that the RB does not
have the name, only addresses; you can match the extent list address
against the load list, or use CSVQUERY). If the TCB is also a jobstep
TCB, you have the PGM= or command processor, or a module XCTLed to. In
case of XCTL, the original PGM= name is in the SCT.
If the current PRB is not the oldest, the previous RB PSW will have the
interrupt code, allowing you to tell which SVC (LINK or SYNCH) invoked
you. And that RB should allow you to determine the invoker.
For LOAD, the situation is messier. There is no extra PRB, and your best
bet for a well-behaved program is to chase the save area chain, and test
each entry point with the CSVQUERY service/macro.
This is very simplified. For authorized programs it gets messier (e.g.,
start tasks have two job step TCBs; batch programs three; and TSO more).
Gerhard Postpischil
Bradford, Vermont
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN