The code inspector can be enhanced as per our requirement. It has these following class category and test class with CL_CI_CATEGORY_TEMPLATE and CL_CI_TEST_SCAN_TEMPLATE respectivelyThe code inspector can be enhanced as per our requirement. It has these following class category and test class with CL_CI_CATEGORY_TEMPLATE and CL_CI_TEST_SCAN_TEMPLATE respectively
Category Class
Category Class is used to create a folder in the code inspector. It has a inteface IF_CI_TEST and a SuperClass CL_CI_CATEGORY_ROOT.

The important method is CONSTRUCTOR.
method constructor.
super->constructor( ).
description = ’Attributes check’(000). ” The description of the Folder.
category = ’CL_CI_CATEGORY_TOP’(001). ” Parent Folder to which it should get linked.
position = ’999′. ”or 020 ….
endmethod.
Note: Test Class can be added to the standard category given by SAP.
TEST CLASSES
Test Class will hold the custom logic for the code inspector check. It has a superclass CL_CI_TEST_SCAN and the same interface as Category Class. The important methods of this class are CONSTRUCTOR, GET_MESSAGE_TEXT and RUN.
Constructor method will have the code to which category the test is linked.
method CONSTRUCTOR .
SUPER->CONSTRUCTOR( ).
DESCRIPTION = ’Auth Check’(001). ” The description of the test
CATEGORY = ‘ZCL_CI_CATEGORY_ATTRIBUTES’. ” Category name to which the test is linked
VERSION = ‘000′. ” Version no.
HAS_ATTRIBUTES = ‘ ‘. ” Whether the test has input field
ATTRIBUTES_OK = ‘ ‘.
endmethod. “CONSTRUCTOR
The following method RUN is used to perform the code inspector check. Important attributes used for the method as follows.
| TOKENS | The internal table will have ABAP Code separated by Standard ABAP Statements, Strings. |
| STATEMENTS | The internal table will give the line no in the code |
method RUN.
data : lt_temp_tokens type STOKESX_TAB,
tokens_wa1 type stokesx,
lv_string type string,
lv_include type program,
lv_level type i.
lv_abvlin type i.
data : lt_temp_tok type stokesx_TAB.
if ref_scan is initial.
check get( ) = ’X’.
endif.
lt_temp_tokens[] = ref_scan->tokens[].
lt_temp_tok[] = lt_temp_tokens[].
loop at ref_scan->tokens into token_wa where type = ’S’.
If token_wa-len3 = 0.
LV_ABVLIN = sy-tabix - 1.
read table lt_temp_tok index LV_ABVLIN into tokens_wa1.
if tokens_wa1-str eq ’FUNCTION’ or tokens_wa1-str eq ’DEFAULT’ or tokens_wa1-str eq ’VALUE’.
else.
loop at lt_temp_tokens into tokens_wa1 where row = token_wa-row.
CONCATENATE lv_string tokens_wa1-str into lv_string SEPARATED BY space.
endloop.
loop at ref_scan->statements into statement_wa where from <= token_wa-row and to >= token_wa-row.
lv_level = statement_wa-level.
endloop.
lv_include = get_include( p_level = lv_level ).
inform(
p_sub_obj_name = lv_include
p_kind = c_error
p_test = ’ZCL_CI_TEST_HARDCODE’
p_line = token_wa-row
p_column = token_wa-col
p_code = ’0001′
p_param_1 = lv_string ).
clear lv_string.
endif.
endif.
endloop.
endmethod.
method GET_MESSAGE_TEXT .
case P_CODE.
* To display the message in the output of the Code Inspector.
endcase.
endmethod. ”GET_MESSAGE_TEXT

Methods in the class

Activate both the class. Before adding the Category and test class to the test variant the class should be added to the code inspector. Follow the steps to add the Class in Transaction Code SCI.

It will list all the code inspector class. Select the class which was created to add to the test variant.

Check variant screen of the Code Inspector.













satya
Enhancement of Code inspector Default variant:
I want to my custom checks to standard SAP DEFAULT Variant.
I can create a new Local variant but instead of every user create the variant i want to customize the standard DEFAULT variant, how exactly can i do this
Satya
Raj
Hi ,
It’s not a Good idea to change the SAP’s DEFAULT variant,
Still if it’s a requirement thn.Go to Transaction code SCI
Put the variant name as “DEFAULT”
And edit it.
Please get back if i am not clear.
Raj
SAP IGnite.
pavankumar reddy k
Hi Raj,
Can you please repost this document as it is missing the steps to add the Class in Transaction Code SCI.
Thanks in advance,
Pavan
pavankumar reddy k
Hi Raj,
Can you please repost this document as it is missing the steps to add the Class in Transaction Code SCI.
Thanks in advance,
Pavan.
Raj
Hi pavan
Thanks for pointing it out.
As was busy not able to repost it.you can comment here the missing step will try to put it in article.
So that it canbe help ful to others.
Thanks
Raj
SAP IGnite