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

How to convert string to integer in ABAP.

Former Member
0 Likes
40,088

Hi All

How to convert number which is stored as string or character type into integer.

Regards

Archana.

1 ACCEPTED SOLUTION
Read only

abdul_hakim
Active Contributor
0 Likes
13,978

Hi

check the below code which will convert character to integer..

DATA NO1(10) TYPE C VALUE '1234567890'.

DATA NO2 TYPE I.

NO2 = NO1.

WRITE NO2.

the foll code will convert the string to interger.

DATA NO1 TYPE STRING.

DATA NO2 TYPE I.

NO1 = '1234567890'.

NO2 = NO1.

WRITE NO2.

Regards,

Abdul

Reward points if ans is helpful...

Message was edited by: Abdul Hakim

Hi All

How to convert number which is stored as string or character type into integer.

Regards

Archana.

6 REPLIES 6
Read only

abdul_hakim
Active Contributor
0 Likes
13,979

Hi

check the below code which will convert character to integer..

DATA NO1(10) TYPE C VALUE '1234567890'.

DATA NO2 TYPE I.

NO2 = NO1.

WRITE NO2.

the foll code will convert the string to interger.

DATA NO1 TYPE STRING.

DATA NO2 TYPE I.

NO1 = '1234567890'.

NO2 = NO1.

WRITE NO2.

Regards,

Abdul

Reward points if ans is helpful...

Message was edited by: Abdul Hakim

Read only

Former Member
13,978

Hi Archana,

1. Just declare a new variable of type i.

and assign the character variable to i.

2. eg.

REPORT ac.

data : a(50) type c.

data :num type i.

a = '799'.

num = a.

write 😕 a.

write 😕 num.

Hope the above helps.

Regards,

Amit M.

Read only

0 Likes
8,192

INCORRECT

Read only

FredericGirod
Active Contributor
0 Likes
13,978

You must have to check if the value contain only number.

you could do that with a check: check w_value na sy-abdcd.

And if you want to prevent any problem, you could include your move with a catch. That will block the shortdump.

Rgd

Frédéric

Read only

Former Member
0 Likes
13,978

Hi Use this Fm to do that.

<b>CONVERT_STRING_TO_INTEGER

JUST pass string variable to this you will get int value</b>regards

vijay

Read only

0 Likes
13,978

Hi,

I don't know if it's your case, but, I guess you don't need a FM, it's is automaticly.

data: v1(8) type c ,

v2 type i .

v1 = '10' .

v2 = v1 .

att,

Alexandre Nogueira