Microsoft Dynamics GP Developing for Dynamics GP
A blog dedicated to the Microsoft Dynamics GP Developer & Consultant community
 
Welcome to MSDN Blogs Sign in | Join | Help

Developing for Dynamics GP

by David Musgrave (Australia) and the Microsoft Dynamics GP Developer Support Team (USA)

News

  • Please use the Blog Feedback? - Contact Us link at the top of the page to email questions relating to the blog itself.

    If you wish to ask a technical question, please use the links below to ask on the Newsgroups. If you ask on the Newsgroups, others in the community can respond and the answers are available for everyone in the future.

    Please do not use comments on pages and posts to ask questions unrelated to the topic on that page or post.



    Dates of Interest:

    11-Jul-2008: Blog Created by David Musgrave.
    10-Oct-2008: First Post by Scott Stephenson.
    04-Nov-2008: First Post by Dave Dusek.
    11-Nov-2008: First Post by Beth Gardner.
    28-Nov-2008: First Post by Chris Roehrich.
    30-Dec-2008: First Post by Patrick Roth.
    24-Feb-2009: First Post by Greg Willson.
    22-Apr-2009: First Post by David Clauson.
    04-May-2009: First Post by Ryan Wigestrand.
    19-Jun-2009: First Post by Dawn Langlie.
    03-Jul-2009: First Post by Emily Halvorson.
    23-Sep-2009: Created Twitter account with blog feed.



    WorldMaps Statistics since
    24-Feb-2009:




    Click for WorldMaps Stumbler



    Translator Tool:




    Social Networking

    Follow David Musgrave and the blog on:

    David Musgrave on Twitter

    David Musgrave on LinkedIn


    Disclaimer

    This blog is provided "AS IS" with no warranties, and confers no rights.

    The links in this blog may lead to third-party Web sites. Microsoft provides third-party resources to help you find customer service and/or technical support resources. Information at these sites may change without notice. Microsoft is not responsible for the content at any third-party Web sites and does not guarantee the accuracy of third-party information.

Contents

Favourite Posts

Blog Links

Newsgroups Links

Resources Links

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

David MeegoI recently had a support case where the partner consultant was trying to use the RW_ConvertToWordsAndNumbers() report writer user defined function to display the Purchase Order total in words at the bottom of the document.

They were using the POP Purchase Order Other Form (but this method works for the POP Purchase Order Blank Form as well) and had created a calculated field using the RW_ConvertToWordsAndNumbers() function similar to one shown below:

Name: (c) ConvertToWordsAndNumbers
Result Type: String
Expression Type: Calculated
Calculated: FUNCTION_SCRIPT(RW_ConvertToWordsAndNumbers  cyPrintTotal  POP_PO.Currency ID  0)

The problem was that even though the amount correctly changed when the originating or functional multi-currency view was selected, the wording always used the originating currency's terms. 

For example: For a system with a functional currency of US Dollars (Z-US$) and a transaction with an originating currency of UK Pounds (Z-UK), the string returned was always in the form "X Pounds and Y Pence".  The amounts were correct, by the terminology did not change.


Solution for Purchase Order Processing (POP) Forms 

The problem is that the POP_PO.Currency ID field from the Purchase Order Work table is a constant value containing the originating Currency ID for the transaction.  What is needed is a field that will have the actual Currency ID for the currency view being printed.

Looking at other calculated fields on the report I could see that the calculated field nLegend4 was being used to indicate which currency view was being printed.  nLegend4 is an integer representation of the Legend 4 field and is used to indicate which view is being used 1 = Functional, 2 = Originating.

Getting the Functional Currency ID is simple as it is always available from Function Currency of Globals.  Getting the Originating Currency ID is slightly more complex.  Our calculated fields will be using the field Display Type of Data. If we were to use Data for the Currency ID field from the Purchase Order Work table in a footer section, it will already be pointing at the next record.  So we need to use Display Type of Last for the Currency ID field. The report already has a hidden Currency ID field with Display Type of Last in the Report Footer section so we can re-use that field.

So, we just need a calculated field which will display the correct Currency ID based on the value in the Legend 4 field. We can then use this field with the report writer function to get the desired results:

Name: (c) Currency ID
Result Type: String
Expression Type: Conditional
Conditional: nLegend4 = 1
True Case: Functional Currency of Globals
False Case: RF_LAST Currency ID

So the updated calculated field from before is:

Name: (c) ConvertToWordsAndNumbers
Result Type: String
Expression Type: Calculated
Calculated: FUNCTION_SCRIPT(RW_ConvertToWordsAndNumbers  cyPrintTotal   (c) Currency ID  0)

Now when the report is printed both the about and the currency terminology will change depending on the currency view used.


Solution for Sales Order Processing (SOP) Forms 

An almost identical question was asked on the Partner Forum, but this time it was about the SOP Blank Invoice Form. To make this work for the SOP Blank Invoice Form requires the same technique.  First you will need to drag the Currency ID field from the Sales Transaction Work field into the Report Footer (RF) section. By default the field will be set to Data type of Last.

Then build the exact same calculated fields as decribed above but change the fields used as shown in the table below:

Field POP Forms SOP Forms
Currency View nLegend4 (C) Force Functional
Document Total cyPrintTotal F/O Document Amount

For more detailed steps please see the following Knowledge Base (KB) article.

How to modify the SOP Blank Invoice Form to display the total amount of the invoice in words in Microsoft Dynamics GP and in Microsoft Great Plains (KB 917473) Secure Link 

Note: This article has now been updated to pass in a Currency ID, instead passing a blank "" string.  Passing a blank currency ID to the RW function meant it was always using terminology (Dollars/Cents, Pounds/Pence, etc.) from the functional currency regardless of the currency view for the document.


More Information 

For more information on using the RW_ConvertToWordsAndNumbers() function and other Report Writer functions please see the following posts:

Hybrid - Cheque Amount in Words Example

Using the built-in Report Writer Functions 

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

Hope you found this example useful. 

David

08-Jul-2009: Posted follow up article: RW - Getting RW_ConvertToWordsAndNumbers() to show cents in words.

Posted: Wednesday, May 06, 2009 9:00 AM by David Musgrave
Attachment(s): POP Purchase Order Other Form.zip

Comments

DynamicAccounting.net said:

David Musgrave at Developing for Dynamics GP has info on getting the RW_ConverttoWordsandNumbers() function

# May 8, 2009 11:05 AM

Devesh said:

Need to display "Sixty Dollars and fifty cents" but after using this function it shows "Sixty Dollars and 50 cents" please help

# July 8, 2009 1:41 AM

David Musgrave said:

# July 8, 2009 7:59 AM

Mohammed said:

Hi David

This very useful since these many days we customized thru VBA. Hope you that if the retuned char is more than 80 char it is not showing the whole words e.g. 7,777,777.77

I hear that there was one function is available for this to split into 2 strings eventhough I check with the SDK doc I can't get the desired result will you please help me on this

Thanks

Mohammed

# August 8, 2009 1:12 PM

David Musgrave said:

Hi Mohammed

The link for the VBA example of how to work around the 80 character limit for string calculated fields is provided in this post.

Hybrid - Cheque Amount in Words Example

David

# August 10, 2009 3:02 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker