In this recipe, we will see how we can create our own company specific checks and categories and display them with the standard check categories. For simplicity's sake, we will create a check by the name My Check
under a new category My Check category. When this check will run, it will search for the token T512T
in the program and will display the number of occurrences and the corresponding line numbers.
Follow these steps:
SE24
. Enter the class name CL_CI_CATEGORY_TEMPLATE
in the class field and click the Copy button. The screenshot appears as follows:CONSTRUCTOR
method in the Edit mode. Add the code given in the following screenshot:CL_CI_TEST_SCAN_TEMPLATE
class having the name ZST9_CL_CI_CHECK
. In the CONSTRUCTOR
method, add the code given in the following screenshot:run
method of the Check
class, which is given in the following screenshot:GET_MESSAGE_TEXT
method of the class given in the following screenshot:SCI
and SCII
. Follow the menu path from the transaction SCI
.category
class and click Save. A confirmation dialog box appears. Click Yes.check
class.First we create the category
class. We assign the necessary text (My Check Category) to be displayed in the CONSTRUCTOR
method. The folder of the category will have this text displayed. Next the check
class is defined and the text My Check. The linkage between the check
class and the category
class is done in the CONSTRUCTOR
method of the check
class.
The run
method is executed when the check is executed. The REF_SCAN
object supplied with the TOKENS
table within the method is used for checking all the tokens of the program code that is to be included in the inspection. A loop is run on the TOKENS
table and if the token t512T
is found, the method INFORM
is called with the necessary information supplied. We want the information message to be displayed along with the row and column of the token. The P_CODE
value 0001
is also supplied, for which an appropriate text message is added in the GET_MESSAGE_TEXT
method.
Then, both classes were activated.
Finally, the activation setting will display the new check and the category along with standard categories and checks for transactions SCI
and SCII
, as shown in the following screenshot:
We ran the inspection for a program having two occurrences of the token T512T
. The output of the results is shown in the following screenshot:
3.133.142.2