ibm-information-center/dist/eclipse/plugins/i5OS.ic.cl_5.4.0.1/call.htm

221 lines
12 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Call Program (CALL)</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="CALL.Top_Of_Page"></a>
<h2>Call Program (CALL)</h2>
<table width="100%">
<tr>
<td valign="top" align="left"><b>Where allowed to run: </b>All environments (*ALL)<br>
<b>Threadsafe: </b>Yes
</td>
<td valign="top" align="right">
<a href="#CALL.PARAMETERS.TABLE">Parameters</a><br>
<a href="#CALL.COMMAND.EXAMPLES">Examples</a><br>
<a href="#CALL.ERROR.MESSAGES">Error messages</a></td>
</tr>
</table>
<div> <a name="CALL"></a>
<p>The Call (CALL) command calls the program named in the command, and passes control to it. Optionally, the program or user issuing the CALL command can pass parameters to the called program. The CALL command can be used in batch jobs, in interactive jobs, and in both compiled and interpreted control language (CL). When the called program finishes processing, it can return control to the calling program using the RETURN command.
</p>
<p>If the CALL command is issued by a CL procedure, each parameter value passed to the called program can be a character string constant, a numeric constant, a logical constant, a floating-point constant, or a CL variable. If a floating-point constant is specified, the value is converted to double-precision format and passed to the called program. If parameters are passed, the value of the constant or variable is available to the program that is called. Parameters cannot be passed in any of the following forms: lists of values, qualified names, expressions, null parameters (that is, a parameter whose value is null, specified by *N), or keyword parameters. Up to 255 parameters can be passed to the called program.
</p>
<p>If parameters are passed to a program using the CALL command, the values of the parameters are passed in the order in which they appear on the CALL command; this order must match the order in which they appear in the parameter list in the calling program.
</p>
<p>Parameters in a called program can be used in place of its variables. However, no storage in the called program is associated with the variables it receives. Instead, if a variable is passed, the storage for the variable is in the program in which it was originally declared. If a constant is passed, a copy of the constant is made in the calling program and that copy is passed to the called program.
</p>
<p>The result is that if a variable is passed, the called program can change its value and the change is reflected in the calling program. If a constant is passed, and its value is changed by the called program, the changed value is not known to the calling program. Therefore, if the calling program calls the same program again, the values of constants will be to their original values.
</p>
<p>Information on passing variable parameters using the CALL command within a Submit Job (SBMJOB) command is in the Work Management information in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
</p>
<p><b>Restrictions:</b>
</p>
<ul>
<li>You must have object operational (*OBJOPR) and execute (*EXECUTE) authorities to the program to be called, and *EXECUTE authority to the library where the program is located.
</li>
<li>The CALL command is threadsafe, meaning that it can be used to call a program when the CALL command is run in a job with multiple threads. No checking is done whether or not the program to be called is threadsafe.
</li>
</ul>
</div>
<table width="100%">
<tr><td align="right"><a href="#CALL.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div>
<h3><a name="CALL.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" rowspan="3"><a href="#CALL.PGM"><b>PGM</b></a></td>
<td valign="top">Program</td>
<td valign="top"><i>Qualified object name</i></td>
<td valign="top" rowspan="3">Required, Positional 1</td>
</tr>
<tr>
<td valign="top">Qualifier 1: Program</td>
<td valign="top"><i>Name</i></td>
</tr><tr>
<td valign="top">Qualifier 2: Library</td>
<td valign="top"><i>Name</i>, <b><u>*LIBL</u></b>, *CURLIB</td>
</tr><tr>
<td valign="top"><a href="#CALL.PARM"><b>PARM</b></a></td>
<td valign="top">Parameters</td>
<td valign="top">Values (up to 255 repetitions): <i>Not restricted</i></td>
<td valign="top">Optional, Positional 2</td>
</tr>
</table>
<table width="100%">
<tr><td align="right"><a href="#CALL.Top_Of_Page">Top</a></td></tr>
</table>
</div>
<div> <a name="CALL.PGM"></a>
<h3>Program (PGM)</h3>
<p>Specifies the program to be called.
</p>
<p>This is a required parameter.
</p>
<p><b>Qualifier 1: Program</b>
</p>
<dl>
<dt><b><i>name</i></b></dt>
<dd>Specify the name of the program to call.
</dd>
</dl>
<p><b>Qualifier 2: Library</b>
</p>
<dl>
<dt><b><u>*LIBL</u></b></dt>
<dd>All libraries in the library list for the current thread are searched until the first match is found.
</dd>
</dl>
<dl>
<dt><b>*CURLIB</b></dt>
<dd>The current library for the thread is used to locate the program. If no library is specified as the current library for the thread, the QGPL library is used.
</dd>
<dt><b><i>name</i></b></dt>
<dd>Specify the name of the library where the program is located.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#CALL.Top_Of_Page">Top</a></td></tr>
</table>
<div> <a name="CALL.PARM"></a>
<h3>Parameters (PARM)</h3>
<p>Specifies one or more parameter values that are passed to the called program. A maximum of 255 parameter values can be passed.
</p>
<p>Each of the values can be specified only in one of the following forms: a character string constant, a numeric constant, a logical constant, double-precision floating point constant, or a program variable.
</p>
<p>The type and length of each parameter must be the same in both the calling and receiving programs. The number of parameters and the order in which they are sent and received must also be the same. If the CALL command is entered interactively or in a noncompiled batch environment, the type and length expected by the called program must match that of each parameter to be passed on the command.
</p>
<p>Parameters can be passed and received as follows:
</p>
<ul>
<li>Character string constants of 32 bytes or less are <i>always</i> passed with a length of <i>32</i> bytes (padded on the right with blanks). If a character constant is longer than 32 bytes, the whole length of the constant is passed. If the parameter is defined to contain more than 32 bytes, the calling program must pass a constant that contains exactly that number of bytes. Constants longer than 32 characters are <i>not</i> padded to the length expected by the receiving program.
<p>The receiving program can receive less than the number of bytes passed (in this case, no message is sent). For example, if a program specifies that 4 characters are to be received and ABCDEF is passed (padded with blanks in 26 positions), only ABCD is accepted and used by the program. Quoted character strings can also be passed.
</p>
</li>
<li>Decimal constants are passed in packed form and with a length of (15 5), where the value is 15 digits long, of which 5 digits are decimal positions. If a parameter of 12345 is passed, the receiving program must declare the decimal field as (15 5); the parameter is received as 1234500000 (which is 12,345.00000).
</li>
<li>Logical constants are passed as 1 byte with a logical value of '1' or '0'.
</li>
<li>Floating-point literals and floating-point special values (*NAN, *INF, and *NEGINF) are passed as double-precision floating-point numbers, which occupy 8 bytes and are specified in the form sn.nEsn; where s is a plus sign (+) or a minus sign(-); for example, -2.47E+3 or 3.653E24. A single-precision floating-point number cannot be passed to a called program.
</li>
<li>A program variable can be passed if the call is made from a CL program, in which case the receiving program must declare the field to match the variable defined in the calling CL procedure. For example, if a CL procedure defines a decimal variable named &amp;CHKNUM as (5 0), the receiving program must declare the field as packed with 5 digits total, with no decimal positions.
<p>If either a decimal constant or a program variable can be passed to the called program, the parameter should be defined as (15 5), and any calling program must adhere to that definition. If the type, number, order, and length of the parameters do not match between the calling and receiving programs (other than the length exception noted previously for character constants), unpredictable results will occur.
</p>
<p>The value *N cannot be used to specify a null value because a null value cannot be passed to another program.
</p>
</li>
</ul>
<p>
<b>Note: </b>If a parameter value is to be changed by a CL procedure or specified as a variable on a CL command, it must be in writeable storage. For example, in C or C++, strings may be read only. If a read only string is passed as a parameter to a CL procedure, and the CL procedure attempts to change the value of the variable or uses the variable on a CL command, the CL procedure will fail.
</p>
</div>
<table width="100%">
<tr><td align="right"><a href="#CALL.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div><h3><a name="CALL.COMMAND.EXAMPLES">Examples</a> </h3>
<p><b>Example 1: Calling a Program</b>
</p>
<p>
<pre>
CALL PGM(PAYROLL)
</pre>
</p>
<p>The program named PAYROLL is called with no parameters being passed to it. The library list is used to locate the called program.
</p>
<p><b>Example 2: Passing a Character Constant</b>
</p>
<p>
<pre>
CALL PGM(PAYROLL) PARM('1')
</pre>
</p>
<p>The program named PAYROLL is called with a character constant passed as a quoted string. The program must declare a field of up to 32 characters to receive the constant. The library list is used to locate the called program.
</p>
<p><b>Example 3: Passing Parameters</b>
</p>
<p>
<pre>
CALL PGM(LIB1/PAYROLL) PARM(CHICAGO 1234 &amp;VAR1)
</pre>
</p>
<p>The program named PAYROLL located in library LIB1 is called. The calling program passes three parameters: a character string (CHICAGO), a decimal value (1234.00000), and the contents of the CL variable &amp;VAR1. The attributes of the variable determine the attributes of the third parameter.
</p>
<p><b>Example 4: Calling Program with Floating-Point Values</b>
</p>
<p>
<pre>
CALL PGM(PGM1) PARM(1.5E3 *INF)
</pre>
</p>
<p>The program named PGM1 is called with two double-precision floating-point values being passed to it.
</p>
</div>
<table width="100%">
<tr><td align="right"><a href="#CALL.Top_Of_Page">Top</a></td></tr>
</table>
<hr size="2" width="100%">
<div><h3><a name="CALL.ERROR.MESSAGES">Error messages</a> </h3>
<p><b><u>*ESCAPE Messages</u></b>
</p>
<dl>
<dt><b>CPD0783</b></dt>
<dd>Variable &amp;3 for parameter &amp;2 must be TYPE(*DEC), LEN(&amp;4,&amp;5).
</dd>
<dt><b>CPF0005</b></dt>
<dd>Returned command string exceeds variable provided length.
</dd>
<dt><b>CPF0006</b></dt>
<dd>Errors occurred in command.
</dd>
<dt><b>CPF0805</b></dt>
<dd>Error found when program &amp;1 in &amp;2 started.
</dd>
<dt><b>CPF0806</b></dt>
<dd>Error found when procedure started.
</dd>
</dl>
</div>
<table width="100%">
<tr><td align="right"><a href="#CALL.Top_Of_Page">Top</a></td></tr>
</table>
</body>
</html>