2012 Feb 10 3:47 AM
Hi all,
I've seen such conditions in SAP's standard coding like IF 1 = 0, IF 1 = 1 and even CHECK 1 = 0. Why such conditions?
I mean is this a right way to exit something? we can always use EXIT, right?
I'm curious because these are written in SAP standard coding...
Edited by: william wilstroth on Feb 10, 2012 11:48 AM
2012 Feb 10 4:04 AM
Hi,
Here is an example for this.
Imagine you are developing an application for a particular country, and that country is having different time zones. So in your development you need to keep in mind of all timezones. But for the time being you will develop a code for a single timezone and test it . If its working fine you can go for other timezone.
But you are writing the code similar for all the regions , except there is a change in timezone.
So the scenario is that you can copy the whole code code and enable only the corresponding timezone validation to be done. There 1=0 condition can be applied( that code will be not executed ).
And also another imp thing is that if someone need any future additions regarding timezone in your code he can just remove the 1=0 condition and test the code.
It will depend upon the client coding standards also. But usually they prefer these coding since it can be used for easy up gradation and effective testing in less time.
Regards,
Ben
2012 Feb 10 4:04 AM
Hi,
Here is an example for this.
Imagine you are developing an application for a particular country, and that country is having different time zones. So in your development you need to keep in mind of all timezones. But for the time being you will develop a code for a single timezone and test it . If its working fine you can go for other timezone.
But you are writing the code similar for all the regions , except there is a change in timezone.
So the scenario is that you can copy the whole code code and enable only the corresponding timezone validation to be done. There 1=0 condition can be applied( that code will be not executed ).
And also another imp thing is that if someone need any future additions regarding timezone in your code he can just remove the 1=0 condition and test the code.
It will depend upon the client coding standards also. But usually they prefer these coding since it can be used for easy up gradation and effective testing in less time.
Regards,
Ben
2012 Feb 10 4:43 AM
Hi,
Normally we use that condition when we want to bypass that piece of code.
2012 Feb 10 6:31 AM
Hi,
it's a good way to deactivate code but have the cross references still alive to see the code in the where-used list.
Regards,
René
2012 Feb 10 7:09 AM
Hello william,
The main purpose of such code is for "Maintainability" of the program.
Check the below link for the example.
<link to blocked site removed by moderator>
Hope this will be clear to you.
Regards,
Supriya.
Edited by: Thomas Zloch on Feb 10, 2012
2012 Feb 10 7:58 AM
Hi,
This is only for the status maintainability.It is like checking some conditions.
Karthik.R
2012 Feb 10 1:21 PM
Hi,
Personally I think it's a worthless piece of code and I see why you ask. If I were wanting to keep a piece of code around just in case I would simply comment it out so it never executed. In this way I could still refer to it later or find it in a where-used list.
Regards,
Ryan Crosby
2012 Feb 10 4:51 PM
Hi William,
So you talking about sap standard code right?
yes sap standard does have these condotions in some parts codes and some of them, are even blank, no code withing the IF ENDIF. probable reason is tht there's some code may not be used, but the programmer doesnt want to delete teh code, assuming that it may be required to be used or to be refered sometime in future, commenting it is one option but sap standard programs dont leave commented code back as it a good prctice to deleted all commented code once you have the final version of the program..
for the blank conditions , they are kind of placeholdera for adding code in future.