DBA Data[Home] [Help]

PACKAGE BODY: APPS.XLA_ACCOUNTING_DUMP_PKG

Source


1 PACKAGE BODY xla_accounting_dump_pkg AS
2 -- $Header: xlaapdmp.pkb 120.5 2008/01/17 12:23:27 kapkumar ship $
3 /*===========================================================================+
4 |             Copyright (c) 2001-2002 Oracle Corporation                     |
5 |                       Redwood Shores, CA, USA                              |
6 |                         All rights reserved.                               |
7 +============================================================================+
8 | PACKAGE NAME                                                               |
9 |     xla_accounting_dump_pkg                                                |
10 |                                                                            |
11 | DESCRIPTION                                                                |
12 |     Package Body for the Accounting Program Disgnostics.                   |
13 |                                                                            |
14 | HISTORY                                                                    |
15 |     24/08/2004     K. Boussema     Created                                 |
16 |     11/09/2004     K. Boussema     Reviewed to include data model changes  |
17 |     20/12/2004     K. Boussema     Reviewed the purge                      |
18 +===========================================================================*/
19 
20 --=============================================================================
21 --           ****************  declaraions  ********************
22 --=============================================================================
23 -------------------------------------------------------------------------------
24 -- declaring private constants
25 -------------------------------------------------------------------------------
26 C_MAXSIZE                    CONSTANT NUMBER        := 4000;
27 C_HEADER                     CONSTANT VARCHAR2(30) := 'HEADER'       ;
28 C_MLS_HEADER                 CONSTANT VARCHAR2(30) := 'HEADER_MLS'   ;
29 C_LINE                       CONSTANT VARCHAR2(30) := 'LINE'         ;
30 C_BC_LINE                    CONSTANT VARCHAR2(30) := 'LINE_BASE_CUR';
31 C_MLS_LINE                   CONSTANT VARCHAR2(30) := 'LINE_MLS'     ;
32 
33 
34 C_CHR_NEWLINE                CONSTANT VARCHAR2(10):= xla_environment_pkg.g_chr_newline;
35 
36 -------------------------------------------------------------------------------
37 -- declaring private structures
38 -------------------------------------------------------------------------------
39 TYPE t_array_number      IS TABLE OF NUMBER            INDEX BY BINARY_INTEGER;
40 TYPE t_array_date        IS TABLE OF DATE              INDEX BY BINARY_INTEGER;
41 TYPE t_array_char4000    IS TABLE OF VARCHAR2(4000)    INDEX BY BINARY_INTEGER;
42 TYPE t_array_char2000    IS TABLE OF VARCHAR2(2000)    INDEX BY BINARY_INTEGER;
43 TYPE t_array_char200     IS TABLE OF VARCHAR2(200)     INDEX BY BINARY_INTEGER;
44 TYPE t_array_char240     IS TABLE OF VARCHAR2(240)     INDEX BY BINARY_INTEGER;
45 TYPE t_array_char80      IS TABLE OF VARCHAR2(80)      INDEX BY BINARY_INTEGER;
49 TYPE r_diagnostic_event IS RECORD
46 TYPE t_array_char30      IS TABLE OF VARCHAR2(30)      INDEX BY BINARY_INTEGER;
47 TYPE t_array_char1       IS TABLE OF VARCHAR2(1)       INDEX BY BINARY_INTEGER;
48 
50    ( event_id                    t_array_number
51    , primary_ledger_id           t_array_number
52    , ledger_id                   t_array_number
53    , ledger_name                 t_array_char80
54    , transaction_number          t_array_char240
55    , event_number                t_array_number
56    , event_date                  t_array_date
57    , entity_code                 t_array_char30
58    , event_class_code            t_array_char30
59    , event_type_code             t_array_char30
60    , event_class_name            t_array_char80
61    , event_type_name             t_array_char80
62    , reference_num_1             t_array_number
63    , reference_num_2             t_array_number
64    , reference_num_3             t_array_number
65    , reference_num_4             t_array_number
66    , reference_char_1            t_array_char240
67    , reference_char_2            t_array_char240
68    , reference_char_3            t_array_char240
69    , reference_char_4            t_array_char240
70    , reference_date_1            t_array_date
71    , reference_date_2            t_array_date
72    , reference_date_3            t_array_date
73    , reference_date_4            t_array_date
74    );
75 
76 
77 -------------------------------------------------------------------------------
78 -- declaring private variables
79 -------------------------------------------------------------------------------
80 --
81 -- parametrers
82 --
83 g_application_id               PLS_INTEGER;
84 g_primary_ledger_id            PLS_INTEGER;
85 g_transaction_number           VARCHAR2(240);
86 g_event_number                 NUMBER;
87 g_event_type_code              VARCHAR2(30);
88 g_event_class_code             VARCHAR2(30);
89 g_entity_code                  VARCHAR2(30);
90 g_request_id                   NUMBER;
91 g_from_line_number             NUMBER;
92 g_to_line_number               NUMBER;
93 g_errors_only                  VARCHAR2(1);
94 g_source_name                  VARCHAR2(1);
95 g_acctg_attribute              VARCHAR2(1);
96 
97 g_array_events                 r_diagnostic_event;
98 
99 g_html_file                    t_array_char4000;
100 -------------------------------------------------------------------------------
101 -- forward declarion of private procedures and functions
102 -------------------------------------------------------------------------------
103 
104 
105 PROCEDURE write_html_file
106        (p_msg                        IN VARCHAR2)
107 ;
108 
109 PROCEDURE write_fnd_log_attachment
110 ;
111 
112 PROCEDURE write_output
113 ;
114 
115 PROCEDURE write_logfile
116        (p_msg                        IN VARCHAR2)
117 ;
118 
119 PROCEDURE write_title
120 ;
121 
122 PROCEDURE write_header
123 ;
124 
125 PROCEDURE write_footer
126 ;
127 
128 PROCEDURE write_warning_msg(
129    p_appli_s_name                 IN  VARCHAR2
130   ,p_msg_name                     IN  VARCHAR2
131   ,p_token_1                      IN  VARCHAR2
132   ,p_value_1                      IN  VARCHAR2
133   ,p_token_2                      IN  VARCHAR2
134   ,p_value_2                      IN  VARCHAR2
135   ,p_token_3                      IN  VARCHAR2
136   ,p_value_3                      IN  VARCHAR2
137 );
138 
139 PROCEDURE initialize
140        (p_application_id             IN NUMBER
141        ,p_ledger_id                  IN NUMBER
142        ,p_event_class_code           IN VARCHAR2
143        ,p_event_type_code            IN VARCHAR2
144        ,p_transaction_number         IN VARCHAR2
145        ,p_event_number               IN NUMBER
146        ,p_from_line_number           IN NUMBER
147        ,p_to_line_number             IN NUMBER
148        ,p_request_id                 IN NUMBER
149        ,p_errors_only                IN VARCHAR2
150        ,p_source_name                IN VARCHAR2
151        ,p_acctg_attribute            IN VARCHAR2)
152 ;
153 
154 PROCEDURE get_diagnostic_events
155 ;
156 
157 
158 PROCEDURE dump_diagnostic_events
159 ;
160 
161 PROCEDURE dump_diagnostic_Ledgers
162 ;
163 
164 PROCEDURE dump_transaction_objects(
165                                  p_event_id         IN NUMBER
166                                , p_ledger_id        IN NUMBER
167                                , p_ledger_name      IN VARCHAR2
168                                );
169 
170 PROCEDURE dump_diagnostic_sources
171 ;
172 
173 PROCEDURE dump_source_names (  p_event_id          IN NUMBER
174                              , p_ledger_id         IN NUMBER
175                              , p_ledger_name       IN VARCHAR2
176                              , p_object_name       IN VARCHAR2
177                              , p_object_type_code  IN VARCHAR2
178                                )
179 ;
180 
181 PROCEDURE dump_source_values ( p_event_id                 IN NUMBER
182                              , p_ledger_id                IN NUMBER
183                              , p_ledger_name              IN VARCHAR2
184                              , p_object_name              IN VARCHAR2
185                              , p_object_type_code         IN VARCHAR2
186                              )
187 ;
188 
189 PROCEDURE dump_acctg_attributes(  p_event_id         IN NUMBER
193 ;
190                                 , p_ledger_id        IN NUMBER
191                                 , p_ledger_name      IN VARCHAR2
192                                )
194 
195 PROCEDURE dump_hdr_attributes(    p_event_id         IN NUMBER
196                                 , p_ledger_id        IN NUMBER
197                                 , p_ledger_name      IN VARCHAR2
198                                )
199 ;
200 
201 PROCEDURE dump_line_attributes(   p_event_id         IN NUMBER
202                                 , p_ledger_id        IN NUMBER
203                                 , p_ledger_name      IN VARCHAR2
204                                )
205 ;
206 --=============================================================================
207 --               *********** Local Trace Routine **********
208 --=============================================================================
209 
210 --
211 --=============================================================================
212 --               *********** Local Trace Routine **********
213 --=============================================================================
214 
215 C_LEVEL_STATEMENT     CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
216 C_LEVEL_PROCEDURE     CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
217 C_LEVEL_EVENT         CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
218 C_LEVEL_EXCEPTION     CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
219 C_LEVEL_ERROR         CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
220 C_LEVEL_UNEXPECTED    CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
221 
222 C_LEVEL_LOG_DISABLED  CONSTANT NUMBER := 99;
223 C_DEFAULT_MODULE      CONSTANT VARCHAR2(240) := 'xla.plsql.xla_accounting_dump_pkg';
224 
225 g_log_level           NUMBER;
226 g_log_enabled         BOOLEAN;
227 
228 PROCEDURE trace
229            (p_msg                        IN VARCHAR2
230            ,p_level                      IN NUMBER
231            ,p_module                     IN VARCHAR2 )
232 IS
233 BEGIN
234 IF (p_msg IS NULL AND p_level >= g_log_level) THEN
235           fnd_log.message(p_level, p_module);
236 ELSIF p_level >= g_log_level THEN
237           fnd_log.string(p_level, p_module, p_msg);
238 END IF;
239 
240 EXCEPTION
241        WHEN xla_exceptions_pkg.application_exception THEN
242           RAISE;
243        WHEN OTHERS THEN
244           xla_exceptions_pkg.raise_message
245              (p_location   => 'XLA_CMP_EVENT_TYPE_PKG.trace');
246 END trace;
247 
248 
249 /*======================================================================+
250 |                                                                       |
251 | Private Procedure                                                     |
252 |                                                                       |
253 | write_fnd_log_attachment                                              |
254 |                                                                       |
255 |                                                                       |
256 +======================================================================*/
257 PROCEDURE write_fnd_log_attachment
258 IS
259 l_log_module                      VARCHAR2(240);
260 l_attachment_id                   NUMBER;
261 BEGIN
262 IF g_log_enabled THEN
263       l_log_module := C_DEFAULT_MODULE||'.write_fnd_log_attachment';
264 END IF;
265 
266 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
267 
268       trace
269          (p_msg      => 'BEGIN of procedure write_fnd_log_attachment'
270          ,p_level    => C_LEVEL_PROCEDURE
271          ,p_module   => l_log_module);
272 
273 END IF;
274 
275 IF (C_LEVEL_STATEMENT  >= g_log_level) THEN
276 
277    trace
278          (p_msg      => 'number of lines to write in fnd logfile ='||g_html_file.COUNT
279          ,p_level    => C_LEVEL_STATEMENT
280          ,p_module   => l_log_module);
281 
282    trace
283          (p_msg      => 'Call fnd_log.message_with_attachment API'
284          ,p_level    => C_LEVEL_STATEMENT
285          ,p_module   => l_log_module);
286 END IF;
287 
288 IF (C_LEVEL_UNEXPECTED  >= g_log_level) THEN
289 
290    FND_MESSAGE.SET_NAME('XLA','XLA_DIAGNOSTICS_OUTPUT');
291 
292    l_attachment_id:= FND_LOG.MESSAGE_WITH_ATTACHMENT(
293                          C_LEVEL_UNEXPECTED,
294                          l_log_module,
295                          TRUE,
296                         'ascii',
297                         'text/html',
298                          NULL,
299                          NULL,
300                          'html',
301                          'Accounting Event Extract Diagnostics Output'
302                          );
303 
304 ELSE
305 
306   l_attachment_id := -1;
307 
308 END IF;
309 
310 IF (C_LEVEL_STATEMENT  >= g_log_level) THEN
311 
312    trace
313         (p_msg      => 'l_attachment_id ='||l_attachment_id
314         ,p_level    => C_LEVEL_STATEMENT
315         ,p_module   => l_log_module);
316 
317 END IF;
318 
319 IF l_attachment_id <> -1 AND g_html_file.COUNT > 0 THEN
320 
321        IF (C_LEVEL_STATEMENT  >= g_log_level) THEN
322          trace
323          (p_msg      => 'Call FND_LOG_ATTACHMENT.WRITE() API'
324          ,p_level    => C_LEVEL_STATEMENT
325          ,p_module   => l_log_module);
326        END IF;
327 
328 
329       FOR Idx IN g_html_file.FIRST .. g_html_file.LAST LOOP
330 
334 
331          IF g_html_file.EXISTS(Idx) AND g_html_file(Idx) IS NOT NULL THEN
332 
333             FND_LOG_ATTACHMENT.WRITE(l_attachment_id,g_html_file(Idx));
335          END IF;
336 
337       END LOOP;
338 
339       IF (C_LEVEL_STATEMENT  >= g_log_level) THEN
340          trace
341          (p_msg      => 'Call FND_LOG_ATTACHMENT.CLOSE()'
342          ,p_level    => C_LEVEL_STATEMENT
343          ,p_module   => l_log_module);
344        END IF;
345 
346       FND_LOG_ATTACHMENT.CLOSE(l_attachment_id);
347 
348 END IF;
349 
350 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
351       trace
352          (p_msg      => 'END of procedure write_fnd_log_attachment'
353          ,p_level    => C_LEVEL_PROCEDURE
354          ,p_module   => l_log_module);
355 END IF;
356 
357 EXCEPTION
358    WHEN xla_exceptions_pkg.application_exception THEN
359       RAISE;
360    WHEN OTHERS THEN
361       xla_exceptions_pkg.raise_message
362          (p_location   => 'xla_accounting_dump_pkg.write_fnd_log_attachment');
363 END write_fnd_log_attachment;
364 
365 --=============================================================================
366 --               *********** Concurrent Program routines **********
367 --=============================================================================
368 
369 /*======================================================================+
370 |                                                                       |
371 | Private Procedure                                                     |
372 |                                                                       |
373 | write_logfile                                                         |
374 |                                                                       |
375 | Printer the string in fnd log file                                    |
376 |                                                                       |
377 +======================================================================*/
378 PROCEDURE write_logfile
379        (p_msg                        IN VARCHAR2) IS
380 BEGIN
381 
382    fnd_file.put_line(fnd_file.log,p_msg);
383 
384 EXCEPTION
385    WHEN xla_exceptions_pkg.application_exception THEN
386       RAISE;
387    WHEN OTHERS THEN
388       xla_exceptions_pkg.raise_message
389          (p_location   => 'xla_accounting_dump_pkg.write_logfile');
390 END write_logfile;
391 
392 /*======================================================================+
393 |                                                                       |
394 | Private Procedure                                                     |
395 |                                                                       |
396 | write_output                                                          |
397 |                                                                       |
398 | Printer the string in fnd output file                                 |
399 |                                                                       |
400 +======================================================================*/
401 PROCEDURE write_output IS
402 l_log_module                      VARCHAR2(240);
403 BEGIN
404 IF g_log_enabled THEN
405       l_log_module := C_DEFAULT_MODULE||'.write_output';
406 END IF;
407 
408 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
409       trace
410          (p_msg      => 'BEGIN of procedure write_output'
411          ,p_level    => C_LEVEL_PROCEDURE
412          ,p_module   => l_log_module);
413 END IF;
414 
415 IF g_html_file.COUNT > 0 THEN
416 
417      FOR Idx IN g_html_file.FIRST .. g_html_file.LAST LOOP
418 
419          IF g_html_file.EXISTS(Idx) AND g_html_file(Idx) IS NOT NULL THEN
420 
421             fnd_file.put_line(fnd_file.output,g_html_file(Idx));
422 
423          END IF;
424 
425       END LOOP;
426 
427 END IF;
428 
429 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
430       trace
431          (p_msg      => 'END of procedure write_output'
432          ,p_level    => C_LEVEL_PROCEDURE
433          ,p_module   => l_log_module);
434 END IF;
435 EXCEPTION
436    WHEN xla_exceptions_pkg.application_exception THEN
437       RAISE;
438    WHEN OTHERS THEN
439       xla_exceptions_pkg.raise_message
440          (p_location   => 'xla_accounting_dump_pkg.write_output');
441 END write_output;
442 
443 
444 /*======================================================================+
445 |                                                                       |
446 | Private Procedure                                                     |
447 |                                                                       |
448 | write_html_file                                                       |
449 |                                                                       |
450 | Printer the string in fnd output file                                 |
451 |                                                                       |
452 +======================================================================*/
453 PROCEDURE write_html_file
454        (p_msg                        IN VARCHAR2) IS
455 BEGIN
456 
457    g_html_file(NVL(g_html_file.LAST,0) +1 ):= SUBSTR(p_msg,1,C_MAXSIZE);
458 
459 EXCEPTION
460    WHEN xla_exceptions_pkg.application_exception THEN
461       RAISE;
462    WHEN OTHERS THEN
463       xla_exceptions_pkg.raise_message
464          (p_location   => 'xla_accounting_dump_pkg.write_html_file');
468 --          *********** Accounting Program Diagnostics routine **********
465 END write_html_file;
466 
467 --=============================================================================
469 --=============================================================================
470 
471 
472 /*======================================================================+
473 |                                                                       |
474 | Private Procedure                                                     |
475 |                                                                       |
476 | write_title                                                           |
477 |                                                                       |
478 | Printer the title                                                     |
479 |                                                                       |
480 +======================================================================*/
481 PROCEDURE write_title
482 IS
483 l_log_module                      VARCHAR2(240);
484 l_request_id                      NUMBER;
485 BEGIN
486    IF g_log_enabled THEN
487       l_log_module := C_DEFAULT_MODULE||'.write_title';
488    END IF;
489    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
490       trace
491          (p_msg      => 'BEGIN of procedure write_title'
492          ,p_level    => C_LEVEL_PROCEDURE
493          ,p_module   => l_log_module);
494    END IF;
495 
496    l_request_id                := fnd_global.conc_request_id();
497    write_html_file('<html>');
498    write_html_file('<head>');
499    write_html_file('<title> Accounting Program Diagnostics ( request id: '||l_request_id||')</title>');
500    write_html_file('</head>');
501    write_html_file('<body>');
502    write_html_file('<h2 align="center"> Transaction Objects Diagnostic Output </h2>');
503    write_html_file('<div style="text-align: center;"> Request Id '||TO_CHAR(l_request_id)
504                 ||' run at System time: '||TO_CHAR(sysdate,'fmDD-MON-YYYY fmHH24:MI:SS'));
505    write_html_file('</div>');
506    write_html_file('<br>');
507    write_html_file('<br><br>');
508 
509 
510    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
511       trace
512          (p_msg      => 'END of procedure write_title'
513          ,p_level    => C_LEVEL_PROCEDURE
514          ,p_module   => l_log_module);
515 
516    END IF;
517 EXCEPTION
518 WHEN xla_exceptions_pkg.application_exception THEN
519    RAISE;
520 WHEN OTHERS THEN
521    xla_exceptions_pkg.raise_message
522       (p_location => 'xla_accounting_dump_pkg.write_title');
523 END write_title;
524 /*======================================================================+
525 |                                                                       |
526 | Private Procedure                                                     |
527 |                                                                       |
528 | write_header                                                          |
529 |                                                                       |
530 | Printer the standard header                                           |
531 |                                                                       |
532 +======================================================================*/
533 PROCEDURE write_header
534 IS
535 l_log_module                VARCHAR2(240);
536 l_application_name          VARCHAR2(80);
537 l_application_id            NUMBER;
538 l_ledger_name               VARCHAR2(80);
539 l_event_class_name          VARCHAR2(80);
540 l_event_type_name           VARCHAR2(80);
541 l_transaction_number        VARCHAR2(240);
542 l_event_number              VARCHAR2(80);
543 l_from_line_number          VARCHAR2(80);
544 l_to_line_number            VARCHAR2(80);
545 l_parent_request_id         VARCHAR2(80);
546 l_error_only                VARCHAR2(80);
547 l_source_name               VARCHAR2(80);
548 l_acctg_attribute           VARCHAR2(80);
549 BEGIN
550 IF g_log_enabled THEN
551       l_log_module := C_DEFAULT_MODULE||'.write_header';
552    END IF;
553    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
554       trace
555          (p_msg      => 'BEGIN of procedure write_header'
556          ,p_level    => C_LEVEL_PROCEDURE
557          ,p_module   => l_log_module);
558    END IF;
559 --======================================================================
560 -- set local variables
561 --======================================================================
562 l_transaction_number        := g_transaction_number;
563 l_event_number              := TO_CHAR(g_event_number);
564 l_from_line_number          := TO_CHAR(g_from_line_number);
565 l_to_line_number            := TO_CHAR(g_to_line_number);
566 l_parent_request_id         := TO_CHAR(g_request_id) ;
567 l_error_only                := g_errors_only;
568 l_source_name               := g_source_name;
569 l_acctg_attribute           := g_acctg_attribute ;
570 
571 BEGIN
572 --
573 --
574 --
575  SELECT DISTINCT
576        a.application_id                                         application_id
577      , nvl(a2.application_name, TO_CHAR(g_application_id))      application_name
578      , nvl(b.name,TO_CHAR(g_primary_ledger_id))                 ledger_name
579      , nvl(d.name,g_event_class_code )                          event_class_name
580      , nvl(e.name,g_event_type_code)                            event_type_name
581  INTO  l_application_id
582     ,  l_application_name
583     ,  l_ledger_name
584     ,  l_event_class_name
585     ,  l_event_type_name
586  FROM  fnd_application_tl      a
587      , fnd_application_tl      a2
588      , xla_subledger_options_v b
589      , xla_event_classes_tl    d
593    AND a2.language        (+)= USERENV('LANG')
590      , xla_event_types_tl      e
591  WHERE a.application_id      = g_application_id
592    AND a2.application_id  (+)= a.application_id
594    AND b.ledger_id        (+)= nvl(g_primary_ledger_id,-99)
595    AND b.application_id   (+)= a.application_id
596    AND d.entity_code      (+)= nvl(g_entity_code,'#')
597    AND d.event_class_code (+)= nvl(g_event_class_code,'#')
598    AND d.application_id   (+)= a.application_id
599    AND d.language         (+)= USERENV('LANG')
600    AND e.entity_code      (+)= nvl(g_entity_code,'#')
601    AND e.event_class_code (+)= nvl(g_event_class_code,'#')
602    AND e.event_type_code  (+)= nvl(g_event_type_code,'#')
603    AND e.application_id   (+)= a.application_id
604    AND e.language         (+)= USERENV('LANG')
605 ;
606 
607 
608 EXCEPTION
609 
610   WHEN OTHERS THEN
611 
612     l_application_name := TO_CHAR(g_application_id);
613     l_ledger_name      := TO_CHAR(g_primary_ledger_id);
614     l_event_class_name := g_event_class_code;
615     l_event_type_name  := g_event_type_code;
616 
617 END;
618 
619 
620 BEGIN
621 
622   SELECT x1.meaning ,
623          x2.meaning ,
624          x3.meaning
625     INTO l_error_only         ,
626          l_source_name        ,
627          l_acctg_attribute
628     FROM XLA_LOOKUPS x1,
629          XLA_LOOKUPS x2,
630          XLA_LOOKUPS x3
631    WHERE x1.lookup_type = 'XLA_YES_NO'
632      and x1.lookup_type = x2.lookup_type
633      and x1.lookup_type = x3.lookup_type
634      and x1.lookup_code = g_errors_only
635      and x2.lookup_code = g_source_name
636      and x3.lookup_code = g_acctg_attribute
637     ;
638 
639 EXCEPTION
640   WHEN NO_DATA_FOUND THEN
641     l_error_only        :=   g_errors_only;
642     l_source_name       :=   g_acctg_attribute;
643     l_acctg_attribute   :=   g_source_name;
644   WHEN OTHERS THEN
645     l_error_only        :=   g_errors_only;
646     l_source_name       :=   g_acctg_attribute;
647     l_acctg_attribute   :=   g_source_name;
648 END;
649 
650 
651    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
652       trace
653          (p_msg      => 'Write Search criteria'
654          ,p_level    => C_LEVEL_STATEMENT
655          ,p_module   => l_log_module);
656    END IF;
657 
658    write_html_file('<b> Search Criteria </b>');
659    write_html_file('<br><br>');
660    write_html_file('<table border="0"><tbody>');
661 
662    write_html_file('<tr style="background-color: #cccc99">');
663    write_html_file('<th style="text-align: left;"> Application Name </th>');
664    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_application_name||'</td>');
665    write_html_file('</tr>');
666 
667    write_html_file('<tr style="background-color: #cccc99">');
668    write_html_file('<th style="text-align: left;"> Ledger Name </th>');
669    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_ledger_name||'</td>');
670    write_html_file('</tr>');
671 
672    write_html_file('<tr style="background-color: #cccc99">');
673    write_html_file('<th style="text-align: left;"> Event Class Name </th>');
674    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_event_class_name||'</td>');
675    write_html_file('</tr>');
676 
677    write_html_file('<tr style="background-color: #cccc99">');
678    write_html_file('<th style="text-align: left;"> Event Type Name </th>');
679    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_event_type_name||'</td>');
680    write_html_file('</tr>');
681 
682    write_html_file('<tr style="background-color: #cccc99">');
683    write_html_file('<th style="text-align: left;"> Transaction number </th>');
684    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_transaction_number||'</td>');
685    write_html_file('</tr>');
686 
687    write_html_file('<tr style="background-color: #cccc99">');
688    write_html_file('<th style="text-align: left;"> Event Number </th>');
689    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_event_number||'</td>');
690    write_html_file('</tr>');
691 
692    write_html_file('<tr style="background-color: #cccc99">');
693    write_html_file('<th style="text-align: left;"> From Distribution Line Number </th>');
694    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_from_line_number||'</td>');
695    write_html_file('</tr>');
696 
697    write_html_file('<tr style="background-color: #cccc99">');
698    write_html_file('<th style="text-align: left;"> To Distribution Line Number </th>');
699    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_to_line_number||'</td>');
700    write_html_file('</tr>');
701 
702    write_html_file('<tr style="background-color: #cccc99">');
703    write_html_file('<th style="text-align: left;"> Accounting Program Request id </th>');
704    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_parent_request_id||'</td>');
705    write_html_file('</tr>');
706 
707    write_html_file('<tr style="background-color: #cccc99">');
708    write_html_file('<th style="text-align: left;"> Errors Only </th>');
709    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_error_only||'</td>');
710    write_html_file('</tr>');
711 
712    write_html_file('<tr style="background-color: #cccc99">');
713    write_html_file('<th style="text-align: left;"> Display Source Name </th>');
714    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_source_name||'</td>');
715    write_html_file('</tr>');
716 
720    write_html_file('</tr>');
717    write_html_file('<tr style="background-color: #cccc99">');
718    write_html_file('<th style="text-align: left;"> Display Accounting Attributes </th>');
719    write_html_file('<td style="background-color: #f7f7e7" valign="top">'||l_acctg_attribute||'</td>');
721 
722    write_html_file('</tbody>');
723    write_html_file('</table>');
724 
725    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
726       trace
727          (p_msg      => 'END of procedure write_header'
728          ,p_level    => C_LEVEL_PROCEDURE
729          ,p_module   => l_log_module);
730    END IF;
731 
732 EXCEPTION
733 WHEN xla_exceptions_pkg.application_exception THEN
734    RAISE;
735 WHEN OTHERS THEN
736    xla_exceptions_pkg.raise_message
737       (p_location => 'xla_accounting_dump_pkg.write_header');
738 END write_header;
739 
740 /*======================================================================+
741 |                                                                       |
742 | Private Procedure                                                     |
743 |                                                                       |
744 | write_warning_msg                                                     |
745 |                                                                       |
746 | Printer the warnig message                                            |
747 |                                                                       |
748 +======================================================================*/
749 --
750 -- to review in order to remove the message hard coded
751 --
752 PROCEDURE write_warning_msg(
753    p_appli_s_name                 IN  VARCHAR2
754   ,p_msg_name                     IN  VARCHAR2
755   ,p_token_1                      IN  VARCHAR2
756   ,p_value_1                      IN  VARCHAR2
757   ,p_token_2                      IN  VARCHAR2
758   ,p_value_2                      IN  VARCHAR2
759   ,p_token_3                      IN  VARCHAR2
760   ,p_value_3                      IN  VARCHAR2
761 )
762 IS
763 l_new_line                  VARCHAR2(200);
764 l_tab                       VARCHAR2(200);
765 l_log_module                VARCHAR2(240);
766 l_message                   VARCHAR2(4000);
767 l_message_number            NUMBER;
768 BEGIN
769 IF g_log_enabled THEN
770       l_log_module := C_DEFAULT_MODULE||'.write_warning_msg';
771    END IF;
772    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
773       trace
774          (p_msg      => 'BEGIN of procedure write_warning_msg'
775          ,p_level    => C_LEVEL_PROCEDURE
776          ,p_module   => l_log_module);
777 
778    END IF;
779    --
780    l_tab      := '&'||'nbsp;'||'&'||'nbsp;'||'&'||'nbsp;';
781    l_new_line := '<br>';
782    --
783 
784    fnd_message.set_name(p_appli_s_name ,p_msg_name);
785 
786    IF p_token_1 IS NOT NULL THEN fnd_message.set_token(p_token_1 ,p_value_1); END IF;
787 
788    IF p_token_2 IS NOT NULL THEN fnd_message.set_token(p_token_2,p_value_2);  END IF;
789 
790    IF p_token_3 IS NOT NULL THEN fnd_message.set_token(p_token_3,p_value_3);  END IF;
791 
792    l_message := SUBSTR(fnd_message.get,1,2000);
793 
794    l_message := REPLACE(l_message, C_CHR_NEWLINE,l_new_line || l_tab );
795 
796    write_html_file(l_new_line||l_tab);
797    write_html_file(l_message);
798    write_html_file('<br><br>');
799 
800    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
801       trace
802          (p_msg      => 'END of procedure write_warning_msg'
803          ,p_level    => C_LEVEL_PROCEDURE
804          ,p_module   => l_log_module);
805    END IF;
806 
807 EXCEPTION
808 WHEN xla_exceptions_pkg.application_exception THEN
809    RAISE;
810 WHEN OTHERS THEN
811    xla_exceptions_pkg.raise_message
812       (p_location => 'xla_accounting_dump_pkg.write_warning_msg');
813 END write_warning_msg;
814 
815 /*======================================================================+
816 |                                                                       |
817 | Private Procedure                                                     |
818 |                                                                       |
819 | write_footer                                                          |
820 |                                                                       |
821 | Printer the standard footer                                           |
822 |                                                                       |
823 +======================================================================*/
824 PROCEDURE write_footer
825 IS
826 l_log_module                      VARCHAR2(240);
827 BEGIN
828    IF g_log_enabled THEN
829       l_log_module := C_DEFAULT_MODULE||'.write_footer';
830    END IF;
831    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
832       trace
833          (p_msg      => 'BEGIN of procedure write_footer'
834          ,p_level    => C_LEVEL_PROCEDURE
835          ,p_module   => l_log_module);
836    END IF;
837 
838    write_html_file('</body>');
839    write_html_file('</html>');
840 
841    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
842       trace
843          (p_msg      => 'END of procedure write_footer'
844          ,p_level    => C_LEVEL_PROCEDURE
845          ,p_module   => l_log_module);
846 
847    END IF;
848 EXCEPTION
849 WHEN xla_exceptions_pkg.application_exception THEN
850    RAISE;
851 WHEN OTHERS THEN
852    xla_exceptions_pkg.raise_message
853       (p_location => 'xla_accounting_dump_pkg.write_footer');
854 END write_footer;
855 
859 --
856 --=============================================================================
857 --
858 --
860 --=============================================================================
861 PROCEDURE initialize
862        (p_application_id             IN NUMBER
863        ,p_ledger_id                  IN NUMBER
864        ,p_event_class_code           IN VARCHAR2
865        ,p_event_type_code            IN VARCHAR2
866        ,p_transaction_number         IN VARCHAR2
867        ,p_event_number               IN NUMBER
868        ,p_from_line_number           IN NUMBER
869        ,p_to_line_number             IN NUMBER
870        ,p_request_id                 IN NUMBER
871        ,p_errors_only                IN VARCHAR2
872        ,p_source_name                IN VARCHAR2
873        ,p_acctg_attribute            IN VARCHAR2) IS
874 
875 l_log_module                      VARCHAR2(240);
876 l_array_null_events               r_diagnostic_event;
877 l_null_html_file                  t_array_char4000;
878 BEGIN
879    IF g_log_enabled THEN
880       l_log_module := C_DEFAULT_MODULE||'.initialize';
881    END IF;
882    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
883       trace
884          (p_msg      => 'BEGIN of procedure initialize'
885          ,p_level    => C_LEVEL_PROCEDURE
886          ,p_module   => l_log_module);
887       trace
888          (p_msg      => 'p_application_id = '||p_application_id
889          ,p_level    => C_LEVEL_PROCEDURE
890          ,p_module   => l_log_module);
891       trace
892          (p_msg      => 'p_ledger_id = '||p_ledger_id
893          ,p_level    => C_LEVEL_PROCEDURE
894          ,p_module   => l_log_module);
895       trace
896          (p_msg      => 'p_event_class_code = '||p_event_class_code
897          ,p_level    => C_LEVEL_PROCEDURE
898          ,p_module   => l_log_module);
899       trace
900          (p_msg      => 'p_event_type_code = '||p_event_type_code
901          ,p_level    => C_LEVEL_PROCEDURE
902          ,p_module   => l_log_module);
903       trace
904          (p_msg      => 'p_transaction_number = '||p_transaction_number
905          ,p_level    => C_LEVEL_PROCEDURE
906          ,p_module   => l_log_module);
907       trace
908          (p_msg      => 'p_event_number = '||p_event_number
909          ,p_level    => C_LEVEL_PROCEDURE
910          ,p_module   => l_log_module);
911       trace
912          (p_msg      => 'p_from_line_number = '||p_from_line_number
913          ,p_level    => C_LEVEL_PROCEDURE
914          ,p_module   => l_log_module);
915       trace
916          (p_msg      => 'p_to_line_number = '||p_to_line_number
917          ,p_level    => C_LEVEL_PROCEDURE
918          ,p_module   => l_log_module);
919       trace
920          (p_msg      => 'p_request_id = '||p_request_id
921          ,p_level    => C_LEVEL_PROCEDURE
922          ,p_module   => l_log_module);
923 
924       trace
925          (p_msg      => 'p_errors_only = '||p_errors_only
926          ,p_level    => C_LEVEL_PROCEDURE
927          ,p_module   => l_log_module);
928 
929       trace
930          (p_msg      => 'p_source_name = '||p_source_name
931          ,p_level    => C_LEVEL_PROCEDURE
932          ,p_module   => l_log_module);
933 
934     trace
935          (p_msg      => 'p_acctg_attribute = '||p_acctg_attribute
936          ,p_level    => C_LEVEL_PROCEDURE
937          ,p_module   => l_log_module);
938 
939    END IF;
940 
941    ----------------------------------------------------------------------------
942    -- Initializing global variables
943    ----------------------------------------------------------------------------
944 
945    g_application_id                  :=  p_application_id;
946    g_primary_ledger_id               :=  p_ledger_id;
947    g_transaction_number              :=  p_transaction_number;
948    g_event_number                    :=  p_event_number;
949    g_event_type_code                 :=  p_event_type_code;
950    g_event_class_code                :=  p_event_class_code;
951    g_entity_code                     :=  NULL;
952    g_request_id                      :=  p_request_id;
953    g_errors_only                     :=  p_errors_only;
954    g_source_name                     :=  p_source_name;
955    g_acctg_attribute                 :=  p_acctg_attribute;
956    g_from_line_number                :=  p_from_line_number;
957    g_to_line_number                  :=  p_to_line_number ;
958 
959    g_array_events                    := l_array_null_events;
960 
961    g_html_file                       := l_null_html_file;
962 
963    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
964       trace
965          (p_msg      => 'END of procedure initialize'
966          ,p_level    => C_LEVEL_PROCEDURE
967          ,p_module   => l_log_module);
968    END IF;
969 
970 EXCEPTION
971 WHEN xla_exceptions_pkg.application_exception THEN
972    RAISE;
973 WHEN OTHERS THEN
974    xla_exceptions_pkg.raise_message
975       (p_location => 'xla_accounting_dump_pkg.initialize');
976 END initialize;   -- end of procedure
977 
978 --=============================================================================
979 --
980 --
981 --
982 --=============================================================================
983 PROCEDURE get_diagnostic_events  IS
984 
985 l_log_module                      VARCHAR2(240);
986 l_array_null_events               r_diagnostic_event;
987 BEGIN
988 
989    IF g_log_enabled THEN
990       l_log_module := C_DEFAULT_MODULE||'.get_diagnostic_events';
994       trace
991    END IF;
992 
993    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
995          (p_msg      => 'BEGIN of procedure get_diagnostic_events'
996          ,p_level    => C_LEVEL_PROCEDURE
997          ,p_module   => l_log_module);
998    END IF;
999 
1000    BEGIN
1001 
1002      SELECT DISTINCT
1003             xde.event_id
1004            ,xde.ledger_id
1005            ,xde.transaction_number
1006            ,xde.event_number
1007            ,xde.entity_code
1008            ,xde.event_class_code
1009            ,xde.event_type_code
1010            ,xde.event_date
1011            ,xdl.ledger_id
1012            ,nvl(xsov.name,TO_CHAR(xdl.ledger_id))
1013            ,xe.reference_num_1
1014            ,xe.reference_num_2
1015            ,xe.reference_num_3
1016            ,xe.reference_num_4
1017            ,xe.reference_char_1
1018            ,xe.reference_char_2
1019            ,xe.reference_char_3
1020            ,xe.reference_char_4
1021            ,xe.reference_date_1
1022            ,xe.reference_date_2
1023            ,xe.reference_date_3
1024            ,xe.reference_date_4
1025            ,nvl(xect.name,xde.event_class_code )
1026            ,nvl(xett.name,xde.event_type_code)
1027        BULK COLLECT
1028        INTO g_array_events.event_id,
1029             g_array_events.primary_ledger_id,
1030             g_array_events.transaction_number,
1031             g_array_events.event_number,
1032             g_array_events.entity_code,
1033             g_array_events.event_class_code,
1034             g_array_events.event_type_code,
1035             g_array_events.event_date,
1036             g_array_events.ledger_id,
1037             g_array_events.ledger_name,
1038             g_array_events.reference_num_1,
1039             g_array_events.reference_num_2,
1040             g_array_events.reference_num_3,
1041             g_array_events.reference_num_4,
1042             g_array_events.reference_char_1,
1043             g_array_events.reference_char_2,
1044             g_array_events.reference_char_3,
1045             g_array_events.reference_char_4,
1046             g_array_events.reference_date_1,
1047             g_array_events.reference_date_2,
1048             g_array_events.reference_date_3,
1049             g_array_events.reference_date_4,
1050             g_array_events.event_class_name,
1051             g_array_events.event_type_name
1052        FROM xla_events              xe
1053           , xla_diag_events         xde
1054           , xla_diag_ledgers        xdl
1055           , xla_subledger_options_v xsov
1056           , xla_event_classes_tl    xect
1057           , xla_event_types_tl      xett
1058       WHERE xe.application_id      = xde.application_id
1059         AND xe.event_type_code     = xde.event_type_code
1060         AND xe.event_id            = xde.event_id
1061         AND xe.event_number        = xde.event_number
1062         AND xde.application_id     = xdl.application_id
1063         AND xde.ledger_id          = xdl.primary_ledger_id
1064         AND xde.request_id         = xdl.accounting_request_id
1065         AND xdl.application_id     = xsov.application_id (+)
1066         AND xdl.ledger_id          = xsov.ledger_id(+)
1067         AND xde.ledger_id          = nvl(g_primary_ledger_id,xde.ledger_id)
1068         AND xde.event_number       = nvl(g_event_number, xde.event_number)
1069         AND xde.transaction_number = nvl(g_transaction_number,xde.transaction_number)
1070         AND xde.event_class_code   = nvl(g_event_class_code,xde.event_class_code)
1071         AND xde.event_type_code    = DECODE(g_event_type_code
1072                                             ,NULL,xde.event_type_code
1073                                             ,g_event_type_code)
1074         AND xde.request_id             = nvl(g_request_id,xde.request_id)
1075         AND xe.process_status_code     = DECODE(g_errors_only,
1076                                              'Y', DECODE(xe.process_status_code,
1077                                                          'I','I',
1078                                                          'R','R',
1079                                                          'E')
1080                                             , xe.process_status_code)
1081         AND xde.application_id     = g_application_id
1082         AND xect.entity_code      (+)= xde.entity_code
1083         AND xect.event_class_code (+)= xde.event_class_code
1084         AND xect.application_id   (+)= xde.application_id
1085         AND xect.language         (+)= USERENV('LANG')
1086         AND xett.entity_code      (+)= xde.entity_code
1087         AND xett.event_class_code (+)= xde.event_class_code
1088         AND xett.event_type_code  (+)= xde.event_type_code
1089         AND xett.application_id   (+)= xde.application_id
1090         AND xett.language         (+)= USERENV('LANG')
1091       ;
1092 
1093   EXCEPTION
1094 
1095      WHEN OTHERS THEN
1096         g_array_events            :=l_array_null_events;
1097   END;
1098 
1099    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1100          trace
1101             (p_msg      => 'number of rows retrieved = '||g_array_events.event_id.COUNT
1102             ,p_level    => C_LEVEL_STATEMENT
1103             ,p_module   => l_log_module);
1104    END IF;
1105 
1106    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1107       trace
1108          (p_msg      => 'END of procedure get_diagnostic_events'
1109          ,p_level    => C_LEVEL_PROCEDURE
1110          ,p_module   => l_log_module);
1111    END IF;
1112 
1113 EXCEPTION
1117    xla_exceptions_pkg.raise_message
1114 WHEN xla_exceptions_pkg.application_exception THEN
1115    RAISE;
1116 WHEN OTHERS THEN
1118       (p_location => 'xla_accounting_dump_pkg.get_diagnostic_events');
1119 END get_diagnostic_events;   -- end of procedure
1120 
1121  --
1122 /*======================================================================+
1123 |                                                                       |
1124 | Private Procedure                                                     |
1125 |                                                                       |
1126 | dump_diagnostic_events                                                |
1127 |                                                                       |
1128 |                                                                       |
1129 +======================================================================*/
1130 PROCEDURE dump_diagnostic_events
1131 IS
1132 l_log_module                VARCHAR2(240);
1133 BEGIN
1134 IF g_log_enabled THEN
1135       l_log_module := C_DEFAULT_MODULE||'.dump_diagnostic_events';
1136    END IF;
1137    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1138       trace
1139          (p_msg      => 'BEGIN of procedure dump_diagnostic_events'
1140          ,p_level    => C_LEVEL_PROCEDURE
1141          ,p_module   => l_log_module);
1142    END IF;
1143 
1144    write_html_file('<a NAME=getreturntothetop></a>');
1145    write_html_file('<br>');
1146    write_html_file('<b> Search Results </b>');
1147    write_html_file('<br><br>');
1148    write_html_file('<table border="0"><tbody>');
1149    write_html_file('<tr style="background-color: #cccc99">');
1150    write_html_file('<th> Event id </th>');
1151    write_html_file('<th> Ledger </th>');
1152    write_html_file('<th> Ledger Id </th>');
1153    write_html_file('<th> Transaction number </th>');
1154    write_html_file('<th> Event Number </th>');
1155    write_html_file('<th> Event Class Name</th>');
1156    write_html_file('<th> Event Type Name </th>');
1157    write_html_file('<th> Event Date </th>');
1158    write_html_file('</tr>');
1159 
1160 FOR event_cur IN (
1161 
1162 SELECT DISTINCT
1163          xde.event_id                                       event_id
1164        , xde.event_number                                   event_number
1165        , xde.event_date                                     event_date
1166        , xde.transaction_number                             transaction_number
1167        , xde.ledger_id                                      ledger_id
1168        , nvl(xsov.name,TO_CHAR(xde.ledger_id))              ledger_name
1169        , xde.entity_code                                    entity_code
1170        , nvl(xecv.name,xde.event_class_code )               event_class_name
1171        , xde.event_class_code                               event_class_code
1172        , nvl(xtv.name,xde.event_type_code)                  event_type_name
1173        , xde.event_type_code                                event_type_code
1174   FROM xla_events              xe
1175      , xla_diag_events         xde
1176      , xla_subledger_options_v xsov
1177      , xla_event_classes_tl    xecv
1178      , xla_event_types_tl      xtv
1179  WHERE xe.application_id         = xde.application_id
1180    AND xe.event_type_code        = xde.event_type_code
1181    AND xe.event_id               = xde.event_id
1182    AND xe.event_number           = xde.event_number
1183    AND xde.ledger_id             = nvl(g_primary_ledger_id,xde.ledger_id)
1184    AND xsov.ledger_id         (+)= xde.ledger_id
1185    AND xsov.application_id    (+)= xde.application_id
1186    AND xde.event_number          = nvl(g_event_number, xde.event_number)
1187    AND xde.transaction_number    = nvl(g_transaction_number,xde.transaction_number)
1188    AND xde.event_class_code      = nvl(g_event_class_code,xde.event_class_code)
1189    AND xecv.entity_code       (+)= xde.entity_code
1190    AND xecv.event_class_code  (+)= xde.event_class_code
1191    AND xecv.application_id    (+)= xde.application_id
1192    AND xecv.language          (+)= USERENV('LANG')
1193    AND xde.event_type_code       = DECODE(g_event_type_code
1194                                             ,NULL,xde.event_type_code
1195                                             ,xde.event_class_code||'_ALL',xde.event_type_code
1196                                             ,g_event_type_code)
1197    AND xtv.entity_code        (+)= xde.entity_code
1198    AND xtv.event_class_code   (+)= xde.event_class_code
1199    AND xtv.event_type_code    (+)= xde.event_type_code
1200    AND xtv.application_id     (+)= xde.application_id
1201    AND xtv.language           (+)= USERENV('LANG')
1202    AND xde.request_id             = nvl(g_request_id,xde.request_id)
1203    AND xe.process_status_code     = DECODE(g_errors_only,
1204                                              'Y', DECODE(xe.process_status_code,
1205                                                          'I','I',
1206                                                          'R','R',
1207                                                          'E')
1208                                             , xe.process_status_code)
1209    AND xde.application_id        = g_application_id
1210 )
1211 
1212 LOOP
1213 
1214 
1215    write_html_file('<tr style="background-color: #f7f7e7" valign="top">');
1216    write_html_file('<td><a href="#get'||TO_CHAR(event_cur.event_id)||'">'||TO_CHAR(event_cur.event_id)||'</a></td>');
1217    write_html_file('<td>'||event_cur.ledger_name||'</td>');
1218    write_html_file('<td style="text-align: right;">'||TO_CHAR(event_cur.ledger_id)||'</td>');
1219    write_html_file('<td>'||event_cur.transaction_number||'</td>');
1223    write_html_file('<td>'||TO_CHAR(event_cur.event_date)||'</td>');
1220    write_html_file('<td style="text-align: right;">'||TO_CHAR(event_cur.event_number) ||'</td>');
1221    write_html_file('<td>'||event_cur.event_class_name||'</td>');
1222    write_html_file('<td>'||event_cur.event_type_name||'</td>');
1224    write_html_file('</tr>');
1225 
1226 
1227 END LOOP;
1228 
1229    write_html_file('</tbody>');
1230    write_html_file('</table>');
1231    write_html_file('<a href=#getreturntothetop>Return to the top</a>');
1232    write_html_file('<br><br>');
1233 
1234 
1235    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1236       trace
1237          (p_msg      => 'END of procedure dump_diagnostic_events'
1238          ,p_level    => C_LEVEL_PROCEDURE
1239          ,p_module   => l_log_module);
1240    END IF;
1241 
1242 EXCEPTION
1243 WHEN xla_exceptions_pkg.application_exception THEN
1244    RAISE;
1245 WHEN OTHERS THEN
1246    xla_exceptions_pkg.raise_message
1247       (p_location => 'xla_accounting_dump_pkg.dump_diagnostic_events');
1248 END dump_diagnostic_events;
1249 
1250 
1251 /*======================================================================+
1252 |                                                                       |
1253 | Private Procedure                                                     |
1254 |                                                                       |
1255 | dump_diagnostic_Ledgers                                               |
1256 |                                                                       |
1257 |                                                                       |
1258 +======================================================================*/
1259 PROCEDURE dump_diagnostic_Ledgers
1260 IS
1261 l_log_module                VARCHAR2(240);
1262 BEGIN
1263 IF g_log_enabled THEN
1264       l_log_module := C_DEFAULT_MODULE||'.dump_diagnostic_Ledgers';
1265    END IF;
1266    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1267       trace
1268          (p_msg      => 'BEGIN of procedure dump_diagnostic_Ledgers'
1269          ,p_level    => C_LEVEL_PROCEDURE
1270          ,p_module   => l_log_module);
1271    END IF;
1272 
1273    write_html_file('<b> Ledger information </b>');
1274    write_html_file('<br><br>');
1275    write_html_file('<table border="0"><tbody>');
1276    write_html_file('<tr style="background-color: #cccc99">');
1277    write_html_file('<th> Ledger </th>');
1278    write_html_file('<th> Ledger Id</th>');
1279    write_html_file('<th> Primary Ledger </th>');
1280    write_html_file('<th> Primary Ledger Id</th>');
1281    write_html_file('<th> SLA ledger </th>');
1282    write_html_file('<th> SLA ledger Id</th>');
1283    write_html_file('<th> Description Language </th>');
1284    write_html_file('<th> Currency Code </th>');
1285    write_html_file('<th> Accounting Application Definition </th>');
1286    write_html_file('<th> Accounting Application Definition Owner</th>');
1287    write_html_file('<th> AMB Context code </th>');
1288    write_html_file('<th> Start Date Active</th>');
1289    write_html_file('<th> End Date Active </th>');
1290    write_html_file('</tr>');
1291 
1292 
1293 FOR ledger_cur IN ( SELECT DISTINCT
1294                           xdl.ledger_id                                      ledger_id
1295                         , xdl.primary_ledger_id                              primary_ledger_id
1296                         , xdl.sla_ledger_id                                  sla_ledger_id
1297                         , nvl(xso1.name,TO_CHAR(xdl.ledger_id))              ledger_name
1298                         , nvl(xso2.name,TO_CHAR(xdl.primary_ledger_id))      primary_ledger_name
1299                         , nvl(xso3.name,TO_CHAR(xdl.sla_ledger_id))          sla_ledger_name
1300                         , xdl.description_language                           description_language
1301                         , xdl.currency_code                                  currency_code
1302                         , nvl(xpr.name,xpr.product_rule_code)                aad_name
1303                         , xdl.product_rule_code                              aad_code
1304                         , xdl.product_rule_type_code                         aad_owner
1305                         , xdl.amb_context_code                               amb_context
1306                         , xdl.start_date_active                              start_date
1307                         , xdl.end_date_active                                end_date
1308  FROM  xla_events              xe
1309      , xla_diag_events      xde
1310      , xla_diag_ledgers     xdl
1311      , xla_subledger_options_v xso1
1312      , xla_subledger_options_v xso2
1313      , xla_subledger_options_v xso3
1314      , xla_product_rules_tl    xpr
1315  WHERE xe.application_id             = xde.application_id
1316    AND xe.event_id                   = xde.event_id
1317    AND xe.event_type_code            = xde.event_type_code
1318    AND xe.event_number               = xde.event_number
1319    AND xde.application_id            = xdl.application_id
1320    AND xde.ledger_id                 = xdl.primary_ledger_id
1321    AND xde.request_id                = xdl.accounting_request_id
1322    AND xdl.primary_ledger_id         = nvl(g_primary_ledger_id,xdl.primary_ledger_id)
1323    AND xpr.application_id         (+)= xdl.application_id
1324    AND xpr.product_rule_code      (+)= xdl.product_rule_code
1325    AND xpr.product_rule_type_code (+)= xdl.product_rule_type_code
1326    AND xpr.amb_context_code       (+)= xdl.amb_context_code
1327    AND xso1.ledger_id             (+)= xdl.ledger_id
1328    AND xso1.application_id        (+)= xdl.application_id
1329    AND xso2.ledger_id             (+)= xdl.primary_ledger_id
1333    AND xde.event_number              = nvl(g_event_number, xde.event_number)
1330    AND xso2.application_id        (+)= xdl.application_id
1331    AND xso3.ledger_id             (+)= xdl.sla_ledger_id
1332    AND xso3.application_id        (+)= xdl.application_id
1334    AND xde.transaction_number        = nvl(g_transaction_number,xde.transaction_number)
1335    AND xde.event_class_code          = nvl(g_event_class_code,xde.event_class_code)
1336    AND xde.event_type_code           = DECODE(g_event_type_code
1337                                             ,NULL,xde.event_type_code
1338                                             ,xde.event_class_code||'_ALL',xde.event_type_code
1339                                             ,g_event_type_code)
1340    AND xde.request_id                = nvl(g_request_id,xde.request_id)
1341    AND xe.process_status_code        = DECODE(g_errors_only,
1342                                              'Y', DECODE(xe.process_status_code,
1343                                                          'I','I',
1344                                                          'R','R',
1345                                                          'E')
1346                                             , xe.process_status_code)
1347    AND xde.application_id            = g_application_id
1348 )
1349 
1350 LOOP
1351 
1352    write_html_file('<tr style="background-color: #f7f7e7" valign="top">');
1353    write_html_file('<td>'||ledger_cur.ledger_name||'</td>');
1354    write_html_file('<td style="text-align: right;"><a NAME=get'||TO_CHAR(ledger_cur.ledger_id)||'>'||TO_CHAR(ledger_cur.ledger_id)||'</a></td>');
1355    write_html_file('<td>'||ledger_cur.primary_ledger_name||'</td>');
1356    write_html_file('<td style="text-align: right;">'||TO_CHAR(ledger_cur.primary_ledger_id)||'</td>');
1357    write_html_file('<td>'||ledger_cur.sla_ledger_name ||'</td>');
1358    write_html_file('<td style="text-align: right;">'||TO_CHAR(ledger_cur.sla_ledger_id)||'</td>');
1359    write_html_file('<td>'||ledger_cur.description_language||'</td>');
1360    write_html_file('<td>'||ledger_cur.currency_code||'</td>');
1361    write_html_file('<td>'||ledger_cur.aad_name||'</td>');
1362    write_html_file('<td>'||xla_lookups_pkg.get_meaning(
1363                                'XLA_OWNER_TYPE',
1364                                 ledger_cur.aad_owner)||'</td>');
1365    write_html_file('<td>'||ledger_cur.amb_context||'</td>');
1366    write_html_file('<td>'||ledger_cur.start_date||'</td>');
1367    write_html_file('<td>'||ledger_cur.end_date||'</td>');
1368    write_html_file('</tr>');
1369 
1370 
1371 
1372 END LOOP;
1373 
1374    write_html_file('</tbody>');
1375    write_html_file('</table>');
1376    write_html_file('<a href=#getreturntothetop>Return to the top</a>');
1377    write_html_file('<br><br>');
1378 
1379    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1380       trace
1381          (p_msg      => 'END of procedure dump_diagnostic_Ledgers'
1382          ,p_level    => C_LEVEL_PROCEDURE
1383          ,p_module   => l_log_module);
1384    END IF;
1385 
1386 EXCEPTION
1387 WHEN xla_exceptions_pkg.application_exception THEN
1388    RAISE;
1389 WHEN OTHERS THEN
1390    xla_exceptions_pkg.raise_message
1391       (p_location => 'xla_accounting_dump_pkg.dump_diagnostic_Ledgers');
1392 END dump_diagnostic_Ledgers;
1393 
1394 /*======================================================================+
1395 |                                                                       |
1396 | Private Procedure                                                     |
1397 |                                                                       |
1398 | dump_diagnostic_sources                                               |
1399 |                                                                       |
1400 |                                                                       |
1401 +======================================================================*/
1402 PROCEDURE dump_diagnostic_sources
1403 IS
1404 l_log_module                VARCHAR2(240);
1405 l_event_id                  NUMBER;
1406 l_transaction_id            NUMBER;
1407 
1408 l_transction_id_col_name    t_array_char30;
1409 
1410 
1411 
1412 BEGIN
1413 IF g_log_enabled THEN
1414       l_log_module := C_DEFAULT_MODULE||'.dump_diagnostic_sources';
1415    END IF;
1416    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1417       trace
1418          (p_msg      => 'BEGIN of procedure dump_diagnostic_sources'
1419          ,p_level    => C_LEVEL_PROCEDURE
1420          ,p_module   => l_log_module);
1421    END IF;
1422 
1423    l_event_id:= -1;
1424 
1425    FOR Idx IN g_array_events.event_id.FIRST .. g_array_events.event_id.LAST LOOP
1426 
1427         IF g_array_events.event_id.EXISTS(Idx) AND
1428            g_array_events.event_id(Idx) IS NOT NULL AND
1429            g_array_events.event_id(Idx) <> l_event_id THEN
1430 
1431            l_event_id:= g_array_events.event_id(Idx);
1432           --
1433 
1434           write_html_file('<a NAME=get'||TO_CHAR(g_array_events.event_id(Idx))||'></a><b> Transaction Objects Diagnostics For </b>');
1435           write_html_file('<br><br>');
1436           write_html_file('<table border="0"><tbody>');
1437           write_html_file('<tr style="background-color: #cccc99">');
1438           write_html_file('<th style="text-align: left;"> Transaction number </th>');
1439           write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1440                            ||g_array_events.transaction_number(Idx)||'</td>');
1441           write_html_file('</tr>');
1442 
1443           write_html_file('<tr style="background-color: #cccc99">');
1444           write_html_file('<th style="text-align: left;"> Event Id </th>');
1445           write_html_file('<td style="background-color: #f7f7e7" valign="top"text-align: right;">'
1449           write_html_file('<tr style="background-color: #cccc99">');
1446                            ||TO_CHAR(g_array_events.event_id(Idx))||'</td>');
1447           write_html_file('</tr>');
1448 
1450           write_html_file('<th style="text-align: left;"> Event Number </th>');
1451           write_html_file('<td style="background-color: #f7f7e7" valign="top"text-align: right;">'
1452                             ||TO_CHAR(g_array_events.event_number(Idx))||'</td>');
1453           write_html_file('</tr>');
1454 
1455 
1456           write_html_file('<tr style="background-color: #cccc99">');
1457           write_html_file('<th style="text-align: left;"> Event Date </th>');
1458           write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1459                             ||TO_CHAR(g_array_events.event_date(Idx))||'</td>');
1460           write_html_file('</tr>');
1461 
1462           write_html_file('<tr style="background-color: #cccc99">');
1463           write_html_file('<th style="text-align: left;"> Event Class Name </th>');
1464           write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1465                          ||g_array_events.event_class_name(Idx)||'</td>');
1466           write_html_file('</tr>');
1467 
1468           write_html_file('<tr style="background-color: #cccc99">');
1469           write_html_file('<th style="text-align: left;"> Event Class Code </th>');
1470           write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1471                          ||g_array_events.event_class_code(Idx)||'</td>');
1472           write_html_file('</tr>');
1473 
1474           write_html_file('<tr style="background-color: #cccc99">');
1475           write_html_file('<th style="text-align: left;"> Event Type Name </th>');
1476           write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1477                          ||g_array_events.event_type_name(Idx)||'</td>');
1478           write_html_file('</tr>');
1479 
1480           write_html_file('<tr style="background-color: #cccc99">');
1481           write_html_file('<th style="text-align: left;"> Event Type Code </th>');
1482           write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1483                          ||g_array_events.event_type_code(Idx)||'</td>');
1484           write_html_file('</tr>');
1485 
1486           l_transaction_id:= 1;
1487 
1488           BEGIN
1489 
1490               SELECT transaction_id_col_name_1
1491                    , transaction_id_col_name_2
1492                    , transaction_id_col_name_3
1493                    , transaction_id_col_name_4
1494                 INTO l_transction_id_col_name(1)
1495                    , l_transction_id_col_name(2)
1496                    , l_transction_id_col_name(3)
1497                    , l_transction_id_col_name(4)
1498                 FROM xla_entity_id_mappings
1499                WHERE application_id = g_application_id
1500                  AND entity_code    = g_array_events.entity_code(Idx)
1501                  GROUP BY transaction_id_col_name_1
1502                         , transaction_id_col_name_2
1503                         , transaction_id_col_name_3
1504                         , transaction_id_col_name_4
1505               ;
1506 
1507            EXCEPTION
1508             WHEN OTHERS THEN
1509                     l_transction_id_col_name(1):='Transaction Identifier 1';
1510                     l_transction_id_col_name(2):='Transaction Identifier 2';
1511                     l_transction_id_col_name(3):='Transaction Identifier 3';
1512                     l_transction_id_col_name(4):='Transaction Identifier 4';
1513            END;
1514 
1515           IF g_array_events.reference_num_1(Idx) IS NOT NULL THEN
1516 
1517               write_html_file('<tr style="background-color: #cccc99">');
1518               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1519               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1520                          ||g_array_events.reference_num_1(Idx)||'</td>');
1521               write_html_file('</tr>');
1522 
1523               l_transaction_id := l_transaction_id + 1 ;
1524 
1525           END IF;
1526 
1527          IF g_array_events.reference_num_2(Idx) IS NOT NULL THEN
1528 
1529               write_html_file('<tr style="background-color: #cccc99">');
1530               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1531               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1532                          ||g_array_events.reference_num_2(Idx)||'</td>');
1533               write_html_file('</tr>');
1534 
1535               l_transaction_id := l_transaction_id +1 ;
1536 
1537           END IF;
1538 
1539          IF g_array_events.reference_num_3(Idx) IS NOT NULL THEN
1540 
1541               write_html_file('<tr style="background-color: #cccc99">');
1542               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1543               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1544                          ||g_array_events.reference_num_3(Idx)||'</td>');
1545               write_html_file('</tr>');
1546 
1547               l_transaction_id := l_transaction_id +1 ;
1548 
1549           END IF;
1550 
1551          IF g_array_events.reference_num_4(Idx) IS NOT NULL THEN
1552 
1553               write_html_file('<tr style="background-color: #cccc99">');
1554               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1555               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1556                          ||g_array_events.reference_num_4(Idx)||'</td>');
1560 
1557               write_html_file('</tr>');
1558 
1559               l_transaction_id := l_transaction_id + 1 ;
1561           END IF;
1562 
1563          IF g_array_events.reference_char_1(Idx) IS NOT NULL THEN
1564 
1565               write_html_file('<tr style="background-color: #cccc99">');
1566               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1567               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1568                          ||g_array_events.reference_char_1(Idx)||'</td>');
1569               write_html_file('</tr>');
1570 
1571               l_transaction_id := l_transaction_id + 1 ;
1572 
1573           END IF;
1574 
1575          IF g_array_events.reference_char_2(Idx) IS NOT NULL THEN
1576 
1577               write_html_file('<tr style="background-color: #cccc99">');
1578               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1579               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1580                          ||g_array_events.reference_char_2(Idx)||'</td>');
1581               write_html_file('</tr>');
1582 
1583               l_transaction_id := l_transaction_id +1 ;
1584 
1585           END IF;
1586 
1587          IF g_array_events.reference_char_3(Idx) IS NOT NULL THEN
1588 
1589               write_html_file('<tr style="background-color: #cccc99">');
1590               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1591               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1592                          ||g_array_events.reference_char_3(Idx)||'</td>');
1593               write_html_file('</tr>');
1594 
1595               l_transaction_id := l_transaction_id +1 ;
1596 
1597           END IF;
1598 
1599          IF g_array_events.reference_char_4(Idx) IS NOT NULL THEN
1600 
1601               write_html_file('<tr style="background-color: #cccc99">');
1602               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1603               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1604                          ||g_array_events.reference_char_4(Idx)||'</td>');
1605               write_html_file('</tr>');
1606 
1607               l_transaction_id := l_transaction_id +1 ;
1608 
1609           END IF;
1610 
1611         IF g_array_events.reference_date_1(Idx) IS NOT NULL THEN
1612 
1613               write_html_file('<tr style="background-color: #cccc99">');
1614               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1615               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1616                          ||g_array_events.reference_date_1(Idx)||'</td>');
1617               write_html_file('</tr>');
1618 
1619               l_transaction_id := l_transaction_id +1 ;
1620 
1621           END IF;
1622 
1623          IF g_array_events.reference_date_2(Idx) IS NOT NULL THEN
1624 
1625               write_html_file('<tr style="background-color: #cccc99">');
1626               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1627               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1628                          ||g_array_events.reference_date_2(Idx)||'</td>');
1629               write_html_file('</tr>');
1630 
1631               l_transaction_id := l_transaction_id +1 ;
1632 
1633           END IF;
1634 
1635          IF g_array_events.reference_date_3(Idx) IS NOT NULL THEN
1636 
1637               write_html_file('<tr style="background-color: #cccc99">');
1638               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1639               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1640                          ||g_array_events.reference_date_3(Idx)||'</td>');
1641               write_html_file('</tr>');
1642 
1643               l_transaction_id := l_transaction_id +1 ;
1644 
1645           END IF;
1646 
1647          IF g_array_events.reference_date_4(Idx) IS NOT NULL THEN
1648 
1649               write_html_file('<tr style="background-color: #cccc99">');
1650               write_html_file('<th style="text-align: left;"> '||l_transction_id_col_name(l_transaction_id)||' </th>');
1651               write_html_file('<td style="background-color: #f7f7e7" valign="top">'
1652                          ||g_array_events.reference_date_4(Idx)||'</td>');
1653               write_html_file('</tr>');
1654 
1655               l_transaction_id := l_transaction_id +1 ;
1656 
1657           END IF;
1658 
1659           write_html_file('</tbody>');
1660           write_html_file('</table>');
1661 
1662            --
1663            -- dump list of accounting ledgers
1664            --
1665            write_html_file('<ul>');
1666 
1667            FOR Jdx IN g_array_events.ledger_id.FIRST ..g_array_events.ledger_id.LAST LOOP
1668 
1669                IF g_array_events.event_id.EXISTS(Jdx) AND
1670                   g_array_events.event_id(Jdx) IS NOT NULL AND
1671                   g_array_events.event_id(Idx) = g_array_events.event_id(Jdx) THEN
1672 
1673                   write_html_file('<li><a href=#get'||TO_CHAR(g_array_events.event_id(Idx))
1674                                ||TO_CHAR(g_array_events.ledger_id(Jdx))||'>Extract Source values for '
1675                                ||g_array_events.ledger_name(Jdx)||' ledger </a></li>');
1676 
1677 
1678                END IF;
1679 
1683 
1680            END LOOP;
1681 
1682            IF g_acctg_attribute = 'Y' THEN
1684              FOR Jdx IN g_array_events.ledger_id.FIRST ..g_array_events.ledger_id.LAST LOOP
1685 
1686                 IF g_array_events.event_id.EXISTS(Jdx) AND
1687                    g_array_events.event_id(Jdx) IS NOT NULL AND
1688                    g_array_events.event_id(Idx) = g_array_events.event_id(Jdx) THEN
1689 
1690                     write_html_file('<li><a href=#get'||TO_CHAR(g_array_events.event_id(Idx))
1691                                ||TO_CHAR(g_array_events.ledger_id(Jdx))||'ATTRIBUTE'||'> Accounting Attribute values for '
1692                                ||g_array_events.ledger_name(Jdx)||' ledger </a></li>');
1693 
1694                 END IF;
1695 
1696              END LOOP;
1697 
1698            END IF;
1699 
1700            write_html_file('<br><br>');
1701            write_html_file('<a href=#getreturntothetop>Return to the top</a>');
1702            write_html_file('</ul>');
1703 
1704 
1705         END IF;
1706 
1707 
1708         write_html_file('<b> <a NAME=get'||TO_CHAR(g_array_events.event_id(Idx))
1709                       || TO_CHAR(g_array_events.ledger_id(Idx))||'> Extract Source Values for '
1710                       ||g_array_events.ledger_name(Idx)||' ledger ( </a></b>');
1711         write_html_file('<b> <a href="#get'||TO_CHAR(g_array_events.ledger_id(Idx))||'">'||TO_CHAR(g_array_events.ledger_id(Idx))||'</a></b>');
1712         write_html_file('<b> ) </b>');
1713         write_html_file('<br><br>');
1714 
1715         --
1716         -- dump extract object for each accounting ledger
1717         --
1718         dump_transaction_objects(  p_event_id         => g_array_events.event_id(Idx)
1719                              , p_ledger_id        => g_array_events.ledger_id(Idx)
1720                              , p_ledger_name      => g_array_events.ledger_name(Idx)
1721                             );
1722 
1723         IF g_acctg_attribute = 'Y' THEN
1724 
1725                  dump_acctg_attributes(  p_event_id       => g_array_events.event_id(Idx)
1726                                        , p_ledger_id      => g_array_events.ledger_id(Idx)
1727                                        , p_ledger_name    => g_array_events.ledger_name(Idx)
1728                                       );
1729         END IF;
1730 
1731    END LOOP;
1732 
1733 
1734    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1735       trace
1736          (p_msg      => 'END of procedure dump_diagnostic_sources'
1737          ,p_level    => C_LEVEL_PROCEDURE
1738          ,p_module   => l_log_module);
1739    END IF;
1740 
1741 EXCEPTION
1742 WHEN xla_exceptions_pkg.application_exception THEN
1743    RAISE;
1744 WHEN OTHERS THEN
1745    xla_exceptions_pkg.raise_message
1746       (p_location => 'xla_accounting_dump_pkg.dump_diagnostic_sources');
1747 END dump_diagnostic_sources;
1748 
1749 
1750 /*======================================================================+
1751 |                                                                       |
1752 | Private Procedure                                                     |
1753 |                                                                       |
1754 |    dump_acctg_attributes                                              |
1755 |                                                                       |
1756 |                                                                       |
1757 +======================================================================*/
1758 PROCEDURE dump_acctg_attributes(  p_event_id         IN NUMBER
1759                                 , p_ledger_id        IN NUMBER
1760                                 , p_ledger_name      IN VARCHAR2
1761                                )
1762 IS
1763 l_log_module                VARCHAR2(240);
1764 BEGIN
1765 IF g_log_enabled THEN
1766       l_log_module := C_DEFAULT_MODULE||'.dump_acctg_attributes';
1767    END IF;
1768    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1769       trace
1770          (p_msg      => 'BEGIN of procedure dump_acctg_attributes'
1771          ,p_level    => C_LEVEL_PROCEDURE
1772          ,p_module   => l_log_module);
1773    END IF;
1774 
1775 -- Accounting Attribute Values
1776 
1777         write_html_file('<b> <a NAME=get'||TO_CHAR(p_event_id)
1778                       || TO_CHAR(p_ledger_id)||'ATTRIBUTE'||'> Accounting Attribute Values for '
1779                       ||p_ledger_name||' ledger  </a></b>');
1780 
1781         write_html_file('<br><br>');
1782         write_html_file('<ul>');
1783 
1784 -- Header  Accounting Attribute values
1785         write_html_file('<li><a href=#get'||TO_CHAR(p_event_id)
1786                       ||TO_CHAR(p_ledger_id)||'ATTRIBUTE_H'
1787                       ||'> Journal Entry Header Accounting Attribute Values </a></li>');
1788 
1789 -- Line  Accounting Attribute values
1790         write_html_file('<li><a href=#get'||TO_CHAR(p_event_id)
1791                       ||TO_CHAR(p_ledger_id)||'ATTRIBUTE_L'
1792                       ||'> Journal Entry Line Accounting Attribute Values </a></li>');
1793 
1794         write_html_file('</ul>');
1795 
1796 
1797         dump_hdr_attributes(      p_event_id    =>  p_event_id
1798                                 , p_ledger_id   =>  p_ledger_id
1799                                 , p_ledger_name =>  p_ledger_name
1800                                );
1801 
1802 
1803         dump_line_attributes(     p_event_id    =>  p_event_id
1804                                 , p_ledger_id   =>  p_ledger_id
1805                                 , p_ledger_name =>  p_ledger_name
1806                                );
1807 
1808 
1812          (p_msg      => 'END of procedure dump_acctg_attributes'
1809 
1810    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1811       trace
1813          ,p_level    => C_LEVEL_PROCEDURE
1814          ,p_module   => l_log_module);
1815    END IF;
1816 
1817 EXCEPTION
1818 WHEN xla_exceptions_pkg.application_exception THEN
1819    RAISE;
1820 WHEN OTHERS THEN
1821    xla_exceptions_pkg.raise_message
1822       (p_location => 'xla_accounting_dump_pkg.dump_acctg_attributes');
1823 END dump_acctg_attributes;
1824 
1825 
1826 /*======================================================================+
1827 |                                                                       |
1828 | Private Procedure                                                     |
1829 |                                                                       |
1830 |    dump_hdr_attributes                                                |
1831 |                                                                       |
1832 |                                                                       |
1833 +======================================================================*/
1834 PROCEDURE dump_hdr_attributes(    p_event_id         IN NUMBER
1835                                 , p_ledger_id        IN NUMBER
1836                                 , p_ledger_name      IN VARCHAR2
1837                                )
1838 IS
1839 l_log_module                VARCHAR2(240);
1840 l_count                     NUMBER;
1841 BEGIN
1842 IF g_log_enabled THEN
1843       l_log_module := C_DEFAULT_MODULE||'.dump_hdr_attributes';
1844    END IF;
1845    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1846       trace
1847          (p_msg      => 'BEGIN of procedure dump_hdr_attributes'
1848          ,p_level    => C_LEVEL_PROCEDURE
1849          ,p_module   => l_log_module);
1850    END IF;
1851 
1852 
1853      -- Header  Accounting Attribute values
1854 
1855       write_html_file('<b><a NAME=get'||TO_CHAR(p_event_id )
1856                       || TO_CHAR(p_ledger_id)||'ATTRIBUTE_H'||'> Journal Entry Header Accounting Attribute Values for '
1857                       ||p_ledger_name||' ledger </a></b>');
1858 
1859       l_count := 0;
1860       FOR header_attr_rec IN (
1861        SELECT DISTINCT
1862                 nvl(xaat.name,xals.accounting_attribute_code)        attribute_name
1863               , nvl(xstl.name,xals.source_code)                      source_name
1864               , nvl(xds.source_value,' ')                            source_value
1865               , nvl(xds.source_meaning,' ')                          source_meaning
1866           FROM   xla_evt_class_acct_attrs    xals
1867                , xla_acct_attributes_b       xaa
1868                , xla_acct_attributes_tl      xaat
1869                , xla_sources_tl              xstl
1870                , xla_diag_sources            xds
1871                , xla_diag_events             xde
1872                , xla_diag_ledgers            xdl
1873          WHERE  xde.event_id                      = xds.event_id
1874            AND  xds.ledger_id                     = xdl.ledger_id
1875            AND  xde.ledger_id                     = xdl.primary_ledger_id
1876            AND  xde.request_id                    = xdl.accounting_request_id
1877            AND  xds.source_application_id         = xdl.application_id
1878            AND  xaa.assignment_level_code         = 'EVT_CLASS_ONLY'
1879            AND  xaa.accounting_attribute_code     = xals.accounting_attribute_code
1880            AND  xaa.journal_entry_level_code      = 'H'
1881            AND  xaat.accounting_attribute_code (+)= xaa.accounting_attribute_code
1882            AND  xaat.language                  (+)= USERENV('LANG')
1883            AND  xstl.application_id            (+)= xals.source_application_id
1884            AND  xstl.source_type_code          (+)= xals.source_type_code
1885            AND  xstl.source_code               (+)= xals.source_code
1886            AND  xstl.language                  (+)= USERENV('LANG')
1887            AND  xals.default_flag                 = 'Y'
1888            AND  xals.application_id               = xdl.application_id
1889            AND  xals.event_class_code             = xde.event_class_code
1890            AND  xds.source_type_code              = xals.source_type_code
1891            AND  xds.source_code                   = xals.source_code
1892            AND  xdl.application_id                = xals.application_id
1893            AND xds.event_id                       = p_event_id
1894            AND xds.ledger_id                      = p_ledger_id
1895            AND xdl.application_id                 = g_application_id
1896         UNION
1897         SELECT DISTINCT
1898                 nvl(xaat.name,aha.accounting_attribute_code)         attribute_name
1899               , nvl(xst.name, aha.source_code)                       source_name
1900               , nvl(xds.source_value,' ')                            source_value
1901               , nvl(xds.source_meaning,' ')                          source_meaning
1902           FROM xla_aad_hdr_acct_attrs      aha
1903              , xla_acct_attributes_b       xaa
1904              , xla_acct_attributes_tl      xaat
1905              , xla_sources_tl              xst
1906              , xla_diag_sources         xds
1907              , xla_diag_events          xde
1908              , xla_diag_ledgers         xdl
1909         WHERE  xde.event_id                  = xds.event_id
1910            AND xds.ledger_id                 = xdl.ledger_id
1911            AND xde.ledger_id                 = xdl.primary_ledger_id
1912            AND xde.request_id                = xdl.accounting_request_id
1913            AND xds.source_application_id     = xdl.application_id
1914            AND xde.event_date   BETWEEN nvl(xdl.start_date_active, xde.event_date) AND
1918            AND aha.product_rule_type_code     = xdl.product_rule_type_code
1915                                         nvl (xdl.end_date_active, xde.event_date)
1916            AND aha.application_id             = xdl.application_id
1917            AND aha.amb_context_code           = xdl.amb_context_code
1919            AND aha.product_rule_code          = xdl.product_rule_code
1920            AND aha.event_class_code           = xde.event_class_code
1921            AND aha.event_type_code            = xde.event_type_code
1922            AND aha.application_id             = xds.source_application_id
1923            AND aha.source_type_code           = xds.source_type_code
1924            AND aha.source_code                = xds.source_code
1925            AND xaa.accounting_attribute_code  = aha.accounting_attribute_code
1926            AND xaa.assignment_level_code       IN ('AAD_ONLY','EVT_CLASS_AAD')
1927            AND xaat.accounting_attribute_code  (+)= xaa.accounting_attribute_code
1928            AND xaat.language                   (+)= USERENV('LANG')
1929            AND xst.application_id              (+)= aha.source_application_id
1930            AND xst.source_type_code            (+)= aha.source_type_code
1931            AND xst.source_code                 (+)= aha.source_code
1932            AND xst.language                    (+)= USERENV('LANG')
1933            AND xds.event_id                    = p_event_id
1934            AND xds.ledger_id                   = p_ledger_id
1935            AND xdl.application_id              = g_application_id
1936        )
1937   LOOP
1938 
1939    IF (l_count = 0) THEN
1940 
1941       write_html_file('<br><br>');
1942       write_html_file('<table border="0"><tbody>');
1943       write_html_file('<tr style="background-color: #cccc99">');
1944       write_html_file('<th> Accounting Attribute Name </th>');
1945       write_html_file('<th> Source Name</th>');
1946       write_html_file('<th> Source Value </th>');
1947       write_html_file('<th> Source Meaning</th>');
1948 
1949    END IF;
1950 
1951       write_html_file('</tr>');
1952       write_html_file('<tr style="background-color: #f7f7e7" valign="top">');
1953       write_html_file('<td>'||header_attr_rec.attribute_name||'</td>');
1954       write_html_file('<td>'||header_attr_rec.source_name   ||'</td>');
1955       write_html_file('<td>'||header_attr_rec.source_value  ||'</td>');
1956       write_html_file('<td>'||header_attr_rec.source_meaning||'</td>');
1957       write_html_file('</tr>');
1958 
1959 
1960       l_count:= l_count + 1;
1961 
1962   END LOOP;
1963 
1964   IF l_count > 0 THEN
1965 
1966      write_html_file('</tbody>');
1967      write_html_file('</table>');
1968 
1969   ELSE
1970 
1971          write_html_file('<br>');
1972          write_warning_msg(   p_appli_s_name => 'XLA'
1973                             , p_msg_name     => 'XLA_DMP_NO_ACCTG_ATTR'
1974                             , p_token_1      => 'EXTRACT_OBJECT_LEVEL'
1975                             , p_value_1      => xla_lookups_pkg.get_meaning(
1976                                                       p_lookup_type    => 'XLA_EXTRACT_OBJECT_TYPE'
1977                                                     , p_lookup_code    =>  'HEADER'
1978                                                   )
1979                             , p_token_2      => 'EVENT_ID'
1980                             , p_value_2      => p_event_id
1981                             , p_token_3      => 'LEDGER_ID'
1982                             , p_value_3      => p_ledger_id
1983         );
1984   END IF;
1985 
1986   write_html_file('<a href=#getreturntothetop>Return to the top</a>');
1987   write_html_file('<br><br>');
1988 
1989   IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1990       trace
1991          (p_msg      => 'END of procedure dump_hdr_attributes'
1992          ,p_level    => C_LEVEL_PROCEDURE
1993          ,p_module   => l_log_module);
1994   END IF;
1995 
1996 EXCEPTION
1997 WHEN xla_exceptions_pkg.application_exception THEN
1998    RAISE;
1999 WHEN OTHERS THEN
2000    xla_exceptions_pkg.raise_message
2001       (p_location => 'xla_accounting_dump_pkg.dump_hdr_attributes');
2002 END dump_hdr_attributes;
2003 
2004 /*======================================================================+
2005 |                                                                       |
2006 | Private Procedure                                                     |
2007 |                                                                       |
2008 |    dump_line_attributes                                               |
2009 |                                                                       |
2010 |                                                                       |
2011 +======================================================================*/
2012 PROCEDURE dump_line_attributes(   p_event_id         IN NUMBER
2013                                 , p_ledger_id        IN NUMBER
2014                                 , p_ledger_name      IN VARCHAR2
2015                                )
2016 IS
2017 l_log_module                VARCHAR2(240);
2018 l_count                     NUMBER;
2019 BEGIN
2020 IF g_log_enabled THEN
2021       l_log_module := C_DEFAULT_MODULE||'.dump_line_attributes';
2022    END IF;
2023    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2024       trace
2025          (p_msg      => 'BEGIN of procedure dump_line_attributes'
2026          ,p_level    => C_LEVEL_PROCEDURE
2027          ,p_module   => l_log_module);
2028    END IF;
2029 
2030     -- Line Accounting Attribute values
2031 
2032     l_count:=0;
2033 
2034     write_html_file('<b> <a NAME=get'||TO_CHAR(p_event_id)
2038 
2035                       || TO_CHAR(p_ledger_id)||'ATTRIBUTE_L'||'> Journal Entry Line Accounting Attribute Values for '
2036                       ||p_ledger_name||' ledger </a></b>');
2037 
2039     FOR line_attr_rec IN (
2040         SELECT  DISTINCT
2041                  nvl(xaltt.name , xldj.accounting_line_code)       jlt_name
2042                , nvl(lkp.meaning, xldj.accounting_line_type_code)  jlt_owner
2043                , nvl(xds.line_number,0)                            line_number
2044                , nvl(xaat.name,xals.accounting_attribute_code)     attribute_name
2045                , nvl(xst.name, xds.source_code)                    source_name
2046                , xds.source_value                                  source_value
2047                , xds.source_meaning                                source_meaning
2048            FROM  xla_diag_events           xde
2049                , xla_diag_ledgers          xdl
2050                , xla_diag_sources          xds
2051                , xla_sources_tl            xst
2052                , xla_aad_line_defn_assgns  xald
2053                , xla_line_defn_jlt_assgns  xldj
2054                , xla_prod_acct_headers     xpah
2055                , xla_acct_line_types_tl    xaltt
2056                , fnd_lookup_values         lkp
2057                , xla_jlt_acct_attrs        xals
2058                , xla_acct_attributes_tl    xaat
2059           WHERE  xst.application_id            (+)= xds.source_application_id
2060             AND  xst.source_type_code          (+)= xds.source_type_code
2061             AND  xst.source_code               (+)= xds.source_code
2062             AND  xst.language                  (+)= USERENV('LANG')
2063             --
2064             AND  xaat.accounting_attribute_code(+)= xals.accounting_attribute_code
2065             AND  xaat.language                 (+)=USERENV('LANG')
2066             --
2067             AND  xde.event_id                     = xds.event_id
2068             AND  xds.ledger_id                    = xdl.ledger_id
2069             AND  xde.ledger_id                    = xdl.primary_ledger_id
2070             AND  xds.source_application_id        = xdl.application_id
2071             AND  xde.event_date     BETWEEN nvl(xdl.start_date_active, xde.event_date) AND
2072                                     nvl (xdl.end_date_active, xde.event_date)
2073             AND  xpah.application_id              = xdl.application_id
2074             AND  xpah.product_rule_type_code      = xdl.product_rule_type_code
2075             AND  xpah.product_rule_code           = xdl.product_rule_code
2076             AND  xpah.amb_context_code            = xdl.amb_context_code
2077             --
2078             AND  xpah.entity_code                 = xde.entity_code
2079             AND  xpah.event_class_code            = xde.event_class_code
2080             AND  xpah.event_type_code             = xde.event_type_code
2081             --
2082             AND  xds.source_code                  = xals.source_code
2083             AND  xds.source_type_code             = xals.source_type_code
2084             AND  xds.source_application_id        = xals.source_application_id
2085             --
2086             AND  xals.application_id              = xldj.application_id
2087             AND  xals.accounting_line_code        = xldj.accounting_line_code
2088             AND  xals.accounting_line_type_code   = xldj.accounting_line_type_code
2089             AND  xals.amb_context_code            = xldj.amb_context_code
2090             AND  xals.event_class_code            = xldj.event_class_code
2091             AND  xldj.active_flag                 = 'Y'
2092             --
2093             AND  xldj.application_id              = xald.application_id
2094             AND  xldj.amb_context_code            = xald.amb_context_code
2095             AND  xldj.event_class_code            = xald.event_class_code
2096             AND  xldj.event_type_code             = xald.event_type_code
2097             AND  xldj.line_definition_owner_code  = xald.line_definition_owner_code
2098             AND  xldj.line_definition_code        = xald.line_definition_code
2099             --
2100             AND  xald.application_id              = xpah.application_id
2101             AND  xald.amb_context_code            = xpah.amb_context_code
2102             AND  xald.product_rule_type_code      = xpah.product_rule_type_code
2103             AND  xald.product_rule_code           = xpah.product_rule_code
2104             AND  xald.event_class_code            = xpah.event_class_code
2105             AND  xald.event_type_code             = xpah.event_type_code
2106             AND  xpah.accounting_required_flag    = 'Y'
2107             --
2108             AND  xldj.application_id              = xaltt.application_id           (+)
2109             AND  xldj.amb_context_code            = xaltt.amb_context_code         (+)
2110             AND  xldj.accounting_line_code        = xaltt.accounting_line_code     (+)
2111             AND  xldj.accounting_line_type_code   = xaltt.accounting_line_type_code(+)
2112             AND  xldj.event_class_code            = xaltt.event_class_code         (+)
2113             AND  xaltt.language               (+) = USERENV('LANG')
2114             --
2115             AND  lkp.lookup_type              (+) = 'XLA_OWNER_TYPE'
2116             AND  lkp.lookup_code              (+) = xldj.accounting_line_type_code
2117             AND  lkp.view_application_id      (+) = 602
2118             AND  lkp.language                 (+) = USERENV('LANG')
2119             AND  lkp.enabled_flag             (+) = 'Y'
2120             AND  xde.event_date BETWEEN  nvl(lkp.start_date_active,xde.event_date)
2121             AND                          nvl (lkp.end_date_active, xde.event_date)
2122             --
2123             AND  xde.request_id                   = xdl.accounting_request_id
2124             AND  xds.event_id                     = p_event_id
2128           UNION
2125             AND  xds.ledger_id                    = p_ledger_id
2126             AND  xdl.application_id               = g_application_id
2127 
2129         SELECT DISTINCT
2130                nvl(xaltt.name , xldj.accounting_line_code)       jlt_name
2131              , nvl(lkp.meaning, xldj.accounting_line_type_code)  jlt_owner
2132              , nvl(xds.line_number,0)                            line_number
2133              , nvl(xaat.name,xals.accounting_attribute_code)     attribute_name
2134              , nvl(xstl.name,xals.source_code)                   source_name
2135              , xds.source_value                                  source_value
2136              , xds.source_meaning                                source_meaning
2137          FROM   xla_evt_class_acct_attrs    xals
2138               , xla_acct_attributes_b       xaa
2139               , xla_acct_attributes_tl      xaat
2140               , xla_sources_tl              xstl
2141               , xla_diag_sources            xds
2142               , xla_diag_events             xde
2143               , xla_diag_ledgers            xdl
2144               , xla_aad_line_defn_assgns    xald
2145               , xla_line_defn_jlt_assgns    xldj
2146               , xla_prod_acct_headers       xpah
2147               , xla_acct_line_types_tl      xaltt
2148               , fnd_lookup_values           lkp
2149         WHERE  xde.event_id                       = xds.event_id
2150           AND  xds.ledger_id                      = xdl.ledger_id
2151           AND  xde.ledger_id                      = xdl.primary_ledger_id
2152           AND  xds.source_application_id          = xdl.application_id
2153           AND  xaa.assignment_level_code          = 'EVT_CLASS_ONLY'
2154           AND  xaa.accounting_attribute_code      = xals.accounting_attribute_code
2155           AND  xaa.journal_entry_level_code       IN ('L', 'C')
2156           --
2157           AND  xaat.accounting_attribute_code (+) = xaa.accounting_attribute_code
2158           AND  xaat.language                  (+) = USERENV('LANG')
2159           --
2160           AND  xstl.application_id            (+) = xals.source_application_id
2161           AND  xstl.source_type_code          (+) = xals.source_type_code
2162           AND  xstl.source_code               (+) = xals.source_code
2163           AND  xstl.language                  (+) = USERENV('LANG')
2164           --
2165           AND  xals.default_flag                  = 'Y'
2166           AND  xals.application_id                = xdl.application_id
2167           AND  xals.event_class_code              = xde.event_class_code
2168           --
2169           AND  xds.source_type_code               = xals.source_type_code
2170           AND  xds.source_code                    = xals.source_code
2171           AND  xdl.application_id                 = xals.application_id
2172           --
2173           AND  xpah.product_rule_type_code        = xdl.product_rule_type_code
2174           AND  xpah.product_rule_code             = xdl.product_rule_code
2175           AND  xpah.amb_context_code              = xdl.amb_context_code
2176           --
2177           AND  xpah.entity_code                   = xde.entity_code
2178           AND  xpah.event_class_code              = xde.event_class_code
2179           AND  xpah.event_type_code               = xde.event_type_code
2180           --
2181           AND  xald.application_id                = xpah.application_id
2182           AND  xald.amb_context_code              = xpah.amb_context_code
2183           AND  xald.product_rule_type_code        = xpah.product_rule_type_code
2184           AND  xald.product_rule_code             = xpah.product_rule_code
2185           AND  xald.event_class_code              = xpah.event_class_code
2186           AND  xald.event_type_code               = xpah.event_type_code
2187           --
2188           AND  xldj.application_id                = xald.application_id
2189           AND  xldj.amb_context_code              = xald.amb_context_code
2190           AND  xldj.line_definition_owner_code    = xald.line_definition_owner_code
2191           AND  xldj.line_definition_code          = xald.line_definition_code
2192           AND  xldj.event_class_code              = xald.event_class_code
2193           AND  xldj.event_type_code               = xald.event_type_code
2194           AND  xldj.active_flag                   = 'Y'
2195           --
2196           AND  xldj.application_id                = xaltt.application_id           (+)
2197           AND  xldj.amb_context_code              = xaltt.amb_context_code         (+)
2198           AND  xldj.accounting_line_code          = xaltt.accounting_line_code     (+)
2199           AND  xldj.accounting_line_type_code     = xaltt.accounting_line_type_code(+)
2200           AND  xldj.event_class_code              = xaltt.event_class_code         (+)
2201           AND  xaltt.language               (+)   = USERENV('LANG')
2202           --
2203           AND  xpah.accounting_required_flag      = 'Y'
2204           AND  lkp.lookup_type              (+)   = 'XLA_OWNER_TYPE'
2205           AND  lkp.lookup_code              (+)   = xldj.accounting_line_type_code
2206           AND  lkp.view_application_id      (+)   = 602
2207           AND  lkp.language                 (+)   = USERENV('LANG')
2208           AND  lkp.enabled_flag             (+)   = 'Y'
2209           AND  xde.event_date BETWEEN  nvl(lkp.start_date_active,xde.event_date)
2210           AND                          nvl (lkp.end_date_active, xde.event_date)
2211           --
2212           AND  xde.request_id                     = xdl.accounting_request_id
2213           AND  xds.event_id                       = p_event_id
2214           AND  xds.ledger_id                      = p_ledger_id
2215           AND  xdl.application_id                 = g_application_id
2216      ORDER BY line_number, jlt_name, jlt_owner,  attribute_name
2217             ) LOOP
2218      --dump Line acctg attributes
2219 
2220 
2221       IF l_count = 0 THEN
2225        write_html_file('<th> Distribution Line Number </th>');
2222        write_html_file('<br><br>');
2223        write_html_file('<table border="0"><tbody>');
2224        write_html_file('<tr style="background-color: #cccc99">');
2226        write_html_file('<th> Journal Entry Line Name </th>');
2227        write_html_file('<th> Journal Entry Line Owner </th>');
2228        write_html_file('<th> Accounting Attribute Name </th>');
2229        write_html_file('<th> Source Name</th>');
2230        write_html_file('<th> Source Value </th>');
2231        write_html_file('<th> Source Meaning</th>');
2232       END IF;
2233 
2234       write_html_file('</tr>');
2235       write_html_file('<tr style="background-color: #f7f7e7" valign="top">');
2236       IF line_attr_rec.line_number <> 0 THEN
2237        write_html_file('<td style="text-align: right;">'||TO_CHAR(line_attr_rec.line_number)||'</td>');
2238       ELSE
2239        write_html_file('<td style="text-align: right;">'||' '||'</td>');
2240       END IF;
2241       write_html_file('<td>'||nvl(line_attr_rec.jlt_name ,'All')||'</td>');
2242       write_html_file('<td>'||nvl(line_attr_rec.jlt_owner,'All')||'</td>');
2243       write_html_file('<td>'||line_attr_rec.attribute_name||'</td>');
2244       write_html_file('<td>'||line_attr_rec.source_name   ||'</td>');
2245       write_html_file('<td>'||line_attr_rec.source_value  ||'</td>');
2246       write_html_file('<td>'||line_attr_rec.source_meaning||'</td>');
2247 
2248      l_count:= l_count +1;
2249 
2250     END LOOP;
2251     IF l_count > 0 THEN
2252 
2253        write_html_file('</tbody>');
2254        write_html_file('</table>');
2255 
2256     ELSE
2257        write_html_file('<br>');
2258          write_warning_msg(   p_appli_s_name => 'XLA'
2259                             , p_msg_name     => 'XLA_DMP_NO_ACCTG_ATTR'
2260                             , p_token_1      => 'EXTRACT_OBJECT_LEVEL'
2261                             , p_value_1      => xla_lookups_pkg.get_meaning(
2262                                                       p_lookup_type    => 'XLA_EXTRACT_OBJECT_TYPE'
2263                                                     , p_lookup_code    =>  'LINE'
2264                                                   )
2265                             , p_token_2      => 'EVENT_ID'
2266                             , p_value_2      => p_event_id
2267                             , p_token_3      => 'LEDGER_ID'
2268                             , p_value_3      => p_ledger_id
2269         );
2270 
2271     END IF;
2272 
2273     write_html_file('<a href=#getreturntothetop>Return to the top</a>');
2274     write_html_file('<br><br>');
2275     IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2276       trace
2277          (p_msg      => 'END of procedure dump_line_attributes'
2278          ,p_level    => C_LEVEL_PROCEDURE
2279          ,p_module   => l_log_module);
2280     END IF;
2281 
2282 EXCEPTION
2283 WHEN xla_exceptions_pkg.application_exception THEN
2284    RAISE;
2285 WHEN OTHERS THEN
2286    xla_exceptions_pkg.raise_message
2287       (p_location => 'xla_accounting_dump_pkg.dump_line_attributes');
2288 END dump_line_attributes;
2289 
2290 /*======================================================================+
2291 |                                                                       |
2292 | Private Procedure                                                     |
2293 |                                                                       |
2294 | dump_transaction_objects                                              |
2295 |                                                                       |
2296 |                                                                       |
2297 +======================================================================*/
2298 PROCEDURE dump_transaction_objects(  p_event_id         IN NUMBER
2299                                    , p_ledger_id        IN NUMBER
2300                                    , p_ledger_name      IN VARCHAR2
2301                                )
2302 IS
2303 
2304 CURSOR object_cur (p_event_id  NUMBER
2305                   ,p_ledger_id NUMBER)
2306 IS
2307 SELECT  object_name
2308       , object_type_code
2309   FROM xla_diag_sources
2310  WHERE event_id  = p_event_id
2311    AND ledger_id = p_ledger_id
2312  GROUP BY object_name  , object_type_code
2313  ORDER BY DECODE(object_type_code, C_HEADER ,1
2314                                     , C_MLS_HEADER,2
2315                                     , C_LINE,3
2316                                     , C_BC_LINE,4
2317                                     , C_MLS_LINE,5
2318                                    )
2319 ;
2320 l_log_module                VARCHAR2(240);
2321 l_array_object_name         t_array_char30;
2322 l_array_object_type         t_array_char30;
2323 BEGIN
2324 IF g_log_enabled THEN
2325       l_log_module := C_DEFAULT_MODULE||'.dump_transaction_objects';
2326    END IF;
2327    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2328       trace
2329          (p_msg      => 'BEGIN of procedure dump_transaction_objects'
2330          ,p_level    => C_LEVEL_PROCEDURE
2331          ,p_module   => l_log_module);
2332    END IF;
2333 
2334 
2335    OPEN object_cur( p_event_id           => p_event_id
2336                   , p_ledger_id          => p_ledger_id
2337                   );
2338    --
2339    --
2340    FETCH object_cur BULK COLLECT INTO l_array_object_name
2341                                     , l_array_object_type
2342                                     ;
2343    --
2344    --
2345    CLOSE object_cur;
2346    --
2347    IF l_array_object_name.COUNT > 0 THEN
2348 
2349      write_html_file('<ul>');
2350 
2351      FOR Idx IN l_array_object_name.FIRST .. l_array_object_name.LAST LOOP
2355           l_array_object_type(Idx) IN (C_HEADER,C_MLS_HEADER) THEN
2352 
2353        IF l_array_object_type.EXISTS(Idx) AND
2354           l_array_object_type(Idx) IS NOT NULL AND
2356 
2357           write_html_file('<li><b> Header source values retrieved from the extract object '
2358                       ||l_array_object_name(Idx)||'</b></li>');
2359 
2360        ELSIF l_array_object_type.EXISTS(Idx) AND
2361              l_array_object_type(Idx) IS NOT NULL AND
2362              l_array_object_type(Idx) IN (C_LINE,C_MLS_LINE,C_BC_LINE) THEN
2363 
2364           write_html_file('<li><b> Line source values retrieved from the extract object '
2365                       ||l_array_object_name(Idx)||'</b></li>');
2366 
2367        END IF;
2368 
2369        write_html_file('<br><br>');
2370        dump_source_names  ( p_event_id          => p_event_id
2371                           , p_ledger_id         => p_ledger_id
2372                           , p_ledger_name       => p_ledger_name
2373                           , p_object_name       => l_array_object_name(Idx)
2374                           , p_object_type_code  => l_array_object_type(Idx)
2375                           );
2376 
2377        write_html_file('<br>');
2378 
2379      END LOOP;
2380 
2381      write_html_file('</ul>');
2382 
2383    ELSE
2384 
2385         write_warning_msg(   p_appli_s_name => 'XLA'
2386                            , p_msg_name     => 'XLA_DMP_NO_EXTRACT_ROWS'
2387                            , p_token_1      => NULL
2388                            , p_value_1      => NULL
2389                            , p_token_2      => NULL
2390                            , p_value_2      => NULL
2391                            , p_token_3      => NULL
2392                            , p_value_3      => NULL
2393                           );
2394 
2395        write_html_file('&'||'nbsp;'||'&'||'nbsp;'||'&'||'nbsp;');
2396        write_html_file('<a href=#getreturntothetop>Return to the top</a>');
2397        write_html_file('<br><br>');
2398 
2399    END IF;
2400 
2401    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2402       trace
2403          (p_msg      => 'END of procedure dump_transaction_objects'
2404          ,p_level    => C_LEVEL_PROCEDURE
2405          ,p_module   => l_log_module);
2406    END IF;
2407 
2408 EXCEPTION
2409 WHEN xla_exceptions_pkg.application_exception THEN
2410    RAISE;
2411 WHEN OTHERS THEN
2412    xla_exceptions_pkg.raise_message
2413       (p_location => 'xla_accounting_dump_pkg.dump_transaction_objects');
2414 END dump_transaction_objects;
2415 
2416 /*======================================================================+
2417 |                                                                       |
2418 | Private Procedure                                                     |
2419 |                                                                       |
2420 | dump_source_names                                                     |
2421 |                                                                       |
2422 |                                                                       |
2423 +======================================================================*/
2424 PROCEDURE dump_source_names  ( p_event_id          IN NUMBER
2425                              , p_ledger_id         IN NUMBER
2426                              , p_ledger_name       IN VARCHAR2
2427                              , p_object_name       IN VARCHAR2
2428                              , p_object_type_code  IN VARCHAR2
2429                                )
2430 IS
2431 
2432 CURSOR source_cur (p_event_id         NUMBER
2433                   ,p_ledger_id        NUMBER
2434                   ,p_object_name      VARCHAR2
2435                   ,p_object_type_code VARCHAR2)
2436 IS
2437 SELECT
2438         xds.source_code
2439       , xds.source_type_code
2440       , xds.source_application_id
2441       , DECODE(xsb.view_application_id,
2442                 NULL, DECODE(xsb.flex_value_set_id,
2443                              NULL,'N',
2444                              'Y')
2445                 , 'Y')
2446       , nvl(xst.name,xds.source_code)
2447   FROM  xla_diag_sources     xds
2448      ,  xla_sources_b        xsb
2449      ,  xla_sources_tl       xst
2450  WHERE xsb.application_id   (+)= xds.source_application_id
2451    AND xsb.source_type_code (+)= xds.source_type_code
2452    AND xsb.source_code      (+)= xds.source_code
2453    AND xds.event_id            = p_event_id
2454    AND xds.ledger_id           = p_ledger_id
2455    AND xds.object_name         = p_object_name
2456    AND xds.object_type_code    = p_object_type_code
2457    AND xst.application_id   (+)= xds.source_application_id
2458    AND xst.source_type_code (+)= xds.source_type_code
2459    AND xst.source_code      (+)= xds.source_code
2460    AND xst.language         (+)= USERENV('LANG')
2461    AND xds.line_number =  (SELECT max(line_number)
2462                              FROM xla_diag_sources    xds2
2463                             WHERE xds2.event_id            = p_event_id
2464                               AND xds2.ledger_id           = p_ledger_id
2465                               AND xds2.object_name         = p_object_name
2466                               AND xds2.object_type_code    = p_object_type_code
2467                           )
2468  ORDER BY xds.source_application_id, xds.source_type_code, xds.source_code
2469 ;
2470 
2471 l_log_module                VARCHAR2(240);
2472 l_array_source_code         t_array_char30;
2473 l_array_source_name         t_array_char80;
2474 l_array_meaning_flag        t_array_char1;
2475 l_array_source_type_code    t_array_char1;
2476 l_array_source_appl_id      t_array_number;
2477 
2481    END IF;
2478 BEGIN
2479 IF g_log_enabled THEN
2480       l_log_module := C_DEFAULT_MODULE||'.dump_source_names ';
2482    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2483       trace
2484          (p_msg      => 'BEGIN of procedure dump_source_names '
2485          ,p_level    => C_LEVEL_PROCEDURE
2486          ,p_module   => l_log_module);
2487    END IF;
2488 
2489 
2490    OPEN source_cur ( p_event_id           => p_event_id
2491                    , p_ledger_id          => p_ledger_id
2492                    , p_object_name        => p_object_name
2493                    , p_object_type_code   => p_object_type_code
2494                    );
2495    --
2496    --
2497    FETCH source_cur BULK COLLECT INTO l_array_source_code
2498                                     , l_array_source_type_code
2499                                     , l_array_source_appl_id
2500                                     , l_array_meaning_flag
2501                                     , l_array_source_name
2502                                     ;
2503    --
2504    --
2505    CLOSE source_cur;
2506    --
2507    IF l_array_source_code.COUNT > 0 THEN
2508 
2509 
2510      write_html_file('<table border="0"><tbody>');
2511      write_html_file('<tr style="background-color: #cccc99">');
2512 
2513      IF p_object_type_code IN (C_LINE,C_BC_LINE,C_MLS_LINE ) THEN
2514         write_html_file('<th> Distribution line number </th>');
2515      END IF;
2516 
2517      FOR Idx IN l_array_source_code.FIRST .. l_array_source_code.LAST LOOP
2518 
2519        IF g_source_name = 'Y' THEN
2520           write_html_file('<th> '||l_array_source_name(Idx)||' </th>');
2521        ELSE
2522           write_html_file('<th> '||l_array_source_code(Idx)||' </th>');
2523        END IF;
2524 
2525        IF ( l_array_meaning_flag(Idx) = 'Y' ) THEN
2526 
2527           IF g_source_name = 'Y' THEN
2528               write_html_file('<th> '||l_array_source_name(Idx)||' meaning </th>');
2529           ELSE
2530               write_html_file('<th> '||l_array_source_code(Idx)||' meaning </th>');
2531           END IF;
2532 
2533        END IF;
2534 
2535      END LOOP;
2536 
2537      write_html_file('</tr>');
2538 
2539      dump_source_values (  p_event_id                 => p_event_id
2540                          , p_ledger_id                => p_ledger_id
2541                          , p_ledger_name              => p_ledger_name
2542                          , p_object_name              => p_object_name
2543                          , p_object_type_code         => p_object_type_code
2544                         );
2545 
2546      write_html_file('</tbody>');
2547      write_html_file('</table>');
2548      write_html_file('<a href=#getreturntothetop>Return to the top</a>');
2549      write_html_file('<br><br>');
2550 
2551    END IF;
2552 
2553    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2554       trace
2555          (p_msg      => 'END of procedure dump_source_names '
2556          ,p_level    => C_LEVEL_PROCEDURE
2557          ,p_module   => l_log_module);
2558    END IF;
2559 
2560 EXCEPTION
2561 WHEN xla_exceptions_pkg.application_exception THEN
2562    RAISE;
2563 WHEN OTHERS THEN
2564    xla_exceptions_pkg.raise_message
2565       (p_location => 'xla_accounting_dump_pkg.dump_source_names ');
2566 END dump_source_names ;
2567 
2568 /*======================================================================+
2569 |                                                                       |
2570 | Private Procedure                                                     |
2571 |                                                                       |
2572 | dump_source_values                                                    |
2573 |                                                                       |
2574 |                                                                       |
2575 +======================================================================*/
2576 PROCEDURE dump_source_values ( p_event_id                 IN NUMBER
2577                              , p_ledger_id                IN NUMBER
2578                              , p_ledger_name              IN VARCHAR2
2579                              , p_object_name              IN VARCHAR2
2580                              , p_object_type_code         IN VARCHAR2
2581                              )
2582 IS
2583 
2584 CURSOR source_cur( p_event_id         NUMBER
2585                   ,p_ledger_id        NUMBER
2586                   ,p_object_name      VARCHAR2
2587                   ,p_object_type_code VARCHAR2)
2588 IS
2589 SELECT  xds.source_code
2590       , xds.source_type_code
2591       , xds.source_application_id
2592       , nvl(TO_CHAR(xds.source_value),' ')
2593       , nvl(TO_CHAR(xds.source_meaning),' ')
2594       , xds.line_number                     AS line_number
2595       , DECODE(xsb.datatype_code
2596                ,'C','N'
2597                ,'D','N'
2598                ,'Y')
2599       , DECODE(xsb.view_application_id,
2600                 NULL, DECODE(xsb.flex_value_set_id, NULL,'N','Y'), 'Y')
2601   FROM  xla_diag_sources     xds
2602       , xla_sources_b        xsb
2603  WHERE xsb.application_id   (+)= xds.source_application_id
2604    AND xsb.source_type_code (+)= xds.source_type_code
2605    AND xsb.source_code      (+)= xds.source_code
2606    AND xds.event_id         = p_event_id
2607    AND xds.ledger_id        = p_ledger_id
2608    AND xds.object_name      = p_object_name
2609    AND xds.object_type_code = p_object_type_code
2610    AND (xds.line_number = 0 OR
2614 ;
2611         xds.line_number  BETWEEN NVL(g_from_line_number,xds.line_number) AND
2612                                  NVL(g_to_line_number,xds.line_number))
2613  ORDER BY line_number, xds.source_application_id, xds.source_type_code, xds.source_code
2615 
2616 l_log_module                VARCHAR2(240);
2617 l_array_source_code         t_array_char30;
2618 l_array_source_type_code    t_array_char1;
2619 l_array_meaning_flag        t_array_char1;
2620 l_array_numeric_flag        t_array_char1;
2621 l_array_source_appl_id      t_array_number;
2622 l_array_line_number         t_array_number;
2623 l_array_source_meaning      t_array_char2000;
2624 l_array_source_value        t_array_char2000;
2625 l_curr_line_number          NUMBER;
2626 
2627 BEGIN
2628 IF g_log_enabled THEN
2629       l_log_module := C_DEFAULT_MODULE||'.dump_source_values';
2630    END IF;
2631    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2632       trace
2633          (p_msg      => 'BEGIN of procedure dump_source_values'
2634          ,p_level    => C_LEVEL_PROCEDURE
2635          ,p_module   => l_log_module);
2636    END IF;
2637 
2638 
2639    OPEN source_cur ( p_event_id          => p_event_id
2640                    , p_ledger_id          => p_ledger_id
2641                    , p_object_name        => p_object_name
2642                    , p_object_type_code   => p_object_type_code
2643                    );
2644    --
2645    --
2646    FETCH source_cur BULK COLLECT INTO l_array_source_code
2647                                     , l_array_source_type_code
2648                                     , l_array_source_appl_id
2649                                     , l_array_source_value
2650                                     , l_array_source_meaning
2651                                     , l_array_line_number
2652                                     , l_array_numeric_flag
2653                                     , l_array_meaning_flag
2654                                     ;
2655    --
2656    --
2657    CLOSE source_cur;
2658 
2659    --
2660    l_curr_line_number:= -1;
2661    --
2662    IF l_array_source_code.COUNT > 0 THEN
2663 
2664      FOR Idx IN l_array_source_code.FIRST .. l_array_source_code.LAST LOOP
2665 
2666        IF (l_curr_line_number <> l_array_line_number(Idx) ) THEN
2667 
2668          IF ( l_curr_line_number <> -1 ) THEN
2669            write_html_file('</tr>');
2670          END IF;
2671 
2672          write_html_file('<tr style="background-color: #f7f7e7" valign="top">');
2673          IF p_object_type_code IN (C_LINE,C_BC_LINE,C_MLS_LINE ) THEN
2674             write_html_file('<td style="text-align: right;">'||TO_CHAR(l_array_line_number(Idx))||'</td>');
2675          END IF;
2676          l_curr_line_number:= l_array_line_number(Idx);
2677 
2678        END IF;
2679 
2680        IF l_array_numeric_flag(Idx) ='Y' THEN
2681 
2682          write_html_file('<td style="text-align: right;">'||l_array_source_value(Idx)||'</td>');
2683 
2684        ELSE
2685 
2686           write_html_file('<td> '||l_array_source_value(Idx) ||' </td>');
2687 
2688        END IF;
2689 
2690        IF ( l_array_meaning_flag(Idx)='Y')
2691        THEN
2692            write_html_file('<td> '||l_array_source_meaning(Idx)||' </td>');
2693        END IF;
2694 
2695      END LOOP;
2696 
2697      IF ( l_curr_line_number <> -1 ) THEN
2698            write_html_file('</tr>');
2699      END IF;
2700 
2701    END IF;
2702 
2703    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2704       trace
2705          (p_msg      => 'END of procedure dump_source_values'
2706          ,p_level    => C_LEVEL_PROCEDURE
2707          ,p_module   => l_log_module);
2708    END IF;
2709 
2710 EXCEPTION
2711 WHEN xla_exceptions_pkg.application_exception THEN
2712    RAISE;
2713 WHEN OTHERS THEN
2714    xla_exceptions_pkg.raise_message
2715       (p_location => 'xla_accounting_dump_pkg.dump_source_values');
2716 END dump_source_values;
2717 
2718 --============================================================================
2719 --
2720 -- PUBLIC PROCEDURE
2721 --     transaction_objects_diag
2722 --
2723 --============================================================================
2724 PROCEDURE transaction_objects_diag
2725         (p_errbuf                    OUT NOCOPY VARCHAR2
2726        ,p_retcode                    OUT NOCOPY NUMBER
2727        ,p_application_id             IN NUMBER
2728        ,p_dummy_parameter_1          IN VARCHAR2
2729        ,p_ledger_id                  IN NUMBER
2730        ,p_dummy_parameter_2          IN VARCHAR2
2731        ,p_event_class_code           IN VARCHAR2
2732        ,p_dummy_parameter_3          IN VARCHAR2
2733        ,p_event_type_code            IN VARCHAR2
2734        ,p_dummy_parameter_4          IN VARCHAR2
2735        ,p_transaction_number         IN VARCHAR2
2736        ,p_dummy_parameter_5          IN VARCHAR2
2737        ,p_event_number               IN NUMBER
2738        ,p_dummy_parameter_6          IN VARCHAR2
2739        ,p_from_line_number           IN NUMBER
2740        ,p_dummy_parameter_7          IN VARCHAR2
2741        ,p_to_line_number             IN NUMBER
2742        ,p_request_id                 IN NUMBER
2743        ,p_errors_only                IN VARCHAR2
2744        ,p_source_name                IN VARCHAR2
2745        ,p_acctg_attribute            IN VARCHAR2)
2746 IS
2747 l_log_module                      VARCHAR2(240);
2748 BEGIN
2749    IF g_log_enabled THEN
2750 
2754 
2751       l_log_module := C_DEFAULT_MODULE||'.transaction_objects_diag';
2752 
2753    END IF;
2755    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2756       trace
2757          (p_msg      => 'BEGIN of procedure transaction_objects_diag'
2758          ,p_level    => C_LEVEL_PROCEDURE
2759          ,p_module   => l_log_module);
2760 
2761    END IF;
2762 
2763 
2764   initialize
2765        (p_application_id       => p_application_id
2766        ,p_ledger_id            => p_ledger_id
2767        ,p_event_class_code     => p_event_class_code
2768        ,p_event_type_code      => p_event_type_code
2769        ,p_transaction_number   => p_transaction_number
2770        ,p_event_number         => p_event_number
2771        ,p_from_line_number     => p_from_line_number
2772        ,p_to_line_number       => p_to_line_number
2773        ,p_request_id           => p_request_id
2774        ,p_errors_only          => p_errors_only
2775        ,p_source_name          => p_source_name
2776        ,p_acctg_attribute      => p_acctg_attribute
2777        );
2778    --
2779    -- build the HTML file
2780    --
2781 
2782    write_title();
2783 
2784    write_header();
2785 
2786    get_diagnostic_events();
2787 
2788    IF g_array_events.event_id.COUNT = 0 THEN
2789 
2790          write_warning_msg(  p_appli_s_name => 'XLA'
2791                            , p_msg_name     => 'XLA_DMP_NO_DATA_FOUND'
2792                            , p_token_1      => NULL
2793                            , p_value_1      => NULL
2794                            , p_token_2      => NULL
2795                            , p_value_2      => NULL
2796                            , p_token_3      => NULL
2797                            , p_value_3      => NULL
2798                          );
2799          p_retcode             := 1;
2800          p_errbuf              := 'Transaction Objects Diagnostics ended in Warning'
2801                                  || ' because no data match the search criteria';
2802 
2803    ELSE
2804 
2805          dump_diagnostic_events();
2806          dump_diagnostic_Ledgers();
2807          dump_diagnostic_sources();
2808 
2809          p_retcode             := 0;
2810          p_errbuf              := 'Transaction Objects Diagnostics completed Normal';
2811 
2812    END IF;
2813 
2814    write_footer();
2815 
2816    --
2817    -- write HTML file into the request output file
2818    --
2819 
2820    write_output();
2821 
2822 
2823    --
2824    -- write HTML file into the FND log attachment
2825    --
2826 
2827    IF (C_LEVEL_UNEXPECTED >= g_log_level) THEN
2828 
2829        write_fnd_log_attachment();
2830 
2831    END IF;
2832 
2833 
2834    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2835 
2836        trace
2837                 (p_msg      => 'p_retcode = '||p_retcode
2838                 ,p_level    => C_LEVEL_STATEMENT
2839                 ,p_module   => l_log_module);
2840        trace
2841                 (p_msg      => 'p_errbuf = '||p_errbuf
2842                 ,p_level    => C_LEVEL_STATEMENT
2843                 ,p_module   => l_log_module);
2844 
2845    END IF;
2846 
2847  IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2848       trace
2849          (p_msg      => 'END of procedure transaction_objects_diag'
2850          ,p_level    => C_LEVEL_PROCEDURE
2851          ,p_module   => l_log_module);
2852 
2853  END IF;
2854 EXCEPTION
2855 WHEN xla_exceptions_pkg.application_exception THEN
2856    ----------------------------------------------------------------------------
2857    -- set out variables
2858    ----------------------------------------------------------------------------
2859    p_retcode                := 2;
2860    p_errbuf                 := xla_messages_pkg.get_message;
2861 
2862 
2863    write_html_file(p_errbuf);
2864    write_logfile(p_errbuf);
2865 
2866    IF (C_LEVEL_ERROR >= g_log_level) THEN
2867       trace
2868          (p_msg      => NULL
2869          ,p_level    => C_LEVEL_ERROR
2870          ,p_module   => l_log_module);
2871    END IF;
2872 
2873    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2874       trace
2875          (p_msg      => 'p_retcode = '||p_retcode
2876          ,p_level    => C_LEVEL_PROCEDURE
2877          ,p_module   => l_log_module);
2878       trace
2879          (p_msg      => 'p_errbuf = '||p_errbuf
2880          ,p_level    => C_LEVEL_PROCEDURE
2881          ,p_module   => l_log_module);
2882       trace
2883          (p_msg      => 'END of procedure transaction_objects_diag'
2884          ,p_level    => C_LEVEL_PROCEDURE
2885          ,p_module   => l_log_module);
2886    END IF;
2887 WHEN OTHERS THEN
2888    ----------------------------------------------------------------------------
2889    -- set out variables
2890    ----------------------------------------------------------------------------
2891    p_retcode                := 2;
2892    p_errbuf                 := sqlerrm;
2893 
2894    write_html_file(p_errbuf);
2895    write_logfile(p_errbuf);
2896 
2897    IF (C_LEVEL_UNEXPECTED >= g_log_level) THEN
2898       trace
2899          (p_msg      => NULL
2900          ,p_level    => C_LEVEL_UNEXPECTED
2901          ,p_module   => l_log_module);
2902    END IF;
2903 
2904    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2905       trace
2906          (p_msg      => 'p_retcode = '||p_retcode
2910          (p_msg      => 'p_errbuf = '||p_errbuf
2907          ,p_level    => C_LEVEL_PROCEDURE
2908          ,p_module   => l_log_module);
2909       trace
2911          ,p_level    => C_LEVEL_PROCEDURE
2912          ,p_module   => l_log_module);
2913       trace
2914          (p_msg      => 'END of procedure transaction_objects_diag'
2915          ,p_level    => C_LEVEL_PROCEDURE
2916          ,p_module   => l_log_module);
2917    END IF;
2918 END transaction_objects_diag;   -- end of procedure
2919 --
2920 --
2921 --============================================================================
2922 --
2923 -- PUBLIC PROCEDURE: acctg_event_extract_log
2924 --
2925 -- DESCRIPTION     : write the Accounting Event Extract Diagnostics
2926 --                   result into FND Logging large attachment.
2927 --
2928 -- PARAMETERS      :
2929 --============================================================================
2930 PROCEDURE acctg_event_extract_log
2931       ( p_application_id             IN NUMBER
2932        ,p_request_id                 IN NUMBER)IS
2933 l_log_module                      VARCHAR2(240);
2934 BEGIN
2935    IF g_log_enabled THEN
2936 
2937       l_log_module := C_DEFAULT_MODULE||'.acctg_event_extract_log';
2938 
2939    END IF;
2940 
2941    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2942       trace
2943          (p_msg      => 'BEGIN of procedure acctg_event_extract_log'
2944          ,p_level    => C_LEVEL_PROCEDURE
2945          ,p_module   => l_log_module);
2946 
2947    END IF;
2948 
2949  IF (C_LEVEL_UNEXPECTED >= g_log_level) THEN
2950 
2951   initialize
2952        (p_application_id       => p_application_id
2953        ,p_ledger_id            => NULL
2954        ,p_event_class_code     => NULL
2955        ,p_event_type_code      => NULL
2956        ,p_transaction_number   => NULL
2957        ,p_event_number         => NULL
2958        ,p_from_line_number     => NULL
2959        ,p_to_line_number       => NULL
2960        ,p_request_id           => p_request_id
2961        ,p_errors_only          => 'N'
2962        ,p_source_name          => 'N'
2963        ,p_acctg_attribute      => 'N'
2964        );
2965 
2966    write_title();
2967 
2968    write_header();
2969 
2970    get_diagnostic_events();
2971 
2972    IF g_array_events.event_id.COUNT = 0 THEN
2973 
2974           write_warning_msg(  p_appli_s_name => 'XLA'
2975                             , p_msg_name     => 'XLA_DMP_NO_DATA_FOUND'
2976                             , p_token_1      => NULL
2977                             , p_value_1      => NULL
2978                             , p_token_2      => NULL
2979                             , p_value_2      => NULL
2980                             , p_token_3      => NULL
2981                             , p_value_3      => NULL
2982                           );
2983 
2984    ELSE
2985 
2986          dump_diagnostic_events();
2987          dump_diagnostic_Ledgers();
2988          dump_diagnostic_sources();
2989 
2990    END IF;
2991 
2992    write_footer();
2993 
2994    write_fnd_log_attachment();
2995 
2996  END IF;
2997 
2998  IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2999       trace
3000          (p_msg      => 'END of procedure acctg_event_extract_log'
3001          ,p_level    => C_LEVEL_PROCEDURE
3002          ,p_module   => l_log_module);
3003 
3004  END IF;
3005 
3006 EXCEPTION
3007 WHEN xla_exceptions_pkg.application_exception THEN
3008 
3009    IF (C_LEVEL_ERROR >= g_log_level) THEN
3010       trace
3011          (p_msg      => 'ERROR ='||xla_messages_pkg.get_message
3012          ,p_level    => C_LEVEL_ERROR
3013          ,p_module   => l_log_module);
3014    END IF;
3015 
3016    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3017       trace
3018          (p_msg      => 'END of procedure acctg_event_extract_log'
3019          ,p_level    => C_LEVEL_PROCEDURE
3020          ,p_module   => l_log_module);
3021    END IF;
3022    RAISE;
3023 WHEN OTHERS THEN
3024 
3025    IF (C_LEVEL_UNEXPECTED >= g_log_level) THEN
3026       trace
3027          (p_msg      => 'ERROR =' ||sqlerrm
3028          ,p_level    => C_LEVEL_UNEXPECTED
3029          ,p_module   => l_log_module);
3030    END IF;
3031 
3032    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3033       trace
3034          (p_msg      => 'END of procedure acctg_event_extract_log'
3035          ,p_level    => C_LEVEL_PROCEDURE
3036          ,p_module   => l_log_module);
3037    END IF;
3038  xla_exceptions_pkg.raise_message
3039       (p_location => 'xla_accounting_dump_pkg.acctg_event_extract_log');
3040 END acctg_event_extract_log;   -- end of procedure
3041 
3042 
3043 --============================================================================
3044 --
3045 -- PUBLIC PROCEDURE
3046 --     purge
3047 --
3048 --============================================================================
3049 PROCEDURE purge
3050        (p_errbuf                     OUT NOCOPY VARCHAR2
3051        ,p_retcode                    OUT NOCOPY NUMBER
3052        ,p_application_id             IN NUMBER
3053        ,p_up_to_date                 IN DATE
3054        ,p_request_id                 IN NUMBER
3055              )
3056 IS
3057 l_log_module                      VARCHAR2(240);
3058 l_count                           NUMBER;
3059 l_rownum                          NUMBER;
3060 l_up_to_date                      DATE;
3061 BEGIN
3062 
3063    IF g_log_enabled THEN
3064 
3065       l_log_module := C_DEFAULT_MODULE||'.purge';
3066 
3067    END IF;
3071          (p_msg      => 'BEGIN of procedure purge'
3068 
3069    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3070       trace
3072          ,p_level    => C_LEVEL_PROCEDURE
3073          ,p_module   => l_log_module);
3074 
3075    END IF;
3076 
3077    SAVEPOINT purgeDATA;
3078 
3079    l_rownum     := 0;
3080    l_up_to_date := TRUNC(p_up_to_date);
3081    write_logfile('**Parameters ** ');
3082    write_logfile('Application Id = '||TO_CHAR(p_application_id));
3083    write_logfile('End Date = '||TO_CHAR(l_up_to_date));
3084    write_logfile('Accounting Program Request Id= '||TO_CHAR(p_request_id));
3085 
3086     IF l_up_to_date IS NOT NULL AND p_request_id IS NOT NULL THEN
3087 
3088           SELECT count(*)
3089           INTO l_count
3090           FROM xla_diag_sources
3091          WHERE source_application_id = p_application_id
3092            AND creation_date <= l_up_to_date
3093            AND request_id    =  p_request_id
3094          ;
3095 
3096    ELSIF l_up_to_date IS NULL AND p_request_id IS NOT NULL THEN
3097 
3098         SELECT count(*)
3099           INTO l_count
3100           FROM xla_diag_sources
3101          WHERE source_application_id = p_application_id
3102            AND request_id    =  p_request_id
3103          ;
3104 
3105 
3106    ELSIF l_up_to_date IS NOT NULL AND p_request_id IS NULL THEN
3107 
3108           SELECT count(*)
3109           INTO l_count
3110           FROM xla_diag_sources
3111          WHERE source_application_id = p_application_id
3112            AND creation_date <= l_up_to_date
3113          ;
3114 
3115    ELSE
3116 
3117           SELECT count(*)
3118           INTO l_count
3119           FROM xla_diag_sources
3120          WHERE source_application_id = p_application_id
3121          ;
3122 
3123    END IF;
3124 
3125 
3126    IF l_count  = 0 THEN
3127 
3128          p_retcode             := 1;
3129          p_errbuf              := 'Transaction Objects Diagnostics purge ended in Warning'
3130                                  || ' because no data match the selection criteria';
3131 
3132    ELSE
3133 
3134 
3135      write_logfile('**Start** purge of xla_diag_events');
3136 
3137      IF l_up_to_date IS NOT NULL AND p_request_id IS NOT NULL THEN
3138 
3139           DELETE FROM xla_diag_events
3140            WHERE event_id IN
3141                     (SELECT event_id FROM xla_diag_events
3142                       WHERE application_id = p_application_id
3143                         AND creation_date <= l_up_to_date
3144                         AND request_id    = p_request_id)
3145           ;
3146 
3147      ELSIF l_up_to_date IS NULL AND p_request_id IS NOT NULL THEN
3148 
3149           DELETE FROM xla_diag_events
3150            WHERE event_id IN
3151                     (SELECT event_id FROM xla_diag_events
3152                       WHERE application_id = p_application_id
3153                         AND request_id    = p_request_id)
3154           ;
3155 
3156      ELSIF l_up_to_date IS NOT NULL AND p_request_id IS NULL THEN
3157 
3158           DELETE FROM xla_diag_events
3159            WHERE event_id IN
3160                     (SELECT event_id FROM xla_diag_events
3161                       WHERE application_id = p_application_id
3162                         AND creation_date <= l_up_to_date)
3163           ;
3164 
3165      ELSE
3166 
3167           DELETE FROM xla_diag_events
3168            WHERE event_id IN
3169                     (SELECT event_id FROM xla_diag_events
3170                       WHERE application_id = p_application_id )
3171           ;
3172 
3173      END IF;
3174 
3175      l_rownum := l_rownum + SQL%ROWCOUNT;
3176      IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3177       trace
3178          (p_msg      => 'Number of rows deleted = '||SQL%ROWCOUNT
3179          ,p_level    => C_LEVEL_STATEMENT
3180          ,p_module   => l_log_module);
3181      END IF;
3182 
3183     write_logfile('Number of rows deleted ='||SQL%ROWCOUNT);
3184     write_logfile('** End ** purge of xla_diag_events');
3185     write_logfile('**Start** purge of xla_diag_ledgers');
3186 
3187 
3188      DELETE FROM xla_diag_ledgers
3189       WHERE application_id = p_application_id
3190         AND primary_ledger_id NOT IN
3191               (SELECT ledger_id
3192                  FROM xla_diag_events
3193                 WHERE application_id        = p_application_id
3194              )
3195       ;
3196 
3197      l_rownum := l_rownum + SQL%ROWCOUNT;
3198      IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3199       trace
3200          (p_msg      => 'Number of rows deleted = '||SQL%ROWCOUNT
3201          ,p_level    => C_LEVEL_STATEMENT
3202          ,p_module   => l_log_module);
3203      END IF;
3204     write_logfile('Number of rows deleted ='||SQL%ROWCOUNT);
3205     write_logfile('** End ** purge of xla_diag_ledgers');
3206     write_logfile('**Start** purge of xla_diag_sources');
3207 
3208      IF l_up_to_date IS NOT NULL AND p_request_id IS NOT NULL THEN
3209 
3210          DELETE FROM xla_diag_sources
3211           WHERE source_application_id = p_application_id
3212             AND creation_date        <= l_up_to_date
3213             AND request_id            = p_request_id
3214           ;
3215 
3216 
3217      ELSIF l_up_to_date IS NULL AND p_request_id IS NOT NULL THEN
3218 
3219          DELETE FROM xla_diag_sources
3220           WHERE source_application_id = p_application_id
3221             AND request_id            = p_request_id
3222           ;
3223 
3224      ELSIF l_up_to_date IS NOT NULL AND p_request_id IS NULL THEN
3225 
3226          DELETE FROM xla_diag_sources
3227           WHERE source_application_id = p_application_id
3228             AND creation_date        <= l_up_to_date
3229           ;
3230 
3231      ELSE
3232 
3233          DELETE FROM xla_diag_sources
3234           WHERE source_application_id = p_application_id
3235           ;
3236 
3237      END IF;
3238 
3239      l_rownum := l_rownum + SQL%ROWCOUNT;
3240      IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3241       trace
3242          (p_msg      => 'Number of rows deleted = '||SQL%ROWCOUNT
3243          ,p_level    => C_LEVEL_STATEMENT
3244          ,p_module   => l_log_module);
3245      END IF;
3246      write_logfile('Number of rows deleted ='||SQL%ROWCOUNT);
3247      write_logfile('**END** purge of xla_diag_sources');
3248 
3249      IF l_rownum > 0 THEN
3250           write_logfile('**COMMIT** purge of Transaction Objects Diagnostics');
3251           COMMIT;
3252      END IF;
3253      p_retcode             := 0;
3254      p_errbuf              := 'Transaction Objects Diagnostics purge completed Normal';
3255 
3256    null;
3257    END IF;
3258 
3259 
3260    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3261 
3262        trace
3263                 (p_msg      => 'p_retcode = '||p_retcode
3264                 ,p_level    => C_LEVEL_STATEMENT
3265                 ,p_module   => l_log_module);
3266        trace
3267                 (p_msg      => 'p_errbuf = '||p_errbuf
3268                 ,p_level    => C_LEVEL_STATEMENT
3269                 ,p_module   => l_log_module);
3270 
3271    END IF;
3272 
3273  IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3274       trace
3275          (p_msg      => 'END of procedure purge'
3276          ,p_level    => C_LEVEL_PROCEDURE
3277          ,p_module   => l_log_module);
3278 
3279  END IF;
3280 EXCEPTION
3281 WHEN xla_exceptions_pkg.application_exception THEN
3282 
3283    ROLLBACK TO  purgeDATA;
3284    ----------------------------------------------------------------------------
3285    -- set out variables
3286    ----------------------------------------------------------------------------
3287    p_retcode                := 2;
3288    p_errbuf                 := xla_messages_pkg.get_message;
3289 
3290    write_logfile(p_errbuf);
3291 
3292    IF (C_LEVEL_ERROR >= g_log_level) THEN
3293       trace
3294          (p_msg      => NULL
3295          ,p_level    => C_LEVEL_ERROR
3296          ,p_module   => l_log_module);
3297    END IF;
3298 
3299    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3300       trace
3301          (p_msg      => 'p_retcode = '||p_retcode
3302          ,p_level    => C_LEVEL_PROCEDURE
3303          ,p_module   => l_log_module);
3304       trace
3305          (p_msg      => 'p_errbuf = '||p_errbuf
3306          ,p_level    => C_LEVEL_PROCEDURE
3307          ,p_module   => l_log_module);
3308       trace
3309          (p_msg      => 'END of procedure purge'
3310          ,p_level    => C_LEVEL_PROCEDURE
3311          ,p_module   => l_log_module);
3312    END IF;
3313 WHEN OTHERS THEN
3314 
3315    ROLLBACK TO  purgeDATA;
3316    ----------------------------------------------------------------------------
3317    -- set out variables
3318    ----------------------------------------------------------------------------
3319    p_retcode                := 2;
3320    p_errbuf                 := sqlerrm;
3321 
3322 
3323    write_logfile(p_errbuf);
3324 
3325    IF (C_LEVEL_UNEXPECTED >= g_log_level) THEN
3326       trace
3327          (p_msg      => NULL
3328          ,p_level    => C_LEVEL_UNEXPECTED
3329          ,p_module   => l_log_module);
3330    END IF;
3331 
3332    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3333       trace
3334          (p_msg      => 'p_retcode = '||p_retcode
3335          ,p_level    => C_LEVEL_PROCEDURE
3336          ,p_module   => l_log_module);
3337       trace
3338          (p_msg      => 'p_errbuf = '||p_errbuf
3339          ,p_level    => C_LEVEL_PROCEDURE
3340          ,p_module   => l_log_module);
3341       trace
3342          (p_msg      => 'END of procedurepurge'
3343          ,p_level    => C_LEVEL_PROCEDURE
3344          ,p_module   => l_log_module);
3345    END IF;
3346 END purge;   -- end of procedure
3347 --
3348 --
3349 --=============================================================================
3350 --
3351 --
3352 --
3353 --
3354 --
3355 --
3356 --
3357 --
3358 --
3359 --
3360 -- Following code is executed when the package body is referenced for the first
3361 -- time
3362 --
3363 --
3364 --
3365 --
3366 --
3367 --
3368 --
3369 --
3370 --
3371 --
3372 --
3373 --
3374 --=============================================================================
3375 
3376 BEGIN
3377 
3378    g_log_level      := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3379    g_log_enabled    := fnd_log.test
3380                           (log_level  => g_log_level
3381                           ,module     => C_DEFAULT_MODULE);
3382 
3383    IF NOT g_log_enabled  THEN
3384       g_log_level := C_LEVEL_LOG_DISABLED;
3385    END IF;
3386    --
3387 END xla_accounting_dump_pkg; -- end of package spec.