01-30-2008 9:32 PM
In my logic I do not want to send a message out when the doc types DO NOT EQUAL either 'AB' 'AN' 'ICLP' 'LU'.
I always get confused betweeen 'OR' and 'AND'
My logic: Is it right? Is there a better way to write the code?
if i_ekko-bsart NE 'AB' or
i_ekko-bsart NE 'AN' or
i_ekko-bsart NE 'ICLP' or
i_ekko-bsart NE 'LU'.
MESSAGE E054(ZS) WITH 'Message out here'
endif.
Thank-You
01-31-2008 4:35 AM
Hi,
OR:
can be used to check whether any of the conditions are true.
ie.,
... log_exp1 OR log_exp2 OR log_exp3 ...
Effect
If you link multiple logical expressions log_exp with OR, then a new logical expression is created which is true if at least one of the logical expressions log_exp is true. Only if all logical expressions are false, then the link is false as well.
AND:
can be used to check whether all the conditons are satisfied.
... log_exp1 AND log_exp2 AND log_exp3 ...
Effect
The linking of several logical expressions log_exp with AND forms a new logical expression that is true when all logical expressions log_exp are true. If one of the logical expressions is false, then the link is also false.
You have used the right logic
Regards,
Renjith Michael.
01-30-2008 11:16 PM
Hello Tom
I get confused, too, if the conditions become too complex. Therefore I try to convert the logic and get rid of NOT conditions.
In your case the condition is: "If the doc type equals either of the following types:... then send a message."
IF ( i_ekko-bsart = 'AB' OR
i_ekko-bsart = 'AN' OR
i_ekko-bsart = 'ICLP' OR
i_ekko-bsart = 'LU' ).
MESSAGE E054(zs) WITH 'Wrong doc type' .
ELSE.
...
ENDIF.
Regards
Uwe
01-31-2008 4:35 AM
Hi,
OR:
can be used to check whether any of the conditions are true.
ie.,
... log_exp1 OR log_exp2 OR log_exp3 ...
Effect
If you link multiple logical expressions log_exp with OR, then a new logical expression is created which is true if at least one of the logical expressions log_exp is true. Only if all logical expressions are false, then the link is false as well.
AND:
can be used to check whether all the conditons are satisfied.
... log_exp1 AND log_exp2 AND log_exp3 ...
Effect
The linking of several logical expressions log_exp with AND forms a new logical expression that is true when all logical expressions log_exp are true. If one of the logical expressions is false, then the link is also false.
You have used the right logic
Regards,
Renjith Michael.