首页 > 代码库 > BAPI: TRANSACTION_BEGIN的作用

BAPI: TRANSACTION_BEGIN的作用

大概知道是启动一个新会话,

CALL FUNCTION ‘TRANSACTION_BEGIN‘

业务数据处理,

CALL FUNCTION ‘TRANSACTION_END‘

 

详细功能不清楚。

 

      CLEAR G_TRANSACTION_ID.

**1.Transaction control for BAPIs
      CALL FUNCTION TRANSACTION_BEGIN
        IMPORTING
          TRANSACTION_ID = G_TRANSACTION_ID.
**2.BAPIs for Creating/Changing Matl Data
      CALL FUNCTION BAPI_MATERIAL_SAVEDATA
        EXPORTING
          HEADDATA       = WA_HEADER
          PLANTDATA      = WA_MARC
          PLANTDATAX     = WA_MARCX
          VALUATIONDATA  = WA_MBEW
          VALUATIONDATAX = WA_MBEWX
        TABLES
          RETURNMESSAGES = IT_RETURN.

      READ TABLE IT_RETURN WITH KEY TYPE = E.
      IF SY-SUBRC EQ 0.
*get reprocess data and error log
        MOVE-CORRESPONDING IT_UPLOAD TO IT_ELOG.
        MOVE IT_RETURN-MESSAGE TO IT_ELOG-REASON.
        APPEND IT_ELOG.
      ELSE.
*get successful log
        MOVE-CORRESPONDING IT_UPLOAD TO IT_SLOG.
        APPEND IT_SLOG.
        CALL FUNCTION TRANSACTION_STATUS
          IMPORTING
            STATUS = G_STATUS_OF_TRANSACTION.
        IF G_STATUS_OF_TRANSACTION = COMMIT_WORK.
          COMMIT WORK AND WAIT.
        ENDIF.
        CALL FUNCTION TRANSACTION_END
          EXPORTING
            TRANSACTION_ID = G_TRANSACTION_ID.

      ENDIF.

 

BAPI: TRANSACTION_BEGIN的作用