Shared objects are stored and managed in area instance versions. In an ABAP program, area instance versions and therefore shared objects are accessed using area handles exclusively. Area handles are instances of the area class of an area. The properties of an area class and thus each area handle are described in detail in Shared Objects - Classes. This section gives an overview of how you use them.
Individual area handles are created using the following static methods of the area class:
There is also a MULTI_ATTACH method to create several area handles at once.
· The methods return a reference to the area handle that is created. Each area handle is bound to exactly one area instance version. This area instance version has a state depending on the method. Binding an area handle to an area instance version has the same effect as setting a lock on the area instance:
· ATTACH_FOR_WRITE and ATTACH_FOR_UPDATE create a change lock
· ATTACH_FOR_READ creates a read lock
The ATTACH_FOR_WRITE method creates a new area instance version, as long as the existing locks permit this. The specification of a name means that different area instances of an area can be created, each with its own versioning. If no name is specified, the content of the CL_SHM_AREA=>DEFAULT_INSTANCE constant is used as the default value. It is recommended that you always work with explicit and unique names. Until the binding is removed, change access is possible in the program on the area instance version that is bound.
Provided that the existing locks permit it, the ATTACH_FOR_UPDATE method
· Creates a new version as a copy of the active area instance version, in the case of areas with versioning, or
· Binds the area handle to an existing active area instance version in the case of areas without versioning.
Specify a name to select an area instance. If no name is specified, the content of the CL_SHM_AREA=>DEFAULT_INSTANCE constant is used as the default value. Until the binding is removed, change access is possible for the area instance version that is bound.
The ATTACH_FOR_READ method binds the area handle to an existing area instance version, provided that the existing locks permit this. Specify a name to select an area instance. If no name is specified, the content of the CL_SHM_AREA=>DEFAULT_INSTANCE constant is used as the default value. Until the binding is removed, read access is possible for the area instance version that is bound.
The following instance methods of the area class removes the binding of individual area handles:
There are also static methods DETACH_AREA and DETACH_ALL_AREAS to remove several bindings at once.
Once the binding between an area handle and the area instance version has been removed, the area handle is inactive and can no longer be used. Removing a binding also removes the corresponding lock and may change the state of the relevant area instance version.
· DETACH removes a read lock.
· DETACH_COMMIT removes a change lock by confirming the changes that were made.
· DETACH_COMMIT removes a change lock without confirming the changes that were made.
The methods of area handles listed above are usually used when you work with shared objects. There are also additional methods for special applications. Transaction SHMM provides a program-independent user interface for these methods.
The INVALIDATE_INSTANCE or INVALIDATE_AREA methods 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, although existing read locks continue to exist.
The PROPAGATE_INSTANCE and PROPAGATE_AREA methods are available for the cross-application server invalidation of area instance versions in the case of transactional areas.
The FREE_INSTANCE or FREE_AREA methods 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.
The GET_INSTANCE_INFOS method returns information about all of an application server’s area instances in an internal table.
The GET_LOCK_KIND, IS_VALID, IS_ACTIVE_VERSION, HAS_ACTIVE_PROPERTIES and GET_DETACH_INFO (from Release 7.0) methods return information about the locks and the state of an area handle.
The BUILD method can be used to call the area constructor of an area explicitly in the current internal session. The BUILD method is a standardized mechanism for building area instances.