S/4HANA Search for database operations: DB Operation SELECT found
ABAP Test Cockpit ATC checks include "DB Operation SELECT found" errors under check title "S/4HANA: Search for database operations" especially for VBFA and KONV tables when executed for an ABAP program of mine.
Here is a sample ATC check error detail:
S/4HANA: Search for database operations
DB Operation SELECT found
Priority 1
DB Operation SELECT found (VBFA, see Note(s):0002198647)
Short text: S/4 HANA: DATA MODEL CHANGES IN SD
Cannot be hidden using a pragma or pseudo-comment
It is an option to supress the error in the ATC checks using a pseudo comment for most of the ATC check options.
But this error cannot be supressed using a pseudo comment.
Besides the original error, a second error is triggered titled as "Read on sensitive database tables" for SAP HANA database tables storing important information.
Actually, it is easy to resolve this kind of errors by using a CDS view instead of direct use of database tables VBFA or KONV.
I would like to take your attention to an additional point on KONV table. With S/4HANA table KONV is replaced with PRCD_ELEMENTS table (Pricing Elements) on HANA.
Let's continue our solution and Create CDS View for VBFA table in order to replace in our ABAP codes.
Here is the CDS view codes. As ABAP programmers can see easily, it is just returning all data from VBFA table, nothing interesting actually.
Let's make a test now. I create a sample ABAP program with following codes. I have the same ATC errors with this sample ABAP report.
Now I'll convert the SELECT command using CDS view which I created VBFA instead of directly referring to VBFA SAP table in the OpenSQL statement.
During this code conversion, following errors could occur and can be easily solved.
The elements in the "SELECT LIST" list must be separated using commas.
If the new Open SQL syntax is used, it must be used throughout. This includes using @ to escape host variables.
If in the FROM clause if you use CDS View name shown in sqlViewName annotation, another ATC check warns programmer to use the associated entity for the CDS view.
The same solution, using a CDS view instead of database table can also be implemented for KONV table.
For KONV table, it is possible to use CDS view V_KONV but I will again suggest ABAP programmers to create a new CDS view which reads data from PRCD_ELEMENTS SAP HANA database table.
For example, instead of following ABAP code with OpenSQL on KONV table;
It is possible to use below ABAP code block including V_KONV CDS view as data source.
This modification will resolve ATC check error DB Operation SELECT found under the check title S/4HANA: Search for database operations for enhancing code quality of your custom ABAP developments on SAP S/4HANA systems.
DB Operation SELECT found (BSEG, see Note(s):0002431747)
I got ATC error "DB Operation SELECT found (BSEG, see Note(s):0002431747)" for BSEG table.
I looked for a view that I can use instead of BSEG and found VFCLMBSEGBS (BASIC BSEG) DDL SQL View.
Though I could resolve "DB Operation SELECT found" priority 1 error message, this time I got a priority 2 "SELECT 533" message with following detail:
Use the associated entity "FCLM_BSEG_BASIC".
So in the second round, I replaced VFCLMBSEGBS - the replacement of BSEG :) - with FCLM_BSEG_BASIC
Of course this change, using the new Open SQL syntax, requires using @ to escape host variables like WHERE clause filter criteria variable names, or INTO clause internal ABAP table names, etc.
But this is a good way of resolving the ABAP Test Cockpit ATC error if the view includes all the fields that you need in your ABAP program.