Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Using Function RW_ConvertToWordsAndNumbers()

Posted on by 210

Hello,

I am getting error "EXCEPTION_CLASS_SCRIPT_OUT_OF_RANGE. SCRIPT_CMD_POWER" when I use the RW_ConvertToWordsAndNumbers() in GP2015 R2.  My research shows that this is an old error but non of the posts of this issues have a solution. 

If there is anyone who has been ale to overcome this issue I would appreciate your sharing the solution with me.

Thank you.

Jackie

*This post is locked for comments

  • Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: Using Function RW_ConvertToWordsAndNumbers()

    The easiest way, of course, is to remove the wording from the Currency Setup window, but I suspect this may not an option. If it is, then that's the answer. Other than that, I don't see an easy way to do this in Report Writer.

  • Jackie McNab Profile Picture
    Jackie McNab 210 on at
    RE: Using Function RW_ConvertToWordsAndNumbers()

    Hello Mariano, 

    Thanks for your suggestions and the information provided.  I played around with building the calculated field and somehow it worked.

    The only problem for me now is that I need to remove the words "dollars" and "cents" from the equation as I am using preprinted forms which already have them printed.

    Any suggestions?

    Jackie

  • Verified answer
    Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: Using Function RW_ConvertToWordsAndNumbers()

    In looking at the source code, I see that this function has the following signature:

    {-----------------------------------------------------------------------
    RW_ConvertToWordsAndNumbers
    
    Convert currency value to Words and Numbers, using descriptive terms from the Currency ID supplied.
    -----------------------------------------------------------------------}
    
    function returns string OUT_string;
    in currency IN_Value;		{ Value of Currency }
    in string IN_Currency;		{ Currency ID of Currency - Leave Blank for Functional }
    in integer IN_Mode; 		{ 0 = Whole Number in words, Parts in numbers }
    				{ 1 = Whole Number in numbers, Parts in numbers }
    			        { 2 = Whole Number in words, Parts in words }
    


    This is, you will pass in the amount to be converted, the actual currency ID as a string, and the mode. There's a section of the code that takes the currency amount you are trying to convert and subtracts the integer part of that value part of that value, then multiplies it to 10 to the power of the number of decimal places. I suspect this is the section that's failing, since you are getting a value out of range when that particular operation is executed (EXCEPTION_CLASS_SCRIPT_OUT_OF_RANGE. SCRIPT_CMD_POWER), a simple example is as follows:

    Let's say you want to convert 273.44. Based on what I am seeing here, the calculation done will be:

    l_Value = (273.44 - 273) * 10 ^ 2;
    
    
    This yields .44 * 100, which is 44 -- as in 44 cents.
    


    Now, the 2 decimals used to elevate 10 ^ 2 is obtained by calling the Dexterity function, Currency_GetNumberOfDecimals(), by passing in the Currency Index stored in the MC_Currency_SETP table or otherwise uses the Functional Currency Decimals if Multicurrency is registered.

    So 4 things come to mind:

    1) Either Multicurrency is registered and you don't have decimal places in place for the currency in question, or

    2) A functional currency has not been defined for the company, or

    3) The values you are passing in to convert exceed the capacity of Dexterity (unlikely), or

    4) Your multicurrency table records are damaged or non-existent.

    I would personally backup the entire system and run a check links in against the Multicurrency tables to ensure all is OK. Step 9 of this support article describes how to do this: https://support.microsoft.com/en-us/help/861642/how-to-assign-a-functional-currency-when-multicurrency-management-is-n 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans