208 lines
11 KiB
HTML
208 lines
11 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="Examples: Send messages" />
|
||
|
<meta name="abstract" content="This topic contains six message examples: send a completion message, send a completion message with variable text, send an inquiry message and receive its reply, send an inquiry message and receive a reply with Send User Message (SNDUSRMSG), send an escape message, and send an informational message to multiple users." />
|
||
|
<meta name="description" content="This topic contains six message examples: send a completion message, send a completion message with variable text, send an inquiry message and receive its reply, send an inquiry message and receive a reply with Send User Message (SNDUSRMSG), send an escape message, and send an informational message to multiple users." />
|
||
|
<meta name="DC.subject" content="message, example, sending, changing, CHGVAR (Change Variable) command, Change Variable (CHGVAR) command, variable, *BCAT value" />
|
||
|
<meta name="keywords" content="message, example, sending, changing, CHGVAR (Change Variable) command, Change Variable (CHGVAR) command, variable, *BCAT value" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="msgcl.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="sndrcpy.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="xsmsg" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Examples: Send messages</title>
|
||
|
</head>
|
||
|
<body id="xsmsg"><a name="xsmsg"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Examples: Send messages</h1>
|
||
|
<div><p>This topic contains six message examples: send a completion message,
|
||
|
send a completion message with variable text, send an inquiry message and
|
||
|
receive its reply, send an inquiry message and receive a reply with <span class="cmdname">Send
|
||
|
User Message (SNDUSRMSG)</span>, send an escape message, and send an informational
|
||
|
message to multiple users. </p>
|
||
|
<div class="example"><h4 class="sectiontitle">Example 1: send a completion message</h4><p>The following
|
||
|
CL procedure allows the display station user to submit a job by calling a
|
||
|
CL program (which contains this procedure) instead of entering the <span class="cmdname">Submit
|
||
|
Job (SBMJOB)</span> command. The procedure sends a completion message
|
||
|
when the job has been submitted. </p>
|
||
|
<pre>PGM
|
||
|
SBMJOB JOB(WKLYPAY) JOBD(USERA) RQSDTA('CALL WKLY PARM(PAY1)')
|
||
|
SNDPGMMSG MSG('WKLYPAY job submitted') MSGTYPE(*COMP)
|
||
|
ENDPGM</pre>
|
||
|
</div>
|
||
|
<div class="example"><h4 class="sectiontitle">Example 2: send a completion message with variable text</h4><p>The
|
||
|
following CL procedure sends a message based on a parameter received from
|
||
|
a program that is called from within this procedure. The message is sent
|
||
|
by the CL procedure as a completion message. (The RCDCNT field is defined
|
||
|
as characters in PGMA.) </p>
|
||
|
<pre>PGM
|
||
|
DCL &RCDCNT TYPE(*CHAR) LEN(3)
|
||
|
CALL PGMA PARM(&RCDCNT)
|
||
|
SNDPGMMSG MSG('PGMA completed' *BCAT &RCDCNT *BCAT +
|
||
|
'records processed') MSGTYPE(*COMP)
|
||
|
ENDPGM</pre>
|
||
|
</div>
|
||
|
<div class="example"><h4 class="sectiontitle">Example 3: send an inquiry message and receive its reply</h4><p>The
|
||
|
following procedure sends a message requesting the system operator to load
|
||
|
a special form. The <span class="cmdname">Receive Message (RCVMSG)</span> command waits
|
||
|
for the reply. The system operator must enter at least 1 character as a reply
|
||
|
to the inquiry message, but the procedure does not contain the remainder of
|
||
|
the code that would use the reply value. </p>
|
||
|
<pre>PGM
|
||
|
DCL SNDRCOPY TYPE(*CHAR) LEN(4)
|
||
|
SNDPGMMSG MSG('Load special form') TOUSR(*SYSOPR) +
|
||
|
KEYVAR(SNDRCOPY) MSGTYPE(*INQ)
|
||
|
RCVMSG MSGTYPE(*RPY) MSGKEY(SNDRCOPY) WAIT(120)
|
||
|
.
|
||
|
.
|
||
|
.
|
||
|
ENDPGM</pre>
|
||
|
<div class="note"><span class="notetitle">Note:</span> <ol><li>The WAIT parameter must be specified on the <span class="cmdname">Receive Message (RCVMSG)</span> command
|
||
|
so that the procedure waits for the reply. If the WAIT parameter is not specified,
|
||
|
the procedure continues with the instruction following the <span class="cmdname">Receive
|
||
|
Message (RCVMSG)</span> command, without receiving the reply.</li>
|
||
|
<li><img src="./delta.gif" alt="Start of change" />The variable SNDRCOPY in the <span class="cmdname">Send Program Message
|
||
|
(SNDPGMMSG)</span> command returns to the procedure the message key of
|
||
|
the sender copy message associated with the inquiry message. This is needed
|
||
|
to get the reply. When this key is specified on a <span class="cmdname">Receive Message
|
||
|
(RCVMSG)</span> command with a message type of *RPY, the reply that was
|
||
|
entered for the associated inquiry message is returned. The SNDRCOPY message
|
||
|
key is specified in the MSGKEY parameter of the <span class="cmdname">Receive Message (RCVMSG)</span> command.<img src="./deltaend.gif" alt="End of change" /></li>
|
||
|
</ol>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="example"><h4 class="sectiontitle">Example 4: send an inquiry message and receive
|
||
|
a reply with SNDUSRMSG</h4><p>The following procedure sends a message to
|
||
|
the system operator when it is run in batch mode or to the display station
|
||
|
operator when it is run from a display station. The procedure accepts either
|
||
|
an uppercase or lowercase Y or N. (The lowercase values are translated to
|
||
|
uppercase by the translation table (the default of the TRNTBL parameter of
|
||
|
the <span class="cmdname">Send User Message (SNDUSRMSG)</span> command) to make program
|
||
|
logic easier.) If the value entered is not one of these four, the operator
|
||
|
is issued a message from <span class="cmdname">Send User Message (SNDUSRMSG)</span> indicating
|
||
|
the reply is not valid. </p>
|
||
|
<pre>PGM
|
||
|
DCL &REPLY *CHAR LEN(1)
|
||
|
.
|
||
|
.
|
||
|
SNDUSRMSG MSG('Update YTD Information Y or N') VALUES(Y N) +
|
||
|
MSGRPY(&REPLY)
|
||
|
IF (&REPLY *EQ Y)
|
||
|
DO
|
||
|
.
|
||
|
.
|
||
|
.
|
||
|
ENDDO
|
||
|
ELSE
|
||
|
DO
|
||
|
.
|
||
|
.
|
||
|
ENDDO
|
||
|
.
|
||
|
.
|
||
|
.
|
||
|
ENDPGM</pre>
|
||
|
</div>
|
||
|
<div class="example"><h4 class="sectiontitle">Example 5: send an escape message</h4><p>The following
|
||
|
procedure uses the message CPF9898 to send an escape message. The text of
|
||
|
the message is <samp class="codeph">'Procedure detected failure'</samp>. Immediate messages
|
||
|
are not allowed as escape messages so message CPF9898 can be used with the
|
||
|
message as message data. </p>
|
||
|
<pre> PGM
|
||
|
.
|
||
|
.
|
||
|
.
|
||
|
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
|
||
|
MSGDTA('Procedure detected failure')
|
||
|
.
|
||
|
.
|
||
|
ENDPGM</pre>
|
||
|
</div>
|
||
|
<div class="example"><h4 class="sectiontitle">Example 6: send an informational message to multiple users</h4><p>The
|
||
|
following procedure allows the system operator to send a message to several
|
||
|
display stations. When the system operator calls the program containing this
|
||
|
procedure, it displays a prompt which the system operator can enter the type
|
||
|
of message to be sent and the text for the message. The procedure concatenates
|
||
|
the date, time, and text of the message.</p>
|
||
|
<pre> PGM
|
||
|
DCLF WSMSGD
|
||
|
DCL &MSG TYPE(*CHAR) LEN(150)
|
||
|
DCL &HOUR TYPE(*CHAR) LEN(2)
|
||
|
DCL &MINUTE TYPE(*CHAR) LEN(2)
|
||
|
DCL &MONTH TYPE(*CHAR) LEN(2)
|
||
|
DCL &DAY TYPE(*CHAR) LEN(2)
|
||
|
DCL &WORKHR TYPE(*DEC) LEN(2 0)
|
||
|
SNDRCVF RCDFMT(PROMPT)
|
||
|
IF &IN91 RETURN /* Request was ended */
|
||
|
RTVSYSVAL QMONTH RTNVAR(&MONTH)
|
||
|
RTVSYSVAL QDAY RTNVAR(&DAY)
|
||
|
RTVSYSVAL QHOUR RTNVAR(&HOUR)
|
||
|
IF (&HOUR *GT '12') DO /* Change from military time */
|
||
|
CHGVAR &WORKHR &HOUR
|
||
|
CHGVAR &WORKHR (&WORKHR - 12)
|
||
|
CHGVAR &HOUR &WORKHR
|
||
|
ENDDO
|
||
|
RTVSYSVAL QMINUTE RTNVAR(&MINUTE)
|
||
|
CHGVAR &MSG ('From Sys Opr ' *CAT &MONTH *CAT '/' +
|
||
|
*CAT &DAY +
|
||
|
*BCAT &HOUR *CAT ':' *CAT &MINUTE +
|
||
|
*BCAT &TEXT)
|
||
|
IF (&TYPE *EQ 'B') GOTO BREAK
|
||
|
NORMAL: SNDPGMMSG MSG(&MSG) TOMSGQ(WS1 WS2 WS3)
|
||
|
GOTO ENDMSG
|
||
|
BREAK: SNDBRKMSG MSG(&MSG) TOMSGQ(WS1 WS2 WS3)
|
||
|
ENDMSG: SNDPGMMSG MSG('Message sent to display stations') +
|
||
|
MSGTYPE(*COMP)
|
||
|
ENDPGM</pre>
|
||
|
<p>The DDS for the display file, WSMSGD, used in this program
|
||
|
follows:</p>
|
||
|
<pre>|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
|
||
|
A DSPSIZ(24 80)
|
||
|
A R PROMPT TEXT('Prompt')
|
||
|
A BLINK
|
||
|
A CA03(91 'Return')
|
||
|
A 1 2'Send Messages To Workstations'
|
||
|
DSPATR(HI)
|
||
|
A 3 2'TYPE'
|
||
|
A TYPE 1 1 +2VALUES('N' 'B')
|
||
|
A CHECK(ME)
|
||
|
DSPATR(MDT)
|
||
|
A +3'(N = No breaks B = Break)'
|
||
|
A 5 2'Text'
|
||
|
A TEXT 100 1 +2LOWER
|
||
|
A
|
||
|
A</pre>
|
||
|
<p>If the system operator enters the following on the prompt:</p>
|
||
|
<pre>B
|
||
|
|
||
|
Please sign off by 3:30 today</pre>
|
||
|
<p>the following break message is sent:</p>
|
||
|
<pre>From Sys Opr 10/30 02:00 Please sign off by 3:30 today</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="msgcl.htm" title="Various message types are described in this topic. Use the Send Program Message (SNDPGMMSG) command or the Send User Message (SNDUSRMSG) command to send a message from a CL procedure or program.">Send messages from a CL program</a></div>
|
||
|
</div>
|
||
|
<div class="reltasks"><strong>Related tasks</strong><br />
|
||
|
<div><a href="sndrcpy.htm" title="This topic describes how to obtain a reply to an inquiry message by using a sender copy message.">Using a sender copy message to obtain a reply</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|