P. 1
Fnd Client Info

Fnd Client Info

|Views: 320|Likes:
Published by ngvpchoices

More info:

Published by: ngvpchoices on Apr 28, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

08/31/2013

pdf

text

original

TEXT

PACKAGE

"FND_CLIENT_INFO" as

/* $Header: AFCINFOS.pls 120.1.12000000.3 2007/04/17 14:05:14 pdeluna ship $ */

--

-- This package-level pragma means that the initialization section of this

-- package cannot write any DB or package status

--

-- Currently, this package has no initialization section

--

WNPS. WNDS). .pragma restrict_references (fnd_client_info.

-- .

-.Name .

-- setup_client_info .

-.Purpose .

-- Sets up the operating unit context and the Multi-Currency context .

.-- in the client info area based on the current application.

-- responsibility. security group and organization. -- . user.

-.Arguments .

-- application_id .

-- responsibility_id .

-- user_id .

-- security_group_id -- org_id .

-- .

procedure setup_client_info(application_id in number. .

.responsibility_id in number.

.user_id in number.

.security_group_id in number.

-- .org_id in number).

-.Name .

-- setup_client_info .

-.Purpose .

-- Sets up the operating unit context and the Multi-Currency context .

.-- in the client info area based on the current application.

. -- This is an overloaded version for backwards compatibility.-- responsibility. and security_group. user.

-- .

Arguments .-.

-- application_id .

-- responsibility_id .

-- user_id -- security_group_id .

-- .

.procedure setup_client_info(application_id in number.

.responsibility_id in number.

.user_id in number.

.security_group_id in number).

-- .

Name .-.

-- set_org_context .

Purpose .-.

-- Sets up the operating unit context in the client info area .

-- .

-.org_id for the operating unit. can be up to 10 .Arguments -- context .

-- bytes long .

-- .

procedure set_org_context (context in varchar2). .

.

Name .-- -.

-- set_currency_context .

Purpose .-.

-- Sets up the client info area for Multi-Currency reporting .

-- .

Arguments .-.

--

context

- context information up to 10 bytes

--

procedure set_currency_context (context in varchar2);

--

-- Name

--

set_security_group_context

-- Purpose

--

Sets up the the security group context in the client info area

--

-- Arguments

--

context

- security_group_id; can be up to 10 bytes long

-- .

.procedure set_security_group_context (context in varchar2).

.

-- .

-.Name .

-- org_security .

-.Purpose .

-- Called by oracle server during parsing sql statment -- .

-.Arguments .

-- obj_schema .schema of the object .

-- obj_name .name of the object .

-- .

FUNCTION org_security( .

obj_name VARCHAR2 .obj_schema VARCHAR2 .

) .

.RETURN VARCHAR2.

.

end fnd_client_info. .

.

PACKAGE BODY "FND_CLIENT_INFO" as .

12000000./* $Header: AFCINFOB.6 2007/12/06 01:59:49 pdeluna ship $ */ .2.pls 120.

.

.

-- .

-.Private Functions and Procedures -- .

.procedure generic_error(routine in varchar2.

errcode in number. .

errmsg in varchar2) is .

begin .

.set_name('FND'.fnd_message. 'SQL_PLSQL_ERROR').

fnd_message. errcode). fnd_message.set_token('ROUTINE'. .set_token('ERRNO'. routine).

dbms_utility. .set_token('REASON'.format_error_stack).fnd_message.

put_line(fnd_message.-- dbms_output. .get).

raise_error.fnd_message. .

end. .

-- .

-.Public Functions and Procedures .

-- .

.

-- .

-.Name .

Purpose .-- setup_client_info -.

-- Sets up the operating unit context and the Multi-Currency context .

-- in the client info area based on the current application. .

security_group and organization. .-- responsibility. user.

-- .

Arguments .-.

-- application_id -- responsibility_id .

-- user_id .

-- security_group_id .

-- org_id .

-- .

responsibility_id in number.procedure setup_client_info(application_id in number. .

.user_id in number.

security_group_id in number. .

org_id in number) is .

org_id_char varchar2(240). .

.org_id_defined boolean.

sp_id_char varchar2(240). . sp_id_defined boolean.

is_multi_org varchar2(1). .

no_morg_profile_value exception. .

reporting_sob_id_char varchar2(240). .

reporting_sob_id_defined boolean. .

is_multi_currency varchar2(1). .

security_profile_id_char varchar2(240).no_mcur_profile_value exception. .

.-- security_profile_id_defined boolean.

l_security_profile_id NUMBER. .

.l_morg_profile_name varchar2(240).

begin .

GET_SPECIFIC CALL IN ./* Bug 5646892: APPSPERFR12:FND:EXTRA FND_PROFILE.

SETUP_CLIENT_INFO .FND_CLIENT_INFO.

org_id.FND_GLOBAL will now pass in the org_id context.e. . FND_GLOBAL. i.

There is no need for setup_client_info to get the ORG_ID value again. .

*/ .

.

-- -.Set MultiOrg Context .

-- .

Check if org_id is NULL or -1.-. not NULL since . It is likely that org_id = -1.

-. When fnd_global calls fnd_profile to get the .fnd_global is passing it in.

-. fnd_global does not set org_id .org_id value and the value returned is NULL.

to NULL. org_id = -1 means there .-. It just leaves the default value of -1. So.

setup_client_info was that it did not check the value. but rather whether a . A benefit of calling fnd_profile in -.was no value returned by fnd_profile.-.

value was defined.-. .

if (org_id is NULL) or (org_id = -1) then .

then check if the instance is multiorg-enabled.If not R12. .-.

if fnd_release.major_version < 12 then .

nvl(multi_currency_flag.Check FND_PRODUCT_GROUPS for multi-org/currency flags select nvl(multi_org_flag. 'N') .-. 'N').

is_multi_currency .into is_multi_org.

.from fnd_product_groups.

If multiorg-enabled. . raise an error since org_id should not be NULL.-.

FND_GLOBAL. .-.org_id should not be NULL if instance is multiorg-enabled.

if is_multi_org = 'Y' then .

not set. indeed. Need to make sure before .get_specific call is a LAST CHECK to make sure that org_id is./* Bug 6637377: This fnd_profile.

This should not undo the fix for 5646892 .the error is raised.

.completely and is needed.

*/ .

responsibility_id. .get_specific('ORG_ID'.fnd_profile. user_id.

org_id_defined). org_id_char.application_id. .

-. then raise the exception. as .If org_id is really not defined.

-.planned. .

if (not org_id_defined) then .

.

select user_profile_option_name .

into l_morg_profile_name from fnd_profile_options_vl .

where profile_option_name = 'ORG_ID'. .

.

raise no_morg_profile_value. .

end if. .

.end if.

else -.Bug 2852842: Due to MOAC re-architecture for R12. a default org_id .

then default the org . If ORG_ID is not set.is no longer required.-.

No need to raise an error in R12. .client_info area to null.-.

.org_id_char := ''.

end if. .

else .

If org_id is NOT NULL. convert to string. . org_id_char := to_char(org_id).-.

.end if.

.

.set_org_context(org_id_char).fnd_client_info.

.

Set MultiCurrency Context. .-- -.

-.This applies to releases before R12. .

-- .

major_version < 12 then .if fnd_release.

if is_multi_currency = 'Y' then .

-- .

-.Get MRC_REPORTING_SOB_ID profile option value -- .

fnd_profile.get_specific('MRC_REPORTING_SOB_ID'. .

. responsibility_id.user_id. application_id.

.reporting_sob_id_char. reporting_sob_id_defined ).

-- .

-.If MRC_REPORTING_SOB_ID profile option defined for this responsibility.set the currency context = MRC_REPORTING_SOB_ID for this resp . -.

-- .

if reporting_sob_id_defined then .

.fnd_client_info.set_currency_context(reporting_sob_id_char).

else .

raise no_mcur_profile_value. .

end if. .

end if. .

end if. .

.

-- .

-.Set Security Group Context .

-- fnd_client_info.set_security_group_context(to_char(security_group_id)). .

.

exception .

when no_morg_profile_value then .

.fnd_message. 'FND-ORG_ID PROFILE CANNOT READ').set_name('FND'.

.set_token('OPTION'.put_line(fnd_message.fnd_message.get). -- dbms_output. l_morg_profile_name).

.fnd_message.raise_error.

-- generic_error('FND_CLIENT_INFO.SETUP_CLIENT_INFO'. . -20000.

-- 'MultiOrg enabled but ORG_ID profile not defined'). .

when no_mcur_profile_value then .

-20000.SETUP_CLIENT_INFO'. .generic_error('FND_CLIENT_INFO.

when others then .'MultiCurrency enabled but MRC_REPORTING_SOB_ID profile not defined').

