Current Enterprise COBOL compilers (and back as far as I know, even COBOL F-level from MVT) always mark the last parameter address in the address list with the bit 0 turned on, though I have not researched what current ones do if the last parameter is "BY VALUE".
Again for current Enterprise COBOL versions, the LE Vendor Interfaces manual available in KC has the PPA1 format and in general how to locate it. Peter -----Original Message----- From: IBM Mainframe Discussion List <[email protected]> On Behalf Of Bernd Oppolzer Sent: Tuesday, September 22, 2020 4:53 PM To: [email protected] Subject: Re: Determining program name/number of paramaters from called COBOL program EXTERNAL EMAIL I've done similar things for other languages (C, PL/1, ASSEMBLER), but not for COBOL. Some remarks: - the desired name of the caller needs to be specified more precisely. By examining the save area chain, it is possible to retrieve the entry point of the calling procedure (Reg 15 in the save area), and, given that it is a COBOL program of a certain compiler release, it will be possible to retrieve the name of that program (IIRC, there is a control block PPA1, which is pointed to by an address nearby the entry point ... dont recall the details; should work for most newer LE compilers). Other possibities: the name of the load module which contains the entry point address could be examined (using the CDE chain). This can be done regardless of the compiler release and even the language of the caller, BTW. The results of both approaches may differ. - in a similar way, it is possible to get the addresses passed as parameters to the calling function (using Reg 1), that is, the addresses that point to the different parts of the LINKAGE SECTION. But it is IMO not possible in the general case to count the number of addresses, unless the COBOL compiler marks the last address with the leftmost bit on (which I don't know). Maybe someone more familiar with COBOL internals could comment on this. In general, the number of parameters is fixed and is a matter of negotiation between caller and called program. And in this case, there is no need to mark the last address. And then, as a consequence, no way for the caller to determine the right number of addresses at run time. HTH, kind regards Bernd Am 22.09.2020 um 21:24 schrieb Chris Cantrell: > Hello, > > I am hoping someone out there can help me with this 'opportunity'. > > In a Z/OS enterprise COBOL environment, I want to be able to retrieve the > calling program name and the number of parms passed to the called program > from the called program. In other words, program A is executed in my batch > job and it calls program B passing 5 parms in the using statement. I want > program B to be able to retrieve the program name for program A as well as > the number of parms that were passed to it. > > I think if I could get to the program stack I could probably figure it out > from there. > > Any assistance that any of you could provide would be greatly appreciated. > > Thanks! > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, send > email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
