使用BAPI一定要提交和回滚(错误)
今天瞎了眼,交货单过账,提交半天没成功, 一直出现在SM12的锁定里,以为是做的BADI增强出了问题,DEBUG半天没毛病。
后来看代码才发现居然没提交(本来有提交代码的,但是做了个BDC测试,把那段代码给删了)。
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CONFIRM_DEC'
EXPORTING
HEADER_DATA = L_HEADER
HEADER_CONTROL = L_CONTROL
DELIVERY = DLV_NUMBER
TABLES
RETURN = L_RETURN.
READ TABLE L_RETURN WITH KEY TYPE = 'E' .
IF SY-SUBRC = 0 .
T_FLAG = 'X' .
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
LOOP AT L_RETURN.
I_MESSAGE_TAB-MSGID = L_RETURN-ID .
I_MESSAGE_TAB-MSGTY = L_RETURN-TYPE.
I_MESSAGE_TAB-MSGNO = L_RETURN-NUMBER.
I_MESSAGE_TAB-MSGV1 = L_RETURN-MESSAGE_V1.
I_MESSAGE_TAB-MSGV2 = L_RETURN-MESSAGE_V2.
I_MESSAGE_TAB-MSGV3 = L_RETURN-MESSAGE_V3.
APPEND I_MESSAGE_TAB.
CLEAR I_MESSAGE_TAB.
ENDLOOP.
CALL FUNCTION 'C14Z_MESSAGES_SHOW_AS_POPUP'
EXPORTING
I_MSGID = I_MESSAGE_TAB-MSGID
I_MSGTY = I_MESSAGE_TAB-MSGTY
I_MSGNO = I_MESSAGE_TAB-MSGNO
I_MSGV1 = I_MESSAGE_TAB-MSGV1
I_MSGV2 = I_MESSAGE_TAB-MSGV2
I_MSGV3 = I_MESSAGE_TAB-MSGV3
I_MSGV4 = I_MESSAGE_TAB-MSGV4
* I_LINENO =
TABLES
I_MESSAGE_TAB = I_MESSAGE_TAB.
ELSE.
MESSAGE '过账成功' TYPE 'S' .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
WAIT UP TO 1 SECONDS .
ENDIF.