‎2010 Mar 25 1:37 PM
hello,
I have a code like below:
If <condition1>
if (variable) between value1 and Value 2.
if (variable2) between value3 and value 4.
---
---
--
endif.
endif.
else.
-
---
endif.
Now problem is even when all the three conditions are satisfying, the cursor always goes to else statement in the second half of the coding..
Any suggestions...
‎2010 Mar 25 1:53 PM
> Any suggestions...
Yes, please use tags and post the actual code here, not just pseudo code.
Thomas
‎2010 Mar 25 2:07 PM
‎2013 Nov 01 6:41 AM
I got the same problem.. let me know that how you fixed it ?
‎2013 Nov 01 7:23 AM
Hi Karthik Mrvk ,
Just remove if statements and use Case statements. It is better to use case statements when you have more than one condition to satisfy. It will improve your program performance.
Regards,
Praveen
‎2013 Nov 01 2:28 PM
Thank you Sai praveen .. and one more help.. i'm very new to ABAP.. can you tell me how to use case statement instead of IF ELSE.
this is my source code.. to find the biggest number among three .. this is working perfectly but how to do it using Case statement.. also if the two number has same value how can i process it . which is the best logic to find it . ??
REPORT ZKARTHI_BIGGESTNUMBER.
WRITE 'fINDING THE bIGGEST NUMBER'.
NEW-LINE.
*DECLARING PARA METERSS*
PARAMETERS: NUMBER1 TYPE I,
NUMBER2 TYPE I,
NUMBER3 TYPE I.
*PARAMETER DECLARATION OVER HERE*
IF ( NUMBER1 = NUMBER2 AND NUMBER1 = NUMBER3 ).
WRITE 'ALL NUMBERS ARE EQUAL'.
ELSEIF ( NUMBER1 > NUMBER2 ).
IF ( NUMBER1 > NUMBER3 ).
WRITE:'bIGGEST NUMBER IS,NUMBER1',NUMBER1.
ENDIF.
ELSEIF ( NUMBER2 > NUMBER3 ).
WRITE:'BIGGEST NUMBER IS NUMBER2',NUMBER2.
ELSE.
WRITE:'BIGGEST NUMBER IS NUMBER3',NUMBER3.
ENDIF.
Message was edited by: Karthi Mrvk
‎2010 Mar 25 1:56 PM
Hi ,
give the logc below..
if <condition1>
if (variable) between value1 and Value 2.
if (variable2) between value3 and value 4.
---
---
--
else.
-
-
endif.
endif.
endif.
now ur problem will solve..let me know still if you have any issues..
‎2015 Sep 29 7:37 AM
‎2010 Mar 25 5:20 PM
The cursor will indeed go to the ELSE statement in debug, but does it execute the code after the else, or does it then go directly to the outer ENDIF....
If I have:
IF .... <First stop.
IF.... <second stop
IF.... <third stop...
endif.
endif.
else.<eventually I get here and then I should immediately go to ENDIF, if the first IF statement is true.
....
endif...<next stop after ELSE.
‎2010 Mar 29 9:52 AM
Hi Simran,
Instead of using nested if statements in my open it is better to go with CASE statement.I am sure it is better in performance prospective of the program.
Regards,
Venkat.