10-18-2007 11:33 AM
hi,
there is a filed lv_var1 which has value '9,999 PC' it can have vlause in this manner also '3,333,333 PC'
so my requirement if to pick up the numbers from the filed ie 9999 in first case and 3333333 in second case ..
how can i do it..?
thnx..
Message was edited by:
neha gupta
10-18-2007 11:45 AM
Hi Neha,
Use SPLIT command or Check demo program DEMO_MOD_TECH_FB_STRING_SPLIT .
Thanks
Lakshman
10-18-2007 11: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.
10-18-2007 11:49 AM
Hi
U can use search command and find that string and split the text into another field. Then u will remain with only numbers.
Regards
Haritha.
10-18-2007 11:50 AM
Hi
You can use the belowing code if lv_var1 is a character variable...
replace all occurences of 'pc' in lv_var1 with space .
10-18-2007 11:57 AM
hi,
first split iv_var1 on space character to value and the rest.
second split value to start and end on comma.
repeat second step until end is blank concatenating end to start.
DATA: i(40),
start(40),
end(40),
value(40),
rest(40),
right(40).
START-OF-SELECTION.
i = '3,333,333,333,333,333 PC'.
SPLIT i AT ' ' INTO value rest.
WRITE:/ 'i =', i.
WRITE:/ 'value =', value.
WRITE:/ 'rest =', rest.
DO.
REPLACE ',' WITH '' INTO value.
IF sy-subrc NE 0.
EXIT.
ENDIF.
SKIP 1.
WRITE:/ 'value =', value.
ENDDO.
CONDENSE value NO-GAPS.
SKIP 1.
WRITE:/ 'value =', value.
WRITE value TO right RIGHT-JUSTIFIED.
WRITE:/ 'right =', right.
10-18-2007 11:58 AM
hi neha,
use split command to seperate a string.
ex: data: v_var(20) type c,
v_var2(10) type c,
v_var3(2) type c.
v_var = '3,333,333 PC'.
split v_var at space into v_var2 v_var3.
<b><i>Reward points if useful</i></b>
Chandra
10-18-2007 12:04 PM
len = strlen (lv_var1).
len = len - 2.
lv_var1 = lv_var1+0(len).
now lv_var1 will hav wat u want..
Hope this solves ur doubt
Reward points if useful