cancel
Showing results for 
Search instead for 
Did you mean: 

Error when working with the substring

Former Member
0 Kudos

Hi,

i am getting a error when using a substring

Scenario : from Flat file to IDoc

input = 30 char

output1 = first 10 chars

output2 = last 4 chars

when my input filed has the maximum number of characters say 30 in this case, then my scenerio works fine.

but if my input string has only first 6 chars, remaining all "spaces" . i get a stringindexoutof boundexception, when i post a flat file. Can anyone tell me if we are suppose to handle such conditions differently

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

In file content conversion you have to use parameter

XXX.fieldContentFormatting nothing

to keep the spaces.

Regards

Stefan

Former Member
0 Kudos

Thanks Stefan.. my issue got solved.

thanks to everybody

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

you could do it like:

> if input.length >= 10 char

> output1 = first 10 chars

> else output1 = input

> if input.length >= 4 chars

> output2 = last 4 chars

> else output2 = input

Regards

Patrick

SudhirT
Active Contributor
0 Kudos

You can handle this condition in the Graphical mapping or with the use of UDF. Make sure with the functional team that how the data is coming in source file. Or always put an condition in UDF like if(a.length > n) then write your code.

Thanks!