Five Stars

StringIndexOutOfBoundsException: String index out of range:

Hi,

Please advise me below. Thank you!

 

I have below "out of range" problem after I run my job by using updated source

Capture.JPG

Previously I can run smoothly with below syntax

row1.BOL.substring(0,4).equals("EXDO")||row1.BOL.substring(0,4).equals("DMCQ")?"LCLshipment":"Invalid"

Can not find any clue for that.

Data sample for BOL is 

BOL
CMDUCAD0323962MB
EGLV235800292095
206739726
206756945
206783071
206671602
206535382
EGLV149800286242
HLCUHAM180317960
EXDO6810670633

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Twelve Stars

Re: StringIndexOutOfBoundsException: String index out of range:

@szhou1,use the below way and let me know?

 

StringHandling.LEN(row1.BOL)>4 &&(row1.BOL.substring(0,4).equals("EXDO")||row1.BOL.substring(0,4).equals("DMCQ"))?"LCLshipment":"Invalid"

Manohar B
Twelve Stars

Re: StringIndexOutOfBoundsException: String index out of range:

@szhou1,since your data length is less than 4 in row1.BOL for some of the values so that's way you were getting out of range" problem.

 

try the below one and let me know.

row1.BOL.length()>1 &&(row1.BOL.substring(row1.BOL.length()-1, row1.BOL.length()).equals("X")
||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("Y")
||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("Z")
||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("B"))?"Dynamic":"Invalid"

Manohar B
Tags (1)
5 REPLIES
Moderator

Re: StringIndexOutOfBoundsException: String index out of range:

Hello,

Would you mind posting your job setting screenshots on forum which will be helpful for us to address your issue?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Twelve Stars

Re: StringIndexOutOfBoundsException: String index out of range:

@szhou1,use the below way and let me know?

 

StringHandling.LEN(row1.BOL)>4 &&(row1.BOL.substring(0,4).equals("EXDO")||row1.BOL.substring(0,4).equals("DMCQ"))?"LCLshipment":"Invalid"

Manohar B
Five Stars

Re: StringIndexOutOfBoundsException: String index out of range:

Hi,

 

Thank you for your advise. I run smoothly with syntax - I am wondering why it works when I add "StringHandling.LEN(row1.BOL)>4"?

I have another question - I also have another syntax to filter if BOL# ends with letter such as "X,Y,Z,B". previously everything is good but for now it shows out of range error either. I tried to add "StringHandling.LEN(row1.BOL)>4" but NOT work.

Can you please advise me about this?

Capture.JPG

My current syntax is 

row1.BOL.substring(row1.BOL.length()-1, row1.BOL.length()).equals("X")||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("Y")||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("Z")||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("B")?"Dynamic":"Invalid" 

Twelve Stars

Re: StringIndexOutOfBoundsException: String index out of range:

@szhou1,since your data length is less than 4 in row1.BOL for some of the values so that's way you were getting out of range" problem.

 

try the below one and let me know.

row1.BOL.length()>1 &&(row1.BOL.substring(row1.BOL.length()-1, row1.BOL.length()).equals("X")
||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("Y")
||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("Z")
||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("B"))?"Dynamic":"Invalid"

Manohar B
Twelve Stars

Re: StringIndexOutOfBoundsException: String index out of range:

@szhou1,since your data length is less than 4 in row1.BOL for some of the values so that's way you were getting out of range" problem.

 

try the below one and let me know.

row1.BOL.length()>1 &&(row1.BOL.substring(row1.BOL.length()-1, row1.BOL.length()).equals("X")
||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("Y")
||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("Z")
||row1.BOL.substring(row1.BOL.length()-1,row1.BOL.length()).equals("B"))?"Dynamic":"Invalid"

Manohar B
Tags (1)