ā2013 Nov 20 1:50 PM
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
ā2013 Nov 20 3:16 PM
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
ā2013 Nov 20 2:05 PM
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
ā2013 Nov 20 2:16 PM
I have no idea either Max.
Not on a loop neither cycle.
Have no idea what is happening here.
ā2013 Nov 20 2:46 PM
On my system it does have this difference, I have no idea why.
ANyone with ideas?
ā2013 Nov 20 2:05 PM
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
ā2013 Nov 20 3:02 PM
Hi
Before executing FIND REGEX try to find ouit the lenght of LV_STREEN by STRLEN
Max
ā2013 Nov 20 3:23 PM
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.
ā2013 Nov 20 3:16 PM
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
ā2013 Nov 20 3:25 PM
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.
ā2013 Nov 20 3:50 PM
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
ā2013 Nov 21 9:04 AM
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!
ā2013 Nov 21 1:02 PM
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
ā2013 Nov 20 3:54 PM
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.
ā2013 Nov 21 1:01 PM
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!
ā2013 Nov 21 1:51 PM
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
ā2013 Nov 22 9:51 AM
Hi Bruno,
Thanks, will definatelly work on that ;0)
Best,
Fafa