cancel
Showing results for 
Search instead for 
Did you mean: 

AND Function becomes inconsistent after updating

Former Member
0 Kudos

Dear SDN Gurus,

in last week the PI of customer is updated from 7.11 SP 05 to 09. After updating some mappings do not work correctly.

 

After analysis i got the reason, the AND Function does not work as before.

 

Here is the screenshots:

The above screenshot is the queue context of AND Function in PI product system, which is still on PI 7.11 SP 05.

 

You can see, from position 27 the output of AND function are “false”, although the and:in1 are empty. This behavior conforms to
the standard function description in SAP Help Documentation:
R is true if X and Y have the value true. Otherwise, R is false.

But, after updating in Development System, the AND function delivers different results:

From the above screenshot you can see the AND function does not give out false value although the inputs are same.

This phenomenon does exist in not only one mapping, but in several mappings, i.e.:

The above screenshot shows the ADN behavior before updating.


Here is the effect after updating. The output values are not more false, but SUPPRESS.


I researched the internet and SAP Notes and could not find the corresponding solution or correction.  

It would be high appreciated if you can give us some instruction and helps ASAP.

Regards

Rene

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Rene,

It appears the function has become more precise now.  When an element contains null, it cannot be evaluated.  The value has to be either "true" or "false".  I believe this is a correction to the existing problem when evaluating against an element that does not exist.  In such situations, a "false" should not be generated, which assumed that both elements have either a "true" or "false" value.

I tested a similar scenario in PI 7.31 and received a similar result.

In Java, when you test the boolean of a null value, a "false" will not be generated when the value does not exist.  The function in mapping is now compatible with Java.  This happens to be what most developers expect.

As mentioned by the others in this thread, I think the best work-around for your desired result is to write an UDF.  One option is an UDF to test for the existence of the nulls and replace them with "false".

Regards,

Bill

Former Member
0 Kudos

Hi Bill,

u r right.

The SAP response is to use "mapWithDefault" function. But it does not work in my case.

Then i began to develop an UDF to handle NULL, SUPPRESS or Value.

My UDF looks like as below:

But it gives error during runtime.

Could you help me out?

Thanks a lot!

Regards

Rene

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>But it gives error during runtime.

What is your error?  You might want to check  !var1[i].equals(null)  as first condition in if block and else if block always...

Former Member
0 Kudos

There are different ways to accomplish this.  You can build a complex UDF or you can use a simple UDF and supplement it with some standard functions.  The reason is that it is much easier to develop an UDF if the context is removed.  In my example below, I revmoved the context first and use a UDF.  Afterward, I insert the context back in.

The UDF code:

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

int lenVar1 = var1.length;
int lenOutput1 = output1.length;
int lenDefault = lenVar1 - lenOutput1;
for (int i=0; i<lenOutput1; i++)
  result.addValue(output1[i]);

for (int i=0; i<lenDefault; i++)  {
  result.addValue("false");
}

}

Former Member
0 Kudos

Hi Bill,

thank u very much for your tip! I developed own UDF: myAnd to replace empty contexts with default value.

But now I have a new problem with <null> und SUPPRESS.

What I want to do is very simle: a UDF: myMapWithDefault.

Here is my coding:

I think it must be very easy to understand.

Anyway it works with <null> and SUPPRESS not as expected:

It would be highly appreciated if you can help me optimize our UDF to handle null and SUPPRESS.

Best Regards

Rene

Former Member
0 Kudos

Is this what you are expecting?

Code:

Former Member
0 Kudos

Hi Bill,

u r great! Now it works fine.

throguh this case i know that in Java "equals" is not "==".

This small detail cost me over 3 days... Finally solved.

Thank u very much and nice weekend!

Rene

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Nageschwar and Baskar,

Thanks for the suggestoin!

the Basis has written OSS to SAP and waiting for answers. As you said, I do not think an UDF is a good solutino at present. If sap cannot correct it. i will change my mapping logic or develope an UDF.

I will update u!

Regards

Rene

former_member223322
Active Participant
0 Kudos

Hi,

I tested this scenario in PI7.0 SP15 and got the same result as Li (PI7.31). So does this AND function works unlikely in PI7.11?

~Srini

baskar_gopalakrishnan2
Active Contributor
0 Kudos

The screenshot shows that you get weird output from boolean AND Function.  You can write UDF using java logical operator && to achieve this functionality for now. Meantime talk to SAP and see what you are missing in this latest upgrade.

nageshwar_reddy
Contributor
0 Kudos

Hi , i think you should raise an an oss message and see what sap has to say. From the sap help documentation, i did not see any change in functionality.

Other option you can try is to write a custom function that behaves like standard one. (Not a good option). Please keep the forum posted on solution you use.