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

Transaction Lock

Former Member
0 Likes
731

Hello dear SAP Gurus,

I have a Z program with a Z transaction that is used by two users, USER01 and USER02.

They are make confirmations of productions orders, using the bapi for confirmations.

How can I lock the USER01 and the USER02 to open two sessions of the same Z transaction without blocking each other?

Thanks in advance,

Adelmo Silva

Edited by: Rob Burbank on Nov 26, 2010 2:58 PM

4 REPLIES 4
Read only

Former Member
0 Likes
682

Maybe you can upload a flag to shared memory so when the second user try to execute the transaction, the program checks if the flag exists in memory, if its so, then interrumpt the process, otherwise continues executing the program.

best regards,

Felipe.

Read only

0 Likes
682

You can lock your Z program from execution using this pair of FMs: ENQUEUE_ESFUNCTION / DEQUEUE_ESFUNCTION.

In the beginning of program, call ENQUEUE_ESFUNCTION like this:

CALL FUNCTION 'ENQUEUE_ESFUNCTION'

EXPORTING

funcname = 'Z_PROGRAM' " name of your program

mode_tfdir = 'X'

EXCEPTIONS

foreign_lock = 4.

At the end of program, call:

CALL FUNCTION 'DEQUEUE_ESFUNCTION'

EXPORTING

funcname = 'Z_PROGRAM'.

P. S. In case if you will use shared memory, this should be SAP memory IMHO (SET/GET).

Read only

0 Likes
682

Thank you all.

I have created a Z table and everytime a user enters in the Z program, the table is updated. If the entry is found in the Z table, user can't open the transaction.

After a big search and a debug in CO02, I found the functions ENQUEUE_ESORDER and the DEQUEUE_ESORDER.

Thanks again.

Adelmo Silva

Edited by: Adelmo Silva on Nov 27, 2010 1:37 PM

Read only

former_member848108
Active Participant
0 Likes
682

Hi Adelmo,

Since you haven't implemented any lock mechanism in your program yet, the users wont be lock each other.

But for consistency, you need to make sure that they are not trying to confirm the same orders at the same time.

Find out the standard lock module (its name starts with ENQUEUE_) used to lock orders and call this FM in your Z-programm.

Regards,

Ozcan.