You are on page 1of 3

CREATE OR REPLACE PROCEDURE apps.

BOM_LOCATOR_UPDATE_PKG (
errbuf OUT
VARCHAR2,
retcode OUT
NUMBER,
p_supply_locator IN
VARCHAR2
)
IS
--script for sweep the supply tupe from bulk to Assembly 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;
gorganization NUMBER
:= fnd_profile.VALUE ('XXX_ORGANIZATION');

CURSOR bom_loc_cur
IS
SELECT *
FROM cco_bom_locator_update
WHERE process_flag = 'N';

CURSOR c1 (p_assembly_item IN VARCHAR2)


IS
SELECT ood.organization_code, ood.organization_id,
msi.segment2 || '.' || msi.segment1 assembly, msi.description,
bic.item_num, bic.operation_seq_num, bic.component_item_id,
msi1.segment2 || '.' || 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 = gorganization
AND msi.segment2 || '.' || msi.segment1 = p_assembly_item;
BEGIN

FOR bom_loc_rec IN bom_loc_cur


LOOP
FOR j IN c1 (bom_loc_rec.assembly_item_number)
LOOP
i := 1;

fnd_file.put_line (fnd_file.LOG,' Assembly_Item_name ' || j.assembly);


fnd_file.put_line (fnd_file.LOG,' 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.assembly;
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 := 2;
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;
l_bom_component_tbl (i).location_name := p_supply_locator;
--end loop;
error_handler.initialize;
-- Call the Public API
-- The public API is the user's interface to the import program. The user must call
it
-- programatically, while sending in one business object at a time. The public API
returns
-- the processed business object, the business object status, and a count of all
-- associated error and warning messages.
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 => ''
);
fnd_file.put_line (fnd_file.LOG,
'Return Status = ' || l_x_return_status
);
fnd_file.put_line (fnd_file.LOG, 'Message Count = ' || l_x_msg_count);
/**** Error messages ****/
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

fnd_file.put_line (fnd_file.LOG,TO_CHAR (k)


|| ' MESSAGE TEXT '
|| SUBSTR
(l_error_message_list (k).MESSAGE_TEXT,
1,
250)
);
fnd_file.put_line (fnd_file.LOG,TO_CHAR (k)
|| ' MESSAGE TYPE '
|| l_error_message_list (k).MESSAGE_TYPE
);
UPDATE cco_bom_locator_update
SET process_flag = 'E',
process_message = l_error_message_list (k).MESSAGE_TEXT
WHERE assembly_item_number = bom_loc_rec.assembly_item_number;
COMMIT;
END LOOP;

ROLLBACK;
ELSE
fnd_file.put_line (fnd_file.LOG,'BOM Locator Updated Successfully for the
Assembly Item:'||bom_loc_rec.assembly_item_number||'~'||p_supply_locator);

-- Error Processing
--COMMIT;
END IF;
END LOOP;
UPDATE cco_bom_locator_update
SET process_flag = 'S'
WHERE assembly_item_number = bom_loc_rec.assembly_item_number;
COMMIT;
END LOOP; ---STAGING TABLE LOOP
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (' OTHER exception ');
fnd_file.put_line (fnd_file.LOG,
'OTHER exception :' || SUBSTR (SQLERRM, 1, 200)
);
END BOM_LOCATOR_UPDATE_PKG;
/
SHOW ERROR;
EXIT;

You might also like