Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

QMHSNDPM & QMHRCVPM

463 views
Skip to first unread message

Gary J. Morin

unread,
Mar 12, 1996, 3:00:00 AM3/12/96
to
*
* Main program A
*
* Purpose : simple maintence program to add/change the customer
* table.
*
DProgramVar DS
D msglen 4B 0 inz(0)
D stkctr 4B 0 inz(0)
D pgmwtt 4B 0 inz(0)
*
Dmsgerr DS
D provid 1 4B 0 inz(60)
D avail 5 8B 0 inz(60)
D rtnmsg 9 15
D rsvr 16 16
D rtndta 17 60
*
Dmsginfo DS
D provid2 1 4B 0 inz(88)
D avail2 5 8B 0 inz(88)
D msgsev 9 12B 0 inz(0)
D msgid2 13 19 inz('CPF9898')
D msgtyp2 20 21
D msgkey2 22 25
D msgresvd 26 32
D CCSID1 33 36B 0 inz(0)
D CCSID2 37 40B 0 inz(0)
D lenret 41 44B 0 inz(0)
D lenavl 45 48B 0 inz(0)
D msgdta2 49 88
*
*code deleted....
*
*

*---------------------------------------------------------------------------
C msghdr Begsr
*
* subroutine should remove any messages from the program
* message queue and then take some action.

*---------------------------------------------------------------------------
C Call 'QMHRCVPM'
C PARM msginfo
C PARM 88 msglen
C PARM 'RCVM0100' fmtname 8
C PARM '* ' stkent 10
C PARM 0 stkctr
C PARM '*ANY ' mtype 10
C PARM '9898' msgkey 4
C PARM pgmwtt
C PARM '*REMOVE ' msgact 10
C PARM msgerr
*
C Endsr

*-------------------------------------------------------------------------------
*
* Trigger Program B
*
* Purpose : a trigger program executre *before *update
* to check several fields for values.
* if the field FIRSTN is blank an *ESCAPE message
* should be sent back to the main program.
*
DMsg C 'First name field cannot be
blank'
DProgramVar DS
D msglen 1 4B 0
D stkctr 5 8B 0
D rtvlen 9 12B 0
D msgqln 13 16B 0
D pgmwtt 17 20B 0
*
Dmsgerr DS
D provid 1 4B 0 inz(56)
D avail 5 8B 0
D rtnmsg 9 15
D rsvr 16 16
D rtndta 17 56
*
*code deleted....
Could anyone in this group help me out. I'm this fustrating
problems with those two APIs. I am attempting to get a trigger
program (Program B below) to send an *ESCAPE message
to Program A's message queue and use QMHRCVPM to get this message.
Could any take a look at the code below and help me out?? I've been
looking at the IBM API ref. manual and an issue of News 3x/400 (Feb.
1995) in order to help me, but I'm still not getting it.

C*-------------------------------------------------------------------------
C Sendmsg Begsr

C*-------------------------------------------------------------------------
C Call 'QMHSNDPM'
C PARM 'CPF9898' msgid 7
C PARM msgfloc msgf 20
C PARM msg msgdta 40
C PARM 40 msglen
C PARM '*INFO ' msgtype 10
C PARM '* ' stkent 10
C PARM 2 stkctr
C PARM msgkey 4
C PARM msgerr
*
C Endsr


Herb Bujak

unread,
Mar 13, 1996, 3:00:00 AM3/13/96
to
In article <4i4agc$j...@news.mainelink.net>, ma...@mainelink.net (Gary J.

Morin) wrote:
> Could anyone in this group help me out. I'm this fustrating
> problems with those two APIs. I am attempting to get a trigger
> program (Program B below) to send an *ESCAPE message
> to Program A's message queue and use QMHRCVPM to get this message.
> Could any take a look at the code below and help me out?? I've been
> looking at the IBM API ref. manual and an issue of News 3x/400 (Feb.
> 1995) in order to help me, but I'm still not getting it.
>

What exactly is going wrong? Are there any messages in your job log?

Here are few thoughts:

1) Is the message file parm correct? 10 char file name + 10 char lib

2) Stack counter value works differently than I expected when I did this
in an ILE/C program. It appears to count each function (subroutine in
RPG??) as a level in the stack. Check your job log for the CPF9898
message, hit F1 on it and then F11 (Display Message Details) to see from
where and to where the message is being sent.

HarryHiles

unread,
Mar 13, 1996, 3:00:00 AM3/13/96
to
In article <4i4agc$j...@news.mainelink.net>, ma...@mainelink.net (Gary J.
Morin) writes:

> C Call 'QMHRCVPM'
> C PARM msginfo
> C PARM 88 msglen
> C PARM 'RCVM0100' fmtname 8
> C PARM '* ' stkent 10
> C PARM 0 stkctr
> C PARM '*ANY ' mtype 10
> C PARM '9898' msgkey 4
> C PARM pgmwtt
> C PARM '*REMOVE ' msgact 10
> C PARM msgerr

The message key (msgkey) parm should be blank, not 9898. Message key
values are assigned by the command or API when the message is sent and are
not related to the message ID (CPF9898 in this case). When QMHRCVPM
receives a message, its message key is returned in the message information
parm in positions 22-25 of the RCVM100/RCVM200 formats.

