Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
vonglan
Active Participant
8,396
Hi,

I could not find this information in detail on the internet yet, and I think it is quite useful to know, so here is a quick description.

If you are the person responsible for ATC checks, and you want to use an SAP provided check (for example in automatic checks during release of transports), but you want to disable the possibility for the developers to use a pragma or pseudocomment, you can do this quite easily by creating a subclass to the respective SAP test class.

For example, we do NOT want the developers to call obsolete functions. We also do not want to allow the "workaround" of using a pseudo comment or pragma (FM_OLDED/FB_OLDED) that the SAP standard check allows.

This check is part of test class CL_CI_TEST_EXTENDED_CHECK.

So, we create a subclass of that class:
CLASS zcl_ci_test_extended_check DEFINITION
PUBLIC
INHERITING FROM cl_ci_test_extended_check
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
METHODS constructor.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_ci_test_extended_check IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
myname = 'ZCL_CI_TEST_EXTENDED_CHECK' ##NO_TEXT.
" necessary in this case because otherwise pragma is still displayed in finding details
DATA(parentname) = myname+1.
description = description && ' fewer pragmas'(001).
LOOP AT scimessages REFERENCE INTO DATA(msg).
IF msg->pcom = 'FM_OLDED'. " obsolete function module
msg->pcom = c_exceptn_imposibl.
ENDIF.
IF msg->test = parentname.
" necessary to keep the standard SAP priority mapping (CL_CI_TEST_ROOT->INFORM)
INSERT VALUE #( BASE msg->*
test = myname ) INTO TABLE scimessages.
ENDIF.
ENDLOOP.
DELETE scimessages WHERE test = parentname.
ENDMETHOD.
ENDCLASS.

In the constructor, we modify the standard table of checks scimessages. We change the field pcom (pseudo comment) for the respective test.

After creating and activating the class (don't forget to create the text element 001), we need to enable it for ATC/SCI. This is done vie transaction SCI, menu: Code Inspector / Management of / Tests. At the end of the list, you should see your new Z class. You have to tick the checkbox on the left, then save.

Now the new check is available when you create or change check variants.



Best regards,

Edo

 

Update 18.02.2019: Bugfix in code to re-enable standard SAP priority mapping.

Update 26.03.2019: For some test classes, e.g. CL_CI_TEST_CRITICAL_STATEMENTS, the pragmas are ignored during the check - as intended, but in the finding list, the pragmas are still mentioned (because the class passes its own name as a constant as the origin of its findings).

 
11 Comments
Labels in this area