2004 Oct 22 1:32 PM
HI!
I want to use the enqueue and dequeue functions but I don´t understand some parameters.
my table "MESSAGE" has 2 primary keys - session_id and message_id
now I want to select some lines, so I have to lock all entries but witch values must the SESSION_ID, MESSAGE_ID and the X_session_id, X_message_id parameters have.
for example:
this is the code I used to log the queue when I entered a new line (+ check if the session exist and so on)
after that I included a DEQUEUE.
CALL FUNCTION 'ENQUEUE_EZMA1_QUEUE'
EXPORTING
mode_zma1_queue = 'E'
mode_zma1_message = 'E'
mode_zma1_smsmessage = 'E'
session_id = 0.
RAISE other_failure.
ENDIF.
another question:
if the programm where i locked the Queue throws an exception - Do I allways have to write the dequeue function in the exception handler?
Otherwise the lock isn´t deleted, or?
mfg Max
2004 Oct 22 4:51 PM
Hi Markus,
The ENQUEUE and DEQUEUE mechanism (generated lock objects) are part of the explicit SAP locking method. In short it is capable of maintaining locks on an object during the entire transaction (while database locks are terminated at the end of a LUW). SAP refers to this as logical locks.
The locks placed by any ENQUEUE call will be terminated in the following cases:
1. Explicit call of the related DEQUEUE module. The lock conditions and modes must match.
2. Explicit call of the function module 'DEQUEUE_ALL'.
3. At the end of a transaction automatically, but only if NO update modules were called.
4. When update modules were called, the termination depend on the _SCOPE parameter:
_SCOPE = 1 --> Lock will be released at the end of the SAP transaction (but update called fm's cannot use the lock)
_SCOPE = 2 --> Lock will be released at the end of the transaction (asynchronously called fm's can rely on these lock). This is the default.
_SCOPE = 3 --> Lock will be released at the end of the SAP ntransaction (asynchronously called fm's can rely on these lock).
5. When a transaction terminates. Not with an error, but when the program has been left.
6. When a connection to a user fails.
7. Implicitly when the lock is removed via transaction SM12
So to answer your last question first: If the exception is handled AND your program still runs, YES you need to unlock it. If the exception is handled AND your program will stop, NO you do not need to unlock it. If the exception is unhandled (and thus an ABAP dump is generated), you cannot unlock it anymore, but SAP will do this for you.
Now in your specific case when calling 'ENQUEUE_EZMA1_QUEUE':
SESSION_ID should contain the fieldvalue of ZMA1-SESSION_ID (the one you want to lock).
MESSAGE_ID should contain the fieldvalue of ZMA1-MESSAGE_ID (the one you want to lock).
I assume the SESSION_ID comes before MESSAGE_ID: You can also lock SESSION_ID only (which locks ALL SESSION_ID's equal to your given value).
If you do NOT supply SESSION_ID and MESSAGE_ID (leave the INITIAL), you effectively lock your entire table (within the CLIENT).
The fields X_SESSION_ID and X_MESSAGE_ID are used to also allow for 'EMPTY' key fields. To prevent table locking, but to lock a record where SESSION_ID is filled, but MESSAGE_ID is empty (INITIAL), you will need to place an 'X' in the X_MESSAGE_ID field to make sure that this value is used for locking.
Hope this helps you along.
Regards,
Rob.
2004 Oct 24 7:25 PM
2004 Oct 25 9:10 AM
Hi Marcus,
Initial value of a numc[10] is '0000000000'.
Regards,
Komal.