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

Amount conversion

Former Member
0 Likes
1,415

hi all,

i m doing a program in which i have to print check, and i have to display amount in word including decimals also, but problem is that when i m converting the amount

in words then its going for dump.

code: data amt1 like BSEG-WRBTR.

data amt2(18) type c.

data amt3(13) type p decimals 2.

data amt4 like BSEG-WRBTR.

data : amt(14) type c,

amt5(2) type c.

*************here is the problem** value in regud-swnes = 4193.25

move regud-swnes to amt2.

translate amt2 using '* '.

condense amt2.

split amt2 at '.' into amt amt5.

if amt5 = '00'.

move amt to amt3.

else.

move amt2 to amt3.

endif.

move amt3 to amt4. " Here is the dump and saying that amt3 must be a number but problem is that

when i m giving amt3 type n, then its converting amount

4193.25 to 419325.00, which is wrong.

can anyone please help me.

regards saurabh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,292

Hello!

Try using FM SPELL_AMOUNT. That should solve all your problems.

Cheers!

11 REPLIES 11
Read only

Former Member
0 Likes
1,293

Hello!

Try using FM SPELL_AMOUNT. That should solve all your problems.

Cheers!

Read only

0 Likes
1,292

hi anurag,

thanks for reply, but still i m facing same problem,

code.

data amt1 like BSEG-WRBTR.

data amt2(18) type c.

data amt3(14) type n.

data amt4 like BSEG-WRBTR.

data exdrats like spell-word.

data : amt(14) type c,

amt5(2) type c.

move regud-swnes to amt2.

translate amt2 using '* '.

condense amt2.

split amt2 at '.' into amt

if amt5 = '00'.

move amt to amt3.

else.

concatenate amt amt5 into amt3 separated by '.' .

endif.

move amt3 to amt4. "Here is dump its saying that 'Unable to interpret amt3 as number'.

call function 'Z_SPELL_WORD'

exporting

amount = amt4

IMPORTING

IN_WORDS = exdrats .

please help me.

regards saurabh.

Read only

Former Member
0 Likes
1,292

Just use the standard FM SPELL_AMOUNT. Just give the input amount and the currency type, it will output the amount in words.

Read only

Former Member
0 Likes
1,292

Hi,

I tried executing your code and it is not giving me any dump. Please let us know if your problem is solved.

Regards

Read only

0 Likes
1,292

hi vinit....

thnx for reply, please check else condition. its giving dump.

regards saurabh.

Read only

0 Likes
1,292

I have tried this code in 4.7 it is not going to dump it is displaying the value u required ie, 4193.25

REPORT ZSRK_064.

DATA AMT1 LIKE BSEG-WRBTR.

DATA AMT2(18) TYPE C.

DATA AMT3(13) TYPE P DECIMALS 2.

DATA AMT4 LIKE BSEG-WRBTR.

DATA : AMT(14) TYPE C,

AMT5(2) TYPE C.

DATA : REGUD-SWNES LIKE REGUD-SWNES.

*************here is the problem** value in regud-swnes = 4193.25

REGUD-SWNES = '4193.25'.

MOVE REGUD-SWNES TO AMT2.

TRANSLATE AMT2 USING '* '.

CONDENSE AMT2.

SPLIT AMT2 AT '.' INTO AMT AMT5.

IF AMT5 = '00'.

MOVE AMT TO AMT3.

ELSE.

MOVE AMT2 TO AMT3.

ENDIF.

MOVE AMT3 TO AMT4.

WRITE : / AMT4.

Read only

0 Likes
1,292

hi srekanth,

thanx for reply, according to yr code its showing the value '419325.00' in amt4, that is wrong,

i need the value of amt4 '4193.25'. because i m calling a function module to convert it into word.

code:

DATA AMT1 LIKE BSEG-WRBTR.

DATA AMT2(18) TYPE C.

DATA AMT3(13) TYPE P DECIMALS 2.

DATA AMT4 LIKE BSEG-WRBTR.

DATA : AMT(14) TYPE C,

AMT5(2) TYPE C.

DATA : REGUD-SWNES LIKE REGUD-SWNES.

*************here is the problem** value in regud-swnes = 4193.25

REGUD-SWNES = '4193.25'.

MOVE REGUD-SWNES TO AMT2.

TRANSLATE AMT2 USING '* '.

CONDENSE AMT2.

SPLIT AMT2 AT '.' INTO AMT AMT5.

IF AMT5 = '00'.

MOVE AMT TO AMT3.

ELSE.

MOVE AMT2 TO AMT3.

ENDIF.

MOVE AMT3 TO AMT4. "Here is the dump its saying that 'unable to interpret '4193.25' as number.

call function 'Z_SPELL_WORD'

exporting

amount = amt4

IMPORTING

IN_WORDS = exdrats .

this is the code.

please help me.

regards saurabh.

Read only

0 Likes
1,292

REPORT ZSRK_064.

DATA AMT1 LIKE BSEG-WRBTR.

DATA AMT2(18) TYPE C.

DATA AMT3(13) TYPE P DECIMALS 2.

DATA AMT4 LIKE BSEG-WRBTR.

DATA : TEMPAMT LIKE REGUD-SWNES,

WA_USR01 LIKE USR01.

DATA : AMT(14) TYPE C,

AMT5(2) TYPE C.

DATA : REGUD-SWNES LIKE REGUD-SWNES.

*************here is the problem** value in regud-swnes = 4193.25

REGUD-SWNES = '4193.25'.

MOVE REGUD-SWNES TO AMT2.

TRANSLATE AMT2 USING '* '.

CONDENSE AMT2.

SPLIT AMT2 AT '.' INTO AMT AMT5.

IF AMT5 = '00'.

MOVE AMT TO AMT3.

ELSE.

MOVE AMT2 TO AMT3.

ENDIF.

*SELECT SINGLE * FROM USR01*

INTO WA_USR01

WHERE BNAME EQ SY-UNAME.

MOVE AMT3 TO TEMPAMT.

IF WA_USR01-DCPFM EQ ' ' OR WA_USR01-DCPFM EQ 'Y'.

REPLACE '.' IN TEMPAMT WITH ',' .

ENDIF.

MOVE TEMPAMT TO AMT4.

CALL FUNCTION 'Z_SPELL_WORD'

EXPORTING

AMOUNT = AMT4

IMPORTING

IN_WORDS = EXDRATS.

Read only

Former Member
0 Likes
1,292

Hi Saurabh,

You can use sample code below.

REPORT Z_SPELL.

TABLES SPELL.

DATA : T_SPELL LIKE SPELL OCCURS 0 WITH HEADER LINE.

DATA : PAMOUNT LIKE SPELL-NUMBER VALUE '1234510'.

SY-TITLE = 'SPELLING NUMBER'.

PERFORM SPELL_AMOUNT USING PAMOUNT 'USD'.

WRITE: 'NUMBERS', T_SPELL-WORD, 'DECIMALS ', T_SPELL-DECWORD.

FORM SPELL_AMOUNT USING PWRBTR PWAERS.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = PAMOUNT

CURRENCY = PWAERS

FILLER = SPACE

LANGUAGE = 'E'

IMPORTING

IN_WORDS = T_SPELL

EXCEPTIONS

NOT_FOUND = 1

TOO_LARGE = 2

OTHERS = 3.

ENDFORM. " SPELL_AMOUNT

Regards,

Amit.

Read only

Former Member
0 Likes
1,292

hi

use the following fm .....

sample code

data : l_IN_WORDS like spell.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = w_tot_val

CURRENCY = 'INR'

LANGUAGE = SY-LANGU

IMPORTING

IN_WORDS = l_IN_WORDS.

regards

sam

Read only

Former Member
0 Likes
1,292

Hi,

Use all the defination type as string instead of char or numeric.This will sort out the issue