cancel
Showing results for 
Search instead for 
Did you mean: 

User Defined Function Issue with Inbound Node

Former Member
0 Kudos

Hello Guys,

I have some doubts to do the some code with a UDF.

I do a call to an RFC to get some data of R/3 from PI. In the return I have:

<item>

<field1>

<field2>

</item>

The item is 0 to unbounded, and I have to do a loop at the item and take the values of field1 and field2 of the last item.

I have created a UDF with context queue, but how can I take the values

It is correct if I have?

public void calculate(String[] var1, ResultList result, Container container) throws StreamTransformationException

{

String a = "";

String b = "";

String result = "";

for ( int i = 0; i < var1.length; i++ )

{

a = var1.??

b = var1.??

}

if ( a.equals( '' ) and b.equals( 'DELE' ) )

{

result = a.

}

else

{

result = "";

}

result.addValue ( result)

}

I want to take the values of the las item for field1 and field2 in strings a and b, and after do a check of the values to put the result.

What I don't know hot to do is to take these values.

Could you help me please?

Many thanks in advance.

Regards,

Xavi.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Use removeContext just after the RFC lookup result & before the UDF. That would give you all the field values( field1 & field2) values in one context. Then use this UDF:

for(i=0;i<var1.length;i++)

{

if(i = var1.length - 1)

{

result.addValue(var1<i> ) ;

}

}

Use this same UDF for both the fields seperately.

Hope it helps.

Regards

Soumen...

Answers (1)

Answers (1)

VijayKonam
Active Contributor
0 Kudos

Have the field1 and field2 with no contexts as inputs to your UDF. Check the length of any queue (assumed to be same for both field1 and field2). Now use this length to represent the last item of the fields like field1[length-1] and field2[length-1] length. You would have last values in them. Use them where you want based on your logic.

VJ