Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ENQUEUE_EPROG and BAPI_TRANSACTION_COMMIT

Former Member
0 Likes
1,441

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,215

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

5 REPLIES 5
Read only

Former Member
0 Likes
1,216

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

Read only

0 Likes
1,215

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

Read only

0 Likes
1,215

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

Read only

0 Likes
1,215

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,215

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