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

Convert integer into string

Former Member
0 Likes
7,335

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.

8 REPLIES 8
Read only

naimesh_patel
Active Contributor
0 Likes
2,073

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

Read only

0 Likes
2,073

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

Read only

0 Likes
2,073

Check this program RF_SPELL

Read only

0 Likes
2,073

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

Read only

Former Member
0 Likes
2,073

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.

Read only

0 Likes
2,073

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

William Wilstroth
Read only

abdul_hakim
Active Contributor
0 Likes
2,073

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