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

Function Module Help.

Former Member
0 Likes
825

Hi,

Is there any function module to convert currency into words??

FYI, I know the function modules SPELL_AMOUNT and HR_IN_CHG_INR_WRDS are used for this.

But my requirement is little different.

My requirement goes something like this :

if the amount is $23.43 or Rs 23.43 then the words should come like this :

Twenty Three dollars and forty three cents or

Twenty Three ruppes and forty three paise.

Any kind of help will be really appreciated.

Regards

Abhinab Mishra

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
793

Hi, <li>SPELL_AMOUNT is the right function module. <li>Try the sample program.

REPORT ztest.
DATA:langu      LIKE sy-langu,
     currency   LIKE payr_fi-waers VALUE 'USD',
     amount     LIKE payr_fi-rwbtr VALUE '123456789.12'.
DATA:wa_spell   TYPE spell.
CALL FUNCTION 'SPELL_AMOUNT'
  EXPORTING
    amount    = amount
    currency  = currency
    filler    = space
    language  = sy-langu
  IMPORTING
    in_words  = wa_spell
  EXCEPTIONS
    not_found = 1
    too_large = 2
    OTHERS    = 3.
IF sy-subrc EQ 0.
  DATA:full_in_words TYPE string.
  CONCATENATE wa_spell-word 'dollors' 'and' wa_spell-decword 'cents'
         INTO full_in_words
 SEPARATED BY space.
  WRITE full_in_words.
ENDIF.
Thanks Venkat.O

6 REPLIES 6
Read only

Former Member
0 Likes
793

I don't think there is any FM which handles after decimals ...

Instead split the amount and call FM separately (two times) ...

Read only

0 Likes
793

Is there any way to achieve this??

like the cents and paise??

Read only

0 Likes
793

The only way is to aplit your amount into two variables ..

split v_amount at ',' into v_f1 v_dec.

Now call FM 2 times passing the above variables ...

Concatenate both ....

Read only

Former Member
0 Likes
793

Hi Abhinab Mishra,

Try this:

DATA: v_decimal(2) TYPE n,

v_decimales(6) TYPE c.

p_amount = p_amount * 100.

v_decimal = p_amount MOD 100.

p_amount = p_amount / 100.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

amount = p_amount

currency = v_waers

language = sy-langu

IMPORTING

in_words = it_spell

EXCEPTIONS

not_found = 1

too_large = 2

OTHERS = 3.

CONCATENATE it_spell-word

'AND'

v_decimal

INTO p_total SEPARATED BY space.

Regards,

José

Read only

venkat_o
Active Contributor
0 Likes
794

Hi, <li>SPELL_AMOUNT is the right function module. <li>Try the sample program.

REPORT ztest.
DATA:langu      LIKE sy-langu,
     currency   LIKE payr_fi-waers VALUE 'USD',
     amount     LIKE payr_fi-rwbtr VALUE '123456789.12'.
DATA:wa_spell   TYPE spell.
CALL FUNCTION 'SPELL_AMOUNT'
  EXPORTING
    amount    = amount
    currency  = currency
    filler    = space
    language  = sy-langu
  IMPORTING
    in_words  = wa_spell
  EXCEPTIONS
    not_found = 1
    too_large = 2
    OTHERS    = 3.
IF sy-subrc EQ 0.
  DATA:full_in_words TYPE string.
  CONCATENATE wa_spell-word 'dollors' 'and' wa_spell-decword 'cents'
         INTO full_in_words
 SEPARATED BY space.
  WRITE full_in_words.
ENDIF.
Thanks Venkat.O

Read only

SujeetMishra
Active Contributor
0 Likes
793

Hello Abhinav,

Please split your amount at '.', and put into two variables and call SPELL_AMOUNT FM two times for each.

after that just concatenate both variable and pass it to final amount field.

FM for displaying amount after decimal is not available.

Hope above will solve your problem.

Regards,

Sujeet