Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 44

Approvals Management Engine

1. Create Table
XXWINFO_INVOICE_AME_HEADERS
XXWINFO_INVOICE_AME_LINES

2. AME SETUPS
1. Providing AME Application Access to USER
AME is Approval Management Engine. AME uses the Role Based Access Model (RBAC) to
provide users access to AME functions.

The User needs to have the following roles and responsibilities to access AME functions.

Roles:

1. Approvals Management Process Owner


2. Approvals Management System Viewer
3. Approvals Management Business Analyst
4. Approvals Management System Administrator
5. Approvals Management Administrator

Responsibilities:

1. Approvals Management Business Analyst


2. Approvals Management Administrator

AME setup and starting the configuration is a 2-step process:

i. Assign pre-defined roles to user


Assign the above-mentioned roles to the user by using User Management responsibility
Navigation: User Management -> Users

Search the user and click on update.


Click Assign Roles

Search with the string ‘Approval%’


Select all 5 roles and click on “Select”
Give the justification and click on “Apply”
ii. Grant data access to user
Grant Transaction Type access to the user using Functional Administrator responsibility.

Click on “Create Grant”

Provide Object as “AME Transaction Types” and click on “Next”

Provide “AME Calling Applications” as Set


Oafa Security
3. Create Transaction Type
Navigate to Approvals Management Administrator Responsibility

Click on Create Transaction Type


Provide details and click on Next

Provide the values for the mandatory attributes (seeded) and click on Next.
Review the details and click on Next.
4. Create Attributes
Navigate to Approvals Management Business Analyst
Select The transaction Type and click on Attributes

Click on Create
Create the attributes required
Invoice Amount

Invoice Type
Profit_loss_account(balance_sheet Y/N)

Create Conditions
Click on Conditions Tab

Click on Create
Create the required Conditions (need to create the conditions for attributes)

5. Create Approver Groups


Click on Approver Groups Tab and then click on create to

Provide the details and add the Group members.


6. Create Action Types
Click on Use Existing Action Type

Select required Action Type and click on continue and then click on Finish

7. Create Rules
Click on Rules Tab and click on create.
Provide the Details and click on Next

Click on Add condition.

Select required conditions and click on Continue

Click on Next

Click on Action Type.


Select the required Action Type and click on continue.
Select the action(approval group)

Click on Next.
Review the details and click on Finish.

2. Create Workflow
Create Item Type
Click File -> New

Save the work flow


Right click on the folder and click New Item Type
Provide internal name, display name, description and click on “OK”
Create Attributes
Approver Name
Invoice ID
Right click on Item Type and click on New Attribute.

Provide the details and click on “OK”


Navigator Control Properties X

Item Type AR |nvoico Draft


APR
lnlefnal Name

Bi‹play Name Approval Name


Desciiprm oName

Lwgth

Type

Value

OK Cancel

Navigator Control Properties X


AtnbuteAccess
Item Typg AR Invoice Dralt
Infeinal Name Display Na«›e
Descriph n |Invoice ID IN @tCEID

Typee Invoice ID

Length
Defau\
Type

Value

OK Cancel
Create Lookups, Lookup Codes
Right click on Lookup Types and click on NEW
, Oracle Workflow Builder 2.Fx3.0.1
' fii\e d’ft j’iew window }]efp

. Hdden ype
Provide the details and click on “OK”

Similarly right click on the lookup create and create lookup codes.
N av'ig ato r Ca ntroI Propertie s

Lookup Type Approve or Re ie ct Internal NameETEO


Display NameR e)eCt

Desc fiption Reiect

Navigator Control Properties

|nte‹naI M ame |FUMCTIDM_RESULT

Dismay Name |Function Result

OK Cancelt
Navigator Control Properties

Lookup Type Function Result


COMPLETED
|n*.etnaI Name Display same Description
Completed

completed

! LookupCoda

Lookup Type Function Result

|ntwnaI Name /PENDiNG

Pending

OF CBnceI Help
Create Message Type
Right click on Message and click on New Message

Then provide the details and click on “OK”


In result Tab attach the lookup.

Create Notification
Right click on Notification and click on New Notification.
Attach the lookup type and Message Type.

Create Process

