× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 18 Jun 2013 11:24, Marco Facchinetti wrote:
Just curious why an item defined with the TEMPLATE keyword is valid
as %SIZE's argument but not for %LEN.

I have no access to the text of that message RNF0655. What was the context of the failed reference; i.e. what was the line of code... as a declarative or a run-time statement?

http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc092508560.htm#wq806
_i TEMPLATE i_
"The TEMPLATE keyword indicates that the definition is to be used only for further LIKE or LIKEDS definitions. The TEMPLATE keyword is valid for Data Structure definitions and Standalone field definitions."

Thus if %LEN(template_var) was referenced in a run-time expression [a statement vs a declare], then I would expect that utilization would fail, per the aforementioned restriction; i.e. the /template/ exists only for the LIKExx. If the %LEN() is really preferred over %SIZE(), then just reference what was defined /like/ that template, instead of naming the TEMPLATE declarative.

For a declarative however, I would expect the same capability as with a BASED storage declaration. Thus if the based declarative can be specified for %LEN(), I would expect the TEMPLATE declarative could as well. And while a based declarative could be utilized at run-time after the basing pointer was set, the TEMPLATE would have no similar ability to be referenced in run-time because there is no capability for the effect [template-only] declarative to be addressed.

http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc092508852.htm#lnright
_i %LEN Used for its Value
"... the number of digits or characters of the variable expression.
...
For character, graphic, or UCS-2 expressions the value returned is the number of characters in the value of the expression. For variable-length values, such as the value returned from a built-in function or a variable-length field, the value returned by %LEN is the current length of the character, graphic, or UCS-2 value.

Note that if the parameter is a built-in function or expression that has a value computable at compile-time, the length returned is the actual number of digits of the constant value rather than the maximum possible value that could be returned by the expression.
..."

An argument that the %LEN() is available only for run-time overlooks that a constant can be assigned. Thus the capability could conceivably exist for the use of %LEN() on a declaration for any declarative that is either a scalar or a DS with a fixed "size" known at compile-time [just as stated in the above doc snippet]. Arguably, %SIZE() can be used instead to get bytes, and then multiply according to data type; e.g. multiply by .5 for a graphic scalar to get the character count. But that subtle difference between what %LEN() and %SIZE() provide, alludes to the possible value for the capability that a %LEN(template_var) might provide vs what %SIZE(template_var) provides.

http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc092508749.htm#bifsint
"Built-in functions ... [w]hen used with definition specification keywords, the value of the built-in function must be known at compile time and the argument cannot be an expression."

http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc092508874.htm#bbsize
"%SIZE may be specified anywhere that a numeric constant is allowed on the definition specification and in an expression in the extended factor 2 field of the calculation specification."


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.