Data object buffering techniques

Using ABAP shared objects

Properties of Shared objects
  • Cross program buffering data that is read often
  • Concurrent read access is supported
  • Access is controlled by a lock mechanism
Scenarios
  1. Usage as a shared buffer: a shared buffer contains a large data set on which many consumers can perform reads but which is changed rarely and is usually provided by a single program.
  2. Usage as an exclusive buffer: an exclusive buffer contains data that is accessed by only one program but that is maintained for various programs across transaction boundaries.
A prerequisite for saving an object in shared memory is that the class of that object is defined with the shared memory enabled additions of the class statement.

#1 Create a root class

Create a class using SE24, set the interface and mark the class for Shared memory: 

#2 Create a shared memory area

Using the transaction SHMA, create an area of the shared memory:

#3 Code write request

When the class and the area are implemented, add coding for the write request: 

#4 Code read request 

Now we can access the shared memory through reading: 

#5 Monitor shared areas

Using the transaction SHMM,



Remember, Shared Memory Objects exist as long as the SAP Instance exists. Any server restart, system upgrade etc. activities can remove the instance. Also, any change to the root class needs the existing memory objects to be deleted and updated again.

Additional information

Shared memory and shared buffer 

To explicitly store data clusters in the cross-transaction application buffer using the statements EXPORT TO SHARED MEMORY or EXPORT TO SHARED BUFFER.

Buffer module

Declare the global variable to store data and avoid repeated access to the table. 

SAP memory

It is a Global memory available across all sessions.

SAP memory is a memory area to which all main sessions within an SAP GUI have access. You can use SAP memory either to pass data from one program to another within a session or to pass data from one session to another.

Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on screens. The SPA/GPA parameters should be in TPARA table.

Syntax:
  • SET PARAMETER ID pid FIELD f.
  • GET PARAMETER ID pid FIELD f.



Comments