Oracle Workflow Guide
Release 2.6.2

Part Number A95265-03
  Go to previous page Go to next page       Go To Table Of Contents Go To Index Go To Table Of Contents

                     Contents  Index  Glossary Master Index Feedback
 

Example: Verify Authority

The Verify Authority function activity calls a PL/SQL stored procedure named WF_REQDEMO.VerifyAuthority

to verify whether the requisition amount is within the approver's spending limit. This activity is also another example of an automated function activity that returns a result based on a business rule that you implement as a stored procedure.

Result Type
This activity expects a result of 'Yes' or 'No' when the procedure completes to indicate whether the approver has the authority to approve the requisition. These result values are defined in the lookup type called Yes/No, associated with the Standard item type.

PL/SQL Stored Procedure
The PL/SQL stored procedure that this function activity calls is described in detail below. Each section in the procedure is numbered with the notation 1-> for easy referencing. We also use the convention 'l_' to identify local arguments used within the procedure.

 procedure VerifyAuthority (itemtype in varchar2,
itemkey in varchar2,
actid in number,
funcmode in varchar2,
resultout out varchar2) is
1-> l_forward_to_username varchar2(30);
l_requisition_amount number;
l_spending_limit number;
2-> begin
if (funcmode = 'RUN') then
l_requisition_amount := wf_engine.GetItemAttrNumber (
itemtype => itemtype,
itemkey => itemkey,
aname => 'REQUISITION_AMOUNT');
3-> l_forward_to_username := wf_engine.GetItemAttrText (
itemtype => itemtype,
itemkey => itemkey,
aname => 'FORWARD_TO_USERNAME');
4-> if (wf_reqdemo.checkSpendingLimit(l_forward_to_username,
l_requisition_amount)) then
resultout :='COMPLETE:Y';
else
resultout :='COMPLETE:N';
end if;
end if;
5-> if (funcmode = 'CANCEL') then
resultout :='COMPLETE:';
return;
end if;
6-> if (funcmode = 'TIMEOUT') then
resultout :='COMPLETE:';
return;
end if;
7-> exception
when others then
wf_core.context('WF_REQDEMO', 'VerifyAuthority', itemtype,
itemkey, actid, funcmode);
raise;
8-> end VerifyAuthority;

1-> The local arguments l_forward_to_username, l_requisition_amount, and l_spending_limit are declared in this section.

2-> If the value of funcmode is equal to RUN, then assign l_requisition_amount to the value of the REQUISITION_AMOUNT item type attribute, determined by calling the Workflow Engine API GetItemAttrNumber. See: GetItemAttribute.

3-> This section assigns l_forward_to_username to the value of the FORWARD_TO_USERNAME item type attribute, determined by calling the Workflow Engine API GetItemAttrText.

4-> This section calls the function CheckSpendingLimit for the current approver to determine whether the requisition amount is less than or equal to the approver's spending limit. If the requisition amount is less than or equal to the value in l_spending_limit, meaning the approver has authority to approve, then assign resultout to be COMPLETE:Y. Otherwise, assign resultout to be COMPLETE:N.

5-> If the value of funcmode is CANCEL, then assign resultout to be COMPLETE:.

6-> If the value of funcmode is TIMEOUT, then assign resultout to be COMPLETE:.

7-> This section calls WF_CORE.CONTEXT if an exception occurs.

8-> The VerifyAuthority procedure ends.

 
         Previous  Next          Contents  Index  Glossary


Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.