ERP系统里的BOM展开函数
2011-06-27 23:56
239 查看
ERP系统里的BOM展开函数:
l_grp_id NUMBER ;
l_session_id NUMBER ;
l_org_id NUMBER ;
l_levels_to_explode NUMBER := 10 ;
l_module NUMBER DEFAULT 2 ; -- BOM = 2
l_cst_type_id NUMBER DEFAULT -1 ; -- All cost = -1 else 0
l_item_id NUMBER ;
l_bom_or_eng NUMBER ;
l_using_req_quantity NUMBER ;
l_using_ass_dem_date DATE ;
l_rev_date VARCHAR2(20):= to_char(bom_dt,'DD-MON-YY HH24:MI');
l_err_msg VARCHAR2(250) ;
l_error_code NUMBER ;
BEGIN
-- 首先要有一个Group id
SELECT bom_explosion_temp_s.NEXTVAL
INTO l_grp_id
FROM dual ;
-- 其次要得到一个Session id
SELECT bom_explosion_temp_session_s.NEXTVAL
INTO l_session_id
FROM dual ;
bompexpl.exploder_userexit(
verify_flag =>0,
org_id =>l_org_id,
order_by =>1,
grp_id =>l_grp_id,
session_id =>l_session_id,
levels_to_explode =>l_levels_to_explode,
bom_or_eng =>l_bom_or_eng,
impl_flag =>1,
plan_factor_flag =>2,
explode_option =>2, -- 2,
module =>l_module,
cst_type_id =>l_cst_type_id,
std_comp_flag =>2,
expl_qty =>1,
item_id =>l_item_id,
alt_desg =>'',
comp_code =>'',
rev_date =>l_rev_date,
err_msg =>l_err_msg,
error_code =>l_error_code
);
END ;
运行结束后用以下语句得到结果.
SELECT * FROM bom_explosion_temp bet
WHERE bet.group_id = l_grp_id
Select Aa.Organization_Code 组织
,Aa.Segment1 装配件编码
,Aa.Description 装配件描述
,Msi.Segment1 组件编码
,Msi.Description 组件描述
,Msi.Primary_Uom_Code 单位
,Aa.Component_Quantity 数量
,Aa.Component_Remarks 工位
,Aa.Operation_Seq_Num 工序
,Aa.Supply_Subinventory 供应子库
,Decode(Aa.Wip_Supply_Type, 1, '推式', 2, '装配拉式', 3, '拉式工序', 4, '批量',
5, '供应商', 6, '虚拟件', 7,'基于物料清单', '未定义') 供应方式
,Aa.Level_Num 级别
From Mtl_System_Items_b Msi
,(Select Bom.Organization_Id ,Mp.Organization_Code,Msi.Segment1
,Msi.Description
,Bic.Component_Item_Id
,Bic.Component_Remarks
,Bic.Operation_Seq_Num
,Bic.Component_Quantity
,Bic.Supply_Subinventory
,Bic.Wip_Supply_Type
,Level Level_Num
From Bom_Structures_b Bom
,Bom_Components_b Bic
,Mtl_System_Items_b Msi
,Mtl_Parameters Mp
Where Bom.Bill_Sequence_Id = Bic.Bill_Sequence_Id
And Nvl(Bic.Disable_Date, Sysdate + 1) > Sysdate
And Bom.Organization_Id = Msi.Organization_Id
And Bom.Assembly_Item_Id = Msi.Inventory_Item_Id
And Bom.Organization_Id = Mp.Organization_Id
And Mp.Organization_Code = '&organization_code'
Start With Msi.Segment1 = '&Assembly_Item_Num' Connect By Prior Bic.Component_Item_Id = Bom.Assembly_Item_Id
And Prior Bic.Wip_Supply_Type = 6) Aa
Where Msi.Organization_Id = Aa.Organization_Id
And Msi.Inventory_Item_Id = Aa.Component_Item_Id
And Aa.Wip_Supply_Type <> 6
Order By Aa.Component_Remarks
,Msi.Segment1
PROCEDURE extend_bom (
p_sequence_id IN NUMBER
,p_organization_id IN NUMBER
,p_assembly_item_id IN NUMBER
,p_assembly_item IN VARCHAR2
,p_top_assembly_item_id IN NUMBER
,p_top_assembly_item IN VARCHAR2
,p_creation_date IN NUMBER
)
IS
aa NUMBER;
CURSOR c1
IS
SELECT bic.component_item_id
,msib.segment1
,bic.component_quantity unit_qty
,msib.wip_supply_type
,bic.bill_sequence_id
,bic.item_num
FROM bom_bill_of_materials bom
,bom_inventory_components bic
,mtl_system_items_b msib
WHERE bom.organization_id = p_organization_id
AND msib.organization_id = bom.organization_id
AND msib.inventory_item_id = bic.component_item_id
AND bom.assembly_item_id = p_assembly_item_id
AND NVL (bom.common_bill_sequence_id, bom.bill_sequence_id) = bic.bill_sequence_id
AND ( bic.disable_date IS NULL
OR bic.disable_date > SYSDATE)
AND effectivity_date <= SYSDATE;
BEGIN
FOR r1 IN c1
LOOP
BEGIN
IF r1.wip_supply_type = 6
THEN --phantom
BEGIN
extend_bom (p_sequence_id
,p_organization_id
,r1.component_item_id
,r1.segment1
,p_top_assembly_item_id
,p_top_assembly_item
,p_creation_date
);
NULL;
END;
ELSE
BEGIN
INSERT INTO aps_sd_sourcing_rule_check_t
(sequence_id
,top_assembly_item_id
,assembly_item_id
,component_item_id
,item_num
,unit_qty
bb6d
,organization_id
,creation_date
,top_assembly_item
,assembly_item
,item
)
VALUES (p_sequence_id
,p_top_assembly_item_id
,p_assembly_item_id
,r1.component_item_id
,r1.item_num
,r1.unit_qty
,p_organization_id
,p_creation_date
,p_top_assembly_item
,p_assembly_item
,r1.segment1
);
END;
END IF;
END;
END LOOP;
COMMIT;
END;
l_grp_id NUMBER ;
l_session_id NUMBER ;
l_org_id NUMBER ;
l_levels_to_explode NUMBER := 10 ;
l_module NUMBER DEFAULT 2 ; -- BOM = 2
l_cst_type_id NUMBER DEFAULT -1 ; -- All cost = -1 else 0
l_item_id NUMBER ;
l_bom_or_eng NUMBER ;
l_using_req_quantity NUMBER ;
l_using_ass_dem_date DATE ;
l_rev_date VARCHAR2(20):= to_char(bom_dt,'DD-MON-YY HH24:MI');
l_err_msg VARCHAR2(250) ;
l_error_code NUMBER ;
BEGIN
-- 首先要有一个Group id
SELECT bom_explosion_temp_s.NEXTVAL
INTO l_grp_id
FROM dual ;
-- 其次要得到一个Session id
SELECT bom_explosion_temp_session_s.NEXTVAL
INTO l_session_id
FROM dual ;
bompexpl.exploder_userexit(
verify_flag =>0,
org_id =>l_org_id,
order_by =>1,
grp_id =>l_grp_id,
session_id =>l_session_id,
levels_to_explode =>l_levels_to_explode,
bom_or_eng =>l_bom_or_eng,
impl_flag =>1,
plan_factor_flag =>2,
explode_option =>2, -- 2,
module =>l_module,
cst_type_id =>l_cst_type_id,
std_comp_flag =>2,
expl_qty =>1,
item_id =>l_item_id,
alt_desg =>'',
comp_code =>'',
rev_date =>l_rev_date,
err_msg =>l_err_msg,
error_code =>l_error_code
);
END ;
运行结束后用以下语句得到结果.
SELECT * FROM bom_explosion_temp bet
WHERE bet.group_id = l_grp_id
Select Aa.Organization_Code 组织
,Aa.Segment1 装配件编码
,Aa.Description 装配件描述
,Msi.Segment1 组件编码
,Msi.Description 组件描述
,Msi.Primary_Uom_Code 单位
,Aa.Component_Quantity 数量
,Aa.Component_Remarks 工位
,Aa.Operation_Seq_Num 工序
,Aa.Supply_Subinventory 供应子库
,Decode(Aa.Wip_Supply_Type, 1, '推式', 2, '装配拉式', 3, '拉式工序', 4, '批量',
5, '供应商', 6, '虚拟件', 7,'基于物料清单', '未定义') 供应方式
,Aa.Level_Num 级别
From Mtl_System_Items_b Msi
,(Select Bom.Organization_Id ,Mp.Organization_Code,Msi.Segment1
,Msi.Description
,Bic.Component_Item_Id
,Bic.Component_Remarks
,Bic.Operation_Seq_Num
,Bic.Component_Quantity
,Bic.Supply_Subinventory
,Bic.Wip_Supply_Type
,Level Level_Num
From Bom_Structures_b Bom
,Bom_Components_b Bic
,Mtl_System_Items_b Msi
,Mtl_Parameters Mp
Where Bom.Bill_Sequence_Id = Bic.Bill_Sequence_Id
And Nvl(Bic.Disable_Date, Sysdate + 1) > Sysdate
And Bom.Organization_Id = Msi.Organization_Id
And Bom.Assembly_Item_Id = Msi.Inventory_Item_Id
And Bom.Organization_Id = Mp.Organization_Id
And Mp.Organization_Code = '&organization_code'
Start With Msi.Segment1 = '&Assembly_Item_Num' Connect By Prior Bic.Component_Item_Id = Bom.Assembly_Item_Id
And Prior Bic.Wip_Supply_Type = 6) Aa
Where Msi.Organization_Id = Aa.Organization_Id
And Msi.Inventory_Item_Id = Aa.Component_Item_Id
And Aa.Wip_Supply_Type <> 6
Order By Aa.Component_Remarks
,Msi.Segment1
PROCEDURE extend_bom (
p_sequence_id IN NUMBER
,p_organization_id IN NUMBER
,p_assembly_item_id IN NUMBER
,p_assembly_item IN VARCHAR2
,p_top_assembly_item_id IN NUMBER
,p_top_assembly_item IN VARCHAR2
,p_creation_date IN NUMBER
)
IS
aa NUMBER;
CURSOR c1
IS
SELECT bic.component_item_id
,msib.segment1
,bic.component_quantity unit_qty
,msib.wip_supply_type
,bic.bill_sequence_id
,bic.item_num
FROM bom_bill_of_materials bom
,bom_inventory_components bic
,mtl_system_items_b msib
WHERE bom.organization_id = p_organization_id
AND msib.organization_id = bom.organization_id
AND msib.inventory_item_id = bic.component_item_id
AND bom.assembly_item_id = p_assembly_item_id
AND NVL (bom.common_bill_sequence_id, bom.bill_sequence_id) = bic.bill_sequence_id
AND ( bic.disable_date IS NULL
OR bic.disable_date > SYSDATE)
AND effectivity_date <= SYSDATE;
BEGIN
FOR r1 IN c1
LOOP
BEGIN
IF r1.wip_supply_type = 6
THEN --phantom
BEGIN
extend_bom (p_sequence_id
,p_organization_id
,r1.component_item_id
,r1.segment1
,p_top_assembly_item_id
,p_top_assembly_item
,p_creation_date
);
NULL;
END;
ELSE
BEGIN
INSERT INTO aps_sd_sourcing_rule_check_t
(sequence_id
,top_assembly_item_id
,assembly_item_id
,component_item_id
,item_num
,unit_qty
bb6d
,organization_id
,creation_date
,top_assembly_item
,assembly_item
,item
)
VALUES (p_sequence_id
,p_top_assembly_item_id
,p_assembly_item_id
,r1.component_item_id
,r1.item_num
,r1.unit_qty
,p_organization_id
,p_creation_date
,p_top_assembly_item
,p_assembly_item
,r1.segment1
);
END;
END IF;
END;
END LOOP;
COMMIT;
END;
相关文章推荐
- ERP系统里的BOM展开函数
- ERP系统BOM详细解析(一)
- SAP MM模块-BOM展开函数
- ERP系统BOM详细解析(一)
- ERP系统中BOM的作用
- ERP系统中与BOM有关的常用方法
- ERP系统BOM详细解析(一)
- BOM展开和反查函数
- BOM展开函数
- ERP系统BOM详细解析
- BOM展开函数解析
- 可配置BOM用函数CS_BOM_EXPL_MAT_V2展开缺少项目
- [易飞]批量导出易飞ERP系统目前所有BOM(含本币未税单位成本)
- [ABAP] PBOM历史版本函数展开 CSAP_MAT_BOM_READ
- BOM展开的中间函数给大家
- ERP系统中与BOM有关的常用方法
- ERP系统中与BOM有关的常用方法
- [ABAP] PBOM历史版本函数展开 CSAP_MAT_BOM_READ
- ERP系统BOM详细解析(一)