Sunteți pe pagina 1din 85

Oracle

Workflow Builder by Dinesh Kumar S

Oracle Workflow Builder by Dinesh Kumar S

About Oracle Workflow:



Why Workflow?
It automates & streamlines business process.


What Workflow does?
It routs information to Roles (User/Group of Users) based on rules.

Rule 1
Rule 2
Routing
Information


Key:

Rules
Process
Activity




Rule 3
Rule 4

Procedures.
Routes.
Actions Performed.

Oracle Workflow Builder by Dinesh Kumar S

Workflow Major Components



WF Builder
WF Engine
WF Definition Loader
Notification Systems
WF Monitor



WF Builder:



WF Engine:

Graphical Interface.
Used to Modify & create business process.
2 Windows available [navigator, process Diagram].

It is embedded in oracle DB.


Monitors the WF status and co-ordinates the routing of activities.

WF Definition Loader:

- The utility program that moves WF definitions b/w DB and corresponding flat file representation.
- Its a standalone server program.
- Integrated into WF builder.



Oracle Workflow Builder by Dinesh Kumar S



WF Notification System:

- Automatically Notify users.
- Send Notification to individuals or roles.
- Automatic Notification forwarding.

Oracle Workflow Builder by Dinesh Kumar S


-

Notification Activity encounters.

When WF encounters notification activity, it calls notification system API to send a notification.

Notification system communicates with directory services to get roles and user information to
whom the Notification to be sent.

Notification system communicates with mailer and web agent to get the following data.
Messages & message Attributes.
Notification preference for the role.

Notification system communicates with Notification viewer to display messages through web
Browser.



WF Monitor:

- Graphically monitors & administrate workflow transactions.
- It supports the below features.
Java Applet: To view WF Activity diagrammatically.
View Transaction action history.
Retry / Skip Activity.
Resend & rerun any process.
- Action Summary of Key Activities.



Oracle Workflow Builder by Dinesh Kumar S

Workflow Data Model:





Objects
Item Type
Attribute

Process

Function
Event
Notification

Message
Lookup Types

Transactions

Description
Classification of components that makes Workflow process.
An item type attribute is a property associated with a given item
type.
A Global variable that can be used across by any activity inside
WF.
Manages Business Process according to the business process
rules defined.
It derives relationship b/w the activities.
An automated unit of work usually defined as a PLSQL stored
procedures & functions.
An event activity represents a business event from the Business
Event System within a workflow process.
When the workflow engine reaches a notification activity, it
issues a Send ( ) API call to the Notification System to send the
message to an assigned performer.
A message is what a notification activity sends to a role in a
workflow process.
A lookup type is a static list of values. These lists can be
referenced by activities and by item type, message or activity
attributes.
The relationship b/w two activities represented by an arrow
[transition].

Master Table Details:

Oracle Workflow Builder by Dinesh Kumar S

Workflow Master Tables


Table Name
WF_ITEM_TYPES

Description
The details of internal names of item types will be stored.

WF_ITEM_TYPES_TL

Translation table for WF_ITEM_TYPES

WF_ITEM_ATTRIBUTES

The details of Item attribute.

WF_ACTIVITIES

The details of activities involved in business process.

WF_ACTIVITY_ATTRIBUTES

The details of attributes associated with activities.

WF_ACTIVITY_TRANSITIONS

The transition details b/w the activities of the process

WF_PROCESS_ACTIVITIES

All details of process includes Activity, sub-processes etc.

WF_MESSAGES

The message definition details.

WF_MESSAGE_ATTRIBUTES
WF_LOOKUP_TYPES
WF_LOOKUPS
WF_NOTIFICATIONS
WF_NOTIFICATION_ATTRIBUTES
WF_ITEMS
WF_ITEM_ACTIVITY_STATUSES
WF_ITEM_ATTRIBUTE_VALUES

The details about Attributes associated with Messages.


The details of Lookup Type definitions.
Details of lookup Codes created for lookup types.
Notification details defined inside item type.
Details of attributes associated with notification.
Information of all the workflow process & its history.
Activity status of all activity for different item type instance.
The values of all the attributes associated with the item type at
the particular instance.
The values of activity attributes for all the activities for different
instances of the workflow items.
The routing rules defined by user like forward, re-assign, reject
etc.

WF_ACTIVITY_ATTR_VALUES
WF_ROUTING_RULES

Types of Workflow Process:

Oracle Workflow Builder by Dinesh Kumar S


Synchronous

Asynchronous

A synchronous process is a process that can be executed without interruption from start
to finish. The Workflow Engine executes a process synchronously when the process
includes activities that can be completed immediately, such as function activities that are
not deferred to the background engine.
The Workflow Engine does not return control to the calling application that initiated the
workflow until it completes the process.
With a synchronous process, you can immediately check for process results that were
written to item attributes or directly to the database. However, the user must wait for
the process to complete.
An asynchronous process is a process that the Workflow Engine cannot complete
immediately because it contains activities that interrupt the flow.
Examples of activities that force an asynchronous process include deferred activities,
notifications with responses, blocking activities, and wait activities.
Rather than waiting indefinitely when it encounters one of these activities, the Workflow
Engine sets the audit tables appropriately and returns control to the calling application.
The workflow process is left in an unfinished state until it is started again. The process
can be restarted by the Notification System, such as when a user responds to a
notification; by the background engine, such as when a deferred activity is executed; or
by the Business Event System, such as when an event message is de-queued from an
inbound queue and sent to the workflow process. With an asynchronous process, the
user does not have to wait for the process to complete to continue using the application.
However, the results of the process are not available until the process is completed at a
later time.


Activity Cost:

Each function activity and event activity has a cost associated with it. The cost is a value representing the number of
seconds it takes for the Workflow Engine to execute the activity.
If you do not know how long it takes for the Workflow Engine to perform the activity, you can enter an estimated
cost and update it later as you accumulate more information about its performance. Generally, you should assign
complex, long running activities a high cost.


The valid range for cost is 0 to 1,000,000.

