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

Write protect for transaction

Former Member
0 Likes
1,060

Hi,

I have a dialog program callable by a transaction. In this program there are

many tab strips with a database table for each tab strip. You can see, change

and delete the data of the database tables on each tab strip.

Now it should be possible, that only one user can change and delete data at

the same time. So I have thought about writing a value in the memory and read

it every time at the beginning of the program.

If one user is starting the program and there isn´t an entry in the memory, the

memory should be set now. If another user is starting the program now, there

should be an entry in the memory, that I can protect the tables for changing and

deleting.

I tried it like that:


  DATA:  user  TYPE  sy-uname.

  IMPORT user FROM MEMORY ID 'user'.

  IF user IS INITIAL.
    user = sy-uname.
    EXPORT user TO MEMORY ID 'user'.
    CLEAR user.
  ENDIF.

It is working, if You call the transaction at once. The username is stored in the

memory.

But when I now start the transaction in another mode the same time, I´m not

getting any entry for the field 'user' in the memory.

Any ideas? Or do You have any better ways how to protect the data?

Thank You very much!

Reward points guaranteed.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
985

Hi,

use lock objects for your requirement

lockobject is created using se11

by default enqueue_<lock objectname>

dequeue_<lock objectname> are created

by SAP.

you can create at table level or row level lock.

CALL FUNCTION 'ENQUEUE_EZPPX0010A'

EXPORTING

MODE_ZPPDORD = 'E'

MANDT = SY-MANDT

WERKS = S_WERKS

AUFNR = X_LOCK_LEVEL

EXCEPTIONS

OTHERS = 1.

delete lock after each insertion

or use call function 'DEQUEUE_ALL'

CALL FUNCTION 'DEQUEUE_EZPPX0010A'

EXPORTING

MODE_ZPPDORD = 'E'

MANDT = SY-MANDT

WERKS = S_WERKS

AUFNR = X_LOCK_LEVEL

EXCEPTIONS

OTHERS = 1.

Regards

amole

REgards

amole

Hi,

use lock objects for your requirement

lockobject is created using se11

by default enqueue_<lock objectname>

dequeue_<lock objectname> are created

by SAP.

you can create at table level or row level lock.

CALL FUNCTION 'ENQUEUE_EZPPX0010A'

EXPORTING

MODE_ZPPDORD = 'E'

MANDT = SY-MANDT

WERKS = S_WERKS

AUFNR = X_LOCK_LEVEL

EXCEPTIONS

OTHERS = 1.

delete lock after each insertion

or use call function 'DEQUEUE_ALL'

CALL FUNCTION 'DEQUEUE_EZPPX0010A'

EXPORTING

MODE_ZPPDORD = 'E'

MANDT = SY-MANDT

WERKS = S_WERKS

AUFNR = X_LOCK_LEVEL

EXCEPTIONS

OTHERS = 1.

Regards

amole

REgards

amole

7 REPLIES 7
Read only

dani_mn
Active Contributor
0 Likes
985

HI,

better use the sap lock concept to lock the database entries.

use ENQUE AND DEQUE function modules of the database.

you can generate these for table from the transaction SE11.

REgards,

Read only

Former Member
0 Likes
985

Hi arna,

1. For such scenarios, using memory id is not the way.

2. Lock objects should be created via se11,

and used in the program,

to detect the locks.

regards,

amit m.

Read only

0 Likes
985

Thank You!

Can You tell me very to set the table lock in TA SE11?

Cheers

Read only

0 Likes
985

In t-code SE11 there is a radio button for Lock object select that and create a lock object for ur table.

Enter the primary and secondary tables there.

Ur lock name must start with EZ<name>

Read only

Former Member
Read only

Former Member
0 Likes
985

The better idea to implement SAP Standard Locking Mechanism to prevent data should be deleted from other users. If you are dealing with HR Module, then you can try using these FM's <b>BAPI_EMPLOYEE_ENQUEUE & BAPI_EMPLOYEE_DEQUEUE</b>.

To know more about this, please visit the below link.

<a href="http://help.sap.com/saphelp_nw04s/helpdata/en/c2/2d7037ecc92a7ee10000009b38f8cf/frameset.htm">Locking</a>

Regards,

Ramki.

Read only

Former Member
0 Likes
986

Hi,

use lock objects for your requirement

lockobject is created using se11

by default enqueue_<lock objectname>

dequeue_<lock objectname> are created

by SAP.

you can create at table level or row level lock.

CALL FUNCTION 'ENQUEUE_EZPPX0010A'

EXPORTING

MODE_ZPPDORD = 'E'

MANDT = SY-MANDT

WERKS = S_WERKS

AUFNR = X_LOCK_LEVEL

EXCEPTIONS

OTHERS = 1.

delete lock after each insertion

or use call function 'DEQUEUE_ALL'

CALL FUNCTION 'DEQUEUE_EZPPX0010A'

EXPORTING

MODE_ZPPDORD = 'E'

MANDT = SY-MANDT

WERKS = S_WERKS

AUFNR = X_LOCK_LEVEL

EXCEPTIONS

OTHERS = 1.

Regards

amole

REgards

amole