Oracle Apps Basics – Session Context

Posted on April 30, 2009. Filed under: Oracle Applications - The Basics | Tags: , , , , , , , , , , , , , , , |

Download This Article From The Download Folder

This is one of several “Oracle Applications Basics” articles that are aimed at oracle applications program developers and cover a number of commonly used development elements when interacting with the E-Business Suite.

This article covers how to establish an Oracle Applications Context within your SQL session ( i.e. Toad/SQL Developer) when developing outside of the application or when a requirement exists to interact with Oracle Applications from an external source.

When logging into Oracle Applications a number of “Session” variables are assigned that are used during the time you spend logged on, these variables and application profile options are referred to collectively as the Apps Context. Some of these variables are used to restrict access to data through the use of secured views. You may find that certain views within Oracle Applications do not return data when you know that they should do, this is probably because you have not set your “Apps Context”.

A custom program being developed within the application should not need to establish its own context, that is established when the user logs in via the standard Apps login screen. You may find that certain products such as workflow will want you to establish a session manually within your code in certain scenarios, for details on this you will need to consult the product documentation however as a general rule you should not need to establish a context yourself if you are developing your code to run within Oracle Apps and you are doing so with the correct responsibilities and users with correct security access.

To set a global context session you can use the following code:

 

BEGIN
   fnd_global.apps_initialize
      (  user_id      => 0
      ,  resp_id      => 0
      ,  resp_appl_id => 0
      );
END;

 

The values for user_id, resp_id and resp_appl_id can be obtained by running the following query:

 

SELECT u.user_id user_id
,      r.responsibility_id resp_id
,      r.application_id resp_appl_id
,      r.responsibility_key resp_key
FROM   fnd_user u
,      fnd_user_resp_groups ur
,      fnd_responsibility r
WHERE  u.user_name = ‘<USER_NAME>’
AND    ur.responsibility_id = r.responsibility_id
AND    ur.user_id = u.user_id;

 

Substitute <USER_NAME> for the oracle applications user name for the account you wish to use. This query will then return a list of the assigned responsibilities for that user.

Once executed you will have established a context within your database session and will be able to see profile option values at user/responsibility/site level aswell as retrieve data from organisation secured views.

R12 Considerations

With the introduction of R12 Oracle introduced the concept of “Multi Organization Access Control” which allowed a user to operate across different organizations using a single responsibility. The introduction of this feature meant that the fnd_global.apps_initialize function was no longer sufficient to establish the context session and an additional API was introduced called MO_GLOBAL.

Within R12 after calling the apps_intialize API you must then call MO_GLOBAL.INIT(‘<PRODUCT_SHORT_NAME>’) where PRODUCT_SHORT_NAME is the product you are coding for i.e. ONT, PER, AMS etc…

To read more about Multi Organization Access Control and how it can impact your code see Meta Link note 420787.1 “White Paper: Oracle Applications Multiple Organizations Access Control for Custom Code”.

Download This Code From The Download Folder

Make a Comment

Leave a comment

2 Responses to “Oracle Apps Basics – Session Context”

RSS Feed for Oracle Apps Tech Blog Comments RSS Feed

[…] For more details regarding fnd_global.apps_initialise see my other blog entry “Oracle Apps Basics – Session Context” […]

[…] Download This Article From The Download Folder This is one of several “Oracle Applications Basics” articles that are aimed at oracle applications program developers and cover a number of commonly used development elements when interacting with the E-Business Suite. This article covers how to establish an Oracle Applications Context within your SQL session ( i.e. Toad/SQL Developer) when developing outside of the application or when a requirement … Read More […]


Where's The Comment Form?

  • April 2009
    M T W T F S S
     12345
    6789101112
    13141516171819
    20212223242526
    27282930  

Liked it here?
Why not try sites on the blogroll...