Note** although the cost is entered and displayed in seconds in Oracle Workflow Builder, it is actually converted
and stored in the database as hundredths of a second.

In normal processing, the Workflow Engine completes the execution of a single activity before continuing to a
subsequent activity.
In some cases, an activity might take so long to process that background processing would be more appropriate.


The default threshold for the Workflow Engine is 50 hundredths of a second. Activities with a cost higher than
this are deferred to background engines.

Deferred Processing:

Oracle Workflow Builder by Dinesh Kumar S

The engine has a deferred processing feature that allows long-running tasks to be handled by background engines
instead of in real time. Deferring the execution of activity functions to background engines allows the Workflow
Engine to move forward to process other activities that are currently active.
The engine can be set up to operate anywhere on a continuum between processing all eligible work immediately, to
processing nothing and marking all transitions as deferred.
Each activity has a user-defined processing cost. You can set this cost to be small if the activity merely sets an item
attribute, or you may set it to be very high if the activity performs a resource-intensive operation. If the result of a
completed activity triggers the execution of a costly function, you might want to defer the execution of that costly
function to a background engine.
The Workflow Engine integrates with Oracle Advanced Queues to carry out deferred processing. If a function
activity has a cost that exceeds the main threshold cost, the Workflow Engine marks that activity with a status of
'DEFERRED' in the workflow status tables and en-queues the deferred activity to a special queue for deferred
activities. A special queue processor called the background engine checks and processes the activities in the
'deferred' queue. The order in which the deferred activities are processed are based on the first in, first out
ordering of an activity's en-queue time.



Deferred Activity:

When an activity is deferred, the main Workflow Engine can then continue to the next available activity, which
may occur on some other parallel branch of the process. If no other activity is available to be executed, the
Workflow Engine returns control immediately to the calling application. The user remains unaware that
processing is still taking place, rendering a faster execution time.

To defer an activity,

Activity Cost > Threshold Cost

The threshold cost is a PL/SQL package variable with a default value of 50 hundredths of a second. Set a cost
above this threshold for all activities that you don't want the user to wait for.

At runtime, the Workflow Engine defers any thread to the background as soon as it encounters an activity with a
cost higher than the threshold. Then the background engine later identifies the process as deferred and
continues its execution.

Workflow Access Protection:


Oracle Workflow Builder by Dinesh Kumar S

Access protection is a feature that prevents workflow seed data created by a 'seed data provider' from being
modified by a 'seed data consumer'.


'seed data provider' --> any organization that creates 'seed data' for other organizations ('seed data consumers')
to use in defining and customizing a workflow process.

Workflow objects definitions that can be customized.


Workflow object definitions protected against customization.


Scenario:

There are 2 teams in my organization Global Team & Regional Team. Global Team does development across all
regions where as regional team does development within their own region and not shared by other.
Consider my organization Global team using oracle std. item type in my workflow in a custom workflow process.

Now my organization wants to enable below protections,
Identify certain workflow objects in its custom workflow definition as corporate standards that the regional
teams should adhere to and not modify.

Designate certain objects in its deployed process as customizable for the regional offices to alter to their offices'
needs.

Oracle Workflow Builder by Dinesh Kumar S

How this can be achieved?


By using Access Protection Feature in Oracle Workflow.


Access Protection Features:

1. Access Level
2. Customization Level
3. Protection Level

The combination of protection, customization, and access levels make up the access protection feature and
determines whether a user can modify a given workflow object.
The level, in all three cases, is a numeric value ranging from 0 to 1000 that indicates the relationship between
different organizations as providers and consumers of seed data.


The following ranges of levels are presumed by Oracle Workflow:

0-9
10-19
20-99
100-999

Oracle Workflow
Oracle Application Object Library
Oracle Applications development
Customer organization. You can determine how you want this range to be interpreted. For example, 100 can
represent headquarters, while 101 can represent a regional office, and so on.
Public

1000


Access Level:

A "user of Oracle Workflow" in this case, represents someone who is operating Oracle Workflow Builder, or the
Workflow Definitions Loader program, which loads workflow process definitions from a file into a database. As a
seed data provider, you should always operate Oracle Workflow Builder at the same consistent access level
because the level you work at affects the protection level of the seed data you create.
You can view your access level as follows:

In Oracle Workflow Builder, select About Workflow from the Help menu.

If you are going to run the Workflow Definitions Loader program to download workflow process
definitions from the database to a file, check the value for the environment variable
WF_ACCESS_LEVEL on your workflow server.

Oracle Workflow Builder by Dinesh Kumar S

Protection Level:

Whenever you create a workflow object in Oracle Workflow Builder, you have the option of protecting the object
at a certain level. An object's protection level helps control whether other users can modify the object based on
their access levels, by allowing only users with an access level equal to or lower than the object's protection level
to modify the object.

The protection level that you set for an object is dependent on the setting of the Lock at this Access Level check
box and on your current access level.

If you check the Lock at this Access Level check box, the protection level for the object is set to your current access
level. Users with an access level higher than your current access level will not be able to modify the object. These
users will see a small lock on the workflow object's icon, indicating that the object can be used but not modified.
For users with an access level equal to or lower than your current access level, the customization level for the
object will determine whether they can modify the object.
If you do not check the Lock at this Access Level check box, the protection level for the object is set to 1000. In this
case all users who are not restricted by the customization level can modify the object.



Customization Level:

Every workflow object, in addition to having a protection level, also records a customization level when you modify
the object and save it to a database or file. An object's customization level helps control whether other users can
modify the object based on their access levels, by allowing only users with an access level equal to or higher than
the object's customization level to modify the object.

Setting the customization level ensures that a customizable object that has been customized never gets overwritten
during a seed data upgrade, because the upgrade always occurs with the Workflow Definitions Loader operating at
an access level below the customized object's customization level.

Oracle Workflow Builder by Dinesh Kumar S

Workflow Definition Loader (WFLOAD):


We use the Workflow Definitions Loader to save or load process definitions from a database or flat file. We can
also define as it is a utility that moves workflow data between a file and a database and it is also used to upgrade,
upload and download the workflow data.
Usage:

