Introduction:
Many times before executing standard APIs or querying from org stripped views, you need to initialize apps context.
Script:
set serveroutput on;
declare
l_user_name varchar2(240) := 'SERU'; -- Replace this with Oracle Apps user name
l_resp_name varchar2(240) := 'INV'; -- Responsibility Name
l_prod_short_name varchar2(240) := 'INV'; -- Product Short Name
l_resp_appl_id number;
l_user_id number;
l_resp_id number;
begin
-- Get the user id
begin
select user_id
into l_user_id
from fnd_user
where user_name=l_user_name;
exception
when no_data_found then
dbms_output.put_line('user '|| l_user_name ||' not found');
return;
when others then
dbms_output.put_line('exception :'||sqlerrm);
return;
end;
-- Get the resp id and resp application id
begin
select application_id, Responsibility_id
into l_resp_appl_id, l_resp_id
from fnd_responsibility_vl
where responsibility_name like l_resp_name||'%';
exception
when no_data_found then
dbms_output.put_line('Responsibility '|| l_resp_name ||' not found');
return;
when others then
dbms_output.put_line('exception :'||sqlerrm);
return;
end;
-- call apps init
FND_GLOBAL.APPS_INITIALIZE(USER_ID => l_user_id,RESP_ID => l_resp_id,RESP_APPL_ID=>l_resp_appl_id);
-- set mo global context.
--mo_global.set_org_context(P_ORG_ID_CHAR=> '',P_SP_ID_CHAR=> null,P_APPL_SHORT_NAME=>'');
mo_global.set_org_context(l_prod_short_name);
--mo_global.set_policy_context ('S', v_org_id);
end;
/
Many times before executing standard APIs or querying from org stripped views, you need to initialize apps context.
Script:
set serveroutput on;
declare
l_user_name varchar2(240) := 'SERU'; -- Replace this with Oracle Apps user name
l_resp_name varchar2(240) := 'INV'; -- Responsibility Name
l_prod_short_name varchar2(240) := 'INV'; -- Product Short Name
l_resp_appl_id number;
l_user_id number;
l_resp_id number;
begin
-- Get the user id
begin
select user_id
into l_user_id
from fnd_user
where user_name=l_user_name;
exception
when no_data_found then
dbms_output.put_line('user '|| l_user_name ||' not found');
return;
when others then
dbms_output.put_line('exception :'||sqlerrm);
return;
end;
-- Get the resp id and resp application id
begin
select application_id, Responsibility_id
into l_resp_appl_id, l_resp_id
from fnd_responsibility_vl
where responsibility_name like l_resp_name||'%';
exception
when no_data_found then
dbms_output.put_line('Responsibility '|| l_resp_name ||' not found');
return;
when others then
dbms_output.put_line('exception :'||sqlerrm);
return;
end;
-- call apps init
FND_GLOBAL.APPS_INITIALIZE(USER_ID => l_user_id,RESP_ID => l_resp_id,RESP_APPL_ID=>l_resp_appl_id);
-- set mo global context.
--mo_global.set_org_context(P_ORG_ID_CHAR=> '',P_SP_ID_CHAR=> null,P_APPL_SHORT_NAME=>'');
mo_global.set_org_context(l_prod_short_name);
--mo_global.set_policy_context ('S', v_org_id);
end;
/
No comments:
Post a Comment