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: 

Incorrect output with SPELL_AMOUNT

Former Member
0 Kudos
78

hi friends, i am using SPELL_AMOUNT in a smartform. but the output is not correct. if the value is like :

1,4310,551.80

in words : US dollar four milion three hundered ten thousand five hundered fifty one and eighty thousand cents only.

2 REPLIES 2

Former Member
0 Kudos
35

part of my code is :

clear : W_T685T.

*data :l_effective like komv-kwert.
clear : l_effective.


loop at IT_T685T into W_T685T.
l_effective = l_effective + W_T685T-kwert.
endloop.

data : amount type P DECIMALS 4. 
data  :var type P DECIMALS 2. 
amount = l_effective.

if ZXEKKO-waers = 'INR'.



    CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
      EXPORTING
        AMT_IN_NUM         = amount
      IMPORTING
        AMT_IN_WORDS       = in_words-word
      EXCEPTIONS
        DATA_TYPE_MISMATCH = 1
        OTHERS             = 2.



CALL FUNCTION 'ZMMF_HR_IN_CHG_INR_WRDS'
EXPORTING
AMT_IN_NUM         = amount
IMPORTING
AMT_IN_WORDS       = in_words-word
EXCEPTIONS
DATA_TYPE_MISMATCH = 1
OTHERS             = 2.
*end


else.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT    = amount          "changed amount to var
CURRENCY  = ZXEKKO-waers
LANGUAGE  = SY-LANGU
IMPORTING
IN_WORDS  = in_words
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS    = 3.
endif.

select single * from TCURT into wa_tcurt where spras = sy-langu and WAERS =
ZXEKKO-waers.
condense in_words-word.
condense in_words-decword.

if ZXEKKO-waers <> 'INR'.
translate in_words-word to lower case.
translate in_words-decword to lower case.
translate in_words-word(1) to upper case.
concatenate wa_tcurt-ktext in_words-word 'and' in_words-decword 'only'
into in_words-word
separated by space.
find substring 'cents' in in_words-word.
if sy-subrc = 0.
replace substring 'cents' in in_words-word with space.
endif.

find substring 'only' in in_words-word.
if sy-subrc = 0.
replace substring 'only' in in_words-word with space.
endif.

concatenate in_words-word 'cents' 'only'
into in_words-word
separated by space.



else.
find substring 'Paise' in in_words-word.
if sy-subrc = 0.
replace substring 'Rupees' in in_words-word with 'and'.
else.
replace substring 'Rupees' in in_words-word with space.
endif.
translate in_words-word to lower case.
translate in_words-word+0(1) to upper case.
concatenate 'Rupees' in_words-word 'only' into in_words-word separated
by space.

*    translate in_words-word to lower case.
*    translate in_words-word(1) to upper case.
endif.

Former Member
0 Kudos
35

i have also tried to change to :

data : amount type P DECIMALS 2.

with this o/p becomes :

us dollar forty thousand one hundered five and five thousand one hundered eighty cents only.