Normally when we upgrade our database, we use the Workflow Definitions Loader to preserve and back up our
process definitions to a flat file. When the database upgrade is completed, we use the Loader program again to
upload the definitions back into your database.
We can also use the Loader program to upgrade our database with a newer version of a process definition or to
transfer process definitions to other databases.

Modes:
The Workflow Definitions Loader automatically validates the process definition to ensure that it conforms to
specific process design rules. There are four modes available with WFLOAD.These are as follows:
1)
2)
3)
4)

DOWNLOAD - Download the WF definitions into Flat file.


UPGRADE Honors both protection and customization levels of data
UPLOAD Honors only protection level of data [No respect of Customization Level]
FORCE Force upload regardless of protection or customization level


WFLOAD Username/password <access_level> Y <Mode> <File_name>.wft <Item_Type>

For Example,

WFLOAD apps/apps 0 Y DOWNLOAD poxwfrqa.wft POAPWF

Workflow APIs:

Oracle Workflow Builder by Dinesh Kumar S

Below are some important APIs frequently used in workflow development / customizations.
WF_ENGINE APIs
WF_ENGINE. CreateProcess

WF_ENGINE. SetItemUserKey

WF_ENGINE. GetItemUserKey

WF_ENGINE. SetItemOwner

WF_ENGINE. StartProcess

WF_ENGINE. LaunchProcess

WF_ENGINE. SuspendProcess

WF_ENGINE. AbortProcess

WF_ENGINE. AddItemAttr

CreateProcess (itemtype in varchar2,itemkey in varchar2,process in varchar2


default );
Creates a new runtime process for an application item. For example, a
Requisition item type may havea Requisition Approval Process as a top level
process. When a particular requisition is created, an application calls
CreateProcess to set up the information needed to start the defined process.
SetItemUserKey (itemtype in varchar2,itemkey in varchar2, userkey in
varchar2);
Lets you set a userfriendly identifier for an item in a process, which is initially
identified by an item type and item key. The user key is intended to be a user
friendly identifier to locate items in the Workflow Monitor and other user
interface components of Oracle Workflow.
GetItemUserKey (itemtype in varchar2,itemkey in varchar2) return varchar2;
Returns the userfriendly key assigned to an item in a process, identified by an
item type and item key. The user key is a userfriendly identifier to locate
items in the Workflow Monitor and other user interface components of Oracle
Workflow.
SetItemOwner (itemtype in varchar2,itemkey in varchar2,owner in varchar2);
A procedure to set the owner of existing items. The owner must be a valid role.
Typically, the role that initiates a transaction is assigned as the process owner,
so that any participant in that role can find and view the status of that process
instance in the Workflow Monitor.
StartProcess (itemtype in varchar2,itemkey in varchar2);
Begins execution of the specified process. The engine locates the activity
marked as START and then executes it. CreateProcess( ) must first be called to
define the itemtype and itemkey before calling StartProcess( ).
LaunchProcess (itemtype in varchar2,itemkey in varchar2,process in varchar2
default'',userkey in varchar2 default '',owner in varchar2 default '');
Launches a specified process by creating the new runtime process and
beginning its execution. This is a wrapper that combines CreateProcess and
StartProcess.
SuspendProcess (itemtype in varchar2,itemkey in varchar2,process in
varchar2 default '');
Suspends process execution so that no new transitions occur. Outstanding
notifications can complete by calling CompleteActivity( ), but the workflow
does not transition to the next activity. Restart suspended processes by calling
ResumeProcess( ). ResumeProcess(itemtype in varchar2,itemkey in
varchar2,process in varchar2 default ''); Returns a suspended process to
normal execution status. Any activities that were transitioned to while the
process was suspended are now executed.
AbortProcess (itemtype in varchar2,itemkey in varchar2,process in varchar2
default '',result in varchar2 default eng_force);
Aborts process execution and cancels outstanding notifications. The process
status is considered COMPLETE, with a result specified by the result argument.
Also, any outstanding notifications or subprocesses are set to a status of
COMPLETE with a result of force, regardless of the result argument.
AddItemAttr (itemtype in varchar2,itemkey in varchar2,aname in varchar2);
Adds an empty item type attribute variable to the process. Although most item

Oracle Workflow Builder by Dinesh Kumar S


