Monday, June 17, 2013

Business Event: Creation And Subscription



A business event is an occurrence in an internet/intranet application or program that might be significant to other objects in a system or to external agents.

For instance, the creation of a purchase order is an example of a business event in a purchasing application.

Creating/Defining a Business event 

There must be a unique internal name for a business event.
The suggested format for these internal names is a compound structure of identifiers
separated by periods (.) as follows: (Which is case-sensitive.)

<company>.<family>.<product>.<component>.<object>.<event>

Example : oracle.apps.xxokl.am.test_busi_event

Steps to create a new Business Event:

Navigation à System Administrator à Workflow à Administrator Workflow à Business Event

            à Click on “Create Event”

à Fill all the required field (marked with *)

                Name     should be in the format specified above.
                Status     must be “Enabled”
                Owner Name    Enter program name here.(Any oracle module name)
                Owner Tag        Enter program id here (Oracle module short name)

à Click on “Apply”


à It will give the confirmation of successful event creation
 

Subscription of a Business event


An event subscription is a registration indicating that a particular event is significant to a
particular system and specifying the processing to perform when the triggering event
occurs.

Steps to Subscribe a Business Event:

Navigation à System Administrator à Workflow à Administrator Workflow à Business Event

à Search the business event create above (for which subscription has to be created)

                    à Click on “Subscription”


à Put the required fields in the next window.
Subscriber region,

System (Where the subscription executes) 

Click on the System field’s up arrow icon to display a list of systems from which to choose

 Triggering Event region,

Source Type  (To which the subscription applies) 
• Local - The subscription applies only to events raised on the subscribing system. 
• External - The subscription applies only to events received by an inbound agent on the subscribing system.  

• Error - The subscription applies to only to errored events dequeued from the WF_ERROR queue.

 Event Filter
Name of your business event.

Source Agent (optional -to which the subscription applies). 
The subscription is executed only when the triggering event is received from that agent.  


Note: In most cases, the Source Agent field is left blank.


Execution Condition region,

Phase Number 

It specify the order in which subscriptions that apply to the same event are executed 
Status
Select Enabled or Disabled.
Rule Data. 
• Key - The subscription requires only the event key. 
                                           • Message - The subscription requires the complete event data


Action Type Region

 Action Type

There are total 6 types of ‘Action Types’. Select anyone as your requirement put at least the required fields in ‘Action’ region of the selected ‘Action Type’.

List of the ‘Action Type’ and corresponding ‘Action’ is mentioned below. 
‘ * ‘ mark indicates the required field)



Action Type
Action
Additional Options
Priority (1 required 0 optional)
Custom




Java Rule Function

0

PL/SQL Rule Fuction

0

Workflow Type

0

Workflow Process

0

Out Agent

0

To Agent

0

*Priority

1
Launch Workflow




*Workflow Type

1

*Workflow Process

1

*Priority

1


Add Subscription Parameters




Launch when Parameters Match



Launch when Parameters Match

Receive Message from Trading Partner




*Priority

1
Send To Agent




Out Agent

0

To Agent

0

*Priority

1


Add Subscription Parameters



Launch When Parameters Match

Send Notification




*Message Type

1

*Message Name

1

*Recipient

1

Callback

0

Context

0

Comment

0

Due Date

0

*Priority

1
Send Message to Trading Partner




*Priority

1



















































Note :: All the required fields have LOV attached


 On Error 
     Stop and Rollback 
     Skip to Next  


Subscription Parameters Region 
You can enter any additional parameters for the rule function in the Parameters field. Specify the name and value for each parameter in the following format:



<name1>=<value1> <name2>=<value2> ... <nameN>=<valueN>

 Documentation Region
 Owner name
     Enter program name here.
Owner tag 
     Enter program ID here.
Customization Level 
    Customization level “User” is automatically set for subscriptions that you define. 
Description(optional)

      You can give the description about your subscription/event. 

Warning: Each subscription must have a unique combination of subscribing system,source type, triggering event, source agent, phase, owner name, and owner tag. If you are defining several subscriptions with similar properties, assign each    subscription a different phase number to differentiate it from the others. 


Following Subscription is an example with “Action Type-Custom”




à Click On “Next”



à Click On “Apply”


à It will give the confirmation message of successful subscription
 
Sample Subscribed Function:

function xx_test_event_func(
                          p_subscription_guid in raw
                         ,p_event in out nocopy wf_event_t)
return varchar2 is

   l_parmlist                wf_parameter_list_t;
   l_user_id                 number;
   l_resp_id                 number;
   l_application_id          number;

begin
   ---- get the parameter list for the event.
   l_parmlist := p_event.getparameterlist ();
   
   l_user_id := to_number (p_event.getvalueforparameter ('USER_ID'));
         
   l_resp_id := to_number (p_event.getvalueforparameter ('RESP_ID'));
         
   l_application_id := to_number (p_event.getvalueforparameter ('RESP_APPL_ID'));
       
   --<write your business logic>

    return 'SUCCESS';
exception
   when others then
      return 'FAILURE';
end xx_test_event_func;

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;