82550698 2014-11-21
当我们发送一个审批请求时,如果审批人在通知页面就能看到要审批的数据信息就不用登录到系统中查看相关信息了,可直接在通知中审批掉。
相关代码如下:
创建package:
create or replace package QTESTWF as
procedure start_workflow (item_id in number,user_name in varchar2) ;
procedure get_line_detail(document_id in varchar2,
display_type in varchar2,
document in out NOCOPY varchar2,
document_type in out NOCOPY varchar2);
end QTESTWF;
/
create or replace package body QTESTWF as
procedure start_workflow (item_id in number,user_name in varchar2)
IS
l_asset_number VARCHAR2(100) :='D';
l_ItemType varchar2(100) := 'QTESTWF';--'QTESTWF';--流程内部名称
l_ItemKey varchar2(100) ;
v_url varchar2(1000) := 'http://61.144.28.248';
P_CONTENT VARCHAR2(3000) :='测试工作流';
begin
select QTESTWF_SEQ.nextval into l_ItemKey from dual;--获取序列号
wf_engine.createProcess(ItemType => l_ItemType, --流程名
ItemKey => l_ItemKey, --项目关键字
process => 'QTESTWF', --process内部名称
user_key => l_ItemKey, --用户关键字
owner_role => 'D' --流程责任人
);
--以下是参数
wf_engine.SetItemAttrText(itemtype => l_itemtype,
itemkey => l_itemkey,
aname => 'USERNAME',--对应的都是内部名称
avalue => l_asset_number);
wf_engine.SetItemAttrText(itemtype => l_itemtype,
itemkey => l_itemkey,
aname => 'P_CONTENT',
avalue => P_CONTENT);
wf_engine.StartProcess(ItemType => l_ItemType, ItemKey => l_ItemKey);
commit;
end start_workflow;
----------------------------------------------------------------------------------------
--Get workflow attribute
----------------------------------------------------------------------------------------
procedure get_line_detail(document_id in varchar2,
display_type in varchar2,
document in out NOCOPY varchar2,
document_type in out NOCOPY varchar2) is
l_document VARCHAR2(32000) := '';
l_user_name varchar2(30);
l_org_id number := fnd_profile.value('ORG_ID');
max_lines_dsp NUMBER := 20;
l_line_count number :=0;
v_url_str varchar2(254);
v_req_url_str varchar2(254);
NL VARCHAR2(1) := fnd_global.newline;
l_item_type wf_items.item_type%TYPE;
l_item_key wf_items.item_key%TYPE;
l_doc_type varchar2(40);
cursor c_test is
select * from CMCC_FLEXFIELD_TEST ;
begin
-- max_lines_dsp:= to_number(fnd_profile.value('PO_NOTIF_LINES_LIMIT'));
if max_lines_dsp is NULL then
max_lines_dsp := 20;
end if;
l_item_type := substr(document_id, 1, instr(document_id, ':') - 1);
l_item_key := substr(document_id, instr(document_id, ':') + 1,
length(document_id) - 2);
l_user_name := wf_engine.GetItemAttrNumber(itemtype => l_item_type,
itemkey => l_item_key,
aname => 'USERNAME');
l_document := '<table border="1" width="100%">' || '<caption>' ||
'<p align="center">' || l_doc_type || '测试信息</p>' ||
'</caption>' || '<tr>' || '<td width="12%">' ||
'<p align="center">名字</td>' || '<td width="12%">' ||
'<p align="center">Item ID</td>' ||
'<td width="12%">组织</td>' ||
'<td width="13%">段1</td>' ||
'<td width="13%">段2</td>' ||
'<td width="13%">段3</td>' || '</tr>';
for c1 in c_test loop
l_document := l_document || '<tr>' || '<td width="12%">' ||
c1.username || '</td>' ||
'<td width="12%">' || c1.inventory_item_id||
'</td>' || '<td width="12%">' ||
c1.organization_id || '</td>' ||
'<td width="12%">' || c1.segment1||
'</td>' || '<td width="13%">' ||
c1.segment2|| '</td>' ||'<td width="13%">'||
c1.segment3 || '</td>' ||
'</tr>';
end loop;
l_document := l_document ||'</table>';
l_document := l_document ||'<p> </p>';
l_document := l_document ||'<table border="1" width="100%">' || '<caption>' ||
'<p align="center">' || l_doc_type || '行内容</p>' ||
'</caption>' || '<tr>' || '<td width="12%">' ||
'<p align="center">事务类型</td>' || '<td width="12%">' ||
'<p align="center">任务编号</td>' ||
'<td width="12%">支出类型</td>' ||
'<td width="13%">帐户别名</td>' ||
'</tr>';
l_document := l_document || '</table>';
l_document := l_document ||'<p> </p>';
l_document := l_document ||'<table border="1" width="100%">' || '<caption>' ||
'<p align="center">' || l_doc_type || '物料明细</p>' ||
'</caption>' || '<tr>' || '<td width="12%">' ||
'<p align="center">行号</td>' || '<td width="12%">' ||
'<p align="center">物料编码</td>' ||
'<td width="12%">物料说明</td>' ||
'<td width="13%">需求数量</td>' ||
'<td width="13%">单位</td>' ||
'</tr>';
l_line_count :=0;
l_document := l_document || '</table>';
document:=l_document;
end get_line_detail;
end QTESTWF;
/
2,调用workflow:
Declare
l_asset_number VARCHAR2(100) :='SYSADMIN';
l_ItemType varchar2(100) := 'QTESTWF';--'QTESTWF';--流程内部名称
l_ItemKey varchar2(100) ;
v_url varchar2(1000) := 'http://61.144.28.248';
P_CONTENT VARCHAR2(32000) :='测试工作流';
begin
select QTESTWF_SEQ.nextval into l_ItemKey from dual;--获取序列号
wf_engine.createProcess(ItemType => l_ItemType, --流程名
ItemKey => l_ItemKey, --项目关键字
process => 'QTESTWF', --process内部名称
user_key => l_ItemKey, --用户关键字
owner_role => 'D' --流程责任人
);
--以下是参数
wf_engine.SetItemOwner(itemtype => l_itemtype,
itemkey => l_itemkey,
owner => 8439);
wf_engine.SetItemAttrText(itemtype => l_itemtype,
itemkey => l_itemkey,
aname => 'USERNAME',--对应的都是内部名称
avalue => l_asset_number);
wf_engine.SetItemAttrText(itemtype => l_itemtype,
itemkey => l_itemkey,
aname => 'SEND_EMPLOYEE',
avalue => 'D');
wf_engine.SetItemAttrText(itemtype => l_itemtype,
itemkey => l_itemkey,
aname => 'OPEN_FORM',
avalue => 'CTESTHM:inventory_item_id=2'); --带参数调用FORM
--'QINVISSRAP:X_HEADER_id="'||to_char(l_header_id)||'"MFG_ORGANIZATION_id="'||to_char(l_organization_id)||'"';
wf_engine.SetItemAttrText(itemtype => l_itemtype,
itemkey => l_itemkey,
aname => 'P_SUBJECT',
avalue => '通知汇总');
wf_engine.SetItemAttrText (itemtype => l_itemtype,
itemkey => l_itemkey,
aname => 'P_CONTENT',
avalue => 'plsql:QTESTWF.get_line_detail/'||l_itemtype||':'||l_itemkey);
wf_engine.StartProcess(ItemType => l_ItemType, ItemKey => l_ItemKey);
commit;
end ;