‎2007 Jan 16 11:26 AM
Hi,
I have a variable X = '>HARI<'
search itab_filein-record for c_left_bracket.
l_length = sy-fdpos.
move itab_filein-record(l_length) to samp.
Now samp contains '>HARI' since sy-fdpos returns 5.
How to avoid first character in this case. The samp should be only HARI
Regards,
Ratna
‎2007 Jan 16 11:28 AM
try this out -
data l_data(10) .
data a type i.
data len type i.
l_data = '>HARI<'.
search l_data for '<'.
a = sy-fdpos.
replace '>' with '' into l_data.
write: l_data(a).
‎2007 Jan 16 11:28 AM
try this out -
data l_data(10) .
data a type i.
data len type i.
l_data = '>HARI<'.
search l_data for '<'.
a = sy-fdpos.
replace '>' with '' into l_data.
write: l_data(a).
‎2007 Jan 16 11:32 AM
data : len type i,
pos type i,
vchar(1),
string2(20).
compute len = strlen( str1 ).
do len times.
vchar = str1+pos(1).
if vchar ne '<' or vchar ne '>'.
concatenate str2 vchar into str2.
endif.
pos = pos + 1.
enddo.
now str2 contains the required thing
regards
shiba dutta
‎2007 Jan 16 11:35 AM
Hi,
Once you get '>HARI' into samp,
replace '>' with '' into samp.
‎2007 Jan 16 11:42 AM
Hi ratna,
PARAMETER : str1(20) .
DATA : v2(20),
d TYPE i,
e TYPE i,
f type i.
DATA : check1(26) VALUE 'abcdefghijklmnopqrstuvwxyz',
check2(26) VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
d = 0.
e = 0.
*str1 = '>HARI<'.
f = strlen( str1 ).
WHILE d NE f.
IF str1d(1) CA check1 OR str1d(1) CA check2.
v2e(1) = str1d(1).
d = d + 1.
e = e + 1.
ELSE.
d = d + 1.
continue.
ENDIF.
ENDWHILE.
write : / v2.
‎2007 Jan 16 11:50 AM
Check the output with input >HARI<
parameters : val(10) type c.
data : final(10) 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'. "---->increase ur criteria with '*,.:" and so on
else.
move v to final+n(1).
endif.
n = n + 1.
enddo.
condense final no-gaps.
start-of-selection.
write:/ final.Regards,
vijay
‎2007 Jan 16 12:25 PM
hi Ratna,
this is probabaly the easiest way:
If the bracket is allways in first position you can simply add a startposition in the move statemnet (+1). do:
<i>move itab_filein-record<b>+1</b>(l_length) to samp.</i>
When you have to dynamically determine the startposition of the substring to be copied look at this example:
data: str_a(10) value 'joris bots', "source string
str_b(10), "destination string
i type integer, " start position of copy
" strlen type integer. strlength to be copied
i := 1. " determine startposition
strlen = 10. " determine length of string
strlen = strlen - i. " correct length with startposition
" (not needed if strlen does not exceed total length.
move str_a+i(strlen) to str_b. " no do the final move starting at position i,
" never exceeding the length of the source string
" no dumps or syntax errors etc
this example should produce:
str_b = 'oris bots'
Hope it helps!
Good luck
Joris Bots