Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem in an IF condition

Former Member
0 Likes
867

Hi ,

I am currently doing a report and i have a query in 1 section :

i am using an IF condition

IF ( BCLASS NE 'MSVC' ) OR

( BCLASS NE 'USVC' ) .

if sy-subrc = 0.

but here BCLASS EQ MSVC but sy-subrc is getting set to 0 .

Can anyone please tell me if anything is wrong in my declaration or what could be the reason .

Thanks in advance .

1 ACCEPTED SOLUTION
Read only

former_member195698
Active Contributor
0 Likes
847

use AND condition

      • And Sy-subrc check is not required (Thanks to Rob) -- Sorry for partial answer

Edited by: Abhishek Jolly on Feb 6, 2009 5:41 PM

6 REPLIES 6
Read only

former_member156446
Active Contributor
0 Likes
847

Try this:

IF ( BCLASS NE 'MSVC' OR  BCLASS NE 'USVC' ) .
if sy-subrc = 0.

Hmm...

IF ( 'A' = '1' OR 'B' = 'C' ).
  WRITE:/ sy-subrc.
ENDIF.

Edited by: J@Y on Feb 6, 2009 11:52 AM

Read only

former_member195698
Active Contributor
0 Likes
848

use AND condition

      • And Sy-subrc check is not required (Thanks to Rob) -- Sorry for partial answer

Edited by: Abhishek Jolly on Feb 6, 2009 5:41 PM

Read only

Former Member
0 Likes
847

Not all ABAP statements set sy-subrc. "IF" is one of these.

Total Questions:  11 (10 unresolved)

While your at it, please clean up your unresolved questions.

Rob

Read only

Former Member
0 Likes
847

Hi,

Check this

IF ( BCLASS NE 'MSVC' ) AND

( BCLASS NE 'USVC' ) .

Read only

Former Member
0 Likes
847

hi,

SY-SUBRC is by default zero.

and sy-subrc is not set with respect to a if condition, so that might be the reason that sy-subrc is 0.

Hope this is helpful

Thanks

Sharath

Read only

Former Member
0 Likes
848

dont you need to use if .. else.. endif blcok completely


IF ( BCLASS NE 'MSVC' ) OR 
( BCLASS NE 'USVC' ) . 

-----  

ELSE.

---
ENDIF.