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 programor 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 RPG program monitoring the execution 000000 003200 * of a MMAIL command. 000000 003300 *======================================================================== 000000 003400 000000 003500 /copy MMAIL/qrpglesrc,hspecs 000000 003600 /copy MMAIL/qrpglesrc,hspecsbnd 000000 003700 /copy MMAIL/qrpglesrc,prototypeb 000000 003800 /copy MMAIL/qrpglesrc,usec 000000 003900 000000 004000 D command s 512 000000 004100 D rc s 10i 0 000000 004200 /free 000000 004300 000000 004400 rc=doCmd('ADDLIBLE MMAIL'); 000000 004500 000000 004600 rc=doCmd('CHGJOB INQMSGRPY(*DFT)'); 000000 004700 000000 004800 command='MMAIL/EMLSTMF SUBJECT(''Bad command'') + 000000 004900 FROMNAME(''Jack Brown'') + 000000 005000 FROMADDR(''jbrown@gmail.com'') + 000000 005100 TO(''smallt@gmail.com''/''Small Tony''/*TO) + 000000 005200 STMF(''/tmp/missing.txt'')'; 000000 005300 rc=doCmd(command); 000000 005400 if rc<>0; // command failed, developer must take actions! 000000 005500 // ... user code here ... 000000 005600 endif; 000000 005700 000000 005800 return; 000000