Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Amount in Words

Former Member
0 Kudos

Hi Dear All,

I am searching for function module to convert amount in words. Not only Indian currency but any currency. SPELL_AMOUNT Is one But it does not working properly. So please Help me..................

Thanks And Regards.

Pradip Pawar

12 REPLIES 12

former_member184657
Active Contributor
0 Kudos

SPELL_AMOUNT will work properly.... keep trying

pk

Former Member
0 Kudos

Hi Pradip Pawar..

SAP is not only for India and FM 'SPELL_AMOUNT' is not only for Indian Currency...

Explain your problem so that will be answerd..Think as a Consultant.

Regards,

Sg

Edited by: Suneel Kumar Gopisetty on Jun 4, 2008 9:03 AM

0 Kudos

Dear Suneel,

I understand that SPELL_AMOUNT is not only for India But I used SPELL_AMOUNT And I Passed 2450.50 This Amount and Currency as USD. Then FM is replying

'TWO THOUSAND FOUR HUNDRED FIFTY' but what about 50 cents???

Pradip Pawar

0 Kudos

ive had the same problem.

try creating a new funtion module(ZAMOUNT) with the following code.

FUNCTION ZAMOUNT.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(AMOUNT) TYPE PC207-BETRG

*" REFERENCE(CURRENCY) TYPE T001R-WAERS DEFAULT SPACE

*" EXPORTING

*" REFERENCE(TEXT) TYPE C

*"----


*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(AMOUNT) TYPE PC207-BETRG

*" EXPORTING

*" REFERENCE(TEXT) TYPE C

*"----


&----


*

& Tables Definition *

&----


*

tables spell.

&----


*

& Data Declaration *

&----


*

data: amount_ch(13) ,

text1(150) ,

text2(35) ,

flag ,

len type i ,

move type i .

data : begin of itab ,

cr(3),

lac(2),

th(2),

hun(3),

paise(3),

end of itab .

amount_ch = amount.

len = strlen( amount_ch ).

move = 13 - len.

shift amount_ch right by move places.

move amount_ch to itab.

If currency = 'INR'.

write: 'RUPEES' to text1.

else.

write: 'US DOLLARS' to text1.

endif.

*if itab-paise GT '.50'.

*itab-hun = itab-hun + 1.

*endif.

if itab-cr ne '000' and itab-cr ne space.

perform spellamount using itab-cr 'CRORE' flag text1.

endif.

if itab-lac ne '00' and itab-lac ne space.

perform spellamount using itab-lac 'LAKH' flag text1 .

  • PERFORM SPELLAMOUNT USING ITAB-LAC 'LACS' FLAG TEXT1 .

endif.

if itab-th ne '00' and itab-th ne space.

perform spellamount using itab-th 'THOUSAND' flag text1 .

endif.

if itab-hun ne '000' and itab-hun ne space..

perform spellamount using itab-hun '' flag text1 .

endif.

if itab-paise ne '.00' and itab-paise ne space .

  • itab-paise = itab-paise mod 10.

flag = 1.

If currency = 'INR'.

perform spellamount using itab-paise 'PAISE' flag text1.

else.

perform spellamount using itab-paise 'CENTS' flag text1.

endif.

  • perform spellamount using itab-paise ' ' flag text1.

endif.

concatenate text1 'ONLY' into text1 separated by space.

write text1 to text.

endfunction.

&----


*& Form SPELLAMOUNT

&----


form spellamount using amount

unit

flag

text1 .

call function 'SPELL_AMOUNT'

exporting

amount = amount

language = sy-langu

importing

in_words = spell

exceptions

not_found = 1

too_large = 2

others = 3.

if flag = 0.

concatenate text1 spell-word unit into text1 separated by ' ' .

else.

concatenate text1 'AND' spell-word unit into text1 separated by ' '.

endif.

  • replace all occurrences of '-' in text1 with ' '.

clear spell.

endform.

*ENDFUNCTION.

after that u can start using this FM instead of SPELL_AMOUNT.

regards,

pk

0 Kudos

Hi,

As stated in my previous posy it appears in IN_WORDS-DECWORD.

Raju Chitale

Former Member
0 Kudos

HI.

Refer this.

CONVERT_TO_LOCAL_CURRENCY - Conversion of currency

CONVERT_TO_FOREIGN_CURRENCY Convert local currency to foreign currency.

CONVERT_TO_LOCAL_CURRENCY Convert from foreign currency to local currency

Reward all helpfull answers.

Regards.

Jay

Former Member
0 Kudos

hi

what the problem u r facing in SPELL_AMOUNT,

coz CURRENCY and LANGUAGE field r there so u can put valur in these also as required.

Former Member
0 Kudos

Hi,

SPELL_AMOUNT ith FM. Do not forget to pass the currency e.g. 'INR' for Rupees. Just run in SE37 & see the results. In_WORDS-WORDS contain the Rupee 'part ' of it & IN_WORDS-DECWORD contain 'PAise' Part of it you need to concatenate 'Rupee' IN_WORDS-WORDS '& Paisa' IN_WORDS-DECWORD to get the desired result. ''Rupee' & 'Paise' Needs to be replace with the appropriate unit depenidng on the currency.

I hope this helps,

Regards

Raju Chitale

Former Member
0 Kudos

Hi,

u can also try

HR_IN_CHG_INR_WRDS

thanks

Former Member
0 Kudos

Hi,

Check the following code:

REPORT ZSPELL.

TABLES SPELL.

DATA : T_SPELL LIKE SPELL OCCURS 0 WITH HEADER LINE.

DATA : PAMOUNT LIKE SPELL-NUMBER VALUE '1234510'.

SY-TITLE = 'SPELLING NUMBER'.

PERFORM SPELL_AMOUNT USING PAMOUNT 'USD'.

WRITE: 'NUMBERS', T_SPELL-WORD, 'DECIMALS ', T_SPELL-DECWORD.

FORM SPELL_AMOUNT USING PWRBTR PWAERS.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = PAMOUNT

CURRENCY = PWAERS

FILLER = SPACE

LANGUAGE = 'E'

IMPORTING

IN_WORDS = T_SPELL

EXCEPTIONS

NOT_FOUND = 1

TOO_LARGE = 2

OTHERS = 3.

ENDFORM. " SPELL_AMOUNT

Regards,

Bhaskar

Former Member
0 Kudos

hi

i understood ur problem see first you split the value from at point then u'll have the value before decimals in one variable and after decimal in another.

then paas the complete value in the function and u'll get the result as u stated no put a condition if var2(that is after decimal [point ) if it is not empty then concatenate and put the cents and display it otherwise whatever ur getting will do

.

eg = 1750.80

split a1 into var1 var2 at '.'.

now 1750 will go in var1.

var1 = 1750.

and var2 will be having 80.

var2 = 80.

now use concatenate

and replace all occurrences of rs into desired currency. and display it

reward points if helpful

Former Member
0 Kudos

Thanks To All