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

SAP Code Inspector for ABAP Internal Table without Content Check

Using SAP Code Inspector ABAP programmers can check existing code quality for HANA migration and for better performance and code security. "Possible use of internal table without prior content check" is one of the errors listed by SAP Code Inspector tool to inform ABAP developers for a possible code performance killer.

ABAP programmers run SAP Code Inspector for existing ABAP programs even within the program in an SE38 ABAP Editor using menu selections:
Program > Check > Code Inspector

Here is a small list of errors, warnings and information after I execute the SAP Code Inspector tool before I release my developments to test systems.

Possible use of LT_VBFA without prior content check

SAP Code Inspector for ABAP program

For example, above warning is thrown for ABAP code lines below by the Code Inspector.

SELECT vbeln posnr ntgew brgew gewei
INTO CORRESPONDING FIELDS OF TABLE lt_lips
FROM lips
FOR ALL ENTRIES IN lt_vbfa
WHERE lips~vbeln = lt_vbfa-vbelv
AND lips~posnr = lt_vbfa-posnv .
Code

The warning can be supressed by using pseudo CI_FAE_LINES_ENSURED

The reason is explained in detail if the ABAP programmer clicks on the blue i icon and reads the problem description section.
In fact, every ABAP developer knows the reason.
In ABAP where "SELECT FOR ALL ENTRIES" is used, database table rows are returned according to match criteria from the contents of the internal table.
The point that ABAP developer should check is that if the internal table is empty then all database table rows are returned by the SELECT statement.
To prevent this pitfall with SELECT FOR ALL ENTRIES command, before using the internal table in this ABAP statement it should be checked that it is not empty or initial.

ABAP programmers can use one of the following options to secure the performance of their codes:

IF lt_vbfa IS NOT INITIAL. " internal table
 SELECT ... FOR ALL ENTRIES IN lt_vbfa ...
ENDIF.

* OR

IF ( 0 < lines( lt_vbfa ) ). " internal table
 SELECT ... FOR ALL ENTRIES IN lt_vbfa ...
ENDIF.
Code


SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


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