ARTICLE
Shared Objects - Overview
Shared objects are instances of classes or anonymous data objects in
shared memory . Named data objects can
be stored as attributes of classes. The memory area of the shared memory
for shared objects is the shared object memory. Its size is determined
by the profile parameter
abap/shared_objects_size_MB .
Shared objects are managed with the help of areas
. You create and maintain areas and their properties using
transaction SHMA .
Shared Memory-Enabled Classes
The prerequisite for storing an instance of a class in the shared memory
is that the class of the object has to be defined with the
SHARED MEMORY ENABLED addition of the
CLASS statement, or that the property Shared memory-enabled
has to be selected in the Class Builder. Each area is linked to a
global area root class , which can
contain separate data and references to other instances of shared
memory-enabled classes or to anonymous data objects in its attributes.
Areas and Area Instances
An area is the template for area instances in the shared memory. Several
area instances can be created from one area instance, which are
distinguished by name. In addition, there can be several versions of an
area instance ( area instance
versions ). Version IDs are used to differentiate between the
versions. All area instance versions of the same area instance name make
up an area instance. In the simplest case (without versioning), an area
instance consists of a single area instance version.
Area Classes and Area Handles
When an area is defined in transaction SHMA , a
global and final area class (with the same
name) is generated as a subclass of
CL_SHM_AREA . Class CL_SHM_AREA itself is a direct subclass
of CL_ABAP_MEMORY_AREA . In an
ABAP program, an area is accessed exclusively using the methods of the
generated area class. There are static methods for binding an ABAP
program (or its internal session) to area instances in the shared memory
(attach methods). Binding creates an instance of the area class as an
area handle , and creates an
area lock at the same time. The ABAP
program can access the bound area instance version using the area handle
and thus access the shared objects that are stored there. The area
handle also contains the methods for deleting the connection or the lock
(detach methods).
Access to Objects
The shared objects in an area instance version are addressed by
references , which are obtained using
the area handle. The shared objects within an area instance version can
refer to each other without any restrictions. An ABAP program can
contain references to shared objects provided that it is bound to an
area instance version. Area instances themselves are self-contained so
that they cannot contain any references to other area instance versions
or be contained in an internal session. There is one exception to this
rule, provided that an area instance is bound to an internal session for
writing or updating. During this time, there can be references in the
area instance to objects in the internal session or to other area in
stances that are similarly bound.
Note
Do not confuse area instances or area instance versions with
instances of classes. In particular, an area
instance is not an instance of an area class. Area instances are managed
areas (the actual areas) in the shared memory in which shared objects
can be stored, and that are addressed by area handles.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved