Code:
- // Test removing job log messages
- /copy qrpglesrc,stdhspec
-
- dcl-s divisor int(10) inz(10);
- dcl-s dividend int(10) inz(0);
- dcl-s result int(10) inz(0);
- dcl-s start timestamp;
- dcl-s stop timestamp;
- dcl-s duration int(10);
- dcl-s i int(10);
- dcl-s loops int(10) inz(100000);
-
- // error code parameter descriptions
- /include qsysinc/qrpglesrc,qusec
- dcl-ds apierror likeds(qusec);
-
- // remove program messages API
- dcl-pr QmhRmvPM extpgm('QMHRMVPM');
- CallStackEntry char(64) const options(*varsize);
- CallStackCount int(10) const;
- MsgKey char(4) const;
- MsgToRemove char(10) const;
- ApiErrorDS like(qusec);
- end-pr;
-
- // first, cause an error :-)
- // result = divisor / dividend; - this throws the following:
- // MCH1211 Escape
- // RNQ0102 Sender copy
- // RNQ0102 Inquiry
-
- // first, a baseline division without errors
- // do it a lot in order to see the ramifications
- dividend = 1;
- exsr withmonitor;
-
- // next, with errors
- // do it a lot in order to see the ramifications
- dividend = 0;
- exsr withmonitor;
-
- *inlr = *on;
-
- // subroutine so we don't have to duplicate the code
- // don't judge me
- begsr withMonitor;
- start = %timestamp(*sys);
-
- // this avoids the white message, but still puts MCH1211 Escape in the job log
- start = %timestamp(*sys);
-
- for i = 1 to loops;
- monitor;
- result = divisor / dividend;
- on-error;
- // do something about the error!
- result = 0;
-
- // after that, remove the message from the job log
- qusbprv = %size(apierror);
- apierror = qusec;
- qmhrmvpm('*': // this program's msgq
- 0: // this procedure's relative call stack
- *blanks: // no msg key; see the next parm
- '*NEW': // remove all the new messages
- apierror); // API will return errors here
- endmon;
- endfor;
-
- // how long did that take?
- stop = %timestamp(*sys);
- duration = %diff(stop: start: *mseconds);
- dsply duration;
- endsr;
|
|