CREATE OR REPLACE PROCEDURE xxx_pl_item_update_proc(p_segment1 IN VARCHAR2,
p_org_id IN NUMBER,
errbuff OUT NOCOPY VARCHAR2,
retcode OUT NOCOPY VARCHAR2) is
x_return_status VARCHAR2(100);
x_msg_count NUMBER;
x_msg_data VARCHAR2(1000);
v_user_id PLS_INTEGER := fnd_global.user_id;
v_resp_appl_id PLS_INTEGER := fnd_global.resp_appl_id;
v_resp_id PLS_INTEGER := fnd_global.resp_id;
cursor inv_cur is
select INVENTORY_ITEM_ID,
organization_id ,
inventory_item_status_code
from mtl_system_items_b
where segment1 = p_segment1
and inventory_item_status_code != 'Inactive'
and organization_id = Nvl(p_org_id,organization_id);
begin
FND_GLOBAL.APPS_INITIALIZE (FND_PROFILE.VALUE ('v_user_id'),
FND_PROFILE.VALUE ('v_resp_id'),
FND_PROFILE.VALUE ('v_resp_appl_id'));
for inv_rec in inv_cur loop
insert into mtl_pending_item_status
(inventory_item_id,
organization_id,
status_code,
effective_date,
implemented_date,
pending_flag,
last_update_date,
last_updated_by,
creation_date,
created_by)
values(
inv_rec.inventory_item_id, -- Item Segment
inv_rec.organization_id, -- Organization Id
'Inactive', -- status
sysdate,
sysdate,
'Y',
sysdate,
1057,
sysdate,
1057);
/**** STEP 2) Call below API code to do the actual change ****/
--begin
inv_item_status_pub.Update_Pending_Status (
p_api_version => 1.0
,p_Org_Id => inv_rec.organization_id -- Organization Id
,p_Item_Id => inv_rec.inventory_item_id -- Item Segment
,p_init_msg_list => FND_API.G_FALSE
,p_commit => FND_API.G_FALSE
,x_return_status => x_return_status
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data );
end loop;
dbms_output.put_line('x_return_status' || x_return_status);
commit;
EXCEPTION
WHEN no_data_found
THEN
DBMS_OUTPUT.PUT_LINE (SQLCODE || '_' || SQLERRM);
errbuff := 'No Data Found ' || SQLCODE || '_' || SQLERRM ;
retcode := '1'; -- warning
fnd_file.put_line(fnd_file.log, errbuff);
WHEN OTHERS
THEN
errbuff := SQLERRM || ' ' || SQLCODE;
retcode := '2'; -- error
fnd_file.put_line(fnd_file.log,errbuff);
end;
p_org_id IN NUMBER,
errbuff OUT NOCOPY VARCHAR2,
retcode OUT NOCOPY VARCHAR2) is
x_return_status VARCHAR2(100);
x_msg_count NUMBER;
x_msg_data VARCHAR2(1000);
v_user_id PLS_INTEGER := fnd_global.user_id;
v_resp_appl_id PLS_INTEGER := fnd_global.resp_appl_id;
v_resp_id PLS_INTEGER := fnd_global.resp_id;
cursor inv_cur is
select INVENTORY_ITEM_ID,
organization_id ,
inventory_item_status_code
from mtl_system_items_b
where segment1 = p_segment1
and inventory_item_status_code != 'Inactive'
and organization_id = Nvl(p_org_id,organization_id);
begin
FND_GLOBAL.APPS_INITIALIZE (FND_PROFILE.VALUE ('v_user_id'),
FND_PROFILE.VALUE ('v_resp_id'),
FND_PROFILE.VALUE ('v_resp_appl_id'));
for inv_rec in inv_cur loop
insert into mtl_pending_item_status
(inventory_item_id,
organization_id,
status_code,
effective_date,
implemented_date,
pending_flag,
last_update_date,
last_updated_by,
creation_date,
created_by)
values(
inv_rec.inventory_item_id, -- Item Segment
inv_rec.organization_id, -- Organization Id
'Inactive', -- status
sysdate,
sysdate,
'Y',
sysdate,
1057,
sysdate,
1057);
/**** STEP 2) Call below API code to do the actual change ****/
--begin
inv_item_status_pub.Update_Pending_Status (
p_api_version => 1.0
,p_Org_Id => inv_rec.organization_id -- Organization Id
,p_Item_Id => inv_rec.inventory_item_id -- Item Segment
,p_init_msg_list => FND_API.G_FALSE
,p_commit => FND_API.G_FALSE
,x_return_status => x_return_status
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data );
end loop;
dbms_output.put_line('x_return_status' || x_return_status);
commit;
EXCEPTION
WHEN no_data_found
THEN
DBMS_OUTPUT.PUT_LINE (SQLCODE || '_' || SQLERRM);
errbuff := 'No Data Found ' || SQLCODE || '_' || SQLERRM ;
retcode := '1'; -- warning
fnd_file.put_line(fnd_file.log, errbuff);
WHEN OTHERS
THEN
errbuff := SQLERRM || ' ' || SQLCODE;
retcode := '2'; -- error
fnd_file.put_line(fnd_file.log,errbuff);
end;
No comments:
Post a Comment