读取交货单拣配数量PIKMG(转)
原文链接:https://www.591sap.com/thread-953-1-1.html
SAP交货单交货数量在lips中直接读取,但是拣配数量lfimg,只存在vbfa中,且如果基本计量单位和销售单位不一样,那么需要数量的转换
一、部分代码:
SELECT SUM( rfmng ) INTO lv_rfmng FROM vbfa WHERE vbelv = lt_lips-vbeln AND posnv = lt_lips-posnr AND vbtyp_n = 'Q'. IF sy-subrc = 0. CALL FUNCTION 'MATERIAL_UNIT_CONVERSION' "基本计量单位-->销售单位 EXPORTING input = lv_rfmng * KZMEINH = ' ' matnr = lt_lips-matnr meinh = lt_lips-vrkme "销售单位 meins = lt_lips-meins "基本计量单位 IMPORTING output = t_item-pikmg EXCEPTIONS conversion_not_found = 1 input_invalid = 2 material_not_found = 3 meinh_not_found = 4 meins_missing = 5 no_meinh = 6 output_invalid = 7 overflow = 8 OTHERS = 9. ENDIF. t_item-vrkme = lt_lips-vrkme.
二、调用标准函数直接取拣配数量:WB2_GET_PICK_QUANTITY
DATA:e_pikmg TYPE pikmg. CALL FUNCTION 'WB2_GET_PICK_QUANTITY' EXPORTING i_vbeln = i_head-vbeln i_posnr = t_item-posnr * I_MODE = ' ' IMPORTING e_pikmg = e_pikmg EXCEPTIONS document_read_error = 1 OTHERS = 2.
三、交货单拣配发货过账时,拣配数量的控制1、增强MV50AFZ1拣配数量XLIPS-PIKMG
FORM USEREXIT_SAVE_DOCUMENT_PREPARE. *{ INSERT SGDK905697 1 *发货过账时拣配数量为0 检查 DATA:lv_wbstk TYPE vbuk-wbstk. CHECK likp-lfart = 'ZLF1' AND vbuk-wbstk = 'C'."VBUK-WBSTK check post goods issue SELECT SINGLE wbstk INTO lv_wbstk FROM vbuk WHERE vbeln = vbuk-vbeln AND wbstk = 'C'. IF sy-subrc <> 0 . LOOP AT xlips WHERE updkz NE 'D' AND pikmg IS INITIAL. READ TABLE xlips TRANSPORTING NO FIELDS WITH KEY uecha = xlips-posnr. IF sy-subrc = 0. CONTINUE. ELSE. MESSAGE '拣配数量不能为0!' TYPE 'E'. ENDIF. ENDLOOP. ENDIF. *} INSERT ENDFORM.
但FORM USEREXIT_SAVE_DOCUMENT_PREPARE中报错,会在某些场景触发系统报错:Risk of posting several mat.documents for one delivery->long text
2、交货单不完整性检查配置
交货单中 交货数量=0,拣配数量=0,不允许过账,可以通过交货单不完整性检查配置来解决,但是这里有个致命的问题,不支持交货单物料的批次拆分,所以该配置又局限性,不适用。
注意,将“检查数量0”设置为B,即可实现避免交货单0拣配数量问题
原文链接:https://www.591sap.com/thread-953-1-1.html
每天学习一个知识点,累积就是财富。