DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_MULTI_MESSAGE

Source


1 PACKAGE BODY HR_MULTI_MESSAGE AS
2 /* $Header: hrmulmes.pkb 120.0 2005/05/31 01:28:27 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |---------------------< Package Private Definitions >----------------------|
6 -- ----------------------------------------------------------------------------
7 --
8 -- The following global variable is used to indicate if Multiple
9 -- Error List feature is disabled. If TRUE the Multiple Error List
10 -- is disabled and the procedures and functions should provide
11 -- "stop at first error found" functionality.
12 g_multi_list_disabled     boolean   default true;
13 --
14 -- ----------------------------------------------------------------------------
15 -- |-------------------------< enable_message_list >--------------------------|
16 -- ----------------------------------------------------------------------------
17 --
18 procedure enable_message_list is
19 begin
20   --
21   -- Clear any existing contents from the Multiple Message List
22   --
23   -- Call FND_MSG_PUB.INITIALIZE to ensure multiple message list
24   -- is emptied.
25   --
26   fnd_msg_pub.initialize;
27   --
28   -- Enable Multiple Message Detection
29   --
30   g_multi_list_disabled := false;
31 end enable_message_list;
32 --
33 -- ----------------------------------------------------------------------------
34 -- |-------------------------< disable_message_list >-------------------------|
35 -- ----------------------------------------------------------------------------
36 --
37 procedure disable_message_list is
38 begin
39   --
40   -- Message List is not cleared at this stage because message retrieval
41   -- is still required by the user interface. Disabling the list will
42   -- prevent new messages from being added and the "verify" functions from
43   -- returning FALSE. The message list will be cleared when it is enabled
44   -- again.
45   --
46   g_multi_list_disabled := true;
47 end disable_message_list;
48 --
49 -- ------------------------------------------------------------------------------
50 -- |-------------------------< is_message_list_enabled >------------------------|
51 -- ------------------------------------------------------------------------------
52 --
53 function is_message_list_enabled
54    return boolean is
55 begin
56   return NOT g_multi_list_disabled;
57 end is_message_list_enabled;
58 --
59 -- ----------------------------------------------------------------------------
60 -- |------------------------< no_all_inclusive_error >------------------------|
61 -- ----------------------------------------------------------------------------
62 --
63 function no_all_inclusive_error
64   (p_check_column1                 in     varchar2
65   ,p_check_column2                 in     varchar2 default null
66   ,p_check_column3                 in     varchar2 default null
67   ,p_check_column4                 in     varchar2 default null
68   ,p_check_column5                 in     varchar2 default null
69   ,p_associated_column1            in     varchar2 default null
70   ,p_associated_column2            in     varchar2 default null
71   ,p_associated_column3            in     varchar2 default null
72   ,p_associated_column4            in     varchar2 default null
73   ,p_associated_column5            in     varchar2 default null
74   ) return boolean is
75 begin
76   if hr_multi_message.g_multi_list_disabled then
77     return true;
78   else
79     return ('T'= fnd_msg_pub.no_all_inclusive_error
80                     (p_check_column1      => p_check_column1
81                     ,p_check_column2      => p_check_column2
82                     ,p_check_column3      => p_check_column3
83                     ,p_check_column4      => p_check_column4
84                     ,p_check_column5      => p_check_column5
85                     ,p_associated_column1 => p_associated_column1
86                     ,p_associated_column2 => p_associated_column2
87                     ,p_associated_column3 => p_associated_column3
88                     ,p_associated_column4 => p_associated_column4
89                     ,p_associated_column5 => p_associated_column5
90                     ) );
91   end if;
92 end no_all_inclusive_error;
93 --
94 -- ----------------------------------------------------------------------------
95 -- |--------------------------< no_exclusive_error >--------------------------|
96 -- ----------------------------------------------------------------------------
97 --
98 function no_exclusive_error
99   (p_check_column1                 in     varchar2
100   ,p_check_column2                 in     varchar2 default null
101   ,p_check_column3                 in     varchar2 default null
102   ,p_check_column4                 in     varchar2 default null
103   ,p_check_column5                 in     varchar2 default null
104   ,p_associated_column1            in     varchar2 default null
105   ,p_associated_column2            in     varchar2 default null
106   ,p_associated_column3            in     varchar2 default null
107   ,p_associated_column4            in     varchar2 default null
108   ,p_associated_column5            in     varchar2 default null
109   ) return boolean is
110 begin
111   if hr_multi_message.g_multi_list_disabled then
112     return true;
113   else
114     return ('T'= fnd_msg_pub.no_exclusive_error
115                     (p_check_column1      => p_check_column1
116                     ,p_check_column2      => p_check_column2
117                     ,p_check_column3      => p_check_column3
118                     ,p_check_column4      => p_check_column4
119                     ,p_check_column5      => p_check_column5
120                     ,p_associated_column1 => p_associated_column1
121                     ,p_associated_column2 => p_associated_column2
122                     ,p_associated_column3 => p_associated_column3
123                     ,p_associated_column4 => p_associated_column4
124                     ,p_associated_column5 => p_associated_column5
125                     ) );
126   end if;
127 end no_exclusive_error;
128 --
129 -- ----------------------------------------------------------------------------
130 -- |---------------------------< no_error_message >---------------------------|
131 -- ----------------------------------------------------------------------------
132 --
133 function no_error_message
134   (p_check_message_name1           in     varchar2
135   ,p_check_message_name2           in     varchar2 default null
136   ,p_check_message_name3           in     varchar2 default null
137   ,p_check_message_name4           in     varchar2 default null
138   ,p_check_message_name5           in     varchar2 default null
139   ,p_associated_column1            in     varchar2 default null
140   ,p_associated_column2            in     varchar2 default null
141   ,p_associated_column3            in     varchar2 default null
142   ,p_associated_column4            in     varchar2 default null
143   ,p_associated_column5            in     varchar2 default null
144   ) return boolean is
145 begin
146   if hr_multi_message.g_multi_list_disabled then
147     return true;
148   else
149     return ('T'= fnd_msg_pub.no_error_message
150                     (p_check_message_name1 => p_check_message_name1
151                     ,p_check_message_name2 => p_check_message_name2
152                     ,p_check_message_name3 => p_check_message_name3
153                     ,p_check_message_name4 => p_check_message_name4
154                     ,p_check_message_name5 => p_check_message_name5
155                     ,p_associated_column1  => p_associated_column1
156                     ,p_associated_column2  => p_associated_column2
157                     ,p_associated_column3  => p_associated_column3
158                     ,p_associated_column4  => p_associated_column4
159                     ,p_associated_column5  => p_associated_column5
160                     ) );
161   end if;
162 end no_error_message;
163 --
164 -- ----------------------------------------------------------------------------
165 -- |------------------------------< exception_add >---------------------------|
166 -- ----------------------------------------------------------------------------
167 --
168 function exception_add
169   (p_associated_column1            in     varchar2 default null
170   ,p_associated_column2            in     varchar2 default null
171   ,p_associated_column3            in     varchar2 default null
172   ,p_associated_column4            in     varchar2 default null
173   ,p_associated_column5            in     varchar2 default null
174   ,p_same_associated_columns       in     varchar2 default 'N'
175   ) return boolean is
176   l_same_associated_columns  varchar2(1);
177 begin
178   if hr_multi_message.g_multi_list_disabled then
179     return true;
180   else
181    --   convert p_same_associated_columns values of
182    --   'Y' and 'N' to 'T' and 'F' values.
183     if p_same_associated_columns = 'Y' then
184       l_same_associated_columns := 'T';
185     else
186       l_same_associated_columns := 'F';
187     end if;
188     fnd_msg_pub.add_detail
189                     (p_associated_column1      => p_associated_column1
190                     ,p_associated_column2      => p_associated_column2
191                     ,p_associated_column3      => p_associated_column3
192                     ,p_associated_column4      => p_associated_column4
193                     ,p_associated_column5      => p_associated_column5
194                     ,p_same_associated_columns => l_same_associated_columns
195                     ,p_message_type            => HR_MULTI_MESSAGE.G_ERROR_MSG
196                     );
197     return false;
198   end if;
199 end exception_add;
200 --
201 -- ----------------------------------------------------------------------------
202 -- |-----------------------------------< add >--------------------------------|
203 -- ----------------------------------------------------------------------------
204 --
205 procedure add
206   (p_associated_column1            in     varchar2 default null
207   ,p_associated_column2            in     varchar2 default null
208   ,p_associated_column3            in     varchar2 default null
209   ,p_associated_column4            in     varchar2 default null
210   ,p_associated_column5            in     varchar2 default null
211   ,p_same_associated_columns       in     varchar2 default 'N'
212   ,p_message_type                  in     varchar2 default
213                                                    hr_multi_message.g_error_msg
214   ) is
215   l_same_associated_columns  varchar2(1);
216   l_hr_msg_name              varchar2(30);
217   l_hr_msg_appl              fnd_application.application_short_name%type;
218   l_fnd_msg_encoded          varchar2(2000);
219   l_fnd_msg_appl             fnd_application.application_short_name%type;
220   l_fnd_msg_name             varchar2(30);
221 begin
222   if hr_multi_message.g_multi_list_disabled then
223     --
224     -- Provide stop at first error found behaviour
225     --
226     if p_message_type = hr_multi_message.g_error_msg then
227       --
228       -- For error messages raise a PL/SQL exception
229       --
230       -- Fix for 4309248:
231       -- Background
232       -- ==========
233       -- Modification to fix bug 2661569 (changing a hardcoded
234       -- call from fnd_message.raise_error to
235       -- hr_utility.raise_error) was incorrect. As HRMS
236       -- error messages can be setup in two ways. Either
237       -- using the hr_utility or fnd_message packages. The
238       -- following solution ensures that when an error is
239       -- raised it is done in a consistent way to how the
240       -- error was setup. i.e. If the error was setup using
241       -- hr_utility then hr_utility.raise_error will be
242       -- called. Otherwise if the error was setup using
243       -- fnd_message then fnd_message.raise_error will
244       -- be called.
245       --
246       -- Solution Overview
247       -- =================
248       -- When an error is raised using the hr_utility.raise_error
249       -- the error details are not cleared from the hr_utility
250       -- package. Hence we cannot just call
251       -- hr_utility.get_message_details and assume that when
252       -- 'NO_MESSAGE' has been called that the error has been
253       -- set-up using fnd_message. This is because if one message
254       -- is set-up using hr_utility then all following messages
255       -- set-up using fnd_message would also look as if they
256       -- have been set-up using hr_utility. The solution needs
257       -- obtain the error details currently held in both
258       -- hr_utility and fnd_message. If error details returned
259       -- from both packages are the same then hr_utility has
260       -- been used. If they are different then fnd_message must
261       -- have been used for the latest message.
262       --
263       -- Solution Details
264       -- ================
265       -- Obtain the error message details from the
266       -- hr_utility package to find out if the error message
267       -- was raised from through that package. If the
268       -- the 'NO_MESSAGE' string is returned then the error
269       -- can't have been set using the hr_utility package.
270       --
271       -- Obtain error details from the hr_utility package
272       --
273       hr_utility.get_message_details
274         (msg_name => l_hr_msg_name
275         ,msg_appl => l_hr_msg_appl
276         );
277       --
278       -- If the 'NO_MESSAGE' string is returned then the error
279       -- can't have been setup using the hr_utility package,
280       -- it must be in fnd_message.
281       --
282       if l_hr_msg_name = 'NO_MESSAGE' then
283         fnd_message.raise_error;
284       else
285         --
286         -- Obtain error details from fnd_message, without
287         -- clearing the message in the other package.
288         --
289         l_fnd_msg_encoded := fnd_message.get_encoded(AUTO_LOG => 'Y');
290         if l_fnd_msg_encoded is not null then
291           fnd_message.parse_encoded
292             (encoded_message => l_fnd_msg_encoded
293             ,app_short_name  => l_fnd_msg_appl
294             ,message_name    => l_fnd_msg_name
295             );
296         else
297           l_fnd_msg_appl := null;
298           l_fnd_msg_name := 'NO_MESSAGE';
299         end if;
300         --
301         -- If the message names returned from the fnd_message
302         -- and hr_utility packages are different then the
303         -- latest message cannot have been setup using the
304         -- hr_utility package.
305         if l_fnd_msg_name <> l_hr_msg_name then
306           fnd_message.raise_error;
307         else
308           hr_utility.raise_error;
309         end if;
310       end if;
311     else
312       -- All other message types should be ignored.
313       -- Make sure fnd_message package is cleared
314       -- so later messages can be set without being
315       -- mixed up with previously set values.
316       --
317       fnd_message.clear;
318     end if;
319   else
320     --
321     -- Provide Multiple Message Detection for all types of message
322     --
323     --  convert p_same_associated_columns values of
324     --   'Y' and 'N' to 'T' and 'F' values.
325     if p_same_associated_columns = 'Y' then
326       l_same_associated_columns := 'T';
327     else
328       l_same_associated_columns := 'F';
329     end if;
330     --
331     fnd_msg_pub.add_detail
332                     (p_associated_column1      => p_associated_column1
333                     ,p_associated_column2      => p_associated_column2
334                     ,p_associated_column3      => p_associated_column3
335                     ,p_associated_column4      => p_associated_column4
336                     ,p_associated_column5      => p_associated_column5
337                     ,p_same_associated_columns => l_same_associated_columns
338                     ,p_message_type            => p_message_type
339                     );
340   end if;
341 end add;
342 --
343 -- ----------------------------------------------------------------------------
344 -- |-------------------------< unexpected_error_add >-------------------------|
345 -- ----------------------------------------------------------------------------
346 --
347 function unexpected_error_add
348   (p_procedure_name                in     varchar2
349   ) return boolean is
350 l_encoded varchar2(2000);
351 l_pkg_name varchar2(2000);
352 l_procedure_name varchar2(2000);
353 l_position number;
354 begin
355   if hr_multi_message.g_multi_list_disabled then
356     return true;
357   else
358     --
359     if sqlcode = -20001 then
360       l_encoded := fnd_message.get_encoded;
361       if l_encoded is not null then
362         fnd_message.set_encoded(l_encoded);
363         fnd_msg_pub.add;
364       else
365         l_position := instr(p_procedure_name,'.');
366         if l_position <> 0 then
367           l_pkg_name := substr(p_procedure_name,1,l_position-1);
368           l_procedure_name := substr(p_procedure_name,l_position+1,length(p_procedure_name));
369         else
370           l_pkg_name := '';
371           l_procedure_name := p_procedure_name;
372         end if;
373         fnd_msg_pub.add_exc_msg
374                         (p_pkg_name => l_pkg_name
375                         ,p_procedure_name => l_procedure_name);
376       end if;
377     else
378       l_position := instr(p_procedure_name,'.');
379       if l_position <> 0 then
380         l_pkg_name := substr(p_procedure_name,1,l_position-1);
381         l_procedure_name := substr(p_procedure_name,l_position+1,length(p_procedure_name));
382       else
383         l_pkg_name := '';
384         l_procedure_name := p_procedure_name;
385       end if;
386       fnd_msg_pub.add_exc_msg
387                       (p_pkg_name => l_pkg_name
388                       ,p_procedure_name => l_procedure_name);
389 
390     end if;
391     return false;
392   end if;
393 end unexpected_error_add;
394 --
395 -- ----------------------------------------------------------------------------
396 -- |--------------------------< end_validation_set >--------------------------|
397 -- ----------------------------------------------------------------------------
398 --
399 procedure end_validation_set is
400 l_encoded varchar2(2000);
401 l_message_type varchar2(1);
402 begin
403   if hr_multi_message.is_message_list_enabled then
404     --
405     --  loop through messages to find the first message of type ERROR
406     FOR I IN 1..fnd_msg_pub.count_msg LOOP
407       l_encoded := fnd_msg_pub.get_detail(p_msg_index => I);
408       fnd_message.set_encoded(l_encoded);
409       l_message_type := fnd_message.get_token
410                             (token => fnd_msg_pub.g_message_type_token_name);
411       if l_message_type = hr_multi_message.g_error_msg then
412         raise hr_multi_message.Error_Message_Exist;
413       end if;
414     end loop;
415   end if;
416 end end_validation_set;
417 --
418 -- ----------------------------------------------------------------------------
419 -- |---------------------------< get_return_status >--------------------------|
420 -- ----------------------------------------------------------------------------
421 --
422 function get_return_status return varchar2 is
423 begin
424   --
425   -- return error status if any type of message exists in the list
426   -- else returns success status
427   --
428   if fnd_msg_pub.count_msg > 0 then
429     return 'E';
430   else
431     return 'S';
432   end if;
433 end get_return_status;
434 --
435 -- ----------------------------------------------------------------------------
436 -- |-----------------------< get_return_status_disable >----------------------|
437 -- ----------------------------------------------------------------------------
438 --
439 function get_return_status_disable return varchar2 is
440 begin
441   --
442   -- disable the message list if enabled and return status
443   g_multi_list_disabled := true;
444   --
445   return hr_multi_message.get_return_status;
446 end get_return_status_disable;
447 --
448 END HR_MULTI_MESSAGE;