Pages

Saturday, June 3, 2017

Work Flow in Oracle Apps

Workflow Definition: 
Workflow is the series of activities that are necessary to complete a task.

Workflow Engine:
The Workflow Engine manages all automated aspects of a workflow process for each item

Workflow Components:

Attributes
Processes
Notifications
Messages
Functions
Events
LookupTypes

Attribute Types:

Text
Number
Date
Lookup
Form
URL
Document
Role
Attribute
Event

Create Process
wf_engine.createprocess(itemtype,itemkey,processname,uservalue,owner);

Start Process
wf_engine.startprocess(itemtype,itemkey);

Launch Process
wf_engine.launchprocess(itemtype,itemkey,processname,uservalue,owner);

Access Levels

Preserve Customisations
Lock at this Access Level

0-9 - Oracle Workflow
10-19 - AOL
20-99 - Oracle E-Business Suite
100 -999 Customisation
1000 - Public

#HIDE_REASSIGN
#FROM_ROLE
WF_NOTIFICATION(HISTORY)

Parameters for a PL/SQL :

When the Workflow Engine calls a stored procedure for a unction activity, it passes four parameters to the procedure and may expect a result when the procedure completes.

Itemtype (IN) : Internal name of the item
Itemkey (IN) : A string to uniquely identify the item type instance
Actid (IN) : ID of the activity from where this procedure is called.
Funcmode (IN) : Execution mode of the activity
Resultout (OUT) : Result Type of the activity

FUNCMODE : For functions, it can be RUN or CANCEL
For notifications, it can be RESPOND, FORWARD, TRANSFER or TIMEOUT

RESULTOUT : COMPLETE:: Activity successful.
WAITING : Pending for some other activity
DEFERRED: : Activity deferred till
NOTIFIED::: Activity notified to with a . Externally, must be completed using WF_ENGINE.CompleteActivity.
ERROR: :Activity encounters an error

PL/SQL Coding Standards

Procedure
( itemtype in varchar2,
itemkey in varchar2,
actid in number,
funcmode in varchar2,
resultout out varchar2 )
is
;
Begin
if ( funcmode = ’RUN’ ) then
resultout := ’COMPLETE:’;
return;
end if;
if ( funcmode = ’CANCEL’ ) then
resultout := ’COMPLETE’;
return;
end if;
if ( funcmode = ’RESPOND’ ) then
resultout := ’COMPLETE’;
return;
end if;
if ( funcmode = ’FORWARD’ ) then
resultout := ’COMPLETE’;
return;
end if;
if ( funcmode = ’TIMEOUT’ ) then
resultout := ’COMPLETE’;
return;
end if;
if ( funcmode = ’TRANSFER’ ) then
resultout := ’COMPLETE’;
return;
end if;
Exception
When others then
WF_CORE.CONTEXT (’’, ’’, , , to_char(),
);
raise;
End ;


Example for Custom Requisition WF :

PROCEDURE Req_App_Process(Requisitionid IN VARCHAR2,
RequisitionDesc IN VARCHAR2,
RequisitionAmount IN NUMBER,
RequestorUsername IN VARCHAR2,
ProcessOwner IN VARCHAR2,
Workflowprocess IN VARCHAR2 DEFAULT NULL,
item_type IN VARCHAR2 DEFAULT NULL ) IS

ItemType VARCHAR2(30) := NVL(item_type,’WFDEMO’);
ItemKey VARCHAR2(30) := RequisitionNumber;
ItemUserKey VARCHAR2(80) := RequisitionDesc;

BEGIN

— Start Process :
— If workflowprocess is passed, it will be run.
— If workflowprocess is NOT passed, the selector function
— defined in the item type will determine which process to run.

Wf_Engine.CreateProcess( ItemType => ItemType,
ItemKey => ItemKey,
process => WorkflowProcess );

Wf_Engine.SetItemUserKey (ItemType => ItemType,
ItemKey => ItemKey,
UserKey => ItemUserKey);

— Initialize workflow item attributes

Wf_Engine.SetItemAttrText (itemtype => itemtype,
itemkey => itemkey,
aname => ‘REQUISITION_NUMBER’,
avalue => RequisitionNumber);

Wf_Engine.SetItemAttrText (itemtype => itemtype,
itemkey => itemkey,
aname => ‘REQUISITION_DESCRIPTION’,
avalue => ItemUserKey);
Wf_Engine.SetItemAttrNumber( itemtype => itemtype,
itemkey => itemkey,
aname => ‘REQUISITION_AMOUNT’,
avalue => RequisitionAmount );

Wf_Engine.SetItemAttrText (itemtype => itemtype,
itemkey => itemkey,
aname => ‘REQUESTOR_USERNAME’,
avalue => RequestorUsername);
Wf_Engine.SetItemOwner ( itemtype => itemtype,
itemkey => itemkey,
owner => ProcessOwner );

Wf_Engine.StartProcess( itemtype => itemtype,
itemkey => itemkey );
EXCEPTION
WHEN OTHERS THEN

Wf_Core.context (‘WF_REQDEMO’,’StartProcess’,RequisitionNumber,RequisitionAmount,
RequestorUsername,ProcessOwner,Workflowprocess);
RAISE;

END Req_App_Process;

Adding Workflow From  Role

wf_engine.setitemattrtext (itemtype      => ‘TEST’,
                                  itemkey  => l_chr_key,
                                  Aname         => ‘#FROM_ROLE’,
                                  Avalue        => CBROWN
                                  );

No comments:

Post a Comment