TAA Tools
RPGSNDMSG       RPG SEND MESSAGE USING API             TAASUBD

Note ---  The RPG Send  Message tool is  very flexible, but  requires a
few  steps  to include  the  code in  your  program.   There  are other
simple solutions provided by the TAA Tools:

        - SNDESCMSG   - Send escape message
        - SNDSTSMSG   - Send status message
        - SNDDIAGMSG  - Send diagnostic message
        - SNDCOMPMSG  - Send completion message

The  RPG Send Message tool  provides the basic RPG  code needed to send
a message using  the QMHSNDPM API.   The advantage of  the API is  that
you do not need a CL program to send messages.

The intent  of the tool is that  you would access this  member from the
SEU  browse function and copy  in the code when  you want the function.

The source  is  in the  proper  format for  an  RPG program  (You  must
remove the  **NEWPAGE line).   The E  spec and the  array data  must be
placed in  the proper place in  the program.  The  sample MOVE and EXSR
specs show how  to use the  subroutine.  You must  provide the  message
text as array data.  See the sample.

The ZMSBR  subroutine is  written so  that it  is a 'black  box'.   You
should not  need to make  any changes to  the subroutine.   The code in
the  subroutine uses  the CAT operation  to generate hex  4 byte binary
values  required by  the  API  and  some other  unusual  techniques  to
simplify the interface.

     E* Arrays used for RPGSNDMSG TAA Tool
     E                    ZMC     1  50  3   ZMT    68   Msg code/text
     C* Sample of MOVE and EXSR to invoke the 'Send msg' subroutine
     C                     MOVE 'Z01'     ZMERID           Set msg code
     C                     EXSR ZMSBR                      Msg subr
     C****************************************************************
     C* Subroutine to send a message using the QMHSNDPM API
     C*   This code was copied from the TAA Tool RPGSNDMSG
     C           ZMSBR     BEGSR                           Msg subr
     C* Initialize fields on first use
     C           ZMFST     IFEQ *BLANK                     If 1st time
     C           *LIKE     DEFN ZMC       ZMERID           Msg ID
     C           *LIKE     DEFN ZMT       ZMMSG2           Addl txt fld
     C           X'0000'   CAT  X'0000'   ZMERRC           Error code
     C* Set the message data length to 256
     C           X'0000'   CAT  X'00FF'   ZMMDLN           Msg dta len
     C* If Stack count is 1, it goes to the calling pgm's msg queue
     C           X'0000'   CAT  X'0001'   ZMSTKC           Stack ctr
     C                     MOVE 'X'       ZMFST   1        1st time sw
     C                     ENDIF                           If 1st time
     C* If Msg ID is blank or CPF9898 use, standard message
     C           ZMMID     IFEQ *BLANKS                    If blank
     C           ZMMID     OREQ 'CPF9898'                    or CPF9898
     C                     MOVE 'CPF9898' ZMMID            Msg ID
     C           'QCPFMSG' CAT  '*LIBL':3 ZMQLF     P      Qlfd msg fil
     C                     ENDIF                           If blank
     C* If the message type is *STATUS, make the pgmq = *EXT
     C           ZMMTYP    IFEQ '*STATUS'                  If *STATUS
     C                     MOVEL'*EXT'    ZMPGMQ           Pgm queue
     C                     ENDIF                           If *STATUS

     C* If the message type is blank, make it an escape
     C           ZMMTYP    IFEQ *BLANKS                    No msg type
     C                     MOVEL'*ESCAPE' ZMMTYP    P      Msg type
     C                     ENDIF                           No msg type
     C* If the message queue is blank, move an *
     C           ZMPGMQ    IFEQ *BLANKS                    No msgq
     C                     MOVEL'*'       ZMPGMQ           Pgm queue
     C                     ENDIF                           No msgq
     C* Lookup message ID
     C                     Z-ADD1         ZMX     30       Msg index
     C           ZMERID    LOKUPZMC,ZMX                  20 Lookup
     C* If not found, generate a special message
     C  N20                DO                              Not found
     C           'No text 'CAT  'ZMERID ='ZMMDTA    P      No txt msg
     C                     CAT  ZMERID:1  ZMMDTA           No txt msg
     C                     GOTO ZMSND                      Branch
     C                     ENDDO                           Not found
     C* If found, assemble message text from one or more lines
     C                     MOVELZMT,ZMX   ZMMDTA           Msg data
     C* Check for additional message text lines
     C                     DO   4                          Do 4 times
     C                     ADD  1         ZMX              Bump
     C* If not same ID, branch to send the message
     C           ZMERID    CABNEZMC,ZMX   ZMSND            Branch NE
     C* If same ID, concatenate the message
     C                     MOVE ZMT,ZMX   ZMMSG2           Addl text
     C                     CAT  ZMMSG2:0  ZMMDTA           Concat
     C                     ENDDO                           Do 4 times
     C* Send escape message using the API
     C           ZMSND     TAG                             Send point
     C                     CALL 'QMHSNDPM'                 Call API
     C                     PARM           ZMMID   7        Message ID
     C                     PARM           ZMQLF  20        Qlfd msgf
     C                     PARM           ZMMDTA256        Msg dta
     C                     PARM           ZMMDLN  4        Msg dta len
     C                     PARM           ZMMTYP 10        Msg type
     C                     PARM           ZMPGMQ 10        Pgm queue
     C                     PARM           ZMSTKC  4        Stack cntr
     C                     PARM           ZMMKEY  4        Msg key
     C                     PARM           ZMERRC  4        Error code
     C                     ENDSR                           Msg subr
     C****************************************************************
