I have a character field with value '9,405.000000'. I want to convert it to numeric. But the ',' is causing issue in %Dec. . How can I get the value 9405.000000 in a numeric field?
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
I use %xlate inside %dec so the decimal can float. This replaces commas with spaces that are ignored by %dec
MyNumField = %DEC(%XLATE(‘,’:’ ‘:MyCharField):15:5)
Did you try to search at all for a solution? An answer was given in the forum just a week ago. — Tom
Try
http://itknowledgeexchange.techtarget.com/itanswers/converting-amount-in-character-field-to-numeric-in-rpgle/
I use %xlate inside %dec so the decimal can float. This replaces commas with spaces that are ignored by %dec
MyNumField = %DEC(%XLATE(‘,’:’ ‘:MyCharField):15:5)
Search for Bob Cozzi’s CharToNum procedure. Works great. He even includes the source code in the posting.