How to create your own ATC check in SAP BTP ABAP Environment
Some of you may not only want to configure the ATC checks delivered by SAP and bundle them to custom ATC check variants but are eager to write own ATC checks. It became possible with the SAP BTP ABAP Environment 2105 by using the released API IF_CI_ATC_CHECK and ADT in Eclipse.
|NOTE: In order to incorporate feedback from early adaptors before making the API IF_CI_ATC_CHECK free available for all, it is currently available via the feature toggle. You need to create a customer ticket on BC-CP-ABA component to turn it on in your SAP BTP ABAP Environment system. In the ABAP trial the feature toggle is already turned on.|
The API looks as following:
and you can also take a look at the provided example implementation of an ATC check:
Let’s take a look how you can create your own ATC check. In the following example the class ZCL_ATC_CHECK_CLASS_NAME (based on the API IF_CI_ATC_CHECK) was implemented with the purpose to check naming convention of the class names. Now it is possible to implement an ATC check based on that class.
First the new ATC check category will be created to bundle custom ATC checks (e.g. using the context menu New -> ABAP Repository Object (Ctrl+Shift+N)):
The Description field shows how the new check category will appear in the ATC check variant:
The Parent Category will be just left empty:
After that, new ATC checks can be added to this category. Let’s create a new ATC check which checks the names of classes against a naming convention. You can do it, again, e.g., using the New -> ABAP Repository Object context menu, but it can be done faster, now. After creation of the ATC check category, you will get the new ABAP Test Cockpit node in your Project Explorer which bundles all ABAP Test Cockpit related objects: Check Categories, Checks and Check Variants. You can use the context menu New -> ATC Check on the ABAP Test Cockpit node to create your ATC check:
Just enter the Name and Description of the check and the Category and Implementing Class and choose Next:
This is how the new ATC check editor looks like:
You can change some data here, e.g., enter the Description. After that, save and activate the new ATC check.
Now it’s time to create a new ATC check variant containing this new ATC check (using the ABAP Test Cockpit node context menu New->ATC Check Variant):
This is how the new ATC check variant editor in ADT in Eclipse looks like:
The new ATC check appears under the new ATC check category (which contains other custom ATC checks, which were added there meanwhile). Here, you can include the new ATC check into your new ATC check variant and define the parameters of the check. In this example, the ATC check variant ZMY_NAMING_CONVENTION will consist only of the new ATC check which will check the names of classes for beginning with ZCL_CI. If it is not the case, the check will report an ATC error. After saving and activating the new ATC check variant it’s time to check your custom code package with it:
The results in the ATC Problems View show the ATC naming convention errors for the names of the classes, which don’t begin with ZCL_CI: