Get Example source ABAP code based on a different SAP table
ABAP_SHM - Area Handles
Creating Area Handles Area handles are instances of the area class > of an area. An individual area handle is created using one of the following static methods from the area class, whereby an associated area lock> is set:
ATTACH_FOR_WRITE>>
ATTACH_FOR_UPDATE>>
ATTACH_FOR_READ>> There is also the method MULTI_ATTACH>> to create multiple area handles at once. These methods return a reference to a created area handle. Each area handle is bound to exactly one area instance version. This area instance version has a certain state>, depending on the method used. Binding an area handle to an area instance version is equivalent to setting one of the following area locks > on the area instance:
ATTACH_FOR_WRITE>> and ATTACH_FOR_UPDATE>> both create a change lock
ATTACH_FOR_READ>> creates a read lock
Creating Area Instance Versions The method ATTACH_FOR_WRITE>> creates a new area instance version if existing locks allow it. By specifying a name, different area instances of an area can be created with their own versioning each. If no name is specified, the content of constant CL_SHM_AREA=>DEFAULT_INSTANCE> is used as the default value. It is recommended that explicit and unique names are always used. Until the binding is removed, the bound area instance version can be accessed for changes in the current ABAP_ISESS >.
Changing Area Instance Versions The method ATTACH_FOR_UPDATE>> does one of the following, if existing locks allow it:
In areas with versioning>, it creates a new version as a copy of the active area instance version.
In areas without versioning>, it binds the area handle to an existing active area instance version. When a name is specified, an area instance is selected. If no name is specified, the content of the constant CL_SHM_AREA=>DEFAULT_INSTANCE > is used as the default value. Until the binding is removed, the bound area instance version can be accessed for changes in the current ABAP_ISESS .
Reading Area Instance Versions The method ATTACH_FOR_READ>> binds the area handle to an existing area instance version if existing locks allow it. When a name is specified, an area instance is selected. If no name is specified, the content of the constant CL_SHM_AREA=>DEFAULT_INSTANCE> is used as the default value. Until the binding is removed, the bound area instance version can be accessed for reads in the current ABAP_ISESS .
Detaching Area Handles The following instance methods of the area class remove the binding of an individual area handle:
DETACH>> removes a read lock.
DETACH_COMMIT>> removes a change lock and confirms the changes that were made.
DETACH_ROLLBACK>> removes a change lock without confirming the changes that were made. In addition, there are the static methods, DETACH_AREA>> and DETACH_ALL_AREAS >>, are used to remove multiple bindings at once. Once the binding between an area handle and the area instance version is removed, the area handle is inactive and can no longer be used. Removing a binding also removes the corresponding area lock and might change the state of the relevant area instance version.
Additional Methods The methods of the area handles mentioned above are normally used when working with shared objects. There are also additional methods also exist for special applications. Transaction SHMM>> provides a program-independent user interface for such methods.
Invalidating versions The methods INVALIDATE_INSTANCE>> or INVALIDATE_AREA>> can be used to set one or more active area instance versions to obsolete>. This prevents new read locks from being set for this version, while existing read locks are retained.
Deleting versions The methods FREE_INSTANCE>> or FREE_AREA>> can be used to set one or more active or obsolete area instance versions to expired>. This removes all read locks and no new read locks can be set on these versions.
Information about area instances The method GET_INSTANCE_INFOS>> returns information about all area instances of an ABAP_ASINSTANCE in an internal table.
Information about area handles The methods GET_LOCK_KIND>>, IS_VALID>, IS_ACTIVE_VERSION>>, IS_SHARED>>, HAS_ACTIVE_PROPERTIES>>, and GET_DETACH_INFO>> return information about locks and the state of an area handle.
Explicit call of the area constructor The method BUILD>> can be used to call the area constructor> of an area explicitly in the current ABAP_ISESS . This method is a standardized mechanism for building area instances.