Stuart,
As Simon pointed out, in your display file DDS, you should have something
like this:
*================================================================
* MSGRCD - Message subfile record
*================================================================
A R MSGRCD SFL
A SFLMSGRCD(24)
A MSGKEY SFLMSGKEY
A PGMNAM SFLPGMQ
A*================================================================
* MSGCTL - Message subfile control
A*================================================================
A R MSGCTL SFLCTL(MSGRCD)
A OVERLAY
A SFLSIZ(2)
A SFLPAG(1)
A SFLDSP
A SFLDSPCTL
A SFLINZ
A 25
AON25 SFLEND
A PGMNAM SFLPGMQ
and in your RPG program (at the top, before anything is actually done), you
have something like the following:
/free
PGMNAM = 'MYPGM';
/end-free
and in your message sending procedure, you simply pass 'PGMNAM' as the call
stack entry and 0 as the call stack entry count.
Of course, to be more generic, you could (should) use the Program Status
Data Structure, so in your main-line code, you could have the following
(mine is in a copybook):
D PgmSDS SDS Qualified
D MainProc 10A
D Status 5S 0
D PrvSts 5S 0
D Stmt 8A
D Routine 8A
D Parms 3S 0
D ExcpMsg 7A
D ExcpMsgPfx 3A Overlay(ExcpMsg)
D ExcpMsgNbr 4A Overlay(ExcpMsg:*Next)
D 4A
D WorkArea 30A
D PgmLib 10A
D ExcpData 80A
D ExcpID 4A
D FileErr 10A
D 6A
D Date 8A
D Century 2A
D FileErr2 8A
D FileSts 35A
D QualJob 26A
D JobName 10A Overlay(QualJob)
D JobUser 10A Overlay(QualJob:*Next)
D JobNbr 6A Overlay(QualJob:*Next)
D JobDate 6S 0
D JobDateC 6A Overlay(JobDate)
D RunDate 6S 0
D RunDateC 6A Overlay(RunDate)
D RunTime 6S 0
D RunTimeC 6A Overlay(RunTime)
D CmpDate 6S 0
D CmpDateC 6A Overlay(CmpDate)
D CmpTime 6S 0
D CmpTimeC 6A Overlay(CmpTime)
D CmpLvl 4A
D SrcfName 10A
D SrcfLib 10A
D SrcfMbr 10A
D OwnPgm 10A
D OwnMod 10A
D 76A
D SrcID 5I 0
D SrcID2 5I 0
D UsrPrf 10A
D 62A
and then you have this at the top of the mainline code:
PGMNAM = PgmSDS.OwnPgm;
and pass PGMSDS.OwnPgm as the CSE value to QMHSNDPM. That way, as long as
you ensure that every program which includes the message sending procedure
also includes the PGMSDS copybook, you will know that it will correctly get
sent to the program message queue.
At least that's how I do it, and it's always worked for me.
Rory
On Thu, Mar 11, 2010 at 3:41 PM, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>wrote:
Stuart,
The PEP for an RPG program should be named something like this:
_QRNP_PEP_my-program-name
Notice that it's not the same name as the program. However, it _is_ the
"program boundary" (*PGMBDY) that might be what you are thinking of?
But sending the message to the "program name" (by which I assume you
mean the /module/ name) you should get the main procedure of that
module, so it should be easy enough to use that name from a subprocedure
to send a message to a message subfile.
also -- wanted to point out that a program can potentially have many
"main procedures"... So when you said the PEP called the "main
procedure" you weren't quite right. It calls the main procedure of the
entry module -- which is also referred to as the UEP (User Entry Procedure)
As an Amazon Associate we earn from qualifying purchases.