Say I have a COBOL-module, X, which is called by another program, Y.
How do I identify the name of Y within X?
I could of course pass this in the linkage section to each sub-module, but I'd rather rely on a more programmatic way of dealing with this than developers coding some literals correctly.
But is there any known way of doing this effectively? Perhaps some obscure LE feature or specific control blocks to read?
All programs are running in batch on z/OS with Enterprise COBOL.
You can walk back up the DSA (Data Save Area, for AMODE31 nonXPLINK, the pointer to DSA is in register 13.) to the previous frame (aka your caller), then if that frame is written with a high level language (e.g. COBOL, C), then you need to find the beginning of the EP (Entry Point), then you can nevigate to the PPA1 control block. The name of the EP would be near the end of PPA1. (You will need to use the offset information in PPA1 to get to it in a programmatic manner.)
If your code need to works with varies different favour of LE program, you will need to code enough to handle them without ABENDing. (For example, your COBOL program Y maybe called by non-LE assembler, or LE assembler, or another COBOL program.) You can make you job easier to do if you just limit the check to caller that's written in LE highlevel languages.