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: 

Regarding Amount in words

Former Member
0 Kudos

Hai Experts ,

my requirement is to convert the currency field value in words for that i am using the FM 'SPELL_AMOUNT'

but that FM didnt display the value in words after decimal point.

for example if the value s 100.50 i need to display it in words as hundred rupees fifty paise but the FM

'SPELL_AMOUNT' displayed the output as hundred rupees only

is there any FM available for converting the value in words including decimal point?

With Regards,

R.dhineshraj.

1 ACCEPTED SOLUTION

faisal_altaf2
Active Contributor
0 Kudos

Hi, Raj.

Test the Sample Code Bellow This will solve out your Problem,

DATA: amt_in_words(1000).

CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
  EXPORTING
    amt_in_num               = '100.50'
 IMPORTING
   amt_in_words             = amt_in_words
* EXCEPTIONS
*   DATA_TYPE_MISMATCH       = 1
*   OTHERS                   = 2
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

WRITE: amt_in_words.

Best Regards,

Faisal

11 REPLIES 11

faisal_altaf2
Active Contributor
0 Kudos

Hi, Raj.

Test the Sample Code Bellow This will solve out your Problem,

DATA: amt_in_words(1000).

CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
  EXPORTING
    amt_in_num               = '100.50'
 IMPORTING
   amt_in_words             = amt_in_words
* EXCEPTIONS
*   DATA_TYPE_MISMATCH       = 1
*   OTHERS                   = 2
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

WRITE: amt_in_words.

Best Regards,

Faisal

0 Kudos

Hai faizal,

Thanks for your answer.This FM is working fine for indian currency but my requirement is currrency may be whatever but it has to return the value in amount in words including decimal point.

0 Kudos

HI, Raj,

Just add the following two Lines after you FM Hope will solve out this time

REPLACE 'Rupees' WITH 'Dollar' into amt_in_words.
REPLACE 'Paise' WITH 'Cents' into amt_in_words.

WRITE: / amt_in_words.

Please Reply if any issue,

Best Regards,

Faisal

0 Kudos

Hi, Raj

Above FM will not Sport more than two digits after decimal point if you have the requirement like this than please use the following way,

DATA: amount TYPE p DECIMALS 3 VALUE '100.504',
      c_amount TYPE string,
      part_1st TYPE string,
      part_2nd TYPE string,
      in_words TYPE spell,
      amt_in_words(1000).

c_amount = amount.

SPLIT c_amount at '.' into part_1st part_2nd.

CALL FUNCTION 'SPELL_AMOUNT'
 EXPORTING
   amount          = part_1st
 IMPORTING
   in_words        = in_words.
part_1st = in_words-word.
clear: in_words.
CALL FUNCTION 'SPELL_AMOUNT'
 EXPORTING
   amount          = part_2nd
 IMPORTING
   in_words        = in_words.
part_2nd = in_words-word.

CONCATENATE part_1st 'unit1' part_2nd 'unit2' into amt_in_words SEPARATED BY space.

WRITE: / amt_in_words.

Kind Regards,

Faisal

0 Kudos

hai Faizal,

thanks for your reply.if i split the amount field as two parts means it was returning the value for 2 parts in amount in words.

i have one more doubt in that coding if the currency is 'USD' it has to return first part as 100 dollars and then latter part as 50 cent but it returns only amount in words likewise it has to return the corresponding currency in words according to the entry of text in the import parameter currency to the FM 'SPELL_AMOUNT'.

is there any possibilty to do this in the FM SPELL_AMOUNT?

0 Kudos

Hi, Raj

Have you tested the above sample code after getting words of two part than we will CONCATENATE to add Dollar and Cents like bellow in above code unit1 means Dollar for US and for other countries replace accordingly same way for unit2.

CONCATENATE part_1st 'Dollar' part_2nd 'Cents' into amt_in_words SEPARATED BY space.

Best Regards,

Faisal

Former Member
0 Kudos

Check these threads for details..

Regards,

Lalit Mohan Gupta.

Former Member
0 Kudos

Hi,

check this link ..

[]

Regards.

Ansari.

former_member183990
Active Contributor
0 Kudos

Test for function group HRPAYINX

Function module HR_IN_CHG_INR_WRDS

Uppercase/Lowercase

Runtime: 1,708,765 Microseconds

Import parameters Value

AMT_IN_NUM 100.50

Export parameters Value

AMT_IN_WORDS ONE HUNDRED Rupees FIFTY Paise

hope it will help you

Former Member
0 Kudos

hi,

try this function module



fm HR_IN_CHG_INR_WRDS
 

Thanks

Arun

faisal_altaf2
Active Contributor
0 Kudos

Hi, Raj

I think have to Close this Thread Now.

Regards,

Faisal