2005 Nov 25 12:19 PM
Hi All
How to convert number which is stored as string or character type into integer.
Regards
Archana.
2005 Nov 25 12:22 PM
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
2005 Nov 25 12:22 PM
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
2005 Nov 25 12:23 PM
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.
2005 Nov 25 12:23 PM
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
2005 Nov 25 12:25 PM
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
2005 Nov 25 12:41 PM
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