Wednesday, June 19, 2013

Deployment of Business Event/Subscription

There are two ways to achieve this.

1> Using WFXLoad

Utility wmximport, a java class available in package oracle.apps.fnd.wf is used to download and
upload the business event/subscription.

Syntax:

adjava WFXLoad -d         --[to indicate download or upload :-u]
appsusername apps-password
Database Machine name
Database Port Number
Oracle Instance Name         --[from two task]
thin                                      --[for jdbc thin driver connectivity]
Language --[US in this case]
Event/Subscription File Name    --[into which event definition is downloaded or uploaded from]
EVENTS or SUBSCRIPTION
Name of the event

Machine name  --> fnd_profile.value('CSF_EMAP_DS_HOST')/'CSF: eLocation Map host name'
Port name     --> fnd_profile.value('CSF_MAP_DB_PORT')/'CSF: Database port to receive data'
Oracle Instance Name  --> Database name

OR

Open your Database Connection File(.dbc file), you can find it in $FND_SECURE directory

Machine name              --> HOST
Port name                    --> PORT
Oracle Instance Name  --> SID/SERVICE NAME

Example: Download

Event
adjava oracle.apps.fnd.wf.WFXLoad -d apps <<apps password>> <<HOST Name>>:<<PORT Number>>:<<SID>> thin US ./xx_test_event.wfx EVENTS oracle.apps.xxpo.test_busi_event;

Subscription
adjava oracle.apps.fnd.wf.WFXLoad -d apps <<apps password>> <<HOST Name>>:<<PORT Number>>:<<SID>> thin US ./xx_test_subscription.wfx SUBSCRIPTIONS oracle.apps.xxpo.test_busi_event;

Example: Upload

Event
adjava oracle.apps.fnd.wf.WFXLoad -u apps <<apps password>> <<HOST Name>>:<<PORT Number>>:<<SID>> thin US ./xx_test_event.wfx EVENTS oracle.apps.xxpo.test_busi_event;

Subscription
adjava oracle.apps.fnd.wf.WFXLoad -u apps <<apps password>> <<HOST Name>>:<<PORT Number>>:<<SID>> thin US ./xx_test_subscription.wfx SUBSCRIPTIONS oracle.apps.xxpo.test_busi_event;

Note: Please remove <<>>, also the drawback of this uploading script is that it can create a new business event/subscription but it can not upgrade the existing one.


2> Using wf_Events_pkg/wf_event_subscriptions_pkg packaged procedure
Download
declare
   cursor cur_event
   is
     select we.guid event_guid
           ,wes.guid subscription_guid
       from wf_events we
           ,wf_event_subscriptions wes
      where we.name = 'oracle.apps.xxpo.test_busi_event' --<<Business Event Name>>
        and wes.event_filter_guid = we.guid;  
   l_xml_data_e varchar2(32000); 
   l_xml_data_s varchar2(32000);      
begin
   for rec_event in cur_event
   loop
      -- Get XML data for Event Definition
      l_xml_data_e:=wf_Events_pkg.generate(rec_event.event_guid);
      dbms_output.put_line ('Event-xml data: '||l_xml_data_e);
      dbms_output.put_line (chr(10));
      -- Get XML data for Event Subscription Definition
      l_xml_data_s:=wf_event_subscriptions_pkg.generate(rec_event.subscription_guid);
      dbms_output.put_line ('Subscription-xml data: '||l_xml_data_s);
   end loop;
exception  
   when others then
      dbms_output.put_line('Error: '||sqlerrm);
end; 

Upload
declare
-- Event XML Data generated from wf_Events_pkg.generate
l_xml_data_e varchar2(32000) := '<WF_TABLE_DATA>
  <WF_EVENTS>
    <VERSION>1.0</VERSION>
    <GUID>#NEW</GUID>
    <NAME>oracle.apps.xxpo.test_busi_event</NAME>
    <TYPE>EVENT</TYPE>
    <STATUS>ENABLED</STATUS>
    <GENERATE_FUNCTION/>
    <OWNER_NAME>purchasing</OWNER_NAME>
    <OWNER_TAG>PO</OWNER_TAG>
    <CUSTOMIZATION_LEVEL>U</CUSTOMIZATION_LEVEL>
    <LICENSED_FLAG>Y</LICENSED_FLAG>
    <JAVA_GENERATE_FUNC/>
    <DISPLAY_NAME>oracle.apps.xxpo.test_busi_event</DISPLAY_NAME>
    <DESCRIPTION/>
    <IREP_ANNOTATION>
/*#
 *
 *
 * @rep:scope public
 * @rep:displayname oracle.apps.xxpo.requisition4
 * @rep:product PO
 * @rep:category BUSINESS_ENTITY
 */
</IREP_ANNOTATION>
  </WF_EVENTS>
</WF_TABLE_DATA>';

