midrange.com code scratchpad
Name:
RPG to test removing job log messages
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
07/02/2015 03:11:12 pm
IP:
Logged
Description:
MONITOR still puts messages in the job log. QMHRMVPM can remove them, but at what cost?
Code:
  1.       // Test removing job log messages
  2.       /copy qrpglesrc,stdhspec
  3.  
  4.        dcl-s divisor int(10) inz(10);
  5.        dcl-s dividend int(10) inz(0);
  6.        dcl-s result int(10) inz(0);
  7.        dcl-s start timestamp;
  8.        dcl-s stop timestamp;
  9.        dcl-s duration int(10);
  10.        dcl-s i int(10);
  11.        dcl-s loops int(10) inz(100000);
  12.  
  13.        // error code parameter descriptions
  14.        /include qsysinc/qrpglesrc,qusec
  15.        dcl-ds apierror likeds(qusec);
  16.  
  17.        // remove program messages API
  18.         dcl-pr QmhRmvPM extpgm('QMHRMVPM');
  19.            CallStackEntry char(64) const options(*varsize);
  20.            CallStackCount int(10) const;
  21.            MsgKey char(4) const;
  22.            MsgToRemove char(10) const;
  23.            ApiErrorDS like(qusec);
  24.         end-pr;
  25.  
  26.        // first, cause an error :-)
  27.        // result = divisor / dividend; - this throws the following:
  28.        // MCH1211 Escape
  29.        // RNQ0102 Sender copy
  30.        // RNQ0102 Inquiry
  31.  
  32.        // first, a baseline division without errors
  33.        // do it a lot in order to see the ramifications
  34.        dividend = 1;
  35.        exsr withmonitor;
  36.  
  37.        // next, with errors
  38.        // do it a lot in order to see the ramifications
  39.        dividend = 0;
  40.        exsr withmonitor;
  41.  
  42.        *inlr = *on;
  43.  
  44.        // subroutine so we don't have to duplicate the code
  45.        // don't judge me
  46.        begsr withMonitor;
  47.          start = %timestamp(*sys);
  48.  
  49.          // this avoids the white message, but still puts MCH1211 Escape in the job log
  50.          start = %timestamp(*sys);
  51.  
  52.          for i = 1 to loops;
  53.            monitor;
  54.              result = divisor / dividend;
  55.            on-error;
  56.              // do something about the error!
  57.              result = 0;
  58.  
  59.              // after that, remove the message from the job log
  60.              qusbprv = %size(apierror);
  61.              apierror = qusec;
  62.              qmhrmvpm('*':           // this program's msgq
  63.                       0:             // this procedure's relative call stack
  64.                      *blanks:        // no msg key; see the next parm
  65.                      '*NEW':         // remove all the new messages
  66.                      apierror);      // API will return errors here
  67.            endmon;
  68.          endfor;
  69.  
  70.          // how long did that take?
  71.          stop = %timestamp(*sys);
  72.          duration = %diff(stop: start: *mseconds);
  73.          dsply duration;
  74.        endsr;
© 2004-2019 by midrange.com generated in 0.005s valid xhtml & css