原文链接:https://blog.csdn.net/sinat_38119716/article/details/121406275
RFC:ENQUEUE_READ 读取的是SM12的数据
RFC:ENQUEUE_READ2 读取的是SMENQ的数据
SM12 和 SMENQ 的数据其实是一样的,只是一个是旧的TCODE 一个是新的
解锁用的都是RFC: ENQUE_DELETE
通过代码解锁SM12中被锁定目标
garg为对象的名字,可以是锁参数的部分内容
LT_ENQ参考结构seqg3
LT_RAW_ENQ参考结构seqg7
1. 加锁与解锁
代码如下(示例):
BOBF标准锁一般采用以下方法加解锁 (锁的持有是从调用锁定函数后至程序退出前)
* 加锁
DATA:iv_key type /BOBF/CONF_KEY.
CALL FUNCTION 'ENQUEUE_/BOBF/E_LIB_2'
EXPORTING
mode_/bobf/s_lib_enqueue_node = 'E'
mandt = sy-mandt
bo_name = ztest=>sc_bo_name
key = iv_key
* X_BO_NAME = ' '
x_key = 'X'
x_key2 = 'X'
x_node_name = 'X'
_scope = '3'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc EQ 0.
ENDIF.
*解锁
CALL FUNCTION 'DEQUEUE_/BOBF/E_LIB_2'
EXPORTING
mode_/bobf/s_lib_enqueue_node = 'E'
mandt = sy-mandt
bo_name = ztest=>sc_bo_name
key = ls_key-db_key
* X_BO_NAME = ' '
* X_KEY = ' '
* _SCOPE = '3'
* _SYNCHRON = 'X'
* _COLLECT = ' '
.
2. 读取与解锁
读需要的锁并解除锁定 (已知KEY值)
DATA:
lt_enq TYPE STANDARD TABLE OF seqg3,
lv_subrct TYPE sy-subrc,
lv_garg TYPE seqg3-garg,
ls_enq TYPE seqg3.
lv_garg(3) = sy-mandt.
lv_garg+3(30) = ztest=>sc_bo_name.
lv_garg+33 = db_key.
lv_garg+95 = '00000000000000000000000000000000'.
* 读取锁
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
garg = lv_garg
TABLES
enq = lt_enq
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc = 0.
* 解锁
CALL FUNCTION 'ENQUE_DELETE'
EXPORTING
check_upd_requests = 1
* SUPPRESS_SYSLOG_ENTRY = ' '
IMPORTING
subrc = lv_subrct
TABLES
enq = lt_enq.
ENDIF.
以上