sqlerrm).SETUP_CLIENT_INFO'.generic_error('FND_CLIENT_INFO. sqlcode. .

.

.end setup_client_info.

.

-- .

-.Name -- setup_client_info .

Purpose .-.

-- Sets up the operating unit context and the Multi-Currency context .

.-- in the client info area based on the current application.

-- responsibility. . and security_group. user.

-- This is an overloaded version for backwards compatibility. -- .

-.Arguments .

-- application_id .

-- responsibility_id .

-- user_id .

-- security_group_id .

-- procedure setup_client_info(application_id in number. .

responsibility_id in number. .

.user_id in number.

security_group_id in number) is .

begin .

.

.-.Call setup_client_info and pass in fnd_global.org argument.org_id for -.

user_id. responsibility_id.setup_client_info(application_id. .

org_id).security_group_id. . fnd_global.

.

.end setup_client_info.

-- .

Name .-.

-- set_org_context .

-.Purpose .

-- Sets up the operating unit context in the client info area .

-- .

org_id for the operating unit.-.Arguments -- context . can be up to 10 .

-- bytes long .

-- .

procedure set_org_context (context in varchar2) is .

context_area varchar2(64). .

.context_too_long exception.

. local_context varchar2(30).bad_characters exception.

begin .

.

-.check for multibyte characters .

