2014-06-01
BaoXinjian
一、摘要
Oracle
Workflow可以发送Form、Document、URL链接,经常遇到,下文介绍Form和Document如何发送
Attribue Type
- Form
- Document
- URL
二、案例 - 发送Document Link链接
需求:发送Document文件
Step1. 建立一个Message,包含两个Attribute: Document和Form
Step2. 在BXJ_DOCUMENT调用两个Function
Step2.1. Get_Document用以将创建Form链接
1 PROCEDURE GET_DOCUMENT(itemtype IN VARCHAR2,
2
3 itemkey IN VARCHAR2,
4
5 actid IN NUMBER,
6
7 funcmode IN VARCHAR2,
8
9 resultout OUT NOCOPY VARCHAR2) IS
10
11 BEGIN
12
13 设置Document类型Attribute,逐条反应PO Line
14
15 wf_engine.setitemattrtext(itemtype => itemtype,
16
17 itemkey => itemkey,
18
19 aname => ‘DOCUMENT_DETAILS‘,
20
21 avalue => ‘PLSQLCLOB:test_pkg.GET_DOCUMENT_DETAILS/‘ ||itemtype || ‘:‘ ||itemkey);
22
23 END;
Step2.2. Get_Document用以将创建Form链接
1 PROCEDURE GET_DOCUMENT_DETAILS(document_id IN VARCHAR2,
2
3 display_type IN VARCHAR2,
4
5 document IN OUT CLOB,
6
7 document_type IN OUT VARCHAR2) IS
8
9 l_item_type wf_items.item_type%TYPE;
10
11 l_item_key wf_items.item_key%TYPE;
12
13 l_document VARCHAR2(32000) := ‘‘;
14
15 l_clob_document CLOB;
16
17 CURSOR cur_po_lines IS
18
19 SELECT line_num,
20
21 purchase_basis,
22
23 item_description,
24
25 unit_meas_lookup_code,
26
27 unit_price
28
29 FROM po_lines_all
30
31 WHERE po_header_id = 37566;
32
33 BEGIN
34
35 --1. 初始化
36
37 l_item_type := substr(document_id, 1, instr(document_id, ‘:‘) - 1);
38
39 l_item_key := substr(document_id,instr(document_id, ‘:‘) + 1,length(document_id) - 2);
40
41 --2. 写PO line资料
42
43 l_document := ‘<table border=1>‘;
44
45 FOR r_po_lines IN cur_po_lines LOOP
46
47 l_document := l_document||‘<tr>‘;
48
49 l_document := l_document||‘<td>‘||r_po_lines.line_num||‘</td>‘;
50
51 l_document := l_document||‘<td>‘||r_po_lines.purchase_basis||‘</td>‘;
52
53 l_document := l_document||‘<td>‘||r_po_lines.item_description||‘</td>‘;
54
55 l_document := l_document||‘<td>‘||r_po_lines.unit_meas_lookup_code||‘</td>‘;
56
57 l_document := l_document||‘<td>‘||r_po_lines.unit_price||‘</td>‘;
58
59 l_document := l_document||‘</tr>‘;
60
61 END LOOP;
62
63 l_document := l_document||‘</table>‘;
64
65 --3. 通过dbms_lob讲字符串写到workflow中
66
67 dbms_lob.createtemporary(lob_loc => l_clob_document,
68
69 cache => TRUE,
70
71 dur => dbms_lob.session);
72
73 dbms_lob.OPEN(lob_loc => l_clob_document,
74
75 open_mode => dbms_lob.lob_readwrite);
76
77 wf_notification.writetoclob(l_clob_document, l_document); --追加,可不断写
78
79 dbms_lob.append(document, l_clob_document);
80
81 IF (dbms_lob.ISOPEN(l_clob_document) = 1) THEN
82
83 dbms_lob.CLOSE(l_clob_document);
84
85 dbms_lob.freetemporary(l_clob_document);
86
87 END IF;
88
89 END;
Test1.
在BXJ_DOCUMENT调用两个Function
三、案例 - 发送Form Link链接
需求:发送Document文件
1.建立测试用的Package
2. 测试
(1).
打开Form连接
(2). 打开连接后自动查询PO
Step1.建立一个Message,包含两个Attribute: Document和Form
Step2.建立测试用的Package
1 PROCEDURE GET_DOCUMENT(itemtype IN VARCHAR2 ,
2
3 itemkey IN VARCHAR2 ,
4
5 actid IN NUMBER ,
6
7 funcmode IN VARCHAR2 ,
8
9 resultout OUT NOCOPY VARCHAR2) IS13 l_open_form varchar2(200 );
14
15 l_document_id varchar2(25 );
16
17 BEGIN
18
21 SELECT po_header_id
22
23 INTO l_document_id
24
25 FROM po_headers_all
26
27 WHERE segment1 = ‘GP0008720MNC‘ ;
28
33 l_open_form := ‘PO_POXPOEPO:PO_HEADER_ID="‘ || l_document_id || ‘"‘ ||
34
35 ‘ ACCESS_LEVEL_CODE="MODIFY"‘ ||
36
37 ‘ POXPOEPO_CALLING_FORM="POXSTNOT"‘ ;
38
39
40
41 DBMS_OUTPUT.PUT_LINE( ‘l_open_form-->‘ || l_open_form);
42
45 wf_engine.setitemattrtext(itemtype => itemtype,
46
47 itemkey => itemkey,
48
49 aname => ‘OPEN_FORM_COMMAND‘,
50
51 avalue => l_open_form);
52
53
54
55 resultout := wf_engine.eng_completed || ‘:‘ || ‘Y‘ ;
56
59 return;
60
61 END;
Test1. 测试
Test1.1. 打开Form连接
Test1.2. 打开连接后自动查询PO
Thanks and Regards