09-29-2015 5:39 PM
Hi,
I am using Shared Memory attach_for_write and attach_for_read in enhancement.
Does detach_commit() will commit database when used in enhancement? Method does not involve explicit commit
Regards
Mohinder
09-29-2015 10:58 PM
Copied from SAP help document.
Releases a change lock (write or update lock) on the current area handle and confirms the changes that were made. The area handle is then inactive. The prerequisite for this is that the current area instance version must contain an instance of the area root class (root object). In addition, there must not be any references from the area instance version to a different area instance of the shared objects memory, or to the internal session. If an exception occurs when the method is executed, the change lock is not released correctly. Although it remains, the lock cannot be released a second time using the DETACH_COMMIT method. The DETACH_ROLLBACK can be used instead. With non-transactional areas (TRANSACTIONAL component of the PROPERTIES structure has the value ABAP_FALSE), changes to the current area instance version become active immediately after the DETACH_COMMIT method is executed. With transactional areas (TRANSACTIONAL component of the PROPERTIES structure has the value ABAP_TRUE), the changes that are completed when the DETACH_COMMIT is executed are not active until the next database commit. The following rules apply during the time between the completion of the DETACH_COMMIT method and the next database commit: With transactional areas with versioning, all requested read locks access the previous version. No read access is possible for transactional areas without versioning. It is not possible to set a new change lock for areas with or without versioning. When the DETACH_COMMIT method is called, the SHM_COMMIT_EVENT event of the generated area class is triggered automatically.
Refer program DEMO_SHARED_OBJECTS
It is not calling commit work statement implicitly. detach_commit updated the shared memory & set for commit and release lock. It is also Trigger the Event SHM_COMMIT_EVENT. You can write handler method for this Event for update database and explicitly call commit Statement in your handler method.
09-29-2015 10:58 PM
Copied from SAP help document.
Releases a change lock (write or update lock) on the current area handle and confirms the changes that were made. The area handle is then inactive. The prerequisite for this is that the current area instance version must contain an instance of the area root class (root object). In addition, there must not be any references from the area instance version to a different area instance of the shared objects memory, or to the internal session. If an exception occurs when the method is executed, the change lock is not released correctly. Although it remains, the lock cannot be released a second time using the DETACH_COMMIT method. The DETACH_ROLLBACK can be used instead. With non-transactional areas (TRANSACTIONAL component of the PROPERTIES structure has the value ABAP_FALSE), changes to the current area instance version become active immediately after the DETACH_COMMIT method is executed. With transactional areas (TRANSACTIONAL component of the PROPERTIES structure has the value ABAP_TRUE), the changes that are completed when the DETACH_COMMIT is executed are not active until the next database commit. The following rules apply during the time between the completion of the DETACH_COMMIT method and the next database commit: With transactional areas with versioning, all requested read locks access the previous version. No read access is possible for transactional areas without versioning. It is not possible to set a new change lock for areas with or without versioning. When the DETACH_COMMIT method is called, the SHM_COMMIT_EVENT event of the generated area class is triggered automatically.
Refer program DEMO_SHARED_OBJECTS
It is not calling commit work statement implicitly. detach_commit updated the shared memory & set for commit and release lock. It is also Trigger the Event SHM_COMMIT_EVENT. You can write handler method for this Event for update database and explicitly call commit Statement in your handler method.