Oracle EBS WorkFlow 开发笔记总结
转自:http://blog.csdn.net/silencecho/article/details/8906000工作流组成: 1).工作流(item type): 其实就相当于一个业务类型。主要是定义业务信息,另外还包含一些在其他对象需要引用的信息。 为方便理解,可以看作是一个工作流的容器和标志。 2).活动(activity
转自:http://blog.csdn.net/silencecho/article/details/8906000
工作流组成:
1).工作流(item type):
其实就相当于一个业务类型。主要是定义业务信息,另外还包含一些在其他对象需要引用的信息。
为方便理解,可以看作是一个工作流的容器和标志。
2).活动(activity):
是工作流程中的一个执行单元。活动有自己的类型,在运行时,活动的实例会返回一个结果,工作流引擎会更具活动实例的返回值
决定业务流程如何流转。 活动有三种类型:通知,流程和函数。
3).流程(process):
是业务流程的流转规则,真正的流程,由Notification、Function、子Process组成,
开始于一个Start Function,结束于一个或多个End Function,中间是Notification和Function组成的业务流程,
在这个级别上可以把Notification、Function、子Process看成是一样的即activity,
他们都有返回值,不同的结果走不同的流程,由此组成一个符合业务需要的图表
4).消息(message):
消息主要是为通知服务的,可以把消息当作通知的内容和类型。
就是一个消息,内容在Body里面定义,用&引用Message自己的Attribute;对我们程序有用的的是Message的Attribute,
一般和上面的全局变量Attribute对应,Send类型的Attribute将取当时的全局变量Attribute的值发给用户看,
Response类型Attribute将把用户输入的内容返回给全局变量Attribute供我们的程序作下一步判断使用。
一个可以自动执行的活动,该活动可以完成一定的功能,函数通常和一个PL/SQL存储过程联系在一起。
一般对应一个PL/SQL函数并定义返回值为某个Lookup Type。
6).事件(Event):
7).通知(notification):
通知活动对一个人或一个角色发送一个通知,通知必须和一个消息联系在一起。
发送一个消息,消息内容为定义的Message内容,消息的接收人是定义的Performer
8).查找类型(lookup type):
查找类型是你定义的一些枚举类型。工作流里的查找类型主要用来表达活动结果返回值类型。
基础字典列表,就像我们的部门字典表,销售方式字典表一样,不过它是静态的;根据需要设置,
一般用来标志工作流各类Item的返回值,和我们的PL/SQL函数返回值一一对应。
9).属性(Attribute):
全局变量,供整个Item Type里面的元素使用,可以作为Message的附加属性,
Send给用户看或者存储用户的Response内容比如Note和Forward To;
Attribute另一个常用的地方是作为Notification的Performer。当然我们的PL/SQL代码是离不开Attribute,
几乎任何PL/SQL函数都需要通过取得Attribute变量--判断Attribute变量--设置Attribute变量,
决定程序如何走,返回什么值。
-----------------------------Workflow 的保存方式:----------------------------------------
1、Workflow builder 中直接保存到数据库或本地文件目录(后缀名.wft)。
2、用FTP工具将wft文件上传到应用服务器的客户化应用目录,在命令行运行如下命令:
注意UNIX区分大小写。
cd $CUX_TOP/install
WFLOAD apps/apps 0 Y UPLOAD $CUX_TOP/install/Your_workflow_file_name.wft
3、用FTP工具将wft文件上传到应用服务器的客户化应用目录,然后到系统管理员职责提交请求:
请求名:Workflow Definitions Loader
参数:
Mode: Upload
File:$CUX_TOP/install/Your_workflow_file_name.wft
Item Type:置空
-----------------------------Workflow 的保存方式:----------End------------------------------------
----------------------------------------运行Workflow的方式-----------Start------------------
方式一、Workflow管理界面(N:System Administrator/Workflow/Adminnistrator Workflow/Home)
方式二、PL/SQL 启动WorkFlow
DECLARE
l_item_key VARCHAR2(30) := 'COX_DEMO_201303281446';
l_user_item_key VARCHAR2(30) := 'COX_DEMO_201303281446';
l_item_type VARCHAR2(30) := 'COX_0002';
l_process VARCHAR2(30) := 'COX_TOP';
l_submiter_id NUMBER := 31819;
l_approver_id NUMBER := 31819;
l_orig_system VARCHAR2(30) := 'PER';
l_user_name wf_roles.NAME%TYPE;
l_display_name wf_roles.display_name%TYPE;
BEGIN
--01 创建
wf_engine.createprocess(itemtype => l_item_type,
itemkey => l_item_key,
process => l_process,
user_key => l_user_item_key);
--02 初始化
wf_directory.getusername(p_orig_system => l_orig_system,
p_orig_system_id => l_submiter_id,
p_name => l_user_name,
p_display_name => l_display_name);
wf_engine.setitemattrnumber(itemtype => l_item_type,
itemkey => l_item_key,
aname => 'SUBMITER_ID',
avalue => l_submiter_id);
wf_engine.setitemattrtext(itemtype => l_item_type,
itemkey => l_item_key,
aname => 'SUBMITER_NAME',
avalue => l_user_name);
wf_engine.setitemattrtext(itemtype => l_item_type,
itemkey => l_item_key,
aname => 'SUBMITER_DSP_NAME',
avalue => l_display_name);
wf_directory.getusername(p_orig_system => l_orig_system,
p_orig_system_id => l_approver_id,
p_name => l_user_name,
p_display_name => l_display_name);
wf_engine.setitemattrnumber(itemtype => l_item_type,
itemkey => l_item_key,
aname => 'APPROVER_ID',
avalue => l_approver_id);
wf_engine.setitemattrtext(itemtype => l_item_type,
itemkey => l_item_key,
aname => 'APPROVER_NAME',
avalue => l_user_name);
wf_engine.setitemattrtext(itemtype => l_item_type,
itemkey => l_item_key,
aname => 'APPROVER_DSP_NAME',
avalue => l_display_name);
--03 启动
wf_engine.startprocess(itemtype => l_item_type, itemkey => l_item_key);
COMMIT;
dbms_output.put_line(l_item_key);
END;
----------------常用代码--------------------------------------
----查当前系统中所有的工作流:
SELECT b.NAME, t.display_name, t.description
FROM wf_item_types b, wf_item_types_tl t
WHERE b.NAME = t.NAME
AND t.LANGUAGE = 'ZHS'
ORDER BY 1
----查看当前的Workflow管理员,用其登陆EBS即可
SELECT wfr.text
FROM wf_resources wfr
WHERE NAME = 'WF_ADMIN_ROLE'
AND wfr.LANGUAGE = 'US'
----查看Notifaction
SELECT wfn.notification_id,
wfn.message_type,
wfn.recipient_role,
wfn.status,
wfn.subject,
wfn.due_date,
wfn.end_date
FROM wf_notifications wfn
WHERE wfn.message_type = 'Item type 的 Internal name'
AND wfn.subject LIKE ' message 标 题 '
ORDER BY wfn.notification_id DESC
--获取流程实例的属性值:
SELECT item_type,
item_key,
NAME,
text_value,
number_value,
date_value,
event_value
FROM applsys.wf_item_attribute_values
WHERE item_type = 'item type的internal name'
AND item_key = 'item key 的值 ';
--获取当前的active节点的信息:
SELECT was.item_type,
was.item_key,
wpa.process_name || ':' || wpa.instance_label activity,
was.activity_status,
was.activity_result_code,
was.assigned_user,
was.notification_id,
was.begin_date,
pro.display_name process_name,
act.display_name activity_name
FROM apps.wf_item_activity_statuses was,
apps.wf_process_activities wpa,
apps.wf_activities_vl pro,
apps.wf_activities_vl act,
applsys.wf_items wi
WHERE was.process_activity = wpa.instance_id
AND wpa.process_item_type = pro.item_type
AND wpa.process_name = pro.NAME
AND wpa.process_version = pro.version
AND wpa.activity_item_type = act.item_type
AND wpa.activity_name = act.NAME
AND was.item_type = wi.item_type
AND was.item_key = wi.item_key
AND wi.begin_date >= act.begin_date
AND wi.begin_date < nvl(act.end_date, wi.begin_date + 1)
AND was.item_type = 'item type 的 internal name'
AND was.item_key = 'item key 的值'
AND was.end_date IS NULL;
/*查找出EBS中过期工作流数据,以确定是否可以清除,须确保两个条件:
Wf_items表中本条工作流数据end_date不为空(保证本条工作流状态为closed)
Wf_items表中本条工作流数据不含父项工作流,或者父项工作流end_date也不为空(保证本条工作流的父工作流状态为closed)
*/
select c.item_type child,
decode(c.end_date, null, 'OPEN', 'CLOSED') child_status,
c.parent_item_type parent,
decode(c.parent_item_type,
null,
'NOPARENT',
decode(p.end_date, null, 'OPEN', 'CLOSED')) parent_status,
count(*)
from wf_items p, wf_items c
where p.item_type(+) = c.parent_item_type
and p.item_key(+) = c.parent_item_key
group by c.item_type,
decode(c.end_date, null, 'OPEN', 'CLOSED'),
c.parent_item_type,
decode(c.parent_item_type,
null,
'NOPARENT',
decode(p.end_date, null, 'OPEN', 'CLOSED'))
order by c.item_type, c.parent_item_type;
--------------------------------------------超时、阻塞、挂起工作流的清理---Start---------------------------------
Background Engines
"Workflow Background Process"请求用来处理Timeout、Defer、Stuck的工作流;通常情况下我们需要分别为处理超时、阻塞、
挂起各Schedule一个Workflow Background Process。
如果我们Schedule了该请求,但是时候等不及,也可手工提交Workflow Background Process 请求的
参数如下:
Item Type:Minimum Threshold:
Maximun Threshold:
Process Deferred: (Yes/No)
Process Timeout: (Yes/No)
Process Stuck: (Yes/No)
用PL/SQL运行Workflow Background Process请求。
BEGIN
wf_engine.background (itemtype=>NULL ,
process_deferred=>TRUE ,
minthreshold=>NULL ,
maxthreshold=>NULL ,
process_timeout=>FALSE ,
process_stuck=>FALSE);
END;
在 Unix上运行Workflow Background Process请求。
$ $FND_TOP/Admin/Sql/wfbkg.sql
------------------------------------------工作流相关的主要表结构---Start----------------------------------------
wf_item_types_vl --保存工作流的定义,即类
wf_items --保存实际的工作流,或者说工作流的对象实例
wf_item_attribute_values --保存工作流实例的attribute最新值
wf_item_activity_statuses --保存工作流实例的各个activity的状态,比如完成否,返回值
wf_notifications --保存工作流实例的notifications消息,基本是按顺序的,可以看发给谁了
wf_roles --角色视图,工作流引用角色的依据,有mail地址等信息
wf_user_roles --用户和角色关系视图,工作流可以根据它进行“群发”
WF_ITEM_TYPES: The WF_ITEM_TYPES table defines an item that is transitioning through a workflow process.
WF_ACTIVITIES: WF_ACTIVITIES table stores the definition of an activity.
Activities can be processes, notifications, functions or folders.
A process activity is a modelled workflow process, which can be included as an activity in other processes to represent a sub-process.
A notification activity sends a message to a performer. A functions activity performs an automated function that is written as a PL/SQL stored procedure. A folder activity is not part of a process, it provides a means of grouping activities.
WF_MESSAGES: WF_MESSAGES contains the definitions of messages which may be sent out as notifications.
WF_ITEM_ATTRIBUTES: The WF_ITEM_ATTRIBUTES table stores definitions of attributes associated with a process. Each row includes the sequence in which the attribute is used as well as the format of the attribute data.
WF_ACTIVITY_ATTRIBUTES: The WF_ACTIVITY_ATTRIBUTES table defines attributes which behave as parameters for an activity. Activity attributes are only used by function activities. Each row includes the associated activity, type of attribute, and the format used by the activity. Examples of valid attribute types are DATE, DOCUMENT, FORM, ITEMATTR, LOOKUP, and VARCHAR2.
WF_MESSAGE_ATTRIBUTES: WF_MESSAGE_ATTRIBUTES contains message attribute definitions.
Each message may have zero or more message attributes. Message attributes define additional information that is to be sent to, orreceived from the user. Some attributes are values to be substituted for messages tokens, while other attributes define more complexinformation.
WF_PROCESS_ACTIVITIES: WF_PROCESS_ACTIVITIES stores the data for an activity within a specific process.WF_ACTIVITY_TRANSITIONS: The WF_ACTIVITY_TRANSITIONS table defines the transitions from one activity to another in a process. Each row includes the activities at the beginning and end of the transition, as well as the result code and physical location of the transition in the process window.
------------------------------------Workflow 运行时表-------------------------------------------
WF_ITEMS: WF_ITEMS is the runtime table for workflow processes. Each row defines one work item within the system.
WF_ITEM_ACTIVITY_STATUSES: The WF_ITEM_ACTIVITY_STATUSES TABLE is the runtime table for a work item. Each row includes the start and end date, result code, and any error information an activity generates.
WF_NOTIFICATIONS: WF_NOTIFICATIONS holds the runtime information about a specific instance of a sent message. A new row is created in the table each time a message is sent.
WF_MESSAGES: WF_MESSAGES contains the definitions of messages which may be sent out as notifications.
WF_NOTIFICATION_ATTRIBUTES: WF_NOTIFICATION_ATTRIBUTES holds rows created for attributes of a notification. When each new notification is created, a notification attribute row is created for each message attribute in the message definition. Initially, the values of the notification attributes are set to the default values specified in the mesage attribute definition.
---------------------------------------------------业务事件表-----------------------------------------------------------------------
WF_SYSTEMS: System definitions for Business Event System
WF_AGENTS: Agent definitions for Business Event System
WF_EVENTS: Event definitions for Business Event System
WF_EVENT_SUBSCRIPTIONS: Subscription for Business Event System
---------------------------------------- Function 活动调用存储过程时的表中API--------------------------------------------------------------
Workflow Function活动调用存储过程时,参数的格式是固定的,如下所示:
procedure pro_name( itemtype in varchar2,
itemkey in varchar2,
actid in number,
funcmode in varchar2,
resultout in out nocopy varchar2)
itemtype: Workflow builder中定义的item type的internal name.
itemkey: 一个字符串主键,表示启用工作流的应用程序的项目类型。字符串唯一标识该项目内项目类型。
actid: 活动的ID号,表示哪个活动调用这个过程。
funcmode: 一个功能活动的执行模式. 包括: ’RUN’, ’CANCEL’, or ’TIMEOUT’.
resultout: 如果一个结果类型在活动属性中设置了,那么这个参数就在procedure执行完成后代表期望的result_code被返回。
可能的返回结果有:
COMPLETE:<result_code>
——— activity completeswith the indicated result code. The result code must match one of the result codes specified in the result type of the function activity.
WAITING
———activity is set to wait a specified
period of time before it completes. A background
engine continually checks for when the activity
wait period completes, at which point it processes
the activity as complete.
DEFERRED:<date>
———activity is deferred to a background engine for execution until a given date.
<date> must be of the format:
to_char(<date_string>, wf_engine.date_format)
NOTIFIED:< notification_id >: <assigned_user >
———an external entity is notified that an action must be
performed. A notification ID and an assigned user
can optionally be returned with this result. Note
that the external entity must call
CompleteActivity( ) to inform the Workflow engine
when the action completes.
ERROR:<error_code >
—activity encounters an error and returns the indicated error code
------------------------------------------Standard API for an Item Type Selector or Callback Function --------------------------------------------------------------------------
procedure pro_name( itemtype in varchar2,
itemkey in varchar2,
activity_id in number,
command in varchar2,
result in out varchar2) is
itemtype: Workflow builder中定义的item type的internal name.
itemkey: 一个字符串主键,表示启用工作流的应用程序的项目类型。字符串唯一标识该项目内项目类型。
activity_id: 调用procedure的活动ID号。
command: 决定怎样执行 selector/callback功能的选项命令。(包含:'RUN','SET_CTX','TEST_CTX')
result:: A result may be returned depending on the command that is used to call the selector/callback function.
If the function is called with ’RUN’, the name of the process to run must be returned through the
result parameter. If the function is called with ’SET_CTX’, then no return value is expected. If
the function is called with ’TEST_CTX’, then the code must return ’TRUE’ if the context is correct or
’FALSE’ if the context is incorrect. If any other value is returned, Oracle Workflow assumes that
this command is not implemented by the callback.
--------------------------------------------------Standard API for a ”PL/SQL” Document------------------------------------------------------------------
You can integrate a document into a workflow process by defining the
document as an attribute for an item type, message, or activity. One
type of document that Oracle Workflow supports is a ”PL/SQL”
document. Oracle Workflow constructs a dynamic call to a PL/SQL
procedure that generates the document.
The PL/SQL procedure must have the following standard API:
procedure <procedure name> ( document_id in varchar2,
display_type in varchar2,
document in out varchar2,
document_type in out varchar2)
更多推荐
所有评论(0)