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

Locking Transaction

Former Member
0 Likes
896

Hi ,

i have created a z-tcode.if it is running,the other user who tries to run z-tcode

an error message should be raised.i should lock my txn if it is running.

at a time only one user can run the txn

thanks.

6 REPLIES 6
Read only

Former Member
0 Likes
815

Hi,

You can use EXPORT ..IMPORT..

Ex..

DATA: V_VALUE.

INITIALIZATION.

  • Get the value from the memory

IMPORT V_VALUE

FROM DATABASE INDX(ST) ID 'Z_RUNNING'.

IF SY-SUBRC = 0 AND V_VALUE = 'X'.

MESSAGE E208(00) WITH 'Program already running'.

ENDIF.

  • Export the value to the memory to lock the record.

V_VALUE = 'X'.

EXPORT V_VALUE TO DATABASE INDX(ST) ID 'Z_RUNNING'.

********************

********************

  • Do all your processing here...

********************

********************

END-OF-SELECTION.

  • Export the value to the memory to unlock ..

CLEAR V_VALUE.

EXPORT V_VALUE TO DATABASE INDX(ST) ID 'Z_RUNNING'.

Hope this helps.

Thanks,

Naren

Read only

Former Member
0 Likes
815

Hi,

I think you can use ENQUEUE and DEQUEUE Function Modules in the program to lock and unlock the respective transaction.

Example: Function Module 'DEQUEUE_ALL' for unlocking.

Hope this helps.

Thanks,

Srinivas

Read only

Former Member
0 Likes
815

Hi,

This can be done with small development.

- Create a Z table using se11 transaction. This has two field "transaction name" and "userid".

- Whenever you run the transaction, first thing you do is check this table for any entry. If there is already a entry exist with user-id ( let's say user-id XUSR01 ), then you give a error message that "XUSR01" is already executing transaction.

- If there is no entry is this table then add entry in table with "transaction name (ZTCOD)" and "user ID (XUSR01)" and continue the program

- Now let's another user tries to run the transaction ( let's say XUSR02 ), program first reads the table and find the record for XUSR01. So you give the error message "User XUSR01 is executing this transaction".

- And at the end of the transaction, when all the code has been executed, you remove the entry from the table. So not if somebody else now tries to execute the transaction, he can do it.

Let me know if you have any question.

Regards,

RS

Read only

Former Member
0 Likes
815

Hi

U should create an your own block object in SE11 based on TSTC table.

After creating the object, the system generates the fm to lock and unlock.

Or use the generical fm ENQUEUE_E_TABLE and DEQUEUE_E_TABLE for TSTC table.

Max

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
815

There are a few ways to do this with a few lock objects. Here is a way.

Regards,

Rich heilman

Read only

Former Member
0 Likes
815

solved on my own