Sometimes, users sign on to multiple display stations. For instance, programmers may have several Client Access/400 sessions going simultaneously. Or a middle manager in the plant may use a dumb terminal capable of displaying two or three sessions at a time. Whatever the case, a problem occurs when a user is signed on to multiple display stations: You can never tell where theuserisphysically.Andifyouneedtosendhimabreakmessage,there'snowayofmaking sure he sees the message immediately.
The solution is to send the break message to all display stations to which the user is signed on. The Send Break Message (SNDBRKMSG) command doesn't make this easy; you have to determine the names of the display stations first and then enter them into the TOMSGQ parameter. A better approach is to use a system API named QEZSNDMG, which is part of Operational Assistant (OA). The Send Break Message to User (SNBRK-USR) command, shown in Figure 1, is a convenient front-end for the API. It accepts a user profile name in its USER parameter and a message text in its MSG parameter, which can have a maximum length of 494 characters. If that maximum length strikes you as odd, that's not our fault; it's imposed by QEZSNDMG.
The CPP for the command, BRK003CL (Figure 2), does little besides checking that the user profile exists and then calling the API with some assumed parameter values. For example, it assumes you want to send an informational, rather than an inquiry, message.
We've found that using SNDBRKUSR is far more convenient than going through OA to access the API directly. BRK003CL uses utility command Forward Program Messages (FWDPGMMSG), which was published in the January 1998 issue of MC (see "How to Forward Messages in CL").
- Bill Williams and Ernie Malaga
Figure 1: The SNDBRKUSR command sends break messages to every display
station a user is signed on to
/*===================================================================*/
/* To compile: */
/* */
/* CRTCMD CMD(XXX/SNDBRKUSR) PGM(XXX/BRK003CL) + */
/* SRCFILE(XXX/QCMDSRC) TEXT('Send Break + */
/* Message to User') */
/* */
/*===================================================================*/
CMD PROMPT('Send Break Message to User')
PARM KWD(USER) TYPE(*NAME) LEN(10) MIN(1) +
EXPR(*YES) PROMPT('User profile')
PARM KWD(MSG) TYPE(*CHAR) LEN(494) MIN(1) +
EXPR(*YES) PROMPT('Message text') /*===================================================================*/
/* To compile: */
/* */
/* CRTCLPGM PGM(XXX/BRK003CL) SRCFILE(XXX/QCLSRC) + */
/* TEXT('CPP for SNDBRKUSR command') */
/* */
/*===================================================================*/
PGM PARM(&USER &MSG)
DCL VAR(&APIERRCDE) TYPE(*CHAR) LEN(8) +
VALUE(X'0000000000000000')
DCL VAR(&FNRQS) TYPE(*CHAR) LEN(4)
DCL VAR(&MSG) TYPE(*CHAR) LEN(494)
DCL VAR(&MSGLEN) TYPE(*CHAR) LEN(4)
DCL VAR(&MSGSENT) TYPE(*CHAR) LEN(4)
DCL VAR(&USER) TYPE(*CHAR) LEN(10)
MONMSG MSGID(CPF0000 MCH0000) EXEC(GOTO CMDLBL(ERROR))
CHGVAR VAR(%BIN(&MSGLEN)) VALUE(494)
/* Verify existence of user profile */
CHKOBJ OBJ(&USER) OBJTYPE(*USRPRF)
/* Send message */
CALL PGM(QEZSNDMG) PARM('*INFO' '*BREAK' &MSG +
&MSGLEN &USER X'00000001' &MSGSENT &FNRQS +
&APIERRCDE'N''''*USR')
RETURN
ERROR:
FWDPGMMSG
MONMSG MSGID(CPF0000)
ENDPGM
Figure 2: CL program BRK003CL checks that the user
profile exists and calls the API with parameter values
profile exists and calls the API with parameter values
LATEST COMMENTS
MC Press Online