cancel
Showing results for 
Search instead for 
Did you mean: 

ifS and ifSWithoutElse: What is their functinality?

Former Member
0 Kudos

Hi All,

In SP 15 two new standard functions: ifS and ifSWithoutElse have been added.

How are they different from if and ifWithoutElse functions?

Could not find much about them on SAP Help.

Regards,

Anurag Mahendru.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

It has been clearly defined in the oss note

https://service.sap.com/sap/support/notes/1090369

For your benefit and the benefit of the group I am pasting the content from the above oss note

*********************Start of note**********************

Summary

Symptom

The behaviour of functions 'if' and 'ifWithoutElse' in Message-Mapping has been changed. We have changed it after we've become aware of the fact that both functions behave inconsistently with the documentation.

This change has some important consequences, which are described in this note.

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.

Other terms

Message Mapping, XI, PI, IF,IFS IFSWIthoutElse Boolean functions

Reason and Prerequisites

See above.

Solution

To provide customers with functions to use in use-case 1 above, SAP will deliver new standard functions 'ifS' and 'ifSWithoutElse'. The 'S' in the names states for 'Statement'. The new functions will be delivered in

Patch level 1 of SP21 of XITOOLS 3.0,

and SP22 onwards

Patch level 1 of SP14 of XITOOLS 7.0,

Patch level 2 of SP15 of XITOOLS 7.0

and SP16 onwards

SP05 of SAPXIESR 7.1 and SAPXIPCK 7.1,

and subsequent Support Packages of each corresponding major release.

It is not recommended to install the patches between SAP Note 1053706 and 1085331. If you decide to install a patch from Note 1085331 or any subsequent release, carefully test Message-Mappings before deploying the patch in productive systems.

In case the upgrade is necessary and Message-Mappings do not work as before, there is a possibility to workaround the problem. There's no known generic workaround for all kinds of problems that can arise.

Note :

IFS and IFSWIthoutElse functions have a Limitation.

When the The IFS and IFSWIthoutElse functions have the UDF of type Queue or Context, it will be executed unconditionally.

i.e the Queue UDF will be executed once even it does not have a matching condition in the input queue and the Context UDF will be executed once for every Context in the input queue, even if there is no matching condition in the input context.

For situation with functions leaving side-effects described above, we recommend to add a new argument to the User-Defined Function and create the side-effect conditionally based on that argument. Most probably you will want to put in this additional argument the same queue that you use in condition for function 'ifS'.

Please read the relevant Note 1158485 also.

Header Data

Release Status: Released for Customer

Released on: 30.04.2008 13:52:29

Priority: HotNews

Category: Program error

Primary Component: BC-XI-IBD-MAP Mapping

*********************End of note**********************

prateek
Active Contributor
0 Kudos

Interesting :). Thanks for sharing.

Regards,

Prateek

Former Member
0 Kudos

Thanks a lot Sameer. It was really helpful.

Answers (4)

Answers (4)

prateek
Active Contributor
0 Kudos

I think both are same. Atleast Documentation (in IR when u move pointer to it) says so.

Regards,

Prateek

Former Member
0 Kudos

Removed

Former Member
0 Kudos

Hi,

Their is not much of a difference between IF and IFwithoutelse.

In IF you can specify the condition and also provide the details of the true and false path whereas in IFwithout else you can specify only the true path.

Regards,

Nithiyanandam

santhosh_kumarv
Active Contributor
0 Kudos

removed

Edited by: Sãnthosh Kûmãr V on Aug 11, 2008 4:08 PM