EBS 物料单位换算
2015-10-08 15:14 TRACEING 阅读(2451) 评论(0) 编辑 收藏 举报api: inv_convert.inv_um_convert
FUNCTION get_uom_rate(pn_item_id NUMBER
,pv_from_uom VARCHAR2) RETURN NUMBER AS
lv_from_uom_code VARCHAR2(15);
lv_from_uom VARCHAR2(15);
lv_to_uom_code VARCHAR2(15);
lv_to_uom VARCHAR2(15);
ln_return_rate NUMBER;
BEGIN
BEGIN
SELECT msi.primary_uom_code
,msi.primary_unit_of_measure
INTO lv_to_uom_code
,lv_to_uom
FROM mtl_system_items_b msi
WHERE msi.inventory_item_id = pn_item_id
AND msi.organization_id = gn_default_organization_id;
EXCEPTION
WHEN OTHERS THEN
lv_to_uom_code := NULL;
END;
--dbms_output.put_line(pv_from_uom ||'--'||lv_to_uom_code||'--');
IF pv_from_uom = lv_to_uom
THEN
ln_return_rate := 1;
ELSE
SELECT inv_uom.from_uom_code
INTO lv_from_uom_code
FROM (SELECT mucc.from_uom_code
,mucc.from_uom_class
,mucc.from_unit_of_measure
,mucc.inventory_item_id
FROM mtl_uom_class_conversions mucc
UNION
SELECT mucc.to_uom_code
,mucc.to_uom_class
,mucc.to_unit_of_measure
,mucc.inventory_item_id
FROM mtl_uom_class_conversions mucc) inv_uom
WHERE inv_uom.from_unit_of_measure = pv_from_uom
AND inv_uom.inventory_item_id = pn_item_id;
ln_return_rate := inv_convert.inv_um_convert(pn_item_id, lv_from_uom_code, lv_to_uom_code);
END IF;
RETURN ln_return_rate;
END;