DataFlex Report Writer: Currency symbol not relying on Windows Locale
by
, 16-Feb-2014 at 11:39 AM (45717 Views)
If you use a numeric column in a report where the value requires a currency symbol (e.g. article price, order total) you can format the field to print a currency symbol before the number. In the following screenshot is the Euro symbol seen in front of the Credit Limit, the Purchases and the Balance.
For this you format the field and on the Number tab-page you can choose between "Windows Default Currency", "Custom Currency" or "Custom Currency Mask".
In the report above I selected "Windows Default Currency" which causes the print the Euro symbol (€) in front of the numeric value because my Windows Locale is setup for the Netherlands. If I would print this report with the regional settings set to the USA we would see a Dollar sign ($).
Is this always correct? That depends. If all your numbers are in one currency and all computers running the report use the same regional settings it is correct. But sending this report to another region could lead to a print of Dollar values with a Chinese Yuan symbol in front of the number. Not good. A currency recalculation would be required.
Instead of that I can select "Custom Currency" and change the currency formatting symbol to whatever I want. I can change the symbol to Sfr, £ or Kr. etc. The symbol is then hardcoded to the report and always the same. I can make the following screenshot.
The report above shows the first row values in Euros using the Default Windows Currency formatting and on a second row the values in Pound Sterling (recalculated at a rate of .82 euro)
What if you want to control it more? So not rely on the Windows Default Currency and not rely on a hardcoded currency symbol. It is possible by choosing the third option "Custom Currency Mask".
First you make up a default mask. To help, choose Custom Currency first and let is create the mask string for you. Change to Customer Currency Mask and copy the created mask onto the Windows clipboard.
Then close the field formatting dialog and via the field explorer create a string parameter.
In the above screenshot you see I paste the custom mask string. Since a parameter can be changed in the designer or via integration the mask symbol is now flexible. Use this parameter in a function created for the custom mask as shown below.
Does this work always? That depends on if you can specify the currency symbol in the integration API. For example the Euro symbol does not exist in the OEM character set and could not be set by changing the parameter value. So what then? If you switch to a function instead of a parameter you can write:
Above works because DataFlex Report Writer internally uses ANSI and Chr(0128) represents the Euro symbol.Code:return '0.00;$ 1.1;($1.1);,;.;' + Chr (0128)
With a function instead of a parameter your report uses a function to call a function to return the currency mask string.
I hope this blog gave you ideas of how to use the DataFlex Report Writer as your reporting solution.