CL Generic Message Programs

CL provides an easy method of managing messages queues.

Simplify Message Queue Management with CL

These three small programs can simplify message handling for HLL applications. They have been used as subprograms in an OPM environment and as bound procedures in ILE applications.

Remove a message

This program functions to remove an entry from a program message queue from any CL, or HLL program.

**************************************************************************/
/* Program Id...........  SC0005CL - Remove a program message            */
/*                                                                       */
/*                                                                       */
/* Compiler options.....  *OWNER                                         */
/*                                                                       */
/*************************************************************************/
/*************************************************************************/
/*                   MODIFICATION LOG                                    */
/*                                                                       */
/*   DATE   PROGRAMMER      DESCRIPTION                                  */
/*                                                                       */
/*************************************************************************/
     PGM PARM(&PRGNAM)
     DCL VAR(&PRGNAM) TYPE(*CHAR) LEN(10)
     RMVMSG PGMQ(*SAME &PRGNAM) CLEAR(*ALL)
     MONMSG MSGID(CPF0000)
     ENDPGM

Retrieve a Message

This program functions as a message text receiver. It gets message data from the specified file and returns to the calling program.


/*************************************************************************/
/* Program Id...........  SC0010CL - Retreive message text               */
/*                                                                       */
/* Compiler options.....  *OWNER                                         */
/*                                                                       */
/*                                                                       */
/*************************************************************************/
/*************************************************************************/
/*                   MODIFICATION LOG                                    */
/*                                                                       */
/*   DATE   PROGRAMMER      DESCRIPTION                                  */
/*                                                                       */
/*************************************************************************/

PGM        PARM(&MSGID  +
                &MSGFILE   +
                &MSGDTA +
                &MSG    +
               )

DCL        VAR(&MSGID)    TYPE(*CHAR) LEN(7)
DCL        VAR(&MSGFILE)     TYPE(*CHAR) LEN(10)
DCL        VAR(&MSGDTA)   TYPE(*CHAR) LEN(132)
DCL        VAR(&MSG)      TYPE(*CHAR) LEN(80)

             CHGVAR     VAR(&MSG) VALUE(' ')

             RTVMSG     MSGID(&MSGID) MSGF(*LIBL/&MSGFILE) +
                          MSGDTA(&MSGDTA) MSG(&MSG)

             MONMSG     MSGID(CPF0000) EXEC(DO)
             CHGVAR     VAR(%SST(&MSG 1 10)) VALUE('Message ID')
             CHGVAR     VAR(%SST(&MSG 12 7)) VALUE(&MSGID)
             CHGVAR     VAR(%SST(&MSG 20 22)) VALUE('not found in ' +
                          *CAT &MSGFILE *TCAT '.')
             ENDDO

 END:        ENDPGM

Send a Message

This program functions as a command to send messages to a program queue of a CL, or HLL program.

/*************************************************************************/
/* Program Id...........  SC0015CL - Send Program Message                */
/*                                                                       */
/* Compiler options.....  *OWNER                                         */
/*                                                                       */
/*************************************************************************/
/*************************************************************************/
/*                   PROGRAM INTERFACE SECTION                           */
/*                                                                       */
/* CALLED BY PROGRAMS:                                                   */
/* CALLS PROGRAMS:                                                       */
/*                                                                       */
/*************************************************************************/
/*************************************************************************/
/*                   MODIFICATION LOG                                    */
/*                                                                       */
/*   DATE   PROGRAMMER      DESCRIPTION                                  */
/*                                                                       */
/*************************************************************************/
/*=======================================================================*/
/* Program and Declarative Section:                                      */
/*=======================================================================*/

     PGM PARM(&MSGID &MSGF &MSGDTA &RELQ &PGM)

     DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
     DCL VAR(&MSGF) TYPE(*CHAR) LEN(10)
     DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(132)
     DCL VAR(&RELQ) TYPE(*CHAR) LEN(5)
     DCL VAR(&PGM) TYPE(*CHAR) LEN(10)


             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGF) MSGDTA(&MSGDTA) +
                          TOPGMQ(&RELQ &PGM)
             MONMSG     MSGID(CPF0000)

     ENDPGM



Procedure Prototypes

The procedure prototypes for these CLLE programs are simple. The remove message operation only requires the name of the message queue. The retrieve message operation needs the name of the message file that contains the text. This can be important in a multi-language environment, if the library list is not manipulated to accommodate different language text for the application. For example, there might be a default message file in English and separate message files for Spanish, French, or German text.

                                                                                                    
     D RmvMessage      PR                  extpgm('SC0005CL')                                       
     D  msgpgm                       10                                                             
                                                                                                    
     D RtvMessage      PR                  extpgm('SC0010CL')                                       
     D  msgid                         7                                                             
     D  msgfl                        10                                                             
     D  msgdta                      132                                                             
     D  msgtxt                       80                                                             
                                                                                                    
     D SndMessage      PR                  extpgm('SC0015CL')                                       
     D  msgid                         7                                                             
     D  msgfl                        10                                                             
     D  msgdta                      132                                                             
     D  msgrls                        5                                                             
     D  msgpgm                       10