Raul,
I have a useful technique for this sort of thing:
1. Create a source member called MSG and copy all the code (below) into it -
prototype *and* procedure.
2. Include MSG as a copy member *twice* in the main source member - once at
the top, with the other D-specs, and once at the very bottom, like this:
/COPY QRPGLESRC,MBR
When the compiler finds the copybook at the top, 'MSG' isn't defined, so the
compiler defines 'MSG' and only the 3 prototype lines are included there.
When the compiler finds the copybook at the bottom, 'MSG' has been defined,
so only the procedure itself is included there. I like this technique, since
it means I don't need to manually copy the procedure definition at the top
or anything like that.
/IF NOT DEFINED(MSG)
/DEFINE MSG
Dmsg PR n
D msg_data 6000 value varying
D msg_user 10 value
/ELSE
Pmsg B
Dmsg PI n
D msg_data 6000 value varying
D msg_user 10 value
D msgqKant s 10I 0
D wwMsgLen s 10I 0
D dsEC DS
D dsECBytesP 1 4I 0 INZ(256)
D dsECBytesA 5 8I 0 INZ(0)
D dsECMsgID 9 15
D dsECReserv 16 16
D dsECMsgDta 17 256
c monitor
c eval msgqnames = msg_user + '*LIBL'
c eval wwMsgLen = %len(msg_data)
c call 'QMHSNDM'
c parm ' ' MessageID 7
c parm ' ' QualMsgF 20
c parm Msg_data
c parm wwMsgLen
c parm '*INFO' MsgType 10
c parm msgqNames 20
c parm 1 msgqkant
c parm ' ' msgqReply 20
c parm MessageKey 4
c parm dsec
c on-error
c return *off
c endmon
c return *on
Pmsg E
/ENDIF
p.s. I made the msg_data parameter varying, too, so you don't need the
%TRIMR.
HTH,
Rory
On Wed, Apr 28, 2010 at 3:01 PM, Raul A. Jager W. <raul@xxxxxxxxxx> wrote:
Thank you. QMHSNDM does the job. I created a source member to copy at
the end of each program. To bad, it can't be a function because in that
case the message comes from the function, and not the originating program.
As an Amazon Associate we earn from qualifying purchases.