01-18-2013 2:19 AM
hi abapers
/h
in smartforms i want to display amount in words in rupees only and rupees and paise only. for example if the amount is 51.50 it is displaying fifty one rupees and fifty paise only correctly. if the amount is 51.00 it is displaying fifty one rupees and. i want to remove the and. below is my code.
FORM convert_cmount_into_word.
** amount = wa_head-po_value.
DATA : inp_amt LIKE j_1itaxvar-j_1itaxam1,
out_amt LIKE j_1itaxvar-j_1itaxam1.
CLEAR : inp_amt. " = wa_head-po_value.
inp_amt = wa_head-zgtot.
amount = inp_amt.
CLEAR : wa_head-zgtot.
wa_head-zgtot = inp_amt.
IF ekko-waers = 'INR'.
* To convert amount into word for INR (Rupees) - FM name is HR_IN_CHG_INR_WRDS
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
amt_in_num = amount
IMPORTING
amt_in_words = amt_in_word
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.
" code added by nag
REPLACE 'Rupees' WITH 'Rupees And ' INTO amt_in_word.
* CONCATENATE amt_in_word 'Rupees ONLY' INTO amt_in_word SEPARATED BY space.
REPLACE 'Paise' WITH 'Paise Only ' INTO amt_in_word.
* CONCATENATE amt_in_word 'Paise ONLY' INTO amt_in_word SEPARATED BY space.
" end
wa_head-amt_wrd = amt_in_word.
ELSE.
* To converT amount into word for Forigen currency - FM name is SPELL_AMOUNT
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = amount
currency = ekko-waers
* FILLER = ' '
language = sy-langu
IMPORTING
in_words = amtinword
EXCEPTIONS
not_found = 1
too_large = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
amt_in_word = amtinword-word.
wa_head-amt_wrd = amt_in_word.
ENDIF.
ENDFORM. "convert_cmount_into_word
<Priority normalized by moderator>
/h
with warm regards
nagaraj
Message was edited by: Vinod Kumar
01-18-2013 2:56 AM
Well, you can check the fractional portion of "amount" to see if has any paise/fractional portion by using FRAC function and then only print "Rupees and"
DATA: lv_frac TYPE F.
lv_frac = FRAC( amount ).
IF lv_frac = 0.
REPLACE 'Rupees' WITH 'Rupees Only ' INTO amt_in_word.
ELSE.
REPLACE 'Rupees' WITH 'Rupees And ' INTO amt_in_word.
ENDIF.
01-18-2013 3:21 AM
Hi Nagaraj,
After you get the amount in words, you could use SEARCH keyword or FIND and then use offset to check if there is any word in the string after 'Rupees'(this would check if anything is entered after the decimal point).
Please check below link
http://help.sap.com/abapdocu_70/en/ABAPFIND.htm
If there is nothing after 'Rupees', you can take the statement directly.
If the exists some value, you can go ahead with your concatenation of strings as required.
01-18-2013 5:27 AM
Hi,
You have to write the following code,
In the spell_amount function module we have In_words structure with type spell.From this we can filter the 'ZERO' by using the field DECWORD.
IF im_words-decword = 'ZERO'.
CONCATENATE im_words-word 'Rupees Only' INTO amount_words SEPARATED BY space.
ELSE.
CONCATENATE im_words-word 'Rupees and' im_words-decword 'Paise' INTO amount_words SEPARATED BY space.
WRITE:/ AMOUNT_WORDS.
ENDIF.