DBA Data[Home] [Help]

PACKAGE BODY: APPS.HRI_BPL_CONC_LOG

Source


1 PACKAGE BODY hri_bpl_conc_log AS
2 /* $Header: hribcncl.pkb 120.5 2006/06/05 12:38:41 anmajumd noship $ */
3 --
4 -- Array type of hri_adm_msg_log row
5 --
6 TYPE g_msg_log_array_type IS TABLE OF hri_adm_msg_log%rowtype INDEX BY BINARY_INTEGER;
7 --
8 -- Global array to store the information that is to be inserted in hri_adm_msg_log
9 --
10 g_msg_log_array g_msg_log_array_type;
11 --
12 -- To store the index in the global array at which the process infromation will be stored
13 --
14 g_index    NUMBER;
15 --
16 -- Whether to log messages
17 --
18 g_logging  VARCHAR2(30);
19 --
20 -- Variable to store the method action id of the current process
21 --
22 g_mthd_action_id  NUMBER;
23 --
24 --
25 -- Bug 4105868: Set to true to output to a concurrent log file
26 --
27 g_conc_request_id         NUMBER := fnd_global.conc_request_id;
28 --
29 -- Bug 4105868: Global flag which determines whether debugging is turned on
30 --
31 g_debug_flag             VARCHAR2(5) := NVL(fnd_profile.value('HRI_ENBL_DTL_LOG'),'N');
32 --
33 -- Global constants
34 --
35 g_line_length            PLS_INTEGER := 77;
36 --
37 g_rtn                    VARCHAR2(5) := '
38 ';
39 --
40 -- -----------------------------------------------------------------------------
41 -- Inserts row into concurrent program log
42 -- -----------------------------------------------------------------------------
43 --
44 PROCEDURE output_html(p_text  VARCHAR2) IS
45   --
46 BEGIN
47   --
48   g_conc_request_id := fnd_global.conc_request_id;
49   --
50   IF g_conc_request_id IS NOT NULL THEN
51     --
52     -- Write to the concurrent request log
53     --
54     fnd_file.put_line(fnd_file.output, p_text);
55     --
56   END IF;
57   --
58 END output_html;
59 --
60 -- -----------------------------------------------------------------------------
61 -- Inserts row into concurrent program log
62 -- -----------------------------------------------------------------------------
63 --
64 PROCEDURE output(p_text  VARCHAR2) IS
65   --
66 BEGIN
67   --
68   g_conc_request_id := fnd_global.conc_request_id;
69   --
70   IF g_conc_request_id IS NOT NULL THEN
71     --
72     -- Write to the concurrent request log
73     --
74     fnd_file.put_line(fnd_file.log, p_text);
75     --
76   ELSE
77     --
78     hr_utility.trace(p_text);
79     --
80   END IF;
81   --
82 END output;
83 --
84 -- -----------------------------------------------------------------------------
85 -- Inserts row into concurrent program log if debugging is enabled
86 -- -----------------------------------------------------------------------------
87 --
88 PROCEDURE dbg(p_text  VARCHAR2) IS
89   --
90 BEGIN
91   --
92   -- Get the value for the debug flag
93   --
94   g_debug_flag := NVL(fnd_profile.value('HRI_ENBL_DTL_LOG'),'N');
95   --
96   IF g_debug_flag = 'Y'  THEN
97     --
98     -- Write to output
99     --
100     output(p_text);
101     --
102   END IF;
103 --
104 END dbg;
105 --
106 -- -----------------------------------------------------------------------------
107 -- Formats output lines by type
108 -- -----------------------------------------------------------------------------
109 --
110 FUNCTION format_line(p_text       IN VARCHAR2,
111                      p_col_list   IN col_list_tab_type,
112                      p_mode       IN VARCHAR2,
113                      p_line_type  IN VARCHAR2,
114                      p_format     IN VARCHAR2)
115     RETURN VARCHAR2 IS
116 
117   l_text          VARCHAR2(32000);
118   l_text1         VARCHAR2(32000);
119   l_text2         VARCHAR2(32000);
120   l_html_text     VARCHAR2(32000);
121   l_pre_format    VARCHAR2(1000);
122   l_post_format   VARCHAR2(1000);
123 
124 BEGIN
125 
126   -- Extra HTML formatting
127   IF (p_format IS NOT NULL AND
128       p_mode = 'HTML') THEN
129     l_pre_format := p_format;
130     l_post_format := REPLACE(p_format, '<', '</');
131   END IF;
132 
133 -- -----------------
134 -- Headers / Footers
135 -- -----------------
136 
137   -- Format line according to type
138   IF (p_line_type = 'TITLE' AND
139       p_text IS NOT NULL) THEN
140 
141     l_html_text := '<html>' || g_rtn ||
142                    '<head><title>' || p_text || '</title></head>' || g_rtn ||
143                    '<body>';
144 
145   ELSIF (p_line_type = 'HEADER1' AND
146          p_text IS NOT NULL) THEN
147 
148     l_text := ' ' || g_rtn || RPAD('*', LENGTH(p_text) + 6, '*') || g_rtn ||
149               '** ' ||  p_text || ' **' || g_rtn ||
150               RPAD('*', LENGTH(p_text) + 6, '*');
151 
152     l_html_text := '<p><h1>' || p_text || '</h1>';
153 
154   ELSIF (p_line_type = 'HEADER2' AND
155          p_text IS NOT NULL) THEN
156 
157     l_text := RPAD('-', g_line_length, '-') || g_rtn ||
158               upper(p_text) || g_rtn || RPAD('-', g_line_length, '-');
159 
160     l_html_text := '<p><h2>' || p_text || '</h2>';
161 
162   ELSIF (p_line_type = 'HEADER3' AND
163          p_text IS NOT NULL) THEN
164 
165     l_text := ' ' || g_rtn || p_text || g_rtn || RPAD('-', LENGTH(p_text), '-');
166 
167     l_html_text := '<p><h3>' || p_text || '</h3>';
168 
169   ELSIF (p_line_type = 'HEADER4' AND
170          p_text IS NOT NULL) THEN
171 
172     l_text := ' ' || g_rtn || p_text || g_rtn || RPAD('-', LENGTH(p_text), '-');
173 
174     l_html_text := '<p><b><u>' || p_text || '</u></b><br>';
175 
176   ELSIF (p_line_type = 'FOOTER') THEN
177 
178     l_html_text := '</body>';
179 
180 -- -----
181 -- Lists
182 -- -----
183 
184   ELSIF (p_line_type = 'LIST_HEADER') THEN
185 
186     l_html_text := '<ul>';
187 
188   ELSIF (p_line_type = 'LIST_ITEM') THEN
189 
190     l_html_text := '<li>' || p_text || '</li>';
191 
192   ELSIF (p_line_type = 'LIST_FOOTER') THEN
193 
194     l_html_text := '</ul>';
195 
196 
197 -- ------
198 -- Tables
199 -- ------
200 
201   ELSIF (p_line_type = 'TABLE_HEADER') THEN
202 
203     l_html_text := '<p><table border=1>' || g_rtn ||
204                    '     <tr>' || g_rtn;
205 
206     FOR i IN p_col_list.FIRST..p_col_list.LAST LOOP
207 
208       l_text1 := l_text1 || RPAD(p_col_list(i).column_value,
209                                 p_col_list(i).column_length, ' ');
210       l_text2 := l_text2 || RPAD('-',
211                                 p_col_list(i).column_length - 1, '-') || ' ';
212 
213       l_html_text := l_html_text ||
214                    '       <td><b>' || p_col_list(i).column_value ||
215                    '</b></td>' || g_rtn;
216     END LOOP;
217 
218     l_text := l_text1 || g_rtn || l_text2;
219 
220     l_html_text := l_html_text || '     </tr>';
221 
222   ELSIF (p_line_type = 'TABLE_ROW') THEN
223 
224     l_html_text := '     <tr>' || g_rtn;
225 
226     FOR i IN p_col_list.FIRST..p_col_list.LAST LOOP
227       IF (p_col_list(i).column_value IS NOT NULL) THEN
228 
229         l_text := l_text || RPAD(p_col_list(i).column_value,
230                                  p_col_list(i).column_length, ' ');
231 
232         l_html_text := l_html_text ||
233                      '       <td>' || p_col_list(i).column_value ||
234                      '</td>' || g_rtn;
235       ELSE
236 
237         l_text := l_text || RPAD(' ', p_col_list(i).column_length, ' ');
238 
239         l_html_text := l_html_text || '       <td> </td>' || g_rtn;
240 
241       END IF;
242     END LOOP;
243 
244     l_html_text := l_html_text || '     </tr>';
245 
246   ELSIF (p_line_type = 'TABLE_FOOTER') THEN
247 
248     l_html_text := '   </table><br>';
249 
250 -- -------
251 -- Spacers
252 -- -------
253 
254   ELSIF (p_line_type = 'SPACER') THEN
255 
256     l_text := ' ';
257 
258     l_html_text := '<p> ' || g_rtn;
259 
260   ELSIF (p_line_type = 'SPACER BAR') THEN
261 
262     l_text := ' ' || g_rtn || RPAD('-', g_line_length, '-') || g_rtn || ' ';
263 
264     l_html_text := '<br><p><hr align=left size=6 width="75%">' || g_rtn;
265 
266 -- ------------
267 -- Special Text
268 -- ------------
269 
270   ELSIF (p_line_type = 'HYPERLINK') THEN
271 
272     l_text := ' ' || g_rtn || p_text;
273 
274     l_html_text := '<a href="' || p_text ||
275                    '">Click here for more information</a><br>';
276 
277   ELSIF (p_line_type = 'PREFORMAT' AND
278          p_text IS NOT NULL) THEN
279 
280     l_text := ' ' || g_rtn || p_text;
281 
282     l_html_text := '<p><pre>' || p_text || '</pre><br>';
283 
284 -- -------------
285 -- Ordinary Text
286 -- -------------
287 
288   ELSIF (p_line_type = 'PARAGRAPH' AND
289          p_text IS NOT NULL) THEN
290 
291     l_text := ' ' || g_rtn || p_text;
292 
293     l_html_text := '<p>' || l_pre_format ||
294                    REPLACE(p_text, g_rtn, '<br>' || g_rtn) || '<br>' ||
295                    l_post_format;
296 
297   ELSIF (p_text IS NOT NULL) THEN
298 
299     l_text := p_text;
300 
301     l_html_text := l_pre_format ||
302                    REPLACE(p_text, g_rtn, '<br>' || g_rtn) || '<br>' ||
303                    l_post_format;
304   END IF;
305 
306   -- Output string according to type
307   IF (p_mode = 'HTML') THEN
308     RETURN l_html_text;
309   ELSE
310     RETURN l_text;
311   END IF;
312 
313   RETURN l_text;
314 
315 END format_line;
316 --
317 -- -----------------------------------------------------------------------------
318 -- Generic output procedure
319 -- -----------------------------------------------------------------------------
320 --
321 PROCEDURE output(p_text       IN VARCHAR2,
322                  p_mode       IN VARCHAR2,
323                  p_line_type  IN VARCHAR2,
324                  p_col_list   IN col_list_tab_type DEFAULT g_empty_col_list,
325                  p_format     IN VARCHAR2 DEFAULT null) IS
326 
327   l_text           VARCHAR2(32000);
328   l_write_string   VARCHAR2(1000);
329   l_remainder      VARCHAR2(32000);
330   l_break          PLS_INTEGER;
331   l_space          PLS_INTEGER;
332   l_loop           PLS_INTEGER;
333 
334 BEGIN
335 
336   -- Format line according to type
337   l_text := format_line
338              (p_text => p_text,
339               p_col_list => p_col_list,
340               p_mode => p_mode,
341               p_line_type => p_line_type,
342               p_format => p_format);
343 
344   -- Output string according to type
345   IF (p_mode = 'HTML' AND
346       l_text IS NOT NULL) THEN
347 
348     output_html(l_text);
349 
350   -- Log output needs to be chopped up
351   ELSIF (l_text IS NOT NULL) THEN
352 
353     -- Initialize variables
354     l_write_string := null;
355     l_remainder    := l_text;
356 
357     -- Chop up p_text string into display width lines
358     WHILE (length(l_remainder) > 0) LOOP
359 
360       -- Loop check
361       l_loop := length(l_remainder);
362 
363       -- Set position of next break
364       l_break := INSTR(l_remainder, g_rtn);
365 
366       -- Set position of last white space
367       l_space := INSTR(SUBSTR(l_remainder, 1, g_line_length + 1), ' ', -1, 1);
368 
369       -- First check for line breaks
370       IF (l_break > 0 AND
371           l_break - 1 <= g_line_length) THEN
372         l_write_string := SUBSTR(l_remainder, 1, l_break - 1);
373         l_remainder    := SUBSTR(l_remainder, l_break + 1);
374 
375       -- Then break by word
376       ELSIF (l_space > 0 AND
377              length(l_remainder) > g_line_length) THEN
378         l_write_string := SUBSTR(l_remainder, 1, l_space - 1);
379         l_remainder    := SUBSTR(l_remainder, l_space + 1);
380 
381       -- Otherwise chop the line
382       ELSE
383         l_write_string := SUBSTR(l_remainder, 1, g_line_length);
384         l_remainder    := SUBSTR(l_remainder, g_line_length + 1);
385       END IF;
386 
387       -- Write to the log
388       output(l_write_string);
389 
390       -- Make sure loop variable is decreasing otherwise force exit
391       IF (l_loop IS NULL OR
392           length(l_remainder) >= l_loop) THEN
393         l_remainder := '';
394       END IF;
395 
396     END LOOP;
397 
398   END IF;
399 
400 END output;
401 --
402 -- -----------------------------------------------------------------------------
403 -- Looks up in the log table the last collect to date of the concurrent
404 -- process. If no information is found in the log table then the earlier of
405 -- DBC Global Start Date or 5 years ago is returned.
406 -- -----------------------------------------------------------------------------
407 --
408 FUNCTION get_last_collect_to_date
409                  (p_process_code    IN VARCHAR2
410                  ,p_table_name      IN VARCHAR2
411                  )
412 RETURN VARCHAR2 IS
413   --
414   l_sql_stmt            VARCHAR2(500);
415   l_full_refresh_code   VARCHAR2(30);
416   l_date_to_return      DATE;
417   l_process_start_date  DATE;
418   l_process_end_date    DATE;
419   l_collect_from_date   DATE;
420   l_collect_to_date     DATE;
421   --
422 BEGIN
423   --
424   bis_collection_utilities.get_last_refresh_dates
425           (p_object_name  => p_process_code
426           ,p_start_date   => l_process_start_date
427           ,p_end_date     => l_process_end_date
428           ,p_period_from  => l_collect_from_date
429           ,p_period_to    => l_collect_to_date
430           );
431   --
432   l_full_refresh_code := hri_bpl_conc_admin.get_full_refresh_code(p_table_name);
433   --
434   -- If mode is Incremental Update (data in table)
435   --
436   IF (l_full_refresh_code = 'N') THEN
437     --
438     -- If the last collect to date is in the log table use it
439     --
440     IF (l_collect_to_date IS NOT NULL) THEN
441       --
442       l_date_to_return := l_collect_to_date;
443       --
444       -- Otherwise collect for the last month
445       --
446     ELSE
447       --
448       l_date_to_return := ADD_MONTHS(TRUNC(SYSDATE),-1);
449       --
450     END IF;
451     --
452     -- Otherwise mode is Full Refresh (no data in table)
453     --
454   ELSE
455     --
456     -- Collect earlier of DBC Global Start Date or 5 years ago
457     --
458     l_date_to_return := LEAST(ADD_MONTHS(TRUNC(SYSDATE),-60),
459                               hri_bpl_parameter.get_bis_global_start_date);
460     --
461   END IF;
462   --
463   -- 4303724, Added the parameter value 'FND_NO_CONVERT' in function call
464   --
465   -- RETURN fnd_date.date_to_displaydt(l_date_to_return,'FND_NO_CONVERT');
466   --
467   --
468   -- Bug 5217834, used fnd_date.date_to_displaydate to return value
469   -- to value set FND_STANDARD_DATE.
470   --
471      RETURN fnd_date.date_to_displaydate(l_date_to_return);
472   --
473   --
474 END get_last_collect_to_date;
475 --
476 -- -----------------------------------------------------------------------------
477 -- Removes all records in the log table for the concurrent process
478 -- -----------------------------------------------------------------------------
479 --
480 PROCEDURE delete_process_log( p_process_code    IN VARCHAR2 ) IS
481 --
482 BEGIN
483   --
484   bis_collection_utilities.deleteLogForObject(p_object_name => p_process_code);
485   --
486 END delete_process_log;
487 --
488 -- Fix for 4043240
489 -- --------------------------------------------------------------------------
490 -- Log the process start information into the mthd actions table
491 -- --------------------------------------------------------------------------
492 --
493 PROCEDURE record_process_start(p_process_code         IN VARCHAR2)  IS
494   --
495 BEGIN
496   --
497   bis_collection_utilities.g_object_name := p_process_code;
498   bis_collection_utilities.g_start_date  := sysdate;
499   --
500   -- Log the information only if the logging profile is set
501   --
502   IF NVL(fnd_profile.value('HRI_LOG_PRCSS_INFO'),'Y') = 'N' THEN
503     --
504     RETURN;
505     --
506   END IF;
507   --
508   -- Create a record in the methods actions table and get the mthd
509   -- action id for it
510   --
511   IF g_mthd_action_id IS NULL THEN
512     --
513     g_mthd_action_id := hri_opl_multi_thread.get_mthd_action_id
514                                 (p_program    => p_process_code
515                                 ,p_start_time => bis_collection_utilities.g_start_date
516                                 );
517     --
518   END IF;
519   --
520   COMMIT;
521   --
522 END record_process_start;
523 --
524 -- Fix for 4043240
525 -- ----------------------------------------------------------------------------
526 -- PROCEDURE log_process_info to store the eror/warning messages generated by
527 -- the HRI processes
528 -- ----------------------------------------------------------------------------
529 --
530 PROCEDURE log_process_info
531                  (p_msg_type              VARCHAR2
532                  ,p_package_name          VARCHAR2 DEFAULT NULL
533                  ,p_msg_group             VARCHAR2 DEFAULT NULL
534                  ,p_msg_sub_group         VARCHAR2 DEFAULT NULL
535                  ,p_sql_err_code          VARCHAR2 DEFAULT NULL
536                  ,p_note                  VARCHAR2 DEFAULT NULL
537                  ,p_effective_date        DATE     DEFAULT TRUNC(SYSDATE)
538                  ,p_assignment_id         NUMBER   DEFAULT NULL
539                  ,p_person_id             NUMBER   DEFAULT NULL
540                  ,p_job_id                NUMBER   DEFAULT NULL
541                  ,p_location_id           NUMBER   DEFAULT NULL
542                  ,p_event_id              NUMBER   DEFAULT NULL
543                  ,p_supervisor_id         NUMBER   DEFAULT NULL
544                  ,p_person_type_id        NUMBER   DEFAULT NULL
545                  ,p_formula_id            NUMBER   DEFAULT NULL
546                  ,p_other_ref_id          NUMBER   DEFAULT NULL
547                  ,p_other_ref_column      VARCHAR2 DEFAULT NULL
548                  ,p_fnd_msg_name          VARCHAR2 DEFAULT NULL
549                  )
550 IS
551   --
552   -- The variable to store the message log id for the table
553   -- hri_adm_msg_log. The id is generated froma sequence
554   --
555   l_msg_log_id	NUMBER;
556   --
557 BEGIN
558   --
559   -- Log the information only if the logging profile is set
560   --
561   IF NVL(fnd_profile.value('HRI_LOG_PRCSS_INFO'),'Y') = 'N' THEN
562     --
563     RETURN;
564     --
565   END IF;
566   --
567   dbg('In log_process_info');
568   --
569   -- Initialize the index from which the global array will start storing the records
570   --
571   IF g_index IS NULL THEN
572     --
573     g_index := 0;
574     --
575   END IF;
576   --
577   -- Get the next message log id from the sequence
578   --
579   SELECT hri_adm_msg_log_s.nextval
580   INTO   l_msg_log_id
581   FROM   dual;
582   --
583   -- Increment the array index at which the infromation is stored
584   --
585   g_index := g_index+1;
586   --
587   -- Store the log information generated by the HRI process in a global array
588   -- The information stored in this array will be flushed into the
589   -- hri_adm_msg_log table when the procedure log_process_end will be
590   -- called
591   --
592   g_msg_log_array(g_index).msg_log_id           := l_msg_log_id;
593   g_msg_log_array(g_index).msg_type             := p_msg_type;
594   g_msg_log_array(g_index).package_name         := p_package_name;
595   g_msg_log_array(g_index).effective_date       := p_effective_date;
596   g_msg_log_array(g_index).person_id            := p_person_id;
597   g_msg_log_array(g_index).assignment_id        := p_assignment_id;
598   g_msg_log_array(g_index).job_id               := p_job_id;
599   g_msg_log_array(g_index).location_id          := p_location_id;
600   g_msg_log_array(g_index).event_id             := p_event_id;
601   g_msg_log_array(g_index).supervisor_id        := p_supervisor_id;
602   g_msg_log_array(g_index).person_type_id       := p_person_type_id;
603   g_msg_log_array(g_index).formula_id           := p_formula_id;
604   g_msg_log_array(g_index).other_ref_id         := p_other_ref_id;
605   g_msg_log_array(g_index).other_ref_column     := p_other_ref_column;
606   g_msg_log_array(g_index).msg_group            := p_msg_group;
607   g_msg_log_array(g_index).msg_sub_group        := p_msg_sub_group;
608   g_msg_log_array(g_index).sql_err_code         := p_sql_err_code;
609   g_msg_log_array(g_index).fnd_msg_name         := p_fnd_msg_name;
610   g_msg_log_array(g_index).note                 := p_note;
611   --
612   dbg('Exiting log_process_info');
613   --
614 END log_process_info;
615 --
616 -- Flush the process infromation stored in the global array into
617 -- the hri_adm_msg_log table
618 --
619 PROCEDURE flush_process_info(p_package_name   IN VARCHAR2) IS
620 
621 BEGIN
622   --
623   IF g_mthd_action_id IS NULL THEN
624     g_mthd_action_id := hri_opl_multi_thread.get_mthd_action_id
625                                 (p_program    => p_package_name
626                                 ,p_start_time => sysdate);
627   END IF;
628   --
629   IF g_logging IS NULL THEN
630     g_logging := NVL(fnd_profile.value('HRI_LOG_PRCSS_INFO'),'Y');
631   END IF;
632   --
633   -- Log the information only if the logging profile is set
634   --
635   IF (g_index > 0 AND
636       g_logging = 'Y') THEN
637     --
638     -- Insert all the  messages stored in the global
639     -- array into the table hri_adm_msg_log
640     --
641     FOR i IN 1..g_index LOOP
642       INSERT INTO hri_adm_msg_log
643              (msg_log_id
644              ,mthd_action_id
645              ,msg_type
646              ,package_name
647              ,effective_date
648              ,person_id
649              ,assignment_id
650              ,job_id
651              ,location_id
652              ,event_id
653              ,supervisor_id
654              ,person_type_id
655              ,formula_id
656              ,other_ref_id
657              ,other_ref_column
658              ,msg_group
659              ,msg_sub_group
660              ,sql_err_code
661              ,fnd_msg_name
662              ,note
663              )
664       VALUES
665              (g_msg_log_array(i).msg_log_id
666              ,g_mthd_action_id
667              ,g_msg_log_array(i).msg_type
668              ,g_msg_log_array(i).package_name
669              ,g_msg_log_array(i).effective_date
670              ,g_msg_log_array(i).person_id
671              ,g_msg_log_array(i).assignment_id
672              ,g_msg_log_array(i).job_id
673              ,g_msg_log_array(i).location_id
674              ,g_msg_log_array(i).event_id
675              ,g_msg_log_array(i).supervisor_id
676              ,g_msg_log_array(i).person_type_id
677              ,g_msg_log_array(i).formula_id
678              ,g_msg_log_array(i).other_ref_id
679              ,g_msg_log_array(i).other_ref_column
680              ,g_msg_log_array(i).msg_group
681              ,g_msg_log_array(i).msg_sub_group
682              ,g_msg_log_array(i).sql_err_code
683              ,g_msg_log_array(i).fnd_msg_name
684              ,g_msg_log_array(i).note
685              );
686     END LOOP;
687     --
688     commit;
689     --
690   END IF;
691 
692   -- Reset the index
693   g_index := 0;
694 
695 END flush_process_info;
696 --
697 -- -------------------------------------------------------------------------
698 -- Inserts into the log table the information about the concurrent process
699 -- run - start and end times, rows processed, errors and parameters
700 -- -------------------------------------------------------------------------
701 --
702 PROCEDURE log_process_end
703                   (p_status        IN BOOLEAN
704                   ,p_count         IN NUMBER   DEFAULT 0
705                   ,p_message       IN VARCHAR2 DEFAULT NULL
706                   ,p_period_from   IN DATE     DEFAULT to_date(NULL)
707                   ,p_period_to     IN DATE     DEFAULT to_date(NULL)
708                   ,p_attribute1    IN VARCHAR2 DEFAULT NULL
709                   ,p_attribute2    IN VARCHAR2 DEFAULT NULL
710                   ,p_attribute3    IN VARCHAR2 DEFAULT NULL
711                   ,p_attribute4    IN VARCHAR2 DEFAULT NULL
712                   ,p_attribute5    IN VARCHAR2 DEFAULT NULL
713                   ,p_attribute6    IN VARCHAR2 DEFAULT NULL
714                   ,p_attribute7    IN VARCHAR2 DEFAULT NULL
715                   ,p_attribute8    IN VARCHAR2 DEFAULT NULL
716                   ,p_attribute9    IN VARCHAR2 DEFAULT NULL
717                   ,p_attribute10   IN VARCHAR2 DEFAULT NULL
718                   --
719                   -- New parameters for bug fix 4043240
720                   --
721                   ,p_process_type  IN VARCHAR2 DEFAULT NULL
722                   ,p_package_name  IN VARCHAR2 DEFAULT NULL
723                   ,p_full_refresh  IN VARCHAR2 DEFAULT NULL
724                   ,p_attribute11   IN VARCHAR2 DEFAULT NULL
725                   ,p_attribute12   IN VARCHAR2 DEFAULT NULL
726                   ,p_attribute13   IN VARCHAR2 DEFAULT NULL
727                   ,p_attribute14   IN VARCHAR2 DEFAULT NULL
728                   ,p_attribute15   IN VARCHAR2 DEFAULT NULL
729                   ,p_attribute16   IN VARCHAR2 DEFAULT NULL
730                   ,p_attribute17   IN VARCHAR2 DEFAULT NULL
731                   ,p_attribute18   IN VARCHAR2 DEFAULT NULL
732                   ,p_attribute19   IN VARCHAR2 DEFAULT NULL
733                   ,p_attribute20   IN VARCHAR2 DEFAULT NULL
734                   )
735 IS
736   --
737   -- Variable to identify if and error has been logged in
738   -- hri_adm_msg_log
739   --
740   l_error                VARCHAR2(5);
741   --
742   -- Variable to store the status of the process
743   --
744   l_status               VARCHAR2(30);
745   --
746   -- Cursor returning whether an error or warning has occurred
747   --
748   CURSOR error_csr(v_mthd_action_id  NUMBER) IS
749   SELECT 'Y'
750   FROM dual
751   WHERE EXISTS
752    (SELECT null
753     FROM hri_adm_msg_log
754     WHERE mthd_action_id = v_mthd_action_id
755     AND msg_type in ('ERROR','WARNING'));
756   --
757 BEGIN
758   --
759   dbg('In log_process_end');
760   --
761   -- Bug 4105868
762   -- When this procedure is called by a program using the multithreading utility
763   -- the wrapup process should not be called if g_mthd_action_id is not populated.
764   -- This means that one of the child thread is updating the log table. The master
765   -- threads only should be updating BIS_REFRESH_LOG table.
766   --
767   IF g_mthd_action_id is not null THEN
768     --
769     bis_collection_utilities.wrapup
770             (p_status      => p_status
771             ,p_count       => p_count
772             ,p_message     => p_message
773             ,p_period_from => p_period_from
774             ,p_period_to   => p_period_to
775             ,p_attribute1  => p_attribute1
776             ,p_attribute2  => p_attribute2
777             ,p_attribute3  => p_attribute3
778             ,p_attribute4  => p_attribute4
779             ,p_attribute5  => p_attribute5
780             ,p_attribute6  => p_attribute6
781             ,p_attribute7  => p_attribute7
782             ,p_attribute8  => p_attribute8
783             ,p_attribute9  => p_attribute9
784             ,p_attribute10 => p_attribute10
785             );
786   ELSE
787     --
788     g_mthd_action_id := hri_opl_multi_thread.get_mthd_action_id
789                                 (p_program    => p_package_name
790                                 ,p_start_time => sysdate
791                                 );
792     --
793   END IF;
794   --
795   -- Flush the process infromation stored in the global array into
796   -- the hri_adm_msg_log table
797   --
798   flush_process_info
799    (p_package_name => p_package_name);
800 
801   -- If an error/warning message is encountered then the main process
802   -- should have 'Error' status
803   --
804   OPEN error_csr(g_mthd_action_id);
805   FETCH error_csr INTO l_error;
806   CLOSE error_csr;
807   --
808   -- If the global array has a record which is of error/warning type
809   -- or p_status is set to false then the status of the main process should
810   -- be set to 'ERROR'
811   --
812   IF l_error = 'Y' OR
813      p_status = false THEN
814     --
815     l_status := 'ERROR';
816     --
817   ELSE
818     --
819     l_status := 'PROCESSED';
820     --
821   END IF;
822   --
823   -- Update the row in hri_adm_mthd_actions to store the
824   -- process information
825   --
826   UPDATE hri_adm_mthd_actions
827   SET    status              =  l_status,
828          end_time            =  sysdate,
829          collect_from_date   =  p_period_from,
830          collect_to_date     =  p_period_to,
831          process_type        =  p_process_type,
832          program             =  p_package_name,
833          full_refresh_flag   =  p_full_refresh,
834          attribute1          =  p_attribute1,
835          attribute2          =  p_attribute2,
836          attribute3          =  p_attribute3,
837          attribute4          =  p_attribute4,
838          attribute5          =  p_attribute5,
839          attribute6          =  p_attribute6,
840          attribute7          =  p_attribute7,
841          attribute8          =  p_attribute8,
842          attribute9          =  p_attribute9,
843          attribute10         =  p_attribute10,
844          attribute11         =  p_attribute11,
845          attribute12         =  p_attribute12,
846          attribute13         =  p_attribute13,
847          attribute14         =  p_attribute14,
848          attribute15         =  p_attribute15,
849          attribute16         =  p_attribute16,
850          attribute17         =  p_attribute17,
851          attribute18         =  p_attribute18,
852          attribute19         =  p_attribute19,
853          attribute20         =  p_attribute20
854   WHERE mthd_action_id       =  g_mthd_action_id;
855   --
856   COMMIT;
857   --
858   dbg('Exiting log_process_end');
859   --
860 END log_process_end;
861 --
862 -- -------------------------------------------------------------------------
863 -- Procedure to be called by the obsoleted concurrent programs
864 -- -------------------------------------------------------------------------
865 --
866 PROCEDURE obsoleted_message
867                   (errbuf          OUT NOCOPY  VARCHAR2
868                   ,retcode         OUT  NOCOPY VARCHAR2
869                   )
870 IS
871   --
872 BEGIN
873   --
874   fnd_message.set_name('HRI','HRI_407286_OBSOLETED_CONC_PRGM');
875   --
876   fnd_file.put_line(fnd_file.LOG,fnd_message.get);
877   --
878 END obsoleted_message;
879 --
880 END hri_bpl_conc_log;