Get Example source ABAP code based on a different SAP table
ABAP_SHM - 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 known as the shared object memory whose size is determined by the profile parameter abap/shared_objects_size_MB>>. Shared objects are managed using areas>. Areas and their properties are created and maintained using transaction SHMA>>.
Shared-Memory-Enabled Classes The prerequisite for the storage of an instance of a class to be stored in the shared memory is that the class of the object is defined using the addition SHARED MEMORY ENABLED> > of the statement CLASS> or the property Shared-memory-enabled> is selected in the Class Builder. Each area is linked to a global area root class> , whose attributes can contain their own data and references to other instances of shared-memory-enabled classes or to anonymous data objects.
Areas and Area Instances An area is the template for area instances in the shared memory. Multiple area instances with different names can be created from one area. In addition, there can also be multiple versions of an area instance (called area instance versions>), which are distinguished by a version ID. All area instance versions of the same area instance name form 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 using transaction SHMA>>, a global and final area class> (with the same name) is generated as a subclass of CL_SHM_AREA>>. The class CL_SHM_AREA> is itself 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. Static methods (known as attach methods) can be used to bind an ABAP program (or its ABAP_ISESS > ) to area instances in the shared memory. Bindings create an instance of the area class as an area handle> and simultaneously set an area lock>. 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 (detach methods) used to unbind the connection or the lock.
Access to Objects The shared objects in an area instance version are addressed using references>, which are obtained using the area handle. The shared objects within an area instance version can refer to each other without restrictions. An ABAP program can contain references to shared objects as long as it is bound to an area instance version. Area instance versions themselves are self-contained, which means that they cannot contain references to other area instance versions or an ABAP_ISESS >. Exceptions to this rule are possible only when an area instance is bound to an ABAP_ISESS to perform writes or updates. During this time, there can be references in the area instance to objects in the ABAP_ISESS or to other area instances that are also bound.
Latest notes: Area instances or area instance versions must not be confused 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 which can be addressed by area handles. ABAP_HINT_END