cancel
Showing results for 
Search instead for 
Did you mean: 

need to write UDF for following scenerio in sap xi graphical mapping

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

<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

santhosh_kumarv
Active Contributor
0 Kudos

Hi Raghu,

Can u explain your scenario requirement with a sample data?

Regards

San