[Home] [Help]
PACKAGE BODY: APPS.AR_NOTIFICATION_STANDARD
Source
1 package body ar_notification_standard as
2 /*$Header: ARNOTSTB.pls 120.3 2005/07/22 12:45:32 naneja noship $ */
3
4 cursor role_csr is
5 select 'FND_RESP1:'||to_char(responsibility_id) role_name
6 from fnd_responsibility_tl
7 where application_id = 1;
8
9 /* cursor role_csr is
10 select name role_name
11 from wf_roles
12 where name = fnd_global.user_name; */
13
14 function createUrl(p_function in varchar2) return varchar2 is
15 l_url varchar2(1000);
16 l_function_id NUMBER;
17 cursor func is select function_id from fnd_form_functions_vl
18 where function_name = p_function;
19 begin
20 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.createUrl(+)'); end if;
21 open func; fetch func into l_function_id; close func;
22 fnd_profile.get('APPS_WEB_AGENT', l_url);
23 l_url := l_url||'OracleApps.RF?F=';
24 l_url := l_url||icx_call.encrypt2(fnd_global.resp_appl_id||'*'||
25 fnd_global.resp_id||'*'||
26 fnd_global.security_group_id||'*'||
27 l_function_id||'*'||
28 icx_sec.getsessioncookie());
29 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.createUrl(-)');end if;
30 return l_url;
31 end;
32
33 procedure build_error_message(document_id in varchar2,
34 display_type in varchar2,
35 document in out NOCOPY varchar2,
36 document_type in out NOCOPY varchar2) is
37 l_buffer varchar2(32000);
38 l_item_type varchar2(30);
39 l_item_key varchar2(30);
40
41 begin
42 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.build_error_message(+)'); end if;
43 fnd_message.set_name('AR', 'AR_DOC_TRS_BODY');
44 ar_notification_standard.parseDocumentId(document_id, l_item_type, l_item_key);
45 l_buffer := wf_engine.getItemAttrText(itemType => l_item_type,
46 itemKey => l_item_key,
47 aname => 'USER_AREA1');
48 document := fnd_message.get||fnd_global.newline||fnd_global.newline||l_buffer;
49 document_type := 'text/plain';
50 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.build_error_message(-)'); end if;
51 end;
52
53 /*
54 procedure build_error_message_clob(document_id in varchar2,
55 display_type in varchar2,
56 document in out NOCOPY clob,
57 document_type in out NOCOPY varchar2) is
58 l_buffer varchar2(1000);
59 l_item_type varchar2(30);
60 l_item_key varchar2(30);
61
62 begin
63 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.build_error_message(+)'); end if;
64 fnd_message.set_name('AR', 'AR_DOC_TRS_BODY');
65 WF_NOTIFICATION.WriteToClob(document,fnd_message.get||fnd_global.newline||fnd_global.newline);
66
67 ar_notification_standard.parseDocumentId(document_id, l_item_type, l_item_key);
68 l_buffer := wf_engine.getItemAttrText(itemType => l_item_type,
69 itemKey => l_item_key,
70 aname => 'USER_AREA1');
71 WF_NOTIFICATION.WriteToClob(document,l_buffer);
72 document_type := 'text/plain';
73 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.build_error_message(-)'); end if;
74 end;
75 */
76
77 procedure notify(p_subject in varchar2,
78 p_sqlerrm in varchar2,
79 p_role_name in varchar2,
80 p_url in varchar2) is
81 begin
82 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.notify(+)'); end if;
83 raiseNotificationEvent(p_event_name => 'oracle.apps.ar.transmit.notification',
84 p_subject => p_subject,
85 p_doc_pkg => 'AR_NOTIFICATION_STANDARD',
86 p_doc_proc => 'BUILD_ERROR_MESSAGE',
87 p_role_name => p_role_name,
88 p_url => p_url,
89 p_user_area1 => p_sqlerrm);
90 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.notify(-)'); end if;
91 end;
92
93
94 procedure notifyToSysadmin(p_subject in varchar2,
95 p_sqlerrm in varchar2,
96 p_url in varchar2) is
97 begin
98 if ar_doc_transfer_standard.isDebugOn then
99 ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.notifyToSysadmin(+)');
100 ar_doc_transfer_standard.debug('p_subject:'||p_subject);
101 ar_doc_transfer_standard.debug('p_sqlerrm:'||p_sqlerrm);
102 ar_doc_transfer_standard.debug('p_url:'||p_url);
103 end if;
104
105 for l_role_rec in role_csr loop
106
107 raiseNotificationEvent(p_event_name => 'oracle.apps.ar.transmit.notification',
108 p_subject => p_subject,
109 p_doc_pkg => 'AR_NOTIFICATION_STANDARD',
110 p_doc_proc => 'BUILD_ERROR_MESSAGE',
111 p_role_name => l_role_rec.role_name,
112 p_url => p_url,
113 p_user_area1 => p_sqlerrm);
114 end loop;
115 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.notifyToSysadmin(-)');end if;
116 exception
117 when others then
118 if ar_doc_transfer_standard.isDebugOn then
119 ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.notifyToSysadmin()EXCEPTION:'||sqlerrm);
120 end if;
121 end;
122
123
124 procedure parseDocumentId(p_document_id in varchar2,
125 p_item_type out NOCOPY varchar2,
126 p_item_key out NOCOPY varchar2) is
127
128 begin
129 if ar_doc_transfer_standard.isDebugOn then
130 ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.parseDocumentId(+)');
131 ar_doc_transfer_standard.debug('p_document_id:'||p_document_id);
132 end if;
133 p_item_type := substrb(p_document_id, 1, instrb(p_document_id,':')-1);
134 p_item_key := substrb(p_document_id, instrb(p_document_id,':')+1);
135 if ar_doc_transfer_standard.isDebugOn then
136 ar_doc_transfer_standard.debug('p_item_type:'||p_item_type);
137 ar_doc_transfer_standard.debug('p_item_key:'||p_item_key);
138 ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.parseDocumetnID(-)');
139 end if;
140 end;
141
142 procedure compileMessage(ITEMTYPE IN VARCHAR2,
143 ITEMKEY IN VARCHAR2,
144 ACTID IN NUMBER,
145 FUNCMODE IN VARCHAR2,
146 RESULTOUT IN OUT NOCOPY VARCHAR2) is
147
148 l_role_name VARCHAR2(320);
149 l_aname VARCHAR2(200);
150 l_msg_doc_procedure VARCHAR2(30);
151 l_msg_doc_package VARCHAR2(30);
152 l_plsql_block VARCHAR2(100);
153 l_subject VARCHAR2(1000);
154 l_email_address VARCHAR2(200);
155 l_url VARCHAR2(1000);
156
157 begin
158 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.compileMessage(+)');end if;
159 resultout := 'COMPLETE';
160 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.compileMessage(+)');end if;
161 end;
162
163 procedure isURLEmpty(ITEMTYPE IN VARCHAR2,
164 ITEMKEY IN VARCHAR2,
165 ACTID IN NUMBER,
166 FUNCMODE IN VARCHAR2,
167 RESULTOUT IN OUT NOCOPY VARCHAR2) is
168 isEmpty VARCHAR2(1) := 'T';
169
170 begin
171 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.isURLEmpty(+)'); end if;
172 if wf_engine.getItemAttrText(itemtype => itemtype,
173 itemkey => itemkey,
174 aname => 'URL') is not null then
175 isEmpty := 'F';
176 end if;
177 resultout := 'COMPLETE:'||isEmpty;
178 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('RESULTOUT:'||resultout); end if;
179 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.isURLEmpty(-)'); end if;
180 end;
181
182 procedure isMessageEmpty(ITEMTYPE IN VARCHAR2,
183 ITEMKEY IN VARCHAR2,
184 ACTID IN NUMBER,
185 FUNCMODE IN VARCHAR2,
186 RESULTOUT IN OUT NOCOPY VARCHAR2) is
187
188 isEmpty VARCHAR2(1) := 'T';
189
190 begin
191 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.isMessageEmpty(+)'); end if;
192 if wf_engine.getItemAttrText(itemtype => itemtype,
193 itemkey => itemkey,
194 aname => 'MSG_DOC') is not null then
195 isEmpty := 'F';
196 end if;
197 resultout := 'COMPLETE:'||isEmpty;
198 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('RESULTOUT:'||resultout); end if;
199 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.isMessageEmpty(-)'); end if;
200 end;
201
202
203 procedure raiseNotificationEvent(p_event_name in VARCHAR2,
204 p_subject in VARCHAR2,
205 p_doc_pkg in VARCHAR2,
206 p_doc_proc in VARCHAR2,
207 p_role_name in VARCHAR2,
208 p_url in VARCHAR2,
209 p_user_area1 in VARCHAR2,
210 p_user_area2 in VARCHAR2,
211 p_user_area3 in VARCHAR2,
212 p_user_area4 in VARCHAR2,
213 p_user_area5 in VARCHAR2) is
214
215 l_parameter_list wf_parameter_list_t := wf_parameter_list_t();
216 l_itemkey varchar2(30);
217 l_plsqldoc varchar2(200);
218 begin
219 if ar_doc_transfer_standard.isDebugOn then
220 ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.raiseNotificationEvent(+)');
221 ar_doc_transfer_standard.debug('p_event_name:'||p_event_name);
222 ar_doc_transfer_standard.debug('p_subject:'||p_subject);
223 ar_doc_transfer_standard.debug('p_doc_pkg:'||p_doc_pkg);
224 ar_doc_transfer_standard.debug('p_doc_proc:'||p_doc_proc);
225 ar_doc_transfer_standard.debug('p_rol_name:'||p_role_name);
226 ar_doc_transfer_standard.debug('p_url:'||p_url);
227 ar_doc_transfer_standard.debug('p_user_area1:'||p_user_area1);
228 ar_doc_transfer_standard.debug('p_user_area2:'||p_user_area2);
229 ar_doc_transfer_standard.debug('p_user_area3:'||p_user_area3);
230 ar_doc_transfer_standard.debug('p_user_area4:'||p_user_area4);
231 ar_doc_transfer_standard.debug('p_user_area5:'||p_user_area5);
232 end if;
233 l_itemkey := to_char(sysdate, 'DD-MON-RRRR-HHMISS');
234 l_plsqldoc:= 'plsql:'||p_doc_pkg||'.'||p_doc_proc||'/'||'ARNTFCTN:'||l_itemkey;
235 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('l_itemkey:'||l_itemkey); end if;
236 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('l_plsqldoc:'||l_plsqldoc); end if;
237 --
238 -- Set following Event Parameters:
239 --
240 wf_event.AddParameterToList(
241 p_name => 'SUBJECT',
242 p_value => p_subject,
243 p_parameterlist => l_parameter_list);
244
245 wf_event.AddParameterToList(
246 p_name => 'MSG_DOC',
247 p_value => l_plsqldoc,
248 p_parameterlist => l_parameter_list);
249
250 wf_event.AddParameterToList(
251 p_name => 'USER_TO_BE_NOTIFIED',
252 p_value => p_role_name,
253 p_parameterlist => l_parameter_list);
254
255 wf_event.AddParameterToList(
256 p_name => 'URL',
257 p_value => p_url,
258 p_parameterlist => l_parameter_list);
259
260 wf_event.AddParameterToList(
261 p_name => 'USER_AREA1',
262 p_value => p_user_area1,
263 p_parameterlist => l_parameter_list);
264
265 wf_event.AddParameterToList(
266 p_name => 'USER_AREA2',
267 p_value => p_user_area2,
268 p_parameterlist => l_parameter_list);
269
270 wf_event.AddParameterToList(
271 p_name => 'USER_AREA3',
272 p_value => p_user_area3,
273 p_parameterlist => l_parameter_list);
274
275 wf_event.AddParameterToList(
276 p_name => 'USER_AREA4',
277 p_value => p_user_area4,
278 p_parameterlist => l_parameter_list);
279
280 wf_event.AddParameterToList(
281 p_name => 'USER_AREA5',
282 p_value => p_user_area5,
283 p_parameterlist => l_parameter_list);
284
285 wf_event.raise(
286 p_event_name => p_event_name,
287 p_event_key => l_itemkey,
288 p_parameters => l_parameter_list);
289
290 l_parameter_list.DELETE;
291
292 if ar_doc_transfer_standard.isDebugOn then
293 ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD.raiseNotificationEvent(-)');
294 end if;
295
296 exception
297 when others then
298 raise;
299 end;
300
301 begin
302 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD(+)'); end if;
303 if ar_doc_transfer_standard.isDebugOn then ar_doc_transfer_standard.debug('AR_NOTIFICATION_STANDARD(-)'); end if;
304 end;