× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi all,
  I need check message text specified string under some job joblog by
MSGID,  so I wrote a command SCNJOBLOG to do this. For example how to check
MQ manager active or some web server or WAS server istance start or
not.  Following is command and CPP source for your reference.

Command  SCNJOBLOG:

/********************************************************************/
/*   Title:      SCNJOBLOG: Scan jobs log                           */
/*                                                                  */
/*   Description - This command performs job log scaned by MSGID    */
/*                                                                  */
/*   The Create Command command should include the following:       */
/*                                                                  */
/*           CRTCMD     CMD(SCNJOBLOG) PGM(SCNJOBLOGR)              */
/*                      ALLOW(*IPGM *BPGM)                          */
/********************************************************************/
/*  =============================================================== */
/*  = Date  : 2006/12/20                                          = */
/*  = Author: Vengoal Chang                                       = */
/*  =============================================================== */
     /*------------------------------------------------*/
     /*  Command Definition                            */
     /*------------------------------------------------*/

            CMD        PROMPT('Scan Job Log by MSGID')
            PARM       KWD(JOB) TYPE(*SNAME) LEN(10) MIN(1) +
                         PROMPT('Job name')
            PARM       KWD(USER) TYPE(*SNAME) LEN(10) MIN(1) +
                         PROMPT('User name')
            PARM       KWD(JOBNBR) TYPE(*CHAR) LEN(6) RANGE(000000 +
                         999999) MIN(1) PROMPT('Job number')
            PARM       KWD(MSGID) TYPE(*CHAR) LEN(7) SPCVAL((*ALL)) +
                         MIN(1) PROMPT('Message ID to be searched')
            PARM       KWD(SCHSTR) TYPE(*CHAR) LEN(50) +
                         PROMPT('String searched in MSGID Text')
            PARM       KWD(QUOTE) TYPE(*CHAR) LEN(4) RSTD(*YES) +
                         DFT(*NO) VALUES(*YES *NO) PROMPT('Include +
                         quote between SCHSTR')
            PARM       KWD(FOUND) TYPE(*CHAR) LEN(1) RTNVAL(*YES) +
                         PROMPT('CL var for String found (1)')


CPP: SCNJOBLOGR

    H DFTACTGRP(*NO) ACTGRP(*CALLER) BNDDIR('QC2LE') EXPROPTS(*RESDECPOS)
    H DATFMT(*ISO)   TIMFMT(*ISO)    OPTION(*NODEBUGIO) DEBUG
     *----------------------------------------------------------------
     * SCNJOBLOG  Scan specified job's job log by MSGID to
     * search some string in job log
     *
     *----------------------------------------------------------------
     * This program retrieve specified job job's log and return found
     * search string or not.
     *
     * CRTBNDRPG with target release V5R1 and later
     *
     *----------------------------------------------------------------
     * api (application program interfaces) used:
     * quscrtus  create user space
     * qusptrus  retrieve pointer to user space
     * qmhljobl  list job log messages
     * qmhsndm   send non-program messages
     *----------------------------------------------------------------
    D uSpaceName      s             20    inz('RTVJOBLOG QTEMP     ')
    D msgtxt          s            256
    D QUSLIB          s             10

     *  -------------------------------------------------------------------
     *  -  User space attributes data structure                           -
     *  -------------------------------------------------------------------

    D QUSAttr         DS
    D  QUSNumRec                    10I 0 Inz( 1 )
    D  QUSKey                       10I 0 Inz( 3 )
    D  QUSRecLen                    10I 0 Inz( 1 )
    D  QUSRecData                    1A   Inz( '1' )
     *----------------------------------------------------------------
    D struct          DS
    D  msgdln                       10I 0
    D  msgq#                        10I 0
    D  msgkey                        4
    D  msgq                         20    INZ('QSYSOPR   *LIBL     ')
     *
     *----------------------------------------------------------------
     * Get user space list info from header section.
     *----------------------------------------------------------------
    D                 ds                  based(uHeadPtr)
    D uOffSetToList         125    128i 0
    D uNumOfEntrys          133    136i 0
    D uSizeOfEntry          137    140i 0
     *
    D uListEntry1     ds                  Based(uListPtr )
    D uOffsetToNext                 10i 0 overlay(uListEntry1:1)
    D uOffsetToFlds                 10i 0 overlay(uListEntry1:5)
    D uNumFldsRetrnd                10i 0 overlay(uListEntry1:9)
    D uMsgSeverity                  10i 0 overlay(uListEntry1:12)
    D uMsgId                         7a   overlay(uListEntry1:17)
    D uMsgType                       2a   overlay(uListEntry1:24)
    D uMsgKey                        4a   overlay(uListEntry1:26)
    D uMsgFile                      20a   overlay(uListEntry1:30)
    D uMsgFileName                  10a   overlay(uListEntry1:30)
    D uMsgFileLib                   10a   overlay(uListEntry1:40)
     * these fields repeat for each key selected.
    D uListEntry2     ds                  Based(uListPtr2)
    D u2OffsetToNext                10i 0
    D u2LengthOfFlds                10i 0
    D u2IdentifierF                 10i 0
    D u2TypeOfData                   1a
    D u2StatOfData                   1a
    D u2Reserved                    14a
    D u2LengthOfData                10i 0
    D u2Data                       500
     *----------------------------------------------------------------
     * Error return code parm for APIs.
     *----------------------------------------------------------------
    D vApiErrDs       ds
    D  vbytpv                       10i 0 inz(%size(vApiErrDs))
    D  vbytav                       10i 0 inz(0)
    D  vmsgid                        7a
    D  vresvd                        1a
    D  vrpldta                      50a
     *
     *----------------------------------------------------------------
     * Message selection data structure.
     *
     *                               Retrieve JOB Log direction
     *-----------------------------|-------------|--------------------
     * Parameter                   | From Top    | From Bottom
     *-----------------------------|-------------|--------------------
     * msListDirection             | *NEXT       | *PRV
     * msStartingMessageKey        | X'00000000' | X'FFFFFFFF'
     *----------------------------------------------------------------
    D MsgSelectDS     ds
    D  msMaxMsgRequested...
    D                               10i 0 inz(-1)
overlay(msgSelectDS:1)   num of msg requested
    D  msListDirection...
    D                               10a   inz('*NEXT')
overlay(msgSelectDS:5)   List direction
    D  msQualifiedJobName...
    D                               10a   inz('*')
overlay(msgSelectDS:15)     * = current job
    D  msQualifiedUserName...
    D                               10a   inz(' ')
overlay(msgSelectDS:25)       = current job
    D  msQualifiedJobNumber...
    D                                6a   inz(' ')
overlay(msgSelectDS:35)       = current job
    D  msInternalJobIdentifier...
    D                               16a   inz(' ')
overlay(msgSelectDS:41)       = current job
    D  msStartingMessageKey...
    D                                4a
inz(x'00000000')                     start newest message
    D
overlay(msgselectDS:57)
    D  msMaxMsgLength...
    D                               10i 0 inz(500)
overlay(msgSelectDS:61)  id 301,302 lengths
    D  msMaxMsgHelpLength...
    D                               10i 0 inz(100)
overlay(msgSelectDS:65)  id 401,402,403,404
    D  msOffsetToIdentifiersOfFieldstoReturn...
    D                               10i 0 inz(84)
overlay(msgSelectDS:69)  to start of array
    D  msNumberOfFieldsToReturn...
    D                               10i 0 inz(1)
overlay(msgSelectDS:73)
    D  msOffsetToCallMsgQname...
    D                               10i 0 inz(88)
overlay(msgSelectDS:77)
    D  msLengthOfCallMsgQname...
    D                               10i 0 inz(1)
overlay(msgSelectDS:81)
    D  msIndentifiersOfFieldsToReturn...
    D                               10i 0 inz(0302)
overlay(msgSelectDS:85)
    D  msCallMessageQueueName...
    D                                1a   inz('*')
overlay(msgSelectDS:89)
     *----------------------------------------------------------------
     * Create Prototypes for calls
     * --------------------------------------------------------------------
     *  -  QusCrtUs  - Create User Space API                              -
     *  -                                                                 -
     *  -  Usage      Length   Type         Parameter Description         -
     *  -                                                                 -
     *  -  Input          20   Character    Qualified user space name     -
     *  -  Input          10   Character    Extended attribute            -
     *  -  Input         4 0   Binary       Initial size                  -
     *  -  Input           1   Character    Initial value                 -
     *  -  Input          10   Character    Public authority              -
     *  -  Input          50   Character    Text description              -
     * --------------------------------------------------------------------
    D quscrtus        PR                  ExtPgm('QUSCRTUS')
    D                               20
    D                               10    const
    D                               10i 0 const
    D                                1    const
    D                               10    const
    D                               50    const
    D                               10    const
    Db                                    like(vApiErrDS)
     *  -------------------------------------------------------------------
     *  -  Qusptrus      - Get user space pointer       API               -
     *  -                                                                 -
     *  -  Usage      Length   Type         Parameter Description         -
     *  -                                                                 -
     *  -  Input          20   Character    Qualified user space name     -
     *  -  Output          *   Pointer      UserSpace Pointer             -
     *  -  Output                           Error Code                    -
     *  - -----------------------------------------------------------------
    D qusptrus        PR
ExtPgm('QUSPTRUS')                   retrieve pointer
    D
20                                         Space Name
    D
*                                        pointer
    Db
like(vApiErrDS)                      error parm
     *  -------------------------------------------------------------------
     *  -  Quscusat      - Change User Space Attributes API               -
     *  -                                                                 -
     *  -  Usage      Length   Type         Parameter Description         -
     *  -                                                                 -
     *  -  Output         10   Character    Returned library              -
     *  -  Input          20   Character    Qualified user space name     -
     *  -  Input          13   Character    Attribute structure           -
     *  -  Output                           Error code                    -
     *  -------------------------------------------------------------------
    D quscusat        PR                  ExtPgm( 'QUSCUSAT' )
    D                               10A   Const
    D                               20A   Const
    D                               13A   Const
    Db                                    like(vApiErrDS)
     *  ---------------------------------------------------------------
    D system          PR            10I 0 extproc('system')
    D  i_cmd                          *   value options(*string)
     *
    D EXCP_MSGID      S              7A   import('_EXCP_MSGID')
     *  --------------------------------------------------------------
    D qmhljobl        PR                  ExtPgm('QMHLJOBL ')
    D                               20
    D                                8    const
    Db                                    like(MsgSelectDS)
    D                               10i 0 const
    D                                8    const
    Db                                    like(vApiErrDS)
     *  --------------------------------------------------------------
    D SNDPGMMSG       PR                  EXTPGM('QMHSNDPM')
    D   MESSAGEID                    7A   CONST
    D   QUALMSGF                    20A   CONST
    D   MSGDATA                    256A   CONST
    D   MSGDTALEN                   10I 0 CONST
    D   MSGTYPE                     10A   CONST
    D   CALLSTKENT                  10A   CONST
    D   CALLSTKCNT                  10I 0 CONST
    D   MESSAGEKEY                   4A
    D   ERRORCODE                32766A   OPTIONS(*VARSIZE)
     *  --------------------------------------------------------------

    D main            PR                  extpgm('SCNJOBLOGR')
    D  jobname                      10
    D  jobuser                      10
    D  jobnumber                     6
    D  msgId                         7
    D  searchStr                    48
    D  includeQuote                  4
    D  StrFound                      1

    D main            PI
    D  jobname                      10
    D  jobuser                      10
    D  jobnumber                     6
    D  msgId                         7
    D  searchStr                    48
    D  includeQuote                  4
    D  StrFound                      1

    D  searchString   S             50
    D  strpos         S              5I 0
    D  quote          S              1    Inz('''')
    D WWMSGLEN        S             10I 0
    D WWTHEKEY        S              4A
     *----------------------------------------------------------------
    C                   eval      msQualifiedJobName   = jobname
    C                   eval      msQualifiedUserName  = jobuser
    C                   eval      msQualifiedJobNumber = jobnumber
    C                   If        includeQuote = '*YES'
    C                   eval      searchString  = quote + %trim(searchStr)
+
    C                                             quote
    C                   Else
    C                   eval      searchString  = %trim(searchStr)
    C                   EndIf
    C                   eval      StrFound = '0'
     *----------------------------------------------------------------
     * Create user space
    C                   callp     QUSCRTUS(
    C                             uSpaceName:
    C                             'TEST':
    C                             1500000:
    C                             x'00':
    C                             '*ALL':
    C                             'User Space RTVJOBLOG' :
    C                             '*NO':
    C                             vApiErrDs)
     * set UserSpace to autoextended
    C                   CallP     QUSCUSAT( QUSLib     :
    C                                       uSpaceName :
    C                                       QUSAttr    :
    C                                       vApiErrDs  )
     * Get pointer to user space
    C                   callp     QUSPTRUS(
    C                             uSpaceName:
    C                             uHeadPtr:
    C                             vApiErrDs)
     * call api to load job log into user space.
    C                   callp     QMHLJOBL(
    C                             uSpaceName:
    C                             'LJOB0100':
    C                             MsgSelectDS:
    C                             %len(MsgSelectDS):
    C                             'JSLT0100':
    C                             vApiErrDs)
     * Process elements
     *
    C                   If        vbytav = 0
    C                   eval      uListPtr  = uHeadPtr + uOffSetToList
1B  C                   do        uNumOfEntrys

    C                   If        uMsgId = msgId
    C                   eval      uListPtr2 = uHeadPtr + uOffsetToFlds

    C                   eval      msgtxt = %subst(u2Data:1:U2LengthOfData)
    C                   eval      strPos = %scan(%trim(searchString) :
msgtxt)
    C                   If        strPos > 0
    C                   eval      StrFound = '1'
    C                   leave
    C                   EndIf

    C                   EndIf

    C                   eval      uListPtr  = uHeadPtr  + uOffsetToNext
1E  C                   enddo
    C                   Else
    C                   eval      msgtxt = 'API Error: ' + vmsgid +
    C                                 '. Please see job log for detail'
    C                   eval      WWMSGLEN = %len(%trimr(msgtxt))
    C                   CALLP     SNDPGMMSG('CPF9897': 'QCPFMSG   *LIBL':
    C                               msgtxt:WWMSGLEN: '*ESCAPE':
    C                               '*PGMBDY': 1: WWTHEKEY: vApiErrDs)
    C                   EndIf

    C                   eval      *inlr = *on
    C                   return

Testing program to check MQ server start or not:
CHKQMSTSC:
first get MQ all job name with AMQZXMA0 job, then scan job log msgid AMQ8003
message text to match search Queue manager name string , return '1' mean
QMGR start, '0' not start.

PGM   (&QMGR &RC)

            DCL        VAR(&QMGR)       TYPE(*CHAR) LEN(48)
            DCL        VAR(&RC)         TYPE(*CHAR) LEN(1)
            DCL        VAR(&JOBNAME)    TYPE(*CHAR) LEN(10)
            DCL        VAR(&USER)       TYPE(*CHAR) LEN(10)
            DCL        VAR(&JOBNBR)     TYPE(*CHAR) LEN(6)
            DCL        VAR(&STATUS)     TYPE(*CHAR) LEN(10)
            DCL        VAR(&JOBTYPE)    TYPE(*CHAR) LEN(1)
            DCL        VAR(&SUBTYPE)    TYPE(*CHAR) LEN(1)

            DCL        VAR(&USP_NAME)   TYPE(*CHAR) LEN(10)
            DCL        VAR(&USP_LIB)    TYPE(*CHAR) LEN(10)
            DCL        VAR(&USP_QUAL)   TYPE(*CHAR) LEN(20)
            DCL        VAR(&USP_TYPE)   TYPE(*CHAR) LEN(10)
            DCL        VAR(&USP_SIZE)   TYPE(*CHAR) LEN(4)
            DCL        VAR(&USP_FILL)   TYPE(*CHAR) LEN(1)
            DCL        VAR(&USP_AUT)    TYPE(*CHAR) LEN(10)
            DCL        VAR(&USP_TEXT)   TYPE(*CHAR) LEN(50)

            DCL        VAR(&API_USQUAL) TYPE(*CHAR) LEN(20)
            DCL        VAR(&API_JBQUAL) TYPE(*CHAR) LEN(26)
            DCL        VAR(&API_JBNAM)  TYPE(*CHAR) LEN(10)
            DCL        VAR(&API_USER)   TYPE(*CHAR) LEN(10)
            DCL        VAR(&API_JOBNR)  TYPE(*CHAR) LEN(6)
            DCL        VAR(&API_STATUS) TYPE(*CHAR) LEN(10)

            DCL        VAR(&STARTPOS)   TYPE(*CHAR) LEN(4)
            DCL        VAR(&DATALEN)    TYPE(*CHAR) LEN(4)
            DCL        VAR(&HEADER)     TYPE(*CHAR) LEN(150)
            DCL        VAR(&LST_OFFSET) TYPE(*DEC)  LEN(5 0)
            DCL        VAR(&LST_SIZE)   TYPE(*DEC)  LEN(5 0)
            DCL        VAR(&LST_DATA)   TYPE(*CHAR) LEN(4096)
            DCL        VAR(&LST_NBR)    TYPE(*DEC)  LEN(5 0)
            DCL        VAR(&LST_LEN)    TYPE(*DEC)  LEN(5 0)
            DCL        VAR(&LST_LENBIN) TYPE(*CHAR) LEN(4)
            DCL        VAR(&LST_POSBIN) TYPE(*CHAR) LEN(4)
            DCL        VAR(&LST_COUNT)  TYPE(*DEC)  LEN(5) VALUE(0)
            DCL        VAR(&TYPE) TYPE(*CHAR) LEN(1) VALUE('*')
            DCL        VAR(&NBRTORTN)  TYPE(*CHAR)  LEN(4)
            DCL        VAR(&KEYSTORTN) TYPE(*CHAR)  LEN(4)
            DCL        VAR(&SBSSYS   ) TYPE(*CHAR)  LEN(20)

            CHGVAR     VAR(&RC) VALUE('0')

            CHGVAR     VAR(%BIN(&NBRTORTN)) VALUE(1)
            CHGVAR     VAR(%BIN(&KEYSTORTN)) VALUE(1906)

            CHGVAR     VAR(&USP_NAME) VALUE('LSTJOBNAME')
            CHGVAR     VAR(&USP_LIB)  VALUE('QTEMP')
            CHGVAR     VAR(&USP_QUAL) VALUE(&USP_NAME *CAT +
                         &USP_LIB)
            CHGVAR     VAR(&USP_TYPE) VALUE('MYTYPE')
            CHGVAR     VAR(%BIN(&USP_SIZE)) VALUE(64000)
            CHGVAR     VAR(&USP_FILL) VALUE(' ')
            CHGVAR     VAR(&USP_AUT)  VALUE('*USE')
            CHGVAR     VAR(&USP_TEXT) VALUE('my user space')

            CALL       PGM(QUSCRTUS) PARM(&USP_QUAL &USP_TYPE +
                         &USP_SIZE &USP_FILL &USP_AUT &USP_TEXT)

            CHGVAR     VAR(&API_USQUAL) VALUE(&USP_QUAL)
            CHGVAR     VAR(&API_JBNAM)  VALUE('AMQZXMA0')
            CHGVAR     VAR(&API_USER)   VALUE('*ALL')
            CHGVAR     VAR(&API_JOBNR)  VALUE('*ALL')
            CHGVAR     VAR(&API_STATUS) VALUE('*ACTIVE')
            CHGVAR     VAR(&API_JBQUAL) VALUE(&API_JBNAM *CAT +
                         &API_USER *CAT &API_JOBNR)

            CALL       PGM(QUSLJOB) PARM(&API_USQUAL 'JOBL0200' +
                         &API_JBQUAL &API_STATUS X'00000000' +
                         &TYPE &NBRTORTN &KEYSTORTN)

            CHGVAR     VAR(%BIN(&STARTPOS)) VALUE(1)
            CHGVAR     VAR(%BIN(&DATALEN))  VALUE(140)

            CALL       PGM(QUSRTVUS) PARM(&API_USQUAL &STARTPOS +
                         &DATALEN &HEADER)

            CHGVAR     VAR(&LST_OFFSET) VALUE(%BIN(&HEADER 125 4))
            CHGVAR     VAR(&LST_SIZE)   VALUE(%BIN(&HEADER 129 4))
            CHGVAR     VAR(&LST_NBR)    VALUE(%BIN(&HEADER 133 4))
            CHGVAR     VAR(&LST_LEN)    VALUE(%BIN(&HEADER 137 4))

            CHGVAR     VAR(%BIN(&LST_POSBIN)) VALUE(&LST_OFFSET + 1)
            CHGVAR     VAR(&LST_LENBIN) VALUE(%SST(&HEADER 137 4))

            CHGVAR     VAR(&LST_COUNT) VALUE(0)

LST_LOOP:   IF         COND(&LST_COUNT *EQ &LST_NBR) THEN(GOTO +
                         CMDLBL(LST_END))

            CALL       PGM(QUSRTVUS) PARM(&API_USQUAL &LST_POSBIN +
                         &LST_LENBIN &LST_DATA)

            CHGVAR     VAR(&JOBNAME) VALUE(%SST(&LST_DATA 1 10))
            CHGVAR     VAR(&USER)    VALUE(%SST(&LST_DATA 11 10))
            CHGVAR     VAR(&JOBNBR)  VALUE(%SST(&LST_DATA 21 6))
            CHGVAR     VAR(&STATUS)  VALUE(%SST(&LST_DATA 43 10))
            CHGVAR     VAR(&JOBTYPE) VALUE(%SST(&LST_DATA 53 1))
            CHGVAR     VAR(&SUBTYPE) VALUE(%SST(&LST_DATA 54 1))
            CHGVAR     VAR(&SBSSYS ) VALUE(%SST(&LST_DATA 81 20))

            IF         COND(&JOBNAME *EQ &API_JBNAM) THEN(DO)
               CHGVAR     VAR(&RC) VALUE('0')
            SCNJOBLOG  JOB(&JOBNAME) USER(&USER) JOBNBR(&JOBNBR) +
                         MSGID(AMQ8003) SCHSTR(&QMGR) FOUND(&RC)
               IF (&RC *EQ '1') DO
            SNDPGMMSG  MSG('QMGR:' *CAT &QMGR *BCAT &JOBNAME *BCAT +
                         &USER *BCAT &JOBNBR *BCAT 'JOB' *BCAT +
                         'RUNNING UNDER' *BCAT &SBSSYS)
               MONMSG     MSGID(CPF0000)
               GOTO  LST_END
               ENDDO
            ENDDO

            CHGVAR     VAR(&LST_COUNT) VALUE(&LST_COUNT + 1)
            CHGVAR     VAR(%BIN(&LST_POSBIN)) +
                         VALUE(%BIN(&LST_POSBIN) + &LST_LEN)
            GOTO       CMDLBL(LST_LOOP)

LST_END:    DLTUSRSPC  USRSPC(&USP_LIB/&USP_NAME)

END:        ENDPGM



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.