SlideShare a Scribd company logo
1 of 11
Workflow Function Activity
Overview
• 前面的工作流中使用了通知节点作为演示,
  在实际的情况中, 更多使用到的是另外一种
  节点: 函数节点. 函数节点用于执行指定的
  plsql函数, 实现特定的业务功能. 将在之前创
  建的工作流(wfdemo.wft)基础之上演示函数
  节点的使用, 包括如下内容:
 – 如何定义一个函数节点?
 – 工作流过程API规范
 – 工作流过程运行模式
Create a function activity
• 使用WFB打开wfdemo.wft文件, 在导航窗口的函数节点下面添加一个新
  的节点, 该节点重要的属性有Function Name和Result Type:
  Function Name
  指定为某个plsql存储过程, 格式为<Package>.<Procedure>
  Result Type
  指定为某个Lookup Type名称, 这里选择
  WFSTD工作流中的Boolean, 它有两个值
  T和F分别表示true和false. Result Type
  决定了函数节点之后的会有哪些分支
  (T/F), 工作流过程在执行时会返回
  Result Type中的某个值, 如果返回T则
  流程沿着T分支往下走, F则走F分支.
Workflow Procedure
                   - API Standard
• 创建函数节点时指定的过程由工作流引擎调用
  (Wf_Engine_Util.Function_Call), 它必须遵循如下的格
  式:
  procedure <procedure name> (
     itemtype in varchar2,
     itemkey    in varchar2,
     actid      in number,
     funcmode in varchar2,
     resultout out varchar2) is...
  工作流引擎在执行过程时, 会传入当前的item type,
  item key, 活动id, 模式以及结果参数, 过程中需要对
  funcmode进行判断从而决定具体执行哪些操作.
• 参考附件中的wf_function_template.sql, 该脚本包含
  了工作流过程的编写模板.
Workflow Procedure
        - Function Mode & Resultout
• API标准中的funcmode参数代表节点的运行模式, 有以下几种情况:
  RUN          运行, 节点在初次运行时模式为RUN
  CANCEL       取消节点执行, wf_engine.abortprocess会传入此模式
  RETRY        重新执行该节点, 在状态监控页面执行retry或者调用
               wf_engine.handleerror过程时传入此模式
  SKIP         跳过该节点,在状态监控页面执行skip或者调用
               wf_engine.handleerror过程时传入此模式
• API标准中的resultout参数用于返回节点的状态和执行结果, 格式为status:result,
  比如COMPLETE:T表示节点状态为COMPLETE返回结果为T. 可能的结果有:
  COMPLETE:<result_code>
  WAITING
  DEFERRED:<date>
  NOTIFIED:<notification_id>:<assigned_user>
  ERROR:<error_code>
  其中result_code会与函数节点指定的result type中的值进行比较, 从而决定流程
  下一步的走向.
Workflow Procedure
              - wfdemo.find_approver
• wfdemo.find_approver用于根据申请人(LEAVEREQUSTER)工作流属性, 找到该
  申请人的上级主管, 并设置为审批人(LEAVEREQAPPROVER)工作流属性. 需要
  建一个plsql包wfdemo还它下面的子过程find_approver, 代码如下(可以在附
  件中找到):
   create or replace package body wfdemo as
      procedure find_approver(itemtype in varchar2,
                          itemkey in varchar2,
                          actid in number,
                          funcmode in varchar2,
                          resultout out varchar2) as
        v_manager VARCHAR2(30);
        v_employee VARCHAR2(30);
      begin
        IF funcmode in ('RUN', 'RETRY') THEN
        v_employee := wf_engine.getItemAttrText(itemtype, itemkey,
      'LEAVEREQUSTER') ;
Workflow Procedure
             - wfdemo.find_approver
    select c.user_name into v_manager
        from fnd_user a, per_all_assignments_f b, fnd_user c
        where a.user_name = v_employee
         and a.employee_id = b.person_id
         and b.effective_end_date > sysdate
         and b.supervisor_id = c.employee_id;
     END IF;
     IF v_manager is null THEN
       resultout := 'COMPLETE:F';
     ELSE
       wf_engine.SetItemAttrText(itemtype, itemkey, 'LEAVEREQAPPROVER', v_manager);
       resultout := 'COMPLETE:T';
     END IF;
EXCEPTION WHEN OTHERS THEN
      resultout := 'ERROR:' || sqlcode;
      WF_CORE.CONTEXT('wfdemo', 'find_approver', itemtype, itemkey, to_char(sqlcode));
      raise;