Right click on Processes and click on New Process


Provide the Details and click on “OK”

(Process After completion)


Add the standard package from standard workflow provided by oracle.
Click on open

Click on browse
Select WFSTD Workflow
Click on open
Drag and drop Start and End Functions from the Standard Package.

Drag and drop the Notification that we have created.

Double click on the Notification Function and attach the attribute.


Click on New Funtion

Click on process window, Navigator Control Properties window will open.


Provide the Function/Procedure to be called as Function Name and attach the lookup
code to Result Type.

Similarly Create the another function.


Right click on the Start Function and drag to Notification

As we attached the Lookup type to the Notification, while dragging from Notification
Function we need to select the option.(Response from the notification)
Build the workflow according to the requirement.

Here CHECKLISTAPP Function is calling the procedure


(XX_WIN_PKG_BG_LOGIC_INVOKE. PR_APPROVED_WF_STATUS)
APPROVERREJECTED Function is calling the procedure (XX_WIN_PKG_BG_LOGIC_INVOKE.
PR_REJECTED_WF_STATUS)

========================================================================
create or replace PACKAGE XX_WIN_PKG_BG_LOGIC_INVOKE IS
PROCEDURE PR_APPROVED_WF_STATUS(
p_item_type in varchar2,
p_item_key in varchar2,
p_act_id in varchar2,
p_funcmode in varchar2,
RESULT OUT NOCOPY VARCHAR2);
PROCEDURE PR_REJECTED_WF_STATUS(
p_item_type in varchar2,
p_item_key in varchar2,
p_act_id in varchar2,
p_funcmode in varchar2,
RESULT OUT NOCOPY VARCHAR2);
END;

create or replace PACKAGE BODY XX_WIN_PKG_BG_LOGIC_INVOKE IS


PROCEDURE PR_APPROVED_WF_STATUS(
p_item_type in varchar2,
p_item_key in varchar2,
p_act_id in varchar2,
p_funcmode in varchar2,
RESULT OUT NOCOPY VARCHAR2) IS

p_invoice_id number;
p_user varchar2(200);
cursor app_list(p_invoice_id number) is select aprrover_id, invoice_id , status ,
no_of_approvers,
response_count, concatenated_app_list from (select aprrover_id, invoice_id , status ,
no_of_approvers,
response_count, concatenated_app_list from XX_WIN_APPROV_STATUS
where invoice_id = p_invoice_id and status = 'Pending' order by aprrover_id) where
rownum = 1;
c1 app_list%rowtype;
BEGIN
IF (p_funcmode <> 'RUN') THEN RETURN;
END IF;
select wf_engine.GetItemAttrText(itemtype => p_item_type,
itemkey => p_item_key,
aname => 'INVOICEID'
),
wf_engine.GetItemAttrText(itemtype => p_item_type,
itemkey => p_item_key,
aname => 'XXAPR'
)into p_invoice_id, p_user from dual;
--RESULT := 'COMPLETE';
update XX_WIN_APPROV_STATUS set status = 'Approved' where invoice_id = p_invoice_id
and concatenated_app_list = p_user;
open app_list(p_invoice_id);
fetch app_list into c1;
if app_list%notfound then
update XXWINFO_INVOICE_AME_HEADERS set approval_status = 'Approved' where
UNIT_INVOICE_HEADER_ID = p_invoice_id;
commit;
RESULT := 'COMPLETED';
else

wf_engine.SetItemAttrText (itemtype => p_item_type,

itemkey => p_item_key,

aname => 'XXAPR',

avalue => c1.concatenated_app_list);


RESULT := 'PENDING';
close app_list;
end if;
END PR_APPROVED_WF_STATUS;
PROCEDURE PR_REJECTED_WF_STATUS(
p_item_type in varchar2,
p_item_key in varchar2,
p_act_id in varchar2,
p_funcmode in varchar2,
RESULT OUT NOCOPY VARCHAR2) IS
p_invoice_id number;
p_user
varchar2(200); BEGIN
select wf_engine.GetItemAttrText(itemtype => p_item_type,
itemkey => p_item_key,
aname => 'INVOICEID'
),
wf_engine.GetItemAttrText(itemtype => p_item_type,
itemkey => p_item_key,
aname => 'XXAPR'
)into p_invoice_id, p_user from dual;
IF (p_funcmode <> 'RUN') THEN RETURN;
END IF;