type attributes are defined at design time, developers can create new
attributes at runtime for a specific process.
WF_ENGINE. SetItemAttrText
SetItemAttrText(itemtype in varchar2,itemkey in varchar2,aname in
varchar2,avalue in varchar2);
WF_ENGINE. SetItemAttrNumber
SetItemAttrNumber(itemtype in varchar2,itemkey in varchar2,aname in
varchar2,avalue in number);
WF_ENGINE. SetItemAttrDate
SetItemAttrDate (itemtype in varchar2,itemkey in varchar2,aname in
varchar2,avalue in date);
WF_ENGINE. GetItemAttrText
GetItemAttrText(itemtype in varchar2,itemkey in varchar2,aname in varchar2)
return varchar2;
WF_ENGINE. GetItemAttrNumber
GetItemAttrNumber(itemtype in varchar2,itemkey in varchar2,aname in
varchar2) return number;
WF_ENGINE. GetItemAttrDate
GetItemAttrDate(itemtype in varchar2,itemkey in varchar2,aname in varchar2)
return date;
WF_ENGINE. BeginActivity
BeginActivity (itemtype in varchar2,itemkey in varchar2,activity in varchar2);
Determines if the specified activity can currently be performed on the process
item and raises an exception if it cannot. The CompleteActivity() procedure
automatically performs this function as part of its validation. However, you can
use BeginActivity to verify that the activity you intend to perform is currently
allowed before actually calling it.
WF_ENGINE. CompleteActivity
CompleteActivity(itemtype in varchar2,itemkey in varchar2,activity in
varchar2,result_code in varchar2);
Notifies the workflow engine that the specified activity has been completed for
a particular item.
WF_ENGINE. ItemStatus
ItemStatus(itemtype in varchar2,itemkey in varchar2,status out
varchar2,result out varchar2);
Returns the status and result for the root process of the specified item
instance. Possible values returned for the status are: ACTIVE, COMPLETE,
ERROR, or SUSPENDED. If the root process does not exist, then the item key
does not exist and will thus cause the procedure to raise an exception.
Workflow core APIs: PL/SQL procedures called by function activities can use a set of core Oracle Workflow APIs to raise
and catch errors. When a PL/SQL procedure called by a function activity either raises an unhandled exception, or returns
a result beginning with 'ERROR:', the Workflow Engine sets the function activity's status to ERROR and sets the columns
ERROR_NAME, ERROR_MESSAGE, and ERROR_STACK in the table WF_ITEM_ACTIVITY_STATUSES to reflect the error.
WF_CORE. CLEAR
CLEAR Clears the error buffers.
WF_CORE. GET_ERROR
GET_ERROR(err_name out varchar2,err_message out varchar2 err_stack out
varchar2);
Returns the name of a current error message and the token substituted error
message. Also clears the error stack. Returns null if there is no current error.
WF_CORE. RAISE
RAISE (name in varchar2);
Raises an exception to the caller by supplying a correct error number and
token substituted message for the name of the error message provided.
Workflow Directory Service APIs:
WF_DIRECTORY. GetRoleUsers
GetRoleUsers(role in varchar2,users out UserTable);
Returns a table of users for a given role.
WF_DIRECTORY. GetUserRoles
GetUserRoles(user in varchar2,roles out RoleTable);
Returns a table of roles that a given user is assigned to.
WF_DIRECTORY. GetRoleInfo
GetRoleInfo(Role in varchar2,Display_Name out varchar2,Email_Address out
varchar2,Notification_Preference out varchar2,Language out
varchar2,Territory out varchar2);

Returns the following information about a role:

Oracle Workflow Builder by Dinesh Kumar S


Display name
Email address
Notification Preference ('QUERY', 'MAILTEXT', 'MAILHTML','MAILATTH',
'SUMMARY')
Language
Territory
IsPerformer (user in varchar2,role in varchar2);
Returns true or false to identify whether a user is a performer of a role.
GetRoleName (p_orig_system in varchar2,p_orig_system_id in
varchar2,p_name out varchar2,p_display_name out varchar2);
Returns a Workflow display name and role name for a role given the system
information from the original user and roles repository.
SetAdHocUserStatus (user_name in varchar2,status in varchar2 default
'ACTIVE');
Sets the status of an ad hoc user as 'ACTIVE' or 'INACTIVE'.
SetAdHocRoleStatus (role_name in varchar2,status in varchar2 default
'ACTIVE');
Sets the status of an ad hoc role as 'ACTIVE' or 'INACTIVE'.
CreateAdHocUser (name in out varchar2,display_name in out varchar2,
language in varchar2 default null, territory in varchar2 default null,
description in varchar2 default null, notification_preference in varchar2
default 'MAILHTML', email_address in varchar2 default null, fax in varchar2
default null, status in varchar2 default 'ACTIVE', expiration_date in date
default sysdate);
Creates a user at runtime by creating a value in the WF_LOCAL_USERS table.
This is referred to as an ad hoc user.
CreateAdHocRole (role_name in out varchar2, role_display_name in out
varchar2, language in varchar2 default null, territory in varchar2 default null,
role_description in varchar2 default null, notification_preference in varchar2
default'MAILHTML', role_users in varchar2 default null, email_address in
varchar2 default null, fax in varchar2 default null, status in varchar2 default
'ACTIVE',expiration_date in date default sysdate);

Creates a role at runtime by creating a value in the WF_LOCAL_ROLES table.
This is referred to as an ad hoc role.
AddUsersToAdHocRole (role_name in varchar2,role_users in varchar2);
Adds users to a existing ad hoc role.
RemoveUsersFromAdHocRole (role_name in varchar2,role_users in varchar2
default null);
Removes users from an existing ad hoc role.

WF_DIRECTORY. IsPerformer
WF_DIRECTORY. GetRoleName

WF_DIRECTORY. SetAdHocUserStatus

WF_DIRECTORY. SetAdHocRoleStatus

WF_DIRECTORY. CreateAdHocUser

WF_DIRECTORY. CreateAdHocRole

WF_DIRECTORY.
AddUsersToAdHocRole
WF_DIRECTORY.
RemoveUsersFromAdHocRole

Oracle Workflow Builder by Dinesh Kumar S











Sample Workflow 1

Description: Send PO Details to user [Role].

Oracle Workflow Builder by Dinesh Kumar S


Pre requisites: Import oracle standard file WFSTD.wft.

It will be available in oracle database in the below path



\oracle\ora92\wf\DATA\US

Step 1: New Item Type Creation.

Oracle Workflow Builder by Dinesh Kumar S

New Item_type created.




Step 2: New Attributes Creation


Right Click Attribute create new attribute.

PO_NUMS



ORG_NUM




Step 3: Creating New Process.

Oracle Workflow Builder by Dinesh Kumar S

Oracle Workflow Builder by Dinesh Kumar S



Step 4: Define Process Details.

Oracle Workflow Builder by Dinesh Kumar S


Double click the process created and a new window opens.



Step 5: Creating functions inside root process.

Below are the functions we will be using in our workflow.

Function 1: Start

[Oracle Standard]
Function 2: End

[Oracle Standard]
Function 3: PO_DTLS


Notification: NOTIFY_PO

Step 5.1: START (Function):


Oracle Workflow Builder by Dinesh Kumar S

Step 5.2: END (Function):


Oracle Workflow Builder by Dinesh Kumar S

Oracle Workflow Builder by Dinesh Kumar S


Step 5.3: Creating Role Attribute & Roles.


Step 5.3.1: Create Role Attribute

Oracle Workflow Builder by Dinesh Kumar S

Step 5.3.2: Create Roles



We can create roles in 2 methods:


Method 1:
Global Application Roles

Method 2:
Database Adhoc Roles


