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: 
Read only

Amount in words

Former Member
0 Likes
2,755

Hi,

I am working in 4.6c. I have to convert an amount to words.

Say 1450 to One thousand four hundred fifty dollars and 00 cents.

I tried it with SPELL_AMOUNT bbut its not satisfying my requirement.

Is there any function module for doing it.

regards,

Bala

Hi,

I am working in 4.6c. I have to convert an amount to words.

Say 1450 to One thousand four hundred fifty dollars and 00 cents.

I tried it with SPELL_AMOUNT bbut its not satisfying my requirement.

Is there any function module for doing it.

regards,

Bala

13 REPLIES 13
Read only

Former Member
0 Likes
1,947

Hi,

What is the problem with SPELL_AMOUNT ?

Svetlin

Read only

0 Likes
1,947

instead of 1450 pass the amount with decimals 1450.00 along with the currency key.

Regards

Raja

Read only

Former Member
0 Likes
1,947

when i pass 1450

i get one thousand and four hundred fifty

when i pass 1450.00

i get a different output which very much odd

Read only

Former Member
0 Likes
1,947

You will get the values in SPELL-DECWORD AND SPELL-WORD.

You amy ahve to write alittle bit more ABAP to achieve what you want . Cents are not known in SAP only USD with decimal places in known.

Cheers

Read only

0 Likes
1,947

SPELL_AMOUNT shd work correctly.

Can u plz tell us wat you are expecting & wat is the result from SPELL_AMOUNT. wat are the inputs given ?

regards

gv

Read only

Former Member
0 Likes
1,947

Also check if you are passing P type variable in AMOUNT .

If you pass acharacter varaible with '1450.00' you will get a different result.

Cheers

Read only

Former Member
0 Likes
1,947

I have got the output now when i tried with the currency value

but i am getting the output in caps like

ONE THOUSAND FOUR HUNDRED FIFTY DOLLARS ZERO CENTS

i wanna display as

One Thousand Four Hundred Fifty Dollars

in sapscript

can anyone give a solutio for this

Read only

0 Likes
1,947

Use translate to lower case .

data index like sy-index.

data ix like sy-index.

DATA letters(500) TYPE C.

letters = 'ONE THOUSAND FOUR HUNDRED FIFTY DOLLARS'.

TRANSLATE letters TO LOWER CASE.

TRANSLATE letters+0(1) TO UPPER CASE.

TRANSLATE letters using ' #'.

index = 1.

DO.

SEARCH letters FOR '#' STARTING AT index.

if sy-subrc = 0.

index = SY-FDPOS + 1 + ix.

TRANSLATE letters+index(1) TO UPPER CASE.

ix = index.

index = index + 1.

else.

exit.

endif.

check index >= 500.

exit.

ENDDO.

TRANSLATE letters using '# '.

write letters.

This will give the output needed for u

regards

gv

Message was edited by: Venkat

Read only

0 Likes
1,947

Hi Bala,

How did u manage to get the display as Dollars and Cents. Can you please help with the logic.

Read only

Former Member
0 Likes
1,947

data keepamount(1)

data count type I.

data count1 type I.

( Amount is the field having in words )

count1 = STRLEN(AMOUNT).

Do count1 times .

IF KEEPAMOUNT EQ SPACE.

KEEPAMOUNT = AMOUNT+COUNT(1) .

COUNT = COUNT + 1.

CONTINUE .

ENDIF.

TRANSLATE AMOUNT+COUNT(1) TO LOWER CASE.

KEEPAMOUNT = AMOUNT+COUNT(1).

COUNT = COUNT + 1.

ENDDO.

Cheers

Move AMOUNT+COUNT(1) To KEEPAMOUNT.

Mo

Read only

Former Member
0 Likes
1,947

Hi,

I am not sure when you are using spell_amount, you are passing 'CURRENCY" and "LANGUAGE" along with the "AMOUNT".

for example if you pass -

AMOUNT = '1450.55'

CURRENCY = 'USD'

LANGUAGE = 'EN'

to the SPELL_AMOUNT it will return you value like -

NUMBER = 000000000001450 <- this is the amount without

decimals

DECIMAL = 550 <- this is decimal amount

CURRDEC = 2

WORD = ONE THOUSAND FOUR HUNDRED FIFTY <- without

decimal

amount in

word

DECWORD = FIFTY-FIVE <- decimal amount in word

now if you are using 'USD' as currency it means amount mentioned by WORD is in dollar and amount mentioned by DECWORD is cents.

Cheers,

Rajeev

Read only

Former Member
0 Likes
1,947

hi,

spell_amount is the correct function module

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = IS_HEADER-NETWR

CURRENCY = IS_HEADER-WAERK

LANGUAGE = SY-LANGU

IMPORTING

IN_WORDS = G_AMOUNT_WORDS

EXCEPTIONS

NOT_FOUND = 1

TOO_LARGE = 2

OTHERS = 3.

G_AMOUNT_WORDS-word contain "One thousand four hundred fifty dollars"

G_AMOUNT_WORDS-decword contain zero (equivalent string to the decimal )

you concatenate both like

concatenate G_AMOUNT_WORDS-word IS_HEADER-WAERK

'and' G_AMOUNT_WORDS-decword 'cents' into l_string

separated by space.

hope this will help

Read only

Former Member
0 Likes
1,947

Hi,

can you compare you code with this :

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

Br,

Laxmi