186 lines
12 KiB
HTML
186 lines
12 KiB
HTML
|
|
||
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head><META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<title>Monitor Message (MONMSG)</title>
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body bgcolor="white">
|
||
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<a name="MONMSG.Top_Of_Page"></a>
|
||
|
<h2>Monitor Message (MONMSG)</h2>
|
||
|
<table width="100%">
|
||
|
<tr>
|
||
|
<td valign="top" align="left"><b>Where allowed to run: </b>
|
||
|
<ul><li>Batch program (*BPGM)</li>
|
||
|
<li>Interactive program (*IPGM)</li>
|
||
|
</ul><b>Threadsafe: </b>Yes
|
||
|
</td>
|
||
|
<td valign="top" align="right">
|
||
|
<a href="#MONMSG.PARAMETERS.TABLE">Parameters</a><br>
|
||
|
<a href="#MONMSG.COMMAND.EXAMPLES">Examples</a><br>
|
||
|
<a href="#MONMSG.ERROR.MESSAGES">Error messages</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<div> <a name="MONMSG"></a>
|
||
|
<p>The Monitor Message (MONMSG) command is used to monitor escape, notify, and status messages sent to the program message queue of the program in which the command is used. Completion and diagnostic messages cannot be monitored.
|
||
|
</p>
|
||
|
<p>When the MONMSG command is compiled in a control language (CL) program, it establishes a monitor for the arrival of the specified messages. The command monitors the messages for the condition specified by the comparison data given in the command. If a message meeting the conditions arrives on the message queue, the CL command specified on the MONMSG command is processed.
|
||
|
</p>
|
||
|
<p>Up to 1000 MONMSG commands can be specified in a program to monitor the arrival of messages for specific conditions or for a group of conditions. Specific message identifiers or generic message identifiers can be monitored.
|
||
|
</p>
|
||
|
<p>The MONMSG command can be coded following most commands in a CL procedure. A MONMSG command that is not placed at the beginning of the program applies only to the immediately preceding command; this is called a command-level MONMSG command. The command-level MONMSG command monitors only messages sent by the previous command. If the message sent by that command meets the conditions specified in the MONMSG command, the action specified in the same MONMSG command is taken. As many as 100 MONMSG commands, coded immediately after a command, can monitor the messages sent by that command.
|
||
|
</p>
|
||
|
<p>When the action specified in the MONMSG command has been performed, and that action does not end with a GOTO or RETURN command, control returns to the command in the program that follows the command that sent the message. If the action ends with a GOTO command, control branches to the command in the program specified in the GOTO command. If the action ends with a RETURN command, control returns to the program that called the program that contains the MONMSG command.
|
||
|
</p>
|
||
|
<p>If one or more MONMSG commands are placed at the beginning of the program, immediately following the declare commands or the PGM command if there are no declare commands, they monitor messages sent by all of the commands in the program (maximum of 100). This is called a program-level MONMSG command. If any message sent by any command in the program meets the conditions specified in any one of the program-level MONMSG commands, the corresponding action specified in the same command is taken.
|
||
|
</p>
|
||
|
<p>The action taken by a command-level MONMSG command overrides a program-level MONMSG command.
|
||
|
</p>
|
||
|
<p>If a command is coded for the EXEC parameter on a MONMSG command that is placed at the beginning of a program, <i>only</i> the GOTO command can be used, and it must specify the label for the command to which control is to be passed if a monitored message occurs. The label specified on a program-level MONMSG command cannot be a label associated with a subroutine. If a GOTO command is performed for a program-level MONMSG, the subroutine stack will be reset by the next Call Subroutine (CALLSUBR) command.
|
||
|
</p>
|
||
|
<p>If a command is not coded for the EXEC parameter, monitored messages are ignored.
|
||
|
</p>
|
||
|
<p><b>Restrictions:</b>
|
||
|
</p>
|
||
|
<ul>
|
||
|
<li>This command is valid only in CL procedures.
|
||
|
</li>
|
||
|
<li>It can be coded after the last declare command (if declare commands are used), following the PGM command that begins the program, or it can be coded following any command allowed in CL procedures, except for the following: DO, DOWHILE, DOUNTIL, DOFOR, ELSE, ENDDO, SELECT, WHEN, OTHERWISE, ENDSELECT, ENDPGM, CALLSUBR, SUBR, RTNSUBR, ENDSUBR, GOTO, IF, or RETURN. Note that if another program sends a message that is monitored by this command, a return cannot be made to that program.
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#MONMSG.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<hr size="2" width="100%">
|
||
|
|
||
|
<div>
|
||
|
<h3><a name="MONMSG.PARAMETERS.TABLE">Parameters</a></h3>
|
||
|
<table border="1" cellpadding="4" cellspacing="0">
|
||
|
<!-- col1="10" col2="15" col3="30" col4="10" -->
|
||
|
<tr>
|
||
|
<th bgcolor="aqua" valign="bottom" align="left">Keyword</th>
|
||
|
<th bgcolor="aqua" valign="bottom" align="left">Description</th>
|
||
|
<th bgcolor="aqua" valign="bottom" align="left">Choices</th>
|
||
|
<th bgcolor="aqua" valign="bottom" align="left">Notes</th>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td valign="top"><a href="#MONMSG.MSGID"><b>MSGID</b></a></td>
|
||
|
<td valign="top">Message identifier</td>
|
||
|
<td valign="top">Values (up to 50 repetitions): <i>Name</i></td>
|
||
|
<td valign="top">Required, Positional 1</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td valign="top"><a href="#MONMSG.CMPDTA"><b>CMPDTA</b></a></td>
|
||
|
<td valign="top">Comparison data</td>
|
||
|
<td valign="top"><i>Character value</i>, <b><u>*NONE</u></b></td>
|
||
|
<td valign="top">Optional, Positional 2</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td valign="top"><a href="#MONMSG.EXEC"><b>EXEC</b></a></td>
|
||
|
<td valign="top">Command to execute</td>
|
||
|
<td valign="top"><i>Command string</i></td>
|
||
|
<td valign="top">Optional, Positional 3</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#MONMSG.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div> <a name="MONMSG.MSGID"></a>
|
||
|
<h3>Message identifier (MSGID)</h3>
|
||
|
<p>Specifies the message identifiers of one or more escape, notify, or status messages that are to be monitored by this command. As many as 50 specific or generic message identifiers can be specified on one command.
|
||
|
</p>
|
||
|
<p>
|
||
|
<b>Note: </b>Many CL commands issue one escape message for many different error conditions. Details about the error or failure are given in diagnostic messages that precede the escape message. Although diagnostic messages cannot be monitored, they can be received from the job's external message queue after the escape message has activated the user's message monitor.
|
||
|
</p>
|
||
|
<p>The first 3 characters of a message identifier must be a code consisting of an alphabetic character followed by two alphanumeric (alphabetic or decimal) characters; the last 4 characters may consist of the decimal numbers 0 through 9 and the characters A through F.
|
||
|
</p>
|
||
|
<p>
|
||
|
<b>Note: </b>Message identifiers using the MCH code (MCHnnnn) use only the numbers 0 through 9 in the last four characters.
|
||
|
</p>
|
||
|
<p>If zeros are specified in either two or all four of the rightmost positions, such as USRmm00, a <i>generic message identifier</i> is specified. For example, if CPF0000 is specified, all messages with the prefix 'CPF' are monitored. Generic message identifiers can be used for both command-level MONMSG and procedure-level MONMSG statements.
|
||
|
</p>
|
||
|
<p>Specify the message identifiers of 1 to 50 messages that are monitored when they arrive at this program's message queue. The message identifiers and message text of the escape, notify, and status messages which may be sent by a command can be found in the command's documentation in the Information Center as well as the command's online help. CL variables cannot be used to specify message identifiers.
|
||
|
</p>
|
||
|
<p>This is a required parameter.
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#MONMSG.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<div> <a name="MONMSG.CMPDTA"></a>
|
||
|
<h3>Comparison data (CMPDTA)</h3>
|
||
|
<p>Specifies the comparison data that is used to determine whether the monitored message (having one of the specified message identifiers) received on the program's message queue is acted on by this command. The message data specified in the MSGDTA parameter of the Send Program Message (SNDPGMMSG) command is compared with this comparison data. If the first part (up through the first 28 characters, or less) of the message's substitution values matches the comparison data specified, the action specified in the EXEC parameter of this command is taken. The action is also taken if no comparison data is specified.
|
||
|
</p>
|
||
|
<dl>
|
||
|
<dt><b><u>*NONE</u></b></dt>
|
||
|
<dd>No comparison data is specified. If the message in the program's message queue is from a command that this command is monitoring, and if it has the specified identifier, the action specified for the <b>Command to execute (EXEC)</b> parameter is taken.
|
||
|
</dd>
|
||
|
<dt><b><i>comparison-data</i></b></dt>
|
||
|
<dd>Specify a character string of no more than 28 characters, enclosed in apostrophes if necessary, that is compared with the same number of characters in the message data of the received message, starting with the first character in the message data. If the comparison data matches the first part of the received message data, this command performs the function specified in the EXEC parameter. A CL variable cannot be specified for the comparison data.
|
||
|
<p>The comparison data can be displayed by the Display Program Variable (DSPPGMVAR) command.
|
||
|
</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#MONMSG.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<div> <a name="MONMSG.EXEC"></a>
|
||
|
<h3>Command to execute (EXEC)</h3>
|
||
|
<p>Specifies the CL command to be processed when a monitored message sent to the program's message queue meets the conditions specified in this command. If no command is specified and a monitored message arrives on the queue, the message is ignored, and control passes to the next command in the program.
|
||
|
</p>
|
||
|
<p>If the MONMSG command is placed at the beginning of the program, the EXEC parameter must specify the GOTO command and the label identifying the command that receives control.
|
||
|
</p>
|
||
|
<p>Specify the CL command, including its parameters to be used, that is run when a message meeting the conditions specified in this command is received. The command specified is not run if the received message does not meet the specified conditions. A CL variable cannot be specified in place of the CL command.
|
||
|
</p>
|
||
|
<p>
|
||
|
<b>Note: </b>If a DO, DOWHILE, DOUNTIL, DOFOR, or SELECT command is specified on EXEC, the entire group associated with the command is processed if the condition is met.
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#MONMSG.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<hr size="2" width="100%">
|
||
|
<div><h3><a name="MONMSG.COMMAND.EXAMPLES">Examples</a> </h3>
|
||
|
<p><b>Example 1: Monitoring Messages Sent by Any Command</b>
|
||
|
</p>
|
||
|
<p>
|
||
|
<pre>
|
||
|
PGM
|
||
|
MONMSG MSGID(CPF0001 CPF1999) EXEC(GOTO EXIT2)
|
||
|
</pre>
|
||
|
</p>
|
||
|
<p>This example shows a MONMSG command at the beginning of a CL procedure that monitors for messages CPF0001 and CPF1999; these messages might be sent by any command processed later in the procedure. When either message is received from any of the commands running in the procedure, control branches to the command identified by the label EXIT2.
|
||
|
</p>
|
||
|
<p>CPF0001 states that an error was found in the command that is identified in the message itself. CPF1999, which can be sent by many of the debugging commands (like CHGPGMVAR), states that errors occurred on the command, but it does not identify the command in the message.
|
||
|
</p>
|
||
|
<p><b>Example 2: Monitoring Messages Sent by a Single Command</b>
|
||
|
</p>
|
||
|
<p>
|
||
|
<pre>
|
||
|
CHGVAR VAR(&A) VALUE(&A / &B)
|
||
|
MONMSG MSGID(MCH1211) EXEC(CHGVAR VAR(&A) VALUE(1))
|
||
|
</pre>
|
||
|
</p>
|
||
|
<p>In this example, the MONMSG command follows a Change Variable (CHGVAR) command and, therefore, is only monitoring messages sent by the CHGVAR command. Escape message MCH1211 is sent to this program's message queue when a division by zero is attempted. Because MSGID(MCH1211) is specified, the MONMSG command is monitoring for this condition; when it receives the message, the second CHGVAR command is processed. In this command, the variable &A is set to a value of 1.
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#MONMSG.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
<hr size="2" width="100%">
|
||
|
<div><h3><a name="MONMSG.ERROR.MESSAGES">Error messages</a> </h3>
|
||
|
<p>None
|
||
|
</p>
|
||
|
</div>
|
||
|
<table width="100%">
|
||
|
<tr><td align="right"><a href="#MONMSG.Top_Of_Page">Top</a></td></tr>
|
||
|
</table>
|
||
|
</body>
|
||
|
</html>
|