星期三, 11月 08, 2023

2007-12-31 如何擷取訊息佇列(Message Queue)的屬性?(Command: RTVMQGQA with API QMHRMQAT)


如何擷取訊息佇列(Message Queue)的屬性?(Command: RTVMQGQA with API QMHRMQAT)
Retrieve Nonprogram Message Queue Attributes (QMHRMQAT) API
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/QMHRMQAT.htm


File  : QCLSRC
Member: RTVMSGQA
Type  : CLP
Usage : CRTCLPGM PGM(your-lib/RTVMSGQA) SRCFILE(your-lib/QCLSRC) SRCMBR(RTVMSGQA)

/*  ===============================================================  */
/*  = Retrieve the message queue attributes                       =  */
/*  = Command RtvMsgQA   CPP                                      =  */
/*  =   RtvMsgQA   CLP                                            =  */
/*  ===============================================================  */
/*  = Date  : 2007/12/31                                          =  */
/*  = Author: Vengoal Chang                                       =  */
/*  ===============================================================  */
/*  = Keyword     Len      Description                            =  */
/*  = -------     ---      -----------                            =  */
/*  =                                                             =  */
/*  = RTNLIB       10      Library where the MSGQ was found       =  */
/*  = NBRMSGS      10 0    Number of messages                     =  */
/*  = SIZE         10 0    Size of the message queue              =  */
/*  = INCSIZE      10 0    Increment size                         =  */
/*  = NBRINCS      10 0    Number of increments that have occurred=  */
/*  = MAXINCS      10 0    Maximum increments (15622 = *NOMAX)    =  */
/*  = SEV           2 0    Severity code filter                   =  */
/*  = DLVRY         7      Delivery type (e.g. *BREAK)            =  */
/*  = BRKPGM       10      Break program                          =  */
/*  = BRKPGMLIB    10      Break program library                  =  */
/*  = ALWRPY       10      Allow other jobs to reply              =  */
/*  = FORCE         4      Force to auxiliary storage             =  */
/*  = ALWALR        1      Allow alerts (Y/N)                     =  */
/*  = FULLACN      10      Message queue full action              =  */
/*  = TEXT         50      Text description                       =  */
/*  ===============================================================  */

 RTVMSGQA:   PGM        PARM(&MSGQQUAL &RTNLIB    &NBRMSGS    +
                             &SIZE     &INCSIZE   &NBRINCS    +
                             &MAXINCS  &SEV       &DLVRY      +
                   &BRKPGM   &BRKPGMLIB &ALWRPY   &FORCE      +
                             &ALWALR   &FULLACN   &TEXT)

             DCL        VAR(&MSGQQUAL)  TYPE(*CHAR) LEN(20) /* +
                          qualified message queue name */
             DCL        VAR(&RTNLIB )   TYPE(*CHAR) LEN(10)
             DCL        VAR(&NBRMSGS )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&SIZE    )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&INCSIZE )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&NBRINCS )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&MAXINCS )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&SEV     )  TYPE(*DEC ) LEN(2 0)
             DCL        VAR(&DLVRY   )  TYPE(*CHAR) LEN(7)
             DCL        VAR(&BRKPGM )   TYPE(*CHAR) LEN(10)
             DCL        VAR(&BRKPGMLIB) TYPE(*CHAR) LEN(10)
             DCL        VAR(&ALWRPY)   TYPE(*CHAR) LEN(10)
             DCL        VAR(&FORCE  )   TYPE(*CHAR) LEN( 4)
             DCL        VAR(&ALWALR )   TYPE(*CHAR) LEN( 1)
             DCL        VAR(&FULLACN )  TYPE(*CHAR) LEN(10)
             DCL        VAR(&TEXT    )  TYPE(*CHAR) LEN(50)

             DCL        VAR(&MSGQ)      TYPE(*CHAR) LEN(10)
             DCL        VAR(&MSGQLIB)   TYPE(*CHAR) LEN(10)
             DCL        VAR(&API_ERROR) TYPE(*CHAR) LEN(4)
             DCL        VAR(&RECEIVER)  TYPE(*CHAR) LEN(160)
             DCL        VAR(&RCV_LEN)   TYPE(*CHAR) LEN(4)

             MONMSG     MSGID(MCH3601)
             MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))

             CHGVAR     VAR(&MSGQ)    VALUE(%SST(&MSGQQUAL  1 10))
             CHGVAR     VAR(&MSGQLIB) VALUE(%SST(&MSGQQUAL 11 10))
             RTVOBJD    OBJ(&MSGQLIB/&MSGQ) OBJTYPE(*MSGQ) +
                          RTNLIB(&RTNLIB)
             CHGVAR     VAR(&MSGQQUAL) VALUE(&MSGQ *CAT &RTNLIB)

             CHGVAR     VAR(%BIN(&RCV_LEN)) VALUE(160)
             CHGVAR     VAR(%BIN(&API_ERROR 1 4)) VALUE(0)

             CALL       PGM(QMHRMQAT) PARM(&RECEIVER &RCV_LEN +
                          'RMQA0100' &MSGQQUAL &API_ERROR)

             CHGVAR     VAR(&NBRMSGS ) VALUE(%BIN(&RECEIVER  29  4))
             CHGVAR     VAR(&SIZE    ) VALUE(%BIN(&RECEIVER  33  4))
             CHGVAR     VAR(&INCSIZE ) VALUE(%BIN(&RECEIVER  37  4))
             CHGVAR     VAR(&NBRINCS ) VALUE(%BIN(&RECEIVER  41  4))
             CHGVAR     VAR(&MAXINCS ) VALUE(%BIN(&RECEIVER  45  4))
             CHGVAR     VAR(&SEV     ) VALUE(%BIN(&RECEIVER  49  4))
             CHGVAR     VAR(&DLVRY   ) VALUE(%SST(&RECEIVER  53  7))
             CHGVAR     VAR(&BRKPGM  ) VALUE(%SST(&RECEIVER  60 10))
             CHGVAR     VAR(&BRKPGMLIB) VALUE(%SST(&RECEIVER  70 10))
             CHGVAR     VAR(&FORCE   ) VALUE(%SST(&RECEIVER  80  4))
             CHGVAR     VAR(&TEXT    ) VALUE(%SST(&RECEIVER  84 50))
             CHGVAR     VAR(&ALWALR  ) VALUE(%SST(&RECEIVER 134  1))
             CHGVAR     VAR(&FULLACN ) VALUE(%SST(&RECEIVER 141 10))

             CHGVAR     VAR(&ALWRPY  ) VALUE(%SST(&RECEIVER 151 10))

 ENDPGM:
             RMVMSG     CLEAR(*ALL)
             RETURN     /* Normal end of program */

