Wednesday, November 4, 2009

api to retrieve on hand quantity

DECLARE
x_return_status VARCHAR2 (1);
x_msg_data VARCHAR2 (4000);
x_msg_count NUMBER;
x_qoh NUMBER;
x_rqoh NUMBER;
x_qr NUMBER;
x_qs NUMBER;
x_att NUMBER;
x_atr NUMBER;
x_sqoh NUMBER;
x_srqoh NUMBER;
x_sqr NUMBER;
x_sqs NUMBER;
x_satt NUMBER;
x_sqtr NUMBER;
BEGIN
inv_globals.set_org_id (207);
inv_quantity_tree_pub.clear_quantity_cache;
inv_quantity_tree_pub.query_quantities
(p_api_version_number => 1.0
, x_return_status => x_return_status
, x_msg_count => x_msg_count
, x_msg_data => x_msg_data
, p_organization_id => 207
, p_inventory_item_id => 167742
, p_tree_mode => 1
, p_is_revision_control => FALSE
, p_is_lot_control => TRUE
, p_is_serial_control => TRUE
, p_grade_code => NULL
, p_revision => NULL
, p_lot_number => NULL
, p_subinventory_code => NULL
, p_locator_id => NULL
, x_qoh => x_qoh
, x_rqoh => x_rqoh
, x_qr => x_qr
, x_qs => x_qs
, x_att => x_att
, x_atr => x_atr
, x_sqoh => x_sqoh
, x_srqoh => x_srqoh
, x_sqr => x_sqr
, x_sqs => x_sqs
, x_satt => x_satt
, x_satr => x_sqtr
);
DBMS_OUTPUT.put_line (x_return_status);
DBMS_OUTPUT.put_line (x_msg_count);
DBMS_OUTPUT.put_line (x_qr);
DBMS_OUTPUT.put_line (x_qoh);
DBMS_OUTPUT.put_line (x_rqoh);
END;

retrieve on hand quantity

SELECT SUM (target_qty) , item_idFROM (SELECT moqv.subinventory_code subinv , moqv.inventory_item_id item_id , SUM (transaction_quantity) target_qty FROM mtl_onhand_qty_cost_v moqv WHERE moqv.organization_id = :org_id AND moqv.inventory_item_id = :item_id GROUP BY moqv.subinventory_code , moqv.inventory_item_id , moqv.item_cost UNION SELECT mmt.subinventory_code subinv , mmt.inventory_item_id item_id , -SUM (primary_quantity) target_qty FROM mtl_material_transactions mmt , mtl_txn_source_types mtst WHERE mmt.organization_id = :org_id AND transaction_date >= TO_DATE (:hist_date) + 1 AND mmt.transaction_source_type_id = mtst.transaction_source_type_id AND mmt.inventory_item_id = :item_id GROUP BY mmt.subinventory_code , mmt.inventory_item_id) oqGROUP BY oq.item_id