Download - Workflow Simpl Example
-
7/31/2019 Workflow Simpl Example
1/44
-
7/31/2019 Workflow Simpl Example
2/44
Create PL/SQL Package
1)
Open WFSTD and save as new workflow:
Navigation: File >> Open
-
7/31/2019 Workflow Simpl Example
3/44
Click Browse then navigate to Workflow installation directory
Navigation: Workflow Installation Directory\ WF\DATA\US\WFSTD
Now Click File >Save as, Enter ErpSchools Demo and click OK
Right click on WFSTD and select New Item type
-
7/31/2019 Workflow Simpl Example
4/44
Enter the fields as below
Internal Name: ERP_DEMO
Display Name: ErpSchools Demo
Description: ErpSchools Demo
-
7/31/2019 Workflow Simpl Example
5/44
Now you will see ErpSchools Demo icon in the Navigator
-
7/31/2019 Workflow Simpl Example
6/44
Expand the node to see attributes, processes, notifications, functions, Events, Messages and
lookup types.
-
7/31/2019 Workflow Simpl Example
7/44
-
7/31/2019 Workflow Simpl Example
8/44
-
7/31/2019 Workflow Simpl Example
9/44
-
7/31/2019 Workflow Simpl Example
10/44
Double click ErpSchools Process Icon
-
7/31/2019 Workflow Simpl Example
11/44
2)Create Workflow Attributes:Navigation:
Window menu > Navigator
-
7/31/2019 Workflow Simpl Example
12/44
-
7/31/2019 Workflow Simpl Example
13/44
Enter the fields
Internal Name: ERP_ITEM_NUMBER
Display Name: Item Number
Description: Item Number
Type: Text
Default Value: Value Not Assigned
http://erpschools.com/Oracle_Applications_Workflow_Attributes.asphttp://erpschools.com/Oracle_Applications_Workflow_Attributes.asp -
7/31/2019 Workflow Simpl Example
14/44
-
7/31/2019 Workflow Simpl Example
15/44
Enter the attribute fields
Internal Name: ERP_SEND_ITEM_FORM_LINK
Display Name: Send Item Form Link
Description: Send Item Form Link
Type: Form
Value: INVIDITM
-
7/31/2019 Workflow Simpl Example
16/44
Click Apply and then OK
3)Create Workflow Function:Right click and then click on New Function
-
7/31/2019 Workflow Simpl Example
17/44
Properties window will open as shown below
-
7/31/2019 Workflow Simpl Example
18/44
Change/Enter the fields as below
Change Item Type to Standard from ErpSchools Demo
Select Internal Name as Start
Remaining fields will be populated automatically
-
7/31/2019 Workflow Simpl Example
19/44
Click Apply then OK
-
7/31/2019 Workflow Simpl Example
20/44
Again Right click onwhite space and click New Function
-
7/31/2019 Workflow Simpl Example
21/44
Change the properties as below
Item Type: Standard
Internal Name: END
-
7/31/2019 Workflow Simpl Example
22/44
Click Apply and then OK
-
7/31/2019 Workflow Simpl Example
23/44
Right click on white space and then click New Function
-
7/31/2019 Workflow Simpl Example
24/44
Enter the fields
Internal Name: ERP_GET_DETAILS
Display Name: Get New Inventory Item Details
Description: Get New Inventory Item Details
Function Name: erpschools_demo_pkg.get_item_details
-
7/31/2019 Workflow Simpl Example
25/44
-
7/31/2019 Workflow Simpl Example
26/44
4) Create Workflow Notifications:
Right click on white space and then click New Notification
-
7/31/2019 Workflow Simpl Example
27/44
Enter fields
Internal Name: ERP_SEND_ITEM_DET
Display Name: Send Item Detials
Description: Send Item Detials
Message: Sned Item Details Message
-
7/31/2019 Workflow Simpl Example
28/44
Click Apply and then OK
5)Create Workflow Messages:
Right click on Message and click New
http://click.adbrite.com/mb/click.php?sid=523742&banner_id=10873260&variation_id=1147525&uts=1244579774&cpc=302e30313935&keyword_id=121194&inline=y&ab=168296523&sscup=78847b5959ec11a6cac40593b9e333ad&sscra=627069e4616a22d0d326238f7f863cce&ub=1166791973&guid=493771bc-7bde-4afb-9aa5-9430ef7d5800&odc=svx&rs=&r=http://click.adbrite.com/mb/click.php?sid=523742&banner_id=10873260&variation_id=1147525&uts=1244579774&cpc=302e30313935&keyword_id=121194&inline=y&ab=168296523&sscup=78847b5959ec11a6cac40593b9e333ad&sscra=627069e4616a22d0d326238f7f863cce&ub=1166791973&guid=493771bc-7bde-4afb-9aa5-9430ef7d5800&odc=svx&rs=&r= -
7/31/2019 Workflow Simpl Example
29/44
Properties window will pop up as show below
-
7/31/2019 Workflow Simpl Example
30/44
Enter the fields
Internal Name: ERP_SEND_ITEM_DET_MSG
Display Name: Send Item Details Message
Description: Send Item Details Message
-
7/31/2019 Workflow Simpl Example
31/44
Go to Body Tab and enter as shown below
-
7/31/2019 Workflow Simpl Example
32/44
Click Apply and then OK
Navigation: Window Menu > Navigator
Select Item Form Link Attribute
-
7/31/2019 Workflow Simpl Example
33/44
Drag and drop both attributes to Send Item Details Message
6)
Create Roles:
Adhoc roles can be created through PL/SQL from database or they can be created
from Applications using User Management Responsibility. If you use PL/SQL to create roles make
sure you give all user names and role names in UPPER case to avoid some problems
Script to Create a Adhoc Role
Script to Add user to existing Adhoc Role
-
7/31/2019 Workflow Simpl Example
34/44
Script to Remove user from existing Adhoc Role
Using Adhoc roles in workflow notifications
Adhoc Roles Tables
Script to Create a Adhoc Role
DECLARE
lv_role varchar2(100) := ERPSCHOOLS_DEMO_ROLE;
lv_role_desc varchar2(100) := ERPSCHOOLS_DEMO_ROLE;
BEGIN
wf_directory.CreateAdHocRole(lv_role,
lv_role_desc,
NULL,
NULL,
Role Demo for erpschool users,
MAILHTML,
NAME1 NAME2, USER NAME SHOULD BE IN CAPS
NULL,
-
7/31/2019 Workflow Simpl Example
35/44
NULL,
ACTIVE,
NULL);
dbms_output.put_line(Created Role || ||lv_role);
End;
/
Script to Add user to already existing Adhoc Role
DECLARE
v_role_name varchar2(100);
v_user_name varchar2(100);
BEGIN
v_role_name := ERPSCHOOLS_DEMO_ROLE;
v_user_name := NAME3;
WF_DIRECTORY.AddUsersToAdHocRole(v_role_name, v_user_name);
USER NAMES SHOULD BE in CAPS
END;
-
7/31/2019 Workflow Simpl Example
36/44
Script to Remove user from existing Adhoc Role
DECLARE
v_role_name varchar2(100);
v_user_name varchar2(100);
BEGIN
v_role_name := ERPSCHOOLS_DEMO_ROLE;
v_user_name := NAME3;
WF_DIRECTORY.RemoveUsersFromAdHocRole(v_role_name, v_user_name);USER NAMES in
CAPS
END;
Using Adhoc roles in workflow notifications:
Navigation: File > Load Roles fromDatabase
Select roles you want to use and then click OK.
Open the notification properties and then navigate to node tab, selectperformeras the role you
just created and loaded from database.
Tables:
WF_ROLES
-
7/31/2019 Workflow Simpl Example
37/44
WF_USER_ROLES
WF_LOCAL_ROLES
WF_USER_ROLE_ASSIGNMENTS
7)Launching workflow from PL/SQL:First create a database trigger as below to call a PL/SQL procedure from which you kick off
the workflow.
Create Database Trigger
CREATE OR REPLACE TRIGGER ERP_SCHOOLS_DEMO_TRIGGER AFTER INSERT ON
INV.MTL_SYSTEM_ITEMS_B REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW
DECLARE
lv_id NUMBER := :NEW.inventory_item_id;
lv_item_segment1 VARCHAR2(100) := :NEW.segment1;
lv_itemtype VARCHAR2(80) := :NEW.item_type;
lv_user_id NUMBER := -1;
lv_itemkey VARCHAR2(10);
lv_orgid NUMBER :=2;
error_msg VARCHAR2(2000);
error_code NUMBER;
-
7/31/2019 Workflow Simpl Example
38/44
BEGIN
lv_user_id := fnd_global.user_id;
lv_orgid := fnd_global.org_id;
lv_itemkey := 1132; This should be unique value
ERP_DEMO.LAUNCH_WORKFLOW(ERP_DEMO
,lv_itemkey
,ERPSCHOOLS_PROCESSprocess name
,lv_id
,lv_orgid
,lv_item_segment1
);
EXCEPTION
WHEN OTHERS THEN
error_code := SQLCODE;
error_msg := SQLERRM(SQLCODE);
RAISE_APPLICATION_ERROR(-20150,error_msg);
-
7/31/2019 Workflow Simpl Example
39/44
END;
/
Create PL/SQL Package to kickoff workflow
CREATE OR REPLACE PACKAGE APPS.ERP_DEMO IS
PROCEDURE LAUNCH_WORKFLOW
(
itemtype IN VARCHAR2,
itemkey IN VARCHAR2,
process IN VARCHAR2,
item_id IN NUMBER,
org_id IN NUMBER,
item_segment1 IN VARCHAR2
);
END ERP_DEMO;
/
CREATE OR REPLACE PACKAGE BODY APPS.ERP_DEMO IS
-
7/31/2019 Workflow Simpl Example
40/44
PROCEDURE LAUNCH_WORKFLOW(
itemtype IN VARCHAR2,
itemkey IN VARCHAR2,
process IN VARCHAR2,
item_id IN NUMBER,
org_id IN NUMBER,
item_segment1 IN VARCHAR2
)
IS
v_master_form_link varchar2(5000);
v_item_number varchar2(100);
error_code varchar2(100);
error_msg varchar2(5000);
BEGIN
v_add_item_id := ITEM_ID= || item_id || ;
v_item_number := item_segment1;
-
7/31/2019 Workflow Simpl Example
41/44
v_master_form_link := v_master_form_link || v_add_item_id;
WF_ENGINE.Threshold := -1;
WF_ENGINE.CREATEPROCESS(itemtype, itemkey, process);
Get the value of attribute assigned in workflow
v_master_form_link := wf_engine.getitemattrtext(
itemtype => itemtype
,itemkey => itemkey
,aname => ERP_SEND_ITEM_FORM_LINK);
- assign values to variables so that you can usethe attributes
v_master_form_link varchar2(5000) := v_master_form_link||:#RESP_KEY=INVENTORY
#APP_SHORT_NAME=INV ORG_MODE=Y ;
v_master_form_link := v_master_form_link || v_add_item_id;
set the attribute values in workflow so that you can use them in notifications
WF_ENGINE.SetItemAttrText(itemtype, itemkey, MASTERFORM, v_master_form_link);
WF_ENGINE.SetItemAttrText(itemtype, itemkey, ERP_ITEM_NUMBER, item_segment1);
-
7/31/2019 Workflow Simpl Example
42/44
-
7/31/2019 Workflow Simpl Example
43/44
IS
v_GET_ITEM_NUMBER VARCHAR2(1000);
BEGIN
SELECT SEGMENT1 INTO V_GET_ITEM_NUMBER FROM MTL_SYSTEM_ITEMS_B WHERE
ROWNUM =1;
WF_ENGINE.SetItemAttrText(itemtype, itemkey,
ERP_ITEM_NUMBER,v_GET_ITEM_NUMBER );
you can use the get function as below.
v_GET_ITEM_NUMBER := wf_engine.getitemattrtext(
itemtype => itemtype
,itemkey => itemkey
,aname => X_ATTRIBUTE);
resultout:=COMPLETE:||Y';
exception when others then
dbms_output.put_line(Entered Exception);
-
7/31/2019 Workflow Simpl Example
44/44
fnd_file.put_line(fnd_file.log,Entered Exception);
END GET_ITEM_DETAILS;
END ERP_DEMO;