/* Formatted on 2015/07/27 14:30 (Formatter Plus v4.8.8) */
CREATE OR REPLACE PROCEDURE xxklk_proc_item_onhand (
errbuf VARCHAR2,
retcode NUMBER,
v_org_id IN NUMBER
)
AS
x_return_status VARCHAR2 (50);
x_msg_count VARCHAR2 (50);
x_msg_data VARCHAR2 (50);
v_item_id NUMBER;
-- v_org_id NUMBER;
v_qoh NUMBER;
v_rqoh NUMBER;
v_atr NUMBER;
v_att NUMBER;
v_qr NUMBER;
v_qs NUMBER;
v_segment1 VARCHAR2 (50);
v_lot_control_code BOOLEAN;
v_serial_control_code BOOLEAN;
CURSOR c1
IS
SELECT inventory_item_id, segment1
FROM mtl_system_items_b
WHERE organization_id = v_org_id;
BEGIN
-- Set the variable values
OPEN c1;
LOOP
FETCH c1
INTO v_item_id, v_segment1;
EXIT WHEN c1%NOTFOUND;
--end loop;
-- v_item_id := '45';
-- v_org_id := 207;
v_qoh := NULL;
v_rqoh := NULL;
v_atr := NULL;
v_lot_control_code := FALSE;
v_serial_control_code := FALSE;
-- Set the org context
fnd_client_info.set_org_context (22);
-- Call API
inv_quantity_tree_pub.query_quantities
(p_api_version_number => 1.0,
p_init_msg_lst => 'F',
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_organization_id => v_org_id,
p_inventory_item_id => v_item_id,
p_tree_mode => apps.inv_quantity_tree_pub.g_transaction_mode,
-- or 3
p_is_revision_control => FALSE,
p_is_lot_control => v_lot_control_code,
-- is_lot_control,
p_is_serial_control => v_serial_control_code,
p_revision => NULL, -- p_revision,
p_lot_number => NULL, -- p_lot_number,
p_lot_expiration_date => SYSDATE,
p_subinventory_code => NULL, -- p_subinventory_code,
p_locator_id => NULL, -- p_locator_id,
-- p_cost_group_id => NULL, -- cg_id,
p_onhand_source => 3,
x_qoh => v_qoh, -- Quantity on-hand
x_rqoh => v_rqoh,
--reservable quantity on-hand
x_qr => v_qr,
x_qs => v_qs,
x_att => v_att, -- available to transact
x_atr => v_atr -- available to reserve
);
/* DBMS_OUTPUT.put_line ('name: ' || v_segment1);
DBMS_OUTPUT.put_line ('On-Hand Quantity: ' || v_qoh);
DBMS_OUTPUT.put_line ('Available to reserve: ' || v_atr);
DBMS_OUTPUT.put_line ('Quantity Reserved: ' || v_qr);
DBMS_OUTPUT.put_line ('Quantity Suggested: ' || v_qs);
DBMS_OUTPUT.put_line ('Available to Transact: ' || v_att);
DBMS_OUTPUT.put_line ('Available to Reserve: ' || v_atr);*/
fnd_file.put_line
(fnd_file.LOG,
'*************************************************************************'
);
fnd_file.put_line (fnd_file.LOG, 'Name of the Item' || v_segment1);
fnd_file.put_line (fnd_file.LOG, 'Item code: ' || v_item_id);
fnd_file.put_line (fnd_file.LOG, 'On-Hand Quantity: ' || v_qoh);
fnd_file.put_line (fnd_file.LOG, 'Available to reserve: ' || v_atr);
fnd_file.put_line (fnd_file.LOG, 'Quantity Reserved: ' || v_qr);
fnd_file.put_line (fnd_file.LOG, 'Available to Transact: ' || v_att);
fnd_file.put_line (fnd_file.LOG, 'Available to Reserve: ' || v_atr);
END LOOP;
CLOSE c1;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG, 'Errors' || SQLERRM);
END;
--------------------------------------------------------------------------------------------
THE FOLLOWING Result CAN FETCH FROM ABOVE SCRIPT
--------------------------------------------------------------------------------
Quantity on hand
Reservable quantity
Quantity reserved
Quantity suggested
Available To Transact
Quantity Available To Reserve
CREATE OR REPLACE PROCEDURE xxklk_proc_item_onhand (
errbuf VARCHAR2,
retcode NUMBER,
v_org_id IN NUMBER
)
AS
x_return_status VARCHAR2 (50);
x_msg_count VARCHAR2 (50);
x_msg_data VARCHAR2 (50);
v_item_id NUMBER;
-- v_org_id NUMBER;
v_qoh NUMBER;
v_rqoh NUMBER;
v_atr NUMBER;
v_att NUMBER;
v_qr NUMBER;
v_qs NUMBER;
v_segment1 VARCHAR2 (50);
v_lot_control_code BOOLEAN;
v_serial_control_code BOOLEAN;
CURSOR c1
IS
SELECT inventory_item_id, segment1
FROM mtl_system_items_b
WHERE organization_id = v_org_id;
BEGIN
-- Set the variable values
OPEN c1;
LOOP
FETCH c1
INTO v_item_id, v_segment1;
EXIT WHEN c1%NOTFOUND;
--end loop;
-- v_item_id := '45';
-- v_org_id := 207;
v_qoh := NULL;
v_rqoh := NULL;
v_atr := NULL;
v_lot_control_code := FALSE;
v_serial_control_code := FALSE;
-- Set the org context
fnd_client_info.set_org_context (22);
-- Call API
inv_quantity_tree_pub.query_quantities
(p_api_version_number => 1.0,
p_init_msg_lst => 'F',
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_organization_id => v_org_id,
p_inventory_item_id => v_item_id,
p_tree_mode => apps.inv_quantity_tree_pub.g_transaction_mode,
-- or 3
p_is_revision_control => FALSE,
p_is_lot_control => v_lot_control_code,
-- is_lot_control,
p_is_serial_control => v_serial_control_code,
p_revision => NULL, -- p_revision,
p_lot_number => NULL, -- p_lot_number,
p_lot_expiration_date => SYSDATE,
p_subinventory_code => NULL, -- p_subinventory_code,
p_locator_id => NULL, -- p_locator_id,
-- p_cost_group_id => NULL, -- cg_id,
p_onhand_source => 3,
x_qoh => v_qoh, -- Quantity on-hand
x_rqoh => v_rqoh,
--reservable quantity on-hand
x_qr => v_qr,
x_qs => v_qs,
x_att => v_att, -- available to transact
x_atr => v_atr -- available to reserve
);
/* DBMS_OUTPUT.put_line ('name: ' || v_segment1);
DBMS_OUTPUT.put_line ('On-Hand Quantity: ' || v_qoh);
DBMS_OUTPUT.put_line ('Available to reserve: ' || v_atr);
DBMS_OUTPUT.put_line ('Quantity Reserved: ' || v_qr);
DBMS_OUTPUT.put_line ('Quantity Suggested: ' || v_qs);
DBMS_OUTPUT.put_line ('Available to Transact: ' || v_att);
DBMS_OUTPUT.put_line ('Available to Reserve: ' || v_atr);*/
fnd_file.put_line
(fnd_file.LOG,
'*************************************************************************'
);
fnd_file.put_line (fnd_file.LOG, 'Name of the Item' || v_segment1);
fnd_file.put_line (fnd_file.LOG, 'Item code: ' || v_item_id);
fnd_file.put_line (fnd_file.LOG, 'On-Hand Quantity: ' || v_qoh);
fnd_file.put_line (fnd_file.LOG, 'Available to reserve: ' || v_atr);
fnd_file.put_line (fnd_file.LOG, 'Quantity Reserved: ' || v_qr);
fnd_file.put_line (fnd_file.LOG, 'Available to Transact: ' || v_att);
fnd_file.put_line (fnd_file.LOG, 'Available to Reserve: ' || v_atr);
END LOOP;
CLOSE c1;
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG, 'Errors' || SQLERRM);
END;
--------------------------------------------------------------------------------------------
THE FOLLOWING Result CAN FETCH FROM ABOVE SCRIPT
--------------------------------------------------------------------------------
Quantity on hand
Reservable quantity
Quantity reserved
Quantity suggested
Available To Transact
Quantity Available To Reserve
No comments:
Post a Comment