Application Development 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: 

Why write IF 1=0 or Check 0=1?

Wil_Wilstroth
Active Participant
0 Kudos
2,820

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

William Wilstroth
1 ACCEPTED SOLUTION

Former Member
0 Kudos
724

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

7 REPLIES 7

Former Member
0 Kudos
725

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

Former Member
0 Kudos
724

Hi,

Normally we use that condition when we want to bypass that piece of code.

rene_libbert
Explorer
0 Kudos
724

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é

Former Member
0 Kudos
724

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

Former Member
0 Kudos
724

Hi,

This is only for the status maintainability.It is like checking some conditions.

Karthik.R

Ryan-Crosby
Active Contributor
0 Kudos
724

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

former_member205763
Active Contributor
0 Kudos
724

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.