10-25-2007 7:46 AM
Hi ,
Can i use if like this.
IF X = 0 0R X = 1 OR X = 2.
WRITE :----
.
ENDIF.
if iam using like this it is using only the first condition , is there any way to compare x with all the 3 values
10-25-2007 7:49 AM
10-25-2007 7:49 AM
10-25-2007 7:49 AM
THE STATEMENT SHOULD be like below:
DATA: X TYPE I.
<b>IF X = 3 OR X = 1 OR X = 2.</b>
WRITE ....
ENDIF.
Note: spaces are important in X = VALUE
10-25-2007 7:50 AM
Hi your condition will be true of x contains any of 0 or 1 or 2. then the write will execute. It will check all 3 values..
data:
w_i type i.
w_i = 0.
if w_i = 0 or w_i = 1 or w_i = 2.
write: w_i.
endif.
w_i = 1.
if w_i = 0 or w_i = 1 or w_i = 2.
write: w_i.
endif.
w_i = 2.
if w_i = 0 or w_i = 1 or w_i = 2.
write: w_i.
endif.
What is your requirement.
10-25-2007 7:57 AM
as i said in earlier thread... u can use it..
IF X = 0 0R X = 1 OR X = 2. <b>ITS NOT CORRECT... U TYPED 0 INSTEAD OF O </b>
IF X = 0 OR X = 1 OR X = 2. <b>CORRECT ONE...</b>
YOU CAN USE OR OPERATOR FOR THIS PURPOSE...
Reward points for all useful answers...
THANKS & REGARDS
ilesh 24x7
10-25-2007 7:59 AM
Hi Karthick,
You can use the following:
1. IF X IN ( 0 , 1 , 2 ).
write :
endif.
2. if ( x = 0 or x = 1 or x = 2 )
write :
endif.
Careful in the spaces.
Reward if useful.
Regards,
Chitra
10-25-2007 8:39 AM
HI thanks for the reply,
if my condition satisfies i need come out of the if loop hw
10-25-2007 8:02 AM
THIS IS YOURS STATEMENT
<b>IF X = 0 0R X = 1 OR X = 2.</b>
THIS IS MINE
<b>IF X = 0 OR X = 1 OR X = 2.</b>
YOU HAVE A DIFFERENCE IN THESE, CORRECT THE LINE YOUR CODE RUN PERFECTLY.
REWARD IF USEFUL.
AMIT SINGLA
10-25-2007 8:06 AM
Hi,
Try this.
IF ( X = 0 ) 0R
( X = 1 ) OR
( X = 2 ).
WRITE :----
.
ENDIF.
Regards,
Prashant
10-25-2007 9:01 AM
Hi,
Write the IF ELSE statment in such a way that once the condition is satisfied it comes out..
IF time < '120000'.
WRITE: / time, 'AM' . " Here once this step is executed, control comes out of if condition
ELSEIF time > '120000' AND
time < '240000'.
time = time - 12 * 3600.
WRITE: / time, 'PM' . " Here also .. it will come out of IF condition
ELSE.
WRITE / 'High Noon'.
ENDIF.
LOOP AT ITAB.
if itab-qty = 0.
EXIT. " Use EXIT statement to come out of loop
endif.
if itab-qty = 1.
CONTINUE. " Use CONTINUE statement to skip this record & goto next record
endif.
ENDLOOP.
10-25-2007 9:21 AM
Use EXIT to come out of IF loop..
if val1 = '100' OR val1= '200' OR val1 = '300'.
<b>EXIT.</b>
else.
CONTINUE.
endif.
Cheers
ilesh 24x7