免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2678 | 回复: 0
打印 上一主题 下一主题

根据API创建项目 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-25 09:24 |只看该作者 |倒序浏览
根据API创建项目


引用地址:http://showxz.bokee.com/viewdiary.14709005.html

/****************************************************************************************
Created By : COOLER LEE

Creation Date : 2006-1-4

Notes : Please uncomment the dbms_output statements if needed.
This is being commented out for check in purposes.
Purpose : Create,Update item by API.
******************************************************************************************/

/*****************************************************************************************
*根据API创建项目
*创建:LEE 2006-1-4
*目的:该PROCEDURE用于创建项目。每次调用创建一个项目
*参数:l_template_name : 所需要应用的项目模板名称(新建项目的将从依据模板来生成项目属性)
* l_item_rec : 指定须创建项目的属性,必须先赋值再传入,如,
* l_item_rec.segment1 := 'TEST-ITEM01';
l_item_rec.description := 'LEE-CREATE-TEST-ITEM01';
l_item_rec.organization_id := 2;
l_template_name := 'ATO 选件类';
* x_item_rec :已创建好的项目. (用于在程序中返回当前项目的信息)
* x_return_status : 返回值,处理结果,成功为'*',失败为'*'
* *_error_tbl : 返回处理过程中的信息(如果处理失败)
*注意事项及用法:
* 可用的模板如,
* --ATO 模型
* --ATO 选件类
* --成品模板
* --光板
* --非标模胚
l_template_name := 'ATO 选件类';

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

PROCEDURE create_item(l_template_name VARCHAR2,
l_item_rec IN inv_item_grp.item_rec_type,
x_item_rec IN OUT inv_item_grp.item_rec_type,
x_return_status IN OUT VARCHAR2,
x_msg_data OUT VARCHAR2,
x_error_tbl IN OUT inv_item_grp.error_tbl_type) IS
v_message_tmp VARCHAR2(2000);
BEGIN

inv_item_grp.create_item(p_template_name => l_template_name,
p_item_rec => l_item_rec,
x_item_rec => x_item_rec,
x_return_status => x_return_status,
x_error_tbl => x_error_tbl);

dbms_output.put_line('执行结果' || x_return_status);
COMMIT;
FOR i IN 1 .. x_error_tbl.COUNT
LOOP
x_msg_data := x_msg_data || x_error_tbl(i).message_text;
END LOOP;

--返回出错信息示例
/***********************************************************************************
j := x_error_tbl.COUNT;
dbms_output.put_line('执行结果' || x_return_status);

IF j > 0 THEN
ROLLBACK;
dbms_output.put_line('-------------------------------------------------------------');

FOR i IN 1 .. j LOOP
dbms_output.put_line(x_error_tbl(j).message_name);
dbms_output.put_line(x_error_tbl(j).message_name);
dbms_output.put_line(x_error_tbl(j).table_name);
dbms_output.put_line(x_error_tbl(j).column_name);
dbms_output.put_line(substr(x_error_tbl(j).message_text, 1, 254));
END LOOP;
dbms_output.put_line('-------------------------------------------------------------');
ELSE
COMMIT;
END IF;
*************************************************************************************/

END create_item;

----------------------------------------------------------------------------------------------

--- Test Example
--- Created on 2006-1-4 by LEE
declare
-- Local variables here
l_item_rec inv_item_grp.item_rec_type;
x_return_status VARCHAR2(200);
x_msg_data VARCHAR2(200);
x_error_tbl inv_item_grp.error_tbl_type;
x_item_rec inv_item_grp.item_rec_type;
l_template_name VARCHAR2(200);
v_message_tmp VARCHAR2(2000);
i integer;
begin
-- Test statements here

l_item_rec.segment1 := 'TEST-ITEM01';
l_item_rec.description := 'LEE-CREATE-TEST-ITEM01';
l_item_rec.organization_id := 2;
l_template_name := 'ATO 选件类';
inv_item_grp.create_item(p_template_name => l_template_name,
p_item_rec => l_item_rec,
x_item_rec => x_item_rec,
x_return_status => x_return_status,
x_error_tbl => x_error_tbl);

dbms_output.put_line('执行结果 ' || x_return_status);
if x_return_status = fnd_api.G_RET_STS_SUCCESS then
--success;
COMMIT;
DBMS_OUTPUT.put_line('success');
else
--failure;
ROLLBACK;
DBMS_OUTPUT.put_line('failure');
end if;
FOR i IN 1 .. x_error_tbl.COUNT LOOP
x_msg_data := x_msg_data || x_error_tbl(i).message_text;
dbms_output.put_line('x_msg_data is :' || x_msg_data);
END LOOP;
end;

/*****************************************************************************************
*根据API更新项目
*创建:LEE 2006-1-4
*目的:该PROCEDURE用于更新项目。每次调用更新一个项目
*参数:
* l_item_rec : 指定需要更新项目的属性,必须先赋值再传入,如,
* l_item_rec.segment1 := 'TEST-ITEM01';
l_item_rec.description := 'LEE-CREATE-TEST-ITEM01-UPDATE';
l_item_rec.organization_id := 2;
* x_item_rec :已更新好的项目. (用于在程序中返回当前项目的信息)
* x_return_status : 返回值,处理结果,成功为'*',失败为'*'
* *_error_tbl : 返回处理过程中的信息(如果处理失败)
*注意事项及用法:
指定需要更新项目的属性;

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

PROCEDURE update_item(l_item_rec IN inv_item_grp.item_rec_type,
x_item_rec IN OUT inv_item_grp.item_rec_type,
x_return_status IN OUT VARCHAR2,
x_msg_data OUT VARCHAR2,
x_error_tbl IN OUT inv_item_grp.error_tbl_type) IS
v_message_tmp VARCHAR2(2000);
BEGIN

inv_item_grp.update_item(p_item_rec => l_item_rec,
x_item_rec => x_item_rec,
x_return_status => x_return_status,
x_error_tbl => x_error_tbl);

dbms_output.put_line('执行结果' || x_return_status);
COMMIT;
FOR i IN 1 .. x_error_tbl.COUNT
LOOP
x_msg_data := x_msg_data || x_error_tbl(i).message_text;
END LOOP;

--返回出错信息示例
/***********************************************************************************
j := x_error_tbl.COUNT;
dbms_output.put_line('执行结果' || x_return_status);

IF j > 0 THEN
ROLLBACK;
dbms_output.put_line('-------------------------------------------------------------');

FOR i IN 1 .. j LOOP
dbms_output.put_line(x_error_tbl(j).message_name);
dbms_output.put_line(x_error_tbl(j).message_name);
dbms_output.put_line(x_error_tbl(j).table_name);
dbms_output.put_line(x_error_tbl(j).column_name);
dbms_output.put_line(substr(x_error_tbl(j).message_text, 1, 254));
END LOOP;
dbms_output.put_line('-------------------------------------------------------------');
ELSE
COMMIT;
END IF;
*************************************************************************************/

END update_item;

----------------------------------------------------------------------------------------------

--- Test Example
--- Created on 2006-1-4 by LEE
declare
-- Local variables here
l_item_rec inv_item_grp.item_rec_type;
x_return_status VARCHAR2(200);
x_msg_data VARCHAR2(200);
x_error_tbl inv_item_grp.error_tbl_type;
x_item_rec inv_item_grp.item_rec_type;
l_template_name VARCHAR2(200);
v_message_tmp VARCHAR2(2000);
i integer;
begin
-- Test statements here

l_item_rec.segment1 := 'TEST-ITEM01';
l_item_rec.description := 'LEE-CREATE-TEST-ITEM01-UPDATE';
l_item_rec.organization_id := 2;
--l_template_name := 'ATO 选件类';
inv_item_grp.Update_Item( /*p_commit => TRUE,*/
-- p_template_name => l_template_name,
p_item_rec => l_item_rec,
x_item_rec => x_item_rec,
x_return_status => x_return_status,
x_error_tbl => x_error_tbl);

dbms_output.put_line('执行结果 ' || x_return_status);
if x_return_status = fnd_api.G_RET_STS_SUCCESS then
--success;
COMMIT;
DBMS_OUTPUT.put_line('success');
else
--failure;
ROLLBACK;
DBMS_OUTPUT.put_line('failure');
end if;
FOR i IN 1 .. x_error_tbl.COUNT LOOP
x_msg_data := x_msg_data || x_error_tbl(i).message_text;
dbms_output.put_line('x_msg_data is :' || x_msg_data);
END LOOP;
end;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP