SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

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.

DB Operation SELECT found (VBFA, see Note(s):0002198647)

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.

SAP CDS View for VBFA table

Here is the CDS view codes. As ABAP programmers can see easily, it is just returning all data from VBFA table, nothing interesting actually.

define view /KODYAZ/SOM_INFO_VBFA
as

select * from vbfa;
Code

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.

TABLES vbfa.
DATA lt_vbfa TYPE TABLE OF vbfa.

SELECTION-SCREEN BEGIN OF BLOCK ss.
SELECT-OPTIONS:
so_vbeln FOR vbfa-vbeln.
SELECTION-SCREEN END OF BLOCK ss.

START-OF-SELECTION.

SELECT
vbelv posnv vbeln posnn vbtyp_n
INTO CORRESPONDING FIELDS OF TABLE lt_vbfa
FROM vbfa
UP TO 10 ROWS
WHERE vbeln IN so_vbeln.
Code

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.

SELECT
vbelv, posnv, vbeln, posnn, vbtyp_n
INTO CORRESPONDING FIELDS OF TABLE @lt_vbfa
FROM /kodyaz/som_info_vbfa " vbfa => CDS View
UP TO 10 ROWS
WHERE vbeln IN @so_vbeln.
Code

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;

SELECT KAWRT INTO CORRESPONDING FIELDS OF KONV
FROM KONV
WHERE KNUMV = T_LISTK-KNUMV
AND KPOSN = T_LISTP-POSNR
AND KSCHL = 'MWST'
ORDER BY PRIMARY KEY.
Code

It is possible to use below ABAP code block including V_KONV CDS view as data source.

SELECT kawrt INTO CORRESPONDING FIELDS OF @konv
FROM v_konv "konv
WHERE knumv = @t_listk-knumv
AND kposn = @t_listp-posnr
AND kschl = 'MWST'
ORDER BY PRIMARY KEY.
Code

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.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.