Table Buffering in SAP ABAP
Before we start with “Table Buffering in SAP ABAP”. Let us take a general example. Have you ever used YouTube? And, have you ever buffered video before watching it?
If YES, then you already have the idea of Buffering.
And If not, go to YouTube and pause your video, it will load it (Buffer it). So in this scenario, the YouTube video is loaded in your Browser/Application and when you play it, it doesn’t load it anymore from YouTube Server but directly plays it from the Buffer of your Application Server.
In this way you save your time and have a better experience. This concept of Buffering is also utilized by ABAP Tables and termed as Table Buffering in SAP ABAP.
Table Buffering in SAP ABAP is a concept in ABAP Tables to enhance performance (10 to 100 times) and reduce time of processing (accessing) the table.
A Buffer is an interface between Database layer and Application layer. Application Layer communicates with Buffer and the Buffer communicates with Database layer and vice-versa.
*NOTE: Database Interface determines whether the Data is in buffer or not. If not, it takes data from database and also syncs the Buffer.
Using Buffers in Table
Step 01: Choose one radio button from Buffering Permissions.
|Buffering not allowed||This is default value. It is for Transaction table where data changes frequently|
|Buffering allowed but switched off||Buffer is allowed but it is switched OFF and can be switched ON anytime according to the requirement of customer|
|Buffering switched on||Buffering is allowed. In this case we need to provide the Buffering type.|
Step 02: Choose the buffering type: It defines which data will be loaded and when.
|Full Buffering||System loads all the data into Buffer whenever single record of the table is accessed.|
|Generic Buffering||When a record with a specific Generic key is accessed, all other records of that Generic key are also buffered.|
|Single-record Buffering||Only the record that was really accessed is buffered.|
When Full Buffering is used then either entire table is buffered or none of the records will be buffered. When a single record is accessed, the entire data/record of that table is buffered. By Buffering we mean that all the record is in the buffer table.
When To Use Full Buffering
- Larger table is rarely written and frequently read like Master Table, and then we need to use Full Buffering.
- For small tables like customizing tables that are mainly read.
When Generic Buffering is used, all the records with Generic keys are buffered all at once.
- Generic Keys: The key combination of only certain keys that is used to filter data from table.
- Generic key is a part of Primary key.
- All the Generic keys should be mentioned in WHERE condition of SELECT statement otherwise Buffer is bypassed and data is read from Database.
When To Use Generic Buffering
- When only certain Generic Areas are needed.
- For Client Specific Tables, the Client field is the Generic key.
- For Language Specific Tables, The Generic key includes Language key.
All the Data that you have accessed will be buffered and nothing apart from them.
When To Use Single-Record Buffering
- Table where only few records are accessed
How to Bypass a Buffer
By using BYPASSING BUFFER we can bypass the buffer and read directly from database.
SELECT * FROM <TABLE_NAME> INTO TABLE <ITAB> BYPASSING BUFFER.