Hi everyone, I am facing an issue with error capturing in CL
I understood that it is not possible to execute a subroutine inside a Monmsg like this
MONMSG MSGID(CPF0000) EXEC(CALLSUBR SUBR(ERRORSR))
But I need to capture all the errors that are thrown by the CL program into a file. I wrote an error subroutine inside CL like this
SUBR SUBR(ERRORSR)
RCVMSG PGMQ(*SAME) MSGQ(*PGMQ) MSGTYPE(*DIAG) +
WAIT(3) RMV(*NO) MSG(&MSG) +
MSGDTA(&MSGDATA) MSGDTALEN(&MSGLEN) +
MSGID(&MSGID)
CHGVAR VAR(&SQLSTMT) VALUE('INSERT INTO +
QTEMP.ERRFILE VALUES(' || ''''|| +
&MSGID||' '|| &MSG || ''''||')' )
RUNSQL SQL(&SQLSTMT) COMMIT(*NONE) NAMING(*SQL)
CALL PGM(RPTERROR)
ENDSUBR
If a command throw an error, I want to execute this error subroutine and continue the execution . Please let me know how to achieve this since writing subroutine inside monmsg is not an option.
I understood that it is not possible to execute a subroutine inside a Monmsg like this
MONMSG MSGID(CPF0000) EXEC(CALLSUBR SUBR(ERRORSR))
But I need to capture all the errors that are thrown by the CL program into a file. I wrote an error subroutine inside CL like this
SUBR SUBR(ERRORSR)
RCVMSG PGMQ(*SAME) MSGQ(*PGMQ) MSGTYPE(*DIAG) +
WAIT(3) RMV(*NO) MSG(&MSG) +
MSGDTA(&MSGDATA) MSGDTALEN(&MSGLEN) +
MSGID(&MSGID)
CHGVAR VAR(&SQLSTMT) VALUE('INSERT INTO +
QTEMP.ERRFILE VALUES(' || ''''|| +
&MSGID||' '|| &MSG || ''''||')' )
RUNSQL SQL(&SQLSTMT) COMMIT(*NONE) NAMING(*SQL)
CALL PGM(RPTERROR)
ENDSUBR
If a command throw an error, I want to execute this error subroutine and continue the execution . Please let me know how to achieve this since writing subroutine inside monmsg is not an option.
Comment