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 in spell_amount - plz solve

Former Member
0 Likes
897

Hi Gurus..

My Problem is like this,

I want to populate the amount in full...

DATA : T_SPELL LIKE SPELL,

V_TOTAL TYPE YRATE VALUE '1985.64'.

DATA : PAMOUNT LIKE SPELL-NUMBER.

PAMOUNT = V_TOTAL.

PERFORM SPELL_AMOUNT USING PAMOUNT

WRITE: T_SPELL-WORD, 'and', T_SPELL-DECWORD.

FORM SPELL_AMOUNT USING AMOUNT.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = PAMOUNT

*CURRENCY =

FILLER = SPACE

LANGUAGE = 'E'

IMPORTING

IN_WORDS = T_SPELL

EXCEPTIONS

NOT_FOUND = 1

TOO_LARGE = 2

OTHERS = 3.

ENDFORM. "SPELL_AMOUNT

Output is like this :-

One thousand nine hundred eighty-six and zero

where as i want output as -One thousand nine hundred eighty-five and sixty four

Please Help....

Edited by: Shirish Mishra on Aug 22, 2008 3:22 PM

Edited by: Shirish Mishra on Aug 22, 2008 3:23 PM

<LOCKED BY MODERATOR - URGENT, PLEASE HELP OR SIMILAR ARE FORBIDDEN>

Edited by: Alvaro Tejada Galindo on Aug 22, 2008 4:11 PM

Hi Gurus..

My Problem is like this,

I want to populate the amount in full...

DATA : T_SPELL LIKE SPELL,

V_TOTAL TYPE YRATE VALUE '1985.64'.

DATA : PAMOUNT LIKE SPELL-NUMBER.

PAMOUNT = V_TOTAL.

PERFORM SPELL_AMOUNT USING PAMOUNT

WRITE: T_SPELL-WORD, 'and', T_SPELL-DECWORD.

FORM SPELL_AMOUNT USING AMOUNT.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = PAMOUNT

*CURRENCY =

FILLER = SPACE

LANGUAGE = 'E'

IMPORTING

IN_WORDS = T_SPELL

EXCEPTIONS

NOT_FOUND = 1

TOO_LARGE = 2

OTHERS = 3.

ENDFORM. "SPELL_AMOUNT

Output is like this :-

One thousand nine hundred eighty-six and zero

where as i want output as -One thousand nine hundred eighty-five and sixty four

Please Help....

Edited by: Shirish Mishra on Aug 22, 2008 3:22 PM

Edited by: Shirish Mishra on Aug 22, 2008 3:23 PM

<LOCKED BY MODERATOR - URGENT, PLEASE HELP OR SIMILAR ARE FORBIDDEN>

Edited by: Alvaro Tejada Galindo on Aug 22, 2008 4:11 PM

7 REPLIES 7
Read only

Former Member
0 Likes
838

Hi Shirish

You can use the FM

HR_IN_CHG_INR_WRDS

This will return the output as shown in the variable AMT_IN_WORDS

ONE THOUSAND NINE HUNDRED EIGHTY FIVE Rupees SIXTY FOUR Paise

You can modify this by removing the word Rupees and Paise

from it and the output should be as you want

replace all occurences of 'rupees' with 'and'.

replace all occurences of 'paise' with ''.

Hope this helps!

Regards,

Prashant

Edited by: Prashant H Gupta on Aug 22, 2008 8:09 PM

Read only

Former Member
0 Likes
838

Payamout (SPELL-NUMBER) has not decimals ! Try type P

I have had the same problem and call the fm twice...

l_numX type SPELL-NUMBER

l_num1 = payamout

l_num2 = ( payamout * 100 ) mod 100.

Read only

0 Likes
838

report ztest828.


DATA : T_SPELL LIKE SPELL,
V_TOTAL TYPE p decimals 2 VALUE '1985.64'.
DATA : PAMOUNT TYPE p decimals 2  .
PAMOUNT = V_TOTAL.
PERFORM SPELL_AMOUNT USING PAMOUNT.
*WRITE: T_SPELL-WORD, 'and', T_SPELL-DECWORD.

FORM SPELL_AMOUNT USING AMOUNT.

data : l_num type SPELL-NUMBER.

l_num = amount.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = l_num
*CURRENCY =
FILLER = SPACE
LANGUAGE = 'E'
IMPORTING
IN_WORDS = T_SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.


write : T_SPELL-WORD.


l_num = ( amount * 100 ) mod 100.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = l_num
*CURRENCY =
FILLER = SPACE
LANGUAGE = 'E'
IMPORTING
IN_WORDS = T_SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.


write : T_SPELL-WORD.



ENDFORM. "SPELL_AMOUNT

Read only

0 Likes
838

Hi stephan,

Now output is coming like this :-

ONE THOUSAND NINE HUNDRED EIGHTY-SIX

SIXTY-FOUR

I want ONE THOUSAND NINE HUNDRED EIGHTY-FIVE

Read only

0 Likes
838

Shirish,

I want ONE THOUSAND NINE HUNDRED EIGHTY-FIVE

Use FM ROUND before passing the value to spell_amount.

Amit.

Read only

0 Likes
838

Routine updated !

l_num = amount div 1.

report ztest828.


DATA : T_SPELL LIKE SPELL,
V_TOTAL TYPE p decimals 2 VALUE '1985.64'.
DATA : PAMOUNT TYPE p decimals 2  .
PAMOUNT = V_TOTAL.
PERFORM SPELL_AMOUNT USING PAMOUNT.
*WRITE: T_SPELL-WORD, 'and', T_SPELL-DECWORD.

FORM SPELL_AMOUNT USING AMOUNT.

data : l_num type SPELL-NUMBER.

l_num = amount div 1.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = l_num
*CURRENCY =
FILLER = SPACE
LANGUAGE = 'E'
IMPORTING
IN_WORDS = T_SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.


write : T_SPELL-WORD.


l_num = ( amount * 100 ) mod 100.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = l_num
*CURRENCY =
FILLER = SPACE
LANGUAGE = 'E'
IMPORTING
IN_WORDS = T_SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3.


write : T_SPELL-WORD.



ENDFORM. "SPELL_AMOUNT


Edited by: Stephan Kaminski on Aug 22, 2008 5:01 PM

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
838

hi Mishra

Check this piece of code....might be helpful

TABLES : spell.

DATA : w_rupees(6) VALUE 'RUPEES',

w_paisa(3) VALUE 'Ps',

w_and(3) VALUE 'AND',

w_string TYPE string.

PARAMETERS: a TYPE i.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

amount = a

    • CURRENCY = ' '*

    • FILLER = ' '*

language = sy-langu

IMPORTING

in_words = spell

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.

CONCATENATE w_rupees spell-word(128) w_and spell-decword(64) w_paisa INTO w_string SEPARATED BY space.

With Regards

Always Learner..