Quantcast
Channel: ABAP Development
Viewing all articles
Browse latest Browse all 948

Do you agree to write IF 1 = 0 in your production code

$
0
0

IMHO one purpose to write IF 1 = 0 code is to enable the cross reference of message raised in application code.

 

 

I have written several blogs to discuss the tip how to find the source code where the error message in UI is raised.

 

clipboard1.png

Most of the time you have to debug. ( Of course you can use source code scann approach to search the source code with keyword CRM_MDG_CORE 034 , the trouble is how you specify the package to be scanned, especially you are not familar with the application and you know nothing about package name at all )

 

 

The where used List on message could only identify those occurrence where the MESSAGE keyword appears in code.

clipboard2.png

clipboard3.png


For the use case in line 24 and 25 below, the where used list does not work. That is when IF 1 = 0 plays a part.

clipboard4.png

Recently in our code review meeting there are some arguments about this usage. The pros like this approach since it enable the cross reference on message raising by method call and ease the maintenance. The opposition consider that it is "unreached code" and should not appear in production code.

 

 

I just check in the system and find there are plenty of such usage in SAP standard code, also I tested that currently no ATC or extended check profile will complain about this "unreached code". Would you please kindly share your opinion of using IF 1 = 0 this way? Or do you have any concern about it?


Viewing all articles
Browse latest Browse all 948

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>