cancel
Showing results for 
Search instead for 
Did you mean: 

Excess text characters problem

Former Member
0 Kudos

Hi all,

My source text field can sends anything from 1- 80 characters, and I'm mapping to Idoc which can handle only 70 chars....I can't use sub-string node function here because it can send 1 character also.....and ArrayOutofbound error....

Any solution?

Thanks,

Sri

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Yes you can use the Substring function. How??

Use iflese and length function in you mapping. See first you check the length of incoming field if it is greater than 70 than substring it and map to target otherwise map it without substring.

I hope it solves your problem..

Former Member
0 Kudos

Sarvesh,

But the extra 10 character text which is coming in will be mapped to another duplicate node right....there this logic is not working....its giving:

java.lang.StringIndexOutOfBoundsException

Thanks,

Srini

Former Member
0 Kudos

>

> Sarvesh,

>

> But the extra 10 character text which is coming in will be mapped to another duplicate node right....there this logic is not working....its giving:

>

> java.lang.StringIndexOutOfBoundsException

>

> Thanks,

> Srini

Srini,

My understanding is, you should create the duplicatge node only when the length of source field is greater than 70.

So first validate the duplicate segment's parant node so that it will be created only when length is greater than 70 and after that you do the mapping of your field with same logic. By this way you can ensure that it will always have some value to pass in Substring function so that it will not throw the error "StringIndexOutOfBond".

I hope your first node is being created without any problem.

Regards,

Sarvesh

Former Member
0 Kudos

Ya the 1st node was never the problem....I will try this approach and let you know...

Thanks,

Srini

Former Member
0 Kudos

It's not working....I think I have to write UDF with exception handling for the sub- string......do you have any sample code..

Thanks,

Srini

madanmohan_agrawal
Contributor
0 Kudos

Hi,

Sample UDF to know how to use substring


int i = a.length();
if (i>70)
{
String str1 = a.substring(0,70);
return str1;
}
else
return a;

Regards,

Madan Agrawal

Edited by: Madan Agrawal on Apr 10, 2009 11:01 AM

Former Member
0 Kudos

>

> It's not working....I think I have to write UDF with exception handling for the sub- string......do you have any sample code..

>

> Thanks,

> Srini

Srini,

I don't know why it is not working, coz as per my understanding it should work with out any problems.

See, you do not have to use Substring function anymore for duplicate node. You only need to check if the length of incoming source is greater than 70 then only create the duplicate segment & then simply map the source field to target field. So in this case if incoming source field is having any value starting from 71 to 80 it will be mapped to target field.

I don't think you require any UDF for this.

Regards,

Sarvesh

Former Member
0 Kudos

Sarvesh,

See, you do not have to use Substring function anymore for duplicate node. You only need to check if the length of incoming source is greater than 70 then only create the duplicate segment & then simply map the source field to target field. So in this case if incoming source field is having any value starting from 71 to 80 it will be mapped to target field.

I'm not using any sub-string on the second segment, but its still putting the whole thing in the second field..... I used ifwithoutelse

Thanks,

Srini

Former Member
0 Kudos

Hi

while(a[0].length() >70) 
{ 
String tem = a[0].substring(0,70); 
a[0] = a[0].substring(70,a[0].length()); 
result.addValue(tem); 

if(a[0].length() < 132) 
result.addValue(tem); 

} 

context selected 


SplitBy Function

Check this

Srini

Former Member
0 Kudos

It worked in the execution type I used single value instead of using all value from context..

Thanks,

Srini

Answers (1)

Answers (1)

Former Member
0 Kudos

Srini,

Write a small UDF to check whether the character length is less than 70, if so then pass it, if not then just get the first 70 characters. its a simple UDF.

Regards,

Pavan

Former Member
0 Kudos

Pavan,

Do you have any sample code?

--

Srini