000100/*============================================================================*/ 000000 000200/* There are three possible reasons for MMAIL code receiving */ 000000 000300/* an escape message: */ 000000 000400/* 1- Some error in a MMAIL command, detected by its command validity */ 000000 000500/* check program */ 000000 000600/* 2- Some exception in the code itself, outside of its control */ 000000 000700/* 3- MMAIL is facing a situation where it cannot do what requested. */ 000000 000800/* In this case MMAIL is still in control and sends an escape */ 000000 000900/* message telling what the problem is. */ 000000 001000/* */ 000000 001100/* MMAIL does not use any Program Status SubRoutine (*PSSR). */ 000000 001200/* In this way the decision on what to do in case of error is left to */ 000000 001300/* the calling program or to the user. */ 000000 001400/* */ 000000 001500/* There are two possible scenarios: */ 000000 001600/* - Interactive environment. The process stops and the user receives */ 000000 001700/* the escape message. */ 000000 001800/* - Batch environment. */ 000000 001900/* --If the submit command specified INQMSGRPY(*RQD) */ 000000 002000/* then the process stops and a message is sent tomessage queue */ 000000 002100/* QSYSOPR and waits for a reply. */ 000000 002200/* --If the submit command specified INQMSGRPY(*DFT), the control */ 000000 002300/* returns immediately to the calling program. */ 000000 002400/* Then either the calling program monitors for exceptions and decides */ 000000 002500/* what to do, or the calling program is halted by the escape message. */ 000000 002600/* Our suggestion for batch jobs using MMAIL is that they are submitted */ 000000 002700/* with INQMSGRPY(*DFT) and that the calling program monitors for */ 000000 002800/* exception events. */ 000000 002900/* */ 000000 003000/* */ 000000 003100/* The following is the example of a CL program monitoring the execution */ 000000 003200/* of a MMAIL command. */ 000000 003300/*============================================================================*/ 000000 003400 PGM 000000 003500 DCL VAR(&COMMAND) TYPE(*CHAR) LEN(512) 000000 003600 DCL VAR(&COMMANDL) TYPE(*DEC) LEN(15 5) VALUE(512) 000000 003700 000000 003800 ADDLIBLE LIB(MMAIL) 000000 003900 MONMSG MSGID(CPF0000) 000000 004000 000000 004100 CHGJOB INQMSGRPY(*DFT) 000000 004200 000000 004300 CHGVAR VAR(&COMMAND) VALUE('MMAIL/EMLSTMF + 000000 004400 SUBJECT(''Bad command'') FROMNAME(''Jack + 000000 004500 Brown'') TO(''smallt@gmail.com''/''Small + 000000 004600 Tony''/*TO) STMF(''/tmp/missing.txt'')') 000000 004700 000000 004800 CALL PGM(QCMDEXC) PARM(&COMMAND &COMMANDL) 000000 004900 MONMSG MSGID(CEE9901 CPF0000) EXEC(DO) 000000 005000 /* ... user code here ... */ 000000 005100 ENDDO 000000 005200 000000 005300 RETURN 000000 005400 ENDPGM 000000