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
LATEST COMMENTS
MC Press Online