cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI - Differenxce between Boolean functions IFS and if-then-else

Former Member
0 Kudos

Hi Experts,

I have a doubt in what exactly is the difference betwwen the two Boolean Functions IFS and if-then-else, for me it is working in just the same way, so why are they differentiated? I tried a search upon their differences but could not get any satisfactory amswer. Can you please help me in this regard.

Regards,

Aniruddha

Accepted Solutions (1)

Accepted Solutions (1)

former_member854360
Active Contributor
0 Kudos

Hi Ani,

There is a difference between IF and IFS.

The behaviour of functions 'if' and 'ifWithoutElse' in Message-Mapping has been changed. Let us consider the function 'if'. The situation with 'ifWithoutElse' is analogous to it.

There are, in fact, two distinct use-cases for the function 'if':

1. One is when the function is used as an if statement. For example, consider this pseudocode:

if <condition>

value = <expression1>

else

value = <expression2>

end

In this case, one expects that the <condition> expression is evaluated first and then, depending on the value of the condition, one of the branch expressions is evaluated and assigned to variable 'value'.

2. The second use case is when the function is used as a procedure. In pseudocode:

value = if (<condition>, <expression1>, <expression2>)

In this case, all three expressions (<condition>, <expression1> and <expression2>) whould be evaluated first and the results of this expressions would be passed to function 'if', which in turn, would return one of them, depending on condition value, to be assigned to 'value' variable. This second use-case is also known in some programming languages as function 'iif'.

In Message-Mapping, the analog of evaluating an expression is advancing a pointer on one of the argument queues of a function. It turned out that the function 'if' did not consistently work either way and that the customers need both variants of the function. The SAP Note 1053706 has delivered the first patch to the function 'if'. This patch was not functionally complete and the function 'if' was patched again. The SAP Note 1085331 has delivered the finally fixed function 'if'. With this Note, the function always works as in use-case 2 above. That is, all arguments are evaluated first, then value of one of them is returned. To minimize compatibility problems with old usages, the function makes one exception to this rule: in case when evaluating one of the branches throws an Exception, the function ignores it, if the exception is in the branch that is not selected by condition.

This change in behaviour can lead to some of the Message-Mappings producing different results than before implementing the patch.

One common problem situation is when one of the branches of function 'if' contains a User-Defined function that produces side-effects. Like increments and stores a counter in 'GlobalContainer', for example. Such functions will be executed more times than before and will cause the numbering to go awry.

Please refer SAP Note : 1090369 for details.

Thanks,

Debashish Roy

Edited by: SAP_PI_D on Jun 28, 2011 4:10 PM

Answers (1)

Answers (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Have you seen this [thread|]?