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

table maintenance lock

Former Member
0 Likes
1,327

Hello;

i implemented a program to update/maintain a local table. The program calls SM31. The table has maintenance screen which is created by table maintenance generator. When two users want to update simultaneously, one of them locks the other. I want to add a control on one of the key fields to prevent this. If one user enters with key value A and the other enters with key value B then the system must let them both. Is that possible and how?

Thx in advance,

Ali

4 REPLIES 4
Read only

Former Member
0 Likes
860

Please use transaction SE54 for the table in question and choose Events from the menu. Then i think you can choose Event number 14 (Lock / Unlock event) and write your custom code to execute a certain way when a lock scenario gets triggered.

Read only

0 Likes
860

Hi Nareesh,

Thx for the answer. the problem with implementing the event is that lock object (E_TABLEE) has only file name as parameter but i need to check another key field to lock/unlock the table. i think first i have to save the value somewhere and check this everytime the program is called. what do u think?

Regards,

Ali

Edited by: Ali Abbasgil on Jan 3, 2008 10:31 AM

Read only

Former Member
0 Likes
860

If you want to validate before saving, my suggestion is you can use events

Event 01 BEFORE_SAVE_DATA and

Event 02 AFTER_SAVE_DATA.

In EVENT 01 BEFORE_SAVE_DATA the code can be something like this.

*-definitions in function pool

DATA: wa_ztable LIKE ztable, "custom table

v_error_flag,

f_index LIKE sy-tabix.

FORM before_save_data.

CLEAR v_error_flag.

LOOP AT total.

wa_ztable = total.

IF <action> = neuer_eintrag OR

<action> = aendern.

READ TABLE extract WITH KEY total.

IF sy-subrc EQ 0.

f_index = sy-tabix.

ELSE.

CLEAR f_index.

ENDIF.

IF wa_ztable-field1 IS INITIAL OR

wa_ztable-field2 IS INITIAL.

MESSAGE i398(00) WITH 'Fields must not be blank.'

'Data will not be saved'.

v_error_flag = 'X'.

EXIT.

ENDIF.

total = wa_ztable.

MODIFY total.

CHECK f_index GT 0.

extract = wa_ztable.

MODIFY extract INDEX f_index.

ENDIF.

ENDLOOP.

IF v_error_flag <> 'X'.

sy-subrc = 0.

ELSE.

sy-subrc = 4.

ENDIF.

ENDFORM.

Read only

Former Member
0 Likes
860

Hello;

i implemented a program to update/maintain a local table. The program calls SM31. The table has maintenance screen which is created by table maintenance generator. When two users want to update simultaneously, one of them locks the other. I want to add a control on one of the key fields to prevent this. If one user enters with key value A and the other enters with key value B then the system must let them both. Is that possible and how?

Thx in advance,

Ali

Hi Ali,

I am also in same situation can u please tell how ur problem gets solved.

Thanks

Chethan