midrange.com code scratchpad
Name:
FNDMSG - Find messages with specified text string in them.
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
09/27/2010 03:43:42 pm
IP:
Logged
Description:
Find messages with specified text string in them. Display results in a subfile. Allow display of additional message information.
Code:
  1. Command source:
  2.              CMD        PROMPT('Find Messages')                        
  3.                                                                        
  4.              PARM       KWD(TEXT) TYPE(*CHAR) LEN(132) MIN(1) +        
  5.                           PROMPT('Search text')                        
  6.              PARM       KWD(MSGF) TYPE(QUAL1) MIN(1) PROMPT('Message + 
  7.                           file')                                       
  8.                                                                        
  9.  QUAL1:      QUAL       TYPE(*NAME) LEN(10)                            
  10.              QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +               
  11.                           SPCVAL((*LIBL)) PROMPT('Library')            
  12.  
  13. Command Processing RPG source:
  14. Note:  PRCCMD and SNDPGMMSG are wrappers for the QCAPCMD and QMHSNDPM API's respectively.
  15.  
  16.      h bnddir('FNDMSG') dftactgrp(*no) actgrp(*caller) option(*nodebugio)
  17.       *---------------------------------------------------------------------------------------------
  18.       *    Program  . . :  FNDMSG           Author . . :  Rick Chevalier
  19.       *    Date . . . . :  11/01/2001
  20.       *    Purpose  . . :  Find message ID of message containing specified text
  21.       *---------------------------------------------------------------------------------------------
  22.       *    Modifications:                               Date/Prgrmmr
  23.       *---------------------------------------------------------------------------------------------
  24.       *      None to this point.
  25.       *---------------------------------------------------------------------------------------------
  26.       *---------------------------------------------------------------------------------------------
  27.       * File definitions
  28.       *---------------------------------------------------------------------------------------------
  29.      fFndMsgD   cf   e             WorkStn
  30.      f                                     Sfile(Scrn1Sfl:SflRrn)
  31.  
  32.       *---------------------------------------------------------------------------------------------
  33.       * External procedure prototypes
  34.       *---------------------------------------------------------------------------------------------
  35.      d QMHRTVM         pr                  ExtPgm('QMHRTVM')
  36.      d                             1024                                         Message information
  37.      d                                9b 0                                      Message Info length
  38.      d                                8                                         Returned format name
  39.      d                                7                                         Message identifier
  40.      d                               20                                         Qualified file name
  41.      d                                1                                         Replacement data
  42.      d                                9b 0                                      Replacement data len
  43.      d                               10                                         Replace substit val
  44.      d                               10                                         Return fmt ctl char
  45.      d                              116                                         Error code
  46.      d                               10                                         Retrieve option
  47.      d                                9b 0                                      CCSID to convert to
  48.      d                                9b 0                                      Replace data CCSID
  49.  
  50.       * Process or run a command
  51.      dprccmd           pr              *
  52.      d                            32702                                         Command String
  53.      d                                1    options(*nopass: *omit)              Prompt type Dft = 2
  54.  
  55.       *---------------------------------------------------------------------------------------------
  56.       * Internal procedure prototypes
  57.       *---------------------------------------------------------------------------------------------
  58.  
  59.       *---------------------------------------------------------------------------------------------
  60.       * Data definitions
  61.       *---------------------------------------------------------------------------------------------
  62.       * Program entry parameters
  63.      d PSchStr         s            132
  64.      d PMsgF           s             20
  65.  
  66.       * Program status data structure
  67.      Dsystem_ds       sds
  68.      D sds_proc          *PROC                                                  * Procedure name
  69.  
  70.       * Parameters to Retrieve Message API (QMHRTVM)
  71.      d MsgInf          ds          1024    Inz
  72.      d  BytAvl                 5      8b 0
  73.      d  RtnMsgID              27     33
  74.      d  MsgOS                 65     68b 0
  75.      d  MsgLen                69     72b 0
  76.  
  77.      d MsgInfLen       s              9b 0 Inz(1024)
  78.      d FmtNme          s              8    Inz('RTVM0300')
  79.      d MsgID           s              7    Inz(*Blanks)
  80.      d QualMsgF        s             20
  81.      d RepDta          s              1    Inz(*Blank)
  82.      d RepDtaLen       s              9b 0 Inz(0)
  83.      d RplSbsVal       s             10    Inz('*NO')
  84.      d RtnFmtCtlC      s             10    Inz('*NO')
  85.  
  86.      d Error           ds           116
  87.      d  Provid                        9b 0 Inz(0)
  88.      d  Avail                         9b 0 Inz(0)
  89.  
  90.      d RtvOpt          s             10    Inz('*FIRST')
  91.      d CnvCCSID        s              9b 0 Inz(0)
  92.      d RplCCSID        s              9b 0 Inz(0)
  93.  
  94.       * Miscellaneous variables
  95.      d MsgTxt          s           1024
  96.      d FndAt           s              4s 0
  97.      d Selection       s               n
  98.  
  99.      ‚* Translation table to convert lowercase to uppercase
  100.      d UpperCase       c                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  101.      d LowerCase       c                   'abcdefghijklmnopqrstuvwxyz'
  102.  
  103.      ‚* Template for Display Message Description command (DSPMSGD)
  104.      d DspMsgD         s          32702
  105.  
  106.       *---------------------------------------------------------------------------------------------
  107.       * Calculations
  108.       *---------------------------------------------------------------------------------------------
  109.      c                   MoveA     '00'          *IN(80)
  110.      c                   Write     Scrn1Ctl
  111.      c                   Eval      sflrrn = 0
  112.      c                   Eval      QualMsgF = PMsgF
  113.      c                   Eval      PgmNme = SDS_Proc
  114.      c                   Eval      SelTxt = PSchStr
  115.      c                   Eval      MsgF = %subst(PMsgF: 1: 10)
  116.      c                   Eval      MsgFLib = %subst(PMsgF: 11: 10)
  117.  
  118.       * Retrieve message description from file
  119.      c                   CallP     QMHRTVM(MsgInf: MsgInfLen: FmtNme: MsgID:
  120.      c                               QualMsgF: RepDta: RepDtaLen: RplSbsVal:
  121.      c                               RtnFmtCtlC: Error: RtvOpt: CnvCCSID:
  122.      c                               RplCCSID)
  123.  
  124.      c                   DoW       RtnMsgID <> *Blanks
  125.  
  126.       * Parse out message text and ID
  127.      c                   Eval      DspMsgTxt = %Subst(MsgInf: MsgOS + 1: MsgLen)
  128.      c                   Eval      DspMsgID = RtnMsgID
  129.      c                   Eval      MsgID = RtnMsgID
  130.      c                   Eval      RtvOpt = '*NEXT'
  131.  
  132.       * If message contains search string write message to subfile
  133.      c                   Eval      MsgTxt = %XLate(LowerCase: UpperCase:
  134.      c                                        DspMsgTxt)
  135.      c                   Eval      PSchStr = %XLate(LowerCase: UpperCase:
  136.      c                                        PSchStr)
  137.      c                   Eval      FndAt = %Scan(%Trim(PSchStr): MsgTxt)
  138.  
  139.      c                   If        FndAt > 0
  140.      c                   Eval      sflrrn = sflrrn + 1
  141.      c                   Write     Scrn1Sfl
  142.      c                   EndIf
  143.  
  144.      c                   CallP     QMHRTVM(MsgInf: MsgInfLen: FmtNme: MsgID:
  145.      c                               QualMsgF: RepDta: RepDtaLen: RplSbsVal:
  146.      c                               RtnFmtCtlC: Error: RtvOpt: CnvCCSID:
  147.      c                               RplCCSID)
  148.      c                   EndDo
  149.  
  150.       * Display list of matching messages
  151.      c                   If        SflRrn > 0
  152.      c                   Eval      sflrrn = 1
  153.      c                   MoveA     '11'          *IN(80)
  154.  
  155.       * No messages found. Don't display subfile
  156.      c                   Else
  157.      c                   MoveA     '10'          *IN(80)
  158.      c                   EndIf
  159.  
  160.      c                   DoW       *InLR = *Off
  161.      c                   Write     Scrn1Ftr
  162.      c                   ExFmt     Scrn1Ctl
  163.  
  164.       * If user presses F3 or F12 exit program
  165.      c                   If        *InKC Or *InKL
  166.      c                   Eval      *InLR = *On
  167.  
  168.       * Display message description of selected messages
  169.      c                   Else
  170.      c                   Eval      Selection = *Off
  171.      c                   ReadC(E)  Scrn1Sfl
  172.  
  173.      c                   DoW       Not %Error And Not %EOF
  174.  
  175.      c                   If        SelMsg = '1'
  176.      c                   Eval      Selection = *On
  177.      c                   Eval      DspMsgD = 'DSPMSGD ' + DspMsgID + ' ' +
  178.      c                              %Trim(MsgFLib) + '/' + %Trim(MsgF)
  179.      c                   CallP     PrcCmd(DspMsgD)
  180.      c                   EndIf
  181.  
  182.      c                   Eval      SelMsg = ' '
  183.      c                   Update    Scrn1Sfl
  184.      c                   ReadC(E)  Scrn1Sfl
  185.      c                   EndDo                                                  Not %EOF
  186.  
  187.       * If Enter is pressed with no selection exit program
  188.      c                   If        Selection = *Off
  189.      c                   Eval      *InLR = *On
  190.      c                   EndIf
  191.  
  192.      c                   EndIf                                                  *InKC Or *InKL
  193.  
  194.      c                   EndDo                                                  *InLR = *Off
  195.  
  196.       *---------------------------------------------------------------------------------------------
  197.       * Define - Define key lists and parameter lists
  198.       *---------------------------------------------------------------------------------------------
  199.      c     Define        BegSr
  200.  
  201.       * Program entry parameter list
  202.      c     *Entry        PList
  203.      c                   Parm                    PSchStr                        Search string
  204.      c                   Parm                    PMsgF                          Message file
  205.  
  206.      c                   EndSr 
  207.  
  208. Display source:
  209.      A*%%TS  SD  20011102  084224  RCHEVA1     REL-V5R1M0  5722-WDS
  210.      A*%%EC
  211.      A                                      DSPSIZ(24 80 *DS3)
  212.      A          R SCRN1SFL                  SFL
  213.      A*%%TS  SD  20011102  073816  RCHEVA1     REL-V5R1M0  5722-WDS
  214.      A            SELMSG         1   B 11  3
  215.      A            DSPMSGID       7A  O 11  7
  216.      A            DSPMSGTXT     65A  O 11 15
  217.      A          R SCRN1CTL                  SFLCTL(SCRN1SFL)
  218.      A*%%TS  SD  20011102  084224  RCHEVA1     REL-V5R1M0  5722-WDS
  219.      A                                      CA03
  220.      A                                      CA12
  221.      A                                      OVERLAY
  222.      A  81                                  SFLDSP
  223.      A  80                                  SFLDSPCTL
  224.      A N80                                  SFLCLR
  225.      A  90                                  SFLEND(*MORE)
  226.      A                                      SFLSIZ(0014)
  227.      A                                      SFLPAG(0011)
  228.      A            SFLRRN         4S 0H      SFLRCDNBR(CURSOR)
  229.      A            PGMNME        10A  O  1  3COLOR(BLU)
  230.      A                                  1 28'Messages With Text String'
  231.      A                                      COLOR(WHT)
  232.      A                                  1 72DATE
  233.      A                                      EDTCDE(Y)
  234.      A                                      COLOR(BLU)
  235.      A                                  2 72TIME
  236.      A                                      COLOR(BLU)
  237.      A                                  3  2'Selection text . :'
  238.      A            SELTXT        50A  O  3 22
  239.      A                                  4  2'Message file . . :'
  240.      A            MSGF          10A  O  4 22
  241.      A                                  5  4'Library . . . . . :'
  242.      A            MSGFLIB       10A  O  5 25
  243.      A                                  7  5'Type choice and press Enter.'
  244.      A                                      COLOR(BLU)
  245.      A                                  8  7'1-Display details'
  246.      A                                      COLOR(BLU)
  247.      A                                 10  2'Sel'
  248.      A                                      COLOR(WHT)
  249.      A                                 10  7'Msg. ID'
  250.      A                                      COLOR(WHT)
  251.      A                                 10 20'Message Text'
  252.      A                                      COLOR(WHT)
  253.      A          R SCRN1FTR
  254.      A*%%TS  SD  20011101  110051  RCHEVA1     REL-V5R1M0  5722-WDS
  255.      A                                 23  4'F3=Exit'
  256.      A                                      COLOR(BLU)
  257.      A                                 23 15'F12=Cancel'
  258.      A                                      COLOR(BLU) 
© 2004-2019 by midrange.com generated in 0.009s valid xhtml & css