cancel
Showing results for 
Search instead for 
Did you mean: 

UDf suppressing values

Former Member
0 Kudos

Hi ,

I wrote one UDf to check a field out of 3 fields  existence and pass the value which is coming. It is working fine for single value.

But when I tired to send multiple values it is suppressing the values.

Any ideas to resolve this: Please see the screesnhsot for refrence:

udf is below: with 3 input variables  . If multiple values are coming i do not want to suppress.

String field = null;

if (var1 != null)

{

field = var1;

}

else if (var2 != null)

{

field = var2;

}

else if (var3 != null)

{

field = var3;

}

return field;

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Try changing the context of the source field to its parent's parent so, that the values come in a queue without any context ..and then use Advance UDF like it is mentioned and yes... the values are in the form of String so it is advisable to use .equals() to validate string equality

Former Member
0 Kudos

i tried some thing like this but no luck:

String field = null;

if (var1 != null)

{

field = var1;

}

else if (var2 != null)

{

field = var2;

}

else if (var3 != null)

{

field = var3;

}

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

{

if (!field<i>.equalsIgnoreCase(ResultList.SUPPRESS));

{

result.addValue(field<i>);

}

}

return field;

Harish
Active Contributor
0 Kudos

Hi Jan,

from your UDF it is seems you want to pass the field var1 if value is present or check var2 or check var3. If this is the logic then try the below UDF. please input input fields with map with default (Blank)

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

{

if (!var1[i].equals(""))

{

result.addValue(var1[i]);

}

else if (!var2[i].equals(""))

{

result.addValue(var2[i]);

}

else if (!var3[i].equals(""))

{

result.addValue(var3[i]);

}

}

here input can be segment of var1, var2 and var3 or any any of the field in segment which is mand. Please make sure that all the fields including input should be in one context.

refer the wiki - UDF Execution Type - Context and Queue. - Process Integration - SCN Wiki

regards,

Harish

Former Member
0 Kudos

Not only single value...var1 can come multiple times then i need to pass all values out...same case with var 2 var3...do i need to use advanced usf or simple?

i tried ur udf i am getting this error

Function field, Line 1:

cannot find symbol symbol  : variable length location: class com.sap.aii.mapping.api.TransformationInput for (int i=0;i<input.length;i++)                     ^

Function field, Line 3:

array required, but java.lang.String found if (!var1[i].equals(""))          ^

Function field, Line 5:

array required, but java.lang.String found result.addValue(var1[i]);                     ^

Function field, Line 5:

cannot find symbol symbol  : variable result location: class com.sap.xi.tf._test_MM_ result.addValue(var1[i]); ^

Function field, Line 7:

array required, but java.lang.String found else if (!var2[i].equals(""))               ^

Function field, Line 9:

array required, but java.lang.String found result.addValue(var2[i]);                     ^

Function field, Line 9:

cannot find symbol symbol  : variable result location: class com.sap.xi.tf._test_MM_ result.addValue(var2[i]); ^

Function field, Line 11:

array required, but java.lang.String found else if (!var3[i].equals(""))               ^

Function field, Line 13:

array required, but java.lang.String found result.addValue(var3[i]);                     ^

Function field, Line 13:

cannot find symbol symbol  : variable result location: class com.sap.xi.tf._test_MM_ result.addValue(var3[i]); ^

Harish
Active Contributor
0 Kudos

Hi

you need to use advance udf (context udf).

input is the segment or input field which you need to input in udf for the context.

you can not use var1, var2 or var3 because as per your requirement they can be suppressed.

regards,

Harish

Former Member
0 Kudos

sorry for asking silly questions...appreciate your help in this:

i am taking 3 input fields to this udf...var1,var2,var3 are 3 inputs to this udf.

i am sending the screen shot please check and advice...

Any values i dont want to supress adn pass to output:

Harish
Active Contributor
0 Kudos

Hi Jan

modify the udf as below and pass all values (var1, var2 and var3) with map with default blank

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

{

if (!var1[i].equals(""))

{

result.addValue(var1[i]);

}

else if (!var2[i].equals(""))

{

result.addValue(var2[i]);

}

else if (!var3[i].equals(""))

{

result.addValue(var3[i]);

}

}

please let me know if you still phase any issue.

Also i want to know if you have a case where all the values are suppress var1, var2 and var3. Then what you want to do ?

Former Member
0 Kudos

Thanks for reply...i will give this a try....I do not want to supress any values inside this udf.

If any values coming in   then i want to pass those values as output. I do not want to supress any values within udf.

Thanks again for your time.