The Importance of Key Fields in Select Query

SAP Key Fields

Hello Friends, 

Many of you may already aware of this concept but i want to write this for those who does not know about importance of key field concept in ABAP. If we are selecting data from a table and if we are not passing all key fields while getting data from table, this result in loss of data. For better understanding please refer below example-

Example: Suppose there is table EmpBonus and its key fields as EMPID, DUID, PROJID, JOBCODE and non key fields as BonusAmount, ValidFrom, ValidTo, isActive.

SELECT EMPID DUID JOBCODE FROM EmpBonus

WHERE EMPID IN .

In above case as we have not used PROJID and JOBCODE during selection this can lead in data loss.

So while selection data we should select all key fields and then save this data into some local internal table then we have to process it as per requirement and pass to global internal table or as per your need.