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

Problem with FM SPELL_AMOUNT

Former Member
0 Likes
1,478

I am using Function module SPELL_AMOUNT to convert a number to word.

data:lv_no(5) TYPE i.

.

lv_no = 100.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = lv_no

CURRENCY = ' '

FILLER = ' '

LANGUAGE = SY-LANGU

IMPORTING

IN_WORDS = spell

EXCEPTIONS

NOT_FOUND = 1

TOO_LARGE = 2

OTHERS = 3

.

Example : If i Give Input as 100 then its giving O/P as 000000000000100000#ONE HUNDRED

But i need only ONE HUNDRED

Please Guide regarding this.

Regards,

Neelima.

9 REPLIES 9
Read only

agnihotro_sinha2
Active Contributor
0 Likes
1,160
              • Get amount in words

*data: lv_name type spell,

  • lv_currency type string.

*

*SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

*SELECTION-SCREEN BEGIN OF LINE.

*SELECTION-SCREEN COMMENT 10(22) text-001 FOR FIELD p_amt.

*PARAMETER: p_amt type i.

*SELECTION-SCREEN END OF LINE.

*SELECTION-SCREEN END OF BLOCK blk1.

*

*START-OF-SELECTION.

*

*CALL FUNCTION 'SPELL_AMOUNT'

  • EXPORTING

  • AMOUNT = p_amt

  • CURRENCY = 'INR'

  • FILLER = ' '

  • LANGUAGE = SY-LANGU

  • IMPORTING

  • IN_WORDS = lv_name

  • 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.

*

*WRITE: / 'The amount in words is:',lv_name-word.

*LEAVE to LIST-PROCESSING.

Read only

Former Member
0 Likes
1,160

try changing the data type to C

pk

Read only

Former Member
0 Likes
1,160

Hi,

If currency is INR use

DATA : amt   TYPE pc207-betrg VALUE '100',
       amt_w TYPE char100.

CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
  EXPORTING
    amt_in_num         = amt
  IMPORTING
    amt_in_words       = amt_w
  EXCEPTIONS
    data_type_mismatch = 1
    OTHERS             = 2.
IF sy-subrc = 0.

  WRITE amt_w.

ENDIF.

Regards

Read only

Former Member
0 Likes
1,160

Sammeta,

Your answer is in a structure and hence the long answer. If you just want the number 100, you can obtain it by writing or assigning in_words-word.

Sojan

Note : You need to dig little more deep into abap

Read only

Former Member
0 Likes
1,160

I mean the word one hundred.

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,160

>

> Example : If i Give Input as 100 then its giving O/P as 000000000000100000#ONE HUNDRED

> But i need only ONE HUNDRED

> Please Guide regarding this.

The output of the FM is a structure (spell in your case), the value ONE HUNDRED will be in field word. So you need to check spell-word (not spell, what you actually do)

Read only

Former Member
0 Likes
1,160

Here, importing parameter IN_WORDS is a table. Refer the field IN_WORDS-WORD, this will give the amount in words only. If the filler is filled with any symbol like * then the prefix and suffix of output(ONE HUNDRED) contains *s like ONE HUNDRED***************

Regards,

Kiran Bobbala

Read only

0 Likes
1,160

Hi ,

Thanks issued is solved.

Regards ,

Neelima

Read only

Former Member
0 Likes
1,160

Hello

Try after call Fm:


write: spell-word.