‎2007 Jun 22 8:28 AM
Hi,
I want 2 check da condition of some variable for 2 values....in If ...ENDIF.
eg.... how to write da code for
if ...a = 1 or a = 6.
.....
....
....
endif.
‎2007 Jun 22 8:31 AM
Hi I
In this case it is better to use CASE .. ENDCASE.
Eg.
CASE VAR.
WHEN 1.
<STATEMENTS>.
WHEN 2.
<STATEMENTS>.
ENDCASE.
Any how the syntax for IF .. ENDIF.
IF A = 1.
<STATEMENTS>.
ELSEIF A = 2.
<STATEMENTS>.
ENDIF.
Reward if it is useful..
‎2007 Jun 22 8:32 AM
what you have written is the code.
if a = 1 or a = 2.
endif.
Same thing achieved by a case statament would be:
case a.
when 1 or 2.
processing...
when others.
endcase.
‎2007 Jun 22 8:33 AM
Hi,
If A = 1 or A = 6. " This will work if the A value is 1 or 6.
Endif.
Regards
Sudheer
‎2007 Jun 22 8:34 AM
Hi,
U can use 'or' and 'and' if u want to put the condition for both.
IF logexp.
Effect
Used for case distinction.
Depending on whether the logical expression logexp is true or not, this statement triggers the execution of various sections of code enclosed by IF and ENDIF.
There are three different types:
IF logexp.
processing1
ENDIF.
If the logical expression is true, processing1 is executed. Otherwise, the program resumes immediately after ENDIF.
IF logexp.
processing1
ELSE.
processing2
ENDIF.
If the logical expression is true, processing1 is executed. Otherwise, processing2 is executed (see ELSE).
IF logexp1.
processing1
ELSEIF logexp2.
processing2
ELSEIF ...
...
ELSE.
processingN
ENDIF.
If the logexp1 is false, logexp2 is evaluated and so on. You can use any number of ELSEIF statements. If an ELSE statement exists, it always appears after all the ELSEIF statements.
Notes
All IF statements must be concluded in the same processing block by ENDIF.
IF statements can be nested as many times as you like.
The IF statement does not directly affect the selection. For this purpose, you should use the CHECK statement.
regards,
pritha
‎2007 Jun 22 8:36 AM
IF a = 1 or a=6.
Write your logic.
endif.
If multiple if endif, prefer CASE -ENDCASE instead of IF.
‎2007 Jun 22 8:39 AM
Hi Alexander
IF logexp.
processing1
ENDIF.
<b>If the logical expression is true, processing1 is executed. Otherwise, the program resumes immediately after ENDIF</b>
IF logexp.
processing1
ELSE.
processing2
ENDIF.
If the logical expression is true, processing1 is executed. Otherwise, processing2 is executed
IF logexp1.
processing1
ELSEIF logexp2.
processing2
ELSEIF ...
...
ELSE.
processingN
ENDIF.
If the logexp1 is false, logexp2 is evaluated and so on. You can use any number of ELSEIF statements. If an ELSE statement exists, it always appears after all the ELSEIF statements.
<b>Notes</b>
1)All IF statements must be concluded in the same processing block by ENDIF.
2)IF statements can be nested as many times as you like.
3)The IF statement does not directly affect the selection. For this purpose, you should use the CHECK statement.
<i><b>check this sample code</b></i>
IF ITAB5-KSCHL = 'NAVS' OR ITAB5-KSCHL = 'NAVM'.
ITAB1-KBETR = ITAB5-KBETR.
modify ITAB1 transporting KBETR
where KNUMV = ITAB1-KNUMV AND EBELP = ITAB1-EBELP .
ELSEIF ITAB5-KSCHL = 'FRA1' OR ITAB5-KSCHL = 'FRC1' OR
ITAB5-KSCHL = 'FRB1'.
ITAB1-KWERT = ITAB5-KWERT .
modify ITAB1 transporting KWERT
where KNUMV = ITAB1-KNUMV AND EBELP = ITAB1-EBELP
endif.Reward all helpfull answers
Regards
Pavan
‎2007 Jun 22 8:37 AM
Hi,
IF A = 1.
WRITE:/ 'A contains the value one'.
ELSEIF A = 6.
WRITE:/ 'A contains the value six'.
ENDIF.
Regards,
hari krishna