Thursday, February 2

Generic Buffering

Start of Content Area
Background documentation Generic Buffering  Locate the document in its SAP Library structure
With generic buffering, all the records in the buffer whose generic key fields match this record are loaded when one record of the table is accessed. The generic key is a part of the primary key of the table that is left-justified.
Example
In this example, the record highlighted in red is read by a program from table SCOUNTER. If the table is generically buffered, all the records read whose generic key fields (MANDT and CARRID) agree are loaded into the buffer.
This graphic is explained in the accompanying text
When Should you Use Full Buffering? A table should be buffered generically if only certain generic areas of the table are normally needed for processing.
Client-specific, fully-buffered tables are automatically generically buffered since normally it is not possible to work in all clients at the same time on an application server. The client field is the generic key.
Language-specific tables are another example where generic buffering is recommended. In general, only records of one language will be needed on an application server. In this case, the generic key includes all the key fields up to and including the language field.
How Should you Define the Generic Key? In generic buffering, it is crucial to define a suitable generic key.
If the generic key is too small, the buffer will contain a few very large areas. During access, too much data might be loaded in the buffer.
If the generic key is too large, the buffer might contain too many small generic areas. These can reduce buffer performance since there is an administrative entry for every buffered generic area. It is also possible that too many accesses will bypass the buffer and go directly to the database, since they do not fully define the generic key of the table. If there are only a few records in each generic area, it is usually better to fully buffer the table.
Only 64 bytes of the generic key are used. You can specify a longer generic key, but the part of the key exceeding 64 bytes is not used to create the generic areas.
Access to Buffered Data It only makes sense to generically buffer a table if the table is accessed with fully-specified generic key fields. If a field of the generic key is not assigned a value in a SELECT statement, it is read directly from the database, bypassing the buffer.
If you access a generic area that is not in the buffer with a fully-specified generic key, you will access the database to load the area. If the table does not contain any records in the specified area ("No record found"), this area in the buffer is marked as non-existent. It is not necessary to access the database if this area is needed again.