ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Doubt in QMHLSTM api

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Doubt in QMHLSTM api

    Hi All,

    I am using QMHLSTM api to retrieve messages that are waiting for reply in *SYSOPR message queue. I can populate a PF with the following data

    1) Msg key
    2) Msg data
    3) Msg sev
    4) Msg date and time.

    To get the msg data, I used "Valid field identifiers" setting as 302 as "eval qmhifr03=302"

    PHP Code:
    c                   eval      qmhifr03=302                            
    c                   
    eval      qmhNBRFR05=1                            
    c                   
    eval      size=%size(QMHT010000)                  
    c                   eval      qmhOMQN00=56                            
    c                   
    eval      qmhOSMK00=76                            
    c                   
    eval      qmhOFR00=80                             
     
    * List Nonprogram Messages                                           
    c                   exsr      sr_reset                                
    c                   call      
    'QMHLSTM'                               
    c                   parm                    qualnam                   
    c                   parm      
    'LSTM0100'    format1                   
    c                   parm                    QMHT010000                
    c                   parm                    size                      
    c                   parm      
    'MSLT0100'    format2                   
    c                   parm                    qusec 
    But I dont know how to populate the qualified job name that thrown the message. When I verified the API instructions, I could find the valid field identifier should be set as "601". Could any one please let me know how to use both the identifiers in the same call?

    I can post more details if required. Thanks..

    Regu

  • #2
    Re: Doubt in QMHLSTM api

    Are you just trying to take "some" action if you have a job in *MSGW in QINTER?
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Doubt in QMHLSTM api

      Originally posted by jamief View Post
      Are you just trying to take "some" action if you have a job in *MSGW in QINTER?
      Hello Jamie

      No. I am going to extract all the *SYSOPR messages awaiting reply and send the details to another server. I have already looked into your post regarding "monitoring wrkactjob" and Tomhalden post on "*SYSOPR using MMAIL".

      But, in my case, i need details of message data, job that thrown the message and message sent date and time, which need to be added as extra paramaters. The sample code I got is as below. However, I am confused on how to recieve extra data from the API.

      Kindly let me know on how to proceed with this. Thanks a lot for your kind help..

      PHP Code:
           h text('List Message Queue with QMHLSTM API')
           
      h/title List Message Queue with QMHLSTM API (RPG/400 Style)
           
      h dftname(LSTMSGQR)
           
      h copyright('(C) Copyright APL Services 2010-09-17')

           
      fqsysprt   o    f  130        printer usropn infds(infds_printer)

            
      //Server Side Includes
            
      /include qsysinc/qrpglesrc,qszrtvpr
            
      /include qsysinc/qrpglesrc,qusec
            
      /include qsysinc/qrpglesrc,qusgen
            
      /include qsysinc/qrpglesrc,qusrjobi
            
      /include qsysinc/qrpglesrc,qusrobjd
            
      /include qsysinc/qrpglesrc,qusrusat

            
      //Variables
           
      dbrk              s              1a   inz
           dcmdlen           s             15  5 inz
           dcmdstr           s            256a   inz
           dcount            s              4  0 inz
           ddat_iso          s               d   inz datfmt
      (*iso)
           
      ddat_jul          s               d   inz datfmt(*jul)
           
      ddate             s             10a   inz
           ddatfmt           s                   inz like
      (QUSDF)
           
      ddatsep           s                   inz like(QUSDS)
           
      dformat           s              8a   inz
           dformat1          s              8a   inz
           dformat2          s              8a   inz
           djobident         s             16a   inz
           djobname          s             26a   inz
      ('*')
           
      dlen              s             20i 0 inz
           dlibrary          s             10a   inz
           dmsg              s            130a   inz
           dmsgq             s             10a   inz
      ('QSYSOPR')
           
      dmsgqlib          s             10a   inz('*LIBL')
           
      dmsgsev           s              2  0 inz
           dmsgtype          s             10a   inz
           dobjtyp           s             10a   inz
           doffset           s             10i 0 inz
           dp_msgsev         s              2a   inz                                  Printer Variable
           dpos              s             20i 0 inz
           dqualnam          s             20a   inz
           drcvvar           s          32767a   inz
           drtnlib           s             10a   inz
           dsize             s             10i 0 inz
           dstrpos           s             10i 0 inz
           dtime             s              8a   inz
           dtimsep           s                   inz like
      (QUSTS01)
           
      dtline1           s            130a   inz
           dtline2           s            130a   inz
           dusauth           s             10a   inz
      ('*ALL')
           
      dusexat           s             10a   inz
           dusinit           s              1a   inz
      (x'00')
           
      dusrepl           s             10a   inz('*YES')
           
      dussize           s             10i 0 inz(2048)
           
      dustext           s             50a   inz

            
      //Constants
           
      dhk               c                   x'7D'
           
      dday              c                   6
           dmonth            c                   4
           dyear             c                   2

            
      //Arrays
           
      dfg               s             80a   ctdata dim(2perrcd(1)

            
      //Data Structures
           
      dds_ext           ds                  qualified
           d nbrofrecords                  10i 0 inz
      (1)
           
      d key                           10i 0 inz(3)
           
      d len                           10i 0 inz(1)
           
      d data                           1a   inz('1')

            
      //Printer File Information Data Structure
           
      dinfds_printer    ds                  qualified
           d filnam                  1      8a
           d errmsgid               46     52a
           d splfnam                83     92a
           d library                93    102a
           d qualnam                83    102a
           d splnbr                123    124i 0
           d overflow              188    189b 0                                      Overflow Line
           d curline               367    368b 0                                      Current Line
           d curpage               369    372b 0                                      Current Page

           
      /*API Description--------------------------------------------------------*/
            //Execute Command (QCMDEXC) API

            //  Required Parameter Group:

            // 1 Command string Input Char(*)
            // 2 Length of command string Input Packed (15,5)

            //  Optional Parameter:

            // 3 IGC process control INPUT Char(3)
           /*API Description--------------------------------------------------------*/
            //List Nonprogram Messages (QMHLSTM) API

            //  Required Parameter Group:

            // 1 Qualified user space name Input Char(20)
            // 2 Format name Input Char(8)
            // 3 Message selection information Input Char(*)
            // 4 Size of message selection information Input Binary(4)
            // 5 Format of message selection information Input Char(8)
            // 6 Error code I/O Char(*)
           /*API Description--------------------------------------------------------*/
            //Retrieve Product Information (QSZRTVPR) API

            //  Required Parameter Group:

            // 1 Receiver variable Output Char(*)
            // 2 Length of receiver variable Input Binary(4)
            // 3 Format name Input Char(8)
            // 4 Product information Input Char(*)
            // 5 Error code I/O Char(*)

            //  Optional Parameter:

            // 6 Product information format name Input Char(8)
           /*API Description--------------------------------------------------------*/
            //Create User Space (QUSCRTUS) API

            //  Required Parameter Group:

            // 1 Qualified user space name Input Char(20)
            // 2 Extended attribute Input Char(10)
            // 3 Initial size Input Binary(4)
            // 4 Initial value Input Char(1)
            // 5 Public authority Input Char(10)
            // 6 Text description Input Char(50)

            //  Optional Parameter Group 1:
            // 7 Replace Input Char(10)
            // 8 Error code I/O Char(*)

            //  Optional Parameter Group 2:
            // 9 Domain Input Char(10)

            // Optional Parameter Group 3:
            // 10 Transfer size request Input Binary(4)
            // 11 Optimum space alignment Input Char(1)
           /*API Description--------------------------------------------------------*/
            //Change User Space Attributes (QUSCUSAT) API

            //  Required Parameter Group:

            // 1 Returned library name Output Char(10)
            // 2 Qualified user space name Input Char(20)
            // 3 Attributes to change Input Char(*)
            // 4 Error code I/O Char(*)
           /*API Description--------------------------------------------------------*/
            //Retrieve Job Information (QUSRJOBI) API

            // Required Parameter Group:

            // 1 Receiver variable Output Char(*)
            // 2 Length of receiver variable Input Binary(4)
            // 3 Format name Input Char(8)
            // 4 Qualified job name Input Char(26)

            // 5 Internal job identifier Input Char(16)

            // Optional Parameter Group 1:

            // 6 Error code I/O Char(*)

            // Optional Parameter Group 2:

            // 7 Reset performance statistics Input Char(1)
           /*API Description--------------------------------------------------------*/
            //Retrieve Object Description (QUSROBJD) API

            //  Required Parameter Group:

            // 1 Receiver variable Output Char(*)
            // 2 Length of receiver variable Input Binary(4)
            // 3 Format name Input Char(8)
            // 4 Object and library name Input Char(20)
            // 5 Object type Input Char(10)

            //  Optional Parameter Group 1:
            // 6 Error code I/O Char(*)

            //  Optional Parameter Group 2:
            // 7 Auxiliary storage pool (ASP) control Input Char(*)
           /*API Description--------------------------------------------------------*/
            //Retrieve User Space Attributes (QUSRUSAT) API

            //  Required Parameter Group:
            // 1 Receiver variable Output Char(*)
            // 2 Length of receiver variable Input Binary(4)
            // 3 Format name Input Char(8)
            // 4 Qualified user space name Input Char(20)
            // 5 Error code I/O Char(*)
           /*API Description--------------------------------------------------------*/
            //Retrieve User Space (QUSRTVUS) API

            //  Required Parameter Group:
            // 1 Qualified user space name Input Char(20)
            // 2 Starting position Input Binary(4)
            // 3 Length of data Input Binary(4)
            // 4 Receiver variable Output Char(*)

            //  Optional Parameter Group:
            // 5 Error code I/O Char(*)
           /*-----------------------------------------------------------------------*/

           
      d*** START HEADER FILE SPECIFICATIONS ****************************
           
      d*
           
      d*Header File NameH/QMHLSTM
           d
      *
           
      d*Descriptive Name: List Nonprogram Messages.
           
      d*
           
      d*5763-SS1  (CCopyright IBM Corp1994,1994
           d
      *All rights reserved.
           
      d*US Government Users Restricted Rights -
           
      d*Use, duplication or disclosure restricted
           d
      *by GSA ADP Schedule Contract with IBM Corp.
           
      d*
           
      d*Licensed Materials-Property of IBM
           d
      *
           
      d*
           
      d*DescriptionThe List Nonprogram Messages API lists messages
           d
      *          from one or two nonprogram message queues.
           
      d*
           
      d*Header Files IncludedNone.
           
      d*
           
      d*Macros List: None.
           
      d*
           
      d*Structure List: Qmh_Lstm_Input_t
           d
      *             Qmh_Lstm_Header_t
           d
      *             Qmh_Lstm_LSTM0100_Field_t
           d
      *             Qmh_Lstm_LSTM0100_t
           d
      *             Qmh_Lstm_MSLT0100_t
           d
      *             Qmh_Lstm_MSLT0200_t
           d
      *
           
      d*Function Prototype List: QMHLSTM
           d
      *
           
      d*Change Activity:
           
      d*
           
      d*CFD List:
           
      d*
           
      d*FLAG REASON       LEVEL DATE   PGMR      CHANGE DESCRIPTION
           d
      *---- ------------ ----- ------ --------- ----------------------
           
      d*$A0D2862000     3D10  940424 RGARVEY : New Include
           
      d*$A1D9465800     3D70  960509 LMcCrea Add Date and Time
           d
      *                                      Selection criteria
           d
      *$A2D98871     v5r2m0  010902 LIGGETT:  Add microseconds
           d
      *
           
      d*End CFD List.
           
      d*
           
      d*Additional notes about the Change Activity
           d
      *End Change Activity.
           
      d*** END HEADER FILE SPECIFICATIONS ******************************
           
      d*****************************************************************
           
      d*Prototype for calling Message Handler API QMHLSTM
           d
      *****************************************************************
           
      d QMHLSTM         C                   'QMHLSTM'
           
      d*****************************************************************
           
      d*Type Definition for the input parameter section of the user-
           
      d*space.
           
      d****                                                          ***
           
      d*NOTEThe following type definition only defines the fixed
           d
      *   portion of the format.  The array of identifiers of
           d
      *   fields to return specified, and call message queue
           d
      *   specified are each varying length and immediately follow
           d
      *   what is defined here.
           
      d*****************************************************************
           
      dqmhLI00          DS                  inz
           d
      *                                             Qmh Lstm Input
           d qmhUN01                 1     10
           d
      *                                             Userspace Name
           d qmhULIB01              11     20
           d
      *                                             Userspace Library
           d qmhFN00                21     28
           d
      *                                             Format Name
           d qmhMS01                29     36
           d
      *                                             Message Selection
           d qmhSMS00               37     40b 0
           d
      *                                             Size Message Selection
           d qmhMMR02               41     44b 0
           d
      *                                             Max Messages Requested
           d qmhLD03                45     54
           d
      *                                             List Direction
           d qmhSC                  55     64
           d
      *                                             Selection Criteria
           d qmhSC00                65     68b 0
           d
      *                                             Severity Criteria
           d qmhMML00               69     72b 0
           d
      *                                             Max Message Length
           d qmhMMHL00              73     76b 0
           d
      *                                             Max Message Help Length
           d qmhOMN00               77     80b 0
           d
      *                                             Offset Message Name
           d qmhOMK                 81     84b 0
           d
      *                                             Offset Message Key
           d qmhNBRMQ               85     88b 0
           d
      *                                             Number Message Queue
           d qmhOFR                 89     92b 0
           d
      *                                             Offset Field Return
           
      d qmhNBRFR03             93     96b 0
           d
      *                                             Number Field Return
           
      d qmhCCSID02             97    100b 0
           d
      *                                             Coded Character Set ID
           d qmhDTC                101    113
           d
      *                                                        @A1A
           d
      *QMHERVED04            114    114
           d
      *
           
      d*                                Varying length
           d
      *QMHMQN                115    115
           d
      *
           
      d*                                Varying length
           d
      *QMHSMK03              116    119
           d
      *
           
      d*                                Varying length
           d
      *QMHIFR02              120    123b 0 DIM(00001)
           
      d*
           
      d*                                Varying length
           d
      *****************************************************************
           
      d*Type Definition for the header section.
           
      d****                                                          ***
           
      d*NOTEThe following type definition only defines the fixed
           d
      *   portion of the format.  The repeating fields returned
           d
      *   for each identifier field immediately follow what is
           d
      *   defined here.
           
      d*****************************************************************
           
      dqmhLH00          DS                  inz
           d
      *                                             Qmh Lstm Header
           d qmhUN02                 1     10
           d
      *                                             Userspace Name
           d qmhULIB02              11     20
           d
      *                                             Userspace Library
           d qmhOMQN                21     24b 0
           d
      *                                             Offset Message Queue Name
           d qmhOSMK                25     28b 0
           d
      *                                             Offset Start Message Key
           d qmhOEMK                29     32b 0
           d
      *                                             Offset End Message Key
           d qmhNMQU                33     36b 0
           d
      *                                             Number Message Queue Used
           d qmhCCSID03             37     40b 0
           d
      *                                             Coded Character Set ID
           d qmhDTFM                41     53
           d
      *                                                        @A1A
           d qmhDTLM                54     66
           d
      *                                                        @A1A
           d
      *QMHERVED05             67     67
           d
      *
           
      d*                                    Varying length
           d
      *QMHMQN00               68     87    DIM(00001)
           
      d*
           
      d*                                    Varying length
           d
      *QMHSMK04               88     91    DIM(00001)
           
      d*
           
      d*                                    Varying length
           d
      *QMHEMK00               92     95    DIM(00001)
           
      d*
           
      d*                                    Varying length
           d
      *****************************************************************
           
      d*Type Definition for the LJOB0100 repeating fields format.
           
      d****                                                          ***
           
      d*NOTEThe following type definition only defines the fixed
           d
      *   portion of the format.  The repeating fields returned
           d
      *   for each identifier field immediately follow what is
           d
      *   defined here.
           
      d*****************************************************************
           
      dqmh0100F00       DS                  inz
           d
      *                                             Qmh Lstm LSTM0100 Field
           d qmhONF00                1      4b 0
           d
      *                                             Offset Next Field
           d qmhLFR00                5      8b 0
           d
      *                                             Length Field Return
           
      d qmhIF00                 9     12b 0
           d
      *                                             Id Field
           d qmhTD00                13     13
           d
      *                                             Type Data
           d qmhSD02                14     14
           d
      *                                             Status Data
           d qmhERVED07             15     28
           d
      *                                             Reserved
           d qmhLD04                29     32b 0
           d
      *                                             Length Data
           d
      *QMHDATA00              33     33
           d
      *
           
      d*                                  Varying length
           d
      *QMHRSV200              34     34
           d
      *
           
      d*                                  Varying length
           d
      *****************************************************************
           
      d*Type Definition for the LSTM0100 format.
           
      d****                                                          ***
           
      d*NOTEThe following type definition only defines the fixed
           d
      *   portion of the format.  The repeating fields returned
           d
      *   for each identifier field immediately follow what is
           d
      *   defined here.
           
      d*****************************************************************
           
      dqmhM0100         DS                  inz
           d
      *                                             Qmh Lstm LSTM0100
           d qmhONE00                1      4b 0
           d
      *                                             Offset Next Entry
           d qmhOFRTN02              5      8b 0
           d
      *                                             Offset Field Returned
           d qmhNBRFR04              9     12b 0
           d
      *                                             Number Field Returned
           d
      *******************************************************************
           
      d qmhMS02                13     16b 0
           d
      *                                             Message Severity
           d qmhMI00                17     23
           d
      *                                             Message Id
           d
      *******************************************************************
           
      dValue Message Type
           d
      01 Completion
           d
      02 Diagnostic
           d
      04 Informational
           d
      05 Inquiry
           d
      06 Sender's copy
           d* 08 Request
           d* 10 Request with prompting
           d* 14 Notify, exception already handled when API is called
           d* 15 Escape, exception already handled when API is called
           d* 16 Notify, exception not handled when API is called
           d* 17 Escape, exception not handled when API is called
           d* 21 Reply, not checked for validity
           d* 22 Reply, checked for validity
           d* 23 Reply, message default used
           d* 24 Reply, system default used
           d* 25 Reply, from system reply list
           d* 26  Reply, from exit program
           d qmhMT00                24     25
           d*                                             Message Type
           d qmhMK00                26     29
           d*                                             Message Key
           d qmhMFILN00             30     39
           d*                                             Message File Name
           d qmhMFSL00              40     49
           d*                                             Message File Send Library
           d qmhMQN01               50     59
           d*                                             Message Queue Name
           d qmhMQLIB               60     69
           d*                                             Message Queue Library
           d qmhSD01                70     76
           d* Date sent. The date on which the message was sent, in CYYMMDD (century,
           d*            year, month, and day) format.
           d qmhST00                77     82
           d*                                             Send Time
           d qmhSTM00               83     88
           d*                                             Microseconds
           d QMHERVED06             89     89
           d*
           d*feld7                  90     96
           d* Offset to the next field information returned
           d QMH0100F01      ds
           d* Length of field information returned
           d  QMHONF02                      9b 0 OVERLAY(QMH0100F01:00001)
           d* Number of fields returned
           d  QMHLFR02                      9b 0 OVERLAY(QMH0100F01:00005)
           d* Identifier field
           d  QMHIF02                       9b 0 OVERLAY(QMH0100F01:00009)
           d* Type of data
           d  QMHTD04                       1    OVERLAY(QMH0100F01:00013)
           d* Status of data
           d  QMHSD07                       1    OVERLAY(QMH0100F01:00014)
           d* Reserved
           d  QMHERVED23                   14    OVERLAY(QMH0100F01:00015)
           d* Length of data
           d  QMHLD08                       9b 0 OVERLAY(QMH0100F01:00029)
           d* Data
           d  QMHDATA02                   512    OVERLAY(QMH0100F01:00033)
           d* Reserved
           d  QMHRSV206                     1    OVERLAY(QMH0100F01:*next)
           d*
           d*                                                 Varying
           d*                                    length
           d*****************************************************************
           d*Type Definition of the MSLT0100 format.
           d****                                                          ***
           d*NOTE: The following type definition only defines the fixed
           d*   portion of the format.  The array of identifiers of
           d*   fields to return, and call message queue name are each
           d*   varying length and immediately follow what is defined.
           d*****************************************************************
           dqmht010000       ds                  inz
           d*                                             Qmh Lstm MSLT0100
           d qmhMMR03                1      4b 0
           d*                                             Max Messages Requested
           d qmhLD05                 5     14
           d*                                             List Direction
           d qmhSC01                15     24
           d*                                             Selection Criteria
           d qmhSC02                25     28b 0
           d*                                             Severity Criteria
           d qmhMML01               29     32b 0
           d*                                             Max Message Length
           d qmhMMHL01              33     36b 0
           d*                                             Max Message Help Length
           d qmhOMQN00              37     40b 0
           d*                                             Offset Message Queue Name
           d qmhOSMK00              41     44b 0
           d*                                             Offset Start Message Key
           d qmhNBRMQ00             45     48b 0
           d*                                             Number Message Queues
           d qmhOFR00               49     52b 0
           d*                                             Offset Field Return
           d qmhNBRFR05             53     56b 0
           d*                                             Number Field Return
           d QMHMQN02               57     76
           d*                                             Message Queue Name
           d*****************************************************************
           d QMHSMK05               77     80
           d*                                             Starting Message Key
           d* *LOVAL - The first message is the oldest message in the
           d*          message queue.
           d* *HIVAL - The first message is the newest message in the
           d*          message queue.
           d*
           d* Identifiers of fields to return specified
           d QMHIFR03               81     84b 0
           d*qmhifr03                      10i 0 dim(2)
           d*qmhifr031                     10i 0
           d*qmhifr032                     10i 0
           d*****************************************************************
           d*Type Definition of the MSLT0200 format.
           d****                                                          ***
           d*NOTE: The following type definition only defines the fixed
           d*   portion of the format.  The array of identifiers of
           d*   fields to return, and call message queue name are each
           d*   varying length and immediately follow what is defined.
           d*****************************************************************
           dqmhT020000       DS                  inz
           d*                                             Qmh Lstm MSLT0200
           d qmhMMR04                1      4b 0
           d*                                             Max Messages Requested
           d qmhLD06                 5     14
           d*                                             List Direction
           d qmhSC03                15     24
           d*                                             Selection Criteria
           d qmhSC04                25     28b 0
           d*                                             Severity Criteria
           d qmhMML02               29     32b 0
           d*                                             Max Message Length
           d qmhMMHL02              33     36b 0
           d*                                             Max Message Help Length
           d qmhOMQN01              37     40b 0
           d*                                             Offset Message Queue Name
           d qmhOSMK01              41     44b 0
           d*                                             Offset Start Message Key
           d qmhNBRMQ01             45     48b 0
           d*                                             Number Message Queues
           d qmhOFR01               49     52b 0
           d*                                             Offset Field Return
           d qmhNBRFR06             53     56b 0
           d*                                             Number Field Return
           d qmhCCSID04             57     60b 0
           d*                                             Coded Character Set ID
           d qmhDTC00               61     73
           d*                                                        @A1A
           d qmhAF                  74     76
           d*                                                        @A1A
           d qmhERVED08             77     80b 0
           d*                                             Reserved
           d*QMHMQN03               81    100    DIM(00001)
           d*
           d*                                    varying length
           d*QMHSMK06              101    104    DIM(00001)
           d*
           d*                                    varying length
           d*QMHIFR04              105    108b 0 DIM(00001)
           d*
           d*                                    varying length

            //Program Information Data Structure
           dpsds            sds
           d pgmnam                334    343a

           c     *entry        plist
           c                   parm                    e_msgq           10
           c                   parm                    e_msgqlib        10
           c                   parm                    e_msgsev          2
           c                   parm                    e_written         5 0

             // Message queue and message queue library
           c                   if        %addr(e_msgq)<>*null and                     B1
           c                             %addr(e_msgqlib)<>*null
           c                   eval      QMHMQN02=e_msgq+e_msgqlib
           c                   else                                                   X1
           c                   eval      qmhmqn02=msgq+msgqlib
           c                   endif                                                  E1

             // Severity Criteria
           c                   if        %addr(e_msgsev)<>*null and                   B1
           c                             e_msgsev>='
      00' and e_msgsev<='99'
           c                   move      e_msgsev      qmhsc02
           c                   else                                                   X1
           c                   clear                   qmhsc02
           c                   endif                                                  E1
           c                   move      qmhsc02       p_msgsev

           c                   exsr      sr_reset
           c                   clear                   qusd0100
           c                   eval      library='
      QTEMP'
           c                   eval      qualnam=pgmnam+library
           c                   eval      size=%size(qusd0100)
           c                   eval      objtyp='
      *USRSPC'

           c                   call      '
      QUSROBJD'                                   call to API
           c                   parm                    qusd0100
           c                   parm                    size
           c                   parm      '
      OBJD0100'    format
           c                   parm                    qualnam
           c                   parm                    objtyp
           c                   parm                    qusec

           c                   if        qusbavl<>0                                   B1
           c                   exsr      sr_reset
           c                   eval      ustext='
      Userspace for program '+
           c                             pgmnam
           c                   call      '
      QUSCRTUS'                                   call to API
           c                   parm                    qualnam
           c                   parm                    usexat
           c                   parm                    ussize
           c                   parm                    usinit
           c                   parm                    usauth
           c                   parm                    ustext
           c                   parm                    usrepl
           c                   parm                    qusec

           c                   if        qusbavl<>0                                   B2
           c                   goto      end
           c                   endif                                                  E2

           c                   call      '
      QUSCUSAT'                                   call to API
           c                   parm                    rtnlib
           c                   parm                    qualnam
           c                   parm                    ds_ext
           c                   parm                    qusec

           c                   if        qusbavl<>0                                   B2
           c                   goto      end
           c                   endif                                                  E2

           c                   clear                   qusa0100
           c                   eval      size=%size(qusa0100)
           c                   exsr      sr_reset

           c                   call      '
      QUSRUSAT'                                   call to API
           c                   parm                    qusa0100
           c                   parm                    size
           c                   parm      '
      SPCA0100'    format
           c                   parm                    qualnam
           c                   parm                    qusec

             // Automatic Extendability
           c                   if        qusbavl<>0 or qusae<>'
      1'                     B2
           c                   goto      end
           c                   endif                                                  E2

           c                   endif                                                  E1

            * Max Messages Requested
           c                   eval      QMHMMR03=-1
            * List Direction
            * *NEXT Returns messages that are newer than the
            *       messages specified by the starting message key field.
            * *PRV  Returns messages that are older than the message
            *       specified by the starting message key field.
           c                   eval      QMHLD05='
      *PRV'
            * Selection Criteria
            * *ALL  All messages are to be listed.
            * *MNNR Only messages not requiring a reply are listed.
            *       This includes informational, completion, diagnostic,
            *       request, notify, escape, reply, answered inquiry, and
            *       answered sender'
      s copy messages.
            * *
      MNR  Only messages needing a reply are listedThis
            
      *       includes only unanswered inquiry messages.
            * *
      PAR  Only messages that can have problem analysis
            
      *       run against them are listed.
            * *
      SCNR Only sender's copy messages requiring a reply are
            *       listed. This includes only unanswered sender'
      s
            
      *        copy messages.
           
      c                   eval      QMHSC01='*ALL'
            
      Max Message Length
           c                   
      eval      QMHMML01=256
            
      Max Message Help Length
           c                   
      eval      QMHMMHL01=0
            
      Number Message Queues
           c                   
      eval      qmhNBRMQ00=1
            
      *-----------------------------------------------------
            * 
      Starting message key
            
      * *LOVAL The first message is the oldest message in
            
      *          the message queue
            
      * *HIVAL The first message is the newest message in
            
      *          the message queue
           c                   
      eval      QMHSMK05=*hival
            
      *-----------------------------------------------------
            * 
      0101 CHAR(9)   Alert option
            
      0201 CHAR(*)   Replacement data or impromptu message text
            
      0301 CHAR(*)   Message
            
      0302 CHAR(*)   Message with replacement data
            
      0401 CHAR(*)   Message help
            
      0402 CHAR(*)   Message help with replacement data
            
      0403 CHAR(*)   Message help with formatting characters
            
      0404 CHAR(*)   Message help with replacement data and
            *                
      formatting characters
            
      0501 CHAR(*)   Default reply
            
      0601 CHAR(26)  Qualified sender job name
            
      0602 CHAR(1)   Sender type
            
      0603 CHAR(12)  Sending program name
            
      0604 CHAR(10)  Sending module name
            
      0605 CHAR(256Sending procedure name
            
      0606 BINARY(4followed by ARRAY(*) of CHAR(10Number of
            
      *                sending statement numbers or instruction
            
      *                numbers available followed by an array of
            
      *                the sending statement numbers or instruction numbers
            
      0607 CHAR(10)  Sending user profile
            
      0702 CHAR(1)   Receiving type
            
      0703 CHAR(10)  Receiving program name
            
      0704 CHAR(10)  Receiving module name
            
      0705 CHAR(256Receiving procedure name
            
      0706 BINARY(4followed by ARRAY(*) of CHAR(10Number of receiving
            
      *                statement numbers or instruction numbers available
            
      *                followed by an array of the receiving statement
            
      *                numbers or instruction numbers
            
      0801 CHAR(10)  Message file library used
            
      0901 CHAR(30)  Problem identification
            
      1001 CHAR(1)   Reply status
            
      1002 CHAR(1)   Critical break message status
            
      1101 CHAR(1)   Request status
            
      1201 BINARY(4Request level
            
      1301 BINARY(4Coded character set identifier (CCSID) for text
            
      1302 BINARY(4Coded character set identifier (CCSIDconversion
            
      *                status indicator for text
            
      1303 BINARY(4Coded character set identifier (CCSID) for data
            
      1304 BINARY(4Coded character set identifier (CCSIDconversion
            
      *                status indicator for data
           c                   
      eval      qmhifr03=302
            
      Number Field Return
           
      c                   eval      qmhNBRFR05=1
           c                   
      eval      size=%size(QMHT010000)
            
      // Offset Message Queue Name
           
      c                   eval      qmhOMQN00=56
            
      // Offset Start Message Key
           
      c                   eval      qmhOSMK00=76
            
      // Offset Field Return
           
      c                   eval      qmhOFR00=80

            
      * List Nonprogram Messages
           c                   exsr      sr_reset
           c                   call      
      'QMHLSTM'                                    call to API
           c                   parm                    qualnam
           c                   parm      
      'LSTM0100'    format1
           c                   parm                    QMHT010000
           c                   parm                    size
           c                   parm      
      'MSLT0100'    format2
           c                   parm                    qusec

           c                   
      if        qusbavl<>0
           c                   
      goto      end
           c                   
      endif

           
      c                   clear                   qush0100
           c                   
      eval      strpos=1
           c                   
      eval      size=%size(qush0100)
           
      c                   exsr      sr_reset
           c                   call      
      'QUSRTVUS'                                   call to API
           c                   parm                    qualnam
           c                   parm                    strpos
           c                   parm                    size
           c                   parm                    qush0100
           c                   parm                    qusec

           c                   
      if        qusbavl<>0
           c                   
      goto      end
           c                   
      endif

           
      c                   clear                   QMHM0100
           c                   
      eval      strpos=qusold+1

           c                   
      do        qusnbrle                                     B1
           c                   
      eval      size=%size(QMHM0100)
           
      c                   exsr      sr_reset
           c                   call      
      'QUSRTVUS'                                   call to API
           c                   parm                    qualnam
           c                   parm                    strpos
           c                   parm                    size
           c                   parm                    QMHM0100
           c                   parm                    qusec

           c                   
      if        qusbavl<>0                                   B2
           c                   
      goto      end
           c                   
      endif                                                  E2

           c                   exsr      sr_get_msg

           c                   
      if        not %open(qsysprt)                           B2
           c                   
      eval      cmdstr=fg(1)
           
      c                   exsr      sr_cmdexc
           c                   open
      (e)   qsysprt
           c                   
      if        not %error                                   B2
           c                   except    header
           c                   
      endif                                                  E2
           c                   
      endif                                                  E2

           c                   
      if        %open(qsysprt)                               B2
           c                   
      eval      msgsev=qmhMS02
           c                   exsr      sr_edit_time
           c                   exsr      sr_edit_date
           c                   exsr      sr_edit_msgtyp
           c                   
      if        infds_printer.curline+2>=                    B3
           c                             infds_printer
      .overflow
           c                   except    header
           c                   
      endif                                                  E3
           c                   
      eval      count+=1
           c                   except    detail
           c                   
      if        %addr(e_written)<>*null                      B3
           c                   
      eval      e_written+=1
           c                   
      endif                                                  E3
           c                   
      endif                                                  E2

           c                   
      eval      strpos=qmhONE00+1

           c                   enddo                                                  E1

           c     end           tag
           c                   
      if        %open(qsysprt)                               B1
           c                   
      if        count>0                                      B2
           c                   
      eval      tline1=%trim(%char(count))+
           
      c                             ' records in query report'
           
      c                   eval      tline2=*all'*'
           
      c                   eval      len=%len(tline2)
           
      c                   eval      pos=%div(len:2)
           
      c                   if        %rem(len:2)<>0                               B3
           c                   
      eval      pos-=1
           c                   
      endif                                                  E3
           c                   
      eval      %subst(tline2:pos:21)=
           
      c                             ' End of Query Report '
           
      c                   if        infds_printer.curline+3>=                    B3
           c                             infds_printer
      .overflow
           c                   except    header
           c                   
      endif                                                  E3
           c                   except    total
           c                   
      endif                                                  E2
           c                   
      eval      cmdstr=fg(2)
           
      c                   exsr      sr_cmdexc
           c                   
      endif                                                  E1
           c                   seton                                        lr
           c                   
      return

           
      csr   sr_edit_msgtypbegsr
            
      //  Message Types

            //  Completion (*COMP).  Reports the successful completion of a task.

            //  Diagnostic (*DIAG).   Describes errors in processes or input data.
            //  When an error occurs, a program usually sends an escape message,
            //  which causes the task to end abnormally. One or more diagnostic
            //  messages can be sent before the escape message to describe the error.

            //  Escape (*ESCAPE).   Indicates a condition causing a program to end
            //  abnormally, without completing its work.

            //  Exception (*EXCP).   Indicates a condition causing a program to end
            //  abnormally, without completing its work. An exception message can
            //  be either an escape or a notify message. The exception message
            //  type and the special value *EXCP are used only with the Receive
            //  Program Message (QMHRCVPM) API.

            //  Informational (*INFO).   Conveys information without asking for a reply.

            //  Inquiry (*INQ).   Conveys information and asks for a reply.

            //  Notify (*NOTIFY).   Describes a condition in the sending program
            //  requiring corrective action or a reply.

            //  Reply (*RPY).   Responds to an inquiry or notify message.

            //  Request (*RQS).   Requests a function from the receiving program.

            //  Sender's copy (*COPY).   Is a copy of an inquiry or notify message.
            //  This copy is kept by the sender of the inquiry or notify message.

            //  Scope (*SCOPE).   Specifies a program to run when the program this
            //  message is sent to completes. If the message is sent to *EXT the
            //  program is to run when the job completes.

            //  Status (*STATUS).   Describes the status of work being done by a program

           
      c                   select                                                 B1
           c                   when      QMHMT00
      ='01'                                 Completion
           c                   
      eval      msgtype='COMP'
           
      c                   when      QMHMT00='02'                                 Diagnostic
           c                   
      eval      msgtype='DIAG'
           
      c                   when      QMHMT00='04'                                 Informational
           c                   
      eval      msgtype='INFO'
           
      c                   when      QMHMT00='05'                                 Inquiry
           c                   
      eval      msgtype='INQ'
           
      c                   when      QMHMT00='06'                                 Sender's copy
           c                   eval      msgtype='
      COPY'
           c                   when      QMHMT00='
      08'                                 Request
           c                   eval      msgtype='
      RQS'
           c                   when      QMHMT00='
      10'                                 Request
           c                   eval      msgtype='
      RQS'
           c                   when      qmhmt00='
      14'                                 Notify
           c                   eval      msgtype='
      NOTIFY'
           c                   when      QMHMT00='
      15'                                 Escape
           c                   eval      msgtype='
      ESCAPE'
           c                   when      qmhmt00='
      16'                                 Notify
           c                   eval      msgtype='
      NOTIFY'
           c                   when      QMHMT00='
      17'                                 Escape
           c                   eval      msgtype='
      ESCAPE'
           c                   when      QMHMT00='
      21'                                 Reply
           c                   eval      msgtype='
      RPY'
           c                   when      QMHMT00='
      22'                                 Reply
           c                   eval      msgtype='
      RPY'
           c                   when      QMHMT00='
      23'                                 Reply
           c                   eval      msgtype='
      RPY'
           c                   when      QMHMT00='
      24'                                 Reply
           c                   eval      msgtype='
      RPY'
           c                   when      QMHMT00='
      25'                                 Reply
           c                   eval      msgtype='
      RPY'
           c                   when      QMHMT00='
      26'                                 Reply
           c                   eval      msgtype='
      RPY'
           c                   other
           c                   eval      msgtype=*all'
      *'
           c                   endsl                                                  E1
           csr                 endsr

           csr   sr_edit_time  begsr
           c                   if        timsep<>' '                                  B1
           c                   eval      time=%subst(qmhst00:1:2)+timsep+
           c                             %subst(qmhst00:3:2)+timsep+
           c                             %subst(qmhst00:5:2)
           c                   else                                                   X1
           c                   eval      time=qmhst00
           c                   endif                                                  E1
           csr                 endsr

           csr   sr_edit_date  begsr
           c                   clear                   date
           c                   if        datfmt<>' '                                  B1
           c                   select                                                 B2
           c                   when      datfmt='
      *YMD'
           c                   if        datsep=' '                                   B3
           c                   eval      date=%subst(qmhsd01:year:2)+
           c                             %subst(qmhsd01:month:2)+
           c                             %subst(qmhsd01:day:2)
           c                   else                                                   X3
           c                   eval      date=%subst(qmhsd01:year:2)+datsep+
           c                             %subst(qmhsd01:month:2)+datsep+
           c                             %subst(qmhsd01:day:2)
           c                   endif                                                  E3
           c                   when      datfmt='
      *MDY'
           c                   if        datsep=' '                                   B3
           c                   eval      date=%subst(qmhsd01:month:2)+
           c                             %subst(qmhsd01:day:2)+
           c                             %subst(qmhsd01:year:2)
           c                   else                                                   X3
           c                   eval      date=%subst(qmhsd01:month:2)+datsep+
           c                             %subst(qmhsd01:day:2)+datsep+
           c                             %subst(qmhsd01:year:2)
           c                   endif                                                  E3
           c                   when      datfmt='
      *DMY'
           c                   if        datsep=' '                                   B3
           c                   eval      date=%subst(qmhsd01:day:2)+
           c                             %subst(qmhsd01:month:2)+
           c                             %subst(qmhsd01:year:2)
           c                   else                                                   X3
           c                   eval      date=%subst(qmhsd01:day:2)+datsep+
           c                             %subst(qmhsd01:month:2)+datsep+
           c                             %subst(qmhsd01:year:2)
           c                   endif                                                  E3
           c                   when      datfmt='
      *JUL'
           c                   if        %subst(qmhsd01:1:1)='
      0'                      B3
           c                   eval      date='
      19'
           c                   else                                                   X3
           c                   eval      date='
      20'
           c                   endif                                                  E1
           c                   eval      %subst(date:3)=%subst(qmhsd01:year:2)+'
      -'+
           c                             %subst(qmhsd01:month:2)+'
      -'+
           c                             %subst(qmhsd01:day:2)
           c                   monitor                                                B3
           c                   eval      dat_iso=%date(date:*iso)
           c                   on-error  *all
           c                   eval      date=qmhsd01
           c                   leavesr
           c                   endmon                                                 E3
           c                   eval      dat_jul=dat_iso
           c                   eval      date=%char(dat_jul)
           c                   endsl                                                  E2
           c                   endif                                                  E1
           c                   if        date=' '                                     B1
           c                   eval      date=qmhsd01
           c                   endif                                                  E1
           csr                 endsr

           csr   sr_cmdexc     begsr
           c                   eval      cmdlen=%len(%trim(cmdstr))
           c                   call      '
      QCMDEXC'                            99      call to API
           c                   parm                    cmdstr
           c                   parm                    cmdlen
           csr                 endsr

           csr   sr_reset      begsr
           c                   clear                   qusec
           c                   eval      qusbprv=%size(qusec)
           csr                 endsr

           csr   sr_get_msg    begsr
           c                   eval      strpos=qmhOFRTN02+1
           c                   eval      size=%size(QMH0100F01)
           c                   exsr      sr_reset
           c                   call      '
      QUSRTVUS'                                   call to API
           c                   parm                    qualnam
           c                   parm                    strpos
           c                   parm                    size
           c                   parm                    QMH0100F01
           c                   parm                    qusec

           c                   if        qusbavl=0                                    B1
           c                   eval      msg=%subst(qmhdata02:1:qmhld08)
           c                   else                                                   X1
           c                   eval      msg=*all'
      *'
           c                   endif                                                  E1

           csr                 endsr

           csr   *inzsr        begsr
           c                   clear                   qusi0400
           c                   eval      size=%size(qusi0400)
           c                   exsr      sr_reset
           c                   call      '
      QUSRJOBI'                                   call to API
           c                   parm                    qusi0400
           c                   parm                    size
           c                   parm      '
      JOBI0400'    format
           c                   parm                    jobname
           c                   parm                    jobident
           c                   parm                    qusec

           c                   if        qusbavl=0                                    B1
           c                   eval      datfmt=QUSDF
           c                   eval      datsep=QUSDS
           c                   eval      timsep=QUSTS01
           c                   endif                                                  E1

           c                   clear                   QSZR0500
           c                   clear                   qszai500                       Add Info PRDR0500
           c                   clear                   qszpir
           c                   eval      qszpi00='
      *OPSYS'                             Product Id
           c                   eval      qszrl02='
      *CUR'                               Release level
           c                   eval      qszpo00=*zeros                               Product option
           c                   eval      qszli01='
      *CODE'                              Load Id
           c                   eval      size=%size(rcvvar)
           c                   exsr      sr_reset
           c                   call      '
      QSZRTVPR'                                   call to API
           c                   parm                    rcvvar
           c                   parm                    size
           c                   parm      '
      PRDR0500'    format
           c                   parm                    qszpir
           c                   parm                    qusec

           c                   if        qusbavl=0                                    B1
           c                   eval      qszr0500=rcvvar
           c                   eval      qszai500=%subst(rcvvar:qszoai03+1)
           c                   endif                                                  E1

           csr                 endsr
           /*-----------------------------------------------------------------------*/
           oqsysprt   e            header            1
           o                       QSZPI08
           o                       QSZRL11             +1
           o                       qszrd01             +1
           o                                          +18 '
      Messages in Message Queue +
           
      o                                               '
           o                       qmhmqn02            +1
           o                                          120 '
      Seite'
           o                       page               129

           oqsysprt   e            header      1
           o                                              '
      Message severity specified+
           
      o                                              . . . '
           o                       p_msgsev            +1

           oqsysprt   e            detail      1
           o                       QMHMI00
           o                       msgsev              +1
           o                       msgtype             +1
           o                       date                +1
           o                       time                +1
           o                       QMHMFILN00          +1
           o                       QMHMFSL00           +1

           oqsysprt   e            detail      1
           o                       msg

           oqsysprt   e            total       2
           o                       tline1

           oqsysprt   e            total       1
           o                       tline2
      ** FG
      OVRPRTF FILE(QSYSPRT) SPLFNAME(QPDSPMSG) OVRSCOPE(*JOB) USRDTA(' ')
      DLTOVR  FILE(QSYSPRT) LVL(*JOB) 

      Comment


      • #4
        Re: Doubt in QMHLSTM api

        Hi , Could anyone please guide me on how to use this API?

        Comment


        • #5
          Re: Doubt in QMHLSTM api

          I can't read fixed format rpg. Hurts my eyes and whats left of my brain.

          But just what are you asking? for us to write it? Are you getting any data back? did you look up this api with in ibm?

          Personally I would scrap that API. I would dump qsysor to a spool file, parse it and then if you need use the job api to get more detail.

          here is the spooled file;

          Code:
           5761SS1 V6R1M0 080215                                Messages in queue - QSYSOPR                       
          MSGID    SEV MSG TYPE                                                                                   
          CPIEF01  00  INFO         Service Agent is analyzing your system product activity log entries.          
                                QS9PALMON  QSRVAGT    405511 QS9UTIL      0000 01/21/13 04:12:48.233175 QSRVAGT
          Does this not give you most of what you want?
          Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

          Comment


          • #6
            Re: Doubt in QMHLSTM api

            as my requirment is to extract only the messages that need reply, i preferred to use API.. DSPMSG output pulls all the messages whether it is replied or not.

            my question is how to use this API to extract job name of the message?? i hope i get a good guidance here.. thanks a lot for ur interest on this

            Comment


            • #7
              Re: Doubt in QMHLSTM api

              use the 0601 field Identifier for the qualified job name...read the documentation. http://publib.boulder.ibm.com/infoce...is/QMHLSTM.htm
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #8
                Re: Doubt in QMHLSTM api

                There is an example here http://www.think400.dk/adhoc_6.htm that uses more than one field identifier, 302, 601 and 1001.

                Comment


                • #9
                  Re: Doubt in QMHLSTM api

                  Originally posted by Barbara Morris View Post
                  There is an example here http://www.think400.dk/adhoc_6.htm that uses more than one field identifier, 302, 601 and 1001.
                  Thanks Barbara.. this is exactly what i need!!!!

                  Comment

                  Working...
                  X