Problem solve Get help with specific problems with your technologies, process and projects.

Message break-handling program helps you monitor inquiry messages

This break-handling program manages incoming messages according to the kind of message that's received.

It is tedious to enter DSPMSG repeatedly to check messages and inconvenient to have work interrupted in *BREAK mode for every 'Job completed...' message. However, I don't want inquiry messages sitting without response for long periods. Instead, I have a break-handling program that manages incoming messages according to what kind of message is received. Messages requiring a response will break into my current job. Other messages display, as they are received, on the message line without interrupting me.


/* The following three input parameters are standard for a + 'Break Handling' program. */

PGM PARM(&MSGQ &MSGQLIB &MSGKEY)

DCL &MSGQ *CHAR 10 /* Queue where the msg is. */
DCL &MSGQLIB *CHAR 10 /* Queue library. */
DCL &MSGKEY *CHAR 4 /* Key of the received msg. */
DCL &MSGID *CHAR 7 /* ID of the received msg. */
DCL &RTNTYPE *CHAR 2 /* Type of the received msg. */
DCL &MSG *CHAR 78 /* Msg text. */
DCL &OPEN *CHAR 1 VALUE(X'21') /* Rev img. attrib. */
DCL &CLOSE *CHAR 1 VALUE(X'20') /* Normal attrib. */

/* When your message queue is in *BREAK mode and a +
break handling program is assigned, the program +
is automatically called when a message arrives +
and the three parameters are apssed so that the +
message can be received. */

RCVMSG MSGQ(&MSGQLIB/&MSGQ) MSGKEY(&MSGKEY) +
RMV(*NO) MSG(&MSG) MSGID(&MSGID) +
RTNTYPE(&RTNTYPE)

/* Message type '05' is an *INQ type message. Show +
the 'Display Messages' screen so that the message +
can be responded to. */
IF COND(&RTNTYPE = '05') THEN(DSPMSG +
MSGQ(&MSGQLIB/&MSGQ))

/* When a batch job you have submitted gets an error +
message in QSYSOPR, you get a CPI2404 sent to you. +
Display QSYSOPR msgq so that you can respond. */
ELSE CMD(IF COND(&MSGID = CPI2404) THEN(DSPMSG +
MSGQ(QSYSOPR)))

/* All others just display as a *STATUS message. */
/* The &OPEN and &CLOSE are hex display attributes that +
cause the status message to be shown in reverse +
image. */
ELSE CMD(SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA(&OPEN *CAT &MSG *TCAT ' - ' *CAT +
&MSGID *CAT &CLOSE) TOPGMQ(*EXT) +
MSGTYPE(*STATUS))

_

Dig Deeper on RPG iSeries programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close