Skip to Content
Former Member

# Operators: Or/And

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

##### Add a comment
10|10000 characters needed characters exceeded

### 2 Answers

• Best Answer
Former Member
Posted on Jan 31, 2008 at 04: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.

##### Add a comment
10|10000 characters needed characters exceeded
• Posted on Jan 30, 2008 at 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

##### Add a comment
10|10000 characters needed characters exceeded

### Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.