GMCODE表T158G-
01-MB01-采购订单收货
02-MB31-生产订单的货物收据
03-MB1A-发货
04-MB1B-转账过账
05-MB1C-输入其他货物收据
06-MB11
07-MB04
"bapi定义
DATA: ls_gmhead TYPE bapi2017_gm_head_01,
ls_gmcode TYPE bapi2017_gm_code,
ls_gmheadret TYPE bapi2017_gm_head_ret,
lt_gmitem TYPE TABLE OF bapi2017_gm_item_create,
ls_gmitem TYPE bapi2017_gm_item_create,
ls_return TYPE bapiret2,
lt_return TYPE TABLE OF bapiret2.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = ls_gmhead
goodsmvt_code = ls_gmcode
IMPORTING
goodsmvt_headret = ls_gmheadret
TABLES
goodsmvt_item = lt_gmitem
return = lt_return.
生产订单收货 MVT_IND = ‘F’ 采购订单收货 MVT_IND = ‘B’
LOOP AT lt_return INTO ls_return WHERE type CA ‘AEX’.
ENDLOOP.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.