首页 > 代码库 > Commit 函数WAIT = 'X'.

Commit 函数WAIT = 'X'.

 

BAPI_TRANSACTION_COMMIT

IF WAIT EQ SPACE.
  COMMIT WORK.
ELSE.
  COMMIT WORK AND WAIT.
  IF SY-SUBRC NE 0.
    CALL FUNCTION BALW_BAPIRETURN_GET2
         EXPORTING
              TYPE       = E
              CL         = S&
              NUMBER     = 150
         IMPORTING
              RETURN     = RETURN.
  ENDIF.
ENDIF.
CALL FUNCTION BUFFER_REFRESH_ALL.

 

使用API 函数需要注意:要使用      wait = ‘X‘.

不然多条会dump

  IF ex_statu NE ‘E‘.
    CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘
      EXPORTING
        wait = ‘X‘.
    READ TABLE lt_get INTO ls_get INDEX 1.
    ex_lifnr = ls_get-header-object_instance-lifnr.
    ex_statu = ‘S‘.
    ex_msg  = ‘创建供应商成功!‘.
  ELSE.
    CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘.
* ROLLBACK WORK.
* ex_statu = ‘E‘.
* ex_msg  = ‘创建供应商失败!‘.
  ENDIF.

 

CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘. 清空缓存 很重要!!!

 

Commit 函数WAIT = 'X'.