REM dbdrv: sql ~PROD ~PATH ~FILE none none none package &phase=plb \
REM dbdrv: checkfile:~PROD:~PATH:~FILE
/*=======================================================================+
| Copyright (c) 1998 Oracle Corporation Redwood Shores, California, USA|
| All rights reserved. |
+=======================================================================+
| FILENAME
| wfrtgb.pls
| DESCRIPTION
| PL/SQL body for package: WF_ROUTE
| MODIFICATION LOG:
| 06 JUN 2001 JWSMITH BUG 1819232 ADA enhancement
| - Added summary attr for table tag
| - Added alt attr for IMG tag
| - Added ID attr for TD tag
| - Added label for form input & select fields
| 02 JAN 2002 JWSMITH BUG 2001012 - Increased owner, curuser, admin_role,
| l_username, rname, owner, forwardee, t_user,
| username to varchar2(320),display_name 360
*=======================================================================*/
SET VERIFY OFF
WHENEVER SQLERROR EXIT FAILURE ROLLBACK;
WHENEVER OSERROR EXIT FAILURE ROLLBACK;
set arraysize 10;
set scan off;
CREATE OR REPLACE PACKAGE BODY WF_ROUTE AS
/* $Header: wfrtgb.pls 26.10 2005/03/11 06:25:10 anachatt ship $ */
--
-- Error (PRIVATE)
-- Print a page with an error message.
-- Errors are retrieved from these sources in order:
-- 1. wf_core errors
-- 2. Oracle errors
-- 3. Unspecified INTERNAL error
--
procedure Error
as
error_name varchar2(30);
error_message varchar2(2000);
error_stack varchar2(32000);
begin
htp.htmlOpen;
htp.headOpen;
htp.title(wf_core.translate('ERROR'));
htp.headClose;
begin
wfa_sec.Header(background_only=>TRUE);
exception
when others then
htp.bodyOpen;
end;
htp.header(nsize=>1, cheader=>wf_core.translate('ERROR'));
wf_core.get_error(error_name, error_message, error_stack);
error_message:=wf_core.substitutespecialchars(error_message);
error_stack:=wf_core.substitutespecialchars(error_stack);
if (error_name is not null) then
htp.p(error_message);
else
htp.p(sqlerrm);
end if;
htp.hr;
htp.p(wf_core.translate('WFENG_ERRNAME')||': '||error_name);
htp.br;
htp.p(wf_core.translate('WFENG_ERRSTACK')||': '||
replace(error_stack,wf_core.newline,'
'));
wfa_sec.Footer;
htp.htmlClose;
end Error;
--
-- RuleOwner (PRIVATE)
-- Return role owning this rule, and validate rule exists
-- IN
-- ruleid - rule id
-- RETURNS
-- Owning role
--
function RuleOwner(
ruleid in number)
return varchar2
is
owner varchar2(320);
begin
begin
select WRR.ROLE
into owner
from WF_ROUTING_RULES WRR
where WRR.RULE_ID = RuleOwner.ruleid;
exception
when no_data_found then
Wf_Core.Token('RULE', to_char(ruleid));
Wf_Core.Raise('WFRTG_INVALID_RULE');
end;
return owner;
exception
when others then
wf_core.context('Wf_Route', 'RuleOwner', to_char(ruleid));
raise;
end RuleOwner;
--
-- Authenticate (PRIVATE)
-- Authenticate current user has access to rules for this user.
-- Exception raised if access is denied.
-- IN
-- user - user to check
-- RETURNS
-- Authenticated username
-- (username, or current user if username passed in is null)
--
function Authenticate(
user in varchar2)
return varchar2
is
curuser varchar2(320);
admin_role varchar2(320);
begin
-- Get current user
Wfa_Sec.GetSession(curuser);
-- If user is null, must be for current user
if (user is null) then
return(curuser);
end if;
-- If admin granted to current user,
-- grant access and pretend to be
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(curuser, admin_role)) then
return(user);
end if;
-- Otherwise current user must match the user checking
if (curuser <> user) then
Wf_Core.Token('CURUSER', curuser);
Wf_Core.Token('USER', user);
Wf_Core.Raise('WFRTG_ACCESS_USER');
end if;
return(user);
exception
when others then
wf_core.context('Wf_Route', 'Authenticate', user);
raise;
end Authenticate;
--
-- GetAttrValue (PRIVATE)
-- Get value of response rule attribute
-- IN
-- ruleid - routing rule id
-- attrname - attribute name
-- OUT
-- tvalue - text value
-- nvalue - number value
-- dvalue - date value
-- RETURNS
-- False if no attr not defined for this rule
--
function GetAttrValue(
ruleid in number,
attrname in varchar2,
tvalue out varchar2,
nvalue out number,
dvalue out date)
return boolean
is
begin
select WRRA.TEXT_VALUE, WRRA.NUMBER_VALUE, WRRA.DATE_VALUE
into tvalue, nvalue, dvalue
from WF_ROUTING_RULE_ATTRIBUTES WRRA
where WRRA.RULE_ID = GetAttrValue.ruleid
and WRRA.NAME = GetAttrValue.attrname;
return(TRUE);
exception
when no_data_found then
return(FALSE);
when others then
wf_core.context('Wf_Route', 'GetAttrValue', to_char(ruleid), attrname);
raise;
end GetAttrValue;
--
-- GetLookupMeaning (PRIVATE)
-- Retrieve displayed value of lookup
-- IN
-- ltype - lookup type
-- lcode - lookup code
-- RETURNS
-- Displayed meaning of lookup code
--
function GetLookupMeaning(
ltype in varchar2,
lcode in varchar2)
return varchar2
is
meaning varchar2(80);
begin
select WL.MEANING
into meaning
from WF_LOOKUPS WL
where WL.LOOKUP_TYPE = GetLookupMeaning.ltype
and WL.LOOKUP_CODE = GetLookupMeaning.lcode;
return(meaning);
exception
when no_data_found then
return(lcode);
when others then
wf_core.context('Wf_Route', 'GetLookupMeaning', ltype, lcode);
raise;
end GetLookupMeaning;
--
-- GetDisplayValue (PRIVATE)
-- Get displayed value of a response attribute field
-- IN
-- type - field type (VARCHAR2, NUMBER, DATE, LOOKUP, URL)
-- format - field format (depends on type)
-- tvalue - text value
-- nvalue - number value
-- dvalue - date value
-- RETURNS
-- Displayed value
--
function GetDisplayValue(
type in varchar2,
format in varchar2,
tvalue in varchar2,
nvalue in number,
dvalue in date)
return varchar2
is
l_username VARCHAR2(320);
value varchar2(2000);
l_document_attributes fnd_document_management.fnd_document_attributes;
begin
-- Check session and current user
wfa_sec.GetSession(l_username);
l_username := upper(l_username);
if (type = 'VARCHAR2') then
value := tvalue;
elsif (type = 'NUMBER') then
if (format is null) then
value := to_char(nvalue);
else
value := to_char(nvalue, format);
end if;
elsif (type = 'DATE') then
if (format is null) then
value := to_char(dvalue);
else
value := to_char(dvalue, format);
end if;
elsif (type = 'LOOKUP') then
value := GetLookupMeaning(format, tvalue);
elsif (type = 'URL') then
value := tvalue;
elsif (type = 'DOCUMENT') then
/*
** If the default value is a dm document then go get the
** title from the DM system and place it in the field. If
** its a plsql doc then just put the default value in the field
*/
IF (SUBSTR(tvalue, 1, 3) = 'DM:') THEN
/*
** get the document name
*/
fnd_document_management.get_document_attributes(l_username,
tvalue,
l_document_attributes);
value := l_document_attributes.document_name;
ELSE
-- Default to return text value unchanged
value := tvalue;
END IF;
else
-- Default to return text value unchanged
value := tvalue;
end if;
return(value);
exception
when others then
wf_core.context('Wf_Route', 'GetDisplayWindow', type, format,
tvalue, to_char(nvalue), to_char(dvalue));
raise;
end GetDisplayValue;
--
--
-- GetRole (PRIVATE)
-- Produce a Role response field
procedure GetRole(
name in varchar2,
dvalue in varchar2,
seq in varchar2 )
is
len pls_integer;
l_message varchar2(240) := wfa_html.replace_onMouseOver_quotes(wf_core.translate ('WFPREF_LOV'));
-- variable for LOV
l_url varchar2(1000);
l_media varchar2(240) := wfa_html.image_loc;
l_icon varchar2(30) := 'FNDILOV.gif';
l_text varchar2(30) := '';
realname varchar2(360) := null;
s0 varchar2(2000);
--
begin
-- Draw field
htp.formHidden('h_fnames', name||'#ROLE#');
-- always print the display field as null
htp.formHidden('h_fvalues', dvalue);
-- get the display name
wf_directory.GetRoleInfo(dvalue, realname, s0, s0, s0, s0);
-- add LOV here: Note:bottom is name of frame.
-- Note: The REPLACE function replaces all the space characters with
-- the proper escape sequence.
l_url := 'javascript:fnd_open_dm_display_window('||''''||
REPLACE('wf_lov.display_lov?p_lov_name='||'owner'||
'&p_display_name='||'WFA_FIND_USER'||
'&p_validation_callback=wfa_html.wf_user_val'||
'&p_dest_hidden_field=top.opener.parent.document.CREATE_RULE.h_fvalues['||seq||'].value'||
'&p_current_value=top.opener.parent.document.CREATE_RULE.h_fdocnames['||seq||'].value'||
'&p_display_key='||'Y'||
'&p_dest_display_field=top.opener.parent.document.CREATE_RULE.h_fdocnames['||seq||'].value',
' ', '%20')||''''||',500,500)';
-- print everything together so ther is no gap.
htp.tabledata(htf.formText(cname=>'h_fdocnames',
csize=>30,
cmaxlength=>240,
cvalue=>realname,
cattributes=>'id="i_attr'||seq||'"')||
''||
'',
cattributes=>'id=""');
exception
when others then
wf_core.context('Wf_route', 'GetRole', name, seq);
raise;
end GetRole;
--
-- GetLookup (PRIVATE)
-- Produce a lookup response field
-- IN
-- name - field name
-- value - default value (lookup code)
-- format - lookup type
-- submit - flag include a submit button for result field
--
-- MODIFICATION LOG:
-- 06-JUN-2001 JWSMITH BUG 1819232 - added ID attrib for TD tag for ADA
--
procedure GetLookup(
name in varchar2,
value in varchar2,
format in varchar2,
submit in boolean,
seq in varchar2)
as
cursor lookup_codes(p_lookup_type varchar2) is
select MEANING, LOOKUP_CODE
from WF_LOOKUPS
where LOOKUP_TYPE = p_lookup_type
order by MEANING;
template varchar2(4000);
begin
-- always print the display field as null
htp.formHidden('h_fdocnames', '');
-- Create hidden field and select list
template := htf.formHidden('h_fnames', name||'#LOOKUP#'||format)||
wf_core.newline||
htf.formSelectOpen('h_fvalues',
cattributes=>'id="i_attr'||seq||'"');
-- Add all lookups to select list
for i in lookup_codes(format) loop
if (i.lookup_code = value) then
template := template||wf_core.newline||
htf.formSelectOption(i.meaning, 'SELECTED');
else
template := template||wf_core.newline||
htf.formSelectOption(i.meaning);
end if;
end loop;
template := template||wf_core.newline||htf.formSelectClose;
if (not submit) then
-- Draw a normal field
htp.tableData(template, 'left',cattributes=>'id=""');
else
-- Draw a submit-style field for the result.
-- Leave TableData open so reassign button can be added to same cell.
htp.p('
'
||wf_core.newline||template);
htp.formSubmit('Submit', wf_core.translate('SUBMIT'), 'NOBORDER');
end if;
exception
when others then
wf_core.context('Wf_Route', 'GetLookup', name, value, format, seq);
raise;
end GetLookup;
-- GetDocument (PRIVATE)
-- Prints the document text field with the DM lov button.
Procedure GetDocument (name in varchar2,
format in varchar2,
dvalue in varchar2,
index_num in varchar2) is
l_username varchar2(320); -- Username to query
l_callback_URL varchar2(4000);
l_attach_URL varchar2(4000);
begin
htp.formHidden('h_fnames', name||'#DOCUMENT#'||format);
htp.formHidden('h_fvalues', null);
-- Set the destination field name for the document id
fnd_document_management.set_document_id_html (
null,
'CREATE_RULE',
'h_fvalues['||index_num||']',
'h_fdocnames['||index_num||']',
l_callback_url);
-- Check session and current user
wfa_sec.GetSession(l_username);
l_username := upper(l_username);
fnd_document_management.get_launch_attach_url (
l_username,
l_callback_url,
TRUE,
l_attach_url);
-- document field
htp.tableData(cvalue=>htf.formText(cname=>'h_fdocnames', csize=>32,
cmaxlength=>60,
cvalue=>dvalue,
cattributes=>'id="i_attr'||index_num||'"')
||'   '||l_attach_URL,
calign=>'Left',
cattributes=>'id=""');
exception
when others then
wf_core.context('Wf_route', 'GetDocument', name, format, dvalue);
raise;
end GetDocument;
--
-- GetField (PRIVATE)
-- Produce a varchar2/number/date response field
-- IN
-- name - field name
-- type - field type (VARCHAR2, NUMBER, DATE)
-- format - format mask
-- dvalue - default value
-- index_num - for ada enhancement
--
procedure GetField(
name in varchar2,
type in varchar2,
format in varchar2,
dvalue in varchar2,
index_num in varchar2)
is
len number;
begin
-- Figure field len
if (type = 'VARCHAR2') then
len := nvl(to_number(format), 2000);
else
len := 62;
end if;
-- Draw field
htp.formHidden('h_fnames', name||'#'||type||'#'||format);
-- always print the display field as null
htp.formHidden('h_fdocnames', '');
if (len <= 80) then
-- single line field
htp.tableData(
cvalue=>htf.formText(cname=>'h_fvalues',
csize=>len,
cmaxlength=>len,
cvalue=>dvalue,
cattributes=>'id="i_attr'||index_num||'"'),
calign=>'Left',
cattributes=>'id=""');
else
-- multi line field
htp.tableData(
cvalue=>htf.formTextareaOpen2(
cname=>'h_fvalues',
nrows=>2,
ncolumns=>65,
cwrap=>'SOFT',
cattributes=>'id="i_attr'||index_num||'" maxlength= '||to_char(len))
|| dvalue|| htf.formTextareaClose,
calign=>'Left',
cattributes=>'id=""');
end if;
exception
when others then
wf_core.context('Wf_Route', 'GetField', name, type, format, dvalue,
index_num);
raise;
end GetField;
--
-- ValidateRole (PRIVATE)
-- Validate that role is valid internal or display name
-- IN
-- role - role to check
-- RETURNS
-- Internal name of role
--
function ValidateRole(
role in varchar2)
return varchar2
is
dummy number;
rname varchar2(320); -- Internal name of role
role_info_tbl wf_directory.wf_local_roles_tbl_type;
begin
-- Look first for internal name
rname := upper(ValidateRole.role);
Wf_Directory.GetRoleInfo2(rname,role_info_tbl);
if (role_info_tbl(1).name is not null) then
return(rname);
end if;
-- Look for display_name
begin
-- Very costly statement
select NAME
into rname
from WF_ROLES
where DISPLAY_NAME = ValidateRole.role;
-- Found, return internal name
return(rname);
exception
when no_data_found then
-- Not displayed or internal role name, error
wf_core.token('ROLE', role);
wf_core.raise('WFNTF_ROLE');
end;
exception
when others then
wf_core.context('Wf_Route', 'ValidateRole', role);
raise;
end ValidateRole;
--
-- StringToDate (PRIVATE)
-- Convert string to date, taking optional time into account
-- NOTE
-- Makes the following assumptions:
-- 1. Default NLS_DATE_FORMAT does not have a time component,
-- and does not contain any ':' characters.
-- 2. Dstring will be in one of the following formats:
-- NLS_DATE_FORMAT
-- NLS_DATE_FORMAT||' HH24:MI'
-- NLS_DATE_FORMAT||' HH24:MI:SS'
-- IN
-- dstring - date as string
-- RETURNS
-- Date as date
--
function StringToDate(
dstring in varchar2)
return date
is
colon1 number;
colon2 number;
space number;
datebuf date;
begin
-- Check for time component
colon1 := instr(dstring, ':', 1, 1);
if (colon1 = 0) then
-- No time component, do a straight conversion
datebuf := to_date(dstring);
else
-- Look for last space in string (not counting trailers).
-- Using this as dividing point, get date portion of string
-- without time.
space := instr(rtrim(dstring), ' ', -1, 1);
datebuf := to_date(substr(dstring, 1, space-1));
-- Append time component
colon2 := instr(dstring, ':', 1, 2);
if (colon2 = 0) then
-- Assume HH24:MI time component
datebuf := to_date(to_char(datebuf, 'YYYY/MM/DD')||
to_char(to_date(substr(dstring, space),
' HH24:MI'),
' HH24:MI'),
'YYYY/MM/DD HH24:MI');
else
-- Assume HH24:MI:SS time component
datebuf := to_date(to_char(datebuf, 'YYYY/MM/DD')||
to_char(to_date(substr(dstring, space),
' HH24:MI:SS'),
' HH24:MI:SS'),
'YYYY/MM/DD HH24:MI:SS');
end if;
end if;
return(datebuf);
exception
when others then
wf_core.context('Wf_Route', 'StringToDate', dstring);
raise;
end StringToDate;
--
-- SetAttribute (PRIVATE)
-- Set routing response attributes
-- IN
-- ruleid - routing rule id
-- attr_name_type - attribute name#type#format
-- attr_value - attribute value
--
procedure SetAttribute(
ruleid in number,
attr_name_type in varchar2,
attr_value in varchar2,
attr_doc_name in varchar2)
as
first number;
second number;
attr_type varchar2(8);
attr_name varchar2(30);
attr_fmt varchar2(240);
tvalue varchar2(2000) := '';
nvalue number := '';
dvalue date := '';
begin
-- Parse out name#type#format
first := instr(attr_name_type, '#', 1);
second := instr(attr_name_type, '#', 1, 2);
attr_name := substr(attr_name_type, 1, first-1);
attr_type := substr(attr_name_type, first+1, second-first-1);
attr_fmt := substr(attr_name_type, second+1,
length(attr_name_type)-second);
if (attr_type = 'DATE') then
if (attr_fmt is not null) then
dvalue := to_date(attr_value, attr_fmt);
else
dvalue := to_date(attr_value);
end if;
elsif (attr_type = 'NUMBER') then
if (attr_fmt is not null) then
nvalue := to_number(attr_value, attr_fmt);
else
nvalue := to_number(attr_value);
end if;
elsif (attr_type = 'LOOKUP') then
-- Decode lookup meaning to code
begin
select WL.LOOKUP_CODE
into tvalue
from WF_LOOKUPS WL
where Wl.LOOKUP_TYPE = SetAttribute.attr_fmt
and MEANING = SetAttribute.attr_value;
exception
when no_data_found then
wf_core.token('TYPE', attr_fmt);
wf_core.token('CODE', attr_value);
wf_core.raise('WFSQL_LOOKUP_CODE');
end;
elsif (attr_type = 'ROLE') then
-- Decode role to internal name
tvalue := attr_value;
wfa_html.validate_display_name (attr_doc_name, tvalue);
else
-- VARCHAR2 or misc values all use text
tvalue := attr_value;
end if;
-- Update/Insert attributes table with new values
update WF_ROUTING_RULE_ATTRIBUTES WRRA set
TEXT_VALUE = SetAttribute.tvalue,
NUMBER_VALUE = SetAttribute.nvalue,
DATE_VALUE = SetAttribute.dvalue
where WRRA.RULE_ID = SetAttribute.ruleid
and WRRA.NAME = SetAttribute.attr_name;
if (sql%rowcount = 0) then
-- Insert missing attribute row
insert into WF_ROUTING_RULE_ATTRIBUTES (
RULE_ID,
NAME,
TYPE,
TEXT_VALUE,
NUMBER_VALUE,
DATE_VALUE
) values (
SetAttribute.ruleid,
SetAttribute.attr_name,
'RESPOND',
SetAttribute.tvalue,
SetAttribute.nvalue,
SetAttribute.dvalue
);
end if;
exception
when others then
wf_core.context('Wf_Route', 'SetAttribute',
to_char(ruleid), attr_name_type, attr_value);
raise;
end SetAttribute;
--
-- DeleteRule
-- Delete rule with ruleid
-- IN
-- user - role owning rule
-- ruleid - Rule id
--
procedure DeleteRule(
user in varchar2 ,
ruleid in varchar2)
is
owner varchar2(320);
begin
-- Validate access
owner := Wf_Route.Authenticate(user);
-- Delete this rule along with any child attributes
delete from WF_ROUTING_RULE_ATTRIBUTES
where RULE_ID = ruleid;
delete from WF_ROUTING_RULES
where RULE_ID = ruleid;
-- Return to opening page
Wf_Route.List(user, '--EDITSCREEN--');
exception
when others then
wf_core.context('Wf_Route', 'DeleteRule', ruleid, user);
wf_route.error;
end;
--
-- SubmitUpdate
-- Process rule update page
-- IN
-- ruleid - Rule id
-- action - Rule action
-- action_argument - Forward to if forward
-- begin_date - Begin date
-- end_date - End date
-- rule_comment - Rule comment
-- h_fnames - array of attr field names
-- h_fvalues - array of attr field values
-- h_fdocnames - array of document name values
-- h_counter - number of fields passed in fnames and fvalues
-- delete_button - Delete button flag (for cancel this operation)
-- update_button - Update button flag
--
procedure SubmitUpdate(
rule_id in varchar2,
action in varchar2,
fmode in varchar2 ,
action_argument in varchar2 ,
display_action_argument in varchar2 ,
begin_date in varchar2 ,
end_date in varchar2 ,
rule_comment in varchar2 ,
h_fnames in Name_Array,
h_fvalues in Value_Array,
h_fdocnames in Value_Array,
h_counter in varchar2,
delete_button in varchar2 ,
update_button in varchar2 )
is
nruleid number;
owner varchar2(320);
realname varchar2(360);
s0 varchar2(2000);
forwardee varchar2(320);
l_action varchar2(30) := '';
begdate date;
enddate date;
CANCEL_RECORD exception;
begin
-- Find rule owner and validate access
nruleid := to_number(rule_id);
owner := Wf_Route.RuleOwner(nruleid);
owner := Wf_Route.Authenticate(owner);
wf_directory.GetRoleInfo(owner, realname, s0, s0, s0, s0);
l_action := substrb(action, 1, 30);
if (delete_button is not null) then
/*
-- Now delete rule in the List procedure instead of here
-- Delete this rule along with any child attributes
delete from WF_ROUTING_RULE_ATTRIBUTES
where RULE_ID = nruleid;
delete from WF_ROUTING_RULES
where RULE_ID = nruleid;
*/
-- Cancel the operation and return to opening page
raise CANCEL_RECORD;
else
-- UPDATE
--
-- Update main table data
--
if (action = 'FORWARD') then
forwardee := action_argument;
wfa_html.validate_display_name (display_action_argument, forwardee);
l_action := substrb(fmode, 1, 30);
end if;
begdate := StringToDate(begin_date);
enddate := StringToDate(end_date);
-- Validate date range
if (enddate <= begdate) then
wf_core.raise('WFRTG_BAD_DATE_RANGE');
end if;
-- Update columns in main table
update WF_ROUTING_RULES WRR set
ACTION = l_action,
ACTION_ARGUMENT = SubmitUpdate.forwardee,
BEGIN_DATE = SubmitUpdate.begdate,
END_DATE = SubmitUpdate.enddate,
RULE_COMMENT = SubmitUpdate.rule_comment
where WRR.RULE_ID = SubmitUpdate.nruleid;
--
-- Update routing attributes if RESPOND
--
if (action = 'RESPOND') then
-- Start at 2 to step over the Dummy_Name/Dummy_Value pair added at
-- the start of the array.
for i in 2 .. to_number(h_counter) loop
SetAttribute(nruleid, h_fnames(i), h_fvalues(i), h_fdocnames(i));
end loop;
else
begin
-- Update attributes table with null values since this is not a response
update WF_ROUTING_RULE_ATTRIBUTES WRRA set
TEXT_VALUE = null,
NUMBER_VALUE = null,
DATE_VALUE = null
where WRRA.RULE_ID = nruleid;
exception
when others then null;
end;
end if;
end if;
-- Go back to the List page
owa_util.redirect_url(curl=>wfa_html.base_url || '/wf_route.list?user='||owner||'&display_user=--EDITSCREEN--',
bclose_header=>TRUE);
exception
when CANCEL_RECORD then
Wf_Route.List(owner);
when others then
wf_core.context('Wf_Route', 'SubmitUpdate', rule_id, action,
action_argument, begin_date, end_date);
wf_route.error;
end SubmitUpdate;
--
-- UpdateRule
-- Update values for existing rule
-- IN
-- rule_id - Rule id number
-- MODIFICATION LOG:
-- 06-JUN-2001 JWSMITH BUG 1819232 -Added summary attr for table tag for ADA
-- - Added ID attr for TD tags
-- - Added label for input fields and radio buttons
--
procedure UpdateRule(
ruleid in varchar2)
is
nruleid number;
owner varchar2(320);
realname varchar2(360);
s0 varchar2(2000);
l_url varchar2(1000);
l_media varchar2(240) := wfa_html.image_loc;
l_icon varchar2(30) := 'FNDILOV.gif';
l_onmouseover varchar2(240) := wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFA_FIND_USER'));
-- Rule data
cursor rulecurs is
select WRR.MESSAGE_TYPE,
WRR.MESSAGE_NAME,
to_char(WRR.BEGIN_DATE)||to_char(WRR.BEGIN_DATE, ' HH24:MI:SS')
CBEGIN_DATE,
to_char(WRR.END_DATE) ||to_char(WRR.END_DATE, ' HH24:MI:SS')
CEND_DATE,
WRR.ACTION,
WRR.ACTION_ARGUMENT,
WRR.RULE_COMMENT,
WIT.DISPLAY_NAME TYPE_DISPLAY,
WM.SUBJECT
from WF_ROUTING_RULES WRR, WF_ITEM_TYPES_VL WIT, WF_MESSAGES_VL WM,
WF_LOOKUPS WL
where WRR.RULE_ID = nruleid
and WRR.MESSAGE_TYPE = WIT.NAME (+)
and WRR.MESSAGE_TYPE = WM.TYPE (+)
and WRR.MESSAGE_NAME = WM.NAME (+)
and WRR.ACTION = WL.LOOKUP_CODE
and WL.LOOKUP_TYPE = 'WFSTD_ROUTING_ACTIONS';
-- Obsolete fields from above select
-- WM.DISPLAY_NAME MSG_DISPLAY,
-- WL.MEANING ACTION_DISPLAY
--
rulerec rulecurs%rowtype;
-- Attr data
cursor attrcurs is
select WMA.NAME,
WMA.DISPLAY_NAME,
WMA.VALUE_TYPE,
decode(WMA.VALUE_TYPE, 'ITEMATTR', WIA.TEXT_DEFAULT,
WMA.TEXT_DEFAULT) TEXT_VALUE,
decode(WMA.VALUE_TYPE, 'ITEMATTR', WIA.NUMBER_DEFAULT,
WMA.NUMBER_DEFAULT) NUMBER_VALUE,
decode(WMA.VALUE_TYPE, 'ITEMATTR', WIA.DATE_DEFAULT,
WMA.DATE_DEFAULT) DATE_VALUE,
WMA.TYPE,
WMA.FORMAT
from WF_ROUTING_RULES WRR,
WF_MESSAGE_ATTRIBUTES_VL WMA,
WF_ITEM_ATTRIBUTES WIA
where WRR.RULE_ID = nruleid
and WRR.MESSAGE_TYPE = WMA.MESSAGE_TYPE
and WRR.MESSAGE_NAME = WMA.MESSAGE_NAME
and WMA.SUBTYPE = 'RESPOND'
and WMA.TYPE not in ('FORM', 'URL')
and WMA.MESSAGE_TYPE = WIA.ITEM_TYPE (+)
and WMA.TEXT_DEFAULT = WIA.NAME (+)
order by decode(WMA.NAME, 'RESULT', 9999, WMA.SEQUENCE);
-- Obsolete field from above SQL statement
-- WMA.DESCRIPTION,
tvalue varchar2(2000);
nvalue number;
dvalue date;
dispvalue varchar2(2000);
respcnt number := 0;
rowcount number;
msg_type varchar2(8);
msg_name varchar2(30);
fchecked pls_integer := null;
tchecked pls_integer := null;
l_message varchar2(240) := wfa_html.replace_onMouseOver_quotes(wf_core.translate ('WFPREF_LOV'));
begin
-- Find rule owner and validate access
nruleid := to_number(ruleid);
owner := Wf_Route.RuleOwner(nruleid);
owner := Wf_Route.Authenticate(owner);
wf_directory.GetRoleInfo(owner, realname, s0, s0, s0, s0);
-- Get rule data
open rulecurs;
fetch rulecurs into rulerec;
if (rulecurs%notfound) then
Wf_Core.Token('RULE', to_char(nruleid));
Wf_Core.Raise('WFRTG_INVALID_RULE');
end if;
close rulecurs;
-- Set page title
htp.htmlOpen;
htp.headOpen;
htp.title(wf_core.translate('WFRTG_UPDATE_TITLE')||' '||realname);
wfa_html.create_help_function('wf/links/upr.htm?UPRULE');
fnd_document_management.get_open_dm_display_window;
-- Add the java script to the header to open the dm window for
-- any DM function that and any standard LOV
fnd_document_management.get_open_dm_attach_window;
htp.headClose;
wfa_sec.Header(FALSE,'',wf_core.translate('WFRTG_UPDATE_TITLE'), TRUE);
-- Open form
-- Add dummy fields to start both array-type input fields.
-- These dummy values are needed so that the array parameters to
-- the submit procedure will not be null even if there are no real
-- response fields. This would cause a pl/sql error, because array
-- parameters can't be defaulted.
htp.p(' |