DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_WF_EVENT

Source


1 PACKAGE BODY FND_WF_EVENT AS
2 /* $Header: afwfeveb.pls 115.6 2003/09/10 13:45:58 vshanmug ship $ */
3 
4 --
5 -- Get_Form_Function (PUBLIC)
6 --   Get the form Function for a specific Workflow Item Key and Item Type.
7 -- IN:
8 --   itemtype - item type
9 --   itemkey - item key
10 --   aname - attribute name
11 -- RETURNS
12 --   Form Function Name
13 
14 
15 Function Get_Form_Function(wf_item_type in varchar2, wf_item_key in varchar2)
16 return varchar2 is
17 
18  /* cursor to get most recent activity */
19  cursor curact(itype varchar2, ikey varchar2) is
20   select nvl(notification_id,0), nvl(process_activity,0)
21      from wf_item_activity_statuses
22      where item_type = itype
23         and item_key =  ikey
24         and activity_status='NOTIFIED'
25       order by begin_date desc, execution_time desc;
26 
27  ntf_id number;
28  frm_id number;
29 
30  attribute_value varchar2(2048);
31 
32 begin
33      /* Get the current activity */
34      open curact(wf_item_type, wf_item_key);
35      fetch curact into ntf_id, frm_id;
36      close curact;
37 
38      /* either a notification or a form...whoever has the non-zero id is the
39 winner */
40      if (ntf_id <> 0) then
41         select NA.text_value
42            into attribute_value
43            from WF_NOTIFICATION_ATTRIBUTES NA,
44        WF_MESSAGE_ATTRIBUTES_VL MA,
45                   WF_NOTIFICATIONS N
46            where N.NOTIFICATION_ID = ntf_id
47               and NA.NOTIFICATION_ID = N.NOTIFICATION_ID
48               and MA.MESSAGE_NAME = N.MESSAGE_NAME
49               and MA.MESSAGE_TYPE = N.MESSAGE_TYPE
50               and MA.NAME = NA.NAME
51               and MA.SUBTYPE = 'RESPOND'
52               and MA.TYPE <> 'FORM'
53               and MA.NAME <> 'RESULT';
54      else
55          select wv.text_value
56             into attribute_value
57             from wf_process_activities wpa,
58                    wf_activities wa,
59                    wf_activity_attributes waa,
60                    wf_activity_attr_values wv,
61                    wf_items wi
62           where wpa.instance_id  = frm_id
63              and wpa.activity_item_type = wa.item_type
64              and wpa.activity_name = wa.name
65              and waa.activity_item_type = wa.item_type
66              and waa.activity_name = wa.name
67              and waa.activity_version = wa.version
68              and wv.process_activity_id = wpa.instance_id
69              and wv.name = waa.name
70              and waa.type = 'FORM'
71              and wi.item_type = wf_item_type
72              and wi.begin_date >= wa.begin_date
73              and wi.begin_date < nvl(wa.end_date,wi.begin_date+1)
74              and wi.item_key = wf_item_key;
75      end if;
76 
77      return attribute_value;
78 
79 exception  when OTHERS then
80     if (curact%ISOPEN) then
81       close curact;
82     end if;
83 
84     raise;
85 end;
86 
87 -- Raise_Table(PRIVATE)
88 --   Raises a Workflow. This is to be called ONLY from Forms and is used ONLY
89 --   because of the lack of support of object types in Forms.
90 --   The Param Table is a PL/SQL table which can hold up to 100 parameters.
91 -- IN:
92 --   p_event_name - event name
93 --   p_event_key - event key
94 --   p_event_date - This is not being used here but is left for consistentcy with
95 --                  other wf procedures. It MUST always be NULL
96 --   p_param_table - This IN/OUT PL/SQL table contains the parameters to pass to the wf.raise
97 --   p_number_params - This is the number of parameters in the above PL/SQL table
98 --   p_send_date - Send Date
99 -- NOTE
100 --   The PL/SQL Table has the following restrictions
101 --     -There must be consecutive rows in PL/SQL table starting with index 1
102 --     -An identical number of paramters must be returned from raise3 as are submitted to it.
103 
104 Procedure raise_table(p_event_name  	 in varchar2,
105                 	  p_event_key        in varchar2,
106                 	  p_event_data       in clob default NULL,
107 					  p_param_table      in out nocopy Param_Table,
108 					  p_number_params    in NUMBER,
109 					  p_send_date        in date default NULL ) IS
110 
111   l_parameter_list wf_parameter_list_t := wf_parameter_list_t();
112   i number := 1;
113   begin
114 
115   if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
116      wf_log_pkg.string(wf_log_pkg.level_procedure,
117                       'wf.plsql.fnd_wf_event.raise.begin',
118                       'Event Name:'||p_event_name||' Event Key:'||p_event_key);
119   end if;
120 
121   for i in 1..p_number_params LOOP
122      l_parameter_list.extend;
123      l_parameter_list(i) := wf_event.CreateParameter(p_param_table(i).Param_Name, p_param_table(i).Param_Value);
124   end LOOP;
125 
126   wf_event.raise3(p_event_name, p_event_key, p_event_data, l_parameter_list, p_send_date);
127   i := 1;
128   for i in 1..p_number_params LOOP
129     p_param_table(i).Param_Value := wf_event.getValueForParameter(p_param_table(i).Param_Name , l_parameter_list );
130 --    p_param_table(i).Param_Value := ('456');
131   END LOOP;
132 
133 END raise_table;
134 
135 -- Get_Error_Name(PUBLIC)
136 --   Gets the Workflow Error Name
137 -- RETURNS
138 --   The Workflow Error Name
139 -- NOTE
140 --   This routine is to be used only from Forms.
141 --   It exists only because forms cannot fetch a package variable from a server-side package.
142 
143 Function Get_Error_Name RETURN VARCHAR2 IS
144 BEGIN
145   RETURN wf_core.error_name;
146 END Get_Error_Name;
147 
148 -- Erase(PRIVATE)
149 --   Erases all traces of a workflow
150 -- NOTE
151 --   This routine is to be used only from Forms.
152 --   It is only here to isolate forms from WF changes.
153 Procedure erase(p_item_type in varchar2,
154                 p_item_key  in varchar2)
155 IS
156 BEGIN
157   wf_item_import.erase(p_item_type,p_item_key);
158 END erase;
159 
160 end fnd_wf_event;