Wednesday, June 5, 2013

FND_REQUEST Functions

Some of the FND_REQUEST packaged Functions
----------------------------------------------------

Scheduling/Adding Layout/Delivery Options


declare
l_conc_id     number;
l_boolean     boolean;
e_add_del     exception;
e_add_layout  exception;
e_set_option  exception;
e_set_repeat  exception;
begin
   -- intialize the apps.
   fnd_global.apps_initialize (<user_id>,<resp_id>,<resp_app_id>);

   -- Adding delivery option to send the request output as email
   l_boolean := fnd_request.add_delivery_option
                   (type => 'E' -- this one to speciy the delivery option as email
                   ,p_argument1 => 'Delivery Option Test' -- subject for the mail
                   ,p_argument2 => 'xyz@ab.bc.uk' -- from address
                   ,p_argument3 => 'rty@ab.bc.uk' -- to address
                   ,p_argument4 => 'klm@ab.ac.uk' -- cc address to be specified here.
                   ,nls_language => ''); -- Optional

   /* -- Adding delivery option to FTP the request output
     l_boolean := fnd_request.add_delivery_option
                 (type => 'T' -- this one to specify the delivery option as FTP
               ,p_argument1 => 'uatdev.6auconsulting.com' – Server Name/IP address
               ,p_argument2 => 'oradev' – Unix Box User
               ,p_argument3 => 'oradevpass' -- Password
              ,p_argument4 => '/appl/UAT/apps/apps_st/comn/admin/XXAK/data/Test/' – Directory Path
              ,nls_language => ''); -- Optional  */


   -- Adding Template to the request
   if l_boolean then
      l_boolean := fnd_request.add_layout
                     (template_appl_name => 'XXAK'
                     ,template_code      => 'XX_TEST_FND_REQUEST'
                     ,template_language  => 'en' -- English
                     ,template_territory => null
                     ,output_format      => 'PDF'
                     );
   else
      raise e_add_del;                                              
   end if; 


   if l_boolean then
      l_boolean := fnd_request.set_options ('YES');
   else
      raise e_add_layout;
   end if;

   -- Scheduling the request
   if l_boolean then
      l_boolean :=fnd_request.set_repeat_options
                     (repeat_time     => null--to_char(sysdate,'hh24:mi:ss'),
                     ,repeat_interval => 2   --Applies only when releat_time is null
                     ,repeat_unit     => 'MINUTES'--Applies only when releat_time is null
                     ,repeat_type     => 'START' --Applies only when releat_time is null
                     --,repeat_end_time  =>
                     --,increment_dates  => 'Y'-- Increment the date parameters for next run
                     );
   else
      raise e_set_option;                                                
   end if;
                                                 

   if l_boolean then

      l_conc_id := fnd_request.submit_request
                      (application => 'XXAK'
                      ,program     => 'XX_TEST_FND_REQUEST'
                      ,start_time  => null
                      ,sub_request => null
                      ,argument1   => <argument1>
                      ,argument2   => <argument2>
                         );
   else
      raise e_set_repeat;                                             
   end if;
  
   if l_conc_id > 0 then
      dbms_output.put_line('Concurrent Program Id: '||l_conc_id);
   else
      dbms_output.put_line('Error: submit_request');
   end if;
   commit;
exception
   when e_add_del then
      dbms_output.put_line('Error: add_delivery_option');
   when e_add_layout then
      dbms_output.put_line('Error: add_layout');
   when e_set_option then
      dbms_output.put_line('Error: set_options');
   when e_set_repeat then
      dbms_output.put_line('Error: set_repeat_options'); 
   when others then
      dbms_output.put_line('Error: '||sqlerrm);      
end;

8 comments:

  1. if type of add_delivery_option is "ftp"
    what are the parameters required?

    ReplyDelete
    Replies
    1. Dear Anonymous,

      Please see below:

      -- Delivery options lookup
      select *
      from fnd_lookup_values
      where lookup_type = 'DELIVERY_OPTION_TYPE';


      -- Adding delivery option to FTP the request output
      l_boolean := fnd_request.add_delivery_option
      (type => 'T' -- this one to specify the delivery option as FTP
      ,p_argument1 => 'uatdev.6auconsulting.com' – Server Name/IP address
      ,p_argument2 => 'oradev' – Unix Box User
      ,p_argument3 => 'oradevpass' -- Password
      ,p_argument4 => '/appl/UAT/apps/apps_st/comn/admin/XXAK/data/Test/' – Directory Path
      ,nls_language => ''); -- Optional

      Delete
  2. How to send notifications to users???

    ReplyDelete
    Replies
    1. Hi Unaib,

      It depends what kind of notification you want to send. You can use workflow.

      Delete
    2. Thanks Abhay Kumar but it's solved using FND_REQUEST.ADD_NOTIFICATION(:USER_NAME);

      Delete
    3. As I said it depends on your requirement. Anyway good to know.

      Cheers!

      Delete
  3. Good example ! This solution works for me, but I want to know whether it is possible to have some description in the email body in addition to the text on Subject line (p_argument1)? and how ?

    ReplyDelete