5 pts.
 Enterprise Cobol obtaining calling program name
Enterprise Cobol v3.4 on Z/OS 1.9. Batch called program. I want to parse through mvs data areas to obtain the program name that called my program(dynamically). I have viewed examples on Share website to get some system info. I need specifically the program name that called my program. Is this possible in a batch program? thanks

Software/Hardware used:
ASKED: February 2, 2010  8:20 PM
UPDATED: February 4, 2010  2:30 PM

Answer Wiki:
This can be done by calling a CL program with the Program name is input for which you want find out the Caller. Use that input name in SNDPGMMSG with TOPGMQ parameter *PRV and entry parameter (program name). Do RCVMSG with PGMQ parameter value as *PRV and entry parameter on *PGMQ the Sender parameter on RCVMSG will have the calling program name. do a RMVMSG to clear the messages sent SNDPGMMSG MSG('msg') TOPGMQ(*PRV &entparm) KEYVAR(&KEY) RCVMSG PGMQ(*PRV &entparm) MSGQ(*PGMQ) MSGKEY(&KEY) SENDER(&SEND) Check the value of SEND
Last Wiki Answer Submitted:  February 4, 2010  1:26 pm  by  rajsubhyd   105 pts.
All Answer Wiki Contributors:  rajsubhyd   105 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


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


 

In MVS (z/OS) COBOL, this would be quite a trick. it isn’t easy even in Assembler.

You will need to access the CDE chain and dig thru protected memory. This is the calling chain that you see in a dump.

Or maybe it could be done by accessing the savearea of the calling program and determine which program owns that piece of storage; not sure how to code that.

I know I have seen code pieces that address this, but it has been a LONG time. You might try some more mainframe centric sites like IBM’s DeveloperWorks.

Some people make it a practice to include the name of the caller in the parms passed to the called module. maybe like this:

   IDENTIFICATION DIVISION.
   PROGRAM-ID.   PROG001.

   WORKING STORAGE SECTION.
   01  PARMS-PASSED.
       05  CALLER              PIC X(8)    VALUE 'PROG001'.
       05  REAL-DATA        PIC ....
 
   PROCEDURE DIVISION.
   ...
   CALL 'PROG002' USING PARMS-PASSED.

This would be a lot of work to retro-fit into an existing application system. But you might remember it for the future.

 5,205 pts.