Skip to Content
Technical Articles

How to change the priority level in a standard ATC check

There are quite a few useful standard ATC checks delivered by SAP. Recently I found myself using one of the standard ATC checks, but wanting to change the priority level of one of the messages issued by the check. The check wasn’t configurable, so I decided to look into how the priority level could be changed programmatically. I’ll share my solution in this blog post.

Scenario

One of the standard ATC checks delivered by SAP can identify an issue with the following code:

SELECT SINGLE * FROM t002t
    INTO @DATA(ls_t002t)
    WHERE spras = 'V'.

Table T002T has two key fields: SPRAS and SPRSL. Since the SELECT statement is not unique, in an S/4 HANA system it is not guaranteed to always return the same result.

The ATC check issues an information message stating:

“SELECT SINGLE is possibly not unique”

This is however only an information message, and our development team wanted it to be an error message (priority 1 instead of priority 3). To prepare ourselves for a future S/4 HANA conversion, this check is important to us.

Let us see how we can change the priority.

Analysis

The ATC check that triggers this message is located here in transaction SCI:

Navigating to the Management of tests in transaction SCI, we see that the corresponding class is CL_CI_TEST_NO_ORDER_BY:

When looking into this class, we see that in the CONSTRUCTOR the priority level has been hard-coded to 3.

Solution

To change the priority level, we can create a new class, e.g. ZCL_AOC_CHECK_Z01, which inherits the standard class CL_CI_TEST_NO_ORDER_BY. In class ZCL_AOC_CHECK_Z01, we can create a CONSTRUCTOR which executes the CONSTRUCTOR of the super-class, and then changes the priority level to 1. In the CONSTRUCTOR we can also change the description of the check, e.g. by adding a prefix Z - . The code looks like this:

CLASS zcl_aoc_check_z01 DEFINITION
  PUBLIC
  INHERITING FROM cl_ci_test_no_order_by
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    METHODS constructor.
  PROTECTED SECTION.
  PRIVATE SECTION.
    CONSTANTS c_code_ambiguous_single TYPE sci_errc VALUE 'AMB_SINGLE' ##NO_TEXT.
ENDCLASS.



CLASS zcl_aoc_check_z01 IMPLEMENTATION.

  METHOD constructor.
    super->constructor( ).

    description = |Z - { description }|.

    READ TABLE scimessages ASSIGNING FIELD-SYMBOL(<lf_smsg>)
        WITH KEY code = c_code_ambiguous_single.
    IF sy-subrc = 0.
      <lf_smsg>-kind = c_error.
    ENDIF.
  ENDMETHOD.

ENDCLASS.

Now that we have implemented the new check class, it needs to be activated in transaction SCI. Navigate to the Management of tests:

Check the check-box for the class:

We also need to replace the standard check with the new check in the check variant. Deselect the standard check, and select our new check instead:

Test

When running the ATC check for the problematic code, we now get an error message instead of an information message:

Mission accomplished. Happy coding!

This blog post first appeared on the Developer Voyage blog at https://www.developervoyage.com/2019/12/27/how-to-change-the-priority-level-in-a-standard-ATC-check.html

2 Comments
You must be Logged on to comment or reply to a post.