cancel
Showing results for 
Search instead for 
Did you mean: 

Query regarding the usage of IF condition with OR in SAPScript

Former Member
0 Kudos

Hi All,

I am using an IF condition in main window of the sapscript.

I am writing it as

/: if &itab-fld1& ne 'f1' or &itab-fld2& ne 'f2' or &itab-fld3& ne 'f3'

call some include..

/:endif

Now, when i am testing it, during debugging, i found out that, the if condition is working fine for the first field and its not working for the remaining fields i.e., even though the second field condition is satisfied, the control is still coming inside the code and the include is getting called. The same is with checking the third field also. I am not able to understand why, I cehcked out the syntax for the if statement but its fine.

Can anybody please help out whats wrong.

Regards,

Priya

Accepted Solutions (1)

Accepted Solutions (1)

JozsefSzikszai
Active Contributor
0 Kudos

instead of OR you have to use AND:

/: IF &itab-fld1& NE 'f1' AND &itab-fld2& NE 'f2' AND &itab-fld3& NE 'f3'

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Eric,

the AND condition worked. Thank you very much man.

Priya

Former Member
0 Kudos

Hi Eric,

thanks for the answer.

But if we use "and" condition, because we want to call the include if either of the 3 fields are checked,

will it work?

I just have a doubt. Please help me out

REgards

Priya

JozsefSzikszai
Active Contributor
0 Kudos

I just realised that you compare different field with different values, so my first advise is not necessarly OK, still you can give it a try!. It would be best that you describe what you want to achieve, than I can come up with a solution