I need to ensure that a given ABAP program is only running in one instance.
Here is what I tried so far:
1) FM TH_WPINFO
The problem with this is that the Z (custom) program calls lot of SAP function modules and when inside those, the WP_REPORT field of WPLIST table has something else and not the Z program name.
2) FM ENQUEUE_ESINDX
When I used the code below the following happened:
-The First instance runs fine
-The Second instance fails in the locking and exits the way it is supposed to but then
-If I run the program the Third time, it runs with a succesful lock - probably because the after second instance the lock was cleared???
CALL FUNCTION 'ENQUEUE_ESINDX' EXPORTING MODE_INDX = 'E' MANDT = SY-MANDT RELID = 'ZZ' SRTFD = PROGRAM * SRTF2 = * X_RELID = ' ' * X_SRTFD = ' ' * X_SRTF2 = ' ' * _SCOPE = '2' * _WAIT = ' ' * _COLLECT = ' ' EXCEPTIONS FOREIGN_LOCK = 1 SYSTEM_FAILURE = 2 OTHERS = 3.
Any other idea, how I could accomplish this?
Thanks a lot,