Currently in my shop, we have a standard SYSOUT header that displays a bunch of useful information such as:
One thing that would be very useful for us would be to display which load library the current program is running from. I was able to get the compile datetime using the IBM intrinsic function
WHEN-COMPILED, but I am unable to find anything that will get me the loadlib.
What would be the proper way to approach this?
From what I see on the ibm-main listserv, there is no general solution to this problem that will work in all cases. Having said that, your specific case might have a solution as suggested by Peter Relson at https://groups.google.com/d/msg/bit.listserv.ibm-main/-kkUfvDpprk/L5PHW_HOyxMJ:
Mimic the system search order and do a BLDL on each dataset for the member in question. When you find the member, you might know which library it was loaded from. I say "might" because maybe the member was loaded and then someone deleted it from the library. And maybe then added it to different library.
If you follow the discussion thread you will see one member succeeded in creating an Assembler module to do what I think you're asking about. Maybe they would be willing to share their code, or already have on the CBTTAPE site.