end wfdemo;
Run
        - Normal
• 添加函数节点之后流程看起来如下, 如果找
  到了审批人则向他发送通知, 如果没有则结
  束流程:



• 在WAP页面中启动该流程并将申请人设置为
  OPERATIONS:
Run
                  - Normal
• 在状态监控页面查看该流程的运行情况, 如
  下:




可以看到函数节点运行完成, 并且已经发出
FYA通知, 使用如下sql可查找通知的收件人:
  select * from wf_item_activity_statuses
   where item_type = 'LEAVEREQ' and item_key = '6‘
 接下来的流程就于之前的一样了.
Run
               - Error
• 如果在启动流程时没有指定申请人工作流参
  数(LEAVEREQUSTER), 那么函数节点在执行过
  程中会因为select...into语句抛出no data found
  异常, 进而导致节点出错, 如下:
END

More Related Content

Viewers also liked

4, workflow tables & api
4, workflow tables & api4, workflow tables & api
4, workflow tables & apited-xu
 
3, OCP - instance management
3, OCP - instance management3, OCP - instance management
3, OCP - instance managementted-xu
 
2, OCP - installing and creating a database
2, OCP - installing and creating a database2, OCP - installing and creating a database
2, OCP - installing and creating a databaseted-xu
 
1, OCP - architecture intro
1, OCP - architecture intro1, OCP - architecture intro
1, OCP - architecture introted-xu
 
7, OCP - configure database for backup and recovery
7, OCP - configure database for backup and recovery7, OCP - configure database for backup and recovery
7, OCP - configure database for backup and recoveryted-xu
 
6, OCP - oracle security
6, OCP - oracle security6, OCP - oracle security
6, OCP - oracle securityted-xu
 
4, OCP - oracle networking
4, OCP - oracle networking4, OCP - oracle networking
4, OCP - oracle networkingted-xu
 
Trabajo pràctico de computaciòn alerta enredados
Trabajo pràctico de computaciòn alerta enredadosTrabajo pràctico de computaciòn alerta enredados
Trabajo pràctico de computaciòn alerta enredadosSocialGirls
 
Redes sociales(1)
Redes sociales(1)Redes sociales(1)
Redes sociales(1)amsm88
 
V ozes e visões bviw
V ozes e visões   bviwV ozes e visões   bviw
V ozes e visões bviwbudcesar13
 
Recursos educativos y medios didácticos
Recursos educativos y medios didácticosRecursos educativos y medios didácticos
Recursos educativos y medios didácticosAndrea Mora Lizano
 
Gc Ii Fase 3liliana Soares Ivo Granja
Gc Ii Fase 3liliana Soares Ivo GranjaGc Ii Fase 3liliana Soares Ivo Granja
Gc Ii Fase 3liliana Soares Ivo GranjaIvo Granja
 
Tecnologias existentes na_escola
Tecnologias existentes na_escolaTecnologias existentes na_escola
Tecnologias existentes na_escolarmemoria
 
disco rigido
disco rigidodisco rigido
disco rigidofrancoslo
 

Viewers also liked (20)

4, workflow tables & api
4, workflow tables & api4, workflow tables & api
4, workflow tables & api
 
3, OCP - instance management
3, OCP - instance management3, OCP - instance management
3, OCP - instance management
 
2, OCP - installing and creating a database
2, OCP - installing and creating a database2, OCP - installing and creating a database
2, OCP - installing and creating a database
 
1, OCP - architecture intro
1, OCP - architecture intro1, OCP - architecture intro
1, OCP - architecture intro
 
7, OCP - configure database for backup and recovery
7, OCP - configure database for backup and recovery7, OCP - configure database for backup and recovery
7, OCP - configure database for backup and recovery
 
6, OCP - oracle security
6, OCP - oracle security6, OCP - oracle security
6, OCP - oracle security
 
4, OCP - oracle networking
4, OCP - oracle networking4, OCP - oracle networking
4, OCP - oracle networking
 
Español
EspañolEspañol
Español
 
Módulo 4
Módulo 4Módulo 4
Módulo 4
 
docil
docildocil
docil
 
Trabajo pràctico de computaciòn alerta enredados
Trabajo pràctico de computaciòn alerta enredadosTrabajo pràctico de computaciòn alerta enredados
Trabajo pràctico de computaciòn alerta enredados
 
