添加并发请求PDF到工作流附件

本节实现将并发请求输出PDF文件添加到工作流附件

省去了工作流中其他部分,只对附件部分介绍

1.       建立一个类型为Document的Attribute

 

2.       通知界面上创建附件链接

找到Notification下对应的Message;

 

将第一步中创建的Attribute复制到这个Message下面:

 

修改复制后的Attribute的属性

 

至此,Notification页面便存在一个附件链接。

3.       工作流中为附件Attribute赋值

在工作流执行过程中,代码实现对attribute进行赋值:

使用API:

wf_engine.setitemattrdocument

(itemtype        => l_itemtype,

itemkey         => l_itemkey,

aname           => 'TCL_PDF_ATTACH',

documentid      =>    'PLSQLBLOB:KS_OM_TEMP_CREDIT_LIMIT_PKG.READ_REPORT/KSOMTCLA:' || l_itemkey || ':'  || l_tcl_pdf

);

 

此处API中documentid  参数的固定格式为以下三种:

PLSQL:<procedure>/<document_identifier>;

PLSQLCLOB:<procedure>/<document_identifier>;

PLSQLBLOB:<procedure>/<document_identifier>;

4.       实现读取PDF文件的Procedure

该procedure的传入参数存在固定的格式:

/*

procedure <procedure name>

(document_id in varchar2,

display_type in varchar2,

document in out nocopy varchar2,

document_type in out nocopy varchar2);

 

 

procedure <procedure name>

(document_id in varchar2,

display_type in varchar2,

document in out nocopy clob,

document_type in out nocopy varchar2);

 

procedure <procedure name>

(document_id in varchar2,

display_type in varchar2,

document in out nocopy blob,

document_type in out nocopy varchar2);

 */

读取文件的代码:

PROCEDURE read_report (

      document_id     IN       VARCHAR2,

      display_type    IN       VARCHAR2,

      document        IN OUT   BLOB,

      document_type   IN OUT   VARCHAR2

   )

   IS

      lfile_name   VARCHAR2 (240); --读取的目标文件名

      lfile        BFILE;

   BEGIN

/*从传入的参数中提取目标文件的名称*/

SELECT SUBSTR (document_id, INSTR (document_id, ':', -1) + 1)

        INTO lfile_name

        FROM DUAL;

 

/*BFILENAME是读取目录KS_FND_CONC_OUT下的文件lfile_name*/

      lfile := BFILENAME ('KS_FND_CONC_OUT', lfile_name);

      DBMS_LOB.OPEN (lfile, DBMS_LOB.lob_readonly);

      DBMS_LOB.OPEN (document, DBMS_LOB.lob_readwrite);

      document_type := 'application/pdf';

/*将lfile写入document*/

      DBMS_LOB.loadfromfile (dest_lob => document,

                                 src_lob => lfile,

                                 amount => DBMS_LOB.getlength (lfile)

                                );

      DBMS_LOB.CLOSE (lfile);

      DBMS_LOB.CLOSE (document);

END read_report;

posted @ 2013-12-30 15:46  Aston Martin - Hand  阅读(548)  评论(0编辑  收藏  举报