‎2009 Apr 20 8:24 AM
Hi,
I have variable X. It holds value like 12MO..numeric with characters.
Now i want only 12 in X. i do not want 'MO'.
how do i achieve this???
‎2009 Apr 20 8:27 AM
Declare the varaible as type n
data: val(2) type n.
val = '12mo'.
write:/ val.
‎2009 Apr 20 8:26 AM
If you want only the 1st 2 characters, then use this sample code:
data : X type string value '12MO'.
X = X+00(02).
Write : X
Regards,
mansi.
‎2009 Apr 20 8:28 AM
thanks for the quick reply. but this text is dynamic. sometimes the numeric value is of 3 digit and one char at the last.
so the solution will not work.
‎2009 Apr 20 8:42 AM
Hello,
You can try this code:
DATA: x TYPE string VALUE '124578MO',
x1 TYPE string,
x2 TYPE string,
x3 TYPE string.
x3 = x.
DO.
x1 = x+0(1).
IF x1 CO '0123456789'.
CONCATENATE x2 x1 INTO x2.
x = x+1.
ELSE.
EXIT.
ENDIF.
ENDDO.
WRITE: x3, x2.BR,
Suhas
‎2009 Apr 20 8:27 AM
Declare the varaible as type n
data: val(2) type n.
val = '12mo'.
write:/ val.
‎2009 Apr 20 8:28 AM
‎2009 Apr 20 8:38 AM
Steps :
1. Find the string length.
2. do string lenght times.
3. if variable x()
data : c1(10) type c value '0123456789'.
do strlength times.
n = n + 1.
x(n) co c1.
if sy-subrc <> 0.
out = x(n).
exit.
endif.
enddo.
Regards
Kumar M
‎2009 Apr 20 9:19 AM
Hi,
Check this....
Data: cntr type sy-index,
temp type c,
x type char10 value '0123XTY',
reslt type char10.
cntr = 0.
do.
temp = x+cntr(1).
if temp co '0123456789'.
concatenate reslt temp into reslt.
else.
exit.
endif.
enddo.
Thanks & Regards,
Vamsi.