update XX_WIN_APPROV_STATUS set status = 'Rejected' where invoice_id = p_invoice_id


and concatenated_app_list = p_user;

update XXWINFO_INVOICE_AME_HEADERS set approval_status = 'Rejected' where


UNIT_INVOICE_HEADER_ID = p_invoice_id;
commit;
RESULT := 'COMPLETE';
END PR_REJECTED_WF_STATUS;
END;
===========================================================================
===========================================================================
Trigger on XXWINFO_INVOICE_AME_HEADERS
===========================================================================

create or replace TRIGGER tr_call_workflow


FOR INSERT ON XXWINFO_INVOICE_AME_HEADERS
COMPOUND TRIGGER
TYPE r_inv_headers_type IS RECORD
( UNIT_INVOICE_HEADER_ID
XXWINFO_INVOICE_AME_HEADERS.UNIT_INVOICE_HEADER_ID%TYPE,
APPROVAL_STATUS
XXWINFO_INVOICE_AME_HEADERS.APPROVAL_STATUS%TYPE
);

TYPE t_inv_headers_type IS TABLE OF r_inv_headers_type


INDEX BY PLS_INTEGER;

t_HEADERS t_inv_headers_type;
L_Next_Approver Ame_Util.Approverrecord;
approversOut ame_util.approversTable;
p_user varchar2(200);
p_item_type varchar2(200) := 'XXARINV';
p_item_key number;
p_s varchar2(20);
AFTER EACH ROW IS

BEGIN
t_HEADERS (t_HEADERS.COUNT + 1).UNIT_INVOICE_HEADER_ID :=
:NEW.UNIT_INVOICE_HEADER_ID;
t_HEADERS (t_HEADERS.COUNT).APPROVAL_STATUS :=
:NEW.APPROVAL_STATUS;
END AFTER EACH ROW;
AFTER STATEMENT IS

BEGIN
FOR indx IN 1 .. t_HEADERS.COUNT
LOOP
select approval_seq.nextval into p_item_key from dual;
Ame_Api.Getallapprovers(222, t_HEADERS
(indx).UNIT_INVOICE_HEADER_ID
,
'CUSTOM_AR_INVOICE_AME',
approversOut );
pr_call_start_wf(p_item_type , p_item_key, t_HEADERS
(indx).UNIT_INVOICE_HEADER_ID, approversOut );
END LOOP;

END AFTER STATEMENT;


end;

===========================================================

CREATE OR REPLACE PROCEDURE pr_call_start_wf


( p_item_type VARCHAR2,
p_item_key VARCHAR2,
p_invoice_id NUMBER,
approversout ame_util.approverstable
) IS
p_user VARCHAR2(200);
PRAGMA autonomous_transaction;
BEGIN
wf_engine.createprocess(p_item_type, p_item_key, 'APPPROCESS');
wf_engine.setitemuserkey(itemtype => p_item_type, itemkey =>
p_item_key, userkey => 'USERKEY: ' || p_item_key);

FOR i IN approversout.first..approversout.last LOOP


SELECT
user_name
INTO p_user
FROM
fnd_user
WHERE
employee_id = approversout(i).person_id;

INSERT INTO xx_win_approv_status


( aprrover_id,
invoice_id,
status,
concatenated_app_list
) VALUES (
i,
p_invoice_id,
'Pending',
p_user
);

IF ( i = 1 ) THEN
wf_engine.setitemattrtext(itemtype => p_item_type, itemkey
=> p_item_key, aname => 'XXAPR', avalue => p_user);

wf_engine.setitemattrtext(itemtype => p_item_type, itemkey


=> p_item_key, aname => 'INVOICEID', avalue => p_invoice_id

);

END IF;

END LOOP;

wf_engine.setitemowner(itemtype => p_item_type, itemkey =>


p_item_key, owner => 'OPERATIONS');

wf_engine.startprocess(p_item_type, p_item_key);
dbms_output.put_line('Process started');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error in set owner process:' || sqlerrm);
END;

=======================================================

You might also like