ibm-information-center/dist/eclipse/plugins/i5OS.ic.rbam6_5.4.0.1/monms.htm

162 lines
10 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="Monitor Message (MONMSG) Command" />
<meta name="abstract" content="The Monitor Message (MONMSG) command is used to monitor for escape, notify, or status messages sent to the call stack of the procedure in which the Monitor Message (MONMSG) command is used." />
<meta name="description" content="The Monitor Message (MONMSG) command is used to monitor for escape, notify, or status messages sent to the call stack of the procedure in which the Monitor Message (MONMSG) command is used." />
<meta name="DC.subject" content="MONMSG (Monitor Message) command, use, Monitor Message (MONMSG) command, command, CL, MONMSG (Monitor Message), Monitor Message (MONMSG), message, monitoring, parameters" />
<meta name="keywords" content="MONMSG (Monitor Message) command, use, Monitor Message (MONMSG) command, command, CL, MONMSG (Monitor Message), Monitor Message (MONMSG), message, monitoring, parameters" />
<meta name="DC.Relation" scheme="URI" content="contp.htm" />
<meta name="DC.Relation" scheme="URI" content="../clfinder/finder.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/monmsg.htm" />
<meta name="DC.Relation" scheme="URI" content="msghd.htm" />
<meta name="DC.Relation" scheme="URI" content="wmsgs.htm" />
<meta name="DC.Relation" scheme="URI" content="check.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="monms" />
<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>Monitor Message (MONMSG) Command</title>
</head>
<body id="monms"><a name="monms"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1"><span class="cmdname">Monitor Message (MONMSG)</span> Command</h1>
<div><p>The <span class="cmdname">Monitor Message (MONMSG)</span> command is used
to monitor for escape, notify, or status messages sent to the call stack of
the procedure in which the <span class="cmdname">Monitor Message (MONMSG)</span> command
is used. </p>
<div class="section"><p>Escape messages are sent to CL procedures by the commands in the
CL procedures and by the programs and procedures they call. These escape
messages are sent to tell the procedures that errors were detected and requested
functions were not performed. CL procedures can monitor for the arrival of
escape messages, and you can specify through commands how to handle the messages.
For example, if a CL procedure tries to move a data area that has been deleted,
an object-not-found escape message is sent to the procedure by the <span class="cmdname">Move
Object (MOVOBJ)</span> command.</p>
<p>Using the <span class="cmdname">Monitor Message
(MONMSG)</span> command, you can direct a procedure to take predetermined
action if specific errors occur during the processing of the immediately preceding
command. The <span class="cmdname">Monitor Message (MONMSG)</span> command has the following
parameters: </p>
<pre>MONMSG MSGID(message-identifier) CMPDTA(comparison-data) +
EXEC(CL-command)</pre>
<p>Each message that is sent for a specific error has a unique
identifier. You can enter as many as 50 message identifiers on the MSGID parameter.
(See the online help for messages and identifiers). The CMPDTA parameter allows
even greater specification of error messages because you can check for a specific
character string in the MSGDTA portion of the message. On the EXEC parameter,
you can specify a CL command (such as a Call Program (CALL), Do (DO), or a
Go To (GOTO)), which directs the procedure to perform error recovery.</p>
<p>In
the following example, the <span class="cmdname">Monitor Message (MONMSG)</span> command
follows the <span class="cmdname">Receive File (RCVF) </span>command and, therefore,
is only monitoring for messages sent by the RCVF command: </p>
<pre>READLOOP: RCVF /* Read a file record */
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(EOF))
/* Process the file record */
GOTO CMDLBL(READLOOP) /* Get another record */
EOF: /* End of file processing */</pre>
<p>The escape message, CPF0864, is sent to the procedure's invocation
queue when there are no more records in the file to read. Because the example
specifies MSGID(CPF0864), the MONMSG monitors for this condition. When it
receives the message, the GOTO CMDLBL(EOF) command is run.</p>
<p>You can also
use the <span class="cmdname">Monitor Message (MONMSG)</span> command to monitor for
messages sent by any command in a CL procedure. The following example includes
two <span class="cmdname">Monitor Message (MONMSG)</span> commands. The first <span class="cmdname">Monitor
Message (MONMSG)</span> command monitors for the messages CPF0001 and CPF1999;
these messages might be sent by any command run 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>The second
MONMSG command monitors for the messages CPF2105 and MCH1211. Because no
command is coded for the EXEC parameter, these messages are ignored. </p>
<pre>PGM
DCL
MONMSG MSGID(CPF0001 CPF1999) EXEC(GOTO EXIT2)
MONMSG MSGID(CPF2105 MCH1211)
.
.
.
ENDPGM</pre>
<p>Message CPF0001 states that an error was found in the command
that is identified in the message itself. Message CPF1999, which can be sent
by many of the debugging commands, such as <span class="cmdname">Change Program Variable
(CHGPGMVAR)</span>, states that errors occurred on the command, but it
does not identify the command in the message.</p>
<p>All error conditions monitored
for by the <span class="cmdname">Monitor Message (MONMSG)</span> command with the EXEC
parameter specified (CPF0001 or CPF1999) are handled in the same way at EXIT2,
and it is not possible to return to the next sequential statement after the
error. You can avoid this by monitoring for specific conditions after each
command and branching to specific error correction procedures.</p>
<p>All error
conditions monitored for by the <span class="cmdname">Monitor Message (MONMSG)</span> command
without the EXEC parameter specified (CPF2105 or MCH1211) are ignored, and
procedure processing continues with the next command.</p>
<p>If the error occurs
when evaluating the expression on an IF command, the condition is considered
false. In the following example, MCH1211 (divide by zero) could occur on
the IF command. The condition would be considered false, and PROCA would
be called. </p>
<pre>IF(&amp;A / &amp;B *EQ 5) THEN(DLTF ABC)
ELSE CALLPRC PROCA</pre>
<p>If you code the <span class="cmdname">Monitor Message (MONMSG)</span> command
at the beginning of your CL procedure, the messages you specify are monitored
throughout the program, regardless of which command produces these messages.
If the EXEC parameter is used, only the GOTO command can be specified. If
the GOTO command is run in your program, the subroutine stack will be reset.</p>
<p>You
can specify the same message identifier on a procedure-level or a command-level <span class="cmdname">Monitor
Message (MONMSG)</span> command. The command-level <span class="cmdname">Monitor Message
(MONMSG)</span> commands take precedence over the procedure-level MONMSG
commands. In the following example, if message CPF0001 is received on CMDB,
CMDC is run. If message CPF0001 is received on any other command in the procedure,
the procedure branches to EXIT2. If message CPF1999 is received on any command,
including CMDB, the procedure branches to EXIT2. </p>
<pre>PGM
MONMSG MSGID(CPF0001 CPF1999) EXEC(GOTO EXIT2)
CMDA
CMDB
MONMSG MSGID(CPF0001) EXEC(CMDC)
CMDD
EXIT2: ENDPGM</pre>
<p>Because many escape messages can be sent to a procedure, you
must decide which ones you want to monitor for and handle. Most of these
messages are sent to a procedure only if there is an error in the procedure.
Others are sent because of conditions outside the procedure. Generally, a
CL procedure should monitor for those messages that pertain to its basic function
and that it can handle appropriately. For all other messages, i5/OS™ assumes
an error has occurred and takes appropriate default action.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="contp.htm" title="You can use commands to change the flow of logic within your CL procedure.">Control processing within a CL procedure</a></div>
</div>
<div class="reltasks"><strong>Related tasks</strong><br />
<div><a href="msghd.htm" title="Predefined messages are stored in a message file.">Define message descriptions</a></div>
<div><a href="wmsgs.htm" title="This discusses some of the ways that messages can be used to communicate between users and programs.">Messages</a></div>
<div><a href="check.htm" title="Before attempting to use an object in a program, check to determine if the object exists and if you have the authority to use it.">Check for the existence of an object</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../clfinder/finder.htm">CL command finder</a></div>
<div><a href="../cl/monmsg.htm">Monitor Message (MONMSG) command</a></div>
</div>
</div>
</body>
</html>