描述:某些单据进行修改时,需要锁定数据
方法步骤:
1、se11:可copy创建新锁 EZSDDH
2、输入需要锁定的主表,锁参数会根据主键自动补填
3、激活后,会生成对应的锁函数
ENQUEUE_EZSDDH :锁定表
DEQUEUE_EZSDDH:解锁表
4、代码使用如下:
FORM frm_lock USING p_modep_bukrsp_zsddh.IF p_mode = 'L'. "LOCKCALL FUNCTION 'ENQUEUE_EZSDDH'EXPORTINGmode_ztyddh = 'E'mandt = sy-mandtzsddh = p_zsddhbukrs = p_bukrsEXCEPTIONSforeign_lock = 1system_failure = 2OTHERS = 3.IF sy-subrc <> 0.MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.ENDIF.ELSEIF p_mode = 'U'. "UNLOCKCALL FUNCTION 'DEQUEUE_EZSDDH'EXPORTINGmode_ztyddh = 'E'mandt = sy-mandtzsddh = p_zsddhbukrs = p_bukrs.ENDIF.ENDFORM.