You are on page 1of 13

Master/Detail Coordination

Activities
Overview

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 1 of 13 Rev Paradigm_revision
Master/Detail Coordination Activities
System References
None

Distribution
Job Title*

Ownership
The Job Title [list@YourCompany.com?Subject=EDUxxxxx] is responsible for ensuring that
this document is necessary and that it reflects actual practice.

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 2 of 13 Rev Paradigm_revision
Master/Detail Coordination Activities

Schedule: Timing Topic


30 minutes Lecture
0 minutes Practice
30 minutes Total

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 3 of 13 Rev Paradigm_revision
Objectives

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 4 of 13 Rev Paradigm_revision
Master/Detail Coordination Activities

Master/Detail Coordination Activities


When you spawn a detail process from a master process, you are creating a separate process
with its own unique item type and item key. You define the master/detail relationship between
the two processes by calling the Workflow Engine SetItemParent API after you call the
CreateProcess API and before you call the StartProcess API when you create the detail process.
Two activities are used to coordinate the flow in the master and detail processes. One activity
is placed in the master process, the other in the detail process. Each of the activities contains
two attributes used to identify the coordinating activity in the other process.
Wait for Flow Activity
Place this activity in a master or detail process to pause the flow until the other corresponding
detail or master process completes a specified activity. This activity calls the PL/SQL
procedure WF_STANDARD.WAITFORFLOW.
The Wait for Flow activity contains two attributes:
• Continuation Flow: Specify whether this activity is waiting for a corresponding ‘Master’ or
‘Detail’ process to complete.

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 5 of 13 Rev Paradigm_revision
• Continuation Activity: Specify the label of the activity node that must complete in the
corresponding process before the current process continues. The default value is
CONTINUEFLOW.
Continue Flow Activity
Use this activity to mark the position in the corresponding detail or master process where, upon
completion, the halted process is to continue. This activity calls the PL/SQL procedure
WF_STANDARD.CONTINUEFLOW.
The Continue Flow activity contains two attributes:
• Waiting Flow: Specify whether the halted process which is waiting for this activity to
complete is a ‘Master’ or ‘Detail’ flow.
• Waiting Activity: Specify the label of the activity node in the halted process that is waiting
for this activity to complete.
For more information, refer to the Predefined Workflow Activities chapter in the Oracle
Workflow Developer’s Guide.
Using Multiple Wait for Flow Activities
You can use multiple Wait for Flow activities in the same workflow process. For example, if a
master process launches two different sets of detail processes at different stages, the master
process should include a separate Wait for Flow activity node for each set of detail processes.
In this case, when you call the WF_ENGINE.SetItemParent API to associate a detail process
with the master process, you must specify the parent context as the activity label name for the
Wait for Flow activity node that corresponds to this detail process. (If the parent process
contains only one Wait for Flow activity, however, you can leave the parent context parameter
null.)
Example
The following code sample shows an example of launching a set of detail processes from a
master process. This API is the PL/SQL procedure for the Spawn Detail Processes function
activity in the Workflow Agent Ping/Acknowledge process. The procedure is named
WF_EVENT_PING_PKG.Launch_Processes.
procedure LAUNCH_PROCESSES (
ITEMTYPE in varchar2,
ITEMKEY in varchar2,
ACTID in number,
FUNCMODE in varchar2,
RESULTOUT out varchar2
) is
-----------------------------------------------------------
CURSOR c_external_in_agents IS
SELECT
wfa.name AGENT,
wfs.name SYSTEM
FROM
wf_systems wfs,

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 6 of 13 Rev Paradigm_revision
wf_agents wfa
WHERE
wfa.name != 'WF_ERROR‘
and wfa.status = 'ENABLED‘
and wfa.direction = 'IN‘
and wfa.system_guid = wfs.guid
and upper(wfa.queue_handler) = 'WF_EVENT_QH';

l_eventname varchar2(100);
l_eventkey varchar2(240);
l_itemkey varchar2(100);
l_event_t wf_event_t;
l_msg varchar2(32000);
l_clob clob;

begin

if (funcmode = 'RUN') then


l_eventname := wf_engine.GetActivityAttrText(
itemtype => itemtype,
itemkey => itemkey,
actid => actid,
aname => 'EVNTNAME');

