 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to prevent parameter 2 from getting into parm 1 in iSeries</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/how-to-prevent-parm-2-from-getting-into-parm-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-prevent-parm-2-from-getting-into-parm-1/</link>
	<description></description>
	<lastBuildDate>Wed, 22 May 2013 17:18:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-prevent-parm-2-from-getting-into-parm-1/#comment-84821</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Fri, 03 Dec 2010 21:24:28 +0000</pubDate>
		<guid isPermaLink="false">#comment-84821</guid>
		<description><![CDATA[If you need more documentation, see &lt;a href=&quot;http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Frbam6%2Fdflst.htm&quot;&gt;Defining lists for parameters&lt;/a&gt; in the Info Center.

My example is definitely not the only way to do it. It &lt;i&gt;might be&lt;/i&gt; close to the best way, though it can simply depend on how careful you are with accessing parameter values. It can become important in later commands and their CPPs, and it might become important for your current command.

It&#039;s definitely important to use the &lt;i&gt;nbr-of-elements&lt;/i&gt; value(s) when processing a list as you already learned. When a list parameter is the last parameter, you&#039;d be accessing memory that wasn&#039;t part of the parameters at all if you went past the end. You might attempt to access memory that wasn&#039;t even allocated for the command and hit a machine-check.

Tom]]></description>
		<content:encoded><![CDATA[<p>If you need more documentation, see <a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Frbam6%2Fdflst.htm">Defining lists for parameters</a> in the Info Center.</p>
<p>My example is definitely not the only way to do it. It <i>might be</i> close to the best way, though it can simply depend on how careful you are with accessing parameter values. It can become important in later commands and their CPPs, and it might become important for your current command.</p>
<p>It&#8217;s definitely important to use the <i>nbr-of-elements</i> value(s) when processing a list as you already learned. When a list parameter is the last parameter, you&#8217;d be accessing memory that wasn&#8217;t part of the parameters at all if you went past the end. You might attempt to access memory that wasn&#8217;t even allocated for the command and hit a machine-check.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vgp</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-prevent-parm-2-from-getting-into-parm-1/#comment-84813</link>
		<dc:creator>vgp</dc:creator>
		<pubDate>Fri, 03 Dec 2010 15:14:02 +0000</pubDate>
		<guid isPermaLink="false">#comment-84813</guid>
		<description><![CDATA[Tom,
Thank you very much for the info and the detail.  As you probably guessed I am not to savy with commands.

This will help me a lot.   I will try it.

Thanks again.  Gail]]></description>
		<content:encoded><![CDATA[<p>Tom,<br />
Thank you very much for the info and the detail.  As you probably guessed I am not to savy with commands.</p>
<p>This will help me a lot.   I will try it.</p>
<p>Thanks again.  Gail</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-prevent-parm-2-from-getting-into-parm-1/#comment-84797</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Fri, 03 Dec 2010 08:53:30 +0000</pubDate>
		<guid isPermaLink="false">#comment-84797</guid>
		<description><![CDATA[Sometimes you can get programs to do more work by setting variable definitions than you can by coding more op-codes.

Tom]]></description>
		<content:encoded><![CDATA[<p>Sometimes you can get programs to do more work by setting variable definitions than you can by coding more op-codes.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-prevent-parm-2-from-getting-into-parm-1/#comment-84796</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Fri, 03 Dec 2010 08:50:22 +0000</pubDate>
		<guid isPermaLink="false">#comment-84796</guid>
		<description><![CDATA[&lt;i&gt;So I should define the EXC as 6 bytes long...&lt;/i&gt;

More likely it will be (a maximum of) 8 bytes long.

It will actually be a data structure, because that&#039;s a command does to a &quot;list&quot; parameter. The first two bytes will be an unsigned integer (5U 0) that holds the number of list elements that were entered by the user. If three elements were entered, the value will be x&#039;0003&#039; which becomes (3) as an integer. The parameter will physically be pretty much exactly like a VARYING length variable would be in memory.

You use the &lt;i&gt;nbr-of-elements &lt;/i&gt;value to keep your program from referencing elements that weren&#039;t entered by the user.

You might define an 8-byte variable that acts as the receiver of the parm. You never reference it directly though. Instead, define a DS that consists of a 2-byte integer followed by a single character and define the DS as based on a pointer.

When your program is called, assign the address of your 8-byte variable to the pointer. That puts your 3-byte DS definition right over whatever memory address was allocated by the command, and it gives no chance of referencing anything beyond the value because your command guarantees at least one value in your list.

Create a second DS that contains a DIM(6) array of 1-byte values, and also have it be BASED on a pointer. As soon as the first pointer be comes valid, set the second pointer to be the address of the 1-byte variable in the first DS.

At that point, your array DS points to the first element in your list. Any array element that is beyond the &lt;i&gt;nbr-of-elements &lt;/i&gt;value needs to be considered as off-limits to your program code. If &lt;i&gt;nbr-of-elements&lt;/i&gt; contains (3), you don&#039;t want to be referencing element 4.

Well, I can imagine that&#039;s a little confusing, so here&#039;s a stab at a working example:&lt;pre&gt;
     H debug
     H dftactgrp( *NO )
     H     actgrp( *CALLER )
     H     bnddir( &#039;QC2LE&#039; )
     H indent( &#039;  &#039; )

     D ExclPgm         pr                  extpgm( &#039;EXCLUDE&#039; )
     D  Exclude                       8a
     D  InvNo                        10a

     D ExclPgm         PI
     D  Exclude                       8a
     D  InvNo                        10a

     D XL_ds           ds                  based( @XL_ds )
     D  nbrElem                       5u 0
     D  Elems                         1

     D  arElem         s              1    dim( 6 ) based( @Elems )

     D  i              s              5u 0

     C                   eval      @XL_ds    = %addr( Exclude )
     C                   eval      @Elems    = %addr( Elems   )

     C                   for       i  =  1 to nbrElem

     C     arElem(i)     dsply

     C                   endfor

     C                   eval      *inLR   = *on

     C                   return&lt;/pre&gt;
Now, it doesn&#039;t &lt;i&gt;do&lt;/i&gt; anything but display however many elements were entered into the command, but those are the &lt;b&gt;only&lt;/b&gt; elements you&#039;re interested in. Compile it and test it by calling it this way:&lt;pre&gt;
call exclude (x&#039;0002F1F2F3&#039; &#039;Now parm 2&#039;)&lt;/pre&gt;
If you look closely, you&#039;ll see that it&#039;s technically passing three array elements in while claiming that it&#039;s only two. Experiment by adding &#039;F4F5F6&#039; or more onto the end of the first parm. Change the x&#039;0002&#039; to x&#039;0005&#039; or x&#039;0001&#039;.

If there are difficulties or questions, post them here. (...especially if I messed up pasting the code or something.)

Tom]]></description>
		<content:encoded><![CDATA[<p><i>So I should define the EXC as 6 bytes long&#8230;</i></p>
<p>More likely it will be (a maximum of) 8 bytes long.</p>
<p>It will actually be a data structure, because that&#8217;s a command does to a &#8220;list&#8221; parameter. The first two bytes will be an unsigned integer (5U 0) that holds the number of list elements that were entered by the user. If three elements were entered, the value will be x&#8217;0003&#8242; which becomes (3) as an integer. The parameter will physically be pretty much exactly like a VARYING length variable would be in memory.</p>
<p>You use the <i>nbr-of-elements </i>value to keep your program from referencing elements that weren&#8217;t entered by the user.</p>
<p>You might define an 8-byte variable that acts as the receiver of the parm. You never reference it directly though. Instead, define a DS that consists of a 2-byte integer followed by a single character and define the DS as based on a pointer.</p>
<p>When your program is called, assign the address of your 8-byte variable to the pointer. That puts your 3-byte DS definition right over whatever memory address was allocated by the command, and it gives no chance of referencing anything beyond the value because your command guarantees at least one value in your list.</p>
<p>Create a second DS that contains a DIM(6) array of 1-byte values, and also have it be BASED on a pointer. As soon as the first pointer be comes valid, set the second pointer to be the address of the 1-byte variable in the first DS.</p>
<p>At that point, your array DS points to the first element in your list. Any array element that is beyond the <i>nbr-of-elements </i>value needs to be considered as off-limits to your program code. If <i>nbr-of-elements</i> contains (3), you don&#8217;t want to be referencing element 4.</p>
<p>Well, I can imagine that&#8217;s a little confusing, so here&#8217;s a stab at a working example:
<pre>
     H debug
     H dftactgrp( *NO )
     H     actgrp( *CALLER )
     H     bnddir( 'QC2LE' )
     H indent( '  ' )

     D ExclPgm         pr                  extpgm( 'EXCLUDE' )
     D  Exclude                       8a
     D  InvNo                        10a

     D ExclPgm         PI
     D  Exclude                       8a
     D  InvNo                        10a

     D XL_ds           ds                  based( @XL_ds )
     D  nbrElem                       5u 0
     D  Elems                         1

     D  arElem         s              1    dim( 6 ) based( @Elems )

     D  i              s              5u 0

     C                   eval      @XL_ds    = %addr( Exclude )
     C                   eval      @Elems    = %addr( Elems   )

     C                   for       i  =  1 to nbrElem

     C     arElem(i)     dsply

     C                   endfor

     C                   eval      *inLR   = *on

     C                   return</pre>
<p>Now, it doesn&#8217;t <i>do</i> anything but display however many elements were entered into the command, but those are the <b>only</b> elements you&#8217;re interested in. Compile it and test it by calling it this way:
<pre>
call exclude (x'0002F1F2F3' 'Now parm 2')</pre>
<p>If you look closely, you&#8217;ll see that it&#8217;s technically passing three array elements in while claiming that it&#8217;s only two. Experiment by adding &#8216;F4F5F6&#8242; or more onto the end of the first parm. Change the x&#8217;0002&#8242; to x&#8217;0005&#8242; or x&#8217;0001&#8242;.</p>
<p>If there are difficulties or questions, post them here. (&#8230;especially if I messed up pasting the code or something.)</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vgp</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-prevent-parm-2-from-getting-into-parm-1/#comment-84757</link>
		<dc:creator>vgp</dc:creator>
		<pubDate>Thu, 02 Dec 2010 16:25:51 +0000</pubDate>
		<guid isPermaLink="false">#comment-84757</guid>
		<description><![CDATA[Thanks Tom,
yes this is familiar.  The same process that had the QM issue with the setvar

This is the D specs in the RPG.  

D EXCLUDE         DS                         
D  ELEAD                  1      2           
D  EXC                              1    DIM(6) 
D INVFLD          S            10           

The EXC is the separate entries, the invfld is the 2nd parm.  The invfld gets the &#039;INVNO&#039; properly.  

&lt;i&gt;The ‘INVNO’ value is going to be in memory immediately following the EXCLUDE values. If RPG always accesses 6 bytes even when only 3 three were placed in memory, it will access the first bytes of INVNO.&lt;/i&gt;

yes, this is what is happening.
&lt;i&gt;You are defining a list of 1-byte values rather than a 6-byte field. You should only access as many values as were entered by the user. You’ll need to extract the list counter from the EXCLUDE parm and use it.&lt;/i&gt;

So I should define the EXC as 6 bytes long and then load it into the array later?]]></description>
		<content:encoded><![CDATA[<p>Thanks Tom,<br />
yes this is familiar.  The same process that had the QM issue with the setvar</p>
<p>This is the D specs in the RPG.  </p>
<p>D EXCLUDE         DS<br />
D  ELEAD                  1      2<br />
D  EXC                              1    DIM(6)<br />
D INVFLD          S            10           </p>
<p>The EXC is the separate entries, the invfld is the 2nd parm.  The invfld gets the &#8216;INVNO&#8217; properly.  </p>
<p><i>The ‘INVNO’ value is going to be in memory immediately following the EXCLUDE values. If RPG always accesses 6 bytes even when only 3 three were placed in memory, it will access the first bytes of INVNO.</i></p>
<p>yes, this is what is happening.<br />
<i>You are defining a list of 1-byte values rather than a 6-byte field. You should only access as many values as were entered by the user. You’ll need to extract the list counter from the EXCLUDE parm and use it.</i></p>
<p>So I should define the EXC as 6 bytes long and then load it into the array later?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-prevent-parm-2-from-getting-into-parm-1/#comment-84723</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Thu, 02 Dec 2010 08:34:28 +0000</pubDate>
		<guid isPermaLink="false">#comment-84723</guid>
		<description><![CDATA[We need to see how RPG is defining its parms. (Why does this process feel familiar?)

It will almost certainly be how RPG defines and accesses the parms where the problem is.

The &#039;INVNO&#039; value is going to be in memory immediately following the EXCLUDE values. If RPG always accesses 6 bytes even when only 3 three were placed in memory, it will access the first bytes of INVNO.

You are defining a list of 1-byte values rather than a 6-byte field. You should only access as many values as were entered by the user. You&#039;ll need to extract the list counter from the EXCLUDE parm and use it.

Tom]]></description>
		<content:encoded><![CDATA[<p>We need to see how RPG is defining its parms. (Why does this process feel familiar?)</p>
<p>It will almost certainly be how RPG defines and accesses the parms where the problem is.</p>
<p>The &#8216;INVNO&#8217; value is going to be in memory immediately following the EXCLUDE values. If RPG always accesses 6 bytes even when only 3 three were placed in memory, it will access the first bytes of INVNO.</p>
<p>You are defining a list of 1-byte values rather than a 6-byte field. You should only access as many values as were entered by the user. You&#8217;ll need to extract the list counter from the EXCLUDE parm and use it.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vgp</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-prevent-parm-2-from-getting-into-parm-1/#comment-84708</link>
		<dc:creator>vgp</dc:creator>
		<pubDate>Thu, 02 Dec 2010 04:15:25 +0000</pubDate>
		<guid isPermaLink="false">#comment-84708</guid>
		<description><![CDATA[It lost the rest of my info...here it is
This is the command parms:
PARM       KWD(EXCLUDE) TYPE(*CHAR) LEN(1) RSTD(*YES) +  
             VALUES(A B C D E F G H I) +  
             MIN(1) MAX(6) PASSATR(*NO) CHOICE(&#039;F4 +  
             for list&#039;) PROMPT(&#039;Exclude these Codes&#039;)    
                                                         
PARM       KWD(INVNO) TYPE(*CHAR) LEN(10) MIN(1) +      
             MAX(1) PASSATR(*NO) CHOICE(&#039;INV Field name&#039;) +  
             PROMPT(&#039;Invoice field&#039;)             

looks like this where I can do 1 code or up to 6.
Exclude these Codes  . . . . . .      _                             F4 for list  
               + for more values         _                     
Invoice field . . . . . . . . . . . . .      __________           INV Field name   

If I enter A, B, C  in the Codes field and INVNO in the Invoice field,  I get A B C I N V in the Exclude field.

How do I make the remaining of the 6 possible entries be blank instead?]]></description>
		<content:encoded><![CDATA[<p>It lost the rest of my info&#8230;here it is<br />
This is the command parms:<br />
PARM       KWD(EXCLUDE) TYPE(*CHAR) LEN(1) RSTD(*YES) +<br />
             VALUES(A B C D E F G H I) +<br />
             MIN(1) MAX(6) PASSATR(*NO) CHOICE(&#8216;F4 +<br />
             for list&#8217;) PROMPT(&#8216;Exclude these Codes&#8217;)    </p>
<p>PARM       KWD(INVNO) TYPE(*CHAR) LEN(10) MIN(1) +<br />
             MAX(1) PASSATR(*NO) CHOICE(&#8216;INV Field name&#8217;) +<br />
             PROMPT(&#8216;Invoice field&#8217;)             </p>
<p>looks like this where I can do 1 code or up to 6.<br />
Exclude these Codes  . . . . . .      _                             F4 for list<br />
               + for more values         _<br />
Invoice field . . . . . . . . . . . . .      __________           INV Field name   </p>
<p>If I enter A, B, C  in the Codes field and INVNO in the Invoice field,  I get A B C I N V in the Exclude field.</p>
<p>How do I make the remaining of the 6 possible entries be blank instead?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/9 queries in 0.014 seconds using memcached
Object Caching 352/355 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-22 17:39:51 -->