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

74 lines
3.8 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="task" />
<meta name="DC.Title" content="Data type errors" />
<meta name="abstract" content="This details other types of data type errors that may occur." />
<meta name="description" content="This details other types of data type errors that may occur." />
<meta name="DC.Relation" scheme="URI" content="comer.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="dataerror" />
<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>Data type errors</title>
</head>
<body id="dataerror"><a name="dataerror"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Data type errors</h1>
<div><p>This details other types of data type errors that may occur.</p>
<div class="section"> <p>When passing a value, the data type (TYPE parameter) must be
the same (*CHAR, *DEC, or *LGL) in the calling procedure or program and in
the called procedure or program. Errors frequently occur in this area when
you attempt to pass a numeric constant. If the numeric constant is enclosed
in apostrophes, it is passed as a character string. However, if the constant
is not enclosed in apostrophes, it is passed as a packed numeric field with
LEN(15 5).</p>
<div class="p">In the following example, a quoted numeric value is passed
to a program that expects a decimal value. A decimal data error (escape message
MCH1202) occurs when variable &amp;A is referred to in the called program
(PGMA): <pre>CALL PGMA PARM('123') /* CALLING PROGRAM */
PGM PARM(&amp;A) /* PGMA */
DCL &amp;A *DEC LEN(15 5) /* DEFAULT LENGTH */
.
.
.
IF (&amp;A *GT 0) THEN(...) /* MCH1202 OCCURS HERE */</pre>
</div>
<p>In the following example, a decimal value is passed to
a program defining a character variable. Generally, this error does not cause
run-time failures, but incorrect results are common: </p>
<pre>CALL PGMB PARM(12345678) /* CALLING PROG */
PGM PARM(&amp;A) /* PGMB */
DCL &amp;A *CHAR 8
.
.
.
ENDPGM</pre>
<p>Variable &amp;A in PGMB has a value of hex <samp class="codeph">001234567800000F</samp>.</p>
<p>Generally,
data can be passed from a logical (*LGL) variable to a character (*CHAR) variable,
and vice versa, without error, so long as the value is expressed as '0' or
'1'.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="comer.htm" title="This describes the errors encountered most frequently in passing values on a CALL command or a CALLPRC command. Some of these errors can be very difficult to debug, and some have serious consequences for program functions.">Common errors when calling programs and procedures</a></div>
</div>
</div>
</body>
</html>