Copyright 2024 - BV TallVision IT

Your data integrity could be secured - but data integrity issues can still arise: integrity in reporting - when using SELECT SINGLE

Even though data is stored correct and complete - it could still be presented to the end user the wrong way - which results in data integrity problems as well. An error in a report could lead to faulty answers which should be spotted in the testing phase. "Nothing that cannot be fixed". However:

 

A commonly made mistake in programming ABAP selects is the SELECT SINGLE. This statement is very fast because is returns exactly 1 record. When a select single is coded without supplying the full key of the table - the result from the select single may not be the answer you were looking for. In effect - there is no accurate wayof predicting what the system will return as a result on a SELECT SINGLE statement without key. There's even a very fair chance that the result will depend on the database management system installed !

Ergo: it's very bad practice to use select single statements when the full key is not available. It results in arbitrary selection results. When you are sure there is only one result for your selection even without the full key try this:

SELECT * FROM KNVV
  UP TO 1 ROWS
  WHERE kunnr EQ my_kunnr and
  vkorg EQ my_vkorg.
ENDSELECT. 

Would you like to find where (incompletely defined) select single statements were used in your program ? Run the extended program check (option 'Syntax check warnings") or the Code Inspector.