2009 Apr 26 2:00 PM
Hai Experts ,
my requirement is to convert the currency field value in words for that i am using the FM 'SPELL_AMOUNT'
but that FM didnt display the value in words after decimal point.
for example if the value s 100.50 i need to display it in words as hundred rupees fifty paise but the FM
'SPELL_AMOUNT' displayed the output as hundred rupees only
is there any FM available for converting the value in words including decimal point?
With Regards,
R.dhineshraj.
2009 Apr 26 2:48 PM
Hi, Raj.
Test the Sample Code Bellow This will solve out your Problem,
DATA: amt_in_words(1000).
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
amt_in_num = '100.50'
IMPORTING
amt_in_words = amt_in_words
* EXCEPTIONS
* DATA_TYPE_MISMATCH = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE: amt_in_words.
Best Regards,
Faisal
2009 Apr 26 2:48 PM
Hi, Raj.
Test the Sample Code Bellow This will solve out your Problem,
DATA: amt_in_words(1000).
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
amt_in_num = '100.50'
IMPORTING
amt_in_words = amt_in_words
* EXCEPTIONS
* DATA_TYPE_MISMATCH = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE: amt_in_words.
Best Regards,
Faisal
2009 Apr 27 6:46 AM
Hai faizal,
Thanks for your answer.This FM is working fine for indian currency but my requirement is currrency may be whatever but it has to return the value in amount in words including decimal point.
2009 Apr 27 6:52 AM
HI, Raj,
Just add the following two Lines after you FM Hope will solve out this time
REPLACE 'Rupees' WITH 'Dollar' into amt_in_words.
REPLACE 'Paise' WITH 'Cents' into amt_in_words.
WRITE: / amt_in_words.
Please Reply if any issue,
Best Regards,
Faisal
2009 Apr 27 7:15 AM
Hi, Raj
Above FM will not Sport more than two digits after decimal point if you have the requirement like this than please use the following way,
DATA: amount TYPE p DECIMALS 3 VALUE '100.504',
c_amount TYPE string,
part_1st TYPE string,
part_2nd TYPE string,
in_words TYPE spell,
amt_in_words(1000).
c_amount = amount.
SPLIT c_amount at '.' into part_1st part_2nd.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = part_1st
IMPORTING
in_words = in_words.
part_1st = in_words-word.
clear: in_words.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = part_2nd
IMPORTING
in_words = in_words.
part_2nd = in_words-word.
CONCATENATE part_1st 'unit1' part_2nd 'unit2' into amt_in_words SEPARATED BY space.
WRITE: / amt_in_words.
Kind Regards,
Faisal
2009 Apr 27 7:39 AM
hai Faizal,
thanks for your reply.if i split the amount field as two parts means it was returning the value for 2 parts in amount in words.
i have one more doubt in that coding if the currency is 'USD' it has to return first part as 100 dollars and then latter part as 50 cent but it returns only amount in words likewise it has to return the corresponding currency in words according to the entry of text in the import parameter currency to the FM 'SPELL_AMOUNT'.
is there any possibilty to do this in the FM SPELL_AMOUNT?
2009 Apr 27 7:58 AM
Hi, Raj
Have you tested the above sample code after getting words of two part than we will CONCATENATE to add Dollar and Cents like bellow in above code unit1 means Dollar for US and for other countries replace accordingly same way for unit2.
CONCATENATE part_1st 'Dollar' part_2nd 'Cents' into amt_in_words SEPARATED BY space.
Best Regards,
Faisal
2009 Apr 26 3:11 PM
2009 Apr 27 4:45 AM
2009 Apr 27 4:49 AM
Test for function group HRPAYINX
Function module HR_IN_CHG_INR_WRDS
Uppercase/Lowercase
Runtime: 1,708,765 Microseconds
Import parameters Value
AMT_IN_NUM 100.50
Export parameters Value
AMT_IN_WORDS ONE HUNDRED Rupees FIFTY Paise
hope it will help you
2009 Apr 27 5:00 AM
2009 Apr 27 5:07 AM