Method 1: Global Application Roles

Navigation:

Human Resource Transaction Maintenance Global Roles

Role Name:
DEMO_ROLE4
Person:

Valid users from FND_USERS table.




Note** we will be creating Roles using oracle standard API WF_DIRECTORY.

Oracle Workflow Builder by Dinesh Kumar S

Method 2: Database Adhoc Roles



i.
Create New Role
ii.
Add Users to Role
iii.
Using Adhoc Roles in WF Notification

Creating New Role: Use the below API to create new Roles.



Execute the below code in SQL Developer / SQL PLUS.

Role successfully created.


Oracle Workflow Builder by Dinesh Kumar S



Add User to Role: To add users to role use the below API.



ROLE_NAME
DEMO_ROLE4

USERS
User_1



Users successfully added into the Role.



Note** Email_Address of the User should be in CAPS.

Oracle Workflow Builder by Dinesh Kumar S


Update User e-Mail Notification Preference:


User email Notification can be updated in 2 ways.

Method 1: Using Query.
Method 2: Setting Global Preference.

Method 1: Using Query


Email Styles:

Style
DISABLE
QUERY
MAILHTM2
MAILHTML
SUMHTML
MAILTEXT
MAILATTH
SUMMARY

Description
Disabled
Do not send me mail
HTML mail
HTML mail with attachments
HTML summary mail
Plain text mail
Plain text mail with HTML attachments
Plain text summary mail



Method 2: Setting Global Preference.


Responsibility:
Workflow Administrator Web (New)
Navigation:
Workflow Administrator Web (New) Administration

Oracle Workflow Builder by Dinesh Kumar S


Step 5.4: PO_DETAILS (Function)

Create a new procedure and set the Role ATTRIBUTE with ROLE Name.


Procedure Details: D_GETPO_DTLS

Oracle Workflow Builder by Dinesh Kumar S



Note** When assigning a Procedure (or) Function to a WF Function the following parameters to be defined
mandatorily [Itemtype, itemkey, actid, funcmode, resultout]





Step 5.5: Create Message & Assign to Notification





Step 5.5.1: Create Message

Oracle Workflow Builder by Dinesh Kumar S

Oracle Workflow Builder by Dinesh Kumar S


Now drag & drop the attributes which will be displaying in the message.



Use the attributes valid for that message.

Oracle Workflow Builder by Dinesh Kumar S

Step 5.5.2: Create Notification



Right Click & Select Notification.



Note** Remember the following assignments.

Users Roles Role Attribute Performer


In Node tab the performer details should be setup. Since the roles are assigned to role attribute we will be
using the same.

Oracle Workflow Builder by Dinesh Kumar S

Oracle Workflow Builder by Dinesh Kumar S


Step 6: Defining Transitions [Activity Flow Arrows]

Right Click the source & drag it to destination node.




Step 7: Save the Workflow

Navigation: File Save As

This step is to compile the Workflow.

Provide User, Password & Host string to connect to database and save the workflow.



Now the workflow will be compiled using database connection and shows error if exists.

Oracle Workflow Builder by Dinesh Kumar S


Step 8: Uploading/Downloading the Workflow Definitions into Oracle Apps Database

Oracle Workflow .WFT files can be uploaded (or) downloaded by following two methods.


Method 1: Standard Concurrent Program.
Method 2: WFLOAD Utility


Method 1: Standard Concurrent Program.



The program should be submitted in 2 different ways.

a) For a Stand alone version of oracle workflow builder.
b) For an Oracle workflow embedded in oracle version.


For a Stand alone version of oracle workflow builder:

Please Refer: Oracle Workflow Administrator's Guide Release 2.6.3
Part Number B10283-02


http://docs.oracle.com/cd/B13789_01/workflow.101/b10283/instal85.htm#appsload


For an Oracle workflow embedded in oracle version:

Please Refer: Oracle Workflow Administrator's Guide Release 2.6.3
Part Number B10283-02
http://docs.oracle.com/cd/B13789_01/workflow.101/b10283/instal85.htm#appsload

We will be using For an Oracle workflow embedded in oracle version in our case.





(Below Notes are with reference to the above said oracle administrator guide for reference.)

Oracle Workflow Builder by Dinesh Kumar S

For an Oracle workflow embedded in oracle version:



1) Navigate to the Submit Requests form in Oracle Applications to submit the Workflow Definitions Loader
concurrent program. When you install and set up Oracle Applications and Oracle Workflow, your system
administrator needs to add this concurrent program to a request security group for the responsibility that
you want to run this program from. See: Overview of Concurrent Programs and Requests, Oracle
Applications System Administrator's Guide.
2) Submit the Workflow Definitions Loader concurrent program as a request. See: Submitting a Request,
Oracle Applications User's Guide.
3) In the Parameters window, enter values for the following parameters:
Fields
Mode

Parameter Type Description


Download
Specify "Download" to download a process definition from the database to a flat
file.
Upgrade
Specify "Upgrade" to apply a seed data upgrade to a database from an input file.
The Workflow Definitions Loader assumes the access level of the file's creator
(seed data provider) and overwrites any objects protected at a level equal to or
above the upgrade file's access level. The Loader program preserves any
customizations made to customizable seed data in the database.

File

Upload

Specify "Upload" to load a process definition from a flat file into the database.
The upload mode is useful to someone who is developing a workflow process. It
allows the developer to save definitions to the database without concern that
accidental customizations to existing objects might prevent the upload of some
process definition elements. The Workflow Definitions Loader uses the access
level defined by the input file to upload the process definitions from the file and
therefore will overwrite objects in the database that are protected at a level
equal to or higher than that file's access level.

Force

Specify "Force" to force an upload of the process definitions from an input file to
a database regardless of an object's protection level You should be certain that
the process definition in the file is correct as it overwrites the entire process
stored in the database. The Force mode is useful for fixing data integrity
problems in a database with a known, reliable file backup.

--

Specify the full path and name of the file that you want to download a process
definition to, or upgrade or upload a process definition from.
If you set Mode to "Download", use the List button to choose the item type for
the process definition you want to download.

