Skip to Content

What is Code Inspector?

The Code Inspector is a tool for checking Repository objects.

Using the Code Inspector, we can check individual objects or sets of objects for performance, security, syntax, and adherence to name conventions.
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 concepts are explained in the blog by Nick Young Setting up and using the SAP Code Inspector.
In this blog we see the step-by-step tutorial for using Code Inspector.

The summarized basic concepts are as below:

What is Check Variant, Object Set, Inspection in the context of Code inspector? 

  • Check Variant – This defines the rules to be applied, which checks are to be made and the settings of those checks. 
  • Object Set – This defines the development objects that will be included. 
  • Inspection – This defines a combination of Check Variant and Object Set, in other words what checks are to be applied to which development objects.

What is the difference between local and Global Check Variants? 

  • Global elements are available to all users.
  • Local elements are associated directly with a specific user id.
  • SAP provides a Global Check Variant with the name ‘DEFAULT’. This is used for objects that are checked from the context menu of Programs, Classes, Function modules etc.
  • For your username, If you create a Local Check Variant with the name DEFAULT, the system will use this instead of the global check variant.

 

Step-by-step Tutorial

Task 1)Browse the Global ‘DEFAULT’ check variant.
 image

The Global DEFAULT check variant will be displayed as shown below:
 image

Let us not change the Global DEFAULT check variant.

Task 2) Create Local DEFAULT check variant.

Let us create a Local DEFAULT variant (for the logged in user) by copying from Global DEFAULT variant.

 imageimageimage

Save the Local DEFAULT Check Variant.

 

Here onwards whenever you use the Code Inspector from a context-menu of a program, Function module, Class, etc, the local DEFAULT variant is used (instead of the global DEFAULT variant) for examining the code.

Task 3) Create a Sample program and examine with (local) DEFAULT variant of code inspector.

Create a program ZTEST_ONE.

image

if needed, you can copy from below textarea:

 

After activating the program, execute the code inspector as shown below.

 image

The Results will be displayed as under:

image

The warning messages show that naming conventions are not followed for the names spfli_table, alv_obj, alv_exc_obj and row_count.

 

The ‘DEFAULT’ check variant enforces the rule “Global data declarations in program must be prefixed with letter G followed by letter corresponding to type of the data – T for internal tables, O for object references, X for exception objects, E or V for elementary types.

So the names in our sample program should begin with gt_*, go_*, gx_*, gv_* or ge_* based on their types.

 

Go to the program and make changes as shown below:

 image

Execute the code inspector.

 image

 

Task 4)Create a non-DEFAULT check variant.

Create a new Code Inspector Check Variant (non DEFAULT).

 imageimage

image

Save the variant.

 

Task 5) Validate the sample program against the newly created Non-DEFAULT Check Variant.

Create an ObjectSet.

 image

 image

 

Create an Inspection, and Execute.

 image

image 

image

The results will be displayed as shown in next screen.

 image Correct the Program.

 image

Activate the Program.

To run the inspection ZCI_01 again, we need to create a new version of the inspection ZCI_01.

Create a new version of Inspection:

 image

Execute new version of Inspection.

 image

You will see results as shown below:

 image

..

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply