To write formulas containing several nested IIF( ) statements, use the following syntax:
*SELECTCASE {expression}
*CASE {value1}[,{value2},…]
{formulas}
[*CASE {value1}[,{value2},…]
{formulas}
[*CASEELSE]
{formulas}
*ENDSELECT
where
{expression}
is the condition to be evaluated
{value1},..
is the range of comma-delimited results that satisfy the condition for the current case
With such structure the readability of a logic statement can be significantly improved.
Example
*BEGIN
#A = IIF([ACCOUNT].[E]=1 OR [ACCOUNT].[E]=2,X+Y,
IIF([ACCOUNT].[E]=3 OR [ACCOUNT].[E]=4,X-Y,X*Y))
*END
#C = IIF([ACCOUNT].[E]=1 OR [ACCOUNT].[E]=2,W+Z,null)
#B = IIF([ACCOUNT].[E]=3 OR [ACCOUNT].[E]=4,W*Z,null)
The following formulas could be written as follows:
*SELECTCASE [ACCOUNT].[E]
*CASE 1,2
#A=X+Y
#C=W+Z
*CASE 3,4
#A=X-Y
#B=W*Z
*CASEELSE
#A=X*Y
*ENDSELECT
Note
SELECTCASE structures currently CANNOT be nested.
Any software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system environment. The Code is only intended to better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or by its gross negligence.