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

offset too long

Former Member
0 Likes
1,186

Hello experts,

I tryed to execute the following lines of code, but I get an error message saying something like "offset too long".

-


DATA: str1(60) TYPE c,

len type i,

spcarr(60) type c value

'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@&()_-+=|\:;",./'.

str1 = TRAN_STRUCTURE-DBBUSNAME.

REPLACE ALL OCCURRENCES OF '`' IN

str1 WITH ''''.

len = strlen( str1 ).

do len times.

if str1+sy-index(1) na spcarr. <<<< error here!

clear str1+sy-index(1).

endif.

enddo.

RESULT = str1.

-


Any suggestions

Thanks

hiza

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,071

You need another variable of type i.

data startpos type i.

do len times.

startpos = sy-index - 1.

if str1+startpos(1) na spcarr. <<<< error here!

clear str1+startpos(1).

endif.

enddo.

8 REPLIES 8
Read only

Former Member
0 Likes
1,071

I have executed you r code and am not getting any error. Can you check in DEBUG mode where exactly you are getting error ad let me know.

ashish

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,071

I tried to execute this, but result wasnt defined, i guess this is a function module.

Second,

str1 = TRAN_STRUCTURE-DBBUSNAME.

is not a valid abap statement. Qre quotes missing?

Read only

0 Likes
1,071

This code is placed inot a transfer routine of SAP BW!

TRAN_STRUCTURE-DBBUSNAME represents a field of a table and is character string.

Since this is a ABAP-problem I thought it would be reasonable to place my quetion in this forum.

hiza

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,071

Try this.

do len times.
if len = sy-index.
exit.
endif.
if str1+sy-index(1) na spcarr. <<<< error here!
clear str1+sy-index(1).
endif.
enddo.

Regards.

Rich Heilman

Read only

Former Member
0 Likes
1,071

Hi,

Lets say if the String length is 50, then LEN field will have 50 value.

the statment if str1sy-index(1) na spcarr.. lets take the last record, then here, in this line it will become if str150(1) na spcarr. so there is no 51st charecter in the feild STR1, so it it giving the error.

len = strlen( str1 ).

len = len - 1.

do len times.

if str1+sy-index(1) na spcarr. <<<< error here!

clear str1+sy-index(1).

endif.

enddo.

Regards

Sudheer

Read only

Former Member
0 Likes
1,072

You need another variable of type i.

data startpos type i.

do len times.

startpos = sy-index - 1.

if str1+startpos(1) na spcarr. <<<< error here!

clear str1+startpos(1).

endif.

enddo.

Read only

0 Likes
1,071

So if I loop an array "ABCD", str1+sy-index(1) starts with "B" and not "A"!

hiza

Read only

0 Likes
1,071

Correct. When you say stringstartpos(offset), startpos indicates where you are starting and offset indicates the length of the string you want from out of the total string. So for the first character you are starting at zero position and you want 1 character which would be string0(1).