首先SE11 建表
其次 SE11 创建锁,默认类型 E
最后,在程序中使用锁
CONSTANTS: lc_e TYPE bapi_mtype VALUE 'E',
lc_s TYPE bapi_mtype VALUE 'S',
lc_000 TYPE syst_msgno VALUE '000',
lc_ms TYPE syst_msgid VALUE '/BMW/CN_D0338_MSG'.
DATA: lt_log TYPE TABLE OF ztestlog.
DATA(ls_log) = VALUE ztestlog( werks = iv_werks
lgort = iv_lgort
lpartfam = iv_lpartfam
callofftype = iv_callofftype
zdatetime = iv_zdatetime
lifnr = iv_lifnr
z01order = iv_z01order
vbeln = iv_vbeln
zpstat = iv_zpstat
zfilename = iv_zfilename ).
APPEND ls_log TO lt_log.
CALL FUNCTION 'ENQUEUE_EZTESTLOG'
EXPORTING
mode_ztestlog = lc_e
mandt = sy-mandt
werks = iv_werks
lgort = iv_lgort
lpartfam = iv_lpartfam
callofftype = iv_callofftype
zdatetime = iv_zdatetime
lifnr = iv_lifnr
z01order = iv_z01order
vbeln = iv_vbeln
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc = 0.
MODIFY ztestlog FROM TABLE lt_log.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
CALL FUNCTION 'DEQUEUE_EZTESTLOG'
EXPORTING
mode_ztestlog = lc_e
mandt = sy-mandt
werks = iv_werks
lgort = iv_lgort
lpartfam = iv_lpartfam
callofftype = iv_callofftype
zdatetime = iv_zdatetime
lifnr = iv_lifnr
z01order = iv_z01order
vbeln = iv_vbeln.
ENDIF.