2005 Sep 14 7:17 AM
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
2005 Sep 14 7:20 AM
2005 Sep 14 7:22 AM
instead of 1450 pass the amount with decimals 1450.00 along with the currency key.
Regards
Raja
2005 Sep 14 7:27 AM
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
2005 Sep 14 7:37 AM
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
2005 Sep 14 7:40 AM
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
2005 Sep 14 7:40 AM
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
2005 Sep 14 8:00 AM
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
2005 Sep 14 8:03 AM
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
2007 Mar 04 8:06 AM
Hi Bala,
How did u manage to get the display as Dollars and Cents. Can you please help with the logic.
2005 Sep 14 8:10 AM
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
2005 Sep 14 8:34 AM
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
2005 Sep 14 10:04 AM
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
2007 Mar 04 8:21 AM
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
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |