‎2008 Nov 17 7:55 AM
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.
‎2008 Nov 17 8:02 AM
Hello!
Try using FM SPELL_AMOUNT. That should solve all your problems.
Cheers!
‎2008 Nov 17 8:02 AM
Hello!
Try using FM SPELL_AMOUNT. That should solve all your problems.
Cheers!
‎2008 Nov 17 8:46 AM
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.
‎2008 Nov 17 8:05 AM
Just use the standard FM SPELL_AMOUNT. Just give the input amount and the currency type, it will output the amount in words.
‎2008 Nov 17 8:09 AM
Hi,
I tried executing your code and it is not giving me any dump. Please let us know if your problem is solved.
Regards
‎2008 Nov 17 8:34 AM
hi vinit....
thnx for reply, please check else condition. its giving dump.
regards saurabh.
‎2008 Nov 17 8:45 AM
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.
‎2008 Nov 17 8:54 AM
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.
‎2008 Nov 17 10:25 AM
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.
‎2008 Nov 17 8:11 AM
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.
‎2008 Nov 17 8:13 AM
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
‎2008 Nov 17 10:44 AM
Hi,
Use all the defination type as string instead of char or numeric.This will sort out the issue