DECLARE
l_session_id NUMBER;
l_return_status VARCHAR2 (1);
l_msg_count NUMBER := 0;
l_msg_data VARCHAR2 (1000);
l_msg_index_out NUMBER;
l_count NUMBER;
l_org_cnt NUMBER;
l_vendor_cnt NUMBER;
l_org_class VARCHAR2 (3);
l_org_num NUMBER;
l_line_num NUMBER := 0;
l_err_count NUMBER := 0;
p NUMBER;
l_assignment_set_rec mrp_src_assignment_pub.assignment_set_rec_type;
l_assignment_set_val_rec mrp_src_assignment_pub.assignment_set_val_rec_type;
l_assignment_tbl mrp_src_assignment_pub.assignment_tbl_type;
l_assignment_val_tbl mrp_src_assignment_pub.assignment_val_tbl_type;
o_assignment_set_rec mrp_src_assignment_pub.assignment_set_rec_type;
o_assignment_set_val_rec mrp_src_assignment_pub.assignment_set_val_rec_type;
o_assignment_tbl mrp_src_assignment_pub.assignment_tbl_type;
o_assignment_val_tbl mrp_src_assignment_pub.assignment_val_tbl_type;
CURSOR c1 IS
SELECT msa.inventory_item_id,
msa.assignment_set_id,
mas.assignment_set_name,
msa.entity_name item,
msa.description item_desc,
msa.organization_id,
msa.sourcing_rule_id,
msa.sourcing_rule_type,
msa.sourcing_rule_name,
msa.assignment_type,
msa.assignment_id
FROM mrp_assignment_sets mas,
mrp_sr_assignments_v msa
WHERE mas.assignment_set_id = msa.assignment_set_id
AND mas.assignment_set_name = '<Assignment Set Name>'
AND msa.inventory_item_id = <Inventory Item Id>;
BEGIN
FOR i IN c1 LOOP
fnd_message.clear;
L_assignment_tbl (1).assignment_set_id := i.assignment_set_id;
L_assignment_tbl (1).assignment_type := i.assignment_type;
--Item-Organization (SELECT lookup_code, MEANING FROM mfg_lookups WHERE lookup_type = 'MRP_ASSIGNMENT_TYPE')
L_assignment_tbl (1).operation := 'DELETE'; --'CREATE';
L_assignment_tbl (1).organization_id := i.organization_id;
L_assignment_tbl (1).inventory_item_id := i.inventory_item_id;
L_assignment_tbl (1).sourcing_rule_id := i.sourcing_rule_id;
--N1-SHIV ENGINEERING PRODUCTS
L_assignment_tbl (1).sourcing_rule_type := i.sourcing_rule_type;
--Sourcing Rule
L_assignment_tbl (1).assignment_id := i.assignment_id;
mrp_src_assignment_pub.Process_assignment (p_api_version_number => 1.0,
p_init_msg_list => fnd_api.g_false, p_return_values => fnd_api.g_false,
p_commit
=> fnd_api.g_false, x_return_status => l_return_status,
x_msg_count => l_msg_count, x_msg_data => l_msg_data,
p_assignment_set_rec => l_assignment_set_rec,
p_assignment_set_val_rec => l_assignment_set_val_rec,
p_assignment_tbl => l_assignment_tbl,
p_assignment_val_tbl => l_assignment_val_tbl,
x_assignment_set_rec => o_assignment_set_rec,
x_assignment_set_val_rec => o_assignment_set_val_rec,
x_assignment_tbl => o_assignment_tbl,
x_assignment_val_tbl => o_assignment_val_tbl);
IF l_return_status = fnd_api.g_ret_sts_success THEN
dbms_output.Put_line ('Success!');
ELSE
dbms_output.Put_line ('count:'
|| l_msg_count);
IF l_msg_count > 0 THEN
FOR l_index IN 1 .. l_msg_count LOOP
l_msg_data := fnd_msg_pub.Get (p_msg_index => l_index,
p_encoded => fnd_api.g_false);
dbms_output.Put_line (Substr (l_msg_data, 1, 250));
END LOOP;
dbms_output.Put_line ('MSG:'
|| o_assignment_set_rec.return_status);
END IF;
dbms_output.Put_line ('Failure!');
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.Put_line ('Error :'
||SQLERRM);
END;
No comments:
Post a Comment