How can a CL proc know it's own library?
Posted on 2004-11-05
Dear AS/400 Experts,
This is a surprisingly tough question.
I have a CL procedure that must figure out at run-time which library it is being run from. Checking the library list is not sufficient.
I had searched EE for an answer, and found the following clever, incredibly convoluted solution:
OVRPRTF FILE(QPPGMDMP) TOFILE(NOSUCHLIB/NOSUCHFIL)
MONMSG MSGID(CPF0570 CPF4101) EXEC(DO)
RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA)
CHGVAR &OBJLIB (%SST(&MSGDTA 11 10))
It actually generates an error message, which happens to contain the name of the library I am seeking.
Unfortunately, it also causes any subsequent COBOL dumps to fail. So I need another method.
I have 15 years of AS/400 experience and I can't answer this basic question! How about you experts?