header
asked on
COBOL - Get Program ID Automatically?
I'm writing some error handling code in COBOL using a centralized error log CL. I want to be able to send the COBOL Program ID where the error is generated without manually defining in each program the program name. Due to the size of the project and the fact that there are several developers, I want to keep this code as plug and play as possible with a minimal of changes needed to use it somewhere.
In other words, I want to avoid this:
10 WS-ERROR-PROGRAM PIC X(10) VALUE "PROGA".
I have read where there is a special register to contain the Compile Date/Time and was hoping that there is something similiar for the Program ID. Is there a Register that can be used for this or a Special-Name or something?
In other words, I want to avoid this:
10 WS-ERROR-PROGRAM PIC X(10) VALUE "PROGA".
I have read where there is a special register to contain the Compile Date/Time and was hoping that there is something similiar for the Program ID. Is there a Register that can be used for this or a Special-Name or something?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I was hoping it was going to be a little easier than that (like you suggest w/ RPG), but it may be the best solution available.
I'm going to leave this question open for a little longer to see if anyone else has any ideas.
I'm going to leave this question open for a little longer to see if anyone else has any ideas.
ASKER
Dave,
Thanks for the quick answer. I wen't ahead and awarded you with the answer as I feel that your method will be the best solution.
Thanks
Thanks for the quick answer. I wen't ahead and awarded you with the answer as I feel that your method will be the best solution.
Thanks
in RPG we have the program data structure that holds that information (you may have somthing simular in Cobol)
failing theat this Call this CL program in you initialisation
PGM PARM(&CALLER &PGM)
DCL VAR(&CALLER) TYPE(*CHAR) LEN(10)
DCL VAR(&PGM) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGKEY) TYPE(*CHAR) LEN(4)
DCL VAR(&SENDER) TYPE(*CHAR) LEN(80)
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))
CHGVAR VAR(&CALLER) VALUE(' ')
SNDPGMMSG MSG('WHO CALLED ME?') TOPGMQ(*PRV (&PGM)) +
KEYVAR(&MSGKEY)
RCVMSG PGMQ(*PRV (&PGM)) MSGTYPE(*INFO) +
MSGKEY(&MSGKEY) RMV(*YES) SENDER(&SENDER)
CHGVAR VAR(&CALLER) VALUE(%SST(&SENDER 56 10))
GOTO CMDLBL(ENDPGM)
ERROR: CHGVAR VAR(&CALLER) VALUE(' ')
ENDPGM: ENDPGM
Dave