Redes sociales(1)
Redes sociales(1)Redes sociales(1)
Redes sociales(1)
 
Bento Azenha
Bento AzenhaBento Azenha
Bento Azenha
 
V ozes e visões bviw
V ozes e visões   bviwV ozes e visões   bviw
V ozes e visões bviw
 
Recursos educativos y medios didácticos
Recursos educativos y medios didácticosRecursos educativos y medios didácticos
Recursos educativos y medios didácticos
 
Gc Ii Fase 3liliana Soares Ivo Granja
Gc Ii Fase 3liliana Soares Ivo GranjaGc Ii Fase 3liliana Soares Ivo Granja
Gc Ii Fase 3liliana Soares Ivo Granja
 
Arquitectura karen perez
Arquitectura karen perezArquitectura karen perez
Arquitectura karen perez
 
3227realismo
3227realismo3227realismo
3227realismo
 
Tecnologias existentes na_escola
Tecnologias existentes na_escolaTecnologias existentes na_escola
Tecnologias existentes na_escola
 
disco rigido
disco rigidodisco rigido
disco rigido
 

Similar to 5, workflow function activity

Power flow簡介
Power flow簡介Power flow簡介
Power flow簡介Sky Wu
 
3, workflow in ebs
3, workflow in ebs3, workflow in ebs
3, workflow in ebsted-xu
 
Php Webservers
Php WebserversPhp Webservers
Php Webserverssamon127
 
Performance Monitoring With AOP
Performance Monitoring With AOPPerformance Monitoring With AOP
Performance Monitoring With AOPivannotes
 
Asp.net mvc 培训
Asp.net mvc 培训Asp.net mvc 培训
Asp.net mvc 培训lotusprince
 
Monitor is all for ops
Monitor is all for opsMonitor is all for ops
Monitor is all for ops琛琳 饶
 
作業系統數位教材(劉政雄)(1 9)
作業系統數位教材(劉政雄)(1 9)作業系統數位教材(劉政雄)(1 9)
作業系統數位教材(劉政雄)(1 9)Ying wei (Joe) Chou
 
Coding guideline
Coding guidelineCoding guideline
Coding guideline斯理 衛
 
Spring 2.x 中文
Spring 2.x 中文Spring 2.x 中文
Spring 2.x 中文Guo Albert
 
2, a simple workflow
2, a simple workflow2, a simple workflow
2, a simple workflowted-xu
 
异步编程与浏览器执行模型
异步编程与浏览器执行模型异步编程与浏览器执行模型
异步编程与浏览器执行模型keelii
 
Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩chinafenghao
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩chinafenghao
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩chinafenghao
 
Vlog02 [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
Vlog02  [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...Vlog02  [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
Vlog02 [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...SernHao TV
 

Similar to 5, workflow function activity (20)

Power flow簡介
Power flow簡介Power flow簡介
Power flow簡介
 
3, workflow in ebs
3, workflow in ebs3, workflow in ebs
3, workflow in ebs
 
Php Webservers
Php WebserversPhp Webservers
Php Webservers
 
Php Webservers
Php WebserversPhp Webservers
Php Webservers
 
使用 Controller
使用 Controller使用 Controller
使用 Controller
 
Performance Monitoring With AOP
Performance Monitoring With AOPPerformance Monitoring With AOP
Performance Monitoring With AOP
 
Asp.net mvc 培训
Asp.net mvc 培训Asp.net mvc 培训
Asp.net mvc 培训
 
Monitor is all for ops
Monitor is all for opsMonitor is all for ops
Monitor is all for ops
 
使用 Controller
使用 Controller使用 Controller
使用 Controller
 
作業系統數位教材(劉政雄)(1 9)
作業系統數位教材(劉政雄)(1 9)作業系統數位教材(劉政雄)(1 9)
作業系統數位教材(劉政雄)(1 9)
 
Coding guideline
Coding guidelineCoding guideline
Coding guideline
 
Spring 2.x 中文
Spring 2.x 中文Spring 2.x 中文
Spring 2.x 中文
 
2, a simple workflow
2, a simple workflow2, a simple workflow
2, a simple workflow
 
异步编程与浏览器执行模型
异步编程与浏览器执行模型异步编程与浏览器执行模型
异步编程与浏览器执行模型
 
Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩
 
Vlog02 [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
Vlog02  [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...Vlog02  [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
Vlog02 [eng sub]什麼是controller和如何在asp.net核心中創建controller?-what is controller ...
 
CRUD 綜合運用
CRUD 綜合運用CRUD 綜合運用
CRUD 綜合運用
 
I os 07
I os 07I os 07
I os 07
 

More from ted-xu

11, OCP - awr & alert system
11, OCP - awr & alert system11, OCP - awr & alert system
11, OCP - awr & alert systemted-xu
 
10, OCP - flashback
10, OCP - flashback10, OCP - flashback
10, OCP - flashbackted-xu
 
9, OCP - restore and recovery with rman
9, OCP - restore and recovery with rman9, OCP - restore and recovery with rman
9, OCP - restore and recovery with rmanted-xu
 
8, OCP - backup with rman
8, OCP - backup with rman8, OCP - backup with rman
8, OCP - backup with rmanted-xu
 
5, OCP - oracle storage
5, OCP - oracle storage5, OCP - oracle storage
5, OCP - oracle storageted-xu
 
12, OCP - performance tuning
12, OCP - performance tuning12, OCP - performance tuning
12, OCP - performance tuningted-xu
 
7, business event system
7, business event system7, business event system
7, business event systemted-xu
 
1, workflow intro
1, workflow intro1, workflow intro
1, workflow introted-xu
 
OPM Recipe designer notes
OPM Recipe designer notesOPM Recipe designer notes
OPM Recipe designer notested-xu
 
5, sed
5, sed5, sed
5, sedted-xu
 
4, grep
4, grep4, grep
4, grepted-xu
 
3, regular expression
3, regular expression3, regular expression
3, regular expressionted-xu
 
2, bash synax simplified
2, bash synax simplified2, bash synax simplified
2, bash synax simplifiedted-xu
 
1, shell intro
1, shell intro1, shell intro
1, shell introted-xu
 
6, awk
6, awk6, awk
6, awkted-xu
 
8, lamp
8, lamp8, lamp
8, lampted-xu
 
6, vim
6, vim6, vim
6, vimted-xu
 
5, system admin
5, system admin5, system admin
5, system adminted-xu
 
4, files & folders
4, files & folders4, files & folders
4, files & foldersted-xu
 

More from ted-xu (19)

11, OCP - awr & alert system
11, OCP - awr & alert system11, OCP - awr & alert system
11, OCP - awr & alert system
 
10, OCP - flashback
10, OCP - flashback10, OCP - flashback
10, OCP - flashback
 
9, OCP - restore and recovery with rman
9, OCP - restore and recovery with rman9, OCP - restore and recovery with rman
9, OCP - restore and recovery with rman
 
8, OCP - backup with rman
8, OCP - backup with rman8, OCP - backup with rman
8, OCP - backup with rman
 
5, OCP - oracle storage
5, OCP - oracle storage5, OCP - oracle storage
5, OCP - oracle storage
 
12, OCP - performance tuning
12, OCP - performance tuning12, OCP - performance tuning
12, OCP - performance tuning
 
7, business event system
7, business event system7, business event system
7, business event system
 
1, workflow intro
1, workflow intro1, workflow intro
1, workflow intro
 
OPM Recipe designer notes
OPM Recipe designer notesOPM Recipe designer notes
OPM Recipe designer notes
 
5, sed
5, sed5, sed
5, sed
 
4, grep
4, grep4, grep
4, grep
 
3, regular expression
3, regular expression3, regular expression
3, regular expression
 
2, bash synax simplified
2, bash synax simplified2, bash synax simplified
2, bash synax simplified
 
1, shell intro
1, shell intro1, shell intro
1, shell intro
 
6, awk
6, awk6, awk
6, awk
 
8, lamp
8, lamp8, lamp
8, lamp
 
6, vim
6, vim6, vim
6, vim
 
5, system admin
5, system admin5, system admin
5, system admin
 
4, files & folders
4, files & folders4, files & folders
4, files & folders
 

5, workflow function activity

  • 2. Overview • 前面的工作流中使用了通知节点作为演示, 在实际的情况中, 更多使用到的是另外一种 节点: 函数节点. 函数节点用于执行指定的 plsql函数, 实现特定的业务功能. 将在之前创 建的工作流(wfdemo.wft)基础之上演示函数 节点的使用, 包括如下内容: – 如何定义一个函数节点? – 工作流过程API规范 – 工作流过程运行模式
  • 3. Create a function activity • 使用WFB打开wfdemo.wft文件, 在导航窗口的函数节点下面添加一个新 的节点, 该节点重要的属性有Function Name和Result Type: Function Name 指定为某个plsql存储过程, 格式为<Package>.<Procedure> Result Type 指定为某个Lookup Type名称, 这里选择 WFSTD工作流中的Boolean, 它有两个值 T和F分别表示true和false. Result Type 决定了函数节点之后的会有哪些分支 (T/F), 工作流过程在执行时会返回 Result Type中的某个值, 如果返回T则 流程沿着T分支往下走, F则走F分支.
  • 4. Workflow Procedure - API Standard • 创建函数节点时指定的过程由工作流引擎调用 (Wf_Engine_Util.Function_Call), 它必须遵循如下的格 式: procedure <procedure name> ( itemtype in varchar2, itemkey in varchar2, actid in number, funcmode in varchar2, resultout out varchar2) is... 工作流引擎在执行过程时, 会传入当前的item type, item key, 活动id, 模式以及结果参数, 过程中需要对 funcmode进行判断从而决定具体执行哪些操作. • 参考附件中的wf_function_template.sql, 该脚本包含 了工作流过程的编写模板.
  • 5. Workflow Procedure - Function Mode & Resultout • API标准中的funcmode参数代表节点的运行模式, 有以下几种情况: RUN 运行, 节点在初次运行时模式为RUN CANCEL 取消节点执行, wf_engine.abortprocess会传入此模式 RETRY 重新执行该节点, 在状态监控页面执行retry或者调用 wf_engine.handleerror过程时传入此模式 SKIP 跳过该节点,在状态监控页面执行skip或者调用 wf_engine.handleerror过程时传入此模式 • API标准中的resultout参数用于返回节点的状态和执行结果, 格式为status:result, 比如COMPLETE:T表示节点状态为COMPLETE返回结果为T. 可能的结果有: COMPLETE:<result_code> WAITING DEFERRED:<date> NOTIFIED:<notification_id>:<assigned_user> ERROR:<error_code> 其中result_code会与函数节点指定的result type中的值进行比较, 从而决定流程 下一步的走向.
  • 6. Workflow Procedure - wfdemo.find_approver • wfdemo.find_approver用于根据申请人(LEAVEREQUSTER)工作流属性, 找到该 申请人的上级主管, 并设置为审批人(LEAVEREQAPPROVER)工作流属性. 需要 建一个plsql包wfdemo还它下面的子过程find_approver, 代码如下(可以在附 件中找到): create or replace package body wfdemo as procedure find_approver(itemtype in varchar2, itemkey in varchar2, actid in number, funcmode in varchar2, resultout out varchar2) as v_manager VARCHAR2(30); v_employee VARCHAR2(30); begin IF funcmode in ('RUN', 'RETRY') THEN v_employee := wf_engine.getItemAttrText(itemtype, itemkey, 'LEAVEREQUSTER') ;
  • 7. Workflow Procedure - wfdemo.find_approver select c.user_name into v_manager from fnd_user a, per_all_assignments_f b, fnd_user c where a.user_name = v_employee and a.employee_id = b.person_id and b.effective_end_date > sysdate and b.supervisor_id = c.employee_id; END IF; IF v_manager is null THEN resultout := 'COMPLETE:F'; ELSE wf_engine.SetItemAttrText(itemtype, itemkey, 'LEAVEREQAPPROVER', v_manager); resultout := 'COMPLETE:T'; END IF; EXCEPTION WHEN OTHERS THEN resultout := 'ERROR:' || sqlcode; WF_CORE.CONTEXT('wfdemo', 'find_approver', itemtype, itemkey, to_char(sqlcode)); raise; end wfdemo;
  • 8. Run - Normal • 添加函数节点之后流程看起来如下, 如果找 到了审批人则向他发送通知, 如果没有则结 束流程: • 在WAP页面中启动该流程并将申请人设置为 OPERATIONS:
  • 9. Run - Normal • 在状态监控页面查看该流程的运行情况, 如 下: 可以看到函数节点运行完成, 并且已经发出 FYA通知, 使用如下sql可查找通知的收件人: select * from wf_item_activity_statuses where item_type = 'LEAVEREQ' and item_key = '6‘ 接下来的流程就于之前的一样了.
  • 10. Run - Error • 如果在启动流程时没有指定申请人工作流参 数(LEAVEREQUSTER), 那么函数节点在执行过 程中会因为select...into语句抛出no data found 异常, 进而导致节点出错, 如下:
  • 11. END