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: 

issue with spell_amount

pashasapcha
Participant
0 Kudos
720

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.
11 REPLIES 11

DominikTylczyn
Active Contributor
0 Kudos
585

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

matt
Active Contributor
585

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.

585

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.

585

matthew.billingham that will work too of course - I'm just an old dog.

585

pashasapcha You need to get the output of the function into a variable of the SPEEL type, then get the spelled amount out of the WORD field. Check the documentation of the function. It points to the RF_SPELL report that contains a sample call to the function.

585

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.

matt
Active Contributor
585

sandra.rossi I've used CONV many times with FM.

0 Kudos
585

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.

585

sandra.rossi I guess you meant CONV #( ) which is not possible with FMs as it cannot derive the type statically.

matt
Active Contributor
585

christian.guenter

as it cannot derive the type statically.

It could try! 😄

Sandra_Rossi
Active Contributor
585

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.