‎2006 Aug 02 4:44 AM
Hi
i have a custom transaction in SAP.
if a user is currently running the transaction and that same time if any other user tries to run the same transaction i should display error that "you cannot run the transation at this time". in short only one person can run the transaction at any given point of time.
can anyone help me how to achieve this
awaiting your reply and thanks in advance
regards
Sai easwar
‎2006 Aug 02 5:28 AM
Hi Sai,
Create a Lock object with mode 'E' on the tables used in the custom program. Activate the lock object, when u do it 2 Function Modules are generated<b>[ENQUEUE_<Lock_object_name> and DEQUEUE_<Lock_object_name> ]</b> CALL The Enqueue module in PBO which is used to lock and call the Dequeue module after exit statement in PAI to Unlock.
For Further Information on Lock objects check out SAP Library.
Regards:-
Santosh
‎2006 Aug 02 5:34 AM
hi,
i guess lock obejcts are for tables
i want to know if the transaction/program is currently being run by someone or not..
the table is in a different box altogother..i am running the program in one server and the table to be updated is in anotehr server
regards
sai easwar
‎2006 Aug 02 6:00 AM
Hi Sai,
Check out this example code-
This code is for locking the table for calorific values(te450).
In the same way, you should find a function module for your table. You can find it by going to se37 transaction and typing 'ENQUEUE*' and press F4.
CONSTANTS:
lc_exc_lock TYPE c VALUE 'E',
lc_enqueue_scope TYPE c VALUE '2',
lc_dequeue_scope TYPE c VALUE '3'.
Lock the table te450
CALL FUNCTION 'ENQUEUE_EZCALOR_VALUE'
EXPORTING
mode_te450 = lc_exc_lock
scope = lcenqueue_scope
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
EXIT.
ENDIF.
Modifying the te450 table.
MODIFY te450 FROM TABLE lit_te450.
IF sy-subrc NE 0.
ENDIF.
Unlock the te450 table.
CALL FUNCTION 'DEQUEUE_EZCALOR_VALUE'
EXPORTING
mode_te450 = lc_exc_lock
scope = lcdequeue_scope.
Reward points if you find this example useful.
Regards,
Tanuja.