Thursday, 24 September 2015

Creating code inspector Check Variant for client specific naming conventions

1. Creating Check Variant


1.a) Run transaction SCI
 Enter  Check  Variant name and press Create button.

Creating code inspector Check Variant for client specific naming conventions

1.b) Next screen will display list of checks. For defining naming convention standards go to Programming Conventions →Naming Conventions and click on arrow.

Creating code inspector Check Variant for client specific naming conventions

1.c) Enter naming conventions here.

Creating code inspector Check Variant for client specific naming conventions

1.d) If required define other checks also(performance checks, Security checks etc ) and save variant.

e.g.  If ‘Performance Checks→SELECTs in Loops’ is selected, code inspector will search select statements in loops. 

Creating code inspector Check Variant for client specific naming conventions

2. Creating Inspection.


We will check code inspector results for below sample code
REPORT  zsk_test.
TABLES : mara.

*Structure with correct naming convention

TYPES : BEGIN OF ty_struct1,
        matnr TYPE marc-matnr,
        werks TYPE marc-werks,
        END OF ty_struct1.

*Structure with wrong naming convention

TYPES : BEGIN OF struct2,
        matnr TYPE marc-matnr,
        werks TYPE marc-werks,
        END OF struct2.

*Internal table declaration

DATA : t_tab1 TYPE STANDARD TABLE OF ty_struct1,
       t_tab2 TYPE STANDARD TABLE OF struct2.
CONSTANTS : c_const1 TYPE char1 VALUE 'A', "Incorrect naming convention
            co_const2 TYPE char1 VALUE 'B'."Correct naming convention
DATA : var1 TYPE char1.         "Variable with incorrect naming convention
SELECTION-SCREEN : BEGIN OF BLOCK b1.
SELECT-OPTIONS s_matnr FOR mara-matnr.
PARAMETERS : pr_werks TYPE marc-werks.
SELECTION-SCREEN : END OF BLOCK b1.
START-OF-SELECTION.
  SELECT matnr werks
         FROM marc
         INTO TABLE t_tab1
         WHERE matnr IN s_matnr
           AND werks = pr_werks.
  IF sy-subrc <> 0.
    MESSAGE 'No data found' TYPE 'S'.
 ENDIF.

2.a) Enter Inspection name and click on create button.
  • In Object Selection enter program name.

We can run code inspector for multiple objects also. For multiple objects create Object Set first and enter object set name here.
  • In Check Variant enter variant name.

Click on Execute(F8) button_._ 

Creating code inspector Check Variant for client specific naming conventions

2.b) Checking inspection Results
Click on ‘Results’ button as shown below. 

Creating code inspector Check Variant for client specific naming conventions
Result: 
Creating code inspector Check Variant for client specific naming conventions

No comments:

Post a Comment