Item Type --

Oracle Workflow Builder by Dinesh Kumar S

Method 2: WFLOAD Utility.



An inbuilt Oracle utility helps to
save (or) Load Process Definitions from a database or flat file.
Upload/Download/Upgrade the .WFT files into the oracle database.


Syntax for UPLOAD:

WFLOAD <apps/pwd>@<connect_string> 0 Y {UPLOAD | UPGRADE | FORCE} <filepath>[<file_name.wft>]


Upload Modes
UPGRADE
UPLOAD
FORCE

Description
Honors both protection and customization levels of data
Honors only protection level of data [No respect of Customization Level]
Force upload regardless of protection or customization level


Example:
WFLOAD apps/pwd@<connect_string> 0 Y UPLOAD DEMO1.wft



Syntax for DOWNLAOD:

WFLOAD <apps_user_name>/<password>@db 0 Y DOWNLOAD file_name.wft <Item_Type>


The access levels are defined as follows:

0-9
: Reserved for Oracle Workflow
10-19
: Reserved for Oracle Application Object Library
20-99
: Reserved for Oracle E-Business Suite
100-999
: Reserved for customer organizations
1000
: Public


SUMMARY:


To upgrade - WFLOAD apps/pwd 0 Y UPGRADE filename.wft
To upload - WFLOAD apps/pwd 0 Y UPLOAD filename.wft
To force - WFLOAD apps/pwd 0 Y FORCE filename.wft
To download - WFLOAD apps/pwd 0 Y DOWNLOAD filename.wft ITEMTYPE1

Oracle Workflow Builder by Dinesh Kumar S


Step 8.1: First upload the .WFT file to the Custom (or) Standard Application.

UNIX Path: /PO/11.5.0/admin/import/



Step 8.2: Submit the Request Workflow Definition Loader

Log into System Administrator responsibility to submit the request.

Request Name
Parameters
Mode
File
Item Type

Workflow Definition Loader



Upload
The path in which the file is stored in Custom/Standard Schema.
Not Required for upload.


Request executed successfully.

Oracle Workflow Builder by Dinesh Kumar S



Now you can check the whether the item type is uploaded into database or not.

Submit the same request & in parameter window try to select the Item_type if it is populated in LOV the WF
definitions is successfully loaded into database.

Oracle Workflow Builder by Dinesh Kumar S

Step 9: Launch the Workflow.



A workflow can be launched using WF_ENGINE API by two methods,

1) Method 1: LaunchProcess API
2) Method 2: StartProcess API


Common Parameters Used:


Parameter Name
ItemType
ItemKey
Process

Description
Internal Name of the Item type in workflow.
Unique identifier of specific workflow instance.
Internal Name of process where workflow should begin

ProcessName
Aname
UserKey

Activity Name of process.


note: Top/Root process activity name = Internal Name
Internal Name of Process attribute
Data End User would use to identify workflow instance

Owner

Role Display Name (from WF_LOCAL_ROLES)




Useful API Information - Summary:

Workflow API's in Starting a WF Process


API Name Procedure/Function
LaunchProcess
CreateProcess
StartProcess
SetItemOwner
SetItemUserKey
SetItemParent
WF_ENGINE
GetItemUserKey
Event
Background
CreateForkProces
StartForkProcess

Description
Launching a WF from its root process.
Creates a new runtime process for Item_type
For executing a specific Process/Sub-process within a WF.
Setting Workflow Item Owner.
Setting the Usekey for the WF.
If we want to initiate a sub-process from another WF this API can be
used.
Returns user identifier assigned to an item.
Receives an event into WF Process from Business Event sys.
To process deferred & timed out activities stuck in a process.
Creating a new process which is copy of original.
Begins execution of new fork process.

Workflow API's to Set & Get Attribute Information


API Name

Procedure/Function

Description

Oracle Workflow Builder by Dinesh Kumar S

SetItemAttrText
SetItemAttrNumber
SetItemAttrDate
SetItemAttrEvent

SetItemAttrTextArray
SetItemAttrNumberArray
SetItemAttrDateArray

GetItemAttrText
GetItemAttrNumber
GetItemAttrDate
GetItemAttrEvent

WF_ENGINE
GetItemAttrInfo
AddItemAttr
GetActivityAttrInfo


AddItemAttrTextArray
AddItemAttrNumberArray
AddItemAttrDateArray

GetActivityAttrTex
GetActivityAttrNumber
GetActivityAttrDate
GetActivityAttrEvent

To initialize or set value for WF Process Attribute types [text,


number, Date & Event] this API are used

To initialize or set values for Array of Attributes these API's are
used.

To retrieve attribute values & use it in PLSQL procedures (or)
functions these API are used.

Returns property information for an item Attribute like Data
Type, Format etc.
To add a new Attribute to a WF Item Type runtime process.
Returns property information for an activity Attribute like Data
Type, Format etc.

To add a array of new Attributes to a WF Item Type runtime
process.

Returns value of an activity attribute in a process.

Oracle Workflow Builder by Dinesh Kumar S

Workflow API's to know Status of WF to WF Engine


API Name

Procedure/Function
CompleteActivity

CompleteActivityInternalName

BeginActivity
AssignActivity
GetActivityLabel
WF_ENGINE

AbortProcess
SuspendProcess

ResumeProcess
HandleError

ItemStatus

Description
Informs WF engine a specific
activity[identify by node name] is
completed for item.
Informs WF engine a specific
activity[identify by internal name] is
completed for item.
To perform an activity & raises an
exception if it is not.
Assigning activity to a performer.
Returns the label info. An activity by
activity instance identification.
It aborts a process executing & its related
notifications.
Suspends a process so that user cannot
transition current items to any other
activity.
Re-executes a suspended process.
Error Handling tasks for an Activity. Also
used for rollback operation for a process
in an activity.
returns the status for a root process of
specific item instance.

Oracle Workflow Builder by Dinesh Kumar S


Launching Workflow: (Cont.. Step 9)


