[bom_explosion_temp.loop_flag => 表示有迴圈產生]
DECLARE
vOrganizationId NUMBER := 85;
CURSOR curItem(pOrganizationId IN NUMBER) IS
SELECT *
FROM mtl_system_items_b msi
WHERE msi.organization_id = vOrganizationId
AND msi.bom_enabled_flag = 'Y'
AND msi.planning_make_buy_code = 1;
vItem curItem%ROWTYPE;
TYPE rExp IS TABLE OF bom_explosion_temp%ROWTYPE;
vExpTbl rExp;
vLoopTbl rExp := rExp();
PROCEDURE Exploder
(
pOrganizationId IN NUMBER,
pInventoryItemId IN NUMBER,
pVerifyFlag IN NUMBER DEFAULT 0,
pOrderBy IN NUMBER DEFAULT 1,
pGrpID IN NUMBER DEFAULT 0,
pSessionId IN NUMBER DEFAULT 0,
pLevelsToExplode IN NUMBER DEFAULT 99,
pBomOrEng IN NUMBER DEFAULT 1,
pImplFlag IN NUMBER DEFAULT 1,
pPlanFactorFlag IN NUMBER DEFAULT 2,
pExplodeOption IN NUMBER DEFAULT 2,
pModule IN NUMBER DEFAULT 2,
pCstTypeId IN NUMBER DEFAULT 0,
pStdCompFlag IN NUMBER DEFAULT 0,
pExplQty IN NUMBER DEFAULT 1,
pAltDesg IN VARCHAR2 DEFAULT NULL,
pCompCode IN VARCHAR2 DEFAULT NULL,
pRevDate IN VARCHAR2 DEFAULT to_char(SYSDATE,
'YYYY/MM/DD HH24:MI:SS')
) IS
xErrMsg VARCHAR2(240);
xErrCode NUMBER := 0;
BEGIN
DELETE bom_explosion_temp
WHERE group_id = pGrpID;
apps.bompexpl.exploder_userexit(verify_flag => pVerifyFlag,
org_id => pOrganizationId,
order_by => pOrderBy, grp_id => pGrpId,
session_id => pSessionId,
levels_to_explode => pLevelsToExplode,
bom_or_eng => pBomOrEng,
impl_flag => pImplFlag,
plan_factor_flag => pPlanFactorFlag,
explode_option => pExplodeOption,
module => pModule,
cst_type_id => pCstTypeId,
std_comp_flag => pStdCompFlag,
expl_qty => pExplQty,
item_id => pInventoryItemId,
alt_desg => pAltDesg,
comp_code => pCompCode,
rev_date => pRevDate, err_msg => xErrMsg,
ERROR_CODE => xErrCode);
END Exploder;
BEGIN
OPEN curItem(vOrganizationId);
LOOP
FETCH curItem
INTO vItem;
EXIT WHEN curItem%NOTFOUND;
Exploder(pOrganizationId => vItem.Organization_Id,
pInventoryItemId => vItem.Inventory_Item_Id);
SELECT *
BULK COLLECT
INTO vExpTbl
FROM bom_explosion_temp
WHERE loop_flag = 1;
IF vExpTbl.count <> 0 THEN
vLoopTbl := vLoopTbl MULTISET UNION ALL vExpTbl;
END IF;
END LOOP;
CLOSE curItem;
IF NOT vLoopTbl IS EMPTY THEN
FOR i IN vLoopTbl.first .. vLoopTbl.last
LOOP
dbms_output.put_line('Top Item => ' ||
bom_globals.Get_Item_Name(p_org_id => vLoopTbl(i).organization_id,
p_item_id => vLoopTbl(i).top_item_id) ||
' / Assembly => ' ||
bom_globals.Get_Item_Name(p_org_id => vLoopTbl(i).organization_id,
p_item_id => vLoopTbl(i).assembly_item_id) ||
' / Component => ' ||
bom_globals.Get_Item_Name(p_org_id => vLoopTbl(i).organization_id,
p_item_id => vLoopTbl(i).component_item_id));
END LOOP;
ELSE
dbms_output.put_line('No Any Loop');
END IF;
END;
沒有留言:
張貼留言