‎2005 Apr 07 8:06 AM
Hi All,
How to put condition statements in SAP Script?
Regards,
Dilip
‎2005 Apr 07 8:14 AM
‎2005 Apr 08 12:18 AM
Here are some helpful hints
<b>Conditional Text: IF</b>
You can use the IF control command to specify that text lines should be printed only when certain
conditions are met. If the logical expression contained within the IF command is true, then the
text lines enclosed by the IF... ENDIF command pair are printed. Otherwise they are ignored.
<b>Syntax:
/: IF condition
::
/: ENDIF</b>
The logical expression can use the following comparison operators:
= EQ equal to
< LT less than
> GT greater than
<= LE less than or equal to
>= GE greater than or equal to
<> NE not equal to
The following logical operators can be used to combine conditions:
NOT
AND
OR
Evaluation of both the individual logical expressions and of the combinations of expressions is
performed strictly from left to right. There are no precedence rules. Bracketed expressions are
not supported.
The comparison is always performed on literal values, that is, the symbols are formatted as
character strings before they are compared. This is particularly significant in the case of program
symbols, because the formatting of these may depend on various parameters. For example, the
formatted form of a currency field employs a variable number of decimal places and a variable
decimal point symbol (a period or a comma) depending on the applicable currency key.
You can extend the IF command with the ELSE command to allow text lines to be specified that
you want to print in case the condition is false. If the condition is true, the text lines enclosed by
the IF and ELSE commands are formatted; otherwise the text lines enclosed by the ELSE and
ENDIF commands are formatted.
<b>Syntax:
/: IF condition
:
/: ELSE
:
/: ENDIF</b>
The ELSEIF command allows you to specify multiple cases.
<b>Syntax:
/: IF condition
:
/: ELSEIF condition
:
/: ELSE
:
/: ENDIF</b>
You can use any number of ELSEIF commands within one compound IF.. ENDIF control
command. The use of an ELSE command is then optional.
ALSO
<b>Finding a Match: CASE</b>
The CASE command covers a special case of the multiple case IF command. Rather than
allowing an arbitrary condition to be tested in each of the individual cases (as in the general
multiple case IF command), the CASE command allows a given symbol to be tested against
specific values until a matching value is found.
<b>Syntax:
/: CASE symbol
/: WHEN value1
:
/: WHEN value2
:
/: WHEN valuen
:
/: WHEN OTHERS.
:
/: ENDCASE</b>
The symbol in the CASE line is formatted. If its value is found in one of the WHEN lines, then the
text lines following this WHEN line are printed. If no matching value is found then the text lines
enclosed by the WHEN OTHERS line and the ENDCASE command are printed. The WHEN
OTHERS section is optional.
As with the IF command, the comparison is always performed on literal values.
Hope that helps!
Rishi