Managing Break Messages

Create a generic break handling CLP

Quite some time ago, I wrote a break handler. I had dropped it for years. But I was working in an environment where the shop used Turnover. I got irritated with Turnover messages breaking on my message queue. So, I sharpened my pencil and wrote a short version of the original program to redirect the messages. (Yes, it's old--I am retired!)

/*********************************************************************/
/*               Control language program description.               */
/*                                                                   */
/*   System Id............   IBM i5/OS V5R3                          */
/*   Program Id...........   SWBRKMCI                                */
/*   Programmer...........   Steven Croy                             */
/*   Date coded...........   14 FEB 2006                             */
/*                                                                   */
/*   Function.............   BREAK MESSAGE HANDLER                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

             PGM        PARM(&MSGQ &MSGQLIB &MSGKEY)

/*------------------------------------------------------------------*/
/* The 3 parameters messsage queue, message queue library and the   */
/* message key will be sent from the message queue processor.       */
/*------------------------------------------------------------------*/

             DCL        VAR(&MSGQ) TYPE(*CHAR) LEN(10) /* QUEUE +
                          WHERE THE MSG IS. */
             DCL        VAR(&MSGQLIB) TYPE(*CHAR) LEN(10) /* QUEUE +
                          LIBRARY. */
             DCL        VAR(&MSGKEY) TYPE(*CHAR) LEN(4) /* KEY OF +
                          THE RECEIVED MSG. */
             DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7) /* ID OF THE +
                          RECEIVED MSG. */
             DCL        VAR(&RTNTYPE) TYPE(*CHAR) LEN(2) /* TYPE OF +
                          THE RECEIVED MSG. */
             DCL        VAR(&MSG) TYPE(*CHAR) LEN(78) /* MSG TEXT. */

/*------------------------------------------------------------------*/
/* Attributes: starting and ending                                  */
/*------------------------------------------------------------------*/
             DCL        VAR(&OPEN) TYPE(*CHAR) LEN(1) VALUE(X'21')
             DCL        VAR(&CLOSE) TYPE(*CHAR) LEN(1) VALUE(X'20')

/*------------------------------------------------------------------*/
/* When your message queue is in *BREAK mode, assign a break        */
/* handler to execute whenever a message arrives.                   */
/*------------------------------------------------------------------*/

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

/*------------------------------------------------------------------*/
/* The message type is *INQ when the type code is '05', show then   */
/* display the message so you can respond.                          */
/*------------------------------------------------------------------*/

             IF         COND(&RTNTYPE = '05') THEN(DSPMSG +
                          MSGQ(&MSGQLIB/&MSGQ))

/*------------------------------------------------------------------*/
/* When a submitted job errors out, you receive CPI2404. Show the   */
/* QSYSOPR message queue to respond to the message.                 */
/*------------------------------------------------------------------*/

             ELSE       CMD(IF COND(&MSGID = CPI2404) THEN(DSPMSG +
                          MSGQ(QSYSOPR)))

/*------------------------------------------------------------------*/
/* All other messages will be treated as a *STATUS message. Show    */
/* the message on the external message queue line; do not break     */
/*------------------------------------------------------------------*/

             ELSE       CMD(SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
                          MSGDTA(&OPEN *CAT &MSG *TCAT ' - ' *CAT +
                          &MSGID *CAT &CLOSE) TOPGMQ(*EXT) +
                          MSGTYPE(*STATUS))

ENDPGM
  


Here is a screen captures of the simple break handling program (coded above). Note in the example below the reverse image message at the bottom of the display. I have set the break handling program, SWBRKMCI, in my library to be the break message handler for my message queue.

What this does is intercept the messages destined for my message queue and re-route the message (certain types of messages) to the external message queue (line 24) of my job. Messages that would normally break, an annoying occurrence while I’m looking at code, do not break, but merely appear as a message on the bottom of the current display. Messages like the ones from Turnover, appear as below. Less, obtrusive and much less annoying than when your queue is in normal break mode.

The program does filter certain types of messages. If you submit a job and it issues a CPF error message, the program will still break and show you the error, (inquiry type messages). If you want, copy the source to your library and create your own version of the break handler. In order to change your message queue to use a break handler, just issue the command CHGMSGQ:
Example:
CHGMSGQ MSGQ(LIBNAME) PGM(LIBNAME/SWBRKMCI)