Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
JerryWang
Product and Topic Expert
Product and Topic Expert
6,097

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.



Most of the time you have to debug. ( Of course you can use source code scan 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 familiar 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.




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.



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?

27 Comments
Labels in this area