cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping error StringIndexOutOfBound exception

Former Member
0 Kudos

Hi all,

I'm getting this when i'm trying to display the queue for the sub-string function, i have set the starting position to zero and no.of characters to 4. So should increase the no.

RuntimeException in Message-Mapping transformation: Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: 4] in class com.sap.aii.mappingtool.flib3.TextFunctions method substring[, com.sap.aii.mappingtool.tf3.rt.Context@18913e8]

Thanks,

Srinivas

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Srini,

Which SP u r working in?

raj.

agasthuri_doss
Active Contributor
0 Kudos

Hi,

Try with out the Substring function to check whether there is Error or Not

Regards

Agasthuri Doss

Former Member
0 Kudos

SP21

Answers (4)

Answers (4)

ravi_raman2
Active Contributor
0 Kudos

Srinivas,

Can you paste the code for your subString udf here...as String indexoutOf Bounds is thrown when the string you are trying to subString is smaller than the one you expected....you can try this..get all the elements in the string..into an array and print them out with the value for each...that should tell you whats going wrong...

Hope that helps..

Regards

Ravi Raman

Former Member
0 Kudos

Ravi,

The input value is greater than the value which is given in the substring.

Substring has starting position set to 0 and no. of characters to 4 and the value I'm passing is of length '8' like 99993421

ravi_raman2
Active Contributor
0 Kudos

Srinivas..

Is this fixed..

i suggest you loop through all the values in the loop, ..catch the stringIndexOutOfBounds..and see what element its throwing the exception at..

Regards

Ravi

GabrielSagaya
Active Contributor
0 Kudos

StringIndexOutOfBoundException

Thrown by String methods to indicate that an index is either negative or greater than the size of the string. For some methods such as the charAt method, this exception also is thrown when the index is equal to the size of the string

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringIndexOutOfBoundsException.html

Also check

Former Member
0 Kudos

This may be due to

1. there is no values or characters in that place

2. value is not passed to the sub string..i.e..its empty

Can you check whether there is any string in there and check its length....

Former Member
0 Kudos

Guru,

The value is there and its greater than 4

Former Member
0 Kudos

Srini:

Can you post a screen shot or put the mapping here with the corresponding values in each fields. we can dig deeper into it

Former Member
0 Kudos

Hi Davuluri,

I think in your input field one value is less than 4 charcters. So make a display queue on the source input field. If you see a value which is less than 4 that is causing the error.

So in this case you use if--else functionality. Check the length of the input field and if the input is greater than 4 then only take the substring else pass directly.

Regards,

---Satish

former_member214364
Active Contributor
0 Kudos

Hi Srinivas,

Could you please send your UDF code. so that it would be easy to find the cause of error.

Thanks,

Jag