[mrp_net_flag = 1 表示 MRP / ASCP模組使用到,定義為供給或需求
通常生產主料與用料相同時,可能造成無限迴圈的異常]
[一般維修工單最可能發生, 將用料 MRP NET 取消即可]
DECLARE
CURSOR curJob IS
SELECT wdj.organization_id,
wdj.primary_item_id,
wdj.wip_entity_id,
wro.inventory_item_id,
wdj.wip_entity_name
FROM wip_discrete_jobs_v wdj,
wip_requirement_operations_v wro
WHERE wdj.wip_entity_id = wro.wip_entity_id
AND wro.mrp_net_flag = 1
--AND wro.organization_id = 00
--AND wdj.status_type IN (1,3);
AND wdj.creation_date >= SYSDATE - 90;
CURSOR curImpl
(
pOrganizationId IN NUMBER,
pComponentItemId IN NUMBER,
pWipAssemblyId IN NUMBER
) IS
SELECT 1
FROM bom_small_impl_temp bom
WHERE bom.lowest_item_id = pWipAssemblyId
AND bom.organization_id = pOrganizationId
AND bom.parent_item_id = pComponentItemId
AND bom.alternate_designator IS NULL;
vComponentItem mtl_item_flexfields.item_number%TYPE;
vAssemblyItem mtl_item_flexfields.item_number%TYPE;
vSequenceId NUMBER := -99;
xErrorMessage VARCHAR2(2000);
xErrorCode NUMBER;
BEGIN
dbms_output.enable(2000000);
FOR i IN curJob
LOOP
DELETE FROM bom_small_impl_temp
WHERE sequence_id = vSequenceId;
bompiinq.imploder_userexit(sequence_id => vSequenceId,
eng_mfg_flag => 1, -- bom
org_id => i.organization_id, impl_flag => 2,-- both impl and unimpl
display_option => 3,-- 1 = all, 2 = curr, 3=curr,future
levels_to_implode => 10,
item_id => i.primary_item_id,
impl_date => to_char(SYSDATE,'YYYY/MM/DD HH24:MI'),
unit_number_from => '', unit_number_to => '',
err_msg => xErrorMessage,
err_code => xErrorCode);
FOR j IN curImpl(i.organization_id, i.inventory_item_id,
i.primary_item_id)
LOOP
IF curImpl%FOUND THEN
vComponentItem := bom_globals.Get_Item_Name(p_item_id => i.inventory_item_id,
p_org_id => i.organization_id);
vAssemblyItem := bom_globals.Get_Item_Name(p_item_id => i.primary_item_id,
p_org_id => i.organization_id);
IF vAssemblyItem <> vComponentItem THEN
dbms_output.put_line('Org Id: ' || to_char(i.organization_id) || ', ' ||
'Job: ' || i.wip_entity_name || ', ' ||
'Assembly: ' || vAssemblyItem || '(id=' ||
to_char(i.primary_item_id) || ')' || ', ' ||
'Component: ' || vComponentItem || '(id=' ||
to_char(i.inventory_item_id) || ')');
END IF;
EXIT;
END IF;
END LOOP;
END LOOP;
END;
沒有留言:
張貼留言