abap--如何获取sap标准表的相关的锁(lock)

最近经常有abap问关于锁的问题,我特此收集了一些资料,供大家参考,也请大家指正。

1.sap锁的概念
sap为了同步同时多个用户操作同一数据,防止数据出现不一致性而采用了锁机制。一般 sap会在操作数据前设置锁,防止第二个用户进行修改操作,当操作结束后系统在释放锁。

2.SAP锁的类型
Exclusive lock

The locked data can be read or processed by one user only. A request for another exclusive lock or for a shared lock is rejected.

Shared lock

Several users can read the same data at the same time, but as soon as a user edits the data, a second user can no longer access this data. Requests for further shared locks are accepted, even if they are issued by different users, but exclusive locks are rejected.

Exclusive but not cumulative lock

Exclusive locks can be requested by the same transaction more than once and handled successively, but an exclusive but not cumulative lock can only be requested once by a given transaction. All other lock requests are rejected.

3.相关TCODE
SE11

4.相关表
DD25L:组合标题(方式,MC目标,锁定目标)(纪录了锁主表)
DD25T:
DD26S:视图的基本表和外来码关系(纪录了所有和锁相关的表)
DD27S:合计(视图,MC对象,锁定对象)字段

5.相关函数
RS_DD_ENQU_EDIT
RS_DD_ENQU_ADD

6.获取表相关锁的列表程序
REPORT  ZRFI0090 LINE-COUNT 70
                 LINE-SIZE  255
                 NO STANDARD PAGE HEADING.
type-pools: slis.
tables: DD02L,dd26s.
data: begin of g_tab occurs 10,
  TABNAME like dd26s-TABNAME,
  VIEWNAME type dd26s-VIEWNAME,
  ename like EMFIN-FBEMFIN,
  dname like EMFIN-FBEMFIN,
end of g_tab.
data g_fcat  type slis_t_fieldcat_alv.
data:  g_fieldcat type slis_fieldcat_alv.
select-options s_table for dd02l-TABNAME default 'VBAK'.

end-of-selection.
  select dd26s~TABNAME dd25l~VIEWNAME
  INTO CORRESPONDING FIELDS OF TABLE g_tab
  from dd26s
  inner join dd25l
    on dd26s~VIEWNAME = dd25l~VIEWNAME
       and dd25l~AGGTYPE = 'E'
    where TABNAME in s_table.
  loop at g_tab.
    concatenate 'ENQUEUE_' g_tab-VIEWNAME into g_tab-ename.
    concatenate 'DEQUEUE_' g_tab-VIEWNAME into g_tab-dname.
    modify g_tab.
  endloop.

  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name     = 'ZTEST4'
      I_INTERNAL_TABNAME = 'G_TAB'
      i_inclname         = 'ZTEST4'
    CHANGING
      ct_fieldcat        = g_fcat.

  g_fieldcat-fieldname = 'ENAME'.
  g_fieldcat-seltext_s = '加锁函数名'.
  append g_fieldcat to g_fcat.

 g_fieldcat-fieldname = 'DNAME'.
  g_fieldcat-seltext_s = '解锁函数名'.
  append  g_fieldcat to g_fcat.

  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
*      i_callback_program       = repname
*      i_callback_user_command  = g_user_command
*      i_structure_name         = 'INV'
*      is_layout                = layout
       it_fieldcat              = g_fcat
*      is_variant               = g_variant
*      it_events                = events[]
*      i_callback_pf_status_set = 'F01_ALV_EVENT_PF_STATUS_SET'
    tables
      t_outtab                 = g_tab.

7.通过断点找程序所用到的锁
用se38打开程序LSENAF01,并定位到send_enqueue子过程,在该过程中的任一语句设置断点。完成断点设置后,则去执行标准tcode,系统就会在程序调用锁时自动停止在断点处,这时你就可以通过调用堆栈获取加锁函数(ENQUEUE_XXXXXX),其中"XXXXXX"就是锁名称,你就可以通过SE11查看锁信息。 

8.有多个表的锁的样例
锁:EMEKKOE
  主表:EKKO-->E 专用累积
  从表:EKPO-->E 专用累积
  参数:   

abap--如何获取sap标准表的相关的锁(lock)

你可能感兴趣的:(Access)