on 05-25-2011 11:01 AM
Hi,
In the mapping I am working on the requiorement is like this
Source:HeaderComment1
Target:4440
If the value for HeaderComment1 exists in the input payloadd,then the first 35 characters of the HeaderComment1 should be mapped to the target field 4440.
But the input can consist of less than 35 characters as well.
So,if I use the Substring function with range as 0 to 35 then an exception occures.
Please help me on this.
Thanks in advance
What if it is more than 35?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
answered
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Create a User Function Definitions with the code below:
if (value.length ()> 35) {
return value.substring (0,35);
}
return value;
This will solve your problem.
Edited by: Marlon Sperandio Monteiro on May 25, 2011 10:21 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
chk this also ...
input will be "a"
execution type: single value..
if(a ! =null)
{
if(a.length()<34)
{
return a;
}
else{
return(a.substring(0,34));
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Write Logic like below
Check first HeaderComment1 exists in input paly load or nout use exists function, then check lenghth of HeaderComment1
if length leass then 35 then substring(0)done specifiy end postion else substring(35,0).
it is very simple,
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
String s = 'abcdefghijklmnopqrstuvwxyz01234567890123456789abcdefghijklmnopqrstuvwxyz01234567890123456789'
String x;
for( int i = 0; i <=34; i++)
{
x<i>=s<i>;
}
return x;
Regards
Pothana
Edited by: Pothana Yadav on May 25, 2011 12:09 PM
Edited by: Pothana Yadav on May 25, 2011 12:09 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try with this:
String input = 'abcdefghijklmnopqrstuvwxyz01234567890123456789abcdefghijklmnopqrstuvwxyz01234567890123456789';
String output;
int lenght;
lenght = Integer.parseInt(input.length());
If ( lenght < 34 )
output = input.substring(0,lenght);
else
output = input.substring(0,34);
return output;
Hi Pothana,
Thanks for the quick reply.
The condition is that there can be more than 35 characters,but if
1.the count is greater than 35,then first 35 characters should be mapped
2.the count is less than 35 then all the characters should be mapped.
I am implementing the code you provided but not getting what variables to declare
I have declared
String X.
Execution Type:All values of a context
but still I am getting an error.
Do I need to declare some other variables also?
Please help me
Thanks in advance
Follow strictly
1. Create function from Mapping editor
2. Provide Name: LimitedValue
3. Title: Capture up to 35 chars
4. Execution Type: Single Values
5. Category: User-Defined
6. Argument: InputOne
7. Click on Create Function
8. Juss write these code
if (varOne.length()> 35) {
return varOne.substring (0,35);
}
return varOne;
9. Close and Map this UDF with your source and target fields.
10. Test it.
Bye.
Follow strictly
1. Create function from Mapping editor
2. Provide Name: LimitedValue
3. Title: Capture up to 35 chars
4. Execution Type: Single Values
5. Category: User-Defined
6. Argument: InputOne
7. Click on Create Function
8. Juss write these code
if (varOne.length()> 35) {
return varOne.substring (0,35);
}
return varOne;
9. Close and Map this UDF with your source and target fields.
10. Test it.
Bye.
Hi
You can append 35 spaces to HeaderComment1 (through concat function), then use substring and trim to remove spaces.
Regards,
Giuseppe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.