Skip to content
Home / Apps / How to initialize session in Oracle Apps using FND_GLOBAL.APPS_INITIALIZE

How to initialize session in Oracle Apps using FND_GLOBAL.APPS_INITIALIZE

FND_GLOBAL.APPS_INITIALIZE is an API in Oracle Apps to initialize the session. This is required to set up global variables, profile values, and the global security context for a database session. In simple terms, when you want to call any Oracle Apps public API outside the EBS environment like SQL * Plus, Toad, or SQL Developer, use this API first to set the session, else the public API may not work or give appropriate results.

Syntax

FND_GLOBAL.APPS_INITIALIZE(user_id in number,
                          resp_id in number,
                          resp_appl_id in number);

Where,

    • user_id – The USER_ID number
    • resp_id – The ID number of the responsibility
    • resp_appl_id – The ID number of the application to which the responsibility belongs

All the parameters to this procedure are mandatory and you can fetch those using the below queries,

Query to get user_id from fnd_user table. Here, I am using the SYSADMIN user, but you should use your or the appropriate user name.

select fnd.user_id      
 from  fnd_user fnd 
 where  fnd.user_name = 'SYSADMIN'

Query to get resp_id (Responsibility ID) and resp_appl_id ( Responsibility application ID) from fnd_responsibility_vl. In this demo, we are using Inventory responsibility, but you should use respective responsibility as per your requirement.

select resp.responsibility_id, 
       resp.application_id 
from   fnd_responsibility_vl resp 
where  resp.responsibility_name = 'Inventory'

Now, we derived the required values of the parameter, you can use fnd_global.apps_initialize API as shown in the below example. Below anonyms block submits Concurrent Program from back-end using fnd_request API in SQL developer.

DECLARE
   l_request_id NUMBER;
BEGIN
   fnd_global.apps_initialize (user_id=>1121
                              ,resp_id=>20634
                              ,resp_appl_id=>401);

   l_request_id := fnd_request.submit_request ( application => 'INV'
                                              , program => 'CONC_DEMO'
                                              , description => 'Concurrent Program Demo'
                                              , start_time => sysdate
                                              , sub_request => FALSE
                                              , argument1 => 'fnd_request demo' );
   COMMIT;
   
   IF l_request_id = 0 THEN
      dbms_output.put_line('Request not submitted error '|| fnd_message.get);
   ELSE
      dbms_output.put_line('Request submitted successfully request id ' || l_request_id);
   END IF;
EXCEPTION
   WHEN OTHERS THEN
     dbms_output.put_line('Unexpected errro ' || SQLERRM);   
END;

 

This basically sets the profile values in the Oracle apps and you can see the who columns got -updated with the respective values in the fnd_concurrent_requests table. You can refer to another example where we have shown how to Email Oracle Concurrent Request Output using FND_REQUEST or FND_DELIVERY.

Reference and further reading