On 2012/5/4 7:45 PM, Rory Hewitt wrote:
Um. service programs might not be, but programs are (one call stack above
their PEP entry). Aren't they?
I don't think so, at least not for the purpose of sending messages. Only
ILE procedures are on the call stack.
For a cycle-main RPG module, the main procedure gets given the same name
as the module when it is created, and if you also use that name for the
program, then it could appear as though you were successfully sending a
message to the program. But in that case, the *PROC value in the PSDS
would also have the name of the main procedure. When you want to send a
message to the cycle main, *PROC is more reliable than 334-343 since the
name of the main procedure can never change, but the name of the module
and program can change after they were compiled.
Here's how I proved it to myself.
I created the RPG module as CALLSTK1, and the CLLE module as CALLSTKMSG
(see code below).
===> crtpgm qtemp/callstk1 module(callstk1 callstkmsg) entmod(callstk1)
===> crtpgm qtemp/callstk2 module(callstk1 callstkmsg) entmod(callstk1)
When I call CALLSTK1, it works fine because the RPG main procedure has
the same name the program, CALLSTK1.
My call stack at the time of the SNDPGMMSG:
Program Procedure
CALLSTK1 _QRNP_PEP_CALLSTK1
CALLSTK1 CALLSTK1
CALLSTK1 CALLSTKMSG
When I call CALLSTK2, it fails with CPF2479 when trying to send the
message, because the program name is CALLSTK2, and that's not the name
of any procedure on the stack.
Cause . . . . . : Call stack entry CALLSTK2, specified for the send,
receive, move or delete message operation, could not be found in the
call stack.
My call stack at the time of the SNDPGMMSG:
Program Procedure
CALLSTK2 _QRNP_PEP_CALLSTK1
CALLSTK2 CALLSTK1
CALLSTK2 CALLSTKMSG
CLLE module CALLSTKMSG
pgm parm(&where)
dcl &where type(*char) len(10)
sndpgmmsg msgid(CPF9898) msgf(qcpfmsg) +
msgtype(*info) +
msgdta('message to ' *BCAT &where) +
topgmq(*same (&where))
RPGLE module CALLSTK1:
D psds sds
D pgm 334 343
D callstkmsg pr
D where 10a const
/free
sndmsg (pgm);
return;
As an Amazon Associate we earn from qualifying purchases.