DECLARE
--Api In Parameters variables
--ECO
Lt_Eco_Rec Eng_Eco_Pub.Eco_Rec_Type := Eng_Eco_Pub.g_Miss_Eco_Rec;
--ECO版本
Lt_Eco_Revision_Tbl Eng_Eco_Pub.Eco_Revision_Tbl_Type := Eng_Eco_Pub.g_Miss_Eco_Revision_Tbl;
--修改订物料
Lt_Revised_Item_Tbl Eng_Eco_Pub.Revised_Item_Tbl_Type := Eng_Eco_Pub.g_Miss_Revised_Item_Tbl;
--组件
Lt_Rev_Component_Tbl Bom_Bo_Pub.Rev_Component_Tbl_Type := Eng_Eco_Pub.g_Miss_Rev_Component_Tbl;
--替代件
Lt_Sub_Component_Tbl Bom_Bo_Pub.Sub_Component_Tbl_Type := Eng_Eco_Pub.g_Miss_Sub_Component_Tbl;
--指示符
Lt_Ref_Designator_Tbl Bom_Bo_Pub.Ref_Designator_Tbl_Type := Eng_Eco_Pub.g_Miss_Ref_Designator_Tbl;
--工艺路线
Lt_Rev_Operation_Tbl Bom_Rtg_Pub.Rev_Operation_Tbl_Type := Eng_Eco_Pub.g_Miss_Rev_Operation_Tbl;
--资源
Lt_Rev_Op_Resource_Tbl Bom_Rtg_Pub.Rev_Op_Resource_Tbl_Type := Eng_Eco_Pub.g_Miss_Rev_Op_Resource_Tbl;
--替代资源
Lt_Rev_Sub_Resource_Tbl Bom_Rtg_Pub.Rev_Sub_Resource_Tbl_Type := Eng_Eco_Pub.g_Miss_Rev_Sub_Resource_Tbl;
-- API output Parameters variables
Xt_Eco_Rec Eng_Eco_Pub.Eco_Rec_Type := Eng_Eco_Pub.g_Miss_Eco_Rec;
Xt_Eco_Revision_Tbl Eng_Eco_Pub.Eco_Revision_Tbl_Type := Eng_Eco_Pub.g_Miss_Eco_Revision_Tbl;
Xt_Revised_Item_Tbl Eng_Eco_Pub.Revised_Item_Tbl_Type := Eng_Eco_Pub.g_Miss_Revised_Item_Tbl;
Xt_Rev_Component_Tbl Bom_Bo_Pub.Rev_Component_Tbl_Type := Eng_Eco_Pub.g_Miss_Rev_Component_Tbl;
Xt_Sub_Component_Tbl Bom_Bo_Pub.Sub_Component_Tbl_Type := Eng_Eco_Pub.g_Miss_Sub_Component_Tbl;
Xt_Ref_Designator_Tbl Bom_Bo_Pub.Ref_Designator_Tbl_Type := Eng_Eco_Pub.g_Miss_Ref_Designator_Tbl;
Xt_Rev_Operation_Tbl Bom_Rtg_Pub.Rev_Operation_Tbl_Type := Eng_Eco_Pub.g_Miss_Rev_Operation_Tbl;
Xt_Rev_Op_Resource_Tbl Bom_Rtg_Pub.Rev_Op_Resource_Tbl_Type := Eng_Eco_Pub.g_Miss_Rev_Op_Resource_Tbl;
Xt_Rev_Sub_Resource_Tbl Bom_Rtg_Pub.Rev_Sub_Resource_Tbl_Type := Eng_Eco_Pub.g_Miss_Rev_Sub_Resource_Tbl;
-- Other API variables for return status / error handling / debugging
Lt_Error_Table Error_Handler.Error_Tbl_Type;
Lv_Return_Status VARCHAR2(1) := NULL;
Ln_Msg_Count NUMBER := 0;
Lv_Output_Dir VARCHAR2(500) := '/usr/tmp/visus25';
Lv_Debug_Filename VARCHAR2(60) := 'su_debug_10_15.dbg';
-- WHO columns
Ln_User_Id NUMBER := 0;
Ln_Resp_Id NUMBER := 56500;
Ln_Application_Id NUMBER := 20003;
i NUMBER := 1;
--
Lv_Eco_Name VARCHAR2(9) := 'TTY_1289'; --工程变更名称
Lv_Org_Code VARCHAR2(3) := 'TTY'; --库组组织
Lv_Rev_Item_Number VARCHAR2(20) := 'D000317US978'; --修订物料编码
Ld_Eff_Date DATE := Trunc(SYSDATE); --有效日期
Lv_New_Revised_Item_Revision VARCHAR2(2) := NULL;
BEGIN
-- Initialized application Context
Fnd_Global.Apps_Initialize(Ln_User_Id, Ln_Resp_Id, Ln_Application_Id); -- Mfg / Mfg & Dist Mgr / INV
Error_Handler.Initialize;
Lv_Return_Status := NULL;
--Initialized ECO Header
Lt_Eco_Rec.Eco_Name := Lv_Eco_Name; --工程变更名称
Lt_Eco_Rec.Organization_Code := Lv_Org_Code; --库组组织
Lt_Eco_Rec.Change_Type_Code := 'BOM Change'; --类型
Lt_Eco_Rec.Eco_Department_Name := NULL; --ECO部门
Lt_Eco_Rec.Priority_Code := 'Medium'; --优先级
Lt_Eco_Rec.Approval_List_Name := 'CEP_B_DCC'; --审批列表;
Lt_Eco_Rec.Reason_Code := 'A_New'; --原因代码
Lt_Eco_Rec.Approval_Status_Name := 'Approved'; --审批状态
Lt_Eco_Rec.Status_Name := 'Open'; --状态
Lt_Eco_Rec.Description := 'ECO - ' || Lt_Eco_Rec.Eco_Name ||
' API Test'; --说明
Lt_Eco_Rec.Transaction_Type := 'CREATE'; --transaction type : CREATE / UPDATE
Lt_Eco_Rec.Plm_Or_Erp_Change := 'ERP'; -- ERP or PLM
Lt_Eco_Rec.Return_Status := NULL;
--Initialized ECO revised items
Lt_Revised_Item_Tbl(i).Eco_Name := Lv_Eco_Name; --工程变更名称
Lt_Revised_Item_Tbl(i).Organization_Code := Lv_Org_Code; --库组组织
Lt_Revised_Item_Tbl(i).Revised_Item_Name := Lv_Rev_Item_Number; --修订物料
Lt_Revised_Item_Tbl(i).New_Revised_Item_Revision := Lv_New_Revised_Item_Revision; --修订版本
Lt_Revised_Item_Tbl(i).Start_Effective_Date := Ld_Eff_Date; --有效日期
Lt_Revised_Item_Tbl(i).Alternate_Bom_Code := NULL; --
Lt_Revised_Item_Tbl(i).Status_Type := 1; -- 1 - 'Open', 4 - 'Scheduled' , 5 - Cancelled
Lt_Revised_Item_Tbl(i).Change_Description := 'Test'; --变更说明
Lt_Revised_Item_Tbl(i).Transaction_Type := 'CREATE'; -- transaction type : CREATE / UPDATE
-- Disable B000317ABS558, acd_type = 3
Lt_Rev_Component_Tbl(i).Eco_Name := Lv_Eco_Name;
Lt_Rev_Component_Tbl(i).Organization_Code := Lv_Org_Code;
Lt_Rev_Component_Tbl(i).Revised_Item_Name := Lv_Rev_Item_Number;
Lt_Rev_Component_Tbl(i).New_Revised_Item_Revision := Lv_New_Revised_Item_Revision;
Lt_Rev_Component_Tbl(i).Start_Effective_Date := Ld_Eff_Date; --To_Date('2017-07-12 16:45:11' ,'yyyy-mm-dd hh24:mi:ss');
Lt_Rev_Component_Tbl(i).Disable_Date := Ld_Eff_Date + 1; -- disable date is 2 day from effective_date
Lt_Rev_Component_Tbl(i).Operation_Sequence_Number := 1;
Lt_Rev_Component_Tbl(i).Component_Item_Name := 'B000317ABS558'; -- disable
Lt_Rev_Component_Tbl(i).Alternate_Bom_Code := NULL;
Lt_Rev_Component_Tbl(i).Acd_Type := 3; --活动类型:1为添加 2为更改 3为禁用
Lt_Rev_Component_Tbl(i).Item_Sequence_Number := 100; --物料序号
Lt_Rev_Component_Tbl(i).Old_Effectivity_Date := To_Date('2017-07-12 16:45:11'
,'yyyy-mm-dd hh24:mi:ss'); -- old effectivity date from bill
Lt_Rev_Component_Tbl(i).Old_Operation_Sequence_Number := 1; -- old operation sequence number from bill
Lt_Rev_Component_Tbl(i).Transaction_Type := 'CREATE'; -- transaction type : CREATE / UPDATE
-- Add B000317ABS560, acd_type = 1
i := i + 1;
Lt_Rev_Component_Tbl(i).Eco_Name := Lv_Eco_Name; --工程变更名称
Lt_Rev_Component_Tbl(i).Organization_Code := Lv_Org_Code; --库组组织
Lt_Rev_Component_Tbl(i).Revised_Item_Name := Lv_Rev_Item_Number; --修订物料
Lt_Rev_Component_Tbl(i).New_Revised_Item_Revision := Lv_New_Revised_Item_Revision; --修订版本
Lt_Rev_Component_Tbl(i).Start_Effective_Date := Ld_Eff_Date; --有效日期
Lt_Rev_Component_Tbl(i).Operation_Sequence_Number := 1;
Lt_Rev_Component_Tbl(i).Component_Item_Name := 'B000317ABS560'; -- Add
Lt_Rev_Component_Tbl(i).Alternate_Bom_Code := NULL;
Lt_Rev_Component_Tbl(i).Acd_Type := 1; --活动类型:1为添加 2为更改 3为禁用
Lt_Rev_Component_Tbl(i).Item_Sequence_Number := 100; --物料序号
Lt_Rev_Component_Tbl(i).Quantity_Per_Assembly := 5;
Lt_Rev_Component_Tbl(i).Transaction_Type := 'CREATE'; -- transaction type : CREATE / UPDATE
--Change C000317PVS089, acd_type = 2
i := i + 1;
Lt_Rev_Component_Tbl(i).Eco_Name := Lv_Eco_Name;
Lt_Rev_Component_Tbl(i).Organization_Code := Lv_Org_Code;
Lt_Rev_Component_Tbl(i).Revised_Item_Name := Lv_Rev_Item_Number;
Lt_Rev_Component_Tbl(i).New_Revised_Item_Revision := Lv_New_Revised_Item_Revision;
Lt_Rev_Component_Tbl(i).Start_Effective_Date := Ld_Eff_Date; -- effective date
Lt_Rev_Component_Tbl(i).Operation_Sequence_Number := 1;
Lt_Rev_Component_Tbl(i).Component_Item_Name := 'C000317PVS089'; -- Change qty for RS_BOM_C1
Lt_Rev_Component_Tbl(i).Alternate_Bom_Code := NULL;
Lt_Rev_Component_Tbl(i).Acd_Type := 2; --活动类型:1为添加 2为更改 3为禁用
Lt_Rev_Component_Tbl(i).Old_Effectivity_Date := To_Date('2017-08-15 09:50:38'
,'yyyy-mm-dd hh24:mi:ss'); -- old effectivity date from bill
Lt_Rev_Component_Tbl(i).Old_Operation_Sequence_Number := 1; -- old operation sequence number from bill
Lt_Rev_Component_Tbl(i).Item_Sequence_Number := 80; --物料序号
Lt_Rev_Component_Tbl(i).Quantity_Per_Assembly := 2; -- existing comp qty on Bill = 2
Lt_Rev_Component_Tbl(i).Transaction_Type := 'CREATE'; -- transaction type : CREATE / UPDATE
--Initialized ECO revised components
-- Add Ref desig, acd_type = 1
Lt_Ref_Designator_Tbl(1).Eco_Name := Lv_Eco_Name;
Lt_Ref_Designator_Tbl(1).Organization_Code := Lv_Org_Code;
Lt_Ref_Designator_Tbl(1).Revised_Item_Name := Lv_Rev_Item_Number;
Lt_Ref_Designator_Tbl(1).Start_Effective_Date := Ld_Eff_Date; -- same as revised item effective date timestamp
Lt_Ref_Designator_Tbl(1).New_Revised_Item_Revision := Lv_New_Revised_Item_Revision;
Lt_Ref_Designator_Tbl(1).Operation_Sequence_Number := 1;
Lt_Ref_Designator_Tbl(1).Component_Item_Name := 'B000317ABS560'; -- Revised component
Lt_Ref_Designator_Tbl(1).Alternate_Bom_Code := NULL;
Lt_Ref_Designator_Tbl(1).Reference_Designator_Name := 'C102'; --参考指示符
Lt_Ref_Designator_Tbl(1).Acd_Type := 1; -- 1 - Add, 2 - Change , 3 - Delete
Lt_Ref_Designator_Tbl(1).Ref_Designator_Comment := 'Test Ref_Designator';
Lt_Ref_Designator_Tbl(1).New_Reference_Designator := NULL;
Lt_Ref_Designator_Tbl(1).Transaction_Type := 'CREATE'; --transaction type : CREATE / UPDATE
-- call API to create eco
Dbms_Output.Put_Line('=======================================================');
Dbms_Output.Put_Line('Calling Eng_Eco_PUB.Process_Eco API');
Eng_Eco_Pub.Process_Eco(p_Api_Version_Number => 1.0
--,p_Init_Msg_List =>Fnd_Api.g_False
,x_Return_Status => Lv_Return_Status
,x_Msg_Count => Ln_Msg_Count
,p_Bo_Identifier => 'ECO'
,p_Eco_Rec => Lt_Eco_Rec
,p_Eco_Revision_Tbl => Lt_Eco_Revision_Tbl
,p_Revised_Item_Tbl => Lt_Revised_Item_Tbl
,p_Rev_Component_Tbl => Lt_Rev_Component_Tbl
,p_Ref_Designator_Tbl => Lt_Ref_Designator_Tbl
,p_Sub_Component_Tbl => Lt_Sub_Component_Tbl
,p_Rev_Operation_Tbl => Lt_Rev_Operation_Tbl
,p_Rev_Op_Resource_Tbl => Lt_Rev_Op_Resource_Tbl
,p_Rev_Sub_Resource_Tbl => Lt_Rev_Sub_Resource_Tbl
,x_Eco_Rec => Xt_Eco_Rec
,x_Eco_Revision_Tbl => Xt_Eco_Revision_Tbl
,x_Revised_Item_Tbl => Xt_Revised_Item_Tbl
,x_Rev_Component_Tbl => Xt_Rev_Component_Tbl
,x_Ref_Designator_Tbl => Xt_Ref_Designator_Tbl
,x_Sub_Component_Tbl => Xt_Sub_Component_Tbl
,x_Rev_Operation_Tbl => Xt_Rev_Operation_Tbl
,x_Rev_Op_Resource_Tbl => Xt_Rev_Op_Resource_Tbl
,x_Rev_Sub_Resource_Tbl => Xt_Rev_Sub_Resource_Tbl
,p_Debug => 'N'
,p_Output_Dir => Lv_Output_Dir
,p_Debug_Filename => Lv_Debug_Filename);
Dbms_Output.Put_Line('xt_Eco_Rec.eco_name:' || Xt_Eco_Rec.Eco_Name);
Dbms_Output.Put_Line('xt_Eco_Rec.org_code:' ||
Xt_Eco_Rec.Organization_Code);
Dbms_Output.Put_Line('=======================================================');
Dbms_Output.Put_Line('Return Status: ' || Lv_Return_Status);
IF (Lv_Return_Status <> Fnd_Api.g_Ret_Sts_Success) THEN
Dbms_Output.Put_Line('x_msg_count:' || Ln_Msg_Count);
Error_Handler.Get_Message_List(x_Message_List => Lt_Error_Table);
Dbms_Output.Put_Line('Error Message Count :' || Lt_Error_Table.Count);
FOR i IN 1 .. Lt_Error_Table.Count LOOP
Dbms_Output.Put_Line(To_Char(i) || ':' || Lt_Error_Table(i)
.Entity_Index || ':' || Lt_Error_Table(i)
.Table_Name);
Dbms_Output.Put_Line(To_Char(i) || ':' || Lt_Error_Table(i)
.Message_Text);
END LOOP;
END IF;
Dbms_Output.Put_Line('=======================================================');
EXCEPTION
WHEN OTHERS THEN
Dbms_Output.Put_Line('Exception Occured :');
Dbms_Output.Put_Line(SQLCODE || ':' || SQLERRM);
Dbms_Output.Put_Line('=======================================================');
RAISE;
END;
官方参考文档:How To Create An Engineering Change Order (ECO) Using ENG_ECO_PUB.Process_Eco API? (文档 ID 1242524.1)