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;

No comments:

Post a Comment