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

Runtime Error when splitting strasse

Former Member
0 Likes
1,589

Check this one:

DATA:

lv_street TYPE string,       

lv_numb   TYPE string,        

lv_compl  TYPE string,        

lv_off    TYPE i.

lv_street = 'Avenue Boulevard 235 C'.

FIND REGEX '(\d+)\s*(.*)' IN lv_street SUBMATCHES lv_numb lv_compl  MATCH OFFSET lv_off.   lv_street = lv_street(lv_off).

CONDENSE: lv_street, lv_numb, lv_compl.

WRITE:/ lv_street,         / lv_numb,         / lv_compl.

I am having issue now that I am testing to all employees. 

Issue is right here.     

lv_street = lv_street(lv_off).  

Run time error. Lenght is too long. 

However, this lenght (13) exceeded the current lenght of the string (7) This kind of access is illegal . 

Anyone to help please?

Category: Abap programming error Runtime errors: STRING_LENGTH_TOO_LARGE Exp. CX_SY_RANGE_OUT_OF_BOUNDS

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,460

So, from documentation on "MATCH OFFSET moff

If the search is not successful, moff retains its previous value.

Any chance that your lv_off has a previously assigned, large value?

Neal

15 REPLIES 15
Read only

Former Member
0 Likes
1,460

Hi

I've tried your code in my system,,,,and no dump:

LV_STREET is long 22 char and LV_OFF is equal to 17

I don't understand why the system returns 7 as lenght of LV_STREET, but probably your code is a loop or in a cycle?

If it's so perhaps the statament fails in same case, so LV_OFF has the value of prevoius run

Max

Read only

0 Likes
1,460

I have no idea either Max.

Not on a loop neither cycle.

Have no idea what is happening here.

Read only

0 Likes
1,460

On my system it does have this difference, I have no idea why.

ANyone with ideas?

Read only

Former Member
0 Likes
1,460

Anyone to chime in?

I cannot fix the error.

Maybe another solution to split the street in 3 parts?

1st part before number

2nd part number

3rd part after number.

I would appreciate the help!

Thanks

F

Read only

0 Likes
1,460

Hi

Before executing FIND REGEX try to find ouit the lenght of LV_STREEN by STRLEN

Max

Read only

0 Likes
1,460

Ok, debugging and with STRLEN I have now:

LV_STREET is long 17 char and LV_OFF is equal to 15.

Do not understand where this 7 comes from. Have already looked everywhere.

Read only

Former Member
0 Likes
1,461

So, from documentation on "MATCH OFFSET moff

If the search is not successful, moff retains its previous value.

Any chance that your lv_off has a previously assigned, large value?

Neal

Read only

0 Likes
1,460

Nope, it does not have at all  Neal.

Interesting is that if I go for a set or 20 employees for an exampple, the program runs perfectly.

But if I choose all of our employees I have the issue.

Read only

0 Likes
1,460

In the dump, what is the value in the variable lv_street?

Also,  try it like this.

clear lv_off.

FIND REGEX '(\d+)\s*(.*)' IN lv_street SUBMATCHES lv_numb lv_compl  MATCH OFFSET lv_off.   lv_street = lv_street(lv_off).

Neal

Read only

0 Likes
1,460

Thank you Neal,

It was just the case of clearing lv_off first.

But now I will investigate what is happening when there is no number. Valid point by Bruno.

Thank you guys!

Read only

0 Likes
1,460

SO here's my suspicion:

Say your error occurs on record #21.  It does not have an number and is fairly short (say 10 characters).  Record #20 had a number and it was in the 15th position.  So lv_off retains the 15 but the string is only 10.  Because you are using string instead of a fixed length char variable, the max length that can be looked up on the string varies with the length of the string.  This is not so with a fixed length char.

Neal

Read only

bruno_esperanca
Contributor
0 Likes
1,460

So... how does that REGEX work? Does it look for the first number?

What happens if there is no number?

I would say your program is dumping when your program finds a strange street which has an unexpected format. Like mentioned above, try to check what values your variables had at the time of dump. I'm pretty sure it's a data problem.

Read only

0 Likes
1,460

Indeed I have issues when I have no street. But you know what, this is data quality and I will address it with the streams.

Imagine, I would have to write many lines to correct poor data ...

But Thank you Bruno!

Read only

0 Likes
1,460

Hi Fafa,

Not write lines to correct data quality, but at least your code should be robust enough not to dump when it comes across poor quality data.

I very usually write code with a comment like: "This should never happen... but if it does..."

Glad I could help.

All the best,

Bruno

Read only

0 Likes
1,460

Hi Bruno,

Thanks, will definatelly work on that ;0)

Best,

Fafa