Method 1: LaunchProcess API



Parameter information:

itemtype
- A valid item type
itemkey
- A string generated from the application object's primary key.
process
- A valid root process for this item type


(Or null to use the item's selector function)
userkey
- User key to be set
owner
- Role designated as owner of the item




Method 2: CreateProcess + StartProcess API


The following steps to be followed in coding,

1) Create a workflow Process Instance.
2) Set the UserKey for the WF.
3) Set the workflow Item Owner.
4) Set initial values for Process Attributes.
5) Kick-Off the Workflow.


Important Question:

Why we have two methods to launch a workflow from PLSQL procedure?

Method 1 will be used when we are going to kick a WF from its ROOT / TOP Process [One scenario for
understanding].

Method 2 will be used when we want to want to initiate a sub-Process within an item type of from another item
type this method will be used. [One scenario for understanding]

For Knowledge base we will go with method 2.

Oracle Workflow Builder by Dinesh Kumar S


Step 10: Run the Procedure to Kick-off the workflow.

Oracle Workflow Builder by Dinesh Kumar S


Checking the status of Workflow:

Oracle Workflow Builder by Dinesh Kumar S


Step 11: Check Notification in WF Notification Monitor.


Log into Responsibility Workflow Administrator Web (New).


Go to Home. You can view the notification.

Notification:


Worklist:

Oracle Workflow Builder by Dinesh Kumar S

Workflow Status Monitor:



Oracle Workflow Builder by Dinesh Kumar S

Status Diagram:

Oracle Workflow Builder by Dinesh Kumar S



Activity History:


Oracle Workflow Builder by Dinesh Kumar S














Sample Workflow 2

Description:
- Send PO Details to user [Role]. .
- Standard Lookup_Type usage for a function.
Note**

We will be Modifying the existing Workflow File and update the same
package. But pls. change the Package Name, WF objects name.

Oracle Workflow Builder by Dinesh Kumar S


Follow the same steps from Step 1 to Step 5.3 from Sample workflow 1.

Step 5.4: PO_DETAILS (Function)

Create a new procedure and set the Role ATTRIBUTE with ROLE Name.



Procedure Details: D_GETPO_DTLS

Add the below code in the existing package.


Note** two methods you can set result out.

Method 1: Using wf_engine.eng_completed

Method 2: Above method.

Oracle Workflow Builder by Dinesh Kumar S





Follow Step 5.5 from Sample workflow-1 to define Message & notification.



Step 6: Defining Transitions [Activity Flow Arrows]

Right Click the source & drag it to destination node.



While defining transition from node PO_DTLS to NOTIFY_PO we need to select Lookup_type code, based on that
next activity will be performed.




Note** If you have any default (or) any activity to perform we can use even <Default> (or) <Any> transition.

Oracle Workflow Builder by Dinesh Kumar S



Similarly create transition for lookup_code NO.



Note** If a lookup_type for example


Lookup_type:
PO_STATUS_TYPE
Lookup_code:

Approved
Rejected
Incomplete


Follow Step 7 to Step 10 from sample workflow-1 to save, load definitions, launch and kick-off workflow.



Oracle Workflow Builder by Dinesh Kumar S













Sample Workflow 3

Description:
- Using Standard Lookup Type for END activity.
- Using NOOP Activity.
Note**

We will be Modifying the existing Workflow File and update the same
package. But pls. change the Package Name, WF objects name.

Oracle Workflow Builder by Dinesh Kumar S

Noop Activity
The NOOP activity acts as a place holder activity that performs no action. You can use this activity anywhere you
want to place a node without performing an action. You can change the display name of this activity to
something meaningful when you include it in a process, so that it reminds you of what you want this activity to
do in the future. This activity calls the PL/SQL procedure named WF_STANDARD.NOOP.


Refer: http://docs.oracle.com/cd/B19306_01/workflow.102/b15853/T361836T362090.htm#I_sanoop


Note**

END Activity can be associated with Lookup Type only when the Process in which the end activity belongs should
also have result type set with standard or custom Lookup type.


To do this workflow, the following changes to be done in the existing workflow.

1) Creating a Root Process.
2) Creating a NOOP Activity.

Create Workflow as below.


Oracle Workflow Builder by Dinesh Kumar S




Now the ROOT_PROCESS have the sub-process PO_DETAILS6.

Oracle Workflow Builder by Dinesh Kumar S


Properties of Sub-Process PO_DETAILS6.



Inside Sub Process:

Oracle Workflow Builder by Dinesh Kumar S


Since, Sub-Process PO_DETAILS6 associated with Standard Lookup Type Success/Fail. In the END Activity by
default the same lookup Type codes will be populated.


Creating NOOP:

Right Click New Function



Now Follow Step 7 to Step 10 from Sample Workflow 1 to Save, Load Definitions & launch the WF.

Oracle Workflow Builder by Dinesh Kumar S











Sample Workflow 4

Description:
- Using Standard Lookup Type for END activity.
- Using NOOP Activity.
- Using AND Activity.
- Checking PO Created using Requisition or Directly Created.
Note**

We will be Modifying the existing Workflow File and update the same
package. But pls. change the Package Name, WF objects name.

Oracle Workflow Builder by Dinesh Kumar S


Since we have updated the existing workflow we will not be seeing only the changes.

Process Objects:


Object
Type
Process

Attributes




Notification

Object Name

Description

ROOT_PROCESS2
PO_DETAILS7
WF_ITEMTYPE
WF_ITEMKEY
ASSIGN_ROLE7
PO_NUMS7
ORG_NUM7
NOTIFY_PO7

Message

NOTIFY_PO7

Top/Root Process
Sub process inside top process.
Holds Item Type Name
Holds Item Key Data
Role Attribute to hold role data
PO Number
Organization Number
Send Notification to users in
ASSIGN_ROLE7.
Contains Message Template/Body.
Message Attributes:
PO_NUMS7
ORG_NUM7

ROOT_PROCESS2:

Oracle Workflow Builder by Dinesh Kumar S


PO_DETAILS7:

