- SAP ABAP
- What is SAP ABAP
- SAP ABAP Data Dictionary and Domain
- SAP ABAP Data Element
- SAP ABAP Database Table
- SAP ABAP Database tables and views
- SAP ABAP Foreign Key
- SAP ABAP Indexes
- SAP ABAP Structure
- SAP ABAP Package
- SAP ABAP Adding Fields to SAP Standard Table
- SAP ABAP Internal Table and Database Table
- SAP ABAP Select Option and Parameter
- SAP ABAP Types of Internal Table
- SAP ABAP ways of Declaring Internal Tables
- SAP ABAP Mastering Initialization Technique
- SAP ABAP Operations on Internal Table
- SAP ABAP Record Retrieval
- SAP ABAP Insert, Modify and Delete data in the Internal table by using Keywords
- SAP ABAP Sorting and Removing Adjacent Duplicates
- SAP ABAP Seamless Data Transfer Between Internal Tables
- SAP ABAP Search Help Types
- SAP ABAP Lock Objects and Types
- SAP ABAP Buffering and Its Types
- SAP ABAP TMG
- SAP ABAP Table Types
- SAP ABAP Views
- SAP ABAP Control Break Statement
- SAP ABAP COMMIT and ROLLBACK
- SAP ABAP Joins
- SAP For All Entries
- SAP ABAP Procedure to Fill Final Internal Table
- SAP ABAP Modularization
- SAP ABAP Function Group and Function Module
- SAP ABAP SELECT Options
24DDIC3007 – Lock Objects Types and Creation Steps
Understanding Lock Objects
Lock objects in SAP are used to manage the locking mechanism for database records. They ensure that only one user can modify a particular record at a time, preventing data inconsistencies and conflicts. There are primarily two types of lock modules:
Enqueue Lock Objects
Dequeue Lock Objects
- Enqueue Lock Objects
Enqueue lock objects are used to lock database records for writing operations. They prevent other users from modifying the same records simultaneously. Enqueue locks are typically created when a user starts editing a record and are released when the editing session ends.
- Dequeue Lock Objects
Dequeue lock objects are used to release locks that were previously set by enqueue lock objects. They are essential for ensuring that locks are correctly managed and released, allowing other users to access and modify records once the original user’s session is completed.
Steps to Create Lock Objects
Creating lock objects involves defining lock modules and configuring their parameters. Below are the steps to create both enqueue and dequeue lock objects in ABAP.
Step 1: Define a Lock Object
- Access the ABAP Dictionary
Open the ABAP Dictionary by entering transaction code `SE11` in the SAP GUI.
- Create a New Lock Object
– Select “Lock Object” from the object type menu.
– Enter a name for the lock object (e.g., ‘ZMY_LOCK_OBJECT’).
– Click “Create.”
- Define the Lock Object Properties
– Enter a short description for the lock object.
– Choose “Enqueue” as the type of lock object.
- Specify the Lock Parameters
– Define the tables and fields that will be used for locking.
– Specify the lock modes (e.g., shared or exclusive locks).
- Save and Activate
– Save your entries and activate the lock object.
Step 2: Create Lock Modules
Lock modules are the programs that use the lock objects to manage locking and unlocking of records. These modules need to be created for both enqueue and dequeue operations.
Example: Creating an Enqueue Lock Module
- Access Transaction SE37
Open transaction ‘SE37’ to create a new function module.
- Create a New Function Module
– Enter a name for the function module (e.g., ‘Z_ENQUEUE_MY_LOCK’).
– Click “Create.”
- Define the Function Module Properties
– Enter a short description for the function module.
– Specify the import and export parameters as needed.
- Add the Lock Code
– Use the ‘ENQUEUE_’ function module to set locks on the desired records.
Example code snippet:
CALL FUNCTION ‘ENQUEUE_EZMY_LOCK_OBJECT’
EXPORTING
field1 = <value>
field2 = <value>
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
- Save and Activate
– Save your entries and activate the function module.
Example: Creating a Dequeue Lock Module
- Access Transaction SE37
Open transaction ‘SE37’ to create a new function module for dequeue operations.
- Create a New Function Module
– Enter a name for the function module (e.g., ‘Z_DEQUEUE_MY_LOCK’).
– Click “Create.”
- Define the Function Module Properties
– Enter a short description for the function module.
– Specify the import and export parameters as needed.
- Add the Unlock Code
– Use the ‘DEQUEUE_’ function module to release locks on the desired records.
Example code snippet:
CALL FUNCTION ‘DEQUEUE_EZMY_LOCK_OBJECT‘
EXPORTING
field1 = <value>
field2 = <value>
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
- Save and Activate
– Save your entries and activate the function module.
Example Scenario: Implementing Lock Objects
Consider an example where you need to manage access to customer records. You would define a lock object to handle customer record locks and create enqueue and dequeue function modules to manage these locks.
- Define Lock Object
Create a lock object ‘ZCUSTOMER_LOCK’ specifying the `CUSTOMER` table and relevant fields.
- Create Enqueue Module
Create the function module ‘Z_ENQUEUE_CUSTOMER’ using the ‘ENQUEUE_EZCUSTOMER_LOCK’ function.
- Create Dequeue Module
Create the function module ‘Z_DEQUEUE_CUSTOMER’ using the ‘DEQUEUE_EZCUSTOMER_LOCK’ function.
Author : Aniket Pawar, 9373518385
24DDIC3007 – Lock Objects Types and Creation Steps
Understanding Lock Objects
Lock objects in SAP are used to manage the locking mechanism for database records. They ensure that only one user can modify a particular record at a time, preventing data inconsistencies and conflicts. There are primarily two types of lock modules:
Enqueue Lock Objects
Dequeue Lock Objects
- Enqueue Lock Objects
Enqueue lock objects are used to lock database records for writing operations. They prevent other users from modifying the same records simultaneously. Enqueue locks are typically created when a user starts editing a record and are released when the editing session ends.
- Dequeue Lock Objects
Dequeue lock objects are used to release locks that were previously set by enqueue lock objects. They are essential for ensuring that locks are correctly managed and released, allowing other users to access and modify records once the original user’s session is completed.
Steps to Create Lock Objects
Creating lock objects involves defining lock modules and configuring their parameters. Below are the steps to create both enqueue and dequeue lock objects in ABAP.
Step 1: Define a Lock Object
- Access the ABAP Dictionary
Open the ABAP Dictionary by entering transaction code `SE11` in the SAP GUI.
- Create a New Lock Object
– Select “Lock Object” from the object type menu.
– Enter a name for the lock object (e.g., ‘ZMY_LOCK_OBJECT’).
– Click “Create.”
- Define the Lock Object Properties
– Enter a short description for the lock object.
– Choose “Enqueue” as the type of lock object.
- Specify the Lock Parameters
– Define the tables and fields that will be used for locking.
– Specify the lock modes (e.g., shared or exclusive locks).
- Save and Activate
– Save your entries and activate the lock object.
Step 2: Create Lock Modules
Lock modules are the programs that use the lock objects to manage locking and unlocking of records. These modules need to be created for both enqueue and dequeue operations.
Example: Creating an Enqueue Lock Module
- Access Transaction SE37
Open transaction ‘SE37’ to create a new function module.
- Create a New Function Module
– Enter a name for the function module (e.g., ‘Z_ENQUEUE_MY_LOCK’).
– Click “Create.”
- Define the Function Module Properties
– Enter a short description for the function module.
– Specify the import and export parameters as needed.
- Add the Lock Code
– Use the ‘ENQUEUE_’ function module to set locks on the desired records.
Example code snippet:
CALL FUNCTION ‘ENQUEUE_EZMY_LOCK_OBJECT’
EXPORTING
field1 = <value>
field2 = <value>
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
- Save and Activate
– Save your entries and activate the function module.
Example: Creating a Dequeue Lock Module
- Access Transaction SE37
Open transaction ‘SE37’ to create a new function module for dequeue operations.
- Create a New Function Module
– Enter a name for the function module (e.g., ‘Z_DEQUEUE_MY_LOCK’).
– Click “Create.”
- Define the Function Module Properties
– Enter a short description for the function module.
– Specify the import and export parameters as needed.
- Add the Unlock Code
– Use the ‘DEQUEUE_’ function module to release locks on the desired records.
Example code snippet:
CALL FUNCTION ‘DEQUEUE_EZMY_LOCK_OBJECT‘
EXPORTING
field1 = <value>
field2 = <value>
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
- Save and Activate
– Save your entries and activate the function module.
Example Scenario: Implementing Lock Objects
Consider an example where you need to manage access to customer records. You would define a lock object to handle customer record locks and create enqueue and dequeue function modules to manage these locks.
- Define Lock Object
Create a lock object ‘ZCUSTOMER_LOCK’ specifying the `CUSTOMER` table and relevant fields.
- Create Enqueue Module
Create the function module ‘Z_ENQUEUE_CUSTOMER’ using the ‘ENQUEUE_EZCUSTOMER_LOCK’ function.
- Create Dequeue Module
Create the function module ‘Z_DEQUEUE_CUSTOMER’ using the ‘DEQUEUE_EZCUSTOMER_LOCK’ function.
Author : Aniket Pawar, 9373518385