261 migo过账–工单发料 demo
goodsmvt_code = '03'.
move_type = '261'.
LOOP AT req_item.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = req_item-aufnr
IMPORTING
output = pro_no
EXCEPTIONS
OTHERS = 1.
goodsmvt_item-item_text = tr_code.
CLEAR tr_code.
goodsmvt_item-material = req_item-matnr. "物料号
goodsmvt_item-plant = req_item-werks. "工厂
goodsmvt_item-stge_loc = req_item-lgort."库存地点
goodsmvt_item-move_type = '261'.
goodsmvt_item-reserv_no = req_item-rsnum. "预留号 RESB~RSNUM,加上后可以冲销提货数
goodsmvt_item-res_item = req_item-rspos. "预留行号
goodsmvt_item-orderid = pro_no. " 生产订单
goodsmvt_item-spec_stock = req_item-sobkz. " 特殊库存标识
goodsmvt_item-entry_qnt = req_item-menge. "数量
-
goodsmvt_item-batch = req_item-charg. "批次
-
goodsmvt_item-entry_uom = req_item-bprme. "单位 " 通过预留判断是否走销售库存
-
SELECT resb~sobkz FROM resb INTO stocktype
-
WHERE resb~rsnum = req_item-rsnum AND resb~rspos = req_item-rspos.
-
ENDSELECT. IF req_item-sobkz EQ 'E'. " 销售库存 CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = req_item-vbeln IMPORTING output = req_item-vbeln EXCEPTIONS OTHERS = 1. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = req_item-posnr IMPORTING output = req_item-posnr EXCEPTIONS OTHERS = 1. goodsmvt_item-val_sales_ord = req_item-vbeln. goodsmvt_item-val_s_ord_item = req_item-posnr.
-
ELSE.
-
goodsmvt_item-spec_stock = ''. ENDIF. APPEND goodsmvt_item. CLEAR goodsmvt_item. CLEAR stocktype. ENDLOOP.