2023 Oct 09 12:54 PM
Hi, gurus
I have requirement where till now the business is using 'HR_IN_CHG_INR_WRDS' to convert amount into text which is displaying
in rupees. However, now it has to be used for other currencies also
I have tried 'SPELL_AMOUNT'
but it is throwing dump as it is saying wa_head-currency is having different field type than expected.
when I double clicked on it it is of type char20 in custom structure.
But the function module parameter is of SY-WAERS following type for currency.
What can I do so that the fm spell check will give me the amount in words.
Thanks in advance.2023 Oct 09 1:33 PM
Hello pashasapcha
It looks like the CURRENCY field in your structure is incorrectly defined. It shouldn't be of CHAR20 type, but of WAERS which is dedicated for currency fields.
Why don't you declare a local variable like sy-waers, assign the currency from your structure and call SPELL_AMOUNT with that local variable - code snippet:
DATA:
lv_waers LIKE sy-waers.
lv_waers = wa_head-currency.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = amt_num
currency = lv_waers
filler = ' '
language = sy-langu
IMPORTING
in_words = wa_head-amt_in_wrds
EXCEPTIONS
not_found = 1
too_large = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Best regards
Dominik Tylczynski
2023 Oct 09 1:58 PM
Or
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = amt_num
currency = CONV syst_waers( wa_head-currency )
filler = ' '
language = sy-langu
IMPORTING
in_words = wa_head-amt_in_wrds
EXCEPTIONS
not_found = 1
too_large = 2
OTHERS = 3.
2023 Oct 09 2:11 PM
I have tried the same way, now the dump is due to length of amt_in_wrds.
I have checked the fm import parameter 'IN_WORDS'
but here SPELL is a structure with 35 fields. how can I fix the length issue so that I can avoid dump.
2023 Oct 09 2:53 PM
2023 Oct 09 3:01 PM
2023 Oct 09 5:07 PM
matthew.billingham I think constructor expressions are invalid with function module parameters. I guess SAP doesn't want to invest on the old function module concept.
2023 Oct 10 9:07 AM
2023 Oct 10 2:49 PM
matthew.billingham Thanks. I confirm (test in ABAP 7.57). Well, still learning :D. I'll test in other ABAP releases to see why I had this in mind.
2023 Oct 11 7:31 AM
sandra.rossi I guess you meant CONV #( ) which is not possible with FMs as it cannot derive the type statically.
2023 Oct 11 7:39 AM
christian.guenter
as it cannot derive the type statically.
It could try! 😄
2023 Oct 09 2:35 PM
The question title doesn't deserve this misleading title "issue with spell_amount", because it's just a dump because of different parameter/argument type, which has been asked many many times in the forum.
You must pass the same type.