SAP技术干货SAP

锁程序,锁表

2017-11-22  本文已影响19人  Mmm_余安

当程序或者表不允许两个同时操作时。

CALL FUNCTION 'ENQUEUE_ES_PROG'
    EXPORTING
*     MODE_TRDIR     = 'E'
      name           = 'ZFID001'   "程序名
*     X_NAME         = ' '
*     _SCOPE         = '2'
*     _WAIT          = ' '
*     _COLLECT       = ' '
    EXCEPTIONS
      foreign_lock   = 1
      system_failure = 2
      OTHERS         = 3.
  IF sy-subrc <> 0.
    CALL FUNCTION 'MESSAGE_TEXT_BUILD'
      EXPORTING
        msgid               = sy-msgid
        msgnr               = sy-msgno
        msgv1               = sy-msgv1
        msgv2               = sy-msgv1
        msgv3               = sy-msgv1
        msgv4               = sy-msgv1
      IMPORTING
        message_text_output = ls_mess.

    MESSAGE e000(zfi) WITH ls_mess .
  ENDIF.
lv_varkey = sy-mandt && sy-datum+0(4) && '10'.


  CALL FUNCTION 'ENQUEUE_E_TABLE'
    EXPORTING
      mode_rstable   = 'E'
      tabname        = 'ZTFI004'
      varkey         = lv_varkey
      x_tabname      = ' '
      x_varkey       = ' '
      _scope         = '2'
      _wait          = ' '
      _collect       = ' '
    EXCEPTIONS
      foreign_lock   = 1
      system_failure = 2
      OTHERS         = 3.
  IF sy-subrc <> 0.
    CALL FUNCTION 'MESSAGE_TEXT_BUILD'
      EXPORTING
        msgid               = sy-msgid
        msgnr               = sy-msgno
        msgv1               = sy-msgv1
        msgv2               = sy-msgv1
        msgv3               = sy-msgv1
        msgv4               = sy-msgv1
      IMPORTING
        message_text_output = ls_mess.

    MESSAGE e000(zfi) WITH ls_mess .
  ENDIF.
上一篇 下一篇

猜你喜欢

热点阅读