Code Inspector: Dig Down Detailed

Most of the time we do developments and when it comes to checking or doing the review of the code we generally use Code Inspector and EPC i.e. Extended Program Check.
But have you ever wondered what these tools are doing behind the scene?
You can call the Code Inspector for the relevant single objects directly from the ABAP Editor (SE38), the Function Builder (SE37), or the Class Builder (SE24) (Object->Check->Code Inspector). The system then checks using a default check variant which is provided by SAP.
So in this post I will give an overview of how we can use the potentials of code inspector and how we can pin point the errors and deliver the best quality code with adherence to ABAP coding guidelines.
What is Code Inspector?
The Code Inspector is a tool for checking Repository objects regarding performance, security, syntax, and adherence to name conventions.
Using the Code Inspector (transaction code SCI), you can check individual objects or sets of objects for performance, security, syntax, and adherence to naming conventions. You can also determine statistical information or search for certain ABAP words (tokens). In the Code Inspector, you can define inspections that, with the help of check variants, examine certain sets of objects. As the result of an inspection, you receive information messages, warning messages, or error messages on different properties of the examined objects.
The range of functions in the Code Inspector is limited to checking static object definitions and can therefore only point out certain problems.
It cannot, for example, give a precise statement as to how the overall performance of a program is. To be able to do this, you need to analyze program execution yourself at runtime – for example, using the Runtime Analysis Tool (transaction code SE30), the Performance Trace (ST05), or the Global Performance Analysis Function (ST30).

How to start Code Inspector?
You can call the Code Inspector using transaction code SCI or through the menu path SAP Menu à Tools à ABAP Workbench à Test à Code Inspector.
You can call the Code Inspector using transaction code SCI or through the menu path SAP Menu à Tools à ABAP Workbench à Test à Code Inspector.
Below is the screen when you start Code Inspector.

We have three Blocks as below:

  1. Inspection
  2. Object Set
  3. Check Variant
What is Inspection?
Inspection is the process of checking individual objects or set of objects as to whether certain programming guidelines have been adhered to. The result of an inspection run is a list of the individual checks made with errors, warnings, or information messages. There are two types of inspections. They differ with respect to whether the results are made persistent or not.

  • Persistent inspections with results storage
    For execution on the local server or parallel execution on the server group. You can plan persistent inspections as background jobs and use them for any size of object set.
  • Anonymous or ad-hoc inspections without results storage
    For execution on the local server and for fewer than 50 objects. You can execute ad-hoc inspections in online mode only.
When you give a name in inspection box and click create icon following is the screen you get.

In the screen above you can see we can do inspection of an Object set (we will see shortly what that mean) which can be thought of as a collection of objects, Or we can do inspection of objects captured under any transport request by selecting the Request/Task radio button.
We can also do inspection of individual objects by selecting the Single radio button and giving the type of object and giving the name in the input box.
The next thing is Check Variant which is kind of collection of check rules that we have to follow while inspecting any object.

What are Object Sets?
They are collection of several single objects together in a group/set. Sets of objects include, for example, programs, function groups, classes, or DDIC objects. In general, any Repository objects can be included in a set of objects.  
There are global and local sets of objects. Global sets of objects are visible for all users while local objects are only visible for a single user. You can create global sets of objects only if you have the appropriate authorizations.  
Below is the screen you will get when you give the Object Set name and click the create icon.
There are lots of filters that you can use to group objects into an object set.
What are Check Variants?
This is the most important and most crucial component in Code Inspector. The Check Variants are nothing but the rules to be checked when we do the inspection. The system checks the individual objects of a defined set of objects for certain attributes using the check variant.
SAP supplies the global DEFAULT variant, which you can use to check objects from within the workbench i.e. when you do from SE24, SE37, SE38 or SE80. You can anytime enhance the predefined list of check categories and individual checks supplied by SAP but with restriction that you have proper authorizations to change or create check variants.
The individual checks are assigned to different check categories. The following list shows examples of check categories and individual checks.
  • General checks contain formatting elements, such as listing table names from SELECT statements.
  • Performance checks contain checks for performance and for resource use, such as:

  1. Analysis of the WHERE condition for SELECT / UPDATE and DELETE
  2. SELECT statements that read past the table buffer
  3. Low-performing accesses to internal tables

  • Security checks contain checks for critical statements, cross-client queries, inadequate authority checks.
  • Syntax check / generation contains ABAP syntax check, an enhanced program check, and generation:
  • Programming conventions contain checks for name conventions.
  • Search functions contain searches in ABAP coding for tokens (words) and statements.
These are just to mention the most important but there are lot more you can explore.
Give an appropriate name for the check variant based on the checks it will perform and click the create icon. It will take you to the following screen:

If we select the check box for a category all sub items will be checked, you can manually select multiple items from the tree structure and enable the checks.
There is an arrow shown in attributes column where you can again do a pinpoint check. Clicking on the attributes arrow will open more options to be checked.
For every check there is documentation provided where you can see how this check will work and what results you can expect after the inspection.
So go and dig down into the options provided and do not just rely on the results of Workbench Code checks. Create a custom check variant where it will check for all the possible errors that one can expect to be rectified in static review of the code.


Popular Posts