× 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 19-Apr-2015 12:26 -0500, Hoteltravelfundotcom wrote:
I have coded this:
eval ord_wt = %dec(PHWtot:7:2)

but still got error of data decimal error.

To locate this I have taken a D' and have the program dump.

Is this all I need? here it will tell me which is the bad data?

From the dump data showing the value of variable PHWtot [when RNX0105 was the result], one should be able to infer what "is the bad data". What a valid character string representing a _decimal value_ is [at least somewhat] documented in the RPG reference:
<http://www.ibm.com/support/knowledgecenter/api/content/SSPSQF_9.0.0/com.ibm.etools.iseries.langref.doc/evfrilsh828.htm#bbdecnum>

Another definition [that includes overflow RNX0103 as /invalid/ too], for what %DEC can handle in converting a character [string] to a numeric value, might be [and IMO is more accurately described by]:

• zero to many leading blanks
• an optional leading sign character as either the plus ('+') character for a positive value or the minus ('-') character for a negative value
• zero to many blanks
• zero to many decimal digit characters zero ('0') [surely at least as many as the maximum number of digits supported precision of 31 or 63, though possibly not restricted except by size of string]
• zero to many decimal digit characters from zero ('0') to nine ('9') [to avoid overflow, only for as many as, up to the result of the expression (third_argument - second_argument) of the %dec built-in; i.e. the expression (precision-decimal_places), which in the given scenario, is the expression (7-2) derived from the %dec(arg1:7:2), for a result of: /as-many-as 5 digits/]
• an optional decimal separator [aka decimal point] as either the period ('.') character or the comma (',') character
• zero to many decimal digit characters from zero ('0') to nine ('9'), unlimited in number except by the length of the character string
• zero to many blanks; i.e. as insignificant fractional precisions, they are meaningless to the outcome and can not contribute to an overflow condition like the integer portion can
• an optional trailing sign character as either the plus ('+') character for a positive value or the minus ('-') character for a negative value, but only if there was _no_ leading sign
• zero to many trailing blanks


Otherwise can I code in the RPG to handle such an occurrence?


Uh, sure. The RPG could be coded to do anything to /handle/ the signaled\monitored problems that can occur. But depending on what the definition of /handle/ is in that sentence, the problem could be intractable; how an occurrence of bad data might be /handled/, is necessarily _specific_ to both the application and the requirements to maintain the integrity of the [calculated and stored] results. For example, a conspicuously poor /handling/ for a business application, would be setting a recorded price to zero whenever the price being input as character, was deemed invalid according to the %dec casting.


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.