DECLARE
--Script for updating the BOM supply type from phantom to Operation Pull--
l_bom_header_rec bom_bo_pub.bom_head_rec_type
:= bom_bo_pub.g_miss_bom_header_rec;
l_bom_revision_tbl bom_bo_pub.bom_revision_tbl_type
:= bom_bo_pub.g_miss_bom_revision_tbl;
l_bom_component_tbl bom_bo_pub.bom_comps_tbl_type
:= bom_bo_pub.g_miss_bom_component_tbl;
l_bom_ref_designator_tbl bom_bo_pub.bom_ref_designator_tbl_type
:= bom_bo_pub.g_miss_bom_ref_designator_tbl;
l_bom_sub_component_tbl bom_bo_pub.bom_sub_component_tbl_type
:= bom_bo_pub.g_miss_bom_sub_component_tbl;
l_error_message_list error_handler.error_tbl_type;
l_x_bom_header_rec bom_bo_pub.bom_head_rec_type;
l_x_bom_revision_tbl bom_bo_pub.bom_revision_tbl_type;
l_x_bom_component_tbl bom_bo_pub.bom_comps_tbl_type;
l_x_bom_ref_designator_tbl bom_bo_pub.bom_ref_designator_tbl_type;
l_x_bom_sub_component_tbl bom_bo_pub.bom_sub_component_tbl_type;
l_x_return_status VARCHAR2 (2000);
l_x_msg_count NUMBER;
i NUMBER;
CURSOR c1
IS
SELECT ood.organization_code, ood.organization_id, msi.segment1,
msi.description, bic.item_num, bic.operation_seq_num,
bic.component_item_id, msi1.segment1 component, ml.meaning,
bic.wip_supply_type, bic.effectivity_date, bic.disable_date
FROM mtl_system_items_b msi,
org_organization_definitions ood,
bom_bill_of_materials bom,
bom_inventory_components bic,
mtl_system_items_b msi1,
mfg_lookups ml
WHERE bom.assembly_item_id = msi.inventory_item_id
AND bom.bill_sequence_id = bic.bill_sequence_id
AND msi.organization_id = ood.organization_id
AND bom.organization_id = ood.organization_id
AND msi1.inventory_item_status_code = 'Active'
AND bic.component_item_id = msi1.inventory_item_id
AND msi1.organization_id = ood.organization_id
AND ml.lookup_code(+) = bic.wip_supply_type
AND ml.lookup_type(+) = 'WIP_SUPPLY'
AND ood.organization_id = :p_organization_id
and bic.WIP_SUPPLY_TYPE =6 --phantom supply type
and bic.DISABLE_DATE is null
AND msi.segment1 = :p_assembly_item_name;
BEGIN
fnd_global.apps_initialize (1239, 20566, 702);--initialize the environment
FOR j IN c1
LOOP
i := 1;
DBMS_OUTPUT.put_line (' Assembly_Item_name ' || j.segment1);
DBMS_OUTPUT.put_line (' Component_Item_Name' || j.component);
l_bom_component_tbl (i) := bom_bo_pub.g_miss_bom_component_rec;
l_bom_component_tbl (i).transaction_type := 'UPDATE';
l_bom_component_tbl (i).organization_code := j.organization_code;
l_bom_component_tbl (i).assembly_item_name := j.segment1;
l_bom_component_tbl (i).start_effective_date := j.effectivity_date;
l_bom_component_tbl (i).component_item_name := j.component;
l_bom_component_tbl (i).wip_supply_type := 3; --Operation Pull
l_bom_component_tbl (i).item_sequence_number := j.item_num;
l_bom_component_tbl (i).operation_sequence_number :=
j.operation_seq_num;
l_bom_component_tbl (i).return_status := NULL;
error_handler.initialize;
bom_bo_pub.process_bom
(p_bo_identifier => 'BOM',
p_api_version_number => 1.0,
p_init_msg_list => TRUE,
p_bom_header_rec => l_bom_header_rec,
p_bom_revision_tbl => l_bom_revision_tbl,
p_bom_component_tbl => l_bom_component_tbl,
p_bom_ref_designator_tbl => l_bom_ref_designator_tbl,
p_bom_sub_component_tbl => l_bom_sub_component_tbl,
x_bom_header_rec => l_x_bom_header_rec,
x_bom_revision_tbl => l_x_bom_revision_tbl,
x_bom_component_tbl => l_x_bom_component_tbl,
x_bom_ref_designator_tbl => l_x_bom_ref_designator_tbl,
x_bom_sub_component_tbl => l_x_bom_sub_component_tbl,
x_return_status => l_x_return_status,
x_msg_count => l_x_msg_count,
p_debug => 'N',
p_output_dir => '',
p_debug_filename => ''
);
DBMS_OUTPUT.put_line ('Return Status = ' || l_x_return_status);
DBMS_OUTPUT.put_line ('Message Count = ' || l_x_msg_count);
error_handler.get_message_list (l_error_message_list);
IF l_x_return_status <> 'S'
THEN
FOR k IN 1 .. l_x_msg_count
LOOP
DBMS_OUTPUT.put_line
( TO_CHAR (k)
|| ' MESSAGE TEXT '
|| SUBSTR
(l_error_message_list (k).MESSAGE_TEXT,
1,
250
)
);
DBMS_OUTPUT.put_line ( TO_CHAR (k)
|| ' MESSAGE TYPE '
|| l_error_message_list (k).MESSAGE_TYPE
);
END LOOP;
ROLLBACK;
ELSE
COMMIT;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (' OTHER exception ');
END;
--Script for updating the BOM supply type from phantom to Operation Pull--
l_bom_header_rec bom_bo_pub.bom_head_rec_type
:= bom_bo_pub.g_miss_bom_header_rec;
l_bom_revision_tbl bom_bo_pub.bom_revision_tbl_type
:= bom_bo_pub.g_miss_bom_revision_tbl;
l_bom_component_tbl bom_bo_pub.bom_comps_tbl_type
:= bom_bo_pub.g_miss_bom_component_tbl;
l_bom_ref_designator_tbl bom_bo_pub.bom_ref_designator_tbl_type
:= bom_bo_pub.g_miss_bom_ref_designator_tbl;
l_bom_sub_component_tbl bom_bo_pub.bom_sub_component_tbl_type
:= bom_bo_pub.g_miss_bom_sub_component_tbl;
l_error_message_list error_handler.error_tbl_type;
l_x_bom_header_rec bom_bo_pub.bom_head_rec_type;
l_x_bom_revision_tbl bom_bo_pub.bom_revision_tbl_type;
l_x_bom_component_tbl bom_bo_pub.bom_comps_tbl_type;
l_x_bom_ref_designator_tbl bom_bo_pub.bom_ref_designator_tbl_type;
l_x_bom_sub_component_tbl bom_bo_pub.bom_sub_component_tbl_type;
l_x_return_status VARCHAR2 (2000);
l_x_msg_count NUMBER;
i NUMBER;
CURSOR c1
IS
SELECT ood.organization_code, ood.organization_id, msi.segment1,
msi.description, bic.item_num, bic.operation_seq_num,
bic.component_item_id, msi1.segment1 component, ml.meaning,
bic.wip_supply_type, bic.effectivity_date, bic.disable_date
FROM mtl_system_items_b msi,
org_organization_definitions ood,
bom_bill_of_materials bom,
bom_inventory_components bic,
mtl_system_items_b msi1,
mfg_lookups ml
WHERE bom.assembly_item_id = msi.inventory_item_id
AND bom.bill_sequence_id = bic.bill_sequence_id
AND msi.organization_id = ood.organization_id
AND bom.organization_id = ood.organization_id
AND msi1.inventory_item_status_code = 'Active'
AND bic.component_item_id = msi1.inventory_item_id
AND msi1.organization_id = ood.organization_id
AND ml.lookup_code(+) = bic.wip_supply_type
AND ml.lookup_type(+) = 'WIP_SUPPLY'
AND ood.organization_id = :p_organization_id
and bic.WIP_SUPPLY_TYPE =6 --phantom supply type
and bic.DISABLE_DATE is null
AND msi.segment1 = :p_assembly_item_name;
BEGIN
fnd_global.apps_initialize (1239, 20566, 702);--initialize the environment
FOR j IN c1
LOOP
i := 1;
DBMS_OUTPUT.put_line (' Assembly_Item_name ' || j.segment1);
DBMS_OUTPUT.put_line (' Component_Item_Name' || j.component);
l_bom_component_tbl (i) := bom_bo_pub.g_miss_bom_component_rec;
l_bom_component_tbl (i).transaction_type := 'UPDATE';
l_bom_component_tbl (i).organization_code := j.organization_code;
l_bom_component_tbl (i).assembly_item_name := j.segment1;
l_bom_component_tbl (i).start_effective_date := j.effectivity_date;
l_bom_component_tbl (i).component_item_name := j.component;
l_bom_component_tbl (i).wip_supply_type := 3; --Operation Pull
l_bom_component_tbl (i).item_sequence_number := j.item_num;
l_bom_component_tbl (i).operation_sequence_number :=
j.operation_seq_num;
l_bom_component_tbl (i).return_status := NULL;
error_handler.initialize;
bom_bo_pub.process_bom
(p_bo_identifier => 'BOM',
p_api_version_number => 1.0,
p_init_msg_list => TRUE,
p_bom_header_rec => l_bom_header_rec,
p_bom_revision_tbl => l_bom_revision_tbl,
p_bom_component_tbl => l_bom_component_tbl,
p_bom_ref_designator_tbl => l_bom_ref_designator_tbl,
p_bom_sub_component_tbl => l_bom_sub_component_tbl,
x_bom_header_rec => l_x_bom_header_rec,
x_bom_revision_tbl => l_x_bom_revision_tbl,
x_bom_component_tbl => l_x_bom_component_tbl,
x_bom_ref_designator_tbl => l_x_bom_ref_designator_tbl,
x_bom_sub_component_tbl => l_x_bom_sub_component_tbl,
x_return_status => l_x_return_status,
x_msg_count => l_x_msg_count,
p_debug => 'N',
p_output_dir => '',
p_debug_filename => ''
);
DBMS_OUTPUT.put_line ('Return Status = ' || l_x_return_status);
DBMS_OUTPUT.put_line ('Message Count = ' || l_x_msg_count);
error_handler.get_message_list (l_error_message_list);
IF l_x_return_status <> 'S'
THEN
FOR k IN 1 .. l_x_msg_count
LOOP
DBMS_OUTPUT.put_line
( TO_CHAR (k)
|| ' MESSAGE TEXT '
|| SUBSTR
(l_error_message_list (k).MESSAGE_TEXT,
1,
250
)
);
DBMS_OUTPUT.put_line ( TO_CHAR (k)
|| ' MESSAGE TYPE '
|| l_error_message_list (k).MESSAGE_TYPE
);
END LOOP;
ROLLBACK;
ELSE
COMMIT;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (' OTHER exception ');
END;
No comments:
Post a Comment