描述:某些单据进行修改时,需要锁定数据
方法步骤:
1、se11:可copy创建新锁 EZSDDH
2、输入需要锁定的主表,锁参数会根据主键自动补填
3、激活后,会生成对应的锁函数
ENQUEUE_EZSDDH :锁定表
DEQUEUE_EZSDDH:解锁表
4、代码使用如下:
FORM frm_lock USING p_mode
p_bukrs
p_zsddh.
IF p_mode = 'L'. "LOCK
CALL FUNCTION 'ENQUEUE_EZSDDH'
EXPORTING
mode_ztyddh = 'E'
mandt = sy-mandt
zsddh = p_zsddh
bukrs = p_bukrs
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.
ELSEIF p_mode = 'U'. "UNLOCK
CALL FUNCTION 'DEQUEUE_EZSDDH'
EXPORTING
mode_ztyddh = 'E'
mandt = sy-mandt
zsddh = p_zsddh
bukrs = p_bukrs.
ENDIF.
ENDFORM.