Ü SNDUSRMSG
·
This command is used to send impromptu message
(messages i.e. not predefined) or predefined messages to the user/system
operator.
·
It can be used in CL program but cannot be
used on command line directly.
·
The format of this command for impromptu message is:
SNDUSRMSG MSG(‘message text’)
TOUSR(user name/*SYSOPR/*REQUESTER)
TOMSGQ(user queue name/*/*SYSOPR/*EXT)
MSGTYPE(*INFO/*INQ)
VALUES(list of allowable replies)
DFT(default reply value)
MSGRPY(message reply)
·
The format of this command for predefined message is:
SNDUSRMSG MSGID(message id)
MSGF(message file name)
TOUSR(user name/*SYSOPR/*REQUESTER)
TOMSGQ(user queue name/*/*SYSOPR/*EXT)
MSGTYPE(*INFO/*INQ)
VALUES(list of allowable replies)
DFT(default reply value)
MSGRPY(message reply)
·
The format of this command for predefined message
with message data (MSGDTA) option is:
SNDUSRMSG MSGID(CPF9898)
MSGF(QCPFMSG)
MSGDTA(&messge_data)
TOUSR(user name/*SYSOPR/*REQUESTER)
TOMSGQ(user queue name/*/*SYSOPR/*EXT)
MSGTYPE(*INFO/*INQ)
VALUES(list of allowable replies)
DFT(default reply value)
MSGRPY(message reply)
·
TOUSR and TOMSGQ parameter is mutually exclusive.
Only one should be mentioned at a time.
·
If TOUSR=*SYSOPR, then the message is sent to the
system operator.
·
If TOUSR=*REQUESTER, then the message is sent to the
user who is running the interactive job or to QSYSOPR.
·
If TOMSGQ=*, then the message is sent to external
message queue for interactive job and is sent to the system operator for batch
job.
·
If TOMSGQ=*EXT, then the message is sent to external
message queue.
·
In case of predefined messages if we are using
QCPFMSG/CPF9898, then we can give the message in the message data(MSGDTA)
CL-variable.
Example: CL
program to read a database file and display its field’s value on the console
& prompt every time before reading a new record from the file
Ø Physical file used in the
program = CUST
Columns . . . : 1 71 Browse AMIT/QRPGLESRC
SEU==> CUST
FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
*************** Beginning of data *************************************
0001.00
0002.00 A R CUSTR
0003.00 A CSNBR 6A
0004.00 A CSNAME 10A
0005.00 A CS#OPN 5P 0
0006.00 A CS$OPN 10P 2
****************** End of data ****************************************
Ø CL Program
Columns . . . : 1 71 Browse AMIT/QRPGLESRC
SEU==> READFILE
FMT ** ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
*************** Beginning of data *************************************
0001.00 PGM
0001.01 DCL VAR(&VAR1) TYPE(*CHAR) LEN(20)
0001.03 DCL VAR(&REPLY) TYPE(*CHAR) LEN(1) +
0001.04 VALUE('N')
0002.00 DCLF FILE(AMIT/CUST)
0003.00 READ:
0004.00 RCVF
0005.00 MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END1))
0005.02 CHGVAR VAR(&VAR1) VALUE(&CSNBR||' '|| +
0005.03 &CSNAME||' '||+
0005.05 ' ')
0005.06 SNDUSRMSG MSG('DO U WANT TO CONTINUE FILE READING') +
0005.07 MSGRPY(&REPLY) VALUES('Y' 'N')
0005.10
0005.11 IF (&REPLY='Y') DO
0005.12 SNDUSRMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&VAR1) +
0005.13 MSGTYPE(*INFO)
0006.00 GOTO CMDLBL(READ)
0006.01 ENDDO
0006.02 ELSE DO
0006.03 GOTO CMDLBL(END2)
0006.04 ENDDO
0007.00 END1:
0008.00 SNDUSRMSG MSG('THE END OF FILE IS REACHED')
0008.01 END2:
0009.00 ENDPGM
****************** End of data ****************************************
OUTPUT
Below is the output that we
get on the console.
DO U WANT TO CONTINUE FILE READING
Y
100001 AMI.
DO U WANT TO CONTINUE FILE READING
Y
100002 upi.
DO U WANT TO CONTINUE FILE READING
Y
100003 KUM.
THE END OF FILE IS REACHED