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

118 lines
6.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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="task" />
<meta name="DC.Title" content="Write a validity checking program" />
<meta name="abstract" content="You can write a validity checking program for your command to detect errors and send diagnostic messages." />
<meta name="description" content="You can write a validity checking program for your command to detect errors and send diagnostic messages." />
<meta name="DC.subject" content="command, CL, defining, validity checking, writing, program, writing validity checking" />
<meta name="keywords" content="command, CL, defining, validity checking, writing, program, writing validity checking" />
<meta name="DC.Relation" scheme="URI" content="defcm.htm" />
<meta name="DC.Relation" scheme="URI" content="valid.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/sndpgmmsg.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/crtcmd.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="wvchk" />
<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>Write a validity checking program</title>
</head>
<body id="wvchk"><a name="wvchk"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Write a validity checking program</h1>
<div><p>You can write a validity checking program for your command to detect
errors and send diagnostic messages.</p>
<div class="section"> <p>To write a validity checking program for your command, specify
the name of the validity checking program on the VLDCKR parameter on the <span class="cmdname">Create
Command (CRTCMD)</span> command. The program does not have to exist when
the <span class="cmdname">Create Command (CRTCMD)</span> command is run. If *LIBL is
used as the library qualifier, the library list is used to find the validity
checking program when the created command is run.</p>
<p>The following are
two considerations for validity checking programs: </p>
<ul><li>The validity checking program is called only if the command syntax is
correct. All parameters are passed to the program the same as they are passed
to a command processing program.</li>
<li>You should not use the validity checking program to change parameter values
because the changed values are not always passed to the command processing
program.</li>
</ul>
<p>The remainder of this section describes how to send messages from
a validity checking program that is written in CL.</p>
<p>If the validity checking
program detects an error, it should send a diagnostic message to the previous
call and then send escape message CPF0002. For example, if you need a message
saying that an account number is no longer valid, you add a message description
similar to the following to a message file: </p>
<pre>ADDMSGD MSG('Account number &amp;2 no longer valid') +
MSGID(USR0012) +
MSGF(QGPL/ACTMSG) +
SEV(40) +
FMT((*CHAR 4) (*CHAR 6))</pre>
<p>Note that the substitution variable &amp;1 is not in the message
but is defined in the FMT parameter as 4 characters. &amp;1 is reserved for
use by the system and must always be 4 characters. If the substitution variable &amp;1
is the only substitution variable defined in the message, you must ensure
that the fourth byte of the message data does not contain a blank when you
send the message.</p>
<p>This message can be sent to the system by specifying
the following in the validity checking: </p>
<pre>SNDPGMMSG MSGID(USR0012) MSGF(QGPL/ACTMSG) +
MSGDTA('0000' &amp;ACCOUNT) MSGTYPE(*DIAG)</pre>
<p>After the validity checking has sent all the necessary diagnostic
messages, it should then send message CPF0002. The <span class="cmdname">Send Program
Message (SNDPGMMSG)</span> command to send message CPF0002 looks like this:
</p>
<pre>SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) +
MSGTYPE(*ESCAPE)</pre>
<p>When the system receives message CPF0002, it sends message
CPF0001 to the calling program to indicate that errors have been found.</p>
<p>Message
CPD0006 has been defined for use by the user-defined validity checking programs.
An immediate message can be sent in the message data. Note in the following
example that the message must be preceded by four character zeros.</p>
<p>The
following shows an example of a validity checking program: </p>
<pre>PGM PARM(&amp;PARM01)
DCL VAR(&amp;PARM01) TYPE(*CHAR) LEN(10)
IF COND(&amp;PARM01 *EQ 'ERROR') THEN(DO)
SNDPGMMSG MSGID(CPD0006) MSGF(QCPFMSG) +
MSGDTA('0000 DIAGNOSTIC MESSAGE FROM USER-DEFINED +
VALIDITY CHECKER INDICATING THAT PARM01 IS IN ERROR.') +
MSGTYPE(*DIAG)
SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
ENDDO
ELSE
.
.
.
ENDPGM</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="defcm.htm" title="This describes how you can define and create your own commands.">Define commands</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="valid.htm" title="The system performs validity checking on commands. You may also write your own validity checking program although it is not required.">Validity checking</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../cl/sndpgmmsg.htm">Send Program Message (SNDPGMMSG) command</a></div>
<div><a href="../cl/crtcmd.htm">Create Command (CRTCMD) command</a></div>
</div>
</div>
</body>
</html>