您的位置:首页 > 其它

根据API创建BOM

2015-10-13 16:58 351 查看
--根据API创建BOM

--

/*******************************************************************************

*创建:COOLER LEE 2006-1-11 16:09

*目的:该PROCEDURE用于中转对标准创建BOM的API调用。每次调用创建一个BOM

*参数:l_bom_header_rec,BOM头的信息

* l_bom_component_tbl BOM组件的相关信息

* x_return_status 返回值,处理结果,成功为'S',失败为'E',警告为'W'

* x_msg_count 返回值,处理过程中的信息条数,可用代码为中示例来取信息。 

*

*注意事项及用法:

赋值例子:

--BOM头 

l_bom_header_rec := bom_bo_pub.g_miss_bom_header_rec;

l_bom_header_rec.transaction_type := 'CREATE';

-- l_bom_header_rec.Common_Assembly_Item_Name:=;

l_bom_header_rec.assembly_item_name := 'B';

l_bom_header_rec.organization_code := 'ITM';

l_bom_header_rec.assembly_type := 1;

-- l_bom_header_rec.Original_System_Reference:='';

--BOM行

l_bom_component_tbl(1) := bom_bo_pub.g_miss_bom_component_rec;

l_bom_component_tbl(1).transaction_type := 'CREATE';

l_bom_component_tbl(1).assembly_item_name := 'B';

l_bom_component_tbl(1).component_item_name := 'C';

l_bom_component_tbl(1).start_effective_date := SYSDATE;

l_bom_component_tbl(1).organization_code := 'ITM';

l_bom_component_tbl(1).operation_sequence_number := 1;

l_bom_component_tbl(1).item_sequence_number := 10;

l_bom_component_tbl(1).optional := 1; --选项类

l_bom_component_tbl(1).so_basis := 2; --无基准

l_bom_component_tbl(1).wip_supply_type := 1;

l_bom_component_tbl(1).quantity_per_assembly := 1;

*

* 3.在创建ATO模型时,需先创建可选件(AOC)的BOM,最后创建ATO模型.

********************************************************************************/

PROCEDURE create_bom(l_bom_header_rec IN bom_bo_pub.bom_head_rec_type,

l_bom_component_tbl IN bom_bo_pub.bom_comps_tbl_type,

x_return_status IN OUT VARCHAR2,

x_msg_data OUT VARCHAR2,

x_msg_count IN OUT NUMBER) IS

--OUT VARIBLE

x_bom_header_rec bom_bo_pub.bom_head_rec_type;

x_bom_revision_tbl bom_bo_pub.bom_revision_tbl_type;

x_bom_component_tbl bom_bo_pub.bom_comps_tbl_type;

x_bom_ref_designator_tbl bom_bo_pub.bom_ref_designator_tbl_type;

x_bom_sub_component_tbl bom_bo_pub.bom_sub_component_tbl_type;

/* x_return_status VARCHAR2(1);

x_msg_count NUMBER;

*/

BEGIN

--初始化,单独在PL/SQL中测试时需要

/**********************************************

fnd_global.apps_initialize(8949, 50186, 702);

***********************************************/

error_handler.initialize;

x_return_status := NULL;

bom_bo_pub.process_bom(p_bom_header_rec => l_bom_header_rec,

p_init_msg_list => TRUE,

p_bom_component_tbl => l_bom_component_tbl,

x_bom_header_rec => x_bom_header_rec,

x_bom_revision_tbl => x_bom_revision_tbl,

x_bom_component_tbl => x_bom_component_tbl,

x_bom_ref_designator_tbl => x_bom_ref_designator_tbl,

x_bom_sub_component_tbl => x_bom_sub_component_tbl,

x_return_status => x_return_status,

x_msg_count => x_msg_count);

/*,

--p_debug => 'Y',

--p_output_dir => '/usr/tmp',

--p_debug_filename => 'BOM_XGL_009.log'*/

IF x_msg_count > 0 THEN

FOR l_index IN 1 .. x_msg_count LOOP

DECLARE

x_index VARCHAR2(10);

x_msg_data_tmp VARCHAR2(2000);

x_entity_id VARCHAR2(10);

x_message_type VARCHAR2(10);

BEGIN

error_handler.get_message(x_entity_index => x_index,

x_message_text => x_msg_data_tmp,

x_entity_id => x_entity_id,

x_message_type => x_message_type);

dbms_output.put_line(l_index);

x_msg_data := x_msg_data || x_msg_data_tmp;

FOR i IN 1 .. round(length(x_msg_data_tmp) / 255) + 1 LOOP

dbms_output.put_line(substr(x_msg_data_tmp, (i - 1) * 254, 254));

END LOOP;

END;

END LOOP;

END IF;

-- 执行后的信息显示,如果是在PL/SQL中测试需要下段

/**********************************************************************

IF x_msg_count > 0 THEN

FOR l_index IN 1 .. x_msg_count LOOP

DECLARE

x_index VARCHAR2(10);

x_msg_data VARCHAR2(2000);

x_entity_id VARCHAR2(10);

x_message_type VARCHAR2(10);

BEGIN

error_handler.get_message(x_entity_index => x_index,

x_message_text => x_msg_data,

x_entity_id => x_entity_id,

x_message_type => x_message_type);

dbms_output.put_line(l_index);

FOR i IN 1 .. round(length(x_msg_data) / 255) + 1 LOOP

dbms_output.put_line(substr(x_msg_data, (i - 1) * 254, 254));

END LOOP;

END;

END LOOP;

END IF;

-- Check the return status

IF x_return_status = fnd_api.g_ret_sts_success THEN

dbms_output.put_line('创建BOM成功!');

--success;

COMMIT;

ELSE

-- failure;

ROLLBACK;

END IF;

**********************************************************************/

END create_bom;

--

--根据API爆开已创建的BOM

--

/*******************************************************************************

*创建:COOLER LEE 2006-1-11 16:09

*目的:该PROCEDURE用于将新创建的BOM展开到BOM_EXPLOSIONS表。每次调用展开一个多级清单

*参数:p_top_assembly_item_id,BOM中最顶层的inventory_item_id

* p_org_id 组织,如不输入,则取项目主组织

* x_err_msg 返回值,处理结果,存放出错信息,成功时为NULL

* x_err_code 返回值,存放出错代码,成功时为NULL

*

*注意事项及用法:

* 1.该过程一次可以处理整个BOM(最多20层)

* 2.对于ATO模型,必须在插入行到订单之前将ATO模型展开

********************************************************************************/

PROCEDURE exploder_bom(p_top_assembly_item_id NUMBER,

p_org_id NUMBER DEFAULT 2,

x_err_msg IN OUT VARCHAR2,

x_err_code IN OUT NUMBER) IS

v_user_id NUMBER;

BEGIN

v_user_id := nvl(fnd_global.user_id, 0);

bom_oe_exploder_pkg.be_exploder(arg_org_id => p_org_id,

arg_starting_rev_date => SYSDATE,

arg_item_id => p_top_assembly_item_id,

arg_comp_code => '-',

arg_user_id => v_user_id,

arg_err_msg => x_err_msg,

arg_error_code => x_err_code);

-- 执行后的信息显示,如果是在PL/SQL中测试需要下段

/**********************************************************************

IF err_msg IS NOT NULL THEN

dbms_output.put_line(err_code || ':' || err_msg);

ELSE

dbms_output.put_line('成功爆开BOM');

END IF;

**********************************************************************/

END exploder_bom
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: