现在的位置: 首页 > 综合 > 正文

根据API创建ITEM

2012年08月02日 ⁄ 综合 ⁄ 共 6636字 ⁄ 字号 评论关闭

 

根据API创建项目

/****************************************************************************************
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;

抱歉!评论已关闭.