无论哪种移动类型都是可以的,关健是你 header ,item ,serialnumber 这三个表的内容要正确
=================== HEADER ========
DATA i_lines TYPE i .
l_t_goodsmvt_item-material = .
l_t_goodsmvt_item-move_mat = .
IF v_havebatch = 'X'.
l_t_goodsmvt_item-batch = p_batch.
l_t_goodsmvt_item-move_batch = p_batch.
ENDIF.
l_t_goodsmvt_item-plant = .
l_t_goodsmvt_item-move_plant = .
SELECT SINGLE * FROM ekko WHERE ebeln = .
IF sy-subrc = 0 .
l_t_goodsmvt_item-vendor = ekko-lifnr.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_t_goodsmvt_item-vendor
IMPORTING
output = l_t_goodsmvt_item-vendor.
DESCRIBE TABLE l_t_goodsmvt_serialnumber LINES i_lines .
l_t_goodsmvt_serialnumber-matdoc_itm = i_lines + 1.
** Add suffix 'W' for MGR in PRC DC after PRC Phase 2
l_t_goodsmvt_serialnumber-serialno = .
IF ekpo-werks(1) = '4' "PRC DC
AND l_t_goodsmvt_item-vendor <> '116A'.
CONCATENATE 'W'
INTO l_t_goodsmvt_serialnumber-serialno.
ENDIF.
APPEND l_t_goodsmvt_serialnumber.
SELECT SINGLE * FROM ekpo WHERE ebeln =
AND ebelp = i_ebelp
AND loekz <> 'X'.
CHECK sy-subrc = 0.
l_t_goodsmvt_item-plant = ekpo-werks.
l_t_goodsmvt_item-move_plant = ekpo-werks.
l_t_goodsmvt_item-stge_loc = .
l_t_goodsmvt_item-move_type = '101'.
l_t_goodsmvt_item-mvt_ind = 'B'.
l_t_goodsmvt_item-po_number = .
l_t_goodsmvt_item-po_item = i_ebelp.
l_t_goodsmvt_item-spec_stock = ekpo-sobkz.
l_t_goodsmvt_item-entry_qnt = i_menge.
l_t_goodsmvt_item-entry_uom = ekpo-meins.
APPEND l_t_goodsmvt_item.
================== ITEM ===========
DATA v_msg LIKE bapireturn1-message .
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = l_goodsmvt_header
goodsmvt_code = '01'
IMPORTING
goodsmvt_headret = l_goodsmvt_headret
TABLES
goodsmvt_item = l_t_goodsmvt_item
goodsmvt_serialnumber = l_t_goodsmvt_serialnumber
return = l_t_return.
COMMIT WORK AND WAIT.
LOOP AT l_t_return WHERE type = 'E' OR type = 'A' OR type = 'X'.
ENDLOOP.
IF sy-subrc = 0.
*Failed posting article document
* ROLLBACK WORK .
g_return = l_t_return.
PERFORM sub_add_to_log1 USING g_return-type g_return-message .
ELSE.
INSERT ztpp_0001 FROM TABLE t_ztpp_0001 ACCEPTING DUPLICATE KEYS.
CONCATENATE 'Article document & & created' ':'
l_goodsmvt_headret-mat_doc INTO v_msg.
PERFORM sub_add_to_log1 USING 'S' v_msg .
PERFORM sub_add_to_log1 USING 'S' text-m11.
ENDIF.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20037923/viewspace-1023372/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/20037923/viewspace-1023372/