Tuesday, July 22, 2008

XSL function to convert number to word


For long time we have been searching for one function which can be used to convert the number into words. You all might know why this function is mandatory.


Yes this helps a lot when you are doing a check print report. Lot of them posted questions on oracle forum. The great Gareth, gave a suggestion to use package from database & convert into the words. Everybody thought they need to create some custom function for this. But AP module have its own function ap_amount_utilities_pkg.ap_convert_number to do this.




SQL> select ap_amount_utilities_pkg.ap_convert_number(trunc(12345678)) from dual;


AP_AMOUNT_UTILITIES_PKG.AP_CONVERT_NUMBER(TRUNC(12345678))


----------------------------------------------------------------------------


Twelve million three hundred forty-five thousand six hundred seventy-eight



But here is a question…. Can we call a PL/SQL function in BI Publisher at runtime and return a value?……….


If you are thinking how to do this then here is a our guru Tim got a sample extension to do this http://blogs.oracle.com/xmlpublisher/2007/12/03/


And finally if this is not the one your looking for ;) and you need a direct XSL function to do. Then here it is, in the latest BI Publisher oracle BIP Team had added the function toWordsAmt.


Here is an example to call this function




<?xdoxslt:toWordsAmt(12345.98)?>


Output: Twelve Thousand Three Hundred Fourty Five and paise Ninety Eight



But here every body wonders why it shows paise and what if you want to show it in cent (for USD). Even I had the same question. So I posted my query in the oracle forum. But the answer from Vitsrini was little surprise for me. You know why. look the reply from Vitsrini




i tried, its a bug, Paise has been hardcoded it seems, they should have coded by looking @ the currency locale settings. i guess, Tim will accept this :).



and here is our guru Tim reply which gives me some hope to use this function in the future.




I have to admit not knowing about this function until it arrived and checking the code its hardcoded!


These were some functions that were developed in India for one of Oracle's aquisitions that operates almost exclusively in India.



I'll log an enhancement for this to get other languages! Might take some time as looking at the code it does not use any i18n library its just plain coded for rupees!

So all of you wait for the new upgraded version of this function in the next BIP release (just hoping ;) ). To know more about this conversion you can check the oracle BIP forum http://forums.oracle.com/forums/thread.jspa?threadID=656644&tstart=0



No comments:

Post a Comment