‎2011 Sep 06 10:46 AM
At the beginning of a Z program, I use locking object ENQUEUE_EPROG, to prevent the execution in parallel of the program. Before the termination of the program, do I unlock with DEQUEUE_EPROG.
The problem is that, after the call BAPI_TRANSACTION_COMMIT, the lock on the program disappears (I control with SM12). This is not good, because I need the lock until the end of the program.
The questions:
1. And 'possible to solve this problem by using ENQUEUE / DEQUEUE?
2. If it is not possible with ENQUEUE / DEQUEUE, in what other ways can I do?
program = sy-repid.
CALL FUNCTION 'ENQUEUE_EPROG'
EXPORTING
mode_trdir = 'E'
programm = program
* X_PROGRAMM = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
program = sy-repid.
CALL FUNCTION 'DEQUEUE_EPROG'
EXPORTING
programm = sy-repid
EXCEPTIONS
OTHERS = 1.
Ciao,
Serena
‎2011 Sep 06 11:04 AM
Hi Serena,
I guess you need to change the parameter "_SCOPE " to "1" instead of the default "2".
The documentation says,
Definition of the lock duration with respect to an SAP LUW. Possible entry values include "1" for handling the lock in the same program, "2" for transferring the lock to the update, and "3" for handling the lock in the program and in the update.
change the code as shown below,
program = sy-repid.
CALL FUNCTION 'ENQUEUE_EPROG'
EXPORTING
mode_trdir = 'E'
programm = program
* X_PROGRAMM = ' '
_SCOPE = '1' "Change the default value to "1"
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
program = sy-repid.
CALL FUNCTION 'DEQUEUE_EPROG'
EXPORTING
programm = sy-repid
EXCEPTIONS
OTHERS = 1.
Regards,
Chen
‎2011 Sep 06 11:04 AM
Hi Serena,
I guess you need to change the parameter "_SCOPE " to "1" instead of the default "2".
The documentation says,
Definition of the lock duration with respect to an SAP LUW. Possible entry values include "1" for handling the lock in the same program, "2" for transferring the lock to the update, and "3" for handling the lock in the program and in the update.
change the code as shown below,
program = sy-repid.
CALL FUNCTION 'ENQUEUE_EPROG'
EXPORTING
mode_trdir = 'E'
programm = program
* X_PROGRAMM = ' '
_SCOPE = '1' "Change the default value to "1"
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
program = sy-repid.
CALL FUNCTION 'DEQUEUE_EPROG'
EXPORTING
programm = sy-repid
EXCEPTIONS
OTHERS = 1.
Regards,
Chen
‎2011 Sep 06 11:18 AM
Thanks to Chen, with the SCOPE = '1 ' works fine.
Please, one more question: where can I find documentation for ENQUEUE_EPROG and DEQUEUE_EPROG to understand the possible values ​​for all parameters?
Serena
‎2011 Sep 06 11:23 AM
Hi Serena,
Good to hear that the issue is resolved, there is no documentation for that FM, but you could always look at the documentation available at the Data Element level(If the import/export....parameter are referring to a data element/structure/table type etc).
In this case as there is no reference to a DDIC element, you will have to read the documentation on COMMIT WORK, as COMMIT WORK not only does commit but also releases the locks(there are other things too) ...to know more do a F1 on COMMIT WORK
Regards,
Chen
‎2011 Sep 06 11:27 AM
Thanks Chen ... Something new to me ...
What about Lock functions which are not remotely enabled. I think the parameter Scope only appeares when we mark the check box "Allow RFC" while creating a lock object. I dont have sap connectivity now...Will check it later
Kesav
‎2011 Sep 06 11:30 AM
Hello Serena,
Please, one more question: where can I find documentation for ENQUEUE_EPROG and DEQUEUE_EPROG to understand the possible values ​​for all parameters?
Had you asked this question 13yrs ago(when Google was not there), i would not have been amused.
It's 2011 & you've Google at your disposal. So google it out 😄
@Keshav: [_SCOPE|http://help.sap.com/saphelp_nw2004s/helpdata/en/48/e98137dae2424be10000009b38f8cf/frameset.htm] controls who owns the lock. SAP documentation on LUWs & Locking mechanism is very exhaustive. Read them in your leisure, they make a good read
BR,
Suhas
PS: Comments are made in good spirit. Please don't take it otherwise!
Edited by: Suhas Saha on Sep 6, 2011 4:01 PM