|
Here is the code. Two problems I see:
1. the msg in the final destination msgq will show the sender as the qsysopr
bhp job. Should show the original sender.
2. The &MsgType parm. Does it map from RcvMsg to SndPgmMsg?
PGM PARM(&MSGQ &MSGQLIB &MSGKEY)
DCL VAR(&MSGQ) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGQLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGKEY) TYPE(*CHAR) LEN(4)
DCL VAR(&MSG) TYPE(*CHAR) LEN(2000)
DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(2000)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&SENDER) TYPE(*CHAR) LEN(80)
DCL VAR(&SENDUSER) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGF) TYPE(*CHAR) LEN(10)
DCL VAR(&SNDMSGFLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&DESTMSGQ) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGTYPE) TYPE(*CHAR) LEN(2)
MONMSG MSGID(CPF0000 CPF9999) EXEC(GOTO +
CMDLBL(ENDPGM))
/* RECEIVE THE MSG */
RCVMSG MSGQ(&MSGQLIB/&MSGQ) MSGKEY(&MSGKEY) +
RMV(*NO) MSG(&MSG) MSGDTA(&MSGDTA) +
MSGID(&MSGID) SENDER(&SENDER) +
RTNTYPE(&MSGTYPE) MSGF(&MSGF) +
SNDMSGFLIB(&SNDMSGFLIB)
/* MSG SENDING JOB USER. */
CHGVAR VAR(&SENDUSER) VALUE(%SST(&SENDER 11 10))
/* DETERMINE IF MSG FROM A PROD OR TEST JOB. */
IF COND(&SENDUSER *EQ 'TESTUSER') THEN(DO)
CHGVAR VAR(&DESTMSGQ) VALUE('TESTSYSMSG')
ENDDO
ELSE CMD(CHGVAR VAR(&DESTMSGQ) VALUE('PRODSYSMSG'))
/* SEND THE MSG ONTO ITS FINAL DESTINATION. */
IF COND(&MSGID *EQ ' ') THEN(DO)
SNDPGMMSG MSG(&MSG) TOMSGQ(&DESTMSGQ) MSGTYPE(&MSGTYPE)
ENDDO
ELSE CMD(DO)
SNDPGMMSG MSGID(&MSGID) MSGF(&SNDMSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) TOMSGQ(&DESTMSGQ) +
MSGTYPE(&MSGTYPE)
ENDDO
ENDPGM: ENDPGM
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.