RW – Getting RW_ConvertToWordsAndNumbers() to show cents in words


David Meego - Click for blog homepageA little while ago I wrote an article about how to get the RW_ConvertToWordsAndNumbers() report writer user defined function to work correctly for both originating and functional currency views. Today, a comment was added to that article asking about how to get the RW_ConvertToWordsAndNumbers() function to return the cents in words rather than numbers.

Usually the function will convert the dollar amount into words but the cent amount is shown as numbers.

For example: Using the amount 1,234.56 and the currency ID Z-US$ will return:

One Thousand Two Hundred Thirty Four Dollars and 56 Cents

However, the request was to get the following, with the cents in words:

One Thousand Two Hundred Thirty Four Dollars and Fifty Six Cents

None of the available Report Writer (RW) functions which can convert amounts to words can achieve this result. So…

 


I decided to write some Dexterity code (using the Runtime Execute window in the Support Debugging Tool) to manipulate the values returned from the function to achieve the desired end result. This code is written only using RW functions so it can be transferred to calculated fields in the report writer easily.

The concept is to separate the dollars amount from the cents amount and then pass the cents amount to the function as though it was a dollar amount.  We then take back the resulting strings and splice them back together to get the result we wanted. 

Dexterity Code

I then took the same logic and formulas into report writer as calculated fields and created an updated version of the report from the original post (see attached).

Please see the link below for the original article:

RW – Getting RW_ConvertToWordsAndNumbers() to work with multi-currency

An example package of the v10.0 POP Purchase Order Other Form is attached at the bottom of the article. 

Hope you find this useful. 

David

05-Jul-2010: Also look at new function in the post: Announcing Report Writer Function RW_ConvertToWordsAndNumbersParse.

POP Purchase Order Other Form.zip

Comments (5)

  1. Vaidy says:

    Thanks David.

    I was referring this function to one of my friend and the same gap was reported by him. I could not give him any solution for that as I was involved in a different task.

    This was badly needed by him and I can now deviate him to this article.

    Thanks

    Vaidy

  2. Manoj says:

    thanks dave. Now i want to add one string "Only" at the end of amount in words. for eg : six thousand dollars only..

    pls help

  3. David Musgrave says:

    Manoj

    If you are using VBA to get this working, you will need to add the "only" text from VBA.  The VBA code runs after the Report Writer has completed the section being printed. You cannot the results from VBA code in RW calculated fields.

    David

  4. Manoj says:

    thanx for your reply. I am not using any VBA code.I am using the calculated fields in report writer. I want to add "only" string to string B. Is it possible through calculated fields ?

  5. David Musgrave says:

    Hi Manoj

    String calculated fields are limited to 80 characters.  if the contents of String B are longer than 75 characters there will not be room to add " only".  

    So, no.  This method is not going to work 100% of the time.

    David

Skip to main content