-- Event Subscription XML Data generated from wf_event_subscriptions_pkg.generate
l_xml_data_s varchar2(32000) := '<WF_TABLE_DATA>
  <WF_EVENT_SUBSCRIPTIONS>
    <VERSION>1.0</VERSION>
    <GUID>DF5A21A5FF09XXXX040C389B5973638</GUID>
    <SYSTEM_GUID>D470427B6B92D9FDXXXXB59767E7</SYSTEM_GUID>
    <SOURCE_TYPE>LOCAL</SOURCE_TYPE>
    <SOURCE_AGENT_GUID/>
    <EVENT_FILTER_GUID>oracle.apps.xxpo.test_busi_event</EVENT_FILTER_GUID>
    <PHASE>101</PHASE>
    <STATUS>ENABLED</STATUS>
    <RULE_DATA>KEY</RULE_DATA>
    <OUT_AGENT_GUID/>
    <TO_AGENT_GUID/>
    <PRIORITY>50</PRIORITY>
    <RULE_FUNCTION>xx_test_event_func</RULE_FUNCTION>
    <JAVA_RULE_FUNC/>
    <STANDARD_TYPE/>
    <STANDARD_CODE/>
    <ON_ERROR_CODE>ABORT</ON_ERROR_CODE>
    <ACTION_CODE>CUSTOM_RG</ACTION_CODE>
    <WF_PROCESS_TYPE/>
    <WF_PROCESS_NAME/>
    <PARAMETERS/>
    <OWNER_NAME>purchasing</OWNER_NAME>
    <OWNER_TAG>PO</OWNER_TAG>
    <CUSTOMIZATION_LEVEL>U</CUSTOMIZATION_LEVEL>
    <LICENSED_FLAG>Y</LICENSED_FLAG>
    <DESCRIPTION/>
    <EXPRESSION/>
  </WF_EVENT_SUBSCRIPTIONS>
</WF_TABLE_DATA>';

begin
   -- Create Event Definition
   wf_events_pkg.receive(l_xml_data_e);
   -- Create Event Subscription Definition
   wf_event_subscriptions_pkg.receive(l_xml_data_s);
   commit;
exception
   when others then
      dbms_output.put_line('Error: '||sqlerrm);
end;

Delete Business Event and Subscription

------------------------
declare
   cursor cur_event
   is
     select we.guid event_guid
           ,wes.guid subscription_guid
       from wf_events we
           ,wf_event_subscriptions wes
      where we.name = 'oracle.apps.xxpo.test_busi_event' --<<Business Event Name>>
        and wes.event_filter_guid = we.guid;  
begin
   for rec_event in cur_event
   loop
      wf_events_pkg.delete_row(rec_event.event_guid);
      wf_event_subscriptions_pkg.delete_row(rec_event.subscription_guid);
   end loop;
   commit;
exception  
   when others then
      dbms_output.put_line('Error: '||sqlerrm);
end;

Tuesday, June 18, 2013

Business Event - Possible Errors


1>> Check for possible errors
       
              a>. select notification_id
       from wf_notifications
     where subject like '%<business event name>%’;

b>. select wf_notification.getbody(<notification id of business event>)
      from dual;


2>> Check if Agent Listener is down

Navigation :: Workflow Administrator Web Applications > Oracle Applications Manager > Workflow Manager.

3>> Event Error Name: WFE_DISPATCH_RULE_ERR
     Event Error Message: 3825: Error '-4061 - ORA-04061: existing state of has been invalidated
 


Reason: When a package is compiled, all copies in the shared pool are flagged as invalid. The error is caused because the notification mailer is reading an old version of the package stored in memory 

Solution: 
1. Stop the Notification Mailer and Workflow Deferred Notification Agent Listener
2. Recompile the APPS schema through ADADMIN (You should have 'apps' and 'system' password)
3. Start the Notification Mailer and agent listener and re-test 


4>> Event Error Message: No Event Subscriptions exist for this Event 

Run below concurrent program
System Administrator > "Synchronize Product License and Workflow BES License" 

Raising Business Event With Workflow Process

Steps to Raise a Business Event with workflow process.
(The Examples shown below is just an example)



1>.Open the workflow builder.
 Create one attribute to hold the Business Event Key.

                    à Right click on “Attributes” node and select “New Attribute”

Put the value of the event key here or you have choice to give the same value at workflow run time



2>. Create one attribute to hold the Business Event Name.
                                    à Right click on “Attributes” node and select “New Attribute”

Put the value of the event name here or you have choice to give the same value at workflow run time


3>. Create one attribute to hold the Business Event Attribute.

        à Right click on “Attributes” node and select “New Attribute

Put the value of the event key here or you have choice to give the same value at workflow run time


4>. Create one simple Process (or you can add the business Event in the existing process itself).


 
5>. Create one Event.
        à Right click on the “Events” node and select “New Event”
                    Select “Event Action” – “Raise”


6>. Drag the event attribute (Event Attribute) to the event (Business Event Testing) created.




7>. Now drag the event created to the right hand side process window and link to the required nodes of the process (here event is linked with the “Start” and “End” node)

à Double click on the Event ( In the process window).
In the “Node Attributes” tab it will show the Event Attribute attached to the Event.



8>. Now in the “Event Details” tab select the appropriate item attributes for “Event Name” and “Event Key”. 


  9>. Save your workflow to the Database.



10>. Open application and search your workflow.

Navigation ::
System Administrator/Workflow Administrator Web Applications à Administrator Workflow à
 Developer Studio

à Search the workflow with Item type (Internal name)

à Click on “Run”



11>. Put the “Item key” and other workflow attributes value here if you have not attached to the workflow at the time of creation.

    à Click on “Submit”
  12>. It will show the business event raising confirmation window.



à In wf_deferred table there should one row for this business event. (If Phase value if more than 99- See Event Subscription)


SELECT * 
FROM wf_deferred 
WHERE CORRID LIKE '%<business event name>%';

Event Attribute and Event key values will be in the wf_deferred.user_data column.