‎2007 May 15 6:33 AM
Hi Everybody,
From a string of variable length how can I seperate alphabets and integers? Eagerly waiting for ur reply?
Regards,
Pulokesh
‎2007 May 15 6:47 AM
data : text(40) type c value '152as1an',
num(20),
chr(20),
pos type i,
len type i,
v_ch.
compute len = strlen( text ).
do len times.
v_ch = text+pos(1).
if v_ch ca '0123456789'.
concatenate num v_ch into num.
condense num no-gaps.
else .
concatenate chr v_ch into chr.
condense chr no-gaps.
endif.
pos = pos + 1.
enddo.
write : / num,20 chr.
regards
shiba dutta
‎2007 May 15 6:37 AM
‎2007 May 15 6:39 AM
hi Pulokesh,
Check out this way
data: v_char_field(100),
v_qty_num type rl03t-pickm.
call function 'MOVE_CHAR_TO_NUM'
exporting
chr = v_char_field
importing
num = v_qty_num
exceptions
convt_no_number = 1
convt_overflow = 2.
if sy-subrc <> 0.
"write/throw error message
endif.
2)QSS0_CHAR_FLTP_CONVERSION.
‎2007 May 15 6:46 AM
Hi,
<b>do strlen times</b> .
<b>if w_str ca sy-abcde .</b>
w_alpha = w_strw+0(1) .
<b>else</b>.
w_num = w_strw+0(1) .
<b>endif.</b>
<b>left shift w_str .</b>
<b>enddo</b>.
Regards Praveen.
‎2007 May 15 6:47 AM
data : text(40) type c value '152as1an',
num(20),
chr(20),
pos type i,
len type i,
v_ch.
compute len = strlen( text ).
do len times.
v_ch = text+pos(1).
if v_ch ca '0123456789'.
concatenate num v_ch into num.
condense num no-gaps.
else .
concatenate chr v_ch into chr.
condense chr no-gaps.
endif.
pos = pos + 1.
enddo.
write : / num,20 chr.
regards
shiba dutta
‎2007 May 15 7:31 AM
‎2007 May 15 6:48 AM
Hi karmakar,
<b>Reexecute this code....... I have just now to get your problem solved.</b>
*************************************************
parameters:
p_string(30) TYPE c.
data:
w_ints(30) TYPE c,
w_chars(30) TYPE c,
w_index TYPE i.
DO 30 TIMES.
if p_string+w_index(1) CO SY-ABCDE.
concatenate p_string+w_index(1) ' ,' w_chars INTO w_chars.
elseif p_string+w_index(1) CO '0123456789'.
concatenate p_string+w_index(1) ' ,' w_ints INTO w_ints.
endif.
w_index = w_index + 1.
ENDDO.
write: / 'Characters are :',w_chars,
/ 'Integers are :', w_ints.
*************************************************
<b>
Reward all helpful answers</b>
Regards,
V.Raghavender.
‎2007 May 15 6:54 AM
hi..
Just move the field(characters) to variable of type <b>numc</b> to get the integers only.
Then compare string with sy-abcde and the get the alphabets into another variable.
Message was edited by:
veereshbabu ponnada
‎2007 May 15 6:57 AM
Hi,
check this code.
data:char(10) value '1h3h4g4'.
data:str(10).
data:num(10).
data:len(2) type n.
data:n type n.
len = strlen( char ).
do len times.
if sy-abcde cs char+n(1).
concatenate str char+n(1) into str.
else.
concatenate num char+n(1) into num.
endif.
n = n + 1.
enddo.
write:/ str,/ num.
rgds,
bharat.