Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

variable offset

Former Member
0 Likes
2,781

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,421

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).

6 REPLIES 6
Read only

Former Member
0 Likes
1,422

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).

Read only

Former Member
0 Likes
1,421

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

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,421

Hi,

Once you get '>HARI' into samp,

replace '>' with '' into samp.

Read only

Former Member
0 Likes
1,421

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.

Read only

Former Member
0 Likes
1,421

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

Read only

Former Member
0 Likes
1,421

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