[Home] [Help]
PACKAGE BODY: APPS.HXC_TIMECARD_MESSAGE_HELPER
Source
1 PACKAGE BODY hxc_timecard_message_helper AS
2 /* $Header: hxctcdmsg.pkb 120.2 2006/08/15 22:14:20 arundell noship $ */
3
4 c_max_messages_displayed NUMBER := 30;
5 c_message_level_token VARCHAR2(80) := 'FND_MESSAGE_TYPE';
6
7 g_messages hxc_message_table_type;
8
9 g_package varchar2(30) := 'hxc_timecard_message_helper.';
10
11 Procedure initializeErrors is
12 Begin
13
14 g_messages := hxc_message_table_type();
15
16 End initializeErrors;
17
18 Procedure tryFindingMessage
19 (p_message_name out nocopy varchar2
20 ,p_message_app out nocopy varchar2
21 ,p_message_tokens in out nocopy varchar2
22 ) is
23
24 Begin
25
26 hr_message.provide_error;
27
28 p_message_name := hr_message.last_message_name;
29 p_message_app := hr_message.last_message_app;
30
31 if(p_message_name is null) then
32 -- Bug 3036930
33 p_message_name := 'HXC_HXT_DEP_VAL_ORAERR';
34 p_message_tokens := substr('ERROR&' || SQLERRM,1,2000);
35 end if;
36
37 End tryFindingMessage;
38
39 Procedure addErrorToCollection
40 (p_messages IN OUT NOCOPY HXC_MESSAGE_TABLE_TYPE
41 ,p_message_name IN fnd_new_messages.message_name%type
42 ,p_message_level IN VARCHAR2
43 ,p_message_field in VARCHAR2
44 ,p_message_tokens in VARCHAR2
45 ,p_application_short_name in fnd_application.application_short_name%type
46 ,p_time_building_block_id in hxc_time_building_blocks.time_building_block_id%type
47 ,p_time_building_block_ovn in hxc_time_building_blocks.object_version_number%type
48 ,p_time_attribute_id in hxc_time_attributes.time_attribute_id%type
49 ,p_time_attribute_ovn in hxc_time_attributes.object_version_number%type
50 ,p_message_extent in VARCHAR2 DEFAULT null --Bug#2873563
51 ) is
52
53 l_message_index NUMBER;
54 l_message_name fnd_new_messages.message_name%type;
55 l_message_app fnd_application.application_short_name%type;
56 l_message_tokens varchar2(4000); -- Bug 3036930
57 l_proc varchar2(72) := g_package||'addErrorToCollection';
58
59 BEGIN
60
61 if (p_messages is null) then
62
63 --
64 -- Initialize collection
65 --
66
67 p_messages := HXC_MESSAGE_TABLE_TYPE();
68
69 end if;
70 l_message_tokens := p_message_tokens; -- Bug 3036930
71 if(p_message_name = hxc_timecard.c_exception) then
72 tryFindingMessage(l_message_name,l_message_app,l_message_tokens); -- Bug 3036930
73 else
74 l_message_name := p_message_name;
75 l_message_app := p_application_short_name;
76 end if;
77
78 --
79 -- Check passed values (that aren't based on types)
80 -- Modified for 115.10 - added business message
81 -- using constants.
82
83 if (p_message_level NOT IN
84 (hxc_timecard.c_error,
85 hxc_timecard.c_warning,
86 hxc_timecard.c_confirmation,
87 hxc_timecard.c_information,
88 hxc_timecard.c_business_message)) then
89
90 FND_MESSAGE.SET_NAME('HXC','HXC_XXXXXX_INVALID_MSGTYPE');
91 FND_MESSAGE.RAISE_ERROR;
92
93 end if;
94
95 if (length(p_message_field) > 80) then
96
97 FND_MESSAGE.SET_NAME('HXC','HXC_XXXXX_FIELD_TOO_LONG');
98 FND_MESSAGE.SET_TOKEN('FIELD_NAME',p_message_field);
99 FND_MESSAGE.RAISE_ERROR;
100
101 end if;
102
103 if(length(p_message_tokens) > 4000) then
104
105 FND_MESSAGE.SET_NAME('HXC','HXC_XXXXX_TOKENS_TOO_LONG');
106 FND_MESSAGE.SET_TOKEN('TOKENS',p_message_tokens);
107 FND_MESSAGE.RAISE_ERROR;
108
109 end if;
110
111 --
112 -- Add the error to the collection
113 --
114
115 p_messages.extend;
116
117 l_message_index := p_messages.last;
118
119 p_messages(l_message_index) :=
120 HXC_MESSAGE_TYPE
121 (l_message_name
122 ,p_message_level
123 ,p_message_field
124 ,l_message_tokens -- Bug 3036930
125 ,l_message_app
126 ,p_time_building_block_id
127 ,p_time_building_block_ovn
128 ,p_time_attribute_id
129 ,p_time_attribute_ovn
130 ,p_message_extent --Bug#2873563
131 );
132
133 END addErrorToCollection;
134
135 PROCEDURE processErrors(p_messages IN OUT nocopy hxc_self_service_time_deposit.message_table) IS
136
137 l_message_count NUMBER;
138 l_error_message VARCHAR2(4000);
139 l_fnd_separator VARCHAR2(5) := FND_GLOBAL.LOCAL_CHR(0);
140
141 l_token_table hxc_deposit_wrapper_utilities.t_simple_table;
142
143 BEGIN
144 --
145 -- loop over the error msgs. return immediately if the message_table is blank
146 --
147 if(p_messages is null) then
148 return;
149 end if;
150
151 l_message_count:=p_messages.first;
152
153 LOOP
154
155 EXIT WHEN NOT p_messages.exists(l_message_count);
156 EXIT WHEN l_message_count > c_max_messages_displayed;
157
158 if(p_messages(l_message_count).on_oa_msg_stack = FALSE ) then
159 --AI5 message hasnt been processed yet
160
161
162 --
163 -- Set on 'stack'
164 --
165 FND_MESSAGE.SET_NAME
166 (p_messages(l_message_count).application_short_name
167 ,p_messages(l_message_count).message_name
168 );
169
170 IF p_messages(l_message_count).message_tokens IS NOT NULL THEN
171 --
172 -- parse string into a more accessible form
173 --
174 hxc_deposit_wrapper_utilities.string_to_table('&',
175 '&'||p_messages(l_message_count).message_tokens,
176 l_token_table);
177
178 -- table should be full of TOKEN, VALUE pairs. The number of TOKEN, VALUE pairs is l_token_table/2
179
180 FOR l_token in 0..(l_token_table.count/2)-1 LOOP
181
182 FND_MESSAGE.SET_TOKEN
183 (TOKEN => l_token_table(2*l_token)
184 ,VALUE => l_token_table(2*l_token+1)
185 );
186
187 END LOOP;
188 END IF; -- end tokens
189 --
190 -- Next set a token, which indicates the "level" of this message
191 -- to the middle tier.
192 -- Three values are supported by the framework:
193 -- "W" - for warning, shown in a dialogue box
194 -- "I" - for information, also shown in a dialogue box
195 -- "E" - for error, shown in an OAException
196 --
197
198 FND_MESSAGE.SET_TOKEN
199 (TOKEN => c_message_level_token
200 ,VALUE => nvl(substr(p_messages(l_message_count).message_level,1,1),'E')
201 );
202
203 --
204 -- Add this message to the message list
205 --
206 fnd_msg_pub.add;
207
208 --
209 -- Indicate that this message has been added to the stack
210 --
211 p_messages(l_message_count).on_oa_msg_stack := TRUE;
212
213 END IF; -- is this msg already stacked?
214
215 l_message_count:=p_messages.next(l_message_count);
216
217 END LOOP; -- loop over msg table
218
219 END processErrors;
220
221 Procedure processErrors
222 (p_messages in out nocopy hxc_message_table_type) is
223
224 l_index number;
225 l_msg_index number;
226
227 l_proc varchar2(45) := g_package||'processErrors';
228
229 Begin
230
231 if(p_messages is not null) then
232
233 if(g_messages is null) then
234
235 g_messages := hxc_message_table_type();
236
237 end if;
238
239 l_index := p_messages.first;
240
241 Loop
242 Exit When Not p_messages.exists(l_index);
243
244 g_messages.extend;
245
246 if((p_messages(l_index).message_name is null)
247 or
248 (p_messages(l_index).message_name = '')) then
249 g_messages(g_messages.last) :=
250 hxc_message_type
251 ('HXC_366510_EMPTY_MESSAGE',
252 hxc_timecard.c_error,
253 null,
254 'APPLICATION_SHORT_NAME&'||p_messages(l_index).application_short_name,
255 'HXC',
256 null,
257 null,
258 null,
259 null,
260 hxc_timecard.c_blk_children_extent
261 );
262 else
263 g_messages(g_messages.last) :=
264 hxc_message_type
265 (p_messages(l_index).message_name,
266 p_messages(l_index).MESSAGE_LEVEL,
267 p_messages(l_index).MESSAGE_FIELD,
268 p_messages(l_index).MESSAGE_TOKENS,
269 p_messages(l_index).APPLICATION_SHORT_NAME,
270 p_messages(l_index).TIME_BUILDING_BLOCK_ID,
271 p_messages(l_index).TIME_BUILDING_BLOCK_OVN,
272 p_messages(l_index).TIME_ATTRIBUTE_ID,
273 p_messages(l_index).TIME_ATTRIBUTE_OVN,
274 p_messages(l_index).message_extent
275 );
276 end if;
277
278 l_index := p_messages.next(l_index);
279 End Loop;
280
281 p_messages.delete;
282
283 end if;
284
285 End processErrors;
286
287 Function noErrors return BOOLEAN is
288
289 l_index number;
290 l_found BOOLEAN := false;
291
292 Begin
293
294 if(g_messages is null) then
295 return true;
296 else
297 If(g_messages.count>0) then
298 l_index := g_messages.first;
299 Loop
300 Exit when ((not g_messages.exists(l_index)) or (l_found));
301 if(g_messages(l_index).message_level = hxc_timecard.c_error) then
302 l_found := true;
303 end if;
304 l_index := g_messages.next(l_index);
305 End Loop;
306 if(l_found) then
307 return false;
308 else
309 return true;
310 end if;
311 else
312 return true;
313 end if;
314 end if;
315
316 End noErrors;
317
318 Procedure prepareErrors Is
319
320 l_index number;
321
322 l_token_table hxc_deposit_wrapper_utilities.t_simple_table;
323
324 l_token number;
325 l_proc varchar2(70) := g_package||'prepareErrors';
326
327 Begin
328
329 if(NOT noerrors) then
330
331 fnd_msg_pub.initialize;
332
333 l_index := g_messages.first;
334
335 Loop
336 exit when not g_messages.exists(l_index);
337
338 --
339 -- For the moment, just set on the stack
340 --
341
342 if((g_messages(l_index).message_name is not null)
343 AND
344 (g_messages(l_index).application_short_name is not null)
345 AND
346 ((g_messages(l_index).message_level <> hxc_timecard.c_pte)
347 AND
348 (g_messages(l_index).message_level <> hxc_timecard.c_reason_attribute)
349 )
350 ) then
351
352 fnd_message.set_name
353 (g_messages(l_index).application_short_name
354 ,g_messages(l_index).message_name
355 );
356 IF g_messages(l_index).message_tokens IS NOT NULL THEN
357 --
358 -- parse string into a more accessible form
359 --
360 hxc_deposit_wrapper_utilities.string_to_table('&',
361 '&'||g_messages(l_index).message_tokens,
362 l_token_table);
363
364 -- table should be full of TOKEN, VALUE pairs. The number of TOKEN, VALUE pairs is l_token_table/2
365
366 for l_token in 0..(l_token_table.count/2)-1 LOOP
367
368 fnd_message.set_token
369 (token => l_token_table(2*l_token)
370 ,value => l_token_table(2*l_token+1)
371 );
372
373 end loop;
374 end if; -- end tokens
375
376 fnd_msg_pub.add;
377
378 fnd_message.clear;
379
380 end if;
381
382 l_index := g_messages.next(l_index);
383
384 End Loop;
385
386 end if;
387
388 End prepareErrors;
389
390 Function prepareMessages return hxc_message_table_type is
391
392 l_messages hxc_message_table_type := hxc_message_table_type();
393 l_index number;
394 l_proc varchar2(70) := 'hxc_timecard_message_helper.prepareMessages';
395
396
397 Begin
398 --
399 -- Copy the complete set of messages to the return variable
400 -- ready to be passed back to the middle tier
401 --
402 l_index := g_messages.first;
403 Loop
404 Exit when not g_messages.exists(l_index);
405
406 if(instr(g_messages(l_index).message_level,'PTE')=0) then
407
408 l_messages.extend();
409
410 l_messages(l_messages.last) :=
411 hxc_message_type
412 (g_messages(l_index).MESSAGE_NAME
413 ,g_messages(l_index).MESSAGE_LEVEL
414 ,g_messages(l_index).MESSAGE_FIELD
415 ,g_messages(l_index).MESSAGE_TOKENS
416 ,g_messages(l_index).APPLICATION_SHORT_NAME
417 ,g_messages(l_index).TIME_BUILDING_BLOCK_ID
418 ,g_messages(l_index).TIME_BUILDING_BLOCK_OVN
419 ,g_messages(l_index).TIME_ATTRIBUTE_ID
420 ,g_messages(l_index).TIME_ATTRIBUTE_OVN
421 ,g_messages(l_index).message_extent --Bug#2873563
422 );
423
424 end if;
425
426 l_index := g_messages.next(l_index);
427 End Loop;
428
429 return l_messages;
430
431 End prepareMessages;
432
433 Function getMessages return hxc_message_table_type is
434
435 Begin
436
437 if(g_messages is null) then
438
439 g_messages := hxc_message_table_type();
440
441 end if;
442
443 return g_messages;
444
445 End getMessages;
446
447 END hxc_timecard_message_helper;