I think the official, supported answer would be that the calling program should pass that information.
With regard to number of parms -- COBOL should have a special register for that! -- I suspect you could write an assembler program that you called from the called COBOL program, worked its way back through the save area chain, found the parms that its caller was called with, and counted them. You might have to experiment to determine whether the call was one save area back, two, or perhaps more. Hopefully it would be consistent, but see paragraph one above. The name of the calling program is a little more difficult. What is its "name"? The PROGRAM-ID? The PGM= name? What about subprograms and dynamically loaded callers? You can get the PGM= name from the JSCB (again, from an assembler subroutine). PSATOLD->TCB TCBJSCB->JSCB JSCBPGMN is the PGM= name Charles -----Original Message----- From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf Of Chris Cantrell Sent: Tuesday, September 22, 2020 12:24 PM To: [email protected] Subject: Determining program name/number of paramaters from called COBOL program 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
