cancel
Showing results for 
Search instead for 
Did you mean: 

Help in UDF

Former Member
0 Kudos

Hi all,

I have one filed(0...unbounded) in source side of maximum length called data.

EX:abc1234567890988...........

def3456789444499

I have to check the condition that If substring of data(ie 0 to 3 is <b>"abc"</b>) then I want the output of position 4 to position 10 of <b>"def"</b> record.

Please help me out........

Accepted Solutions (0)

Answers (5)

Answers (5)

prabhu_s2
Active Contributor
0 Kudos

Hi Nandini

Do close the thread if the post is been answered.

Former Member
0 Kudos

Hi ,

I am getting multiple array of strings from source.How can I handle those.....

All strings are either starts with abc or def....please help me

Thanks,

prabhu_s2
Active Contributor
0 Kudos

Set the context of that node to the root node. And need to use a loop stmt to traverse the data.

prabhu_s2
Active Contributor
0 Kudos

Do post your source message for the UDF. Also let us know

1. if both the strings will be in the source as in the original post

2. If ABC or DEF is missing what is the expected result and so on?

Former Member
0 Kudos

Hi ,

I am getting the input like the following(multiples.....)....

ABC12345678909888888888....

DEF66666666666666666666....

If the source field value is ABC ....I want the output of position 4 to pos to 10 of DEF record........

Thanks,

stefan_grube
Active Contributor
0 Kudos

So your xml is:

<data>abc123...</data>
<data>def123...</data>
<data>abc123...</data>
<data>def123...</data>

or is it more like:

<data>any123...</data>
<data>abc123...</data>
<data>any123...</data>
<data>def123...</data>

You should try to describe the problem as detailed as possible to get help.

Stefan

prabhu_s2
Active Contributor
0 Kudos

considering the source message:

<b><data>abc123...</data>

<data>def123...</data>

<data>abc123...</data>

<data>def123...</data></b>

check if this works:

String[] ret = new String[strA.length/2];

i=0;int j=0;

while(i<strA.length && strA<i>!=null)

{

if(strA[i++].substring(0,3).equals("abc"))

{

ret[j++] = strA<i>.substring(3, 10);

}

i++;

}

return ret;

stefan_grube
Active Contributor
0 Kudos

You should replace variable i with k.

As [ + i + ] is a command for starting italic, it is not displayed here.

Stefan

prabhu_s2
Active Contributor
0 Kudos

If you r specific of UDF then the below code shud help you

<b><i>if (s1.substring(0,2).equals("abc"))

{

return s2.substring(3,10);

}</i></b>

Former Member
0 Kudos

HI,

Use graphical mapping

field -- substring -equals = (abc) -if statement then substring(4,10) to be root.

Regards

Chilla..

udo_martens
Active Contributor
0 Kudos

Hi Nandini,

assumedly u dont need a UDF. U can achieve that with function "substring".

Regards,

Udo

Former Member
0 Kudos

Hi ,

Thanks for ur quick responses...

I have tried with substring functions...But I am getting empty output finally...

I m sure that I have used all the functions correctly...

Thanks

deviprasad_pothireddy
Active Participant
0 Kudos

Hi Nandini,

You can use the standard functions-> startsWith,substring in your message mapping.

Regards,

Deviprasad.