Application Development and Automation 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: 

FM SPELL_AMOUNT (5 decimals)

Shravan_
Explorer
0 Kudos
2,728

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos
1,108

Do not pass the parameter 'USD'. Leave CURRENCY blank or do not pass it at all (it is optional).

6 REPLIES 6

Former Member
0 Kudos
1,109

Do not pass the parameter 'USD'. Leave CURRENCY blank or do not pass it at all (it is optional).

Former Member
0 Kudos
1,108

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

Former Member
0 Kudos
1,108

chk this program , may be useful

RF_SPELL

andreas_mann3
Active Contributor
0 Kudos
1,108

hi,

split your value with commands <b>trunc</b> and frac

A.

Former Member
0 Kudos
1,108

Hi Shravan,

If you notice this FM always consider the last 2 digits as decimal if you pass the Currency, and if you don’t 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.

Former Member
0 Kudos
1,108

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