112 lines
7.1 KiB
HTML
112 lines
7.1 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="Trailing blanks on command parameters" />
|
|
<meta name="abstract" content="This describes how trailing blanks are handled on command parameters." />
|
|
<meta name="description" content="This describes how trailing blanks are handled on command parameters." />
|
|
<meta name="DC.subject" content="trailing blank, command parameter, parameter, trailing blanks, trailing blank, example" />
|
|
<meta name="keywords" content="trailing blank, command parameter, parameter, trailing blanks, trailing blank, example" />
|
|
<meta name="DC.Relation" scheme="URI" content="workv.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../cl/ovrdbf.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="tralb" />
|
|
<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>Trailing blanks on command parameters</title>
|
|
</head>
|
|
<body id="tralb"><a name="tralb"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Trailing blanks on command parameters</h1>
|
|
<div><p>This describes how trailing blanks are handled on command parameters.</p>
|
|
<div class="section"> <p>Some command parameters are defined with the parameter value
|
|
of VARY(*YES). This parameter value causes the length of the value passed
|
|
to be the number of characters between the apostrophes. When a CL variable
|
|
is used to specify the value for a parameter defined in this way, the system
|
|
removes trailing blanks before determining the length of the variable to be
|
|
passed to the command processor program. If the trailing blanks are present
|
|
and are significant for the parameter, you must take special actions to ensure
|
|
that the length passed includes them. Most command parameters are defined
|
|
and used in ways which do not cause this condition to occur. An example of
|
|
a parameter defined where this condition is likely to occur is the key value
|
|
element of the POSITION parameter on the <span class="cmdname">Override with Database File
|
|
(OVRDBF)</span> command.</p>
|
|
<p>When this condition could occur, the desired
|
|
result can be attained for these parameters by constructing a command string
|
|
that delimits the parameter value with apostrophes and passing the string
|
|
to QCMDEXC or QCAPCMD for processing.</p>
|
|
<p>The following is an example of
|
|
a program that can be used to run the <span class="cmdname">Override with Database File
|
|
(OVRDBF)</span> command so that the trailing blanks are included as part
|
|
of the key value. This same technique can be used for other commands that
|
|
have parameters defined using the parameter VARY(*YES); trailing blanks must
|
|
be passed with the parameter.</p>
|
|
<div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code license and disclaimer information</a> for
|
|
important legal information.</div>
|
|
<pre> PGM PARM(&KEYVAL &LEN)
|
|
/* PROGRAM TO SHOW HOW TO SPECIFY A KEY VALUE WITH TRAILING */
|
|
/* BLANKS AS PART OF THE POSITION PARAMETER ON THE OVRDBF */
|
|
/* COMMAND IN A CL PROGRAM. */
|
|
/* THE KEY VALUE ELEMENT OF THE POSITION PARAMETER OF THE OVRDBF */
|
|
/* COMMAND IS DEFINED USING THE VARY(*YES) PARAMETER. */
|
|
/* THE DESCRIPTION OF THIS PARAMETER ON THE ELEM COMMAND */
|
|
/* DEFINITION STATEMENT SPECIFIES THAT IF A PARAMETER */
|
|
/* DEFINED IN THIS WAY IS SPECIFIED AS A CL VARIABLE THE */
|
|
/* LENGTH IS PASSED AS THE VARIABLE WITH TRAILING BLANKS */
|
|
/* REMOVED. A CALL TO QCMDEXC USING APOSTROPHES TO DELIMIT */
|
|
/* THE LENGTH OF THE KEY VALUE CAN BE USED TO CIRCUMVENT */
|
|
/* THIS ACTION. */
|
|
/* PARAMETERS-- */
|
|
DCL VAR(&KEYVAL) TYPE(*CHAR) LEN(32) /* THE VALUE +
|
|
OF THE REQUESTED KEY. NOTE IT IS DEFINED AS +
|
|
32 CHAR. */
|
|
DCL VAR(&LEN) TYPE(*INT) /* THE LENGTH +
|
|
OF THE KEY VALUE TO BE USED. ANY VALUE OF +
|
|
1 TO 32 CAN BE USED */
|
|
/* THE STRING TO BE FINISHED FOR THE OVERRIDE COMMAND TO BE */
|
|
/* PASSED TO QCMDEXC (NOTE 2 APOSTROPHES TO GET ONE). */
|
|
DCL VAR(&STRING) TYPE(*CHAR) LEN(100) +
|
|
VALUE('OVRDBF FILE(X3) POSITION(*KEY 1 FMT1 '' ')
|
|
/* POSITION MARKER 123456789 123456789 123456789 123456789 */
|
|
DCL VAR(&END) TYPE(*DEC) LEN(15 5) /* A VARIABLE +
|
|
TO CALCULATE THE END OF THE KEY IN &STRING */
|
|
|
|
CHGVAR VAR(%SST(&STRING 40 &LEN)) VALUE(&KEYVAL) /* +
|
|
PUT THE KEY VALUE INTO COMMAND STRING FOR +
|
|
QCMDEXC IMMEDIATELY AFTER THE APOSTROPHE. */
|
|
CHGVAR VAR(&END) VALUE(&LEN + 40) /* POSITION AFTER +
|
|
LAST CHARACTER OF KEY VALUE */
|
|
CHGVAR VAR(%SST(&STRING &END 2)) VALUE('')') /* PUT +
|
|
A CLOSING APOSTROPHE & PAREN TO END +
|
|
PARAMETER */
|
|
CALL PGM(QCMDEXC) PARM(&STRING 100) /* CALL TO +
|
|
PROCESS THE COMMAND */
|
|
ENDPGM</pre>
|
|
<div class="note"><span class="notetitle">Note:</span> If you use VARY(*YES) and RTNVAL(*YES) and are passing a
|
|
CL variable, the length of the variable is passed rather than the length of
|
|
the data in the CL variable.</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="workv.htm" title="CL procedures consist of CL commands, and the commands themselves consist of the command statement, parameters, and parameter values.">Use variables</a></div>
|
|
</div>
|
|
<div class="relinfo"><strong>Related information</strong><br />
|
|
<div><a href="../cl/ovrdbf.htm">Override Database File (OVRDBF) command</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |