Lock data in Z-tables without a locking object
2013-01-28
If I needed to create locking entries in a ZCOISO table I had created, up to two days ago I would have gone to SE11 to create a locking object for the ZCOISO table so that I could then use the function module generated by the locking object to lock the data.
But not anymore.
Because now I know that function module ENQUEUE_E_TABLE exists. This FM allows locking entries to be created for any table, whether a Z-table or not, without having to create a specific locking object for the table.
data: l_tablename type tabname,
l_varkey type vim_enqkey,
lw_zcoiso type zcoiso.
lw_zcoiso-kunnr = '12345'.
l_varkey = lw_zcoiso.
l_tabname = 'ZCOISO'.
call function 'ENQUEUE_E_TABLE'
exporting
tabname = l_tabname
varkey = l_varkey
exceptions
foreign_lock = 1
system_failure = 2
others = 3.
Done. A locking entry is created for table ZCOISO, for the ‘12345’ table key.
Thanks to Michael Opoczynski for this tip.
Greetings from Abapinho.