cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent Help Required !!!

Former Member
0 Kudos

Hi,

I have a requiremnt to map a field called source_code to area_code.

The source_code can have values like below:

Case 1 20,abc

Case 2 ,abc

Case 3 2,abc

Now i need values which are before comma in the area_code (target).

So,it means here i need to take comma as delimiter.

Also, in case 1, i need to send 20

in case 2, i need to send blank constant or null value, and

in case 3, i need to send 2.

Can somebody help me with this eitehr using Graphical mapping or UDF.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi,

You can use a single-line UDF:

return input.substring(0,input.indexOf(","));

with a single input parameter "input" of type string and Execution Type: Single Values.

Hope this helps,

Greg

Former Member
0 Kudos

Hi,

I am able to run the code now but while saving the mapping its giving me error -

the sortedFunctionKeys array contains the not valid key checkComma..

After clicking on details its giving - Internal Problem.

former_member184681
Active Contributor
0 Kudos

Hi,

Try with my source code, I already tested it and it works fine.

Hope this helps,

Greg

Former Member
0 Kudos

One more addition to the requirement...

if the input value is 201,area or anything more than 2 before comma,then i need only 2 fields in the output...

so, for 201,area ->20

Plz modify the code and tell me....

former_member184681
Active Contributor
0 Kudos

Dear Aakash Bhutani,

To have the output limited to 2 characters, simply add the standard substring function after the UDF that I described. Use Start Position = 0 and Character Count = 2 as config parameters for the substring.

Hope this helps,

Greg

Former Member
0 Kudos

Thanks everybody.....

Its working fine now....

Closing the thread !!!!!!!!!

Answers (2)

Answers (2)

Former Member
0 Kudos

chk this code:

input will be "a"

Execution type: all values of a context


for(int j=0;j<a.length;j++)
{
String [] var=a[j].split(",");
result.addValue(var[0]);
}

PriyankaAnagani
Active Contributor
0 Kudos

Hi,

Try with this simple UDF..You can also split the input string at comma and return the value.

int var1=0;

var1 = input.indexOf(',');

return input.subString(0,var1-1);

Regards,

Priyanka

Former Member
0 Kudos

Its giving me the below error:

the sortedFunctionKeys array contains the not valid key checkComma