现有量= 可用量+保留量;
1.现有量
--批次
CURSOR c_lot_number(l_organization_id NUMBER) IS
SELECT mln.lot_number,
mln.expiration_date
FROM mtl_lot_numbers mln
WHERE mln.inventory_item_id = p_inventory_item_id
-- AND mln.status_id = 1 --有效合格批次
AND mln.organization_id = l_organization_id; --需要添加合格字段
FOR rec_loc IN c_lot_number(p_organization_id)
LOOP
--遍历批次。取合格批次。
inv_quantity_tree_pub.query_quantities(p_api_version_number => 1.0,
p_init_msg_lst => NULL,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
p_organization_id => p_organization_id, --仓库ID
p_inventory_item_id => p_inventory_item_id, --物料ID
p_tree_mode => 3,