DBA Data[Home] [Help]

PACKAGE BODY: APPS.XLA_AMB_SETUP_ERR_PKG

Source


1 PACKAGE BODY xla_amb_setup_err_pkg AS
2 -- $Header: xlaamerr.pkb 120.8 2005/06/28 20:10:30 dcshah ship $
3 /*===========================================================================+
4 |             Copyright (c) 2001-2002 Oracle Corporation                     |
5 |                       Redwood Shores, CA, USA                              |
6 |                         All rights reserved.                               |
7 +============================================================================+
8 | PACKAGE NAME                                                               |
9 |     xla_amb_setup_err_pkg                                                  |
10 |                                                                            |
11 | DESCRIPTION                                                                |
12 |     This is the body of the package that handles errors for accounting     |
13 |     methods builder setup generated by the Extract Integrity Checker and   |
14 |     Application Accounting Definition Compilation process                  |
15 |                                                                            |
16 | HISTORY                                                                    |
17 |     12/10/2003      Dimple Shah    Created                                 |
18 |                                                                            |
19 +===========================================================================*/
20 
21 --=============================================================================
22 --           ****************  declaraions  ********************
23 --=============================================================================
24 -------------------------------------------------------------------------------
25 -- declaring private package variables
26 -------------------------------------------------------------------------------
27 g_error_index                  PLS_INTEGER := 0;
28 g_error_count                  PLS_INTEGER := 0;
29 g_amb_errors                   xla_amb_setup_err_pkg.t_array_error;
30 g_request_id                   NUMBER;
31 -------------------------------------------------------------------------------
32 -- forward declarion of private procedures and functions
33 -------------------------------------------------------------------------------
34 PROCEDURE reset;
35 
36 --=============================================================================
37 --               *********** Local Trace Routine **********
38 --=============================================================================
39 C_LEVEL_STATEMENT     CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
40 C_LEVEL_PROCEDURE     CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
41 C_LEVEL_EVENT         CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
42 C_LEVEL_EXCEPTION     CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
43 C_LEVEL_ERROR         CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
44 C_LEVEL_UNEXPECTED    CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
45 
46 C_DEFAULT_MODULE      CONSTANT VARCHAR2(240) := 'xla.plsql.xla_amb_setup_err_pkg';
47 
48 g_trace_label   VARCHAR2(240);
49 g_log_level     NUMBER;
50 g_log_enabled   BOOLEAN;
51 
52 
53 PROCEDURE trace
54        (p_msg                        IN VARCHAR2
55        ,p_level                      IN NUMBER) IS
56 
57    l_module         VARCHAR2(240);
58 BEGIN
59    ----------------------------------------------------------------------------
60    -- Following is for FND log.
61    ----------------------------------------------------------------------------
62    l_module := C_DEFAULT_MODULE||'.'||g_trace_label;
63 
64    IF (p_msg IS NULL AND p_level >= g_log_level) THEN
65       fnd_log.message(p_level, l_module);
66    ELSIF p_level >= g_log_level THEN
67       fnd_log.string(p_level, l_module, p_msg);
68    END IF;
69 EXCEPTION
70    WHEN xla_exceptions_pkg.application_exception THEN
71       RAISE;
72    WHEN OTHERS THEN
73       xla_exceptions_pkg.raise_message
74          (p_location   => 'xla_amb_setup_err_pkg.trace');
75 END trace;
76 
77 --=============================================================================
78 --          *********** public procedures and functions **********
79 --=============================================================================
80 --=============================================================================
81 --
82 -- Following are the public routines:
83 --
84 --    1.    initialize
85 --    2.    stack_error
86 --    3.    insert_errors
87 --
88 --
89 --=============================================================================
90 
91 /*======================================================================+
92 |                                                                       |
93 | Public Procedure                                                      |
94 |                                                                       |
95 | Initialize                                                            |
96 |                                                                       |
97 | This routine is called in the beginning of the program                |
98 | to initialize the array                                               |
99 |                                                                       |
100 +======================================================================*/
101 
102 PROCEDURE initialize
103        (p_request_id              IN  NUMBER   DEFAULT NULL)
104 
105 IS
106 
107 BEGIN
108    g_trace_label :='Initialize';
109    IF ((g_log_enabled = TRUE) AND (C_LEVEL_PROCEDURE >= g_log_level)) THEN
110      trace
111       (p_msg      => 'Begin'
112       ,p_level    => C_LEVEL_PROCEDURE);
113      trace
114       (p_msg      => 'p_request_id = ' ||p_request_id
115       ,p_level    => C_LEVEL_PROCEDURE);
116    END IF;
117 
118    -- Initializing Global Variables
119    g_request_id      := NVL(p_request_id,NVL(g_request_id,xla_environment_pkg.g_req_id));
120    g_error_count     := 0;
121 
122    -- Call Reset
123    reset;
124 
125    IF ((g_log_enabled = TRUE) AND (C_LEVEL_PROCEDURE >= g_log_level)) THEN
126       trace
127        (p_msg      => 'End'
128        ,p_level    => C_LEVEL_PROCEDURE);
129    END IF;
130 
131 EXCEPTION
132 WHEN xla_exceptions_pkg.application_exception THEN
133    RAISE;
134 WHEN OTHERS THEN
135    xla_exceptions_pkg.raise_message
136        (p_location       => 'xla_amb_setup_err_pkg.initialize');
137 END initialize;
138 
139 /*======================================================================+
140 |                                                                       |
141 | Public Procedure                                                      |
142 |                                                                       |
143 | Stack_Error                                                           |
144 |                                                                       |
145 | This routine is called to stack the error into a plsql array          |
146 |                                                                       |
147 +======================================================================*/
148 
149 PROCEDURE stack_error
150        (p_message_name               IN  VARCHAR2
151        ,p_message_type               IN  VARCHAR2
152        ,p_message_category           IN  VARCHAR2
153        ,p_category_sequence          IN  NUMBER
154        ,p_application_id             IN  NUMBER
155        ,p_amb_context_code           IN  VARCHAR2 DEFAULT NULL
156        ,p_product_rule_type_code     IN  VARCHAR2 DEFAULT NULL
157        ,p_product_rule_code          IN  VARCHAR2 DEFAULT NULL
158        ,p_entity_code                IN  VARCHAR2 DEFAULT NULL
159        ,p_event_class_code           IN  VARCHAR2 DEFAULT NULL
160        ,p_event_type_code            IN  VARCHAR2 DEFAULT NULL
161        ,p_line_definition_owner_code IN  VARCHAR2 DEFAULT NULL
162        ,p_line_definition_code       IN  VARCHAR2 DEFAULT NULL
163        ,p_accounting_line_type_code  IN  VARCHAR2 DEFAULT NULL
164        ,p_accounting_line_code       IN  VARCHAR2 DEFAULT NULL
165        ,p_description_type_code      IN  VARCHAR2 DEFAULT NULL
166        ,p_description_code           IN  VARCHAR2 DEFAULT NULL
167        ,p_anal_criterion_type_code   IN  VARCHAR2 DEFAULT NULL
168        ,p_anal_criterion_code        IN  VARCHAR2 DEFAULT NULL
169        ,p_segment_rule_type_code     IN  VARCHAR2 DEFAULT NULL
170        ,p_segment_rule_code          IN  VARCHAR2 DEFAULT NULL
171        ,p_mapping_set_code           IN  VARCHAR2 DEFAULT NULL
172        ,p_source_application_id      IN  NUMBER   DEFAULT NULL
173        ,p_source_type_code           IN  VARCHAR2 DEFAULT NULL
174        ,p_source_code                IN  VARCHAR2 DEFAULT NULL
175        ,p_extract_object_name        IN  VARCHAR2 DEFAULT NULL
176        ,p_extract_object_type        IN  VARCHAR2 DEFAULT NULL
177        ,p_accounting_source_code     IN  VARCHAR2 DEFAULT NULL
178        ,p_accounting_group_code      IN  VARCHAR2 DEFAULT NULL
179        ,p_extract_column_name        IN  VARCHAR2 DEFAULT NULL
180        ,p_language                   IN  VARCHAR2 DEFAULT NULL
181        ,p_mpa_acct_line_type_code    IN  VARCHAR2 DEFAULT NULL
182        ,p_mpa_acct_line_code         IN  VARCHAR2 DEFAULT NULL
183        ) IS
184 
185     -- Local Variables
186    l_amb_context_code        VARCHAR2(30);
187    l_product_rule_type_code  VARCHAR2(1);
188    l_product_rule_code       VARCHAR2(30);
189    l_entity_code             VARCHAR2(30);
190    l_event_class_code        VARCHAR2(30);
191 
192 BEGIN
193    g_trace_label :='Stack_error';
194    IF ((g_log_enabled = TRUE) AND (C_LEVEL_PROCEDURE >= g_log_level)) THEN
195      trace
196       (p_msg      => 'Begin'
197       ,p_level    => C_LEVEL_PROCEDURE);
198      trace
199       (p_msg      => 'p_application_id = '  ||TO_CHAR(p_application_id)
200       ,p_level    => C_LEVEL_PROCEDURE);
201      trace
202       (p_msg      => 'p_amb_context_code = '||p_amb_context_code
203       ,p_level    => C_LEVEL_PROCEDURE);
204      trace
205       (p_msg      => 'p_product_rule_type_code = ' ||p_product_rule_type_code
206       ,p_level    => C_LEVEL_PROCEDURE);
207      trace
208       (p_msg      => 'p_product_rule_code = ' ||p_product_rule_code
209       ,p_level    => C_LEVEL_PROCEDURE);
210      trace
211       (p_msg      => 'p_entity_code = ' ||p_entity_code
212       ,p_level    => C_LEVEL_PROCEDURE);
213      trace
214       (p_msg      => 'p_event_class_code = ' ||p_event_class_code
215       ,p_level    => C_LEVEL_PROCEDURE);
216      trace
217       (p_msg      => 'p_message_name = ' ||p_message_name
218       ,p_level    => C_LEVEL_PROCEDURE);
219    END IF;
220 
221    l_amb_context_code        := p_amb_context_code;
222    l_product_rule_type_code  := p_product_rule_type_code;
223    l_product_rule_code       := p_product_rule_code;
224    l_entity_code             := p_entity_code;
225    l_event_class_code        := p_event_class_code;
226 
227    g_error_index    := g_error_index + 1;
228    g_error_count    := g_error_count + 1;
229 
230    -- Stack Errors in the plsql array
231 
232    g_amb_errors(g_error_index).message_name                   := p_message_name;
233    g_amb_errors(g_error_index).message_type_flag              := p_message_type;
234    g_amb_errors(g_error_index).message_category_code          := p_message_category;
235    g_amb_errors(g_error_index).category_sequence_num          := p_category_sequence;
236    g_amb_errors(g_error_index).application_id                 := p_application_id;
237    g_amb_errors(g_error_index).amb_context_code               := p_amb_context_code;
238    g_amb_errors(g_error_index).product_rule_type_code         := p_product_rule_type_code;
239    g_amb_errors(g_error_index).product_rule_code              := p_product_rule_code;
240    g_amb_errors(g_error_index).line_definition_owner_code     := p_line_definition_owner_code;
241    g_amb_errors(g_error_index).line_definition_code           := p_line_definition_code;
242    g_amb_errors(g_error_index).accounting_line_type_code      := p_accounting_line_type_code;
243    g_amb_errors(g_error_index).accounting_line_code           := p_accounting_line_code;
244    g_amb_errors(g_error_index).description_type_code          := p_description_type_code;
245    g_amb_errors(g_error_index).description_code               := p_description_code;
246    g_amb_errors(g_error_index).analytical_criterion_type_code := p_anal_criterion_type_code;
247    g_amb_errors(g_error_index).analytical_criterion_code      := p_anal_criterion_code;
248    g_amb_errors(g_error_index).segment_rule_type_code         := p_segment_rule_type_code;
249    g_amb_errors(g_error_index).segment_rule_code              := p_segment_rule_code;
250    g_amb_errors(g_error_index).entity_code                    := p_entity_code;
251    g_amb_errors(g_error_index).event_class_code               := p_event_class_code;
252    g_amb_errors(g_error_index).event_type_code                := p_event_type_code;
253    g_amb_errors(g_error_index).mapping_set_code               := p_mapping_set_code;
254    g_amb_errors(g_error_index).source_application_id          := p_source_application_id;
255    g_amb_errors(g_error_index).source_type_code               := p_source_type_code;
256    g_amb_errors(g_error_index).source_code                    := p_source_code;
257    g_amb_errors(g_error_index).extract_object_name            := p_extract_object_name;
258    g_amb_errors(g_error_index).extract_object_type_code       := p_extract_object_type;
259    g_amb_errors(g_error_index).accounting_source_code         := p_accounting_source_code;
260    g_amb_errors(g_error_index).mapping_group_code             := p_accounting_group_code;
261    g_amb_errors(g_error_index).request_id                     := g_request_id;
262    g_amb_errors(g_error_index).extract_column_name            := p_extract_column_name;
263    g_amb_errors(g_error_index).language                       := p_language;
264    g_amb_errors(g_error_index).mpa_accounting_line_type_code  := p_mpa_acct_line_type_code;
265    g_amb_errors(g_error_index).mpa_accounting_line_code       := p_mpa_acct_line_code;
266 
267    IF ((g_log_enabled = TRUE) AND (C_LEVEL_PROCEDURE >= g_log_level)) THEN
268       trace
269        (p_msg      => 'End'
270        ,p_level    => C_LEVEL_PROCEDURE);
271    END IF;
272 
273 EXCEPTION
274 WHEN xla_exceptions_pkg.application_exception THEN
275    RAISE;
276 WHEN OTHERS THEN
277    xla_exceptions_pkg.raise_message
278        (p_location       => 'xla_amb_setup_err_pkg.stack_error');
279 END stack_error;
280 
281 /*======================================================================+
282 |                                                                       |
283 | Public Procedure                                                      |
284 |                                                                       |
285 | Insert_Errors                                                         |
286 |                                                                       |
287 | This routine is called at the end of the program to insert all        |
288 | errors from the plsql array into the error table  and reset the array |
289 |                                                                       |
290 +======================================================================*/
291 
292 PROCEDURE insert_errors IS
293 BEGIN
294    g_trace_label :='Insert_errors';
295    IF ((g_log_enabled = TRUE) AND (C_LEVEL_PROCEDURE >= g_log_level)) THEN
296      trace
297       (p_msg      => 'Begin'
298       ,p_level    => C_LEVEL_PROCEDURE);
299      trace
300       (p_msg      => 'Count of Error Messages in the stack =  '  ||TO_CHAR(g_error_index)
301       ,p_level    => C_LEVEL_PROCEDURE);
302    END IF;
303 
304    IF g_error_index > 0 THEN
305       FOR i IN g_amb_errors.FIRST..g_amb_errors.LAST
306       LOOP
307          INSERT INTO xla_amb_setup_errors
308                         (amb_error_id
309                         ,message_name
310                         ,message_type_flag
311                         ,category_sequence_num
312                         ,message_category_code
313                         ,application_id
314                         ,amb_context_code
315                         ,product_rule_type_code
316                         ,product_rule_code
317                         ,entity_code
318                         ,event_class_code
319                         ,event_type_code
320                         ,line_definition_owner_code
321                         ,line_definition_code
322                         ,accounting_line_type_code
323                         ,accounting_line_code
324                         ,description_type_code
325                         ,description_code
326                         ,analytical_criterion_type_code
330                         ,mapping_set_code
327                         ,analytical_criterion_code
328                         ,segment_rule_type_code
329                         ,segment_rule_code
331                         ,source_application_id
332                         ,source_type_code
333                         ,source_code
334                         ,extract_object_name
335                         ,extract_object_type_code
336                         ,accounting_source_code
337                         ,mapping_group_code
338                         ,created_by
339                         ,creation_date
340                         ,last_update_date
341                         ,last_updated_by
342                         ,last_update_login
343                         ,program_update_date
344                         ,program_application_id
345                         ,program_id
346                         ,request_id
347                         ,extract_column_name
348                         ,language
349                         ,mpa_accounting_line_type_code
350                         ,mpa_accounting_line_code)
351                  VALUES (xla_amb_setup_errors_s.nextval
352                         ,g_amb_errors(i).message_name
353                         ,g_amb_errors(i).message_type_flag
354                         ,g_amb_errors(i).category_sequence_num
355                         ,g_amb_errors(i).message_category_code
356                         ,g_amb_errors(i).application_id
357                         ,g_amb_errors(i).amb_context_code
358                         ,g_amb_errors(i).product_rule_type_code
359                         ,g_amb_errors(i).product_rule_code
360                         ,g_amb_errors(i).entity_code
361                         ,g_amb_errors(i).event_class_code
362                         ,g_amb_errors(i).event_type_code
363                         ,g_amb_errors(i).line_definition_owner_code
364                         ,g_amb_errors(i).line_definition_code
365                         ,g_amb_errors(i).accounting_line_type_code
366                         ,g_amb_errors(i).accounting_line_code
367                         ,g_amb_errors(i).description_type_code
368                         ,g_amb_errors(i).description_code
369                         ,g_amb_errors(i).analytical_criterion_type_code
370                         ,g_amb_errors(i).analytical_criterion_code
371                         ,g_amb_errors(i).segment_rule_type_code
372                         ,g_amb_errors(i).segment_rule_code
373                         ,g_amb_errors(i).mapping_set_code
374                         ,g_amb_errors(i).source_application_id
375                         ,g_amb_errors(i).source_type_code
376                         ,g_amb_errors(i).source_code
377                         ,g_amb_errors(i).extract_object_name
378                         ,g_amb_errors(i).extract_object_type_code
379                         ,g_amb_errors(i).accounting_source_code
380                         ,g_amb_errors(i).mapping_group_code
381                         ,xla_environment_pkg.g_usr_id
382                         ,sysdate
383                         ,sysdate
384                         ,xla_environment_pkg.g_usr_id
385                         ,xla_environment_pkg.g_login_id
386                         ,NULL
387                         ,xla_environment_pkg.g_prog_appl_id
388                         ,xla_environment_pkg.g_prog_id
389                         ,g_amb_errors(i).request_id
390                         ,g_amb_errors(i).extract_column_name
391                         ,g_amb_errors(i).language
392                         ,g_amb_errors(i).mpa_accounting_line_type_code
393                         ,g_amb_errors(i).mpa_accounting_line_code);
394       END LOOP;
395    END IF;
396 
397    ----------------------------------------------------------------------------
398    -- call to reset is made to clear the pl/sql array
399    ----------------------------------------------------------------------------
400    reset;
401 
402    IF ((g_log_enabled = TRUE) AND (C_LEVEL_PROCEDURE >= g_log_level)) THEN
403       trace
404        (p_msg      => 'End'
405        ,p_level    => C_LEVEL_PROCEDURE);
406    END IF;
407 
408 EXCEPTION
409 WHEN xla_exceptions_pkg.application_exception THEN
410    RAISE;
411 WHEN OTHERS THEN
412    xla_exceptions_pkg.raise_message
413        (p_location       => 'xla_amb_setup_err_pkg.insert_errors');
414 END insert_errors;
415 
416 
417 --=============================================================================
418 --          *********** private procedures and functions **********
419 --=============================================================================
420 --=============================================================================
421 --
422 -- Following are the private routines:
423 --
424 --    1.    reset
425 --
426 --
427 --=============================================================================
428 
429 /*======================================================================+
430 |                                                                       |
431 | Private Procedure                                                     |
432 |                                                                       |
433 | Reset                                                                 |
434 |                                                                       |
435 | This routine initializes the plsql array in which errors are stacked  |
436 | in memory                                                             |
437 |                                                                       |
438 +======================================================================*/
439 
440 PROCEDURE reset IS
441 BEGIN
442    g_trace_label :='Reset';
443    IF ((g_log_enabled = TRUE) AND (C_LEVEL_PROCEDURE >= g_log_level)) THEN
444      trace
448 
445       (p_msg      => 'Begin'
446       ,p_level    => C_LEVEL_PROCEDURE);
447    END IF;
449    g_error_index := 0;
450    g_amb_errors.DELETE;
451 
452    IF ((g_log_enabled = TRUE) AND (C_LEVEL_PROCEDURE >= g_log_level)) THEN
453       trace
454        (p_msg      => 'End'
455        ,p_level    => C_LEVEL_PROCEDURE);
456    END IF;
457 
458 EXCEPTION
459 WHEN xla_exceptions_pkg.application_exception THEN
460    RAISE;
461 WHEN OTHERS THEN
462    xla_exceptions_pkg.raise_message
463        (p_location       => 'xla_amb_setup_err_pkg.reset');
464 END reset;
465 
466 -- This is run only the first time when the package is called.
467 BEGIN
468 
469 g_log_level     :=  FND_LOG.G_CURRENT_RUNTIME_LEVEL;
470 g_log_enabled   :=  fnd_log.test
471                                (log_level  => g_log_level
472                                ,module     => C_DEFAULT_MODULE);
473 
474 END xla_amb_setup_err_pkg;