cancel
Showing results for 
Search instead for 
Did you mean: 

Udf for CollapseContext

Former Member
0 Kudos

Hi all,

I need to write a UDF for CollapseContext. Has anybody coding for that.

Thanx in advance,

Thomas

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

use this UDF to get the first value from each context then use removeContext and map that to target .

create a UDF with argument a and choose context


if(a.length>0)
result.addValue(a[0]);

Do the mapping as follows


sourcefield----->UDF----->removeContext---->TargetField

Former Member
0 Kudos

If you want to use the collapsecontext in udf..

just write it like result.collapseContext...

Former Member
0 Kudos

Hi,

thank you for response. But this seems to be half of the truth. Do you have the complete code?

Former Member
0 Kudos

Hey,

crate the UDF with context

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

{

if(!a<i>.equals(ResultList.CC))

result.addValue(a<i>);

}

which will remove contexts for the passed input..

I dont have exact code of collapse context..but i think this is waht done in that..

Rajesh

Former Member
0 Kudos

Hi Thomas,

This is the code for the collapse context, CC is the UDF name

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

String v_current="";

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

{

if (var1<i>.equals(ResultList.CC))

{

i++;

}

if (var1<i> != v_current)

{

result.addValue(var1<i>);

}

v_current = var1<i>;

}

}

Here you have to send the sorted data to this UDF then its working like collapse context.

Regards

Ramesh

Former Member
0 Kudos

hi you can use the standar function ...collapsecontext.

Former Member
0 Kudos

Hi,

You got already SAP PI Provided standard Collapse Context Function.

Thanks,

Madhu