midrange.com code scratchpad
Name:
Peter Dow
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
10/23/2020 09:29:51 pm
IP:
Logged
Description:
Watch monitor program demonstrating conversion of 8-byte message timestamp to database timestamp
Code:
  1.       *    A system watch monitor job, started with
  2.       *
  3.       *        STRWCH SSNID(TEST8TS)
  4.       *               WCHPGM(TEST8TS)
  5.       *               WCHMSG(
  6.       *                      (CPI9200 *NONE *MSGDTA *ALL)
  7.       *                     )
  8.       *               WCHMSGQ((*JOBLOG))
  9.       *               WCHJOB((*ALL/*ALL/*ALL))
  10.       *
  11.       *    will call this program, passing it the message information.
  12.       *
  13.       *    Definition of the event data passed from the watch monitor to this program is found at
  14.       *      https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/apis/xwchevnt.htm
  15.  
  16.       /copy qsysinc/qrpglesrc,qusec
  17.  
  18.      d TEST8TS         pi                                                       *ENTRY
  19.      d  peOption                     10a
  20.      d  peSessionId                  10a
  21.      d  peError                      10a
  22.      d  peEventData                2048a
  23.  
  24.      d CvtDatTim       pr                  extpgm('QWCCVTDT')
  25.      d  InpFmt                       10a   const
  26.      d  InpValue                     20a   const options(*varsize)
  27.      d  OutFmt                       10a   const
  28.      d  OutValue                     20a   options(*varsize)
  29.      d  ErrCde                             likeds(QUSEC)
  30.      d  InpTZ                        10a   const options(*nopass)
  31.      d  OutTZ                        10a   const options(*nopass)
  32.      d  TZInfo                        1a   const options(*nopass)
  33.      d  LenTZInfo                    10i 0 const options(*nopass)
  34.      d  PrecInd                       1a   const options(*nopass)
  35.      d  InpTimInd                     1a   const options(*nopass)
  36.  
  37.      d EventDataDS     ds          2048    qualified
  38.      d  Length                       10u 0
  39.      d  MsgId                         7a
  40.      d  Reserved1                     1a
  41.      d  Msgq                         10a
  42.      d  MsgqLib                      10a
  43.      d  SrcJob                       10a
  44.      d  SrcJobUsr                    10a
  45.      d  SrcJobNbr                     6a
  46.      d  OriginalReplaceentDataLength...
  47.      d                               10u 0
  48.      d  SendingPgm                  256a
  49.      d  SendingPgm10                 10a   overlay(SendingPgm:1)
  50.      d  SendingMod                   10a
  51.      d  OffsetToSendingProcedureName...
  52.      d                               10u 0
  53.      d  LengthOfSendingProcedureName...
  54.      d                               10u 0
  55.      d  ReceivingPgm                 10a
  56.      d  ReceivingMod                 10a
  57.      d  OffsetToReceivingProcedureName...
  58.      d                               10u 0
  59.      d  LengthOfReceivingProcedureName...
  60.      d                               10u 0
  61.      d  MsgSeverity                  10u 0
  62.      d  MsgType                      10a
  63.      d  MsgTimeStamp                  8a
  64.      d  MsgKey                        4a
  65.      d  OffsetToReplacementData...
  66.      d                               10u 0 overlay(EventDataDS:441)
  67.      d  LengthOfReplacementData...
  68.      d                               10u 0 overlay(EventDataDS:445)
  69.  
  70.      d DOSds           ds                  qualified
  71.      d  hours                         3u 0                                      0-23
  72.      d  minutes                       3u 0                                      0-59
  73.      d  seconds                       3u 0                                      0-59
  74.      d  hSeconds                      3u 0                                      0-99
  75.      d  day                           3u 0                                      1-31
  76.      d  month                         3u 0                                      1-12
  77.      d  year                          5u 0                                      0000-9999 eg 1952
  78.      d  TimZonOffset                  5i 0                                      in minutes
  79.      d  dayOfWeek                     3u 0                                      0-6 (0=Sunday)
  80.  
  81.      d TSds            ds                  qualified
  82.      d  year                          4s 0                                      0000-9999 eg 1952
  83.      d                                1a   inz('-')
  84.      d  month                         2s 0                                      1-12
  85.      d                                1a   inz('-')
  86.      d  day                           2s 0                                      1-31
  87.      d                                1a   inz('-')
  88.      d  hours                         2s 0                                      0-23
  89.      d                                1a   inz('.')
  90.      d  minutes                       2s 0                                      0-59
  91.      d                                1a   inz('.')
  92.      d  seconds                       2s 0                                      0-59
  93.      d                                1a   inz('.')
  94.      d  hSeconds                      2s 0                                      0-99
  95.      d                                4a   inz('0000')
  96.  
  97.      d gMsg52          s             52a
  98.      d gTimeStamp      s               z
  99.  
  100.         *inLR = *on;
  101.  
  102.         peError = *blanks; // assume no errors
  103.  
  104.         EventDataDS = peEventData;
  105.  
  106.         CvtDatTim('*DTS' : EventDataDS.MsgTimestamp : '*DOS' :DOSds : QUSEC);
  107.         eval-corr TSds = DOSds;
  108.         gTimeStamp = %timestamp(TSds);
  109.         dsply (gTimeStamp) 'myuserid';
  110.  
© 2004-2019 by midrange.com generated in 0.007s valid xhtml & css