.

if length(context) <> lengthb(context) then raise bad_characters. .

end if. .

.

check for input string too long .-.

.

if lengthb(context) > 10 then .

end if. .raise context_too_long.

.

set local_context to first ten chars of context .-.

-- set to a single space if context was null

local_context := substrb(nvl(context,' '),1,10);

-- pad local_context on the right with blanks to exactly 10 bytes

-- Do not use RPAD(), because it may not work as expected with a

-- MultiByte character set

while lengthb(local_context) < 10 loop

local_context := local_context

' ';

end loop;

-.Get current CLIENT_INFO value in context_area variable .

.

.read_client_info(context_area).dbms_application_info.

.

Do not use RPAD().-. because it may not work as expected with a .pad context_area on the right with blanks to exactly 64 bytes -.

-.MultiByte character set .

.

context_area := nvl(context_area.' '). .

.

while lengthb(context_area) < 64 loop .

context_area := context_area ' '. . end loop.

.

load new value into context_area .-.

.

context_area := local_context .

substrb(context_area. .11.54).

-.save context_area variable to CLIENT_INFO .

.

dbms_application_info.set_client_info(context_area). .

.

exception .

when context_too_long then fnd_message. 'CLIENT_INFO_ARG_TOO_LONG'). .set_name('FND'.

.set_token('ROUTINE'. 'SET_ORG_CONTEXT').fnd_message.

set_token('BAD_ARG'. context). .fnd_message.

-- dbms_output. .get).put_line(fnd_message.

raise_error. .fnd_message.

when bad_characters then .

generic_error('FND_CLIENT_INFO. -20000. . 'Only single-byte characters are valid input').SET_ORG_CONTEXT'.

when others then .

sqlcode. .generic_error('FND_CLIENT_INFO.SET_ORG_CONTEXT'. sqlerrm).

.

.end set_org_context.

-- .

Name .-.

-- set_currency_context .

-.Purpose .

-- Sets up the client info area for Multi-Currency reporting .

-- .

context information up to 10 bytes .-.Arguments -- context .

-- .

procedure set_currency_context (context in varchar2) is .

.context_area varchar2(64).

.context_too_long exception.

.bad_characters exception.

local_context varchar2(30). begin .

.

check for multibyte characters .-.

.

if length(context) <> lengthb(context) then .

raise bad_characters. . end if.

.

check for input string too long .-.

.

if lengthb(context) > 10 then .

.raise context_too_long.

end if. .

-.set local_context to first ten chars of context .

set to a single space if context was null .-.

.

1.10). .' ').local_context := substrb(nvl(context.

.

pad local_context on the right with blanks to exactly 10 bytes -.-. because it may not work as expected with a .Do not use RPAD().

-.MultiByte character set .

.

while lengthb(local_context) < 10 loop .

local_context := local_context ' '. .

end loop. .

Get current CLIENT_INFO value in context_area variable .-.

.

read_client_info(context_area).dbms_application_info. .

.

pad context_area on the right with blanks to exactly 64 bytes .-.

because it may not work as expected with a -.MultiByte character set .-.Do not use RPAD().

.

context_area := nvl(context_area. .' ').

.

while lengthb(context_area) < 64 loop .

context_area := context_area ' '. .

.end loop.

load new value into context_area .-.

.

1.context_area := substrb(context_area.44) .

local_context .

.10).55.substrb(context_area.

-.save context_area variable to CLIENT_INFO .

.

dbms_application_info. .set_client_info(context_area).

.

exception .

'CLIENT_INFO_ARG_TOO_LONG'). .set_name('FND'.when context_too_long then fnd_message.

. 'SET_CURRENCY_CONTEXT').set_token('ROUTINE'.fnd_message.

context).fnd_message. .set_token('BAD_ARG'.

put_line(fnd_message. .-- dbms_output.get).

.raise_error.fnd_message.

when bad_characters then .

'Only single-byte characters are valid input').generic_error('FND_CLIENT_INFO.SET_CURRENCY_CONTEXT'. . -20000.

when others then .

. sqlcode.generic_error('FND_CLIENT_INFO. sqlerrm).SET_CURRENCY_CONTEXT'.

.

.end set_currency_context.

-- .

Name .-.

-- set_security_group_context .

Purpose .-.

-- Sets up the the security group context in the client info area .

-- .

security_group_id. can be up to 10 bytes long .-.Arguments -- context .

-- .

procedure set_security_group_context (context in varchar2) is .

.context_area varchar2(64).

context_too_long exception. .

.bad_characters exception.

begin .local_context varchar2(30).

.

check for multibyte characters .-.

.

if length(context) <> lengthb(context) then .

.raise bad_characters. end if.

.

check for input string too long .-.

.

if lengthb(context) > 10 then .

.raise context_too_long.

.end if.

-- set local_context to first ten chars of context

-- set to a single space if context was null

local_context := substrb(nvl(context,' '),1,10);

-- pad local_context on the right with blanks to exactly 10 bytes

-- Do not use RPAD(), because it may not work as expected with a

-- MultiByte character set

while lengthb(local_context) < 10 loop

local_context := local_context

' ';

end loop. .

Get current CLIENT_INFO value in context_area variable .-.

.

dbms_application_info. .read_client_info(context_area).

.

-.pad context_area on the right with blanks to exactly 64 bytes .

Do not use RPAD().MultiByte character set . because it may not work as expected with a -.-.

.

' '). .context_area := nvl(context_area.

.

while lengthb(context_area) < 64 loop .

.context_area := context_area ' '.

.end loop.

load new value into context_area .-.

context_area := substrb(context_area.54) .1.

.local_context.

.

save context_area variable to CLIENT_INFO .-.

set_client_info(context_area).dbms_application_info. .

.

exception .

when context_too_long then .

'CLIENT_INFO_ARG_TOO_LONG').fnd_message. .set_name('FND'.

fnd_message. . context).set_token('ROUTINE'.set_token('BAD_ARG'.fnd_message. 'SET_SECURITY_GROUP_CONTEXT').

.-- dbms_output.put_line(fnd_message.get).

raise_error. .fnd_message.

when bad_characters then .

generic_error('FND_CLIENT_INFO.SET_SECURITY_GROUP_CONTEXT'. . -20000.

'Only single-byte characters are valid input'). .

.SET_SECURITY_GROUP_CONTEXT'.when others then generic_error('FND_CLIENT_INFO.

sqlcode. sqlerrm). .

end set_security_group_context. .

.

-- .

-.Name -- org_security .

Purpose .-.

-- Called by oracle server during parsing sql statment .

-- .

Arguments .-.

schema of the object .-- obj_schema .

-- obj_name .name of the object -- .

FUNCTION org_security( .

obj_schema VARCHAR2 .

. obj_name VARCHAR2 .

) .

RETURN VARCHAR2 .

IS .

AOL suggested that all product-specific logic should be moved to .-.

Hence. the org_security logic is moved .-.product-specific packages.

-- to the new package MO_GLOBAL.

--

-- However, FND_CLIENT_INFO.org_security is referenced in many CRM

-- views. Removing it from this package is out of the question since

-- all CRM code would break.

--

-- So, only option is to keep it as a wrapper function for

-- MO_GLOBAL.org_security

l_sql_stmt VARCHAR2(1000);

l_predicate VARCHAR2(2000) := '';

.

BEGIN .

.

For backward compatible purpose .-.

org_security(:1. :2) from dual'.l_sql_stmt := 'select mo_global. EXECUTE IMMEDIATE l_sql_stmt INTO l_predicate USING .

.IN obj_schema.

IN obj_name. .

.

.RETURN l_predicate.

we could have avoided the dynamic SQL by simply .-.Alternatively.

-.returning MO_GLOBAL.org_security(obj_schema. obj_name) but we don't .

want this package to have dependencies on other packages during .-.

.compilation.-.

.

EXCEPTION .

. 'SQL_PLSQL_ERROR').set_name('FND'.WHEN OTHERS THEN fnd_message.

.fnd_message. to_char(sqlcode)).set_token('ERRNO'.

fnd_message.set_token('REASON'. .format_error_stack). dbms_utility.

set_token('ROUTINE'. 'ORG_SECURITY'). .fnd_message.

.app_exception.raise_exception.

END org_security. .

.end fnd_client_info.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->