Showing posts with label Message handling. Show all posts
Showing posts with label Message handling. Show all posts

1/22/09 Send messages to all users attached to a group profile

Have you ever wanted to send a message to all users attached to a group profile? Here is a command and a CL program that you can use to do exactly that.


Note: Before you can compile the CL program SNDPGMMSG, you need to create a 132 character physical file named SPOOL132. That is done using this command: CRTPF /SPOOL132 RCDLEN(132)

SNDGRPMSG command

SNDGRPMSG: CMD PROMPT('Send Group Message')
PARM KWD(MSG) TYPE(*CHAR) LEN(512) EXPR(*YES) +
PROMPT('Message text, or')
PARM KWD(MSGID) TYPE(*CHAR) LEN(7) +
PROMPT('Message identifier')
PARM KWD(MSGF) TYPE(QUAL) PROMPT('Message file')
PARM KWD(MSGDTA) TYPE(*CHAR) LEN(512) EXPR(*YES) +
PROMPT('Message data field values')
PARM KWD(TOGRP) TYPE(*CHAR) LEN(10) PROMPT('To +
group profile')
QUAL: QUAL TYPE(*NAME) LEN(10)
QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) +
SPCVAL((*LIBL) (*CURLIB)) PROMPT('Library')



SNDPGMMSG CL program


PGM PARM(&MSG &MSGID &MSGFLB &MSGDTA &TOGRP)

DCL VAR(&MSG) TYPE(*CHAR) LEN(512)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&MSGFLB) TYPE(*CHAR) LEN(20)
DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(512)
DCL VAR(&TOGRP) TYPE(*CHAR) LEN(10)

DCL VAR(&MSGF) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&POS) TYPE(*DEC) LEN(3 0)

DCLF FILE(SPOOL132)

CHGVAR VAR(&MSGF) VALUE(%SST(&MSGFLB 1 10))
CHGVAR VAR(&MSGFLIB) VALUE(%SST(&MSGFLB 11 10))

DSPUSRPRF USRPRF(&TOGRP) TYPE(*GRPMBR) OUTPUT(*PRINT)
MONMSG MSGID(CPF0000) EXEC(DO)
SNDUSRMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('No +
messages sent to group profile' *BCAT +
&TOGRP) MSGTYPE(*INFO) TOUSR(*REQUESTER)
RETURN
ENDDO

CRTDUPOBJ OBJ(SPOOL132) FROMLIB(*LIBL) OBJTYPE(*FILE) +
TOLIB(QTEMP)
CPYSPLF FILE(QPUSRPRF) TOFILE(QTEMP/SPOOL132) +
SPLNBR(*LAST)
DLTSPLF FILE(QPUSRPRF) SPLNBR(*LAST)
CPYF FROMFILE(QTEMP/SPOOL132) +
TOFILE(QTEMP/SPOOL132A) MBROPT(*REPLACE) +
CRTFILE(*YES) INCCHAR(*RCD 1 *EQ ' ')
DLTF FILE(QTEMP/SPOOL132)
CPYF FROMFILE(QTEMP/SPOOL132A) +
TOFILE(QTEMP/SPOOL132B) MBROPT(*REPLACE) +
CRTFILE(*YES) INCCHAR(*RCD 49 *EQ ' ')
DLTF FILE(QTEMP/SPOOL132A)
OVRDBF FILE(SPOOL132) TOFILE(QTEMP/SPOOL132B)
READLOOP:
RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDJOB))
CHGVAR VAR(&POS) VALUE(2)
MSGLOOP:
IF COND(&POS *LE 106) THEN(DO)
IF COND(%SST(&SPOOL132 &POS 1) *NE ' ') THEN(DO)
IF COND(&MSG *NE ' ') THEN(DO)
SNDUSRMSG MSG(&MSG) MSGTYPE(*INFO) +
TOUSR(%SST(&SPOOL132 &POS 10))
MONMSG MSGID(CPF0000)
ENDDO
ELSE CMD(IF COND(&MSGID *NE ' ') THEN(DO))
SNDUSRMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
MSGDTA(&MSGDTA) MSGTYPE(*INFO) +
TOUSR(%SST(&SPOOL132 &POS 10))
MONMSG MSGID(CPF0000)
ENDDO
ENDDO
ELSE CMD(DO)
GOTO CMDLBL(READLOOP)
ENDDO
CHGVAR VAR(&POS) VALUE(&POS + 26)
GOTO CMDLBL(MSGLOOP)
ENDDO
GOTO CMDLBL(READLOOP)
ENDJOB:
DLTOVR FILE(SPOOL132)
DLTF FILE(QTEMP/SPOOL132B)
ENDPGM


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2009, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