/*-- Error handling:  -----------------------------------------------*/
 Error:
     CALL      QMHMOVPM    ( '    '                                  +
                             '*DIAG'                                 +
                             X'00000001'                             +
                             '*PGMBDY'                               +
                             X'00000001'                             +
                             X'0000000800000000'                     +
                           )

     CALL      QMHRSNEM    ( '    '                                  +
                             X'0000000800000000'                     +
                           )
             ENDPGM


File  : QCMDSRC
Member: RTVMSGQA
Type  : CMD
Usage : CrtCmd      Cmd( RtvMsgQA  )                             
                    Pgm( RtvMsgQA  )                                
                    Allow(*Ipgm *Bpgm)                              
                    SrcFile( YourSourceFile )       

/*  ===============================================================  */
/*  = Command....... RtvMsgQA                                     =  */
/*  = CPP........... CtvMsgQA                                     =  */
/*  = Description... Retrieve Message Queue Attributes            =  */
/*  =                                                             =  */
/*  = CrtCmd      Cmd( RtvMsgQA  )                                =  */
/*  =             Pgm( RtvMsgQA  )                                =  */
/*  =             Allow(*Ipgm *Bpgm)                              =  */
/*  =             SrcFile( YourSourceFile )                       =  */
/*  ===============================================================  */
/*  = Date  : 2007/12/31                                          =  */
/*  = Author: Vengoal Chang                                       =  */
/*  ===============================================================  */
             CMD        PROMPT('Retrieve MSGQ Attributes')
             PARM       KWD(MQGQ) TYPE(QUALD) MIN(1) CHOICE(*NONE) +
                          PROMPT('Messagq queue' 1)
             PARM       KWD(RTNLIB) TYPE(*CHAR) LEN(10) RTNVAL(*YES) +
                          PROMPT('Actual library name       (10)')
             PARM       KWD(NBRMSGS) TYPE(*DEC) LEN(10 0) +
                          RTNVAL(*YES) PROMPT('Number of +
                          messagese     (10 0)')
             PARM       KWD(SIZE) TYPE(*DEC) LEN(10 0) RTNVAL(*YES) +
                          PROMPT('Size of the msg queue   (10 0)')
             PARM       KWD(INCSIZE) TYPE(*DEC) LEN(10 0) +
                          RTNVAL(*YES) PROMPT('Increment +
                          size          (10 0)')
             PARM       KWD(NBRINCS) TYPE(*DEC) LEN(10 0) +
                          RTNVAL(*YES) PROMPT('Number of +
                          increments    (10 0)')
             PARM       KWD(MAXINCS) TYPE(*DEC) LEN(10 0) +
                          RTNVAL(*YES) PROMPT('Maximum +
                          increments      (10 0)')
             PARM       KWD(SEV) TYPE(*DEC) LEN(2 0) RTNVAL(*YES) +
                          PROMPT('Severity code filter     (2 0)')
             PARM       KWD(DLVRY) TYPE(*CHAR) LEN(7) RTNVAL(*YES) +
                          PROMPT('Delivery type             ( 7)')
             PARM       KWD(BRKPGM) TYPE(*CHAR) LEN(10) RTNVAL(*YES) +
                          PROMPT('Break program             (10)')
             PARM       KWD(BRKPGMLIB) TYPE(*CHAR) LEN(10) +
                          RTNVAL(*YES) PROMPT('Break program +
                          library     (10)')
             PARM       KWD(ALWRPY) TYPE(*CHAR) LEN(10) RTNVAL(*YES) +
                          PROMPT('Allow other jobs to reply (10)')
             PARM       KWD(FORCE) TYPE(*CHAR) LEN(4) RTNVAL(*YES) +
                          PROMPT('Force to auxiliary storage( 4)')
             PARM       KWD(ALWALR) TYPE(*CHAR) LEN(1) RTNVAL(*YES) +
                          PROMPT('Allow alerts (Y/N)        ( 1)')
             PARM       KWD(FULLACN) TYPE(*CHAR) LEN(10) +
                          RTNVAL(*YES) PROMPT('Message queue full +
                          action (10)')
             PARM       KWD(TEXT) TYPE(*CHAR) LEN(50) RTNVAL(*YES) +
                          PROMPT('Text                      (50)')
QUALD:       QUAL       TYPE(*NAME) +
                        LEN(10) +
                        MIN(1)
             QUAL       TYPE(*NAME) +
                        LEN(10) +
                        DFT(*LIBL) +
                        SPCVAL( +
                          (*CURLIB ) +
                          (*LIBL )) +
                        PROMPT('LIBRARY')


File  : QLSRC
Member: RTVMSGQAT
Type  : CCL
Usage : CrtCLPgm   Pgm( RtvMsgQAT  )  
        CALL  RtvMsgQAT  ('QSYSOPR' '*LIBL')                           

  /*  PROGRAM : RTVMSGQA                                        */
  /*  SYSTEM  : iSeries                                         */
  /*  AUTHOR :  Vengoal Chang           December 31, 2007       */
  /*                                                            */
  /*  Retrieve the message queue attributes                     */
  /*                                                            */


 RTVMSGQA:   PGM  (&MSGQ &MSGQLIB)

             DCL        VAR(&RTNLIB )   TYPE(*CHAR) LEN(10)
             DCL        VAR(&NBRMSGS )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&SIZE    )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&INCSIZE )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&NBRINCS )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&MAXINCS )  TYPE(*DEC ) LEN(10 0)
             DCL        VAR(&SEV     )  TYPE(*DEC ) LEN(2 0)
             DCL        VAR(&DLVRY   )  TYPE(*CHAR) LEN(7)
             DCL        VAR(&BRKPGM )   TYPE(*CHAR) LEN(10)
             DCL        VAR(&BRKPGMLIB) TYPE(*CHAR) LEN(10)
             DCL        VAR(&FORCE  )   TYPE(*CHAR) LEN( 4)
             DCL        VAR(&ALWALR )   TYPE(*CHAR) LEN( 1)
             DCL        VAR(&ALWRPY )   TYPE(*CHAR) LEN(10)
             DCL        VAR(&FULLACN )  TYPE(*CHAR) LEN(10)
             DCL        VAR(&TEXT    )  TYPE(*CHAR) LEN(50)
             DCL        VAR(&MSGQ)      TYPE(*CHAR) LEN(10)
             DCL        VAR(&MSGQLIB)   TYPE(*CHAR) LEN(10)
             DCL        VAR(&MSGQQUAL)  TYPE(*CHAR) LEN(20) /* +
                          qualified message queue name */

             MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))

             RTVMSGQA   MQGQ(&MSGQLIB/&MSGQ) RTNLIB(&RTNLIB) +
                          NBRMSGS(&NBRMSGS) SIZE(&SIZE) +
                          INCSIZE(&INCSIZE) NBRINCS(&NBRINCS) +
                          MAXINCS(&MAXINCS) SEV(&SEV) DLVRY(&DLVRY) +
                          BRKPGM(&BRKPGM) BRKPGMLIB(&BRKPGMLIB) +
                          ALWRPY(&ALWRPY) FORCE(&FORCE) +
                          ALWALR(&ALWALR) FULLACN(&FULLACN) TEXT(&TEXT)
             DMPCLPGM

             SNDPGMMSG  MSG('The messge queue' *bcat &RTNLIB *TCAT +
                            '/' *CAT &MSGQ *BCAT +
                            'delivery mode = ' *CAT &DLVRY    +
                            *BCAT 'Message queue full action =' *CAT +
                            &FULLACN)

 ENDPGM:
             RETURN     /* Normal end of program */

/*-- Error handling:  -----------------------------------------------*/
 Error:
     CALL      QMHMOVPM    ( '    '                                  +
                             '*DIAG'                                 +
                             X'00000001'                             +
                             '*PGMBDY'                               +
                             X'00000001'                             +
                             X'0000000800000000'                     +
                           )

     CALL      QMHRSNEM    ( '    '                                  +
                             X'0000000800000000'                     +
                           )
             ENDPGM
                        




沒有留言: