‎2007 Mar 23 9:40 AM
Hi Friends,
I need one help.
I want to fetch the particular integer values from one string...
Exp: I am having the field value like "ABCD123456" or "ABC 123456" or "ABCDE 123456".
Now i want to get the integer values. Here I need only "123456"
Thanks.
Sridhar.
‎2007 Mar 23 9:42 AM
hi,
Only digits in the string are copied when conversion from string to numc takes place. The field is right-justified and filled with trailing zeros. If the target field is too short, it is truncated from the left.
regards,
veeresh
Message was edited by:
veereshbabu ponnada
‎2007 Mar 23 9:43 AM
if v_string ca '0123456789 '.
v_number = v_string+sy-fdpos.
endif.
Regards,
Ravi
‎2007 Mar 23 9:46 AM
THIS may be useful to ur issue.
CP (Contains Pattern):
The complete string c1 matches the pattern c2 (c1 "matches" c2).
The pattern c2 can contain ordinary characters and wildcards.
'*' stands for any character string and '+' denotes any character.
If the result of the comparison is positive, the system field SY-FDPOS contains the offset of the first character of c2 in c1. The wildcard character '*' at the beginning of the pattern c2 is ignored when determining the value of SY-FDPOS.
If the result of the comparison is negative, the system field SY-FDPOS contains the length of c1.
Examples:
'ABCDE' CP 'CD' is true; SY-FDPOS = 2.
'ABCDE' CP '*CD' is false; SY-FDPOS = 5.
'ABCDE' CP '+CD' is true; SY-FDPOS = 0.
'ABCDE' CP '+CD*' is false; SY-FDPOS = 5.
'ABCDE' CP 'BD*' is true; SY-FDPOS = 1.
‎2007 Mar 23 9:57 AM
Hi Sridhar,
Here is a simple solution...
data:str type string value 'ABCD123456',
val(10) type n.
val = str.
write: val NO-ZERO .
output : 123456
Regards,
Kiran B
‎2007 Mar 23 10:27 AM
Thanks man, its really usefull..and i resolved my problem..
thanks to all who replied to my query....
Thanks,
Sridhar
‎2007 Mar 23 10:24 AM
sridhar,
Use this code...
REPORT YCHATEST1.
DATA : v_str type String,
V_len type i,
v_num type i.
start-of-selection.
v_str = 'ABCD123456'.
v_len = strlen( v_str ).
do .
v_num = v_num + 1.
if v_len eq v_num.
exit.
else.
if v_str+0(v_num) ca sy-abcde.
REPLACE v_str+0(v_num) WITH space INTO v_str.
v_num = v_num - 1 .
v_len = v_len - 1.
endif.
endif.
enddo.
Don't forget to reward if useful
‎2007 Mar 23 10:27 AM
Execute the code .
parameters : val(30) type c.
data : final(30) type c,
cnt type i,
v type c,
n type i.
cnt = strlen( val ).
do cnt times.
move val+n(1) to v.
if v ca '0123456789'.
move v to final+n(1).
endif.
n = n + 1.
enddo.
condense final no-gaps.
write:/ final .-
Never mind but you could have given a 10 pointer to kiran for his time and idea .. its just a request ..
Regards,
Vijay