‎2005 Nov 16 9:25 AM
Hi ,
i have a program that unite some table to one big table,
and i look for lock those tables while the program is running.
lock table just for editing,the users can watch.
there is a way to do this???
‎2005 Nov 16 9:30 AM
Hi,
creaet a lock object with se11
or use fm ENQUEUE_E_TABLE
Andreas
‎2005 Nov 16 9:35 AM
Gil,
U can have a LOCK at the Table Level.
ENQUE* and DEQUE* are the general Function Modules(check out them in SE37) used for LOCKING and UNLOCKING. For every standard tables, we have these Function Modules given by SAP. For Z tables, we have create them using SE11.
Have a look at the following link:
http://help.sap.com/saphelp_47x200/helpdata/en/a2/3547360f2ea61fe10000009b38f839/frameset.htm
Thanks
Kam
Note :Allot points for all worthful postings
‎2005 Nov 16 9:35 AM
Hi Gil,
You can use the ENQUEUE_E_TABLE function module to do that.
If it is ztable u need to create lock object and use it.
Thanks & Regards,
Siri.
Message was edited by: Srilatha T
‎2005 Nov 16 9:47 AM
Hi Gil
Look at the Function group /1BCDWBEN/SEN4 from se80
You will find a lot of Enqeue Deqeue FMs. Use one of the according your requirement.
In your case it would be appropraite to use ENQUEUE_E_TABLE
as mentioned earlier.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
tabname = tabname
EXCEPTIONS
*foreign_lock = 4
system_failure = 8.
Regards
Amit
‎2005 Nov 16 10:35 AM
i think this will help but do you have some idea how to do it in a smart way to 10 table instead of using this FM * 10./
Thnaks.
‎2005 Nov 16 10:48 AM
Hi Gil,
See some info from Help.
<b>In order to be able to define SAP locks for a table, you must first create a lock object for the table via Development->Dictionary.
If the data for an application object is distributed among several database tables, it is often necessary to be able to lock these tables simultaneously. It is therefore possible to include several tables in a
lock object, althought they must be related via appropriate foreign key relationships. The tables involved in a lock object are also known as its base tables.</b>
In the lockobject you can give all the dependent tables.
Hope this is helpful to you.
Thanks & Regards,
Siri.
Message was edited by: Srilatha T
‎2005 Nov 16 10:55 AM
Hi,
try:
append your tab-names in an itab.
loop at itab.
sptab-TABNAME = itab-name.
sptab-VARKEY = SY-MANDT.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
TABNAME = sptab-TABNAME
VARKEY = sptab-VARKEY
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE x001(00) with 'enqued' itab-name.
ENDIF.
endloop.
regards Andreas
‎2005 Nov 16 10:58 AM
Hi,
you may try this one
tables: z1---z10
begin of str occurs 0,
tabname(30),
end of str.
append your table names to str.
Loop at str.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = str-tabname
VARKEY =
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endloop.
‎2005 Nov 16 1:17 PM
Hi,
i did this like that:
-
FORM locktable USING P_ITAB_TABNAME.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = P_ITAB_TABNAME
VARKEY =
X_TABNAME = ' '
X_VARKEY = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " locktable
-
and when i'm runnning the program it crash and give me this msg:
CALL_FUNCTION_CONFLICT_TYPE.
what did i do wrong???
‎2005 Nov 16 1:22 PM
Hi Gil,
Check how u declared the P_ITAB_TABNAME.
May be type is mismatching.
You declare one local variable like
<b>data tabname type RSTABLE-TABNAME.
tabname = P_ITAB_TABNAME.</b>
Pass the tabname to function module.
Thanks,
Siri.
Message was edited by: Srilatha T
‎2005 Nov 16 1:23 PM
P_ITAB_TABNAME should be of type RSTABLE-TABNAME
Data: P_ITAB_TABNAME type RSTABLE-TABNAME.
Regards
Raja
‎2005 Nov 16 1:27 PM
You don't have to lock each individual table like that. You can create one lock object including all those tables and call the ENQUEUE and DEQUEUE function modules at the appropriate times in your code. This will lock all of them at the same time. Others have pointed you in the right direction as to how to create the lock object.
Srinivas