on 04-09-2013 6:37 PM
Hi SAP PI expert ,
Need below help for UDF at Node Level And field level
SAP PI mapping UDF for splitting Description field into multiple targets field
-Description length is Dynamic it can below 60 Char or can be 240 at max target field can hold 70 Chars
1
Node – - Node 1
Description (140 Char) based on the length – UDF - Target Des (70)
-Node2
-Target Des (70)
2
Node – Node 1
Description (210 Char) based on the length – UDF - - Target Des (70)
-Node2
-Target Des (70)
- Node3
-Target Des (70)
Hello,
Check this UDF:
if(!var1[0].equals(""))
{
int len = var1[0].length();
int divide = len/70;
String out = "";
int temp = 0;
if(len%70 == 0)
{
for(int i=0;i<divide;i++)
{
temp = 70*i;
out = var1[0].substring (0+temp,70+temp);
result.addValue(out);
}
}
else
{
for(int j=0;j<divide;j++)
{
temp = 70*j;
out = var1[0].substring (0+temp,70+temp);
result.addValue(out);
}
result.addValue (var1[0].substring (divide*70, len));
}
}
else
result.addSuppress();
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Satnam,
You can use like below code:
String result ="";
if(str.length > 70){
result = str.subString(0,69);
}
return result;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You want it such that the source field which contains say 140 characters has to be split into two such that first 70 go into field1 & rest into field 2. You can have a substring function as substring(0,69) for field1 & substring(70,139) for field 2. If the length is dynamic, then what is your criterion for splitting the fields. Suppose if it is 120, then are you dividing it by 2 i.e 60 each or 70 in first & 50 in second. In such cases you will need UDF.Could you please elaborate on the length for splitting.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
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.