Code Inspector – excluding standard SAP includes
I have always been annoyed by the fact that it is impossible to exclude standard SAP code from the Code Inspector (SCI) results. In my current job (quality manager of all custom code in a 149 SAP systems landscape) it is an absolute necessity to have a code check tool I can trust to deliver only the messages I am interested in. Without the possibility to exclude standard SAP messages, it is a great tool for checking single objects, but all but useless when checking large projects or entire systems.
I have been toying with the idea of checking whether I could tweak the SCI to do my bidding, but Ian Stubbings’ blog on SCI object collectors put me on the right track finally and made me drag my lazy body off the coach and do something! To build this yourself, you first need to build a custom object collector as described in Ian’s blog. I added only one selection parameter (TP_NOSAPINCL, type CHAR1):
Then we need to make three enhancements: two to put the object collector’s new selection field into class memory and one to read that class memory and use it to exclude these irritating messages on standard SAP code. We need two enhancements to set the class memory: one for direct processing and one for parallel/background processing.
First we will build the direct processing enhancements. SAP stores the settings of the object collector in a data cluster. After retrieval of the key to the object collector in class CL_CI_OBJECTSET we create an implicit enhancement at the end of the method to put the information to the class memory.
We use this information in method HANDLE_MESSAGE of CL_CI_TESTS. Here we get the actual value of parameter TP_NOSAPINCL (also in a cluster database) that we specified in our newly created object collector. If this is set to ‘X’, we check whether the current message is for an object that is assigned to a standard SAP package. If so, we leave the method and the message will not be recorded.
Below you find the static methods and class attributes that are being used within the enhancements to suppressing the SCI messages.
The SKIP_MESSAGE method is a bit longer. I have added the code separate from the signature:
And here are the class’ attributes:
This works well when running in the foreground, but when running this in parallel or background, a function is called in a different memory session. Therefore the class memory is lost and needs to be populated in a different spot within the function module call. This time we need to read the object collection key from the cluster database ourselves (see above, method SET_CHECKSET_PARALLEL).
That’s it! This works as long as the Code Inspector can only run one inspection at a time and only one object set can be assigned to an inspection. This also takes care of removing messages from the maintenance view. In fact, it is better than the standard option to exclude maintenance view messages: that option excludes the entire function group, while it might contain custom functions as well, next to the maintenance screens!
I used a function group that has both maintenance views and function modules. Here is the result without the new option:
And here are the results with the new option. These are the messages that are valid for my work:
I am greatly interested in comments, suggestions and improvements! As this is my first blog, please be gentle 🙂 .
Roy
In SCI transaction, In object set, in object selection tab,
We have Program select option, where we can mention pattern to include and exclude Program names. Is this not better option as mentioned by me?
Hi Vipin,
thanks for the comment. In my experience with the SCI, you can select for instance FUGR ZTEST01, but if that function group contains a standard SAP include, that entire include will be checked as well. This goes for type PROG as well.
If you have succeeded in building an object set that excludes standard SAP includes from the checks, could you share your set up please?
Regards,
Roy
are u trying to exclude table maintenance generator includes from FUGR ZTEST01?
Hi Vipin,
ZTEST01 was just a bogus example. In the test I did have a function group that had both maintenance views (and all the SAP includes) and custom function modules. If you are hinting that I should use the standard option "Exclude View Maintenance Function Groups" then the entire function group will be excluded. I don't want that, I want SCI to exclude the standard SAP includes, but to include my custom functions within that group. That is what the solution in this blog does.
Roy
Other than table maintenance generated code where else SAP can create code for us? if so,then let us not mix custom FMs in table maintenance function group. then pass those function group which are just having table maintenance generated code.
People reuse SAP includes all the time, at least at the places I have worked. F.i. programmers copy function groups and add their own functions, or reuse standard SAP includes in their programmes.
And yes, in an ideal world one wouldn't mix maintenance views with custom function modules. But it happens - a lot.
Roy
thanks a lot and nice effort from your side to develop this.
Great blog Roy. I'll be extending my custom object collector to take advantage of this solution asap.
Hello Roy,
Some quality blog this - good work keep it up!
If you don't mind can you create .nugg files (i think you are aware of SAPlink) for your custom classes & attach those? 🙂
BR,
Suhas
Hi Suhas,
I am having a hard time installing the SAPlink-files: the site keeps asking me to log in, while I am logged in. Might have to do with the fact that we are still on an ancient browser level... If I succees in installing the necessary goodies I will definitely create the nuggets.
Roy
Hi,
I had the same problem some time ago and my work around was also with enchancments. I did 2 enchancments in method Handler of class CL_CI_INSPECTION
1. At beginning of method (Declaration enchancment)
DATA ls_sci LIKE EXEC_INSPECINF.
IF P_SUB_OBJ_NAME(1) <> 'Z' AND
P_SUB_OBJ_NAME(1) <> 'Y'.
ls_sci = EXEC_INSPECINF.
CLEAR: EXEC_INSPECINF, P_OBJ_TYPE, P_OBJ_NAME, P_ERRCNT, P_SUB_OBJ_TYPE,
P_SUB_OBJ_NAME, P_LINE, P_COLUMN, P_KIND, P_TEST, P_CODE,
P_PARAM_1, P_PARAM_2, P_PARAM_3, P_PARAM_4, P_CHECKSUM_1, P_SUPPRESS.
ENDIF.
2. At the end of method (code enchancment)
IF ls_sci IS NOT INITIAL.
EXEC_INSPECINF = ls_sci.
ENDIF.
This method is used to gather all errors, so with it you can filter entries that you don't want to see. My condition here is simple -> I only check Z and Y objects, but you could make it more complex. I remember that I was also excluding from checking classes that were generated by CRM and BW/BI (they are also in Z namespace) and lot of other stuff.
Best Regards
Marcin Cholewczuk
Hi Marcin,
sorry for the late reply, but I have had a bad case of sinus inflammation, but am all better now.
My problem was retrieving the setting in the Object Collector. You are using hard coding to exclude Z* and Y*. In my case, this wouldn't work when running this in the background.
But anyway, it is good to see that I am not the only one annoyed enough to go for a solution 🙂
Roy
Hi Roy,
It's quite good tool and after a lot of debugging I must say that I was written well, but it all goes about this tiny things that make using SCI uncomfortable. I was talking with people from SAP, but in their opinion everything is alright because includes are integral part of reports that are using them :/
My other problem was that it was always owner of object (person who created it) who was being notified. Even if he was not working in this company since late 90'
I just hope that this new tool that is being shown on TechED in this year will be better in mentioned areas.
Best Regards
Marcin
Thanks for sharing this technique, great first blog..
Hey,
thanks for sharing.
Is it possible to skip all SAP-standard-programs and coding completly? So that Sap-std is not even scanned?
We're using non-local-analysing deepness and Code Inspector is running for hours and hours because of the sap-std blocks.
Thank you very much!
Hi Alexander, did you manage to get a answer ?
Thanks