for x in c_external_in_agents loop


--
-- For every agent launch detail process
--
l_eventkey := x.agent||'@'||x.system||'@'||itemkey;
l_itemkey := l_eventkey;

wf_engine.CreateProcess(
itemtype => itemtype,
itemkey => l_itemkey,
process => 'WFDTLPNG');

wf_engine.SetItemAttrText(
itemtype => itemtype,
itemkey => l_itemkey,

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 7 of 13 Rev Paradigm_revision
aname => 'EVNTNAME',
avalue => l_eventname);

wf_engine.SetItemAttrText(
itemtype => itemtype,
itemkey => l_itemkey,
aname => 'EVNTKEY',
avalue => l_eventkey);

wf_engine.SetItemAttrText(
itemtype => itemtype,
itemkey => l_itemkey,
aname => 'TOAGENT',
avalue => x.agent||'@'||x.system);

-- Initialize the wf_event_t


wf_event_t.initialize(l_event_t);
l_event_t.setcorrelationid(l_itemkey);
l_msg := '<PING>Test Ping</PING>';
dbms_lob.createtemporary(l_clob, FALSE, DBMS_LOB.CALL);
dbms_lob.write(l_clob, length(l_msg), 1 , l_msg);
l_event_t.SetEventData(l_clob);

wf_engine.SetItemAttrEvent(
itemtype => itemtype,
itemkey => l_itemkey,
name => 'EVNTMSG',
event => l_event_t);

wf_engine.SetItemParent(
itemtype => itemtype,
itemkey => l_itemkey,
parent_itemtype => itemtype,
parent_itemkey => itemkey,
parent_context => null);

wf_engine.StartProcess(
itemtype => itemtype,
itemkey => l_itemkey);

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 8 of 13 Rev Paradigm_revision
end loop;

resultout :=
wf_engine.eng_completed||':'||wf_engine.eng_null;

return;

elsif (funcmode = 'CANCEL') then

null;

end if;

exception
when others then
WF_CORE.CONTEXT('WF_EVENT_PING_PKG', 'LAUNCH_PROCESSES',
ITEMTYPE, ITEMKEY, to_char(ACTID), FUNCMODE);
raise;

end LAUNCH_PROCESSES;

For more information, refer to Workflow Agent Ping/Acknowledge in the Oracle Workflow
Developer’s Guide.

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 9 of 13 Rev Paradigm_revision
Master Process Example

Master Process Example


In the master process above, the Start Detail Flows activity initiates several detail processes.
The master process then completes Activity 1 before it pauses at the Wait for Flow activity.
The Wait for Flow activity is defined to wait for all its detail processes to complete a Continue
Flow activity before allowing the master process to transition to Activity 2.

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 10 of 13 Rev Paradigm_revision
Detail Process Example

Detail Process Example


When a detail process begins, it completes Activity A. When the process reaches the Continue
Flow activity, it signals to the Workflow Engine that the master process can now continue from
the Wait for Flow activity. The detail process itself then transitions to Activity B.

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 11 of 13 Rev Paradigm_revision
Continue Flow Processing

Continue Flow Processing


When a Continue Flow activity is executed, the WF_STANDARD.CONTINUEFLOW
procedure checks whether the corresponding Wait for Flow activity is associated with any
other processes that have not yet completed their Continue Flow activities. If so, the waiting
process continues to wait for those other processes. If the Wait for Flow activity is not waiting
for any other processes, then the WF_STANDARD.CONTINUEFLOW procedure completes
the Wait for Flow activity so that the process that was waiting now continues to the next
activity.
In the master and detail process example, when a detail process executes its Continue Flow
activity, it will check whether the Wait for Flow activity in the master process is still waiting
for any other detail processes. If all the other detail processes have already completed, then the
master process will proceed to Activity 2. If some of the other detail processes have not
completed yet, the master process will continue waiting until they do complete.
For more information, refer to the Predefined Workflow Activities chapter in the Oracle
Workflow Developer’s Guide.

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 12 of 13 Rev Paradigm_revision
Summary

Copyright © Oracle Corporation, 2004. All rights reserved.

Master/Detail Coordination Activities 517727197.doc


Effective Paradigm_effective Page 13 of 13 Rev Paradigm_revision

You might also like