‎2007 Dec 18 10:14 PM
HI,
How to convert integer into string in ABAP.
Is there any function module or there is a way to do in ABAP itself.
Thanks.
‎2007 Dec 18 10:27 PM
If you want from INTEGER to STRING like '10' to 'TEN' than you can use FM SPELL_AMOUNT.
data: p_amt type I,
l_amt like spell.
p_amt = '10'.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = p_amt
CURRENCY = 'USD'
* FILLER = ' '
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = l_amt
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: l_amt-decword.
Regards,
Naimesh Patel
‎2007 Dec 19 4:46 AM
Hi Naimesh,
I think the FM 'SPELL_AMOUNT' will work for '0-99'.
If we want to print more than '99' then what is the solution?
Thanks,
Anil
‎2010 Jul 05 10:48 AM
‎2011 Jul 11 3:31 PM
If you use the amount variable type like PAYR_FI-RWBTR as in the [Spell_Amount function module|http://www.kodyaz.com/sap-abap/convert-numeric-value-currency-using-spell_amount.aspx] sample, you can convert amounts bigger than 100
‎2007 Dec 18 10:44 PM
If you want a var. with I data stored in C format :
DATA int_var TYPE i.
DATA chr_var(5) TYPE c.
Write int_var to chr_var.
Thanks Naimesh! I didn't have idea about the existence of FM you've just mentioned.
‎2007 Dec 19 12:04 AM
Hi Carlos,
The FM that Naimesh mentioned is usually used to spell amount and display it to cheques... I have seen that FM works in a few of my colleagues assignment on cheques...
Thanks
William Wilstroth
‎2007 Dec 19 2:55 AM
FUNCTION MODULES
http://www.erpgenie.com/abap/functions.htm
http://www.sapdevelopment.co.uk/fmodules/fmssap.htm
http://www.erpgenie.com/abap/index.htm
http://www.geocities.com/victorav15/sapr3/abapfun.html
Rewards if useful.........
Minal
‎2007 Dec 19 3:42 AM
Hi,
ABAP Supports automatic type conversion for all the data types except for type T and D.
ie..you cannot convert type T to D or viceversa.
eg.converting integer to string.
DATA: val1 TYPE i,
val2(10) TYPE c.
val2 = val1.
Cheers,
Hakim