TechTalk: Send Message to Group

CL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

A few years ago, MC published the Send Group Message (SNDGRPMSG) command, which sends a message to every active user profile belonging to a group profile or a list of group profiles. It requires you to use the Convert Work Active Job (CVTWRKACT) command from the QUSRTOOL library. I created a similar command, but it is simpler, it uses only native OS/400 commands, and it sends the message to all group members whether they are active or not. I call my command Send Message to Group (SNDMSGGRP).

The command displays all user profiles with the Display User Profile (DSPUSRPRF) command and outputs to an outfile. It then uses the Open Query File (OPNQRYF) command to select from the outfile the user profiles that belong to the group specified to receive the message. The command source can be found in 8, and the CPP for the command, MSG016CL, is in 9. Before you run the SNDMSGGRP command, you might want to determine who will receive the message based on the group profile you specify. One way to do this is to run the following command:

The command displays all user profiles with the Display User Profile (DSPUSRPRF) command and outputs to an outfile. It then uses the Open Query File (OPNQRYF) command to select from the outfile the user profiles that belong to the group specified to receive the message. The command source can be found in Figure 8, and the CPP for the command, MSG016CL, is in Figure 9. Before you run the SNDMSGGRP command, you might want to determine who will receive the message based on the group profile you specify. One way to do this is to run the following command:

 DSPAUTUSR SEQ(*GRPPRF) 

When you run the Display Authorized Users (DSPAUTUSR) command with the SEQ(*GRPPRF) parameter, you will be presented with a list of user profiles sorted by group profile. This display makes it easy to tell which user profiles belong to a specific group profile.

? Sorin Caraiani


TechTalk: Send Message to Group

Figure 8: The SNDMSGGRP Command

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/SNDGRPMSG) PGM(XXX/MSG016CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*==================================================================*/ CMD PROMPT('Send Message to Group') PARM KWD(MSG) TYPE(*CHAR) LEN(512) MIN(1) + PROMPT('Message') PARM KWD(GROUP) TYPE(*NAME) MIN(1) PROMPT('Group + profile') 
TechTalk: Send Message to Group

Figure 9: CPP CL Program MSG016CL

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/MSG016CL) SRCFILE(XXX/QCLSRC) */ /* */ /*==================================================================*/ PGM PARM(&MSG &GROUP) DCL VAR(&GROUP) TYPE(*CHAR) LEN(10) DCL VAR(&MSG) TYPE(*CHAR) LEN(512) DCL VAR(&CNT) TYPE(*DEC) LEN(3) DCL VAR(&ACNT) TYPE(*CHAR) LEN(3) DCL VAR(&QRYSLT) TYPE(*CHAR) LEN(50) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) DCLF FILE(QADSPUPB) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) DSPUSRPRF USRPRF(*ALL) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/QADSPUPB) OVRDBF FILE(QADSPUPB) TOFILE(QTEMP/QADSPUPB) + MBR(*FIRST) SHARE(*YES) CHGVAR VAR(&QRYSLT) VALUE('UPGRPF *EQ ''' + *TCAT &GROUP *TCAT '''') OPNQRYF FILE((QADSPUPB)) QRYSLT(&QRYSLT) LOOP: RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(DONE)) SNDMSG MSG(&MSG) TOUSR(&UPUPRF) CHGVAR VAR(&CNT) VALUE(&CNT + 1) GOTO CMDLBL(LOOP) DONE: CHGVAR VAR(&ACNT) VALUE(&CNT) SNDPGMMSG MSG('Message sent to' *BCAT &ACNT *BCAT + 'users.') CLOF OPNID(QADSPUPB) DLTF FILE(QTEMP/QADSPUPB) GOTO CMDLBL(ENDPGM) ERROR: RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) SNDPGMMSG MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDPGM: ENDPGM 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: