Re: Reply msg linkage info

Simon Coulter <shc-Q/[email protected]>
Newsgroups gmane.comp.lang.as400.mi
Message-ID <[email protected]>
On 11/09/2005, at 11:54 AM, M. Lazarus wrote:

>  Once I have retrieved a *RPY (any variety) message, is there a way to 
> directly link to its corresponding the *INQ message?

My initial thought was: Of course, the link is via the message key 
value. Consider:

When you send an *INQ message you fetch the reply by specifying the 
message key returned by SNDPGMMSG (or equivalent API). Therefore when 
you have a *RPY message you ought to be able to obtain the associated 
*INQ message by using the message key of the reply.

However, experimentation shows that although you can find the *RPY 
message using the *INQ message key you cannot do the reverse.

Once you have the *INQ message key you can toggle between retrieving 
the *INQ or associated *RPY message simply by changing the MSGTYPE. 
When you have the *RPY message key and you specify *INQ for MSGTYPE you 
get CPF2410. You get this error whether you use the original reply or 
the sender copy.

You can also find the *RPY via the message key of the sender's copy of 
the *INQ message.

> How does IBM do it when viewing a *MSGQ's messages?

By magic??? I figured there had to be a link between the two parts so 
started dumping message queue objects. I haven't fully deciphered the 
structure but most of it is straightforward. The structure is different 
for each message type. Interestingly the 'message key' is actually an 
offset into the associated space of the message queue and locates the 
start of the message structure.

Although the structure indicates a link between the *RPY and the *INQ 
message via a message key value it seems this value is not exposed via 
either the RCVMSG command nor the QMHRCVM API.

It appears that IBM code never links the *RPY to the *INQ. It always 
does the reverse--that is links the *INQ to the *RPY. Even if other 
messages were sent between the *INQ and the *RPY the *INQ and *RPY 
always appear together. Prompt the DSPMSG command and examine the 
values for MSGTYPE. You can only specify *ALL, *INFO, *INQ, or *COPY. 
If you specify *INQ or *COPY you will also get the associated *RPY 
message. So IBM code finds an *INQ message and then checks for a *RPY. 
If it finds one it is displayed otherwise it shows an input field where 
a reply could be typed.

>  If this info is available, I would appreciate some sample code.  If 
> possible, RPG using the appropriate MI built-ins, since this info does 
> not seem to be available via traditional means.  TIA.

You can link from the *INQ to the *RPY in CL using RCVMSG commands 
therefore it can also be done using the APIs from RPG or other HLL.

I suggest you change your process to look for the *RPY when you find an 
*INQ message instead of attempting the reverse.


Regards,
Simon Coulter.
--------------------------------------------------------------------
    FlyByNight Software         AS/400 Technical Specialists

    http://www.flybynight.com.au/
    Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
    Fax:   +61 3 9419 0175                                   \ /
                                                              X
                  ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------


_______________________________________________
This is the MI Programming on the AS400 / iSeries (MI400) mailing list
To post a message email: MI400-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/mi400
or email: MI400-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/mi400.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.