使用通过锁表函数 ENQUEUE_E_TABLE
针对 函数 varkey 入参,锁表 SFLIGHT
varkey = |{ sy-mandt }{ |AA| }{ |0017| }{ |20210916| }|.
直接拼接主键就会出现锁表条目数锁不住的情况,SE11、SE16还可编辑
需要改进写法
像下面这样赋值即可针对行项目数据加锁
DATA: BEGIN OF ls_enqu_sflight.
DATA: mandt LIKE sflight-mandt.
DATA: carrid LIKE sflight-carrid.
DATA: connid LIKE sflight-connid.
DATA: fldate LIKE sflight-fldate.
DATA: END OF ls_enqu_sflight.DATA: lv_varkey LIKE rstable-varkey.ls_enqu_sflight-mandt = sy-mandt.
ls_enqu_sflight-carrid = 'AA'.
ls_enqu_sflight-connid = '0017'.
ls_enqu_sflight-fldate = '20210916'.lv_varkey = ls_enqu_sflight.CALL FUNCTION 'ENQUEUE_E_TABLE'EXPORTINGtabname = 'SFLIGHT'varkey = lv_varkeyEXCEPTIONSforeign_lock = 1system_failure = 2OTHERS = 3.
IF sy-subrc IS INITIAL.ENDIF.
定义锁主键工作区
像上面调用即可成功锁住行项目