7/28/08 Using the System Request menu.

The System Request menu is basically a shortcut screen that allows you to access some commonly used commands without leaving the your current screen.

Accessing the System Request menu can be done in a variety of ways depending on your environment and emulation program. Common ways are: pressing the SHIFT and SysRq keys together, or if using PC emulation, right clicking your mouse and selecting ‘SysRq’ from the pop-up window.

Transfer to secondary display session.
Choosing Option 1 will give you a second sign on for the same session, but there is a caveat: once you start another session the first one is paused and it will not resume until you go back to it. This is important to remember if you are running an interactive query, compile, etc.

Cancel a display session
To cancel out the display session that your are viewing, use Option 2.

Display user messages
User messages for your log-on profile can be seen by selecting Option 4. From there you can also manage the messages (i.e. remove all or selected messages).

View System Operator messages (QSYSOPR) To display the system operator messages use Option 6. It takes you right to the QSYSOPR messages screen. This is particularly useful if your display session is running a program and receives an error message that needs to be answered.

View current job information
See your current job information by selecting option 7. This is particularly useful if you need to see job names and job numbers. If you have second display session running, you can see that job information too.




Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

07/08/08 Automatically monitor message queues for Save While Active checkpoints to execute other actions

The following describes two CL programs that can automate your save process so that prior to it starting a program is submitted to batch that creates a job to monitor the message queue for the checkpoint message. When the checkpoint message is received other processes can then be initiated.

Create a save program (i.e.:pgmlib/savepgm)


PGM
CLRMSGQ MSGQ(QUSRSYS/SWAMSGQ)
MONMSG MSGID(CPF2403) EXEC(CRTMSGQ MSGQ(QUSRSYS/SWAMSGQ))

/* INSERT THINGS TO DO PRIOR TO THE SAVE SO A CHECKPOINT CAN BE REACHED */
/* Example ENDSBS SBS(QINTER) OPTION(*IMMED) */

SBMJOB CMD(CALL PGM(yourlibrary/SWAMONMSGQ)) JOB(#SWAMONMSG)
SAVLIB LIB(libtosave) DEV(yourdevice) +

SAVACT(*SYNCLIB) SAVACTMSGQ(QUSRSYS/SWAMSGQ)
ENDPGM


Create a program to monitor for checkpoint (i.e.: pgmlib/SWAMONMSGQ) that will monitor the message queue for the save while active checkpoint message. When the message is processed, other actions can then be executed; i.e.: letting users back into an application or restarting another process. If multiple backups are running at one time, a message queue for each save should be used.

PGM

DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
LOOP: RCVMSG MSGQ(QUSRSYS/SWAMSGQ) MSGID(&MSGID)
IF COND(&MSGID *NE 'CPI3712') THEN(GOTO CMDLBL(LOOP))

/*INSERT THINGS TO DO AFTER THE CHECKPOINT MESSAGE IS REACHED HERE */
/* Example STRSBS SBSD(QINTER) */


ENDPGM

Submit or schedule the save program you created (pgmlib/savepgm)


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

6/9/08 - How to send a message to multiple users

Type the command CALL QEZSNDMG.

Fill in the parameters as follows:

-Message needs reply (Y or N)
-Interrupt user (Y or N) – will send a break message when Y is specified
-Message text (up to 512 characters)
-Send to – this is a list and can also use special values of *ALL and *ALLACT
Press F10 to send the message

This will send out the message to all of the workstations that the users are signed on to at the time.



Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.