Flow Description:

1] PO_DTLS7: Checks PO is valid.

Oracle Workflow Builder by Dinesh Kumar S

IF PO Valid THEN

Send notification to User (AND) Check PO created from Requisition or Not.

ELSE

Performs a DUMMY Activity [NOOP] and Ends with Failure.

END;


2] CHK_REQ: Checks PO created using Requisition or without requisition.



IF PO without REQ THEN
Note** Now Both Activity [NOTIFY_PO7 & CHK_REQ] are completed so it satisfies
AND Activity and Ends with Success.
ELSE

Activity Ends with Failure.

END;



PO_DTLS7:



NOTIFY_PO7:

Oracle Workflow Builder by Dinesh Kumar S

Oracle Workflow Builder by Dinesh Kumar S



CHK_REQ:

Oracle Workflow Builder by Dinesh Kumar S

Standard Activities:

NOOP:



AND:

Oracle Workflow Builder by Dinesh Kumar S







Sample Workflow 5(a)

Description:
- Notification Timeout functionality
Note**

We will be Modifying the existing Workflow File (Exercise 1) and update the
same package. But pls. change the Package Name, WF objects name.

Oracle Workflow Builder by Dinesh Kumar S

Notification Timeout Functionality:


We can set a timeout to a WF notification at Notification properties. Along with timeout functionality if case of
any business requirement we can enable reminder notification to the user. Even after sending reminder
notification if the user didnt approve, it can be escalated to its supervisor.


We are going to use the existing sample workflow 1 for modifying the notification timeout property.


Double Click NOTIFY_PO. Go to Node Tab.


Timeout Types:

Oracle Workflow Builder by Dinesh Kumar S

There are 3 types available,



1. No Timeout
2. Item Attribute
3. Relative Time



No Timeout: Choose No Timeout if the activity does not have to be completed by a given time.




Item Attribute: Choose Item Attribute if you want the activity to be completed by some relative time that is
computed dynamically at runtime. Note that you must first create an item attribute of type number to store the
computed timeout value and reference that predefined item attribute here.

Note** the dynamic timeout value stored in this attribute is interpreted as a relative offset
from the begin date of the activity, in the unit of MINUTES. A null timeout value or a value
of zero means no timeout.


Relative time: Choose Relative Time if you want the activity to be completed by some constant relative time.
You can enter any combination of days, hours and minutes to specify when the activity times out. The value you
enter is interpreted as a relative offset from the begin date of the activity, in the unit of MINUTES. A relative
timeout value of zero means no timeout.

Oracle Workflow Builder by Dinesh Kumar S

Priority type:

For a notification activity node, or for an event activity node with an event action of Send, you can override the
priority assigned to the activitys message.

There are 3 types,

1. Default
2. Item Attribute
3. Constant


Default: Choose Default to keep the default priority of the message.



Item Attribute: Choose Item Attribute to override the default priority with a new priority level that is
dynamically determined at runtime. Note that you must first create an item attribute of type number to store the
Computed priority value and reference that predefined item attribute here.



Constant: Choose Constant to override the default priority with the new specified priority level.

Oracle Workflow Builder by Dinesh Kumar S








Sample Workflow 5(b)

Description:
- Create Custom Result Type in a Notification

Note**

We will be modifying the same Workflow File used in 5(a).

Oracle Workflow Builder by Dinesh Kumar S

Create New Lookup Type:


Oracle Workflow Builder by Dinesh Kumar S


Create Lookup codes for the custom lookup type.

Oracle Workflow Builder by Dinesh Kumar S


Similarly create another lookup code.




Now assign this lookup code to Notification Result type.


Note** when you open the workflow notification the below two custom action buttons will be displayed.

OK_BUDDY
NO_BUDDY

Oracle Workflow Builder by Dinesh Kumar S







Sample Workflow 6

Description:
- Create Business Events


Note**

The event will be raised from Standard Apps Screen.


Business Event System:

Oracle Workflow Builder by Dinesh Kumar S


The Oracle Workflow Business Event System is an application service that leverages the Oracle Advanced
Queuing (AQ) infrastructure to communicate business events between systems.

The Business Event System consists of,

Event Manager
Workflow process event activities.


Event Manager:

o

The Event Manager contains a registry of business events, systems, named communication agents within those
systems, and subscriptions indicating that an event is significant to a particular system. Events can be raised locally
or received from an external system or the local system through AQ.

When a local event occurs, the subscribing code is executed in the same transaction as the code that raised the
event, unless the subscriptions are deferred.


Subscriptions can include the following types of processing:

Executing custom code on the event information


Sending event information to a workflow process
Sending event information to other queues or systems


Event Activities:

o

Business events are represented within workflow processes by event activities. By including event activities in a
workflow process, you can model complex processing or routing logic for business events beyond the options of
directly running a predefined function or sending the event to a predefined recipient.

The Business Event System supports the following types of integration:

message-based point-to-point system integration


system integration messaging hubs
distributed applications messaging

Oracle Workflow Builder by Dinesh Kumar S

Steps to Create Business Events:



Step 1: Create Table

Oracle Workflow Builder by Dinesh Kumar S



Step 2: Create a Package/Procedure/function to insert the data captured when business event is triggered.
Note** for this example Im creating a global function in APPS Schema.



Step 3: Create Business Event

Oracle Workflow Builder by Dinesh Kumar S


Log into responsibility Workflow Administrator and go to Business Events tab.

Oracle Workflow Builder by Dinesh Kumar S


Now click Apply and confirmation message will be displayed.



Step 4: Create Subscription

Oracle Workflow Builder by Dinesh Kumar S


Now enter Action Type. Click the LOV.

Oracle Workflow Builder by Dinesh Kumar S



Click Next and enter the PL/SQL function name details.

Oracle Workflow Builder by Dinesh Kumar S


Click Apply and confirmation message will be displayed.




Step 5: Test the Business Event

Query for the Business event.

Oracle Workflow Builder by Dinesh Kumar S



Event has been raised successfully.



Step 6: Query for the table.