> * Trigger Program B
> *
> * Purpose : a trigger program executre *before *update
> * to check several fields for values.
> * if the field FIRSTN is blank an *ESCAPE message
> * should be sent back to the main program.
> *

> [snip]


>
> Could anyone in this group help me out. I'm this fustrating
>problems with those two APIs. I am attempting to get a trigger
>program (Program B below) to send an *ESCAPE message
>to Program A's message queue and use QMHRCVPM to get this message.
>Could any take a look at the code below and help me out?? I've been
>looking at the IBM API ref. manual and an issue of News 3x/400 (Feb.
>1995) in order to help me, but I'm still not getting it.
>
>C*-----------------------------------------------------------------------
--
> C Sendmsg Begsr
>
>C*-----------------------------------------------------------------------
--
> C Call 'QMHSNDPM'
> C PARM 'CPF9898' msgid 7
> C PARM msgfloc msgf 20
> C PARM msg msgdta 40
> C PARM 40 msglen
> C PARM '*INFO ' msgtype 10
> C PARM '* ' stkent 10
> C PARM 2 stkctr
> C PARM msgkey 4
> C PARM msgerr

The above is sending an informational message to the program that is 2
call stack entries ahead of the current program (the caller's caller).
This may not be what you want. If you want to always send the message to
the most recent call stack entry for program A, put the name of program A
in the program message queue parm (stkent) and set the program stack
counter parm (stkctr) to zero.

Hope this helps. If you have more questions or would like more info, feel
free to e-mail me.

Harry B. Hiles
Los Angeles, CA USA
Harry...@aol.com

The TEAMIBM Network

unread,
Mar 13, 1996, 3:00:00 AM3/13/96
to
Excerpts from ext.globenet.400misc-netnews: 13-Mar-96 QMHSNDPM &
QMHRCVPM 5436@netnews (4881)

> Could anyone in this group help me out. I'm this frustrating


> problems with those two APIs. I am attempting to get a trigger
> program (Program B below) to send an *ESCAPE message
> to Program A's message queue and use QMHRCVPM to get this message.

Gary, I'm not much of an RPG programmer, but I do know
something about these two APIs.

First some hints on your send code:

C Call 'QMHSNDPM'
C PARM 'CPF9898' msgid 7

C PARM msgfloc msgf 20

"msgfloc" needs to be set to the 10 message file name
concatenated with the 10 character library of the
message file. (ie 'QCPFMSG QSYS ')

C PARM msg msgdta 40
C PARM 40 msglen

C PARM '*INFO ' msgtype 10

this should be '*ESCAPE ' if you really want to send an
*ESCAPE message. (But see below.)

C PARM '* ' stkent 10
C PARM 2 stkctr

the combination of '*' and '2' here says that if you were
to do a DSPJOB OPTION(*PGMSTK) when QMHSNDPM is called,
you would find a call stack entry for "Main program A",
followed by some other call stack entry, followed by the
call stack entry invoking QMHSNDPM. (ie the destination of
your message is 2 call stack entries prior to the current
invocation)

C PARM msgkey 4
C PARM msgerr


Now for the QMHRCVPM code:

First, special handling needs to be done if you expect to
handle and receive messages of type *ESCAPE. *ESCAPE is
an exception type message and I believe you need to set up
an exception handling routine to monitor for the exception
and take the appropriate action. (For RPG, I believe this is
a PSSR routine.) If you don't handle an *ESCAPE message
when it is sent to your code, you will function check.

Dmsginfo DS
all the fields in this structure are output and filled in
by QMHRCVPM. You don't need to initialize any of them.


D provid2 1 4B 0 inz(88)
D avail2 5 8B 0 inz(88)
D msgsev 9 12B 0 inz(0)
D msgid2 13 19 inz('CPF9898')
D msgtyp2 20 21
D msgkey2 22 25
D msgresvd 26 32
D CCSID1 33 36B 0 inz(0)
D CCSID2 37 40B 0 inz(0)
D lenret 41 44B 0 inz(0)
D lenavl 45 48B 0 inz(0)
D msgdta2 49 88

C Call 'QMHRCVPM'


C PARM msginfo
C PARM 88 msglen
C PARM 'RCVM0100' fmtname 8
C PARM '* ' stkent 10
C PARM 0 stkctr
C PARM '*ANY ' mtype 10

C PARM '9898' msgkey 4

A message key is conceptually an index specifying the
location of a specific message in the joblog. (ie the 1st,
2nd, 3rd... message in the job log). You get this index
as output from QMHSNDPM in the Message Key parameter.
Generally, one doesn't know the message key of the message
being received, so you set this field to blanks (ie you
want ' ' instead of '9898').

C PARM pgmwtt
C PARM '*REMOVE ' msgact 10
C PARM msgerr

Finally, it's a matter of personal preference, but I find
it is easier to debug code under development by setting
the "Bytes Provided" field of the error code structures to
0. (The "provid" field in your "msgerr" structures.)
That way, any problems I have calling the APIs are sent
as exceptions to my joblog. That way, I don't have to go
in and look at the structures returned in the error code
to figure out if anything is going wrong on my calls.

Good luck -- Walt

Walt Madden AS/400 Division
Department 45X; IBM Rochester, Minnesota
(507)253-5340 tie-line: 553-5340
rchland(wrmadden) or wrma...@vnet.ibm.com

0 new messages