Hi Rob,

You can't do that because %DEC() creates a variable. Granted, it doesn't have a name, and you can't use it directly in your code -- but it's a variable, used by the compiler, under the covers.

That variable needs to be created at compile-time. And, the %LEN BIF (and presumably also the %DECPOS BIF?) execute at run-time, and therefore the output of those BIFs can't be known at compile-time. If it doesn't know the output at compile-time, it can't create a variable with those attributes at compile-time.

One workaround is to force the BIF to output to a named constant:

D LEN c %len(myDecimal)
D DECPOS c %decpos(myDecimal)
/free
mydecimal = %dec(rplary(x):LEN:DECPOS);


But, frankly, I never do that because I find it too cumbersome to code. It's easier to just pick a really large output field, like:

mydecimal = %dec(rplary(x):30:10);


Remember: %DEC isn't controlling the size of the output to myDecimal. It's controlling the size of a temporary variable under-the-covers. Rplary(x) will be first converted to that temporary variable, and then separately copied to your myDecimal variable.

Think about that... the size of the output of %DEC really doesn't matter.



On 7/24/2012 8:22 AM, rob@xxxxxxxxx wrote:
Why can I do this:
d mydecimal s 2p 0 inz(*zero)
mydecimal=%dec(rplAry(x):%size(mydecimal):0);
but not this
mydecimal=%dec(rplAry(x):%size(mydecimal):%decpos(mydecimal));
RNF0329: The third parameter for %DEC or %DECH is not valid.

IBM Rational Developer for Power Systems Software
5724-Y99, 5733-RDG, 5733-RDH, 5733-RDJ, 5733-RDC
Licensed Materials - Property of IBM

Version: 8.0.3

Rob Berendt



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.