** ERC and ERT - Message code and text (Text ends in 71)
Z01Sample message with only one line of text
Z02Sample complex message covering multiple lines which will be
Z02 concatenated together. Start each additional line with the
Z02 same code and a blank in the first position of text.
Z02 You can have up to 4 lines for a maximum of 256 bytes
XXXAllow at least one dummy entry at the end of the array

Sending a simple escape message
-------------------------------

The  subroutine defaults  to  send message  text  of you  choice as  an
escape  message using the CPF9898 message.   The message is sent to the
program that called  the RPG program.   The message  text exists in  an
array in the RPG program.  You supply the text to be used.

Sending a simple status message
-------------------------------

To send the CPF9898  message as a status message,  you do the following
before the EXSR statement:

     C                     MOVEL'*STATUS' ZMMTYP           Msg type

You must supply the message text as array data.

Sending other message IDs, etc.
-------------------------------

You  can also  send any message  from any  message file of  any message
type by setting the values for the following fields:

         ZMMID       Message ID - 7 bytes
         ZMQLF       Qualified message file - 20 bytes
         ZMMTYP      Message type - 10 bytes
         ZMPGMQ      Program queue - 10 bytes
                       (Use an * for typical use)

If you are  not sending  the CPF9898  message, you must  set the  array
data to cause the proper message data for the message.

Entering message text
---------------------

Each  message  you  want  to  send  must  have  a  unique  3  character
identifier.   The message text is  entered as array data and  can be up
to  4  lines  of  source  (a  maximum  of  256  bytes).    The text  is
concatenated together  if the additional  message lines  have the  same
Message  ID.  See  the example  for ID  Z02 to see  how to  construct a
message that is more than one line.

If you  send the CPF9898 message, the system  adds a period as the last
character.

You must have at  least one dummy message as  the last array entry  (or
just  define  the  array  to  be  larger  than  the  number  of  source
statements provided).

Command parameters                                    *CMD
------------------

No command is provided.

Restrictions
------------

None.

Prerequisites
-------------

None.

Implementation
--------------

None.  The code only exists in the QATTINFO member.

Objects used by the tool
------------------------

None.  The code only exists in the QATTINFO member.
					

Added to TAA Productivity tools April 1, 1995


Home Page Up to Top