2006 Aug 07 1:39 PM
Dear Friends,
I wanted to spell amount '5455555.65461' in to word but i am getting problem after decimal it is taking up 2 number after decimal, can any body suggest how to print 5 decimals.
code is as given:
&----
*& Report YTEST *
*& *
&----
*& *
*& *
&----
REPORT YTEST no standard page heading .
data : tline like tline occurs 0 with header line,
SPELL LIKE SPELL OCCURS 0 WITH HEADER LINE.
data amouno type p DECIMALS 5 value '5455555.65461'.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = amouno
CURRENCY = 'USD'
FILLER = ' '
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3
.
WRITE : / 'Amount in Number: ',AMOUNO.
WRITE : / 'Amount in Word: ',SPELL-WORD, 'AND DECIMALS' , SPELL-DECWORD.
Result
*********************************************
Amount in Number: 5,455,555.65461
Amount in Word:
FIVE BILLIONS FOUR HUNDRED FIFTY-FIVE MILLION FIVE HUNDRED FIFTY-FIVE THOUSAND SIX HUNDRED FIFTY-FOUR
AND DECIMALS SIXTY-ONE
2006 Aug 07 1:50 PM
Do not pass the parameter 'USD'. Leave CURRENCY blank or do not pass it at all (it is optional).
2006 Aug 07 1:50 PM
Do not pass the parameter 'USD'. Leave CURRENCY blank or do not pass it at all (it is optional).
2006 Aug 07 1:51 PM
HI Shravan,
Welcome to SDN Forums...
One thing which you can do is split that amount at a decimal point and capture that value in to a variable and pass that value to FM SPELL_AMOUNT by recalling the FM...
Regards,
Santosh
2006 Aug 07 1:54 PM
2006 Aug 07 1:55 PM
2006 Aug 07 3:17 PM
Hi Shravan,
If you notice this FM always consider the last 2 digits as decimal if you pass the Currency, and if you dont pass the currency what you pass will be completely considered as before decimal even if you have a decimal separator.
So what you can do it is split your amount at decimal separator and call the FM twice
First time with Pre decimal values and then with post decimal values.
Both time do not pass any currency and get the output from SPELL-WORD.
And then concatenate, as you require.
Regards,
Sreejesh P.
NB: Award points if helpful.
2006 Aug 07 3:24 PM
There are two ways to resolve it
1. Separting integer/decimal values
l_int = amouno div 1.
l_dec = amouno mod 1.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = L_int
CURRENCY = ''
FILLER = ' '
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.
L_word = spell-word.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = L_dec
CURRENCY = ''
FILLER = ' '
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.
concatenate l_word 'AND DECIMALS' spell-word into L_word separated by space.
WRITE : / 'Amount in Number: ',AMOUNO.
WRITE : / 'Amount in Word: ',L_WORD.
2. Second method is to define a dummy currency with 5 decimals and call the above FM. (I have not tried but it might be possible to define a currency with more than 2 decimals --so not certain whether it would work or not.)
Regards
Anurag