on 10-19-2007 10:44 AM
Hi ,
can any one help to write UDFs for the following scenarios.
my scenario is:
mail adapter---->XI---->proxy
scenario 1:
source field: subject
target field: priority
mapping logic: This uses semi-colon as separator on the Subject, and parses it to get the PRIORITY. If there are less than 4 parameters in the Subject line, then it returns NULL.
scenario 2:
source field: subject
target field: shortdescription
mapping logic: This uses semi-colon as separator on the Subject, and parses it to get the Short Description. If there are less than 4 parameters in the Subject line, then it returns NULL. Also, if there are more than 4 semi-colon separated parameters, then all the parameters after the 4th parameter are considered to be part of the Short Description.
can you please provide java code for above logic in step by step
i am new to write UDFs .
your immediate response will be appreciative
Thanks in advance.
Regards,
Raghu.
<b>solution 1:</b>
// create a function with argument 'ip'
// it will check the number of semicolon occurance; if it is less then 3 then it returns 'NULL' or the input as it is (logic - if number of semicolon lesser then 3 means number of parameter is lesser then 4)
int col_occur = 0;
String op = null;
for(int i=0; i<ip.length();i++)
{
if ( ip.charAt(i) == ';')
col_occur++;
}
if (col_occur < 3)
op = "NULL";
else
op = ip;
return op;
<b>solution 2:</b>
// create a function with argument 'ip'
// // it will check the number of semicolon occurance; if it is less then 3 then it returns 'NULL' orelse it will return parameters from 5 (logic - if number of semicolon lesser then 3 means number of parameter is lesser then 4)
int col_occur = 0;
int start_pt = 0;
String op = null;
for(int i=0; i<ip.length();i++)
{
if ( ip.charAt(i) == ';')
{
col_occur++;
if (col_occur == 4)
start_pt = i;
}
}
if (col_occur < 3)
op = "NULL";
else
op = ip.substring(start_pt+1);
return op;
Regards,
Yuva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raghu,
Can u explain your scenario requirement with a sample data?
Regards
San
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
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.