[Home] [Help]
PACKAGE BODY: APPS.XLA_AAD_MERGE_PVT
Source
1 PACKAGE BODY xla_aad_merge_pvt AS
2 /* $Header: xlaalmer.pkb 120.32.12020000.3 2012/08/02 11:37:17 sgullape ship $ */
3
4 --=============================================================================
5 -- **************** declaraions ********************
6 --=============================================================================
7 -------------------------------------------------------------------------------
8 -- declaring global types
9 -------------------------------------------------------------------------------
10 TYPE t_array_varchar30 IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
11 TYPE t_array_varchar80 IS TABLE OF VARCHAR2(80) INDEX BY BINARY_INTEGER;
12 TYPE t_array_int IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;
13
14 -------------------------------------------------------------------------------
15 -- declaring global constants
16 -------------------------------------------------------------------------------
17 ------------------------------------------------------------------------------
18 -- declaring global variables
19 ------------------------------------------------------------------------------
20 g_amb_context_code VARCHAR2(30);
21 g_staging_context_code VARCHAR2(30);
22 g_application_id INTEGER;
23 g_user_type_code VARCHAR2(30);
24 g_analyzed_flag VARCHAR2(1);
25 g_compile_flag VARCHAR2(1);
26 g_usr_id INTEGER;
27 g_login_id INTEGER;
28
29 C_OWNER_SYSTEM CONSTANT VARCHAR2(1) := 'S';
30 C_DATE CONSTANT DATE := TO_DATE('1','j');
31 C_NUM CONSTANT NUMBER := 9.99E125;
32 C_CHAR CONSTANT VARCHAR2(1) := '
33 ';
34
35 G_EXC_WARNING EXCEPTION;
36
37 --=============================================================================
38 -- *********** Local Trace Routine **********
39 --=============================================================================
40 C_LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
41 C_LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
42 C_LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
43 C_LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
44 C_LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
45 C_LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
46
47 C_LEVEL_LOG_DISABLED CONSTANT NUMBER := 99;
48 C_DEFAULT_MODULE CONSTANT VARCHAR2(240) := 'xla.plsql.xla_aad_merge_pvt';
49
50 g_log_level NUMBER;
51 g_log_enabled BOOLEAN;
52
53 PROCEDURE trace
54 (p_msg IN VARCHAR2
55 ,p_module IN VARCHAR2
56 ,p_level IN NUMBER) IS
57 l_time varchar2(300);
58 BEGIN
59 ----------------------------------------------------------------------------
60 -- Following is for FND log.
61 ----------------------------------------------------------------------------
62 IF (p_msg IS NULL AND p_level >= g_log_level) THEN
63 fnd_log.message(p_level, p_module);
64 ELSIF p_level >= g_log_level THEN
65 fnd_log.string(p_level, p_module, p_msg);
66 END IF;
67 EXCEPTION
68 WHEN OTHERS THEN
69 xla_exceptions_pkg.raise_message
70 (p_location => 'xla_aad_merge_pvt.trace');
71
72 END trace;
73
74
75 --=============================================================================
76 -- *********** private procedures and functions **********
77 --=============================================================================
78
79 --=============================================================================
80 --
81 -- Name: pre_merge
82 -- Description: This API prepares the environment for merge
83 --
84 --=============================================================================
85 FUNCTION pre_merge
86 RETURN VARCHAR2
87 IS
88 CURSOR c IS
89 SELECT *
90 FROM xla_appli_amb_contexts
91 WHERE application_id = g_application_id
92 AND amb_context_code = g_amb_context_code
93 FOR UPDATE OF application_id NOWAIT;
94
95 l_lock_error BOOLEAN;
96 l_recinfo xla_appli_amb_contexts%ROWTYPE;
97 l_retcode VARCHAR2(30);
98 l_log_module VARCHAR2(240);
99 BEGIN
100 IF g_log_enabled THEN
101 l_log_module := C_DEFAULT_MODULE||'.pre_merge';
102 END IF;
103
104 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
105 trace(p_msg => 'BEGIN of function pre_merge',
106 p_module => l_log_module,
107 p_level => C_LEVEL_PROCEDURE);
108 END IF;
109
110 l_retcode := 'SUCCESS';
111
112 -- Begin API Logic
113
114 -- Lock the staging area of the AMB context
115 l_lock_error := TRUE;
116 OPEN c;
117 CLOSE c;
118 l_lock_error := FALSE;
119
120 IF (l_retcode = 'SUCCESS') THEN
121 l_retcode := xla_aad_loader_util_pvt.lock_area
122 (p_application_id => g_application_id
123 ,p_amb_context_code => g_amb_context_code);
124
125 IF (l_retcode <> 'SUCCESS') THEN
126 xla_aad_loader_util_pvt.stack_error
127 (p_appli_s_name => 'XLA'
128 ,p_msg_name => 'XLA_AAD_MGR_LOCK_FAILED');
129 l_retcode := 'WARNING';
130 END IF;
131 END IF;
132
133 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
134 trace(p_msg => 'END of function pre_merge - Return value = '||l_retcode,
135 p_module => l_log_module,
136 p_level => C_LEVEL_PROCEDURE);
137 END IF;
138
139 RETURN l_retcode;
140 EXCEPTION
141 WHEN OTHERS THEN
142 IF (c%ISOPEN) THEN
143 CLOSE c;
144 END IF;
145
146 IF (l_lock_error) THEN
147 l_retcode := 'WARNING';
148
149 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
150 trace(p_msg => 'END of function pre_merge - Return value = '||l_retcode,
151 p_module => l_log_module,
152 p_level => C_LEVEL_PROCEDURE);
153 END IF;
154
155 xla_aad_loader_util_pvt.stack_error
156 (p_appli_s_name => 'XLA'
157 ,p_msg_name => 'XLA_AAD_MGR_LOCK_FAILED');
158
159 RETURN l_retcode;
160 ELSE
161 xla_aad_loader_util_pvt.stack_error
162 (p_appli_s_name => 'XLA'
163 ,p_msg_name => 'XLA_COMMON_ERROR'
164 ,p_token_1 => 'LOCATION'
165 ,p_value_1 => 'xla_aad_merge_pvt.pre_merge'
166 ,p_token_2 => 'ERROR'
167 ,p_value_2 => 'unhandled exception');
168 RAISE;
169 END IF;
170
171 END pre_merge;
172
173
174 --=============================================================================
175 --
176 -- Name: validation
177 -- Description: This API validate the AADs and components
178 -- Return codes:
179 -- SUCCESS - completed sucessfully
180 -- ERROR - completed with error
181 --
182 --=============================================================================
183 FUNCTION validation
184 RETURN VARCHAR2
185 IS
186
187 CURSOR c_updated IS
188 SELECT 1
189 FROM xla_appli_amb_contexts
190 WHERE amb_context_code = g_amb_context_code
191 AND application_id = g_application_id
192 AND updated_flag = 'N';
193
194 -- Return if any AAD has a higher version in the working area then the
195 -- original version of the one in the staging area
196 CURSOR c_invalid_versions IS
197 SELECT distinct t.name
198 FROM xla_product_rules_b w
199 , xla_product_rules_b s
200 , xla_staging_components_h h
201 , xla_product_rules_tl t
202 WHERE w.version_num > h.version_num
203 AND w.amb_context_code = g_amb_context_code
204 AND w.application_id = g_application_id
205 AND w.product_rule_type_code = s.product_rule_type_code
206 AND w.product_rule_code = s.product_rule_code
207 --
208 AND t.application_id = w.application_id
209 AND t.amb_context_code = w.amb_context_code
210 AND t.product_rule_type_code = w.product_rule_type_code
211 AND t.product_rule_code = w.product_rule_code
212 AND t.language = USERENV('LANG')
213 --
214 AND h.staging_amb_context_code = g_staging_context_code
215 AND h.application_id = g_application_id
216 AND h.component_owner_code = s.product_rule_type_code
217 AND h.component_code = s.product_rule_code
218 AND h.component_type_code = 'AAD'
219 AND h.version_num = s.version_num
220 --
221 AND s.amb_context_code = g_staging_context_code
222 AND s.application_id = g_application_id;
223
224 l_exists INTEGER;
225 l_retcode VARCHAR2(30);
226 l_log_module VARCHAR2(240);
227
228 BEGIN
229 IF g_log_enabled THEN
230 l_log_module := C_DEFAULT_MODULE||'.validation';
231 END IF;
232
233 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
234 trace(p_msg => 'BEGIN of function validation',
235 p_module => l_log_module,
236 p_level => C_LEVEL_PROCEDURE);
237 END IF;
238
239 l_retcode := 'SUCCESS';
240
241 l_retcode := xla_aad_loader_util_pvt.validate_adr_compatibility
242 (p_application_id => g_application_id
243 ,p_amb_context_code => g_amb_context_code
244 ,p_staging_context_code => g_staging_context_code);
245
246 IF (g_analyzed_flag = 'Y') THEN
247
248 -- If merge analysis was run and the AAD/setups are modified since merge
249 -- analysis, return FALSE
250 OPEN c_updated;
251 FETCH c_updated INTO l_exists;
252 IF (c_updated%NOTFOUND) THEN
253 l_retcode := 'WARNING';
254 xla_aad_loader_util_pvt.stack_error
255 (p_appli_s_name => 'XLA'
256 ,p_msg_name => 'XLA_AAD_MER_AMB_UPDATED');
257 END IF;
258 CLOSE c_updated;
259 ELSE
260
261 -- If merge analysis is not run, make sure no AAD has a higher version in
262 -- working area than the original version of the one in the staging area
263 FOR l_err in c_invalid_versions LOOP
264 l_retcode := 'WARNING';
265 xla_aad_loader_util_pvt.stack_error
266 (p_appli_s_name => 'XLA'
267 ,p_msg_name => 'XLA_AAD_MER_INVALID_AAD_VERS'
268 ,p_token_1 => 'PROD_RULE_NAME'
269 ,p_value_1 => l_err.name);
270 END LOOP;
271 END IF;
272
273 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
274 trace(p_msg => 'END of function validation - Return value = '||l_retcode,
275 p_module => l_log_module,
276 p_level => C_LEVEL_PROCEDURE);
277 END IF;
278
279 return l_retcode;
280 EXCEPTION
281 WHEN OTHERS THEN
282 xla_aad_loader_util_pvt.stack_error
283 (p_appli_s_name => 'XLA'
284 ,p_msg_name => 'XLA_COMMON_ERROR'
285 ,p_token_1 => 'LOCATION'
286 ,p_value_1 => 'xla_aad_merge_pvt.validation'
287 ,p_token_2 => 'ERROR'
288 ,p_value_2 => 'Unhandled exception');
289 RAISE;
290
291 END validation;
292
293 --=============================================================================
294 --
295 -- Name: clean_oracle_aads
296 -- Description:
297 --
298 --=============================================================================
299 PROCEDURE clean_oracle_aads
300 IS
301 CURSOR c_all_comps IS
302 SELECT w.product_rule_code, w.version_num
303 FROM xla_product_rules_b w
304 WHERE w.application_id = g_application_id
305 AND w.amb_context_code = g_amb_context_code
306 AND w.product_rule_type_code = C_OWNER_SYSTEM
307 AND NOT EXISTS ( SELECT 1
308 FROM xla_product_rules_b s
309 WHERE s.application_id = g_application_id
310 AND s.amb_context_code = g_staging_context_code
311 AND s.product_rule_type_code = C_OWNER_SYSTEM
312 AND s.product_rule_code = w.product_rule_code);
313
314 l_codes t_array_varchar30;
315 l_version_nums t_array_int;
316
317 l_log_module VARCHAR2(240);
318 l_num_rows INTEGER;
319 BEGIN
320 IF g_log_enabled THEN
321 l_log_module := C_DEFAULT_MODULE||'.clean_oracle_aads';
322 END IF;
323
324 IF (g_analyzed_flag = 'Y') THEN
325 null;
326 ELSE
327 OPEN c_all_comps;
328 FETCH c_all_comps BULK COLLECT INTO l_codes, l_version_nums;
329 CLOSE c_all_comps;
330
331 END IF;
332
333 -- Insert log
334 FORALL i IN 1..l_codes.COUNT
335 INSERT INTO xla_aad_loader_logs
336 (aad_loader_log_id
337 ,amb_context_code
338 ,application_id
339 ,request_code
340 ,log_type_code
341 ,aad_application_id
342 ,product_rule_code
343 ,product_rule_type_code
344 ,version_to
345 ,object_version_number
346 ,creation_date
347 ,created_by
348 ,last_update_date
349 ,last_updated_by
350 ,last_update_login
351 ,program_update_date
352 ,program_application_id
353 ,program_id
354 ,request_id)
355 VALUES
356 (xla_aad_loader_logs_s.nextval
357 ,g_amb_context_code
358 ,g_application_id
359 ,'IMPORT'
360 ,'DELETED_AAD'
361 ,g_application_id
362 ,l_codes(i)
363 ,C_OWNER_SYSTEM
364 ,l_version_nums(i)
365 ,1
366 ,sysdate
367 ,xla_environment_pkg.g_usr_id
368 ,sysdate
369 ,xla_environment_pkg.g_usr_id
370 ,xla_environment_pkg.g_login_id
371 ,sysdate
372 ,xla_environment_pkg.g_prog_appl_id
373 ,xla_environment_pkg.g_prog_id
374 ,xla_environment_pkg.g_req_Id);
375
376 -- Delete JLD aasignment that is no longer assigned to the header
377 DELETE FROM xla_aad_line_defn_assgns w
378 WHERE application_id = g_application_id
379 AND amb_context_code = g_amb_context_code
380 AND product_rule_type_code = C_OWNER_SYSTEM
381 AND NOT EXISTS
382 (SELECT 1
383 FROM xla_aad_line_defn_assgns s
384 WHERE s.application_id = g_application_id
385 AND s.amb_context_code = g_staging_context_code
386 AND s.product_rule_type_code = C_OWNER_SYSTEM
387 AND s.product_rule_code = w.product_rule_code
388 AND s.event_class_code = w.event_class_code
389 AND s.event_type_code = w.event_type_code
390 AND s.line_definition_owner_code = w.line_definition_owner_code
391 AND s.line_definition_code = w.line_definition_code);
392
393 l_num_rows := SQL%ROWCOUNT;
394
395 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
396 trace(p_msg => '# xla_aad_line_defn_assgns deleted = '||l_num_rows,
397 p_module => l_log_module,
398 p_level => C_LEVEL_STATEMENT);
399 END IF;
400 -- Bug : 9923803
401 -- API Call to Insert messages into AAD Loader Log Table.
402 xla_aad_loader_util_pvt.insert_aadloaderlog(
403 p_amb_context_code => g_amb_context_code,
404 p_application_id => g_application_id,
405 p_request_code => 'IMPORT' ,
406 p_log_type_code => 'MERGE',
407 p_encoded_message => '# xla_aad_line_defn_assgns deleted = '||l_num_rows,
408 p_component_code => 'clean_oracle_aads');
409
410 -- Delete AC assignment that is no longer assigned to the header
411 DELETE FROM xla_aad_header_ac_assgns w
412 WHERE application_id = g_application_id
413 AND amb_context_code = g_amb_context_code
414 AND product_rule_type_code = C_OWNER_SYSTEM
415 AND NOT EXISTS
416 (SELECT 1
417 FROM xla_aad_header_ac_assgns s
418 WHERE s.application_id = g_application_id
419 AND s.amb_context_code = g_staging_context_code
420 AND s.product_rule_type_code = C_OWNER_SYSTEM
421 AND s.product_rule_code = w.product_rule_code
422 AND s.event_class_code = w.event_class_code
423 AND s.event_type_code = w.event_type_code
424 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
425 AND s.analytical_criterion_code = w.analytical_criterion_code);
426
427 l_num_rows := SQL%ROWCOUNT;
428 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
429 trace(p_msg => '# xla_aad_header_ac_assgns deleted = '||l_num_rows,
430 p_module => l_log_module,
431 p_level => C_LEVEL_STATEMENT);
432 END IF;
433
434 -- Bug : 9923803
435 -- API Call to Insert messages into AAD Loader Log Table.
436 xla_aad_loader_util_pvt.insert_aadloaderlog(
437 p_amb_context_code => g_amb_context_code,
438 p_application_id => g_application_id,
439 p_request_code => 'IMPORT' ,
440 p_log_type_code => 'MERGE',
441 p_encoded_message => '# xla_aad_header_ac_assgns deleted = '||l_num_rows,
442 p_component_code => 'clean_oracle_aads');
443
444 DELETE FROM xla_aad_hdr_acct_attrs w
445 WHERE application_id = g_application_id
446 AND amb_context_code = g_amb_context_code
447 AND product_rule_type_code = C_OWNER_SYSTEM
448 AND NOT EXISTS
449 (SELECT 1
450 FROM xla_aad_hdr_acct_attrs s
451 WHERE s.application_id = g_application_id
452 AND s.amb_context_code = g_staging_context_code
453 AND s.product_rule_type_code = C_OWNER_SYSTEM
454 AND s.product_rule_code = w.product_rule_code
455 AND s.event_class_code = w.event_class_code
456 AND s.event_type_code = w.event_type_code
457 AND s.accounting_attribute_code = w.accounting_attribute_code);
458 l_num_rows := SQL%ROWCOUNT;
459
460 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
461 trace(p_msg => '# xla_aad_hdr_acct_attrs deleted = '||l_num_rows,
462 p_module => l_log_module,
463 p_level => C_LEVEL_STATEMENT);
464 END IF;
465
466 -- Bug : 9923803
467 -- API Call to Insert messages into AAD Loader Log Table.
468 xla_aad_loader_util_pvt.insert_aadloaderlog(
469 p_amb_context_code => g_amb_context_code,
470 p_application_id => g_application_id,
471 p_request_code => 'IMPORT' ,
472 p_log_type_code => 'MERGE',
473 p_encoded_message => '# xla_aad_hdr_acct_attrs deleted = '||l_num_rows,
474 p_component_code => 'clean_oracle_aads');
475
476 DELETE FROM xla_prod_acct_headers w
477 WHERE application_id = g_application_id
478 AND amb_context_code = g_amb_context_code
479 AND product_rule_type_code = C_OWNER_SYSTEM
480 AND NOT EXISTS
481 (SELECT 1
482 FROM xla_prod_acct_headers s
483 WHERE s.application_id = g_application_id
484 AND s.amb_context_code = g_staging_context_code
485 AND s.product_rule_type_code = C_OWNER_SYSTEM
486 AND s.product_rule_code = w.product_rule_code
487 AND s.event_class_code = w.event_class_code
488 AND s.event_type_code = w.event_type_code);
489 l_num_rows := SQL%ROWCOUNT;
490 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
491 trace(p_msg => '# xla_prod_acct_headers deleted = '||l_num_rows,
492 p_module => l_log_module,
493 p_level => C_LEVEL_STATEMENT);
494 END IF;
495 -- Bug : 9923803
496 -- API Call to Insert messages into AAD Loader Log Table.
497 xla_aad_loader_util_pvt.insert_aadloaderlog(
498 p_amb_context_code => g_amb_context_code,
499 p_application_id => g_application_id,
500 p_request_code => 'IMPORT' ,
501 p_log_type_code => 'MERGE',
502 p_encoded_message => '# xla_prod_acct_headers deleted = '||l_num_rows,
503 p_component_code => 'clean_oracle_aads');
504
505 -- Delete AAD that is not in the staging area
506 FORALL i IN 1..l_codes.COUNT
507 DELETE FROM xla_product_rules_tl w
508 WHERE application_id = g_application_id
509 AND amb_context_code = g_amb_context_code
510 AND product_rule_type_code = C_OWNER_SYSTEM
511 AND product_rule_code = l_codes(i);
512 l_num_rows := SQL%ROWCOUNT;
513 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
514 trace(p_msg => '# xla_product_rules_tl deleted = '||l_num_rows,
515 p_module => l_log_module,
516 p_level => C_LEVEL_STATEMENT);
517 END IF;
518 -- Bug : 9923803
519 -- API Call to Insert messages into AAD Loader Log Table.
520 xla_aad_loader_util_pvt.insert_aadloaderlog(
521 p_amb_context_code => g_amb_context_code,
522 p_application_id => g_application_id,
523 p_request_code => 'IMPORT' ,
524 p_log_type_code => 'MERGE',
525 p_encoded_message => '# xla_product_rules_tl deleted = '||l_num_rows,
526 p_component_code => 'clean_oracle_aads');
527
528 FORALL i IN 1..l_codes.COUNT
529 DELETE FROM xla_product_rules_b w
530 WHERE application_id = g_application_id
531 AND amb_context_code = g_amb_context_code
532 AND product_rule_type_code = C_OWNER_SYSTEM
533 AND product_rule_code = l_codes(i);
534 l_num_rows := SQL%ROWCOUNT;
535 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
536 trace(p_msg => '# xla_product_rules_b deleted = '||l_num_rows,
537 p_module => l_log_module,
538 p_level => C_LEVEL_STATEMENT);
539 END IF;
540 -- Bug : 9923803
541 -- API Call to Insert messages into AAD Loader Log Table.
542 xla_aad_loader_util_pvt.insert_aadloaderlog(
543 p_amb_context_code => g_amb_context_code,
544 p_application_id => g_application_id,
545 p_request_code => 'IMPORT' ,
546 p_log_type_code => 'MERGE',
547 p_encoded_message => '# xla_product_rules_b deleted = '||l_num_rows,
548 p_component_code => 'clean_oracle_aads');
549 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
550 trace(p_msg => 'BEGIN of procedure clean_oracle_aads',
551 p_module => l_log_module,
552 p_level => C_LEVEL_PROCEDURE);
553 END IF;
554
555 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
556 trace(p_msg => 'END of procedure clean_oracle_aads',
557 p_module => l_log_module,
558 p_level => C_LEVEL_PROCEDURE);
559 END IF;
560
561 EXCEPTION
562 WHEN OTHERS THEN
563 xla_aad_loader_util_pvt.stack_error
564 (p_appli_s_name => 'XLA'
565 ,p_msg_name => 'XLA_COMMON_ERROR'
566 ,p_token_1 => 'LOCATION'
567 ,p_value_1 => 'xla_aad_merge_pvt.clean_oracle_aads'
568 ,p_token_2 => 'ERROR'
569 ,p_value_2 => 'unhandled exception');
570 RAISE;
571
572 END clean_oracle_aads;
573
574
575 --=============================================================================
576 --
577 -- Name: clean_oracle_jlds
578 -- Description:
579 --
580 --=============================================================================
581 PROCEDURE clean_oracle_jlds
582 IS
583 CURSOR c_all_comps IS
584 SELECT w.event_class_code
585 , w.event_type_code
586 , w.line_definition_code
587 FROM xla_line_definitions_b w
588 WHERE w.application_id = g_application_id
589 AND w.amb_context_code = g_amb_context_code
590 AND w.line_definition_owner_code = C_OWNER_SYSTEM
591 AND NOT EXISTS ( SELECT 1
592 FROM xla_line_definitions_b s
593 WHERE s.application_id = g_application_id
594 AND s.amb_context_code = g_staging_context_code
595 AND s.event_class_code = w.event_class_code
596 AND s.event_type_code = w.event_type_code
597 AND s.line_definition_owner_code = C_OWNER_SYSTEM
598 AND s.line_definition_code = w.line_definition_code);
599
600 l_event_class_codes t_array_varchar30;
601 l_event_type_codes t_array_varchar30;
602 l_codes t_array_varchar30;
603
604 l_log_module VARCHAR2(240);
605 l_num_rows INTEGER;
606 BEGIN
607 IF g_log_enabled THEN
608 l_log_module := C_DEFAULT_MODULE||'.clean_oracle_jlds';
609 END IF;
610
611 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
612 trace(p_msg => 'BEGIN of procedure clean_oracle_jlds',
613 p_module => l_log_module,
614 p_level => C_LEVEL_PROCEDURE);
615 END IF;
616
617 IF (g_analyzed_flag = 'Y') THEN
618 null;
619 ELSE
620 OPEN c_all_comps;
621 FETCH c_all_comps BULK COLLECT INTO l_event_class_codes
622 , l_event_type_codes
623 , l_codes;
624 CLOSE c_all_comps;
625
626 END IF;
627
628 -- Delete JLD assignment for those JLD no longer exist
629 FORALL i IN 1..l_codes.COUNT
630 DELETE FROM xla_aad_line_defn_assgns w
631 WHERE application_id = g_application_id
632 AND amb_context_code = g_amb_context_code
633 AND event_class_code = l_event_class_codes(i)
634 AND event_type_code = l_event_type_codes(i)
635 AND line_definition_owner_code = C_OWNER_SYSTEM
636 AND line_definition_code = l_codes(i);
637 l_num_rows := SQL%ROWCOUNT;
638 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
639 trace(p_msg => '# xla_aad_line_defn_assgns deleted = '||l_num_rows,
640 p_module => l_log_module,
641 p_level => C_LEVEL_STATEMENT);
642 END IF;
643 -- Bug : 9923803
644 -- API Call to Insert messages into AAD Loader Log Table.
645 xla_aad_loader_util_pvt.insert_aadloaderlog(
646 p_amb_context_code => g_amb_context_code,
647 p_application_id => g_application_id,
648 p_request_code => 'IMPORT' ,
649 p_log_type_code => 'MERGE',
650 p_encoded_message => '# xla_aad_line_defn_assgns deleted = '||l_num_rows,
651 p_component_code => 'clean_oracle_jlds');
652
653 DELETE FROM xla_line_defn_ac_assgns w
654 WHERE application_id = g_application_id
655 AND amb_context_code = g_amb_context_code
656 AND line_definition_owner_code = C_OWNER_SYSTEM
657 AND NOT EXISTS
658 (SELECT 1
659 FROM xla_line_defn_ac_assgns s
660 WHERE s.application_id = g_application_id
661 AND s.amb_context_code = g_staging_context_code
662 AND s.event_class_code = w.event_class_code
663 AND s.event_type_code = w.event_type_code
664 AND s.line_definition_owner_code = C_OWNER_SYSTEM
665 AND s.line_definition_code = w.line_definition_code
666 AND s.accounting_line_type_code = w.accounting_line_type_code
667 AND s.accounting_line_code = w.accounting_line_code
668 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
669 AND s.analytical_criterion_code = w.analytical_criterion_code);
670 l_num_rows := SQL%ROWCOUNT;
671 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
672 trace(p_msg => '# xla_line_defn_ac_assgns deleted = '||l_num_rows,
673 p_module => l_log_module,
674 p_level => C_LEVEL_STATEMENT);
675 END IF;
676 -- Bug : 9923803
677 -- API Call to Insert messages into AAD Loader Log Table.
678 xla_aad_loader_util_pvt.insert_aadloaderlog(
679 p_amb_context_code => g_amb_context_code,
680 p_application_id => g_application_id,
681 p_request_code => 'IMPORT' ,
682 p_log_type_code => 'MERGE',
683 p_encoded_message => '# xla_line_defn_ac_assgns deleted = '||l_num_rows,
684 p_component_code => 'clean_oracle_jlds');
685
686 DELETE FROM xla_line_defn_adr_assgns w
687 WHERE application_id = g_application_id
688 AND amb_context_code = g_amb_context_code
689 AND line_definition_owner_code = C_OWNER_SYSTEM
690 AND NOT EXISTS
691 (SELECT 1
692 FROM xla_line_defn_adr_assgns s
693 WHERE s.application_id = g_application_id
694 AND s.amb_context_code = g_staging_context_code
695 AND s.event_class_code = w.event_class_code
696 AND s.event_type_code = w.event_type_code
697 AND s.line_definition_owner_code = C_OWNER_SYSTEM
698 AND s.line_definition_code = w.line_definition_code
699 AND s.accounting_line_type_code = w.accounting_line_type_code
700 AND s.accounting_line_code = w.accounting_line_code
701 AND s.flexfield_segment_code = w.flexfield_segment_code);
702 l_num_rows := SQL%ROWCOUNT;
703 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
704 trace(p_msg => '# xla_line_defn_adr_assgns deleted = '||l_num_rows,
705 p_module => l_log_module,
706 p_level => C_LEVEL_STATEMENT);
707 END IF;
708 -- Bug : 9923803
709 -- API Call to Insert messages into AAD Loader Log Table.
710 xla_aad_loader_util_pvt.insert_aadloaderlog(
711 p_amb_context_code => g_amb_context_code,
712 p_application_id => g_application_id,
713 p_request_code => 'IMPORT' ,
714 p_log_type_code => 'MERGE',
715 p_encoded_message => '# xla_line_defn_adr_assgns deleted = '||l_num_rows,
716 p_component_code => 'clean_oracle_jlds');
717
718 DELETE FROM xla_line_defn_jlt_assgns w
719 WHERE application_id = g_application_id
720 AND amb_context_code = g_amb_context_code
721 AND line_definition_owner_code = C_OWNER_SYSTEM
722 AND NOT EXISTS
723 (SELECT 1
724 FROM xla_line_defn_jlt_assgns s
725 WHERE s.application_id = g_application_id
726 AND s.amb_context_code = g_staging_context_code
727 AND s.event_class_code = w.event_class_code
728 AND s.event_type_code = w.event_type_code
729 AND s.line_definition_owner_code = C_OWNER_SYSTEM
730 AND s.line_definition_code = w.line_definition_code
731 AND s.accounting_line_type_code = w.accounting_line_type_code
732 AND s.accounting_line_code = w.accounting_line_code);
733 l_num_rows := SQL%ROWCOUNT;
734 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
735 trace(p_msg => '# xla_line_defn_jlt_assgns deleted = '||l_num_rows,
736 p_module => l_log_module,
737 p_level => C_LEVEL_STATEMENT);
738 END IF;
739 -- Bug : 9923803
740 -- API Call to Insert messages into AAD Loader Log Table.
741 xla_aad_loader_util_pvt.insert_aadloaderlog(
742 p_amb_context_code => g_amb_context_code,
743 p_application_id => g_application_id,
744 p_request_code => 'IMPORT' ,
745 p_log_type_code => 'MERGE',
746 p_encoded_message => '# xla_line_defn_jlt_assgns deleted = '||l_num_rows,
747 p_component_code => 'clean_oracle_jlds');
748 DELETE FROM xla_mpa_jlt_assgns w
749 WHERE application_id = g_application_id
750 AND amb_context_code = g_amb_context_code
751 AND line_definition_owner_code = C_OWNER_SYSTEM
752 AND NOT EXISTS
753 (SELECT 1
754 FROM xla_mpa_jlt_assgns s
755 WHERE s.application_id = g_application_id
756 AND s.amb_context_code = g_staging_context_code
757 AND s.event_class_code = w.event_class_code
758 AND s.event_type_code = w.event_type_code
759 AND s.line_definition_owner_code = C_OWNER_SYSTEM
760 AND s.line_definition_code = w.line_definition_code
761 AND s.accounting_line_type_code = w.accounting_line_type_code
762 AND s.accounting_line_code = w.accounting_line_code
763 AND s.mpa_accounting_line_type_code = w.mpa_accounting_line_type_code
764 AND s.mpa_accounting_line_code = w.mpa_accounting_line_code);
765 l_num_rows := SQL%ROWCOUNT;
766 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
767 trace(p_msg => '# xla_mpa_jlt_assgns deleted = '||l_num_rows,
768 p_module => l_log_module,
769 p_level => C_LEVEL_STATEMENT);
770 END IF;
771 -- Bug : 9923803
772 -- API Call to Insert messages into AAD Loader Log Table.
773 xla_aad_loader_util_pvt.insert_aadloaderlog(
774 p_amb_context_code => g_amb_context_code,
775 p_application_id => g_application_id,
776 p_request_code => 'IMPORT' ,
777 p_log_type_code => 'MERGE',
778 p_encoded_message => '# xla_mpa_jlt_assgns deleted = '||l_num_rows,
779 p_component_code => 'clean_oracle_jlds');
780 DELETE FROM xla_mpa_header_ac_assgns w
781 WHERE application_id = g_application_id
782 AND amb_context_code = g_amb_context_code
783 AND line_definition_owner_code = C_OWNER_SYSTEM
784 AND NOT EXISTS
785 (SELECT 1
786 FROM xla_mpa_header_ac_assgns s
787 WHERE s.application_id = g_application_id
788 AND s.amb_context_code = g_staging_context_code
789 AND s.event_class_code = w.event_class_code
790 AND s.event_type_code = w.event_type_code
791 AND s.line_definition_owner_code = C_OWNER_SYSTEM
792 AND s.line_definition_code = w.line_definition_code
793 AND s.accounting_line_type_code = w.accounting_line_type_code
794 AND s.accounting_line_code = w.accounting_line_code
795 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
796 AND s.analytical_criterion_code = w.analytical_criterion_code);
797 l_num_rows:= SQL%ROWCOUNT;
798 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
799 trace(p_msg => '# xla_mpa_header_ac_assgns deleted = '||l_num_rows,
800 p_module => l_log_module,
801 p_level => C_LEVEL_STATEMENT);
802 END IF;
803 -- Bug : 9923803
804 -- API Call to Insert messages into AAD Loader Log Table.
805 xla_aad_loader_util_pvt.insert_aadloaderlog(
806 p_amb_context_code => g_amb_context_code,
807 p_application_id => g_application_id,
808 p_request_code => 'IMPORT' ,
809 p_log_type_code => 'MERGE',
810 p_encoded_message => '# xla_mpa_header_ac_assgns deleted = '||l_num_rows,
811 p_component_code => 'clean_oracle_jlds');
812
813 DELETE FROM xla_mpa_jlt_adr_assgns w
814 WHERE application_id = g_application_id
815 AND amb_context_code = g_amb_context_code
816 AND line_definition_owner_code = C_OWNER_SYSTEM
817 AND NOT EXISTS
818 (SELECT 1
819 FROM xla_mpa_jlt_adr_assgns s
820 WHERE s.application_id = g_application_id
821 AND s.amb_context_code = g_staging_context_code
822 AND s.event_class_code = w.event_class_code
823 AND s.event_type_code = w.event_type_code
824 AND s.line_definition_owner_code = C_OWNER_SYSTEM
825 AND s.line_definition_code = w.line_definition_code
826 AND s.accounting_line_type_code = w.accounting_line_type_code
827 AND s.accounting_line_code = w.accounting_line_code
828 AND s.mpa_accounting_line_type_code = w.mpa_accounting_line_type_code
829 AND s.mpa_accounting_line_code = w.mpa_accounting_line_code
830 AND s.flexfield_segment_code = w.flexfield_segment_code);
831 l_num_rows:= SQL%ROWCOUNT;
832 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
833 trace(p_msg => '# xla_mpa_jlt_adr_assgns deleted = '||l_num_rows,
834 p_module => l_log_module,
835 p_level => C_LEVEL_STATEMENT);
836 END IF;
837 -- Bug : 9923803
838 -- API Call to Insert messages into AAD Loader Log Table.
839 xla_aad_loader_util_pvt.insert_aadloaderlog(
840 p_amb_context_code => g_amb_context_code,
841 p_application_id => g_application_id,
842 p_request_code => 'IMPORT' ,
843 p_log_type_code => 'MERGE',
844 p_encoded_message => '# xla_mpa_jlt_adr_assgns deleted = '||l_num_rows,
845 p_component_code => 'clean_oracle_jlds');
846
847 DELETE FROM xla_mpa_jlt_ac_assgns w
848 WHERE application_id = g_application_id
849 AND amb_context_code = g_amb_context_code
850 AND line_definition_owner_code = C_OWNER_SYSTEM
851 AND NOT EXISTS
852 (SELECT 1
853 FROM xla_mpa_jlt_ac_assgns s
854 WHERE s.application_id = g_application_id
855 AND s.amb_context_code = g_staging_context_code
856 AND s.event_class_code = w.event_class_code
857 AND s.event_type_code = w.event_type_code
858 AND s.line_definition_owner_code = C_OWNER_SYSTEM
859 AND s.line_definition_code = w.line_definition_code
860 AND s.accounting_line_type_code = w.accounting_line_type_code
861 AND s.accounting_line_code = w.accounting_line_code
862 AND s.mpa_accounting_line_type_code = w.mpa_accounting_line_type_code
863 AND s.mpa_accounting_line_code = w.mpa_accounting_line_code
864 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
865 AND s.analytical_criterion_code = w.analytical_criterion_code);
866 l_num_rows:= SQL%ROWCOUNT;
867 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
868 trace(p_msg => '# xla_mpa_jlt_ac_assgns deleted = '||l_num_rows,
869 p_module => l_log_module,
870 p_level => C_LEVEL_STATEMENT);
871 END IF;
872 -- Bug : 9923803
873 -- API Call to Insert messages into AAD Loader Log Table.
874 xla_aad_loader_util_pvt.insert_aadloaderlog(
875 p_amb_context_code => g_amb_context_code,
876 p_application_id => g_application_id,
877 p_request_code => 'IMPORT' ,
878 p_log_type_code => 'MERGE',
879 p_encoded_message => '# xla_mpa_jlt_ac_assgns deleted = '||l_num_rows,
880 p_component_code => 'clean_oracle_jlds');
881 FORALL i IN 1..l_codes.COUNT
882 DELETE FROM xla_line_definitions_tl w
883 WHERE application_id = g_application_id
884 AND amb_context_code = g_amb_context_code
885 AND event_class_code = l_event_class_codes(i)
886 AND event_type_code = l_event_type_codes(i)
887 AND line_definition_owner_code = C_OWNER_SYSTEM
888 AND line_definition_code = l_codes(i);
889 l_num_rows:= SQL%ROWCOUNT;
890 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
891 trace(p_msg => '# xla_line_definitions_tl deleted = '||l_num_rows,
892 p_module => l_log_module,
893 p_level => C_LEVEL_STATEMENT);
894 END IF;
895 -- Bug : 9923803
896 -- API Call to Insert messages into AAD Loader Log Table.
897 xla_aad_loader_util_pvt.insert_aadloaderlog(
898 p_amb_context_code => g_amb_context_code,
899 p_application_id => g_application_id,
900 p_request_code => 'IMPORT' ,
901 p_log_type_code => 'MERGE',
902 p_encoded_message => '# xla_line_definitions_tl deleted = '||l_num_rows,
903 p_component_code => 'clean_oracle_jlds');
904
905 FORALL i IN 1..l_codes.COUNT
906 DELETE FROM xla_line_definitions_b w
907 WHERE application_id = g_application_id
908 AND amb_context_code = g_amb_context_code
909 AND event_class_code = l_event_class_codes(i)
910 AND event_type_code = l_event_type_codes(i)
911 AND line_definition_owner_code = C_OWNER_SYSTEM
912 AND line_definition_code = l_codes(i);
913 l_num_rows:= SQL%ROWCOUNT;
914 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
915 trace(p_msg => '# xla_line_definitions_b deleted = '||l_num_rows,
916 p_module => l_log_module,
917 p_level => C_LEVEL_STATEMENT);
918 END IF;
919 -- Bug : 9923803
920 -- API Call to Insert messages into AAD Loader Log Table.
921 xla_aad_loader_util_pvt.insert_aadloaderlog(
922 p_amb_context_code => g_amb_context_code,
923 p_application_id => g_application_id,
924 p_request_code => 'IMPORT' ,
925 p_log_type_code => 'MERGE',
926 p_encoded_message => '# xla_line_definitions_b deleted = '||l_num_rows,
927 p_component_code => 'clean_oracle_jlds');
928
929 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
930 trace(p_msg => 'END of procedure clean_oracle_jlds',
931 p_module => l_log_module,
932 p_level => C_LEVEL_PROCEDURE);
933 END IF;
934
935 EXCEPTION
936 WHEN OTHERS THEN
937 xla_aad_loader_util_pvt.stack_error
938 (p_appli_s_name => 'XLA'
939 ,p_msg_name => 'XLA_COMMON_ERROR'
940 ,p_token_1 => 'LOCATION'
941 ,p_value_1 => 'xla_aad_merge_pvt.clean_oracle_jlds'
942 ,p_token_2 => 'ERROR'
943 ,p_value_2 => 'unhandled exception');
944 RAISE;
945
946 END clean_oracle_jlds;
947
948
949 --=============================================================================
950 --
951 -- Name: clean_oracle_jlts
952 -- Description:
953 --
954 --=============================================================================
955 PROCEDURE clean_oracle_jlts
956 IS
957 CURSOR c_all_comps IS
958 SELECT work.event_class_code
959 , work.accounting_line_code
960 FROM xla_acct_line_types_b work
961 WHERE work.application_id = g_application_id
962 AND work.amb_context_code = g_amb_context_code
963 AND work.accounting_line_type_code = C_OWNER_SYSTEM
964 AND NOT EXISTS ( SELECT 1
965 FROM xla_acct_line_types_b stage
966 WHERE stage.application_id = g_application_id
967 AND stage.amb_context_code = g_staging_context_code
968 AND stage.event_class_code = work.event_class_code
969 AND stage.accounting_line_type_code = C_OWNER_SYSTEM
970 AND stage.accounting_line_code = work.accounting_line_code);
971
972 l_event_class_codes t_array_varchar30;
973 l_codes t_array_varchar30;
974
975 l_log_module VARCHAR2(240);
976 l_num_rows INTEGER;
977 BEGIN
978 IF g_log_enabled THEN
979 l_log_module := C_DEFAULT_MODULE||'.clean_oracle_jlts';
980 END IF;
981
982 IF (g_analyzed_flag = 'Y') THEN
983 null;
984 ELSE
985 OPEN c_all_comps;
986 FETCH c_all_comps BULK COLLECT INTO l_event_class_codes
987 , l_codes;
988 CLOSE c_all_comps;
989
990 END IF;
991
992 IF (l_codes.COUNT > 0) THEN
993
994 FORALL i IN 1..l_codes.COUNT
995 DELETE FROM xla_mpa_jlt_adr_assgns w
996 WHERE application_id = g_application_id
997 AND amb_context_code = g_amb_context_code
998 AND event_class_code = l_event_class_codes(i)
999 AND accounting_line_type_code = C_OWNER_SYSTEM
1000 AND accounting_line_code = l_codes(i);
1001 l_num_rows := SQL%ROWCOUNT;
1002 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1003 trace(p_msg => '# xla_mpa_jlt_adr_assgns deleted = '||l_num_rows,
1004 p_module => l_log_module,
1005 p_level => C_LEVEL_STATEMENT);
1006 END IF;
1007 -- Bug : 9923803
1008 -- API Call to Insert messages into AAD Loader Log Table.
1009 xla_aad_loader_util_pvt.insert_aadloaderlog(
1010 p_amb_context_code => g_amb_context_code,
1011 p_application_id => g_application_id,
1012 p_request_code => 'IMPORT' ,
1013 p_log_type_code => 'MERGE',
1014 p_encoded_message => '# xla_mpa_jlt_adr_assgns deleted = '||l_num_rows,
1015 p_component_code => 'clean_oracle_jlts');
1016
1017 FORALL i IN 1..l_codes.COUNT
1018 DELETE FROM xla_mpa_jlt_ac_assgns w
1019 WHERE application_id = g_application_id
1020 AND amb_context_code = g_amb_context_code
1021 AND event_class_code = l_event_class_codes(i)
1022 AND accounting_line_type_code = C_OWNER_SYSTEM
1023 AND accounting_line_code = l_codes(i);
1024 l_num_rows := SQL%ROWCOUNT;
1025 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1026 trace(p_msg => '# xla_mpa_jlt_ac_assgns deleted = '||l_num_rows,
1027 p_module => l_log_module,
1028 p_level => C_LEVEL_STATEMENT);
1029 END IF;
1030 -- Bug : 9923803
1031 -- API Call to Insert messages into AAD Loader Log Table.
1032 xla_aad_loader_util_pvt.insert_aadloaderlog(
1033 p_amb_context_code => g_amb_context_code,
1034 p_application_id => g_application_id,
1035 p_request_code => 'IMPORT' ,
1036 p_log_type_code => 'MERGE',
1037 p_encoded_message => '# xla_mpa_jlt_ac_assgns deleted = '||l_num_rows,
1038 p_component_code => 'clean_oracle_jlts');
1039 FORALL i IN 1..l_codes.COUNT
1040 DELETE FROM xla_mpa_header_ac_assgns w
1041 WHERE application_id = g_application_id
1042 AND amb_context_code = g_amb_context_code
1043 AND event_class_code = l_event_class_codes(i)
1044 AND accounting_line_type_code = C_OWNER_SYSTEM
1045 AND accounting_line_code = l_codes(i);
1046 l_num_rows := SQL%ROWCOUNT;
1047 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1048 trace(p_msg => '# xla_mpa_header_ac_assgns deleted = '||l_num_rows,
1049 p_module => l_log_module,
1050 p_level => C_LEVEL_STATEMENT);
1051 END IF;
1052 -- Bug : 9923803
1053 -- API Call to Insert messages into AAD Loader Log Table.
1054 xla_aad_loader_util_pvt.insert_aadloaderlog(
1055 p_amb_context_code => g_amb_context_code,
1056 p_application_id => g_application_id,
1057 p_request_code => 'IMPORT' ,
1058 p_log_type_code => 'MERGE',
1059 p_encoded_message => '# xla_mpa_header_ac_assgns deleted = '||l_num_rows,
1060 p_component_code => 'clean_oracle_jlts');
1061
1062 FORALL i IN 1..l_codes.COUNT
1063 DELETE FROM xla_mpa_jlt_assgns w
1064 WHERE application_id = g_application_id
1065 AND amb_context_code = g_amb_context_code
1066 AND event_class_code = l_event_class_codes(i)
1067 AND accounting_line_type_code = C_OWNER_SYSTEM
1068 AND accounting_line_code = l_codes(i);
1069 l_num_rows := SQL%ROWCOUNT;
1070 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1071 trace(p_msg => '# xla_mpa_jlt_assgns deleted = '||l_num_rows,
1072 p_module => l_log_module,
1073 p_level => C_LEVEL_STATEMENT);
1074 END IF;
1075 -- Bug : 9923803
1076 -- API Call to Insert messages into AAD Loader Log Table.
1077 xla_aad_loader_util_pvt.insert_aadloaderlog(
1078 p_amb_context_code => g_amb_context_code,
1079 p_application_id => g_application_id,
1080 p_request_code => 'IMPORT' ,
1081 p_log_type_code => 'MERGE',
1082 p_encoded_message => '# xla_mpa_jlt_assgns deleted = '||l_num_rows,
1083 p_component_code => 'clean_oracle_jlts');
1084 FORALL i IN 1..l_codes.COUNT
1085 DELETE FROM xla_line_defn_adr_assgns w
1086 WHERE application_id = g_application_id
1087 AND amb_context_code = g_amb_context_code
1088 AND event_class_code = l_event_class_codes(i)
1089 AND accounting_line_type_code = C_OWNER_SYSTEM
1090 AND accounting_line_code = l_codes(i);
1091 l_num_rows := SQL%ROWCOUNT;
1092 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1093 trace(p_msg => '# xla_line_defn_adr_assgns deleted = '||l_num_rows,
1094 p_module => l_log_module,
1095 p_level => C_LEVEL_STATEMENT);
1096 END IF;
1097 -- Bug : 9923803
1098 -- API Call to Insert messages into AAD Loader Log Table.
1099 xla_aad_loader_util_pvt.insert_aadloaderlog(
1100 p_amb_context_code => g_amb_context_code,
1101 p_application_id => g_application_id,
1102 p_request_code => 'IMPORT' ,
1103 p_log_type_code => 'MERGE',
1104 p_encoded_message => '# xla_line_defn_adr_assgns deleted = '||l_num_rows,
1105 p_component_code => 'clean_oracle_jlts');
1106 FORALL i IN 1..l_codes.COUNT
1107 DELETE FROM xla_line_defn_ac_assgns w
1108 WHERE application_id = g_application_id
1109 AND amb_context_code = g_amb_context_code
1110 AND event_class_code = l_event_class_codes(i)
1111 AND accounting_line_type_code = C_OWNER_SYSTEM
1112 AND accounting_line_code = l_codes(i);
1113 l_num_rows := SQL%ROWCOUNT;
1114 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1115 trace(p_msg => '# xla_line_defn_ac_assgns deleted = '||l_num_rows,
1116 p_module => l_log_module,
1117 p_level => C_LEVEL_STATEMENT);
1118 END IF;
1119 -- Bug : 9923803
1120 -- API Call to Insert messages into AAD Loader Log Table.
1121 xla_aad_loader_util_pvt.insert_aadloaderlog(
1122 p_amb_context_code => g_amb_context_code,
1123 p_application_id => g_application_id,
1124 p_request_code => 'IMPORT' ,
1125 p_log_type_code => 'MERGE',
1126 p_encoded_message => '# xla_line_defn_ac_assgns deleted = '||l_num_rows,
1127 p_component_code => 'clean_oracle_jlts');
1128
1129 FORALL i IN 1..l_codes.COUNT
1130 DELETE FROM xla_line_defn_jlt_assgns w
1131 WHERE application_id = g_application_id
1132 AND amb_context_code = g_amb_context_code
1133 AND event_class_code = l_event_class_codes(i)
1134 AND accounting_line_type_code = C_OWNER_SYSTEM
1135 AND accounting_line_code = l_codes(i);
1136 l_num_rows := SQL%ROWCOUNT;
1137 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1138 trace(p_msg => '# xla_line_defn_jlt_assgns deleted = '||l_num_rows,
1139 p_module => l_log_module,
1140 p_level => C_LEVEL_STATEMENT);
1141 END IF;
1142 -- Bug : 9923803
1143 -- API Call to Insert messages into AAD Loader Log Table.
1144 xla_aad_loader_util_pvt.insert_aadloaderlog(
1145 p_amb_context_code => g_amb_context_code,
1146 p_application_id => g_application_id,
1147 p_request_code => 'IMPORT' ,
1148 p_log_type_code => 'MERGE',
1149 p_encoded_message => '# xla_line_defn_jlt_assgns deleted = '||l_num_rows,
1150 p_component_code => 'clean_oracle_jlts');
1151
1152 FORALL i IN 1..l_codes.COUNT
1153 DELETE FROM xla_jlt_acct_attrs w
1154 WHERE application_id = g_application_id
1155 AND amb_context_code = g_amb_context_code
1156 AND event_class_code = l_event_class_codes(i)
1157 AND accounting_line_type_code = C_OWNER_SYSTEM
1158 AND accounting_line_code = l_codes(i);
1159 l_num_rows := SQL%ROWCOUNT;
1160
1161 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1162 trace(p_msg => '# xla_jlt_acct_attrs deleted = '||l_num_rows,
1163 p_module => l_log_module,
1164 p_level => C_LEVEL_STATEMENT);
1165 END IF;
1166 -- Bug : 9923803
1167 -- API Call to Insert messages into AAD Loader Log Table.
1168 xla_aad_loader_util_pvt.insert_aadloaderlog(
1169 p_amb_context_code => g_amb_context_code,
1170 p_application_id => g_application_id,
1171 p_request_code => 'IMPORT' ,
1172 p_log_type_code => 'MERGE',
1173 p_encoded_message => '# xla_jlt_acct_attrs deleted = '||l_num_rows,
1174 p_component_code => 'clean_oracle_jlts');
1175
1176 FORALL i IN 1..l_codes.COUNT
1177 DELETE FROM xla_acct_line_types_b w
1178 WHERE application_id = g_application_id
1179 AND amb_context_code = g_amb_context_code
1180 AND event_class_code = l_event_class_codes(i)
1181 AND accounting_line_type_code = C_OWNER_SYSTEM
1182 AND accounting_line_code = l_codes(i);
1183 l_num_rows := SQL%ROWCOUNT;
1184 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1185 trace(p_msg => '# xla_acct_line_types_b deleted = '||l_num_rows,
1186 p_module => l_log_module,
1187 p_level => C_LEVEL_STATEMENT);
1188 END IF;
1189 -- Bug : 9923803
1190 -- API Call to Insert messages into AAD Loader Log Table.
1191 xla_aad_loader_util_pvt.insert_aadloaderlog(
1192 p_amb_context_code => g_amb_context_code,
1193 p_application_id => g_application_id,
1194 p_request_code => 'IMPORT' ,
1195 p_log_type_code => 'MERGE',
1196 p_encoded_message => '# xla_acct_line_types_b deleted = '||l_num_rows,
1197 p_component_code => 'clean_oracle_jlts');
1198
1199 FORALL i IN 1..l_codes.COUNT
1200 DELETE FROM xla_acct_line_types_tl w
1201 WHERE application_id = g_application_id
1202 AND amb_context_code = g_amb_context_code
1203 AND event_class_code = l_event_class_codes(i)
1204 AND accounting_line_type_code = C_OWNER_SYSTEM
1205 AND accounting_line_code = l_codes(i);
1206 l_num_rows := SQL%ROWCOUNT;
1207 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1208 trace(p_msg => '# xla_acct_line_types_tl deleted = '||l_num_rows,
1209 p_module => l_log_module,
1210 p_level => C_LEVEL_STATEMENT);
1211 END IF;
1212 -- Bug : 9923803
1213 -- API Call to Insert messages into AAD Loader Log Table.
1214 xla_aad_loader_util_pvt.insert_aadloaderlog(
1215 p_amb_context_code => g_amb_context_code,
1216 p_application_id => g_application_id,
1217 p_request_code => 'IMPORT' ,
1218 p_log_type_code => 'MERGE',
1219 p_encoded_message => '# xla_acct_line_types_tl deleted = '||l_num_rows,
1220 p_component_code => 'clean_oracle_jlts');
1221
1222 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1223 trace(p_msg => 'BEGIN of procedure clean_oracle_jlts',
1224 p_module => l_log_module,
1225 p_level => C_LEVEL_PROCEDURE);
1226 END IF;
1227
1228 END IF;
1229
1230 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1231 trace(p_msg => 'END of procedure clean_oracle_jlts',
1232 p_module => l_log_module,
1233 p_level => C_LEVEL_PROCEDURE);
1234 END IF;
1235
1236 EXCEPTION
1237 WHEN OTHERS THEN
1238 xla_aad_loader_util_pvt.stack_error
1239 (p_appli_s_name => 'XLA'
1240 ,p_msg_name => 'XLA_COMMON_ERROR'
1241 ,p_token_1 => 'LOCATION'
1242 ,p_value_1 => 'xla_aad_merge_pvt.clean_oracle_jlts'
1243 ,p_token_2 => 'ERROR'
1244 ,p_value_2 => 'unhandled exception');
1245 RAISE;
1246
1247 END clean_oracle_jlts;
1248
1249
1250 --=============================================================================
1251 --
1252 -- Name: clean_oracle_descriptions
1253 -- Description:
1254 --
1255 --=============================================================================
1256 PROCEDURE clean_oracle_descriptions
1257 IS
1258 CURSOR c_all_comps IS
1259 SELECT work.description_code
1260 FROM xla_descriptions_b work
1261 WHERE work.application_id = g_application_id
1262 AND work.amb_context_code = g_amb_context_code
1263 AND work.description_type_code = C_OWNER_SYSTEM
1264 AND NOT EXISTS ( SELECT 1
1265 FROM xla_descriptions_b stage
1266 WHERE stage.application_id = g_application_id
1267 AND stage.amb_context_code = g_staging_context_code
1268 AND stage.description_type_code = C_OWNER_SYSTEM
1269 AND stage.description_code = work.description_code);
1270
1271 l_codes t_array_varchar30;
1272
1273 l_log_module VARCHAR2(240);
1274 l_num_rows INTEGER;
1275 BEGIN
1276 IF g_log_enabled THEN
1277 l_log_module := C_DEFAULT_MODULE||'.clean_oracle_descriptions';
1278 END IF;
1279
1280 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1281 trace(p_msg => 'BEGIN of procedure clean_oracle_descriptions',
1282 p_module => l_log_module,
1283 p_level => C_LEVEL_PROCEDURE);
1284 END IF;
1285
1286 IF (g_analyzed_flag = 'Y') THEN
1287 null;
1288 ELSE
1289 OPEN c_all_comps;
1290 FETCH c_all_comps BULK COLLECT INTO l_codes;
1291 CLOSE c_all_comps;
1292
1293 END IF;
1294
1295 IF (l_codes.COUNT > 0) THEN
1296 FORALL i IN 1..l_codes.COUNT
1297 UPDATE xla_line_defn_jlt_assgns
1298 SET description_type_code = NULL
1299 , description_code = NULL
1300 WHERE application_id = g_application_id
1301 AND amb_context_code = g_amb_context_code
1302 AND description_type_code = C_OWNER_SYSTEM
1303 AND description_code = l_codes(i);
1304 l_num_rows := SQL%ROWCOUNT;
1305 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1306 trace(p_msg => '# xla_line_defn_jlt_assgns clear description = '||l_num_rows,
1307 p_module => l_log_module,
1308 p_level => C_LEVEL_STATEMENT);
1309 END IF;
1310 -- Bug : 9923803
1311 -- API Call to Insert messages into AAD Loader Log Table.
1312 xla_aad_loader_util_pvt.insert_aadloaderlog(
1313 p_amb_context_code => g_amb_context_code,
1314 p_application_id => g_application_id,
1315 p_request_code => 'IMPORT' ,
1316 p_log_type_code => 'MERGE',
1317 p_encoded_message => '# xla_line_defn_jlt_assgns clear description = '||l_num_rows,
1318 p_component_code => 'clean_oracle_descriptions');
1319
1320 FORALL i IN 1..l_codes.COUNT
1321 UPDATE xla_prod_acct_headers
1322 SET description_type_code = NULL
1323 , description_code = NULL
1324 WHERE application_id = g_application_id
1325 AND amb_context_code = g_amb_context_code
1326 AND description_type_code = C_OWNER_SYSTEM
1327 AND description_code = l_codes(i);
1328 l_num_rows := SQL%ROWCOUNT;
1329 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1330 trace(p_msg => '# xla_prod_acct_headers clear description = '||l_num_rows,
1331 p_module => l_log_module,
1332 p_level => C_LEVEL_STATEMENT);
1333 END IF;
1334
1335 -- Bug : 9923803
1336 -- API Call to Insert messages into AAD Loader Log Table.
1337 xla_aad_loader_util_pvt.insert_aadloaderlog(
1338 p_amb_context_code => g_amb_context_code,
1339 p_application_id => g_application_id,
1340 p_request_code => 'IMPORT' ,
1341 p_log_type_code => 'MERGE',
1342 p_encoded_message => '# xla_prod_acct_headers clear description = '||l_num_rows,
1343 p_component_code => 'clean_oracle_descriptions');
1344
1345 FORALL i IN 1..l_codes.COUNT
1346 DELETE FROM xla_descript_details_tl w
1347 WHERE description_detail_id IN
1348 (SELECT description_detail_id
1349 FROM xla_descript_details_b d
1350 , xla_desc_priorities p
1351 WHERE d.description_prio_id = p.description_prio_id
1352 AND p.application_id = g_application_id
1353 AND p.amb_context_code = g_amb_context_code
1354 AND p.description_type_code = C_OWNER_SYSTEM
1355 AND p.description_code = l_codes(i));
1356 l_num_rows := SQL%ROWCOUNT;
1357 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1358 trace(p_msg => '# xla_descript_details_tl deleted = '||l_num_rows,
1359 p_module => l_log_module,
1360 p_level => C_LEVEL_STATEMENT);
1361 END IF;
1362 -- Bug : 9923803
1363 -- API Call to Insert messages into AAD Loader Log Table.
1364 xla_aad_loader_util_pvt.insert_aadloaderlog(
1365 p_amb_context_code => g_amb_context_code,
1366 p_application_id => g_application_id,
1367 p_request_code => 'IMPORT' ,
1368 p_log_type_code => 'MERGE',
1369 p_encoded_message => '# xla_descript_details_tl deleted = '||l_num_rows,
1370 p_component_code => 'clean_oracle_descriptions');
1371
1372 FORALL i IN 1..l_codes.COUNT
1373 DELETE FROM xla_descript_details_b w
1374 WHERE description_prio_id IN
1375 (SELECT description_prio_id
1376 FROM xla_desc_priorities p
1377 WHERE p.application_id = g_application_id
1378 AND p.amb_context_code = g_amb_context_code
1379 AND p.description_type_code = C_OWNER_SYSTEM
1380 AND p.description_code = l_codes(i));
1381 l_num_rows := SQL%ROWCOUNT;
1382 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1383 trace(p_msg => '# xla_descript_details_b deleted = '||l_num_rows,
1384 p_module => l_log_module,
1385 p_level => C_LEVEL_STATEMENT);
1386 END IF;
1387 -- Bug : 9923803
1388 -- API Call to Insert messages into AAD Loader Log Table.
1389 xla_aad_loader_util_pvt.insert_aadloaderlog(
1390 p_amb_context_code => g_amb_context_code,
1391 p_application_id => g_application_id,
1392 p_request_code => 'IMPORT' ,
1393 p_log_type_code => 'MERGE',
1394 p_encoded_message => '# xla_descript_details_b deleted = '||l_num_rows,
1395 p_component_code => 'clean_oracle_descriptions');
1396
1397 FORALL i IN 1..l_codes.COUNT
1398 DELETE FROM xla_desc_priorities w
1399 WHERE application_id = g_application_id
1400 AND amb_context_code = g_amb_context_code
1401 AND description_type_code = C_OWNER_SYSTEM
1402 AND description_code = l_codes(i);
1403 l_num_rows := SQL%ROWCOUNT;
1404 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1405 trace(p_msg => '# xla_desc_priorities deleted = '||l_num_rows,
1406 p_module => l_log_module,
1407 p_level => C_LEVEL_STATEMENT);
1408 END IF;
1409 -- Bug : 9923803
1410 -- API Call to Insert messages into AAD Loader Log Table.
1411 xla_aad_loader_util_pvt.insert_aadloaderlog(
1412 p_amb_context_code => g_amb_context_code,
1413 p_application_id => g_application_id,
1414 p_request_code => 'IMPORT' ,
1415 p_log_type_code => 'MERGE',
1416 p_encoded_message => '# xla_desc_priorities deleted = '||l_num_rows,
1417 p_component_code => 'clean_oracle_descriptions');
1418
1419 FORALL i IN 1..l_codes.COUNT
1420 DELETE FROM xla_descriptions_tl w
1421 WHERE application_id = g_application_id
1422 AND amb_context_code = g_amb_context_code
1423 AND description_type_code = C_OWNER_SYSTEM
1424 AND description_code = l_codes(i);
1425 l_num_rows := SQL%ROWCOUNT;
1426 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1427 trace(p_msg => '# xla_descriptions_tl deleted = '||l_num_rows,
1428 p_module => l_log_module,
1429 p_level => C_LEVEL_STATEMENT);
1430 END IF;
1431 -- Bug : 9923803
1432 -- API Call to Insert messages into AAD Loader Log Table.
1433 xla_aad_loader_util_pvt.insert_aadloaderlog(
1434 p_amb_context_code => g_amb_context_code,
1435 p_application_id => g_application_id,
1436 p_request_code => 'IMPORT' ,
1437 p_log_type_code => 'MERGE',
1438 p_encoded_message => '# xla_descriptions_tl deleted = '||l_num_rows,
1439 p_component_code => 'clean_oracle_descriptions');
1440
1441 FORALL i IN 1..l_codes.COUNT
1442 DELETE FROM xla_descriptions_b w
1443 WHERE application_id = g_application_id
1444 AND amb_context_code = g_amb_context_code
1445 AND description_type_code = C_OWNER_SYSTEM
1446 AND description_code = l_codes(i);
1447 l_num_rows := SQL%ROWCOUNT;
1448 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1449 trace(p_msg => '# xla_descriptions_b deleted = '||l_num_rows,
1450 p_module => l_log_module,
1451 p_level => C_LEVEL_STATEMENT);
1452 END IF;
1453 -- Bug : 9923803
1454 -- API Call to Insert messages into AAD Loader Log Table.
1455 xla_aad_loader_util_pvt.insert_aadloaderlog(
1456 p_amb_context_code => g_amb_context_code,
1457 p_application_id => g_application_id,
1458 p_request_code => 'IMPORT' ,
1459 p_log_type_code => 'MERGE',
1460 p_encoded_message =>'# xla_descriptions_b deleted = '||l_num_rows,
1461 p_component_code => 'clean_oracle_descriptions');
1462 END IF;
1463
1464 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1465 trace(p_msg => 'END of procedure clean_oracle_descriptions',
1466 p_module => l_log_module,
1467 p_level => C_LEVEL_PROCEDURE);
1468 END IF;
1469
1470 EXCEPTION
1471 WHEN OTHERS THEN
1472 xla_aad_loader_util_pvt.stack_error
1473 (p_appli_s_name => 'XLA'
1474 ,p_msg_name => 'XLA_COMMON_ERROR'
1475 ,p_token_1 => 'LOCATION'
1476 ,p_value_1 => 'xla_aad_merge_pvt.clean_oracle_descriptions'
1477 ,p_token_2 => 'ERROR'
1478 ,p_value_2 => 'unhandled exception');
1479 RAISE;
1480
1481 END clean_oracle_descriptions;
1482
1483
1484 --=============================================================================
1485 --
1486 -- Name: clean_oracle_adrs
1487 -- Description:
1488 --
1489 --=============================================================================
1490 PROCEDURE clean_oracle_adrs
1491 IS
1492 -- Retrieve the Oracle adr to be deleted
1493 CURSOR c_all_comps IS
1494 SELECT work.segment_rule_code
1495 FROM xla_seg_rules_b work
1496 WHERE work.application_id = g_application_id
1497 AND work.amb_context_code = g_amb_context_code
1498 AND work.segment_rule_type_code = C_OWNER_SYSTEM
1499 AND NOT EXISTS
1500 (SELECT 1
1501 FROM xla_seg_rules_b stage
1502 WHERE stage.application_id = g_application_id
1503 AND stage.amb_context_code = g_staging_context_code
1504 AND stage.segment_rule_type_code = C_OWNER_SYSTEM
1505 AND stage.segment_rule_code = work.segment_rule_code);
1506
1507 l_codes t_array_varchar30;
1508 i INTEGER;
1509
1510 l_log_module VARCHAR2(240);
1511 l_num_rows INTEGER;
1512 BEGIN
1513 IF g_log_enabled THEN
1514 l_log_module := C_DEFAULT_MODULE||'.clean_oracle_adrs';
1515 END IF;
1516
1517 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1518 trace(p_msg => 'BEGIN of procedure clean_oracle_adrs',
1519 p_module => l_log_module,
1520 p_level => C_LEVEL_PROCEDURE);
1521 END IF;
1522
1523 IF (g_analyzed_flag = 'Y') THEN
1524 null;
1525 ELSE
1526 OPEN c_all_comps;
1527 FETCH c_all_comps BULK COLLECT INTO l_codes;
1528 CLOSE c_all_comps;
1529
1530 END IF;
1531
1532 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1533 trace(p_msg => '# ADRs to be deleted = '||l_codes.COUNT,
1534 p_module => l_log_module,
1535 p_level => C_LEVEL_PROCEDURE);
1536 END IF;
1537 -- Bug : 9923803
1538 -- API Call to Insert messages into AAD Loader Log Table.
1539 xla_aad_loader_util_pvt.insert_aadloaderlog(
1540 p_amb_context_code => g_amb_context_code,
1541 p_application_id => g_application_id,
1542 p_request_code => 'IMPORT' ,
1543 p_log_type_code => 'MERGE',
1544 p_encoded_message =>'# ADRs to be deleted = '||l_codes.COUNT,
1545 p_component_code => 'clean_oracle_adrs');
1546 -- Record if the deleted AAD is used by any other application
1547 IF (l_codes.COUNT > 0) THEN
1548
1549 FORALL i IN 1..l_codes.COUNT
1550 INSERT INTO xla_aad_loader_logs
1551 (aad_loader_log_id
1552 ,amb_context_code
1553 ,application_id
1554 ,request_code
1555 ,log_type_code
1556 ,aad_application_id
1557 ,component_type_code
1558 ,component_owner_code
1559 ,component_code
1560 ,object_version_number
1561 ,creation_date
1562 ,created_by
1563 ,last_update_date
1564 ,last_updated_by
1565 ,last_update_login
1566 ,program_update_date
1567 ,program_application_id
1568 ,program_id
1569 ,request_id)
1570 SELECT xla_aad_loader_logs_s.nextval
1571 ,g_amb_context_code
1572 ,g_application_id
1573 ,'IMPORT'
1574 ,'DELETED_SETUP'
1575 ,application_id
1576 ,'AMB_ADR'
1577 ,C_OWNER_SYSTEM
1578 ,l_codes(i)
1579 ,1
1580 ,sysdate
1581 ,xla_environment_pkg.g_usr_id
1582 ,sysdate
1583 ,xla_environment_pkg.g_usr_id
1584 ,xla_environment_pkg.g_login_id
1585 ,sysdate
1586 ,xla_environment_pkg.g_prog_appl_id
1587 ,xla_environment_pkg.g_prog_id
1588 ,xla_environment_pkg.g_req_Id
1589 FROM (SELECT application_id
1590 FROM xla_seg_rule_details s
1591 WHERE application_id <> g_application_id
1592 AND amb_context_code = g_amb_context_code
1593 AND value_segment_rule_appl_id = g_application_id
1594 AND value_segment_rule_type_code = C_OWNER_SYSTEM
1595 AND value_segment_rule_code = l_codes(i)
1596 UNION
1597 SELECT application_id
1598 FROM xla_line_defn_adr_assgns
1599 WHERE application_id <> g_application_id
1600 AND amb_context_code = g_amb_context_code
1601 AND segment_rule_appl_id = g_application_id
1602 AND segment_rule_type_code = C_OWNER_SYSTEM
1603 AND segment_rule_code = l_codes(i)
1604 UNION
1605 SELECT application_id
1606 FROM xla_mpa_jlt_adr_assgns
1607 WHERE application_id <> g_application_id
1608 AND amb_context_code = g_amb_context_code
1609 AND segment_rule_appl_id = g_application_id
1610 AND segment_rule_type_code = C_OWNER_SYSTEM
1611 AND segment_rule_code = l_codes(i));
1612 l_num_rows := SQL%ROWCOUNT;
1613 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1614 trace(p_msg => '# xla_aad_loader_logs inserted = '||l_num_rows,
1615 p_module => l_log_module,
1616 p_level => C_LEVEL_STATEMENT);
1617 END IF;
1618 -- Bug : 9923803
1619 -- API Call to Insert messages into AAD Loader Log Table.
1620 xla_aad_loader_util_pvt.insert_aadloaderlog(
1621 p_amb_context_code => g_amb_context_code,
1622 p_application_id => g_application_id,
1623 p_request_code => 'IMPORT' ,
1624 p_log_type_code => 'MERGE',
1625 p_encoded_message =>'# xla_aad_loader_logs inserted = '||l_num_rows,
1626 p_component_code => 'clean_oracle_adrs');
1627
1628 -- Delete the reference to Oracle ADR to be deleted
1629 FORALL i IN 1..l_codes.COUNT
1630 DELETE FROM xla_seg_rule_details d
1631 WHERE amb_context_code = g_amb_context_code
1632 AND value_segment_rule_appl_id = g_application_id
1633 AND value_segment_rule_type_code = C_OWNER_SYSTEM
1634 AND value_segment_rule_code = l_codes(i);
1635 l_num_rows := SQL%ROWCOUNT;
1636 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1637 trace(p_msg => '# xla_seg_rules_details (value) deleted = '||l_num_rows,
1638 p_module => l_log_module,
1639 p_level => C_LEVEL_STATEMENT);
1640 END IF;
1641 -- Bug : 9923803
1642 -- API Call to Insert messages into AAD Loader Log Table.
1643 xla_aad_loader_util_pvt.insert_aadloaderlog(
1644 p_amb_context_code => g_amb_context_code,
1645 p_application_id => g_application_id,
1646 p_request_code => 'IMPORT' ,
1647 p_log_type_code => 'MERGE',
1648 p_encoded_message =>'# xla_seg_rules_details (value) deleted = '||l_num_rows,
1649 p_component_code => 'clean_oracle_adrs');
1650
1651 FORALL i IN 1..l_codes.COUNT
1652 DELETE FROM xla_mpa_jlt_adr_assgns w
1653 WHERE amb_context_code = g_amb_context_code
1654 AND segment_rule_appl_id = g_application_id
1655 AND segment_rule_type_code = C_OWNER_SYSTEM
1656 AND segment_rule_code = l_codes(i);
1657 l_num_rows := SQL%ROWCOUNT;
1658 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1659 trace(p_msg => '# xla_mpa_jlt_adr_assgns deleted = '||l_num_rows,
1660 p_module => l_log_module,
1661 p_level => C_LEVEL_STATEMENT);
1662 END IF;
1663 -- Bug : 9923803
1664 -- API Call to Insert messages into AAD Loader Log Table.
1665 xla_aad_loader_util_pvt.insert_aadloaderlog(
1666 p_amb_context_code => g_amb_context_code,
1667 p_application_id => g_application_id,
1668 p_request_code => 'IMPORT' ,
1669 p_log_type_code => 'MERGE',
1670 p_encoded_message =>'# xla_mpa_jlt_adr_assgns deleted = '||l_num_rows,
1671 p_component_code => 'clean_oracle_adrs');
1672
1673 FORALL i IN 1..l_codes.COUNT
1674 DELETE FROM xla_line_defn_adr_assgns w
1675 WHERE amb_context_code = g_amb_context_code
1676 AND segment_rule_appl_id = g_application_id
1677 AND segment_rule_type_code = C_OWNER_SYSTEM
1678 AND segment_rule_code = l_codes(i);
1679 l_num_rows := SQL%ROWCOUNT;
1680 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1681 trace(p_msg => '# xla_line_defn_adr_assgns deleted = '||l_num_rows,
1682 p_module => l_log_module,
1683 p_level => C_LEVEL_STATEMENT);
1684 END IF;
1685 -- Bug : 9923803
1686 -- API Call to Insert messages into AAD Loader Log Table.
1687 xla_aad_loader_util_pvt.insert_aadloaderlog(
1688 p_amb_context_code => g_amb_context_code,
1689 p_application_id => g_application_id,
1690 p_request_code => 'IMPORT' ,
1691 p_log_type_code => 'MERGE',
1692 p_encoded_message =>'# xla_line_defn_adr_assgns deleted = '||l_num_rows,
1693 p_component_code => 'clean_oracle_adrs');
1694
1695 -- Delete the ADR
1696 FORALL i IN 1..l_codes.COUNT
1697 DELETE FROM xla_seg_rule_details w
1698 WHERE application_id = g_application_id
1699 AND amb_context_code = g_amb_context_code
1700 AND segment_rule_type_code = C_OWNER_SYSTEM
1701 AND segment_rule_code = l_codes(i);
1702 l_num_rows := SQL%ROWCOUNT;
1703 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1704 trace(p_msg => '# xla_seg_rule_details deleted = '||l_num_rows,
1705 p_module => l_log_module,
1706 p_level => C_LEVEL_STATEMENT);
1707 END IF;
1708 -- Bug : 9923803
1709 -- API Call to Insert messages into AAD Loader Log Table.
1710 xla_aad_loader_util_pvt.insert_aadloaderlog(
1711 p_amb_context_code => g_amb_context_code,
1712 p_application_id => g_application_id,
1713 p_request_code => 'IMPORT' ,
1714 p_log_type_code => 'MERGE',
1715 p_encoded_message =>'# xla_seg_rule_details deleted = '||l_num_rows,
1716 p_component_code => 'clean_oracle_adrs');
1717
1718 FORALL i IN 1..l_codes.COUNT
1719 DELETE FROM xla_seg_rules_tl w
1720 WHERE application_id = g_application_id
1721 AND amb_context_code = g_amb_context_code
1722 AND segment_rule_type_code = C_OWNER_SYSTEM
1723 AND segment_rule_code = l_codes(i);
1724 l_num_rows := SQL%ROWCOUNT;
1725 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1726 trace(p_msg => '# xla_seg_rules_tl deleted = '||l_num_rows,
1727 p_module => l_log_module,
1728 p_level => C_LEVEL_STATEMENT);
1729 END IF;
1730 -- Bug : 9923803
1731 -- API Call to Insert messages into AAD Loader Log Table.
1732 xla_aad_loader_util_pvt.insert_aadloaderlog(
1733 p_amb_context_code => g_amb_context_code,
1734 p_application_id => g_application_id,
1735 p_request_code => 'IMPORT' ,
1736 p_log_type_code => 'MERGE',
1737 p_encoded_message =>'# xla_seg_rules_tl deleted = '||l_num_rows,
1738 p_component_code => 'clean_oracle_adrs');
1739
1740 FORALL i IN 1..l_codes.COUNT
1741 DELETE FROM xla_seg_rules_b w
1742 WHERE application_id = g_application_id
1743 AND amb_context_code = g_amb_context_code
1744 AND segment_rule_type_code = C_OWNER_SYSTEM
1745 AND segment_rule_code = l_codes(i);
1746 l_num_rows := SQL%ROWCOUNT;
1747 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1748 trace(p_msg => '#xla_seg_rules_b deleted = '||l_num_rows,
1749 p_module => l_log_module,
1750 p_level => C_LEVEL_STATEMENT);
1751 END IF;
1752 -- Bug : 9923803
1753 -- API Call to Insert messages into AAD Loader Log Table.
1754 xla_aad_loader_util_pvt.insert_aadloaderlog(
1755 p_amb_context_code => g_amb_context_code,
1756 p_application_id => g_application_id,
1757 p_request_code => 'IMPORT' ,
1758 p_log_type_code => 'MERGE',
1759 p_encoded_message =>'#xla_seg_rules_b deleted = '||l_num_rows,
1760 p_component_code => 'clean_oracle_adrs');
1761 END IF;
1762
1763 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1764 trace(p_msg => 'END of procedure clean_oracle_adrs',
1765 p_module => l_log_module,
1766 p_level => C_LEVEL_PROCEDURE);
1767 END IF;
1768
1769 EXCEPTION
1770 WHEN OTHERS THEN
1771 xla_aad_loader_util_pvt.stack_error
1772 (p_appli_s_name => 'XLA'
1773 ,p_msg_name => 'XLA_COMMON_ERROR'
1774 ,p_token_1 => 'LOCATION'
1775 ,p_value_1 => 'xla_aad_merge_pvt.clean_oracle_adrs'
1776 ,p_token_2 => 'ERROR'
1777 ,p_value_2 => 'unhandled exception');
1778 RAISE;
1779
1780 END clean_oracle_adrs;
1781
1782
1783 --=============================================================================
1784 --
1785 -- Name: clean_oracle_acs
1786 -- Description:
1787 --
1788 --=============================================================================
1789 PROCEDURE clean_oracle_acs
1790 IS
1791 /*CURSOR c_all_comps IS
1792 SELECT w.analytical_criterion_code
1793 FROM xla_analytical_hdrs_b w
1794 WHERE w.amb_context_code = g_amb_context_code
1795 AND w.application_id = g_application_id
1796 AND w.analytical_criterion_type_code = C_OWNER_SYSTEM
1797 AND NOT EXISTS ( SELECT 1
1798 FROM xla_analytical_hdrs_b s
1799 WHERE s.amb_context_code = g_staging_context_code
1800 AND s.application_id = g_application_id
1801 AND s.analytical_criterion_type_code = C_OWNER_SYSTEM
1802 AND s.analytical_criterion_code = w.analytical_criterion_code);
1803
1804 l_codes t_array_varchar30;*/ -- commented bug6696939
1805
1806 l_log_module VARCHAR2(240);
1807 l_num_rows INTEGER;
1808 BEGIN
1809 IF g_log_enabled THEN
1810 l_log_module := C_DEFAULT_MODULE||'.clean_oracle_acs';
1811 END IF;
1812
1813 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1814 trace(p_msg => 'BEGIN of procedure clean_oracle_acs',
1815 p_module => l_log_module,
1816 p_level => C_LEVEL_PROCEDURE);
1817 END IF;
1818
1819 /*IF (g_analyzed_flag = 'Y') THEN
1820 null;
1821 ELSE
1822 OPEN c_all_comps;
1823 FETCH c_all_comps BULK COLLECT INTO l_codes;
1824 CLOSE c_all_comps;
1825
1826 END IF;
1827
1828 -- Delete reference to the AC
1829 FORALL i IN 1..l_codes.COUNT
1830 DELETE FROM xla_aad_header_ac_assgns w
1831 WHERE application_id = g_application_id
1832 AND amb_context_code = g_amb_context_code
1833 AND analytical_criterion_type_code = C_OWNER_SYSTEM
1834 AND analytical_criterion_code = l_codes(i);
1835
1836 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1837 trace(p_msg => '# xla_aad_header_ac_assgns deleted = '||SQL%ROWCOUNT,
1838 p_module => l_log_module,
1839 p_level => C_LEVEL_STATEMENT);
1840 END IF;
1841
1842 FORALL i IN 1..l_codes.COUNT
1843 DELETE FROM xla_line_defn_ac_assgns w
1844 WHERE amb_context_code = g_amb_context_code
1845 AND analytical_criterion_type_code = C_OWNER_SYSTEM
1846 AND analytical_criterion_code = l_codes(i);
1847
1848 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1849 trace(p_msg => '# xla_line_defn_ac_assgns deleted = '||SQL%ROWCOUNT,
1850 p_module => l_log_module,
1851 p_level => C_LEVEL_STATEMENT);
1852 END IF;
1853
1854 FORALL i IN 1..l_codes.COUNT
1855 DELETE FROM xla_mpa_header_ac_assgns w
1856 WHERE amb_context_code = g_amb_context_code
1857 AND analytical_criterion_type_code = C_OWNER_SYSTEM
1858 AND analytical_criterion_code = l_codes(i);
1859
1860 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1861 trace(p_msg => '# xla_mpa_header_ac_assgns deleted = '||SQL%ROWCOUNT,
1862 p_module => l_log_module,
1863 p_level => C_LEVEL_STATEMENT);
1864 END IF;
1865
1866 FORALL i IN 1..l_codes.COUNT
1867 DELETE FROM xla_mpa_jlt_ac_assgns w
1868 WHERE amb_context_code = g_amb_context_code
1869 AND analytical_criterion_type_code = C_OWNER_SYSTEM
1870 AND analytical_criterion_code = l_codes(i);
1871
1872 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1873 trace(p_msg => '# xla_mpa_jlt_ac_assgns deleted = '||SQL%ROWCOUNT,
1874 p_module => l_log_module,
1875 p_level => C_LEVEL_STATEMENT);
1876 END IF;*/ -- commented bug6696939
1877
1878 -- Delete the AC
1879 DELETE FROM xla_analytical_sources w
1880 WHERE amb_context_code = g_amb_context_code
1881 AND analytical_criterion_type_code = C_OWNER_SYSTEM
1882 AND application_id = g_application_id -- added bug6696939
1883 AND NOT EXISTS
1884 (SELECT 1
1885 FROM xla_analytical_sources s
1886 WHERE s.amb_context_code = g_staging_context_code
1887 AND s.application_id = g_application_id
1888 AND s.entity_code = w.entity_code
1889 AND s.event_class_code = w.event_class_code
1890 AND s.source_application_id = w.source_application_id
1891 AND s.source_type_code = w.source_type_code
1892 AND s.source_code = w.source_code
1893 AND s.analytical_criterion_type_code = C_OWNER_SYSTEM
1894 AND s.analytical_criterion_code = w.analytical_criterion_code
1895 AND s.analytical_detail_code = w.analytical_detail_code);
1896 l_num_rows := SQL%ROWCOUNT;
1897 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1898 trace(p_msg => '# xla_analytical_sources deleted = '||l_num_rows,
1899 p_module => l_log_module,
1900 p_level => C_LEVEL_STATEMENT);
1901 END IF;
1902
1903 -- Bug : 9923803
1904 -- API Call to Insert messages into AAD Loader Log Table.
1905 xla_aad_loader_util_pvt.insert_aadloaderlog(
1906 p_amb_context_code => g_amb_context_code,
1907 p_application_id => g_application_id,
1908 p_request_code => 'IMPORT' ,
1909 p_log_type_code => 'MERGE',
1910 p_encoded_message =>'# xla_analytical_sources deleted = '||l_num_rows,
1911 p_component_code => 'clean_oracle_acs');
1912
1913 /*DELETE FROM xla_analytical_dtls_tl w
1914 WHERE amb_context_code = g_amb_context_code
1915 AND analytical_criterion_type_code = C_OWNER_SYSTEM
1916 AND NOT EXISTS
1917 (SELECT 1
1918 FROM xla_analytical_dtls_b s
1919 WHERE s.amb_context_code = g_staging_context_code
1920 AND s.analytical_criterion_type_code = C_OWNER_SYSTEM
1921 AND s.analytical_criterion_code = w.analytical_criterion_code
1922 AND s.analytical_detail_code = w.analytical_detail_code);
1923
1924 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1925 trace(p_msg => '# xla_analytical_dtls_tl deleted = '||SQL%ROWCOUNT,
1926 p_module => l_log_module,
1927 p_level => C_LEVEL_STATEMENT);
1928 END IF;
1929
1930 DELETE FROM xla_analytical_dtls_b w
1931 WHERE amb_context_code = g_amb_context_code
1932 AND analytical_criterion_type_code = C_OWNER_SYSTEM
1933 AND NOT EXISTS
1934 (SELECT 1
1935 FROM xla_analytical_dtls_b s
1936 WHERE s.amb_context_code = g_staging_context_code
1937 AND s.analytical_criterion_type_code = C_OWNER_SYSTEM
1938 AND s.analytical_criterion_code = w.analytical_criterion_code
1939 AND s.analytical_detail_code = w.analytical_detail_code);
1940
1941 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1942 trace(p_msg => '# xla_analytical_dtls_b deleted = '||SQL%ROWCOUNT,
1943 p_module => l_log_module,
1944 p_level => C_LEVEL_STATEMENT);
1945 END IF;
1946
1947 FORALL i IN 1..l_codes.COUNT
1948 DELETE FROM xla_analytical_hdrs_tl w
1949 WHERE amb_context_code = g_amb_context_code
1950 AND analytical_criterion_type_code = C_OWNER_SYSTEM
1951 AND analytical_criterion_code = l_codes(i);
1952
1953 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1954 trace(p_msg => '# xla_analytical_hdrs_tl deleted = '||SQL%ROWCOUNT,
1955 p_module => l_log_module,
1956 p_level => C_LEVEL_STATEMENT);
1957 END IF;
1958
1959 FORALL i IN 1..l_codes.COUNT
1960 DELETE FROM xla_analytical_hdrs_b w
1961 WHERE amb_context_code = g_amb_context_code
1962 AND analytical_criterion_type_code = C_OWNER_SYSTEM
1963 AND analytical_criterion_code = l_codes(i);
1964
1965 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1966 trace(p_msg => '# xla_analytical_hdrs_b deleted = '||SQL%ROWCOUNT,
1967 p_module => l_log_module,
1968 p_level => C_LEVEL_STATEMENT);
1969 END IF;*/ -- commented bug6696939
1970
1971 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1972 trace(p_msg => 'END of procedure clean_oracle_acs',
1973 p_module => l_log_module,
1974 p_level => C_LEVEL_PROCEDURE);
1975 END IF;
1976
1977 EXCEPTION
1978 WHEN OTHERS THEN
1979 xla_aad_loader_util_pvt.stack_error
1980 (p_appli_s_name => 'XLA'
1981 ,p_msg_name => 'XLA_COMMON_ERROR'
1982 ,p_token_1 => 'LOCATION'
1983 ,p_value_1 => 'xla_aad_merge_pvt.clean_oracle_acs'
1984 ,p_token_2 => 'ERROR'
1985 ,p_value_2 => 'unhandled exception');
1986 RAISE;
1987
1988 END clean_oracle_acs;
1989
1990
1991 --=============================================================================
1992 --
1993 -- Name: clean_oracle_components
1994 -- Description:
1995 --
1996 --=============================================================================
1997 PROCEDURE clean_oracle_components
1998 IS
1999 l_log_module VARCHAR2(240);
2000 BEGIN
2001 IF g_log_enabled THEN
2002 l_log_module := C_DEFAULT_MODULE||'.clean_oracle_components';
2003 END IF;
2004
2005 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2006 trace(p_msg => 'BEGIN of procedure clean_oracle_components',
2007 p_module => l_log_module,
2008 p_level => C_LEVEL_PROCEDURE);
2009 END IF;
2010
2011 clean_oracle_aads;
2012 -- Bug : 12969337
2013 -- API Call to Insert messages into AAD Loader Log Table.
2014 xla_aad_loader_util_pvt.insert_aadloaderlog(
2015 p_amb_context_code => g_amb_context_code,
2016 p_application_id => g_application_id,
2017 p_request_code => 'IMPORT' ,
2018 p_log_type_code => 'MERGE',
2019 p_encoded_message =>'AAD clean up complete',
2020 p_component_code => 'clean_oracle_aads');
2021 clean_oracle_jlds;
2022 -- Bug : 12969337
2023 -- API Call to Insert messages into AAD Loader Log Table.
2024 xla_aad_loader_util_pvt.insert_aadloaderlog(
2025 p_amb_context_code => g_amb_context_code,
2026 p_application_id => g_application_id,
2027 p_request_code => 'IMPORT' ,
2028 p_log_type_code => 'MERGE',
2029 p_encoded_message =>'JLD clean up complete',
2030 p_component_code => 'clean_oracle_jlds');
2031 clean_oracle_jlts;
2032 -- Bug : 12969337
2033 -- API Call to Insert messages into AAD Loader Log Table.
2034 xla_aad_loader_util_pvt.insert_aadloaderlog(
2035 p_amb_context_code => g_amb_context_code,
2036 p_application_id => g_application_id,
2037 p_request_code => 'IMPORT' ,
2038 p_log_type_code => 'MERGE',
2039 p_encoded_message =>'JLT clean up complete',
2040 p_component_code => 'clean_oracle_jlts');
2041 clean_oracle_descriptions;
2042 -- Bug : 12969337
2043 -- API Call to Insert messages into AAD Loader Log Table.
2044 xla_aad_loader_util_pvt.insert_aadloaderlog(
2045 p_amb_context_code => g_amb_context_code,
2046 p_application_id => g_application_id,
2047 p_request_code => 'IMPORT' ,
2048 p_log_type_code => 'MERGE',
2049 p_encoded_message =>'JED clean up complete',
2050 p_component_code => 'clean_oracle_descriptions');
2051 clean_oracle_adrs;
2052 -- Bug : 12969337
2053 -- API Call to Insert messages into AAD Loader Log Table.
2054 xla_aad_loader_util_pvt.insert_aadloaderlog(
2055 p_amb_context_code => g_amb_context_code,
2056 p_application_id => g_application_id,
2057 p_request_code => 'IMPORT' ,
2058 p_log_type_code => 'MERGE',
2059 p_encoded_message =>'ADR clean up complete',
2060 p_component_code => 'clean_oracle_adrs');
2061 clean_oracle_acs;
2062 -- Bug : 12969337
2063 -- API Call to Insert messages into AAD Loader Log Table.
2064 xla_aad_loader_util_pvt.insert_aadloaderlog(
2065 p_amb_context_code => g_amb_context_code,
2066 p_application_id => g_application_id,
2067 p_request_code => 'IMPORT' ,
2068 p_log_type_code => 'MERGE',
2069 p_encoded_message =>'Analytical Criteria clean up complete',
2070 p_component_code => 'clean_oracle_acs');
2071
2072 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2073 trace(p_msg => 'END of procedure clean_oracle_components',
2074 p_module => l_log_module,
2075 p_level => C_LEVEL_PROCEDURE);
2076 END IF;
2077
2078 EXCEPTION
2079 WHEN OTHERS THEN
2080 xla_aad_loader_util_pvt.stack_error
2081 (p_appli_s_name => 'XLA'
2082 ,p_msg_name => 'XLA_COMMON_ERROR'
2083 ,p_token_1 => 'LOCATION'
2084 ,p_value_1 => 'xla_aad_merge_pvt.clean_oracle_components'
2085 ,p_token_2 => 'ERROR'
2086 ,p_value_2 => 'unhandled exception');
2087 RAISE;
2088
2089 END clean_oracle_components;
2090
2091 --=============================================================================
2092 --
2093 -- Name: merge_aads
2094 -- Description: Merge AADs from staging to working area
2095 --
2096 --=============================================================================
2097 PROCEDURE merge_aads
2098 IS
2099 l_log_module VARCHAR2(240);
2100 l_num_rows INTEGER;
2101 BEGIN
2102 IF g_log_enabled THEN
2103 l_log_module := C_DEFAULT_MODULE||'.merge_aads';
2104 END IF;
2105
2106 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2107 trace(p_msg => 'BEGIN of procedure merge_aads',
2108 p_module => l_log_module,
2109 p_level => C_LEVEL_PROCEDURE);
2110 END IF;
2111
2112 IF (g_analyzed_flag = 'Y') THEN
2113 null;
2114 ELSE
2115 -- record log
2116 INSERT INTO xla_aad_loader_logs
2117 (aad_loader_log_id
2118 ,amb_context_code
2119 ,application_id
2120 ,request_code
2121 ,log_type_code
2122 ,aad_application_id
2123 ,product_rule_code
2124 ,product_rule_type_code
2125 ,version_from
2126 ,version_to
2127 ,object_version_number
2128 ,creation_date
2129 ,created_by
2130 ,last_update_date
2131 ,last_updated_by
2132 ,last_update_login
2133 ,program_update_date
2134 ,program_application_id
2135 ,program_id
2136 ,request_id)
2137 SELECT xla_aad_loader_logs_s.nextval
2138 ,g_amb_context_code
2139 ,g_application_id
2140 ,'IMPORT'
2141 ,'MERGED_AAD'
2142 ,g_application_id
2143 ,w.product_rule_code
2144 ,w.product_rule_type_code
2145 ,w.version_num
2146 ,s.version_num
2147 ,1
2148 ,sysdate
2149 ,xla_environment_pkg.g_usr_id
2150 ,sysdate
2151 ,xla_environment_pkg.g_usr_id
2152 ,xla_environment_pkg.g_login_id
2153 ,sysdate
2154 ,xla_environment_pkg.g_prog_appl_id
2155 ,xla_environment_pkg.g_prog_id
2156 ,xla_environment_pkg.g_req_Id
2157 FROM xla_product_rules_b s
2158 , xla_product_rules_b w
2159 WHERE s.application_id = g_application_id
2160 AND s.amb_context_code = g_staging_context_code
2161 AND w.application_id = g_application_id
2162 AND w.amb_context_code = g_amb_context_code
2163 AND w.product_rule_type_code = s.product_rule_type_code
2164 AND w.product_rule_code = s.product_rule_code;
2165
2166
2167 /*******************************************/
2168 /** Added by krsankar for AAD Perf Issue **/
2169 /*******************************************/
2170
2171 INSERT INTO xla_aads_gt
2172 ( product_rule_code,
2173 event_class_code,
2174 event_type_code,
2175 line_definition_code,
2176 table_name
2177 )
2178 select product_rule_code ,
2179 event_class_code ,
2180 event_type_code ,
2181 line_definition_code ,
2182 'XLA_AAD_LINE_DEFN_ASSGNS'
2183 from (select product_rule_code ,
2184 event_class_code ,
2185 event_type_code ,
2186 line_definition_code ,
2187 'XLA_AAD_LINE_DEFN_ASSGNS' ,
2188 amb_context_code,
2189 last_update_date ,
2190 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
2191 from
2192 (select product_rule_code ,
2193 event_class_code ,
2194 event_type_code ,
2195 line_definition_code ,
2196 'XLA_AAD_LINE_DEFN_ASSGNS' ,
2197 amb_context_code,
2198 last_update_date ,
2199 lag(last_update_date) over (PARTITION by application_id,
2200 product_rule_code,
2201 product_rule_type_code,
2202 event_class_code,
2203 event_type_code,
2204 line_definition_code,
2205 line_definition_owner_code
2206 order by amb_context_code
2207 ) lag_date
2208 from XLA_AAD_LINE_DEFN_ASSGNS
2209 order by amb_context_code
2210 ) x
2211 where x.amb_context_code =g_staging_context_code
2212 )
2213 where flag = 'False';
2214 l_num_rows := SQL%ROWCOUNT;
2215 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2216 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_aad_line_defn_assgns is :'||l_num_rows,
2217 p_module => l_log_module,
2218 p_level => C_LEVEL_PROCEDURE);
2219 END IF;
2220 -- Bug : 9923803
2221 -- API Call to Insert messages into AAD Loader Log Table.
2222 xla_aad_loader_util_pvt.insert_aadloaderlog(
2223 p_amb_context_code => g_amb_context_code,
2224 p_application_id => g_application_id,
2225 p_request_code => 'IMPORT' ,
2226 p_log_type_code => 'MERGE',
2227 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_aad_line_defn_assgns is :'||l_num_rows,
2228 p_component_code => 'merge_aads');
2229
2230 INSERT INTO xla_aads_gt
2231 ( product_rule_code,
2232 event_class_code,
2233 accounting_attribute_code,
2234 source_code,
2235 table_name
2236 )
2237 select product_rule_code ,
2238 event_class_code ,
2239 accounting_attribute_code,
2240 source_code,
2241 'XLA_AAD_HDR_ACCT_ATTRS'
2242 from
2243 (select product_rule_code
2244 ,event_class_code
2245 ,accounting_attribute_code
2246 ,source_code
2247 ,'XLA_AAD_HDR_ACCT_ATTRS'
2248 ,amb_context_code
2249 ,last_update_date
2250 ,nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
2251 from
2252 (select product_rule_code
2253 ,event_class_code
2254 ,accounting_attribute_code
2255 ,source_code
2256 ,'XLA_AAD_HDR_ACCT_ATTRS'
2257 ,amb_context_code
2258 ,last_update_date
2259 ,lag(last_update_date) over (PARTITION by application_id
2260 ,product_rule_code
2261 ,product_rule_type_code
2262 ,event_class_code
2263 ,accounting_attribute_code
2264 ,event_type_code
2265 order by amb_context_code
2266 ) lag_date
2267 from XLA_AAD_HDR_ACCT_ATTRS
2268 order by amb_context_code
2269 ) x
2270 where x.amb_context_code =g_staging_context_code
2271 )
2272 where flag = 'False';
2273 l_num_rows := SQL%ROWCOUNT;
2274
2275 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2276 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_aad_hdr_acct_attrs is :'||l_num_rows,
2277 p_module => l_log_module,
2278 p_level => C_LEVEL_PROCEDURE);
2279 END IF;
2280 -- Bug : 9923803
2281 -- API Call to Insert messages into AAD Loader Log Table.
2282 xla_aad_loader_util_pvt.insert_aadloaderlog(
2283 p_amb_context_code => g_amb_context_code,
2284 p_application_id => g_application_id,
2285 p_request_code => 'IMPORT' ,
2286 p_log_type_code => 'MERGE',
2287 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_aad_hdr_acct_attrs is :'||l_num_rows,
2288 p_component_code => 'merge_aads');
2289
2290 INSERT INTO xla_aads_gt
2291 ( product_rule_code,
2292 event_class_code,
2293 event_type_code,
2294 analytical_criterion_code,
2295 table_name
2296 )
2297 select product_rule_code,
2298 event_class_code,
2299 event_type_code,
2300 analytical_criterion_code,
2301 'XLA_AAD_HEADER_AC_ASSGNS'
2302 from (select product_rule_code,
2303 event_class_code,
2304 event_type_code,
2305 analytical_criterion_code,
2306 'XLA_AAD_HEADER_AC_ASSGNS',
2307 amb_context_code,
2308 last_update_date ,
2309 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
2310 from
2311 (select product_rule_code,
2312 event_class_code,
2313 event_type_code,
2314 analytical_criterion_code,
2315 'XLA_AAD_HEADER_AC_ASSGNS',
2316 amb_context_code,
2317 last_update_date ,
2318 lag(last_update_date) over (PARTITION by application_id,
2319 product_rule_code,
2320 product_rule_type_code,
2321 event_class_code,
2322 event_type_code,
2323 analytical_criterion_code,
2324 analytical_criterion_type_code
2325 order by amb_context_code
2326 ) lag_date
2327 from XLA_AAD_HEADER_AC_ASSGNS
2328 order by amb_context_code
2329 ) x
2330 where x.amb_context_code =g_staging_context_code
2331 )
2332 where flag = 'False';
2333 l_num_rows := SQL%ROWCOUNT;
2334
2335 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2336 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_aad_header_ac_assgns is :'||l_num_rows,
2337 p_module => l_log_module,
2338 p_level => C_LEVEL_PROCEDURE);
2339 END IF;
2340 -- Bug : 9923803
2341 -- API Call to Insert messages into AAD Loader Log Table.
2342 xla_aad_loader_util_pvt.insert_aadloaderlog(
2343 p_amb_context_code => g_amb_context_code,
2344 p_application_id => g_application_id,
2345 p_request_code => 'IMPORT' ,
2346 p_log_type_code => 'MERGE',
2347 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_aad_header_ac_assgns is :'||l_num_rows,
2348 p_component_code => 'merge_aads');
2349
2350
2351 UPDATE xla_product_rules_b pr
2352 SET compile_status_code= nvl((select compile_status_code
2353 from xla_product_rules_b pr1
2354 where pr1.product_rule_code = pr.product_rule_code
2355 and pr1.product_rule_type_code = pr.product_rule_type_code
2356 and pr1.amb_context_code = g_amb_context_code
2357 and pr1.application_id = g_application_id
2358 ),'N') --Bug: 10276169 - If select returns null then update default value 'N'.
2359 WHERE amb_context_code = g_staging_context_code
2360 AND application_id = g_application_id;
2361 l_num_rows := SQL%ROWCOUNT;
2362
2363 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2364 trace(p_msg => 'Number of Rows updated in PRODUCT_RULES to original status is :'||l_num_rows,
2365 p_module => l_log_module,
2366 p_level => C_LEVEL_PROCEDURE);
2367 END IF;
2368 -- Bug : 9923803
2369 -- API Call to Insert messages into AAD Loader Log Table.
2370 xla_aad_loader_util_pvt.insert_aadloaderlog(
2371 p_amb_context_code => g_amb_context_code,
2372 p_application_id => g_application_id,
2373 p_request_code => 'IMPORT' ,
2374 p_log_type_code => 'MERGE',
2375 p_encoded_message =>'Number of Rows updated in PRODUCT_RULES to original status is :'||l_num_rows,
2376 p_component_code => 'merge_aads');
2377
2378 -- Delete the AAD from the working area if it already exists in the
2379 -- staging area
2380 DELETE FROM xla_product_rules_b w
2381 WHERE application_id = g_application_id
2382 AND amb_context_code = g_amb_context_code
2383 AND EXISTS (SELECT 1
2384 FROM xla_product_rules_b s
2385 WHERE s.application_id = g_application_id
2386 AND s.amb_context_code = g_staging_context_code
2387 AND s.product_rule_type_code = w.product_rule_type_code
2388 AND s.product_rule_code = w.product_rule_code);
2389 l_num_rows := SQL%ROWCOUNT;
2390 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2391 trace(p_msg => '# xla_product_rules_b deleted : '||l_num_rows,
2392 p_module => l_log_module,
2393 p_level => C_LEVEL_STATEMENT);
2394 END IF;
2395 -- Bug : 9923803
2396 -- API Call to Insert messages into AAD Loader Log Table.
2397 xla_aad_loader_util_pvt.insert_aadloaderlog(
2398 p_amb_context_code => g_amb_context_code,
2399 p_application_id => g_application_id,
2400 p_request_code => 'IMPORT' ,
2401 p_log_type_code => 'MERGE',
2402 p_encoded_message =>'# xla_product_rules_b deleted : '||l_num_rows,
2403 p_component_code => 'merge_aads');
2404
2405 DELETE FROM xla_product_rules_tl w
2406 WHERE application_id = g_application_id
2407 AND amb_context_code = g_amb_context_code
2408 AND EXISTS (SELECT 1
2409 FROM xla_product_rules_tl s
2410 WHERE s.application_id = g_application_id
2411 AND s.amb_context_code = g_staging_context_code
2412 AND s.product_rule_type_code = w.product_rule_type_code
2413 AND s.product_rule_code = w.product_rule_code
2414 AND s.language = w.language);
2415 l_num_rows := SQL%ROWCOUNT;
2416 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2417 trace(p_msg => '# xla_product_rules_tl deleted : '||l_num_rows,
2418 p_module => l_log_module,
2419 p_level => C_LEVEL_STATEMENT);
2420 END IF;
2421 -- Bug : 9923803
2422 -- API Call to Insert messages into AAD Loader Log Table.
2423 xla_aad_loader_util_pvt.insert_aadloaderlog(
2424 p_amb_context_code => g_amb_context_code,
2425 p_application_id => g_application_id,
2426 p_request_code => 'IMPORT' ,
2427 p_log_type_code => 'MERGE',
2428 p_encoded_message =>'# xla_product_rules_tl deleted : '||l_num_rows,
2429 p_component_code => 'merge_aads');
2430
2431 DELETE FROM xla_prod_acct_headers w
2432 WHERE application_id = g_application_id
2433 AND amb_context_code = g_amb_context_code
2434 AND EXISTS (SELECT 1
2435 FROM xla_prod_acct_headers s
2436 WHERE s.application_id = g_application_id
2437 AND s.amb_context_code = g_staging_context_code
2438 AND s.product_rule_type_code = w.product_rule_type_code
2439 AND s.product_rule_code = w.product_rule_code
2440 AND s.event_class_code = w.event_class_code
2441 AND s.event_type_code = w.event_type_code);
2442 l_num_rows := SQL%ROWCOUNT;
2443 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2444 trace(p_msg => '# xla_prod_acct_headers deleted : '||l_num_rows,
2445 p_module => l_log_module,
2446 p_level => C_LEVEL_STATEMENT);
2447 END IF;
2448 -- Bug : 9923803
2449 -- API Call to Insert messages into AAD Loader Log Table.
2450 xla_aad_loader_util_pvt.insert_aadloaderlog(
2451 p_amb_context_code => g_amb_context_code,
2452 p_application_id => g_application_id,
2453 p_request_code => 'IMPORT' ,
2454 p_log_type_code => 'MERGE',
2455 p_encoded_message =>'# xla_prod_acct_headers deleted : '||l_num_rows,
2456 p_component_code => 'merge_aads');
2457
2458 DELETE FROM xla_aad_line_defn_assgns w
2459 WHERE application_id = g_application_id
2460 AND amb_context_code = g_amb_context_code
2461 AND EXISTS (SELECT 1
2462 FROM xla_aad_line_defn_assgns s
2463 WHERE s.application_id = g_application_id
2464 AND s.amb_context_code = g_staging_context_code
2465 AND s.product_rule_type_code = w.product_rule_type_code
2466 AND s.product_rule_code = w.product_rule_code
2467 AND s.event_class_code = w.event_class_code
2468 AND s.event_type_code = w.event_type_code
2469 AND s.line_definition_owner_code = w.line_definition_owner_code
2470 AND s.line_definition_code = w.line_definition_code);
2471 l_num_rows := SQL%ROWCOUNT;
2472 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2473 trace(p_msg => '# xla_aad_line_defn_assgns deleted : '||l_num_rows,
2474 p_module => l_log_module,
2475 p_level => C_LEVEL_STATEMENT);
2476 END IF;
2477 -- Bug : 9923803
2478 -- API Call to Insert messages into AAD Loader Log Table.
2479 xla_aad_loader_util_pvt.insert_aadloaderlog(
2480 p_amb_context_code => g_amb_context_code,
2481 p_application_id => g_application_id,
2482 p_request_code => 'IMPORT' ,
2483 p_log_type_code => 'MERGE',
2484 p_encoded_message =>'# xla_aad_line_defn_assgns deleted : '||l_num_rows,
2485 p_component_code => 'merge_aads');
2486
2487 DELETE FROM xla_aad_hdr_acct_attrs w
2488 WHERE application_id = g_application_id
2489 AND amb_context_code = g_amb_context_code
2490 AND EXISTS (SELECT 1
2491 FROM xla_aad_hdr_acct_attrs s
2492 WHERE s.application_id = g_application_id
2493 AND s.amb_context_code = g_staging_context_code
2494 AND s.product_rule_type_code = w.product_rule_type_code
2495 AND s.product_rule_code = w.product_rule_code
2496 AND s.event_class_code = w.event_class_code
2497 AND s.event_type_code = w.event_type_code
2498 AND s.accounting_attribute_code = w.accounting_attribute_code);
2499
2500 DELETE FROM xla_aad_header_ac_assgns w
2501 WHERE application_id = g_application_id
2502 AND amb_context_code = g_amb_context_code
2503 AND EXISTS (SELECT 1
2504 FROM xla_aad_header_ac_assgns s
2505 WHERE s.application_id = g_application_id
2506 AND s.amb_context_code = g_staging_context_code
2507 AND s.event_class_code = w.event_class_code
2508 AND s.event_type_code = w.event_type_code
2509 AND s.product_rule_type_code = w.product_rule_type_code
2510 AND s.product_rule_code = w.product_rule_code
2511 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
2512 AND s.analytical_criterion_code = w.analytical_criterion_code);
2513 l_num_rows := SQL%ROWCOUNT;
2514 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2515 trace(p_msg => '# xla_aad_header_ac_assgns deleted : '||l_num_rows,
2516 p_module => l_log_module,
2517 p_level => C_LEVEL_STATEMENT);
2518 END IF;
2519 -- Bug : 9923803
2520 -- API Call to Insert messages into AAD Loader Log Table.
2521 xla_aad_loader_util_pvt.insert_aadloaderlog(
2522 p_amb_context_code => g_amb_context_code,
2523 p_application_id => g_application_id,
2524 p_request_code => 'IMPORT' ,
2525 p_log_type_code => 'MERGE',
2526 p_encoded_message =>'# xla_aad_header_ac_assgns deleted : '||l_num_rows,
2527 p_component_code => 'merge_aads');
2528 END IF;
2529
2530 -- Move the AAD from staging area to working area
2531 UPDATE xla_product_rules_b
2532 SET amb_context_code = g_amb_context_code
2533 WHERE application_id = g_application_id
2534 AND amb_context_code = g_staging_context_code;
2535 l_num_rows := SQL%ROWCOUNT;
2536 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2537 trace(p_msg => '# xla_product_rules_b updated : '||l_num_rows,
2538 p_module => l_log_module,
2539 p_level => C_LEVEL_STATEMENT);
2540 END IF;
2541 -- Bug : 9923803
2542 -- API Call to Insert messages into AAD Loader Log Table.
2543 xla_aad_loader_util_pvt.insert_aadloaderlog(
2544 p_amb_context_code => g_amb_context_code,
2545 p_application_id => g_application_id,
2546 p_request_code => 'IMPORT' ,
2547 p_log_type_code => 'MERGE',
2548 p_encoded_message =>'# xla_product_rules_b updated : '||l_num_rows,
2549 p_component_code => 'merge_aads');
2550
2551 UPDATE xla_product_rules_tl w
2552 SET amb_context_code = g_amb_context_code
2553 WHERE application_id = g_application_id
2554 AND amb_context_code = g_staging_context_code
2555 AND NOT EXISTS (SELECT 1
2556 FROM xla_product_rules_tl s
2557 WHERE s.application_id = g_application_id
2558 AND s.amb_context_code = g_amb_context_code
2559 AND s.product_rule_type_code = w.product_rule_type_code
2560 AND s.name = w.name
2561 AND s.language = w.language);
2562 l_num_rows := SQL%ROWCOUNT;
2563 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2564 trace(p_msg => '# xla_product_rules_tl 1 updated : '||l_num_rows,
2565 p_module => l_log_module,
2566 p_level => C_LEVEL_STATEMENT);
2567 END IF;
2568 -- Bug : 9923803
2569 -- API Call to Insert messages into AAD Loader Log Table.
2570 xla_aad_loader_util_pvt.insert_aadloaderlog(
2571 p_amb_context_code => g_amb_context_code,
2572 p_application_id => g_application_id,
2573 p_request_code => 'IMPORT' ,
2574 p_log_type_code => 'MERGE',
2575 p_encoded_message =>'# xla_product_rules_tl 1 updated : '||l_num_rows,
2576 p_component_code => 'merge_aads');
2577
2578 UPDATE xla_product_rules_tl w
2579 SET amb_context_code = g_amb_context_code
2580 , name = substr('('||product_rule_code||') '||name,1,80)
2581 WHERE application_id = g_application_id
2582 AND amb_context_code = g_staging_context_code
2583 AND EXISTS (SELECT 1
2584 FROM xla_product_rules_tl s
2585 WHERE s.application_id = g_application_id
2586 AND s.amb_context_code = g_amb_context_code
2587 AND s.product_rule_type_code = w.product_rule_type_code
2588 AND s.name = w.name
2589 AND s.language = w.language);
2590 l_num_rows := SQL%ROWCOUNT;
2591 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2592 trace(p_msg => '# xla_product_rules_tl 2 updated : '||l_num_rows,
2593 p_module => l_log_module,
2594 p_level => C_LEVEL_STATEMENT);
2595 END IF;
2596 -- Bug : 9923803
2597 -- API Call to Insert messages into AAD Loader Log Table.
2598 xla_aad_loader_util_pvt.insert_aadloaderlog(
2599 p_amb_context_code => g_amb_context_code,
2600 p_application_id => g_application_id,
2601 p_request_code => 'IMPORT' ,
2602 p_log_type_code => 'MERGE',
2603 p_encoded_message =>'# xla_product_rules_tl 2 updated : '||l_num_rows,
2604 p_component_code => 'merge_aads');
2605 UPDATE xla_prod_acct_headers
2606 SET amb_context_code = g_amb_context_code
2607 WHERE application_id = g_application_id
2608 AND amb_context_code = g_staging_context_code;
2609 l_num_rows := SQL%ROWCOUNT;
2610 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2611 trace(p_msg => '# xla_prod_acct_headers updated : '||l_num_rows,
2612 p_module => l_log_module,
2613 p_level => C_LEVEL_STATEMENT);
2614 END IF;
2615 -- Bug : 9923803
2616 -- API Call to Insert messages into AAD Loader Log Table.
2617 xla_aad_loader_util_pvt.insert_aadloaderlog(
2618 p_amb_context_code => g_amb_context_code,
2619 p_application_id => g_application_id,
2620 p_request_code => 'IMPORT' ,
2621 p_log_type_code => 'MERGE',
2622 p_encoded_message =>'# xla_prod_acct_headers updated : '||l_num_rows,
2623 p_component_code => 'merge_aads');
2624
2625 UPDATE xla_aad_line_defn_assgns
2626 SET amb_context_code = g_amb_context_code
2627 WHERE application_id = g_application_id
2628 AND amb_context_code = g_staging_context_code;
2629 l_num_rows := SQL%ROWCOUNT;
2630 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2631 trace(p_msg => '# xla_aad_line_defn_assgns updated : '||l_num_rows,
2632 p_module => l_log_module,
2633 p_level => C_LEVEL_STATEMENT);
2634 END IF;
2635 -- Bug : 9923803
2636 -- API Call to Insert messages into AAD Loader Log Table.
2637 xla_aad_loader_util_pvt.insert_aadloaderlog(
2638 p_amb_context_code => g_amb_context_code,
2639 p_application_id => g_application_id,
2640 p_request_code => 'IMPORT' ,
2641 p_log_type_code => 'MERGE',
2642 p_encoded_message =>'# xla_aad_line_defn_assgns updated : '||l_num_rows,
2643 p_component_code => 'merge_aads');
2644
2645 UPDATE xla_aad_hdr_acct_attrs
2646 SET amb_context_code = g_amb_context_code
2647 WHERE application_id = g_application_id
2648 AND amb_context_code = g_staging_context_code;
2649 l_num_rows := SQL%ROWCOUNT;
2650 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2651 trace(p_msg => '# xla_aad_hdr_acct_attrs updated : '||l_num_rows,
2652 p_module => l_log_module,
2653 p_level => C_LEVEL_STATEMENT);
2654 END IF;
2655 -- Bug : 9923803
2656 -- API Call to Insert messages into AAD Loader Log Table.
2657 xla_aad_loader_util_pvt.insert_aadloaderlog(
2658 p_amb_context_code => g_amb_context_code,
2659 p_application_id => g_application_id,
2660 p_request_code => 'IMPORT' ,
2661 p_log_type_code => 'MERGE',
2662 p_encoded_message =>'# xla_aad_hdr_acct_attrs updated : '||l_num_rows,
2663 p_component_code => 'merge_aads');
2664
2665 UPDATE xla_aad_header_ac_assgns
2666 SET amb_context_code = g_amb_context_code
2667 WHERE application_id = g_application_id
2668 AND amb_context_code = g_staging_context_code;
2669 l_num_rows := SQL%ROWCOUNT;
2670 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2671 trace(p_msg => '# xla_aad_header_ac_assgns updated : '||l_num_rows,
2672 p_module => l_log_module,
2673 p_level => C_LEVEL_STATEMENT);
2674 END IF;
2675 -- Bug : 9923803
2676 -- API Call to Insert messages into AAD Loader Log Table.
2677 xla_aad_loader_util_pvt.insert_aadloaderlog(
2678 p_amb_context_code => g_amb_context_code,
2679 p_application_id => g_application_id,
2680 p_request_code => 'IMPORT' ,
2681 p_log_type_code => 'MERGE',
2682 p_encoded_message =>'# xla_aad_header_ac_assgns updated : '||l_num_rows,
2683 p_component_code => 'merge_aads');
2684 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2685 trace(p_msg => 'END of procedure merge_aads',
2686 p_module => l_log_module,
2687 p_level => C_LEVEL_PROCEDURE);
2688 END IF;
2689
2690 EXCEPTION
2691 WHEN OTHERS THEN
2692 xla_aad_loader_util_pvt.stack_error
2693 (p_appli_s_name => 'XLA'
2694 ,p_msg_name => 'XLA_COMMON_ERROR'
2695 ,p_token_1 => 'LOCATION'
2696 ,p_value_1 => 'xla_aad_merge_pvt.merge_aads'
2697 ,p_token_2 => 'ERROR'
2698 ,p_value_2 => 'unhandled exception');
2699 RAISE;
2700
2701 END merge_aads;
2702
2703
2704 --=============================================================================
2705 --
2706 -- Name: merge_journal_line_defns
2707 -- Description: Merge journal line definitions from staging to working area
2708 --
2709 --=============================================================================
2710 PROCEDURE merge_journal_line_defns
2711 IS
2712 l_log_module VARCHAR2(240);
2713 l_num_rows INTEGER;
2714 BEGIN
2715 IF g_log_enabled THEN
2716 l_log_module := C_DEFAULT_MODULE||'.merge_journal_line_defns';
2717 END IF;
2718
2719 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2720 trace(p_msg => 'BEGIN of procedure merge_journal_line_defns',
2721 p_module => l_log_module,
2722 p_level => C_LEVEL_PROCEDURE);
2723 END IF;
2724
2725 /*************************************************/
2726 /**** Added by krsankar for Performance changes **/
2727 /*************************************************/
2728
2729 INSERT INTO xla_aads_gt
2730 ( event_class_code,
2731 event_type_code,
2732 line_definition_code,
2733 table_name
2734 )
2735 select event_class_code,
2736 event_type_code,
2737 line_definition_code,
2738 'XLA_LINE_DEFINITIONS_B'
2739 from
2740 (select event_class_code,
2741 event_type_code,
2742 line_definition_code,
2743 'XLA_LINE_DEFINITIONS_B',
2744 amb_context_code,
2745 last_update_date ,
2746 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
2747 from
2748 (select event_class_code,
2749 event_type_code,
2750 line_definition_code,
2751 'XLA_LINE_DEFINITIONS_B',
2752 amb_context_code,
2753 last_update_date ,
2754 lag(last_update_date) over (PARTITION by application_id,
2755 event_class_code,
2756 event_type_code,
2757 line_definition_code,
2758 line_definition_owner_code
2759 order by amb_context_code
2760 ) lag_date
2761 from xla_line_definitions_b
2762 order by amb_context_code
2763 ) x
2764 where x.amb_context_code =g_staging_context_code
2765 )
2766 where flag = 'False';
2767 l_num_rows := SQL%ROWCOUNT;
2768
2769 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2770 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_line_definitions_b is :'||l_num_rows,
2771 p_module => l_log_module,
2772 p_level => C_LEVEL_PROCEDURE);
2773 END IF;
2774 -- Bug : 9923803
2775 -- API Call to Insert messages into AAD Loader Log Table.
2776 xla_aad_loader_util_pvt.insert_aadloaderlog(
2777 p_amb_context_code => g_amb_context_code,
2778 p_application_id => g_application_id,
2779 p_request_code => 'IMPORT' ,
2780 p_log_type_code => 'MERGE',
2781 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_line_definitions_b is :'||l_num_rows,
2782 p_component_code => 'merge_journal_line_defns');
2783
2784 INSERT INTO xla_aads_gt
2785 ( event_class_code,
2786 event_type_code,
2787 line_definition_code,
2788 accounting_line_code,
2789 table_name
2790 )
2791 select event_class_code,
2792 event_type_code,
2793 line_definition_code,
2794 accounting_line_code,
2795 'XLA_LINE_DEFN_JLT_ASSGNS'
2796 from
2797 (select event_class_code,
2798 event_type_code,
2799 line_definition_code,
2800 accounting_line_code,
2801 'XLA_LINE_DEFN_JLT_ASSGNS',
2802 amb_context_code,
2803 last_update_date ,
2804 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
2805 from
2806 (select event_class_code,
2807 event_type_code,
2808 line_definition_code,
2809 accounting_line_code,
2810 'XLA_LINE_DEFN_JLT_ASSGNS',
2811 amb_context_code,
2812 last_update_date ,
2813 lag(last_update_date) over (PARTITION by application_id,
2814 event_class_code,
2815 event_type_code,
2816 line_definition_code,
2817 line_definition_owner_code,
2818 accounting_line_code,
2819 accounting_line_type_code
2820 order by amb_context_code
2821 ) lag_date
2822 from XLA_LINE_DEFN_JLT_ASSGNS
2823 order by amb_context_code
2824 ) x
2825 where x.amb_context_code =g_staging_context_code
2826 )
2827 where flag = 'False';
2828 l_num_rows := SQL%ROWCOUNT;
2829
2830 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2831 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_line_defn_jlt_assgns is :'||l_num_rows,
2832 p_module => l_log_module,
2833 p_level => C_LEVEL_PROCEDURE);
2834 END IF;
2835 -- Bug : 9923803
2836 -- API Call to Insert messages into AAD Loader Log Table.
2837 xla_aad_loader_util_pvt.insert_aadloaderlog(
2838 p_amb_context_code => g_amb_context_code,
2839 p_application_id => g_application_id,
2840 p_request_code => 'IMPORT' ,
2841 p_log_type_code => 'MERGE',
2842 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_line_defn_jlt_assgns is :'||l_num_rows,
2843 p_component_code => 'merge_journal_line_defns');
2844
2845 INSERT INTO xla_aads_gt
2846 ( event_class_code,
2847 event_type_code,
2848 line_definition_code,
2849 accounting_line_code,
2850 segment_rule_code,
2851 table_name
2852 )
2853 select event_class_code,
2854 event_type_code,
2855 line_definition_code,
2856 accounting_line_code,
2857 segment_rule_code,
2858 'XLA_LINE_DEFN_ADR_ASSGNS'
2859 from
2860 (select event_class_code,
2861 event_type_code,
2862 line_definition_code,
2863 accounting_line_code,
2864 segment_rule_code,
2865 'XLA_LINE_DEFN_ADR_ASSGNS',
2866 amb_context_code,
2867 last_update_date ,
2868 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
2869 from
2870 (select event_class_code,
2871 event_type_code,
2872 line_definition_code,
2873 accounting_line_code,
2874 segment_rule_code,
2875 'XLA_LINE_DEFN_ADR_ASSGNS',
2876 amb_context_code,
2877 last_update_date,
2878 lag(last_update_date) over (PARTITION by application_id,
2879 event_class_code,
2880 event_type_code,
2881 line_definition_code,
2882 line_definition_owner_code,
2883 accounting_line_code,
2884 accounting_line_type_code,
2885 segment_rule_code,
2886 segment_rule_type_code
2887 order by amb_context_code
2888 ) lag_date
2889 from XLA_LINE_DEFN_ADR_ASSGNS
2890 order by amb_context_code
2891 ) x
2892 where x.amb_context_code = g_staging_context_code
2893 )
2894 where flag = 'False';
2895 l_num_rows := SQL%ROWCOUNT;
2896 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2897 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_line_defn_adr_assgns is :'||l_num_rows,
2898 p_module => l_log_module,
2899 p_level => C_LEVEL_PROCEDURE);
2900 END IF;
2901 -- Bug : 9923803
2902 -- API Call to Insert messages into AAD Loader Log Table.
2903 xla_aad_loader_util_pvt.insert_aadloaderlog(
2904 p_amb_context_code => g_amb_context_code,
2905 p_application_id => g_application_id,
2906 p_request_code => 'IMPORT' ,
2907 p_log_type_code => 'MERGE',
2908 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_line_defn_adr_assgns is :'||l_num_rows,
2909 p_component_code => 'merge_journal_line_defns');
2910
2911 INSERT INTO xla_aads_gt
2912 ( event_class_code,
2913 event_type_code,
2914 line_definition_code,
2915 accounting_line_code,
2916 analytical_criterion_code,
2917 table_name
2918 )
2919 select event_class_code,
2920 event_type_code,
2921 line_definition_code,
2922 accounting_line_code,
2923 analytical_criterion_code,
2924 'XLA_LINE_DEFN_AC_ASSGNS'
2925 from
2926 (select event_class_code,
2927 event_type_code,
2928 line_definition_code,
2929 accounting_line_code,
2930 analytical_criterion_code,
2931 'XLA_LINE_DEFN_AC_ASSGNS',
2932 amb_context_code,
2933 last_update_date ,
2934 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
2935 from
2936 (select event_class_code,
2937 event_type_code,
2938 line_definition_code,
2939 accounting_line_code,
2940 analytical_criterion_code,
2941 'XLA_LINE_DEFN_AC_ASSGNS',
2942 amb_context_code,
2943 last_update_date ,
2944 lag(last_update_date) over (PARTITION by application_id,
2945 event_class_code,
2946 event_type_code,
2947 line_definition_code,
2948 line_definition_owner_code,
2949 accounting_line_code,
2950 accounting_line_type_code,
2951 analytical_criterion_code,
2952 analytical_criterion_type_code
2953 order by amb_context_code
2954 ) lag_date
2955 from XLA_LINE_DEFN_AC_ASSGNS
2956 order by amb_context_code
2957 ) x
2958 where x.amb_context_code = g_staging_context_code
2959 )
2960 where flag = 'False';
2961 l_num_rows := SQL%ROWCOUNT;
2962
2963 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2964 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_line_defn_ac_assgns is :'||l_num_rows,
2965 p_module => l_log_module,
2966 p_level => C_LEVEL_PROCEDURE);
2967 END IF;
2968 -- Bug : 9923803
2969 -- API Call to Insert messages into AAD Loader Log Table.
2970 xla_aad_loader_util_pvt.insert_aadloaderlog(
2971 p_amb_context_code => g_amb_context_code,
2972 p_application_id => g_application_id,
2973 p_request_code => 'IMPORT' ,
2974 p_log_type_code => 'MERGE',
2975 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_line_defn_ac_assgns is :'||l_num_rows,
2976 p_component_code => 'merge_journal_line_defns');
2977
2978 INSERT INTO xla_aads_gt
2979 ( event_class_code
2980 ,event_type_code
2981 ,line_definition_code
2982 ,accounting_line_code
2983 ,mpa_accounting_line_code
2984 ,table_name
2985 )
2986 select mpa_jlt_assgns.event_class_code
2987 ,mpa_jlt_assgns.event_type_code
2988 ,mpa_jlt_assgns.line_definition_code
2989 ,mpa_jlt_assgns.accounting_line_code
2990 ,mpa_jlt_assgns.mpa_accounting_line_code
2991 ,'XLA_MPA_JLT_ASSGNS'
2992 from XLA_MPA_JLT_ASSGNS mpa_jlt_assgns
2993 where mpa_jlt_assgns.application_id = g_application_id
2994 and mpa_jlt_assgns.amb_context_code = g_staging_context_code
2995 AND EXISTS (
2996 SELECT 1
2997 FROM xla_acct_line_types_b xal
2998 WHERE xal.application_id = g_application_id
2999 AND xal.amb_context_code = g_staging_context_code
3000 AND xal.event_class_code = mpa_jlt_assgns.event_class_code
3001 AND xal.accounting_line_type_code = mpa_jlt_assgns.accounting_line_type_code
3002 AND xal.accounting_line_code = mpa_jlt_assgns.accounting_line_code
3003 AND xal.mpa_option_code = 'ACCRUAL')
3004 AND (EXISTS (SELECT 1
3005 FROM XLA_MPA_JLT_ASSGNS mpa_jlt_assgns1
3006 WHERE mpa_jlt_assgns.event_class_code = mpa_jlt_assgns1.event_class_code
3007 and mpa_jlt_assgns.event_type_code = mpa_jlt_assgns1.event_type_code
3008 and mpa_jlt_assgns.line_definition_code = mpa_jlt_assgns1.line_definition_code
3009 and mpa_jlt_assgns.line_definition_owner_code = mpa_jlt_assgns1.line_definition_owner_code
3010 and mpa_jlt_assgns.accounting_line_code = mpa_jlt_assgns1.accounting_line_code
3011 and mpa_jlt_assgns.accounting_line_type_code = mpa_jlt_assgns1.accounting_line_type_code
3012 and mpa_jlt_assgns.mpa_accounting_line_code = mpa_jlt_assgns1.mpa_accounting_line_code
3013 and mpa_jlt_assgns.mpa_accounting_line_type_code = mpa_jlt_assgns1.mpa_accounting_line_type_code
3014 and mpa_jlt_assgns.application_id = mpa_jlt_assgns1.application_id
3015 and mpa_jlt_assgns1.amb_context_code = g_amb_context_code
3016 and to_char(mpa_jlt_assgns.last_update_date,'DD-MON-YYYY') <> to_char(mpa_jlt_assgns1.last_update_date,'DD-MON-YYYY')
3017 )
3018 OR
3019 NOT EXISTS (SELECT 1
3020 FROM XLA_MPA_JLT_ASSGNS mpa_jlt_assgns1
3021 WHERE mpa_jlt_assgns.event_class_code = mpa_jlt_assgns1.event_class_code
3022 and mpa_jlt_assgns.event_type_code = mpa_jlt_assgns1.event_type_code
3023 and mpa_jlt_assgns.line_definition_code = mpa_jlt_assgns1.line_definition_code
3024 and mpa_jlt_assgns.line_definition_owner_code = mpa_jlt_assgns1.line_definition_owner_code
3025 and mpa_jlt_assgns.accounting_line_code = mpa_jlt_assgns1.accounting_line_code
3026 and mpa_jlt_assgns.accounting_line_type_code = mpa_jlt_assgns1.accounting_line_type_code
3027 and mpa_jlt_assgns.mpa_accounting_line_code = mpa_jlt_assgns1.mpa_accounting_line_code
3028 and mpa_jlt_assgns.mpa_accounting_line_type_code = mpa_jlt_assgns1.mpa_accounting_line_type_code
3029 and mpa_jlt_assgns.application_id = mpa_jlt_assgns1.application_id
3030 and mpa_jlt_assgns1.amb_context_code = g_amb_context_code
3031 )
3032 );
3033 l_num_rows := SQL%ROWCOUNT;
3034 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3035 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_mpa_jlt_assgns is :'||l_num_rows,
3036 p_module => l_log_module,
3037 p_level => C_LEVEL_PROCEDURE);
3038 END IF;
3039 -- Bug : 9923803
3040 -- API Call to Insert messages into AAD Loader Log Table.
3041 xla_aad_loader_util_pvt.insert_aadloaderlog(
3042 p_amb_context_code => g_amb_context_code,
3043 p_application_id => g_application_id,
3044 p_request_code => 'IMPORT' ,
3045 p_log_type_code => 'MERGE',
3046 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_mpa_jlt_assgns is :'||l_num_rows,
3047 p_component_code => 'merge_journal_line_defns');
3048
3049 INSERT INTO xla_aads_gt
3050 ( event_class_code
3051 ,event_type_code
3052 ,line_definition_code
3053 ,accounting_line_code
3054 ,analytical_criterion_code
3055 ,table_name
3056 )
3057 select mpa_hdr_ac_assgns.event_class_code
3058 ,mpa_hdr_ac_assgns.event_type_code
3059 ,mpa_hdr_ac_assgns.line_definition_code
3060 ,mpa_hdr_ac_assgns.accounting_line_code
3061 ,mpa_hdr_ac_assgns.analytical_criterion_code
3062 ,'XLA_MPA_HEADER_AC_ASSGNS'
3063 from XLA_MPA_HEADER_AC_ASSGNS mpa_hdr_ac_assgns
3064 where mpa_hdr_ac_assgns.application_id = g_application_id
3065 and mpa_hdr_ac_assgns.amb_context_code = g_staging_context_code
3066 and (EXISTS(SELECT 1
3067 FROM XLA_MPA_HEADER_AC_ASSGNS mpa_hdr_ac_assgns1
3068 WHERE mpa_hdr_ac_assgns.event_class_code = mpa_hdr_ac_assgns1.event_class_code
3069 and mpa_hdr_ac_assgns.event_type_code = mpa_hdr_ac_assgns1.event_type_code
3070 and mpa_hdr_ac_assgns.line_definition_code = mpa_hdr_ac_assgns1.line_definition_code
3071 and mpa_hdr_ac_assgns.line_definition_owner_code = mpa_hdr_ac_assgns1.line_definition_owner_code
3072 and mpa_hdr_ac_assgns.accounting_line_code = mpa_hdr_ac_assgns1.accounting_line_code
3073 and mpa_hdr_ac_assgns.accounting_line_type_code = mpa_hdr_ac_assgns1.accounting_line_type_code
3074 and mpa_hdr_ac_assgns.analytical_criterion_code = mpa_hdr_ac_assgns1.analytical_criterion_code
3075 and mpa_hdr_ac_assgns.analytical_criterion_type_code = mpa_hdr_ac_assgns1.analytical_criterion_type_code
3076 and mpa_hdr_ac_assgns.application_id = mpa_hdr_ac_assgns1.application_id
3077 and mpa_hdr_ac_assgns1.amb_context_code = g_amb_context_code
3078 and to_char(mpa_hdr_ac_assgns.last_update_date,'DD-MON-YYYY') <> to_char(mpa_hdr_ac_assgns1.last_update_date,'DD-MON-YYYY')
3079 UNION
3080 SELECT 1
3081 FROM xla_acct_line_types_b s
3082 WHERE s.application_id = g_application_id
3083 and s.amb_context_code = g_staging_context_code
3084 and s.event_class_code = mpa_hdr_ac_assgns.event_class_code
3085 and s.accounting_line_type_code = mpa_hdr_ac_assgns.accounting_line_type_code
3086 and s.accounting_line_code = mpa_hdr_ac_assgns.accounting_line_code
3087 and s.mpa_option_code = 'NONE'
3088 )
3089 OR
3090 NOT EXISTS(SELECT 1
3091 FROM XLA_MPA_HEADER_AC_ASSGNS mpa_hdr_ac_assgns1
3092 WHERE mpa_hdr_ac_assgns.event_class_code = mpa_hdr_ac_assgns1.event_class_code
3093 and mpa_hdr_ac_assgns.event_type_code = mpa_hdr_ac_assgns1.event_type_code
3094 and mpa_hdr_ac_assgns.line_definition_code = mpa_hdr_ac_assgns1.line_definition_code
3095 and mpa_hdr_ac_assgns.line_definition_owner_code = mpa_hdr_ac_assgns1.line_definition_owner_code
3096 and mpa_hdr_ac_assgns.accounting_line_code = mpa_hdr_ac_assgns1.accounting_line_code
3097 and mpa_hdr_ac_assgns.accounting_line_type_code = mpa_hdr_ac_assgns1.accounting_line_type_code
3098 and mpa_hdr_ac_assgns.analytical_criterion_code = mpa_hdr_ac_assgns1.analytical_criterion_code
3099 and mpa_hdr_ac_assgns.analytical_criterion_type_code = mpa_hdr_ac_assgns1.analytical_criterion_type_code
3100 and mpa_hdr_ac_assgns.application_id = mpa_hdr_ac_assgns1.application_id
3101 and mpa_hdr_ac_assgns1.amb_context_code = g_amb_context_code
3102 UNION
3103 SELECT 1
3104 FROM xla_acct_line_types_b s
3105 WHERE s.application_id = g_application_id
3106 and s.amb_context_code = g_staging_context_code
3107 and s.event_class_code = mpa_hdr_ac_assgns.event_class_code
3108 and s.accounting_line_type_code = mpa_hdr_ac_assgns.accounting_line_type_code
3109 and s.accounting_line_code = mpa_hdr_ac_assgns.accounting_line_code
3110 and s.mpa_option_code = 'NONE'
3111 )
3112 );
3113 l_num_rows := SQL%ROWCOUNT;
3114 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3115 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_mpa_header_ac_assgns is :'||l_num_rows,
3116 p_module => l_log_module,
3117 p_level => C_LEVEL_PROCEDURE);
3118 END IF;
3119 -- Bug : 9923803
3120 -- API Call to Insert messages into AAD Loader Log Table.
3121 xla_aad_loader_util_pvt.insert_aadloaderlog(
3122 p_amb_context_code => g_amb_context_code,
3123 p_application_id => g_application_id,
3124 p_request_code => 'IMPORT' ,
3125 p_log_type_code => 'MERGE',
3126 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_mpa_header_ac_assgns is :'||l_num_rows,
3127 p_component_code => 'merge_journal_line_defns');
3128
3129 INSERT INTO xla_aads_gt
3130 (
3131 event_class_code
3132 ,event_type_code
3133 ,line_definition_code
3134 ,accounting_line_code
3135 ,mpa_accounting_line_code
3136 ,segment_rule_code
3137 ,table_name
3138 )
3139 select mpa_jlt_adr_assgns.event_class_code
3140 ,mpa_jlt_adr_assgns.event_type_code
3141 ,mpa_jlt_adr_assgns.line_definition_code
3142 ,mpa_jlt_adr_assgns.accounting_line_code
3143 ,mpa_jlt_adr_assgns.mpa_accounting_line_code
3144 ,mpa_jlt_adr_assgns.segment_rule_code
3145 ,'XLA_MPA_JLT_ADR_ASSGNS'
3146 from XLA_MPA_JLT_ADR_ASSGNS mpa_jlt_adr_assgns
3147 where mpa_jlt_adr_assgns.application_id = g_application_id
3148 and mpa_jlt_adr_assgns.amb_context_code = g_staging_context_code
3149 and EXISTS ( SELECT 1
3150 FROM xla_mpa_jlt_assgns s
3151 WHERE s.application_id = g_application_id
3152 AND s.amb_context_code = g_staging_context_code
3153 AND s.event_class_code = mpa_jlt_adr_assgns.event_class_code
3154 AND s.event_type_code = mpa_jlt_adr_assgns.event_type_code
3155 AND s.line_definition_owner_code = mpa_jlt_adr_assgns.line_definition_owner_code
3156 AND s.line_definition_code = mpa_jlt_adr_assgns.line_definition_code
3157 AND s.accounting_line_type_code = mpa_jlt_adr_assgns.accounting_line_type_code
3158 AND s.accounting_line_code = mpa_jlt_adr_assgns.accounting_line_code
3159 AND s.mpa_accounting_line_type_code = mpa_jlt_adr_assgns.mpa_accounting_line_type_code
3160 AND s.mpa_accounting_line_code = mpa_jlt_adr_assgns.mpa_accounting_line_code
3161 UNION
3162 SELECT 1
3163 FROM xla_acct_line_types_b s
3164 WHERE s.application_id = g_application_id
3165 AND s.amb_context_code = g_staging_context_code
3166 AND s.event_class_code = mpa_jlt_adr_assgns.event_class_code
3167 AND s.accounting_line_type_code = mpa_jlt_adr_assgns.accounting_line_type_code
3168 AND s.accounting_line_code = mpa_jlt_adr_assgns.accounting_line_code
3169 AND s.mpa_option_code = 'NONE')
3170 and (EXISTS(SELECT 1
3171 FROM XLA_MPA_JLT_ADR_ASSGNS mpa_jlt_adr_assgns1
3172 WHERE mpa_jlt_adr_assgns.event_class_code = mpa_jlt_adr_assgns1.event_class_code
3173 and mpa_jlt_adr_assgns.event_type_code = mpa_jlt_adr_assgns1.event_type_code
3174 and mpa_jlt_adr_assgns.line_definition_code = mpa_jlt_adr_assgns1.line_definition_code
3175 and mpa_jlt_adr_assgns.line_definition_owner_code = mpa_jlt_adr_assgns1.line_definition_owner_code
3176 and mpa_jlt_adr_assgns.accounting_line_code = mpa_jlt_adr_assgns1.accounting_line_code
3177 and mpa_jlt_adr_assgns.accounting_line_type_code = mpa_jlt_adr_assgns1.accounting_line_type_code
3178 and mpa_jlt_adr_assgns.mpa_accounting_line_code = mpa_jlt_adr_assgns1.mpa_accounting_line_code
3179 and mpa_jlt_adr_assgns.mpa_accounting_line_type_code = mpa_jlt_adr_assgns1.mpa_accounting_line_type_code
3180 and mpa_jlt_adr_assgns.segment_rule_code = mpa_jlt_adr_assgns1.segment_rule_code
3181 and mpa_jlt_adr_assgns.segment_rule_type_code = mpa_jlt_adr_assgns1.segment_rule_type_code
3182 and mpa_jlt_adr_assgns.application_id = mpa_jlt_adr_assgns1.application_id
3183 and mpa_jlt_adr_assgns1.amb_context_code = g_amb_context_code
3184 and to_char(mpa_jlt_adr_assgns.last_update_date,'DD-MON-YYYY') <> to_char(mpa_jlt_adr_assgns1.last_update_date,'DD-MON-YYYY')
3185 )
3186 OR
3187 NOT EXISTS(SELECT 1
3188 FROM XLA_MPA_JLT_ADR_ASSGNS mpa_jlt_adr_assgns1
3189 WHERE mpa_jlt_adr_assgns.event_class_code = mpa_jlt_adr_assgns1.event_class_code
3190 and mpa_jlt_adr_assgns.event_type_code = mpa_jlt_adr_assgns1.event_type_code
3191 and mpa_jlt_adr_assgns.line_definition_code = mpa_jlt_adr_assgns1.line_definition_code
3192 and mpa_jlt_adr_assgns.line_definition_owner_code = mpa_jlt_adr_assgns1.line_definition_owner_code
3193 and mpa_jlt_adr_assgns.accounting_line_code = mpa_jlt_adr_assgns1.accounting_line_code
3194 and mpa_jlt_adr_assgns.accounting_line_type_code = mpa_jlt_adr_assgns1.accounting_line_type_code
3195 and mpa_jlt_adr_assgns.mpa_accounting_line_code = mpa_jlt_adr_assgns1.mpa_accounting_line_code
3196 and mpa_jlt_adr_assgns.mpa_accounting_line_type_code = mpa_jlt_adr_assgns1.mpa_accounting_line_type_code
3197 and mpa_jlt_adr_assgns.segment_rule_code = mpa_jlt_adr_assgns1.segment_rule_code
3198 and mpa_jlt_adr_assgns.segment_rule_type_code = mpa_jlt_adr_assgns1.segment_rule_type_code
3199 and mpa_jlt_adr_assgns.application_id = mpa_jlt_adr_assgns1.application_id
3200 and mpa_jlt_adr_assgns1.amb_context_code = g_amb_context_code
3201 )
3202 );
3203 l_num_rows := SQL%ROWCOUNT;
3204 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3205 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_mpa_jlt_adr_assgns is :'||l_num_rows,
3206 p_module => l_log_module,
3207 p_level => C_LEVEL_PROCEDURE);
3208 END IF;
3209 -- Bug : 9923803
3210 -- API Call to Insert messages into AAD Loader Log Table.
3211 xla_aad_loader_util_pvt.insert_aadloaderlog(
3212 p_amb_context_code => g_amb_context_code,
3213 p_application_id => g_application_id,
3214 p_request_code => 'IMPORT' ,
3215 p_log_type_code => 'MERGE',
3216 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_mpa_jlt_adr_assgns is :'||l_num_rows,
3217 p_component_code => 'merge_journal_line_defns');
3218
3219 INSERT INTO xla_aads_gt
3220 ( event_class_code
3221 ,event_type_code
3222 ,line_definition_code
3223 ,accounting_line_code
3224 ,mpa_accounting_line_code
3225 ,analytical_criterion_code
3226 ,table_name
3227 )
3228 select mpa_jlt_ac_assgns.event_class_code
3229 ,mpa_jlt_ac_assgns.event_type_code
3230 ,mpa_jlt_ac_assgns.line_definition_code
3231 ,mpa_jlt_ac_assgns.accounting_line_code
3232 ,mpa_jlt_ac_assgns.mpa_accounting_line_code
3233 ,mpa_jlt_ac_assgns.analytical_criterion_code
3234 ,'XLA_MPA_JLT_AC_ASSGNS'
3235 from XLA_MPA_JLT_AC_ASSGNS mpa_jlt_ac_assgns
3236 where mpa_jlt_ac_assgns.application_id = g_application_id
3237 and mpa_jlt_ac_assgns.amb_context_code = g_staging_context_code
3238 and (EXISTS(SELECT 1
3239 FROM XLA_MPA_JLT_AC_ASSGNS mpa_jlt_ac_assgns1
3240 WHERE mpa_jlt_ac_assgns.event_class_code = mpa_jlt_ac_assgns1.event_class_code
3241 and mpa_jlt_ac_assgns.event_type_code = mpa_jlt_ac_assgns1.event_type_code
3242 and mpa_jlt_ac_assgns.line_definition_code = mpa_jlt_ac_assgns1.line_definition_code
3243 and mpa_jlt_ac_assgns.line_definition_owner_code = mpa_jlt_ac_assgns1.line_definition_owner_code
3244 and mpa_jlt_ac_assgns.accounting_line_code = mpa_jlt_ac_assgns1.accounting_line_code
3245 and mpa_jlt_ac_assgns.accounting_line_type_code = mpa_jlt_ac_assgns1.accounting_line_type_code
3246 and mpa_jlt_ac_assgns.mpa_accounting_line_code = mpa_jlt_ac_assgns1.mpa_accounting_line_code
3247 and mpa_jlt_ac_assgns.mpa_accounting_line_type_code = mpa_jlt_ac_assgns1.mpa_accounting_line_type_code
3248 and mpa_jlt_ac_assgns.analytical_criterion_code = mpa_jlt_ac_assgns1.analytical_criterion_code
3249 and mpa_jlt_ac_assgns.analytical_criterion_type_code = mpa_jlt_ac_assgns1.analytical_criterion_type_code
3250 and mpa_jlt_ac_assgns.application_id = mpa_jlt_ac_assgns1.application_id
3251 and mpa_jlt_ac_assgns1.amb_context_code = g_amb_context_code
3252 and to_char(mpa_jlt_ac_assgns.last_update_date,'DD-MON-YYYY') <> to_char(mpa_jlt_ac_assgns1.last_update_date,'DD-MON-YYYY')
3253 UNION
3254 SELECT 1
3255 FROM xla_acct_line_types_b s
3256 WHERE s.application_id = g_application_id
3257 and s.amb_context_code = g_staging_context_code
3258 and s.event_class_code = mpa_jlt_ac_assgns.event_class_code
3259 and s.accounting_line_type_code = mpa_jlt_ac_assgns.accounting_line_type_code
3260 and s.accounting_line_code = mpa_jlt_ac_assgns.accounting_line_code
3261 and s.mpa_option_code = 'NONE'
3262 )
3263 OR
3264 NOT EXISTS(SELECT 1
3265 FROM XLA_MPA_JLT_AC_ASSGNS mpa_jlt_ac_assgns1
3266 WHERE mpa_jlt_ac_assgns.event_class_code = mpa_jlt_ac_assgns1.event_class_code
3267 and mpa_jlt_ac_assgns.event_type_code = mpa_jlt_ac_assgns1.event_type_code
3268 and mpa_jlt_ac_assgns.line_definition_code = mpa_jlt_ac_assgns1.line_definition_code
3269 and mpa_jlt_ac_assgns.line_definition_owner_code = mpa_jlt_ac_assgns1.line_definition_owner_code
3270 and mpa_jlt_ac_assgns.accounting_line_code = mpa_jlt_ac_assgns1.accounting_line_code
3271 and mpa_jlt_ac_assgns.accounting_line_type_code = mpa_jlt_ac_assgns1.accounting_line_type_code
3272 and mpa_jlt_ac_assgns.mpa_accounting_line_code = mpa_jlt_ac_assgns1.mpa_accounting_line_code
3273 and mpa_jlt_ac_assgns.mpa_accounting_line_type_code = mpa_jlt_ac_assgns1.mpa_accounting_line_type_code
3274 and mpa_jlt_ac_assgns.analytical_criterion_code = mpa_jlt_ac_assgns1.analytical_criterion_code
3275 and mpa_jlt_ac_assgns.analytical_criterion_type_code = mpa_jlt_ac_assgns1.analytical_criterion_type_code
3276 and mpa_jlt_ac_assgns.application_id = mpa_jlt_ac_assgns1.application_id
3277 and mpa_jlt_ac_assgns1.amb_context_code = g_amb_context_code
3278 UNION
3279 SELECT 1
3280 FROM xla_acct_line_types_b s
3281 WHERE s.application_id = g_application_id
3282 and s.amb_context_code = g_staging_context_code
3283 and s.event_class_code = mpa_jlt_ac_assgns.event_class_code
3284 and s.accounting_line_type_code = mpa_jlt_ac_assgns.accounting_line_type_code
3285 and s.accounting_line_code = mpa_jlt_ac_assgns.accounting_line_code
3286 and s.mpa_option_code = 'NONE'
3287 )
3288 );
3289 l_num_rows := SQL%ROWCOUNT;
3290 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3291 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_mpa_jlt_ac_assgns is :'||l_num_rows,
3292 p_module => l_log_module,
3293 p_level => C_LEVEL_PROCEDURE);
3294 END IF;
3295 -- Bug : 9923803
3296 -- API Call to Insert messages into AAD Loader Log Table.
3297 xla_aad_loader_util_pvt.insert_aadloaderlog(
3298 p_amb_context_code => g_amb_context_code,
3299 p_application_id => g_application_id,
3300 p_request_code => 'IMPORT' ,
3301 p_log_type_code => 'MERGE',
3302 p_encoded_message =>'Number of Rows inserted into aads_gt from xla_mpa_jlt_ac_assgns is :'||l_num_rows,
3303 p_component_code => 'merge_journal_line_defns');
3304
3305 IF (g_analyzed_flag = 'Y') THEN
3306 null;
3307
3308 ELSE
3309
3310 -- Delete the journal line definitions from the working area if it already
3311 -- exists in the staging area
3312 DELETE FROM xla_line_definitions_b w
3313 WHERE application_id = g_application_id
3314 AND amb_context_code = g_amb_context_code
3315 AND EXISTS (SELECT 1
3316 FROM xla_line_definitions_b s
3317 WHERE s.application_id = g_application_id
3318 AND s.amb_context_code = g_staging_context_code
3319 AND s.event_class_code = w.event_class_code
3320 AND s.event_type_code = w.event_type_code
3321 AND s.line_definition_owner_code = w.line_definition_owner_code
3322 AND s.line_definition_code = w.line_definition_code);
3323 l_num_rows := SQL%ROWCOUNT;
3324 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3325 trace(p_msg => '# xla_line_definitions_b deleted : '||l_num_rows,
3326 p_module => l_log_module,
3327 p_level => C_LEVEL_STATEMENT);
3328 END IF;
3329 -- Bug : 9923803
3330 -- API Call to Insert messages into AAD Loader Log Table.
3331 xla_aad_loader_util_pvt.insert_aadloaderlog(
3332 p_amb_context_code => g_amb_context_code,
3333 p_application_id => g_application_id,
3334 p_request_code => 'IMPORT' ,
3335 p_log_type_code => 'MERGE',
3336 p_encoded_message =>'# xla_line_definitions_b deleted : '||l_num_rows,
3337 p_component_code => 'merge_journal_line_defns');
3338
3339 DELETE FROM xla_line_definitions_tl w
3340 WHERE application_id = g_application_id
3341 AND amb_context_code = g_amb_context_code
3342 AND EXISTS (SELECT 1
3343 FROM xla_line_definitions_tl s
3344 WHERE s.application_id = g_application_id
3345 AND s.amb_context_code = g_staging_context_code
3346 AND s.event_class_code = w.event_class_code
3347 AND s.event_type_code = w.event_type_code
3348 AND s.line_definition_owner_code = w.line_definition_owner_code
3349 AND s.line_definition_code = w.line_definition_code
3350 AND s.language = w.language);
3351 l_num_rows := SQL%ROWCOUNT;
3352 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3353 trace(p_msg => '# xla_line_definitions_tl deleted : '||l_num_rows,
3354 p_module => l_log_module,
3355 p_level => C_LEVEL_STATEMENT);
3356 END IF;
3357 -- Bug : 9923803
3358 -- API Call to Insert messages into AAD Loader Log Table.
3359 xla_aad_loader_util_pvt.insert_aadloaderlog(
3360 p_amb_context_code => g_amb_context_code,
3361 p_application_id => g_application_id,
3362 p_request_code => 'IMPORT' ,
3363 p_log_type_code => 'MERGE',
3364 p_encoded_message =>'# xla_line_definitions_tl deleted : '||l_num_rows,
3365 p_component_code => 'merge_journal_line_defns');
3366
3367 DELETE FROM xla_line_defn_jlt_assgns w
3368 WHERE application_id = g_application_id
3369 AND amb_context_code = g_amb_context_code
3370 AND EXISTS (SELECT 1
3371 FROM xla_line_defn_jlt_assgns s
3372 WHERE s.application_id = g_application_id
3373 AND s.amb_context_code = g_staging_context_code
3374 AND s.event_class_code = w.event_class_code
3375 AND s.event_type_code = w.event_type_code
3376 AND s.line_definition_owner_code = w.line_definition_owner_code
3377 AND s.line_definition_code = w.line_definition_code
3378 AND s.accounting_line_type_code = w.accounting_line_type_code
3379 AND s.accounting_line_code = w.accounting_line_code);
3380
3381 l_num_rows := SQL%ROWCOUNT;
3382 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3383 trace(p_msg => '# xla_line_defn_jlt_assgns deleted : '||l_num_rows,
3384 p_module => l_log_module,
3385 p_level => C_LEVEL_STATEMENT);
3386 END IF;
3387 -- Bug : 9923803
3388 -- API Call to Insert messages into AAD Loader Log Table.
3389 xla_aad_loader_util_pvt.insert_aadloaderlog(
3390 p_amb_context_code => g_amb_context_code,
3391 p_application_id => g_application_id,
3392 p_request_code => 'IMPORT' ,
3393 p_log_type_code => 'MERGE',
3394 p_encoded_message =>'# xla_line_defn_jlt_assgns deleted : '||l_num_rows,
3395 p_component_code => 'merge_journal_line_defns');
3396
3397 -- ADR assignment is not merged, but overwritten, if the JLD exists in the
3398 -- staging area.
3399 DELETE FROM xla_line_defn_adr_assgns w
3400 WHERE application_id = g_application_id
3401 AND amb_context_code = g_amb_context_code
3402 AND EXISTS (SELECT 1
3403 FROM xla_line_defn_jlt_assgns s
3404 WHERE s.application_id = g_application_id
3405 AND s.amb_context_code = g_staging_context_code
3406 AND s.event_class_code = w.event_class_code
3407 AND s.event_type_code = w.event_type_code
3408 AND s.line_definition_owner_code = w.line_definition_owner_code
3409 AND s.line_definition_code = w.line_definition_code
3410 AND s.accounting_line_type_code = w.accounting_line_type_code
3411 AND s.accounting_line_code = w.accounting_line_code);
3412 --AND s.flexfield_segment_code = w.flexfield_segment_code);
3413 l_num_rows := SQL%ROWCOUNT;
3414
3415 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3416 trace(p_msg => '# xla_line_defn_adr_assgns deleted : '||l_num_rows,
3417 p_module => l_log_module,
3418 p_level => C_LEVEL_STATEMENT);
3419 END IF;
3420 -- Bug : 9923803
3421 -- API Call to Insert messages into AAD Loader Log Table.
3422 xla_aad_loader_util_pvt.insert_aadloaderlog(
3423 p_amb_context_code => g_amb_context_code,
3424 p_application_id => g_application_id,
3425 p_request_code => 'IMPORT' ,
3426 p_log_type_code => 'MERGE',
3427 p_encoded_message =>'# xla_line_defn_adr_assgns deleted : '||l_num_rows,
3428 p_component_code => 'merge_journal_line_defns');
3429
3430 DELETE FROM xla_line_defn_ac_assgns w
3431 WHERE application_id = g_application_id
3432 AND amb_context_code = g_amb_context_code
3433 AND EXISTS (SELECT 1
3434 FROM xla_line_defn_ac_assgns s
3435 WHERE s.application_id = g_application_id
3436 AND s.amb_context_code = g_staging_context_code
3437 AND s.event_class_code = w.event_class_code
3438 AND s.event_type_code = w.event_type_code
3439 AND s.line_definition_owner_code = w.line_definition_owner_code
3440 AND s.line_definition_code = w.line_definition_code
3441 AND s.accounting_line_type_code = w.accounting_line_type_code
3442 AND s.accounting_line_code = w.accounting_line_code
3443 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
3444 AND s.analytical_criterion_code = w.analytical_criterion_code);
3445 l_num_rows := SQL%ROWCOUNT;
3446 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3447 trace(p_msg => '# xla_line_defn_ac_assgns deleted : '||l_num_rows,
3448 p_module => l_log_module,
3449 p_level => C_LEVEL_STATEMENT);
3450 END IF;
3451 -- Bug : 9923803
3452 -- API Call to Insert messages into AAD Loader Log Table.
3453 xla_aad_loader_util_pvt.insert_aadloaderlog(
3454 p_amb_context_code => g_amb_context_code,
3455 p_application_id => g_application_id,
3456 p_request_code => 'IMPORT' ,
3457 p_log_type_code => 'MERGE',
3458 p_encoded_message =>'# xla_line_defn_ac_assgns deleted : '||l_num_rows,
3459 p_component_code => 'merge_journal_line_defns');
3460
3461 -- bug8635648 MPA JLT's deleted even when no data for JLT's in Staging Table
3462 DELETE FROM xla_mpa_jlt_assgns w
3463 WHERE application_id = g_application_id
3464 AND amb_context_code = g_amb_context_code
3465 AND EXISTS (
3466 SELECT 1
3467 FROM xla_acct_line_types_b xal
3468 WHERE xal.application_id = g_application_id -- w.application_id -- changed for bug8635648
3469 AND xal.amb_context_code = g_staging_context_code -- w.amb_context_code -- changed for bug8635648
3470 AND xal.event_class_code = w.event_class_code
3471 AND xal.accounting_line_type_code = w.accounting_line_type_code
3472 AND xal.accounting_line_code = w.accounting_line_code
3473 AND xal.mpa_option_code = 'ACCRUAL');
3474 l_num_rows := SQL%ROWCOUNT;
3475 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3476 trace(p_msg => '# xla_mpa_jlt_assgns deleted : '||l_num_rows,
3477 p_module => l_log_module,
3478 p_level => C_LEVEL_STATEMENT);
3479 END IF;
3480 -- Bug : 9923803
3481 -- API Call to Insert messages into AAD Loader Log Table.
3482 xla_aad_loader_util_pvt.insert_aadloaderlog(
3483 p_amb_context_code => g_amb_context_code,
3484 p_application_id => g_application_id,
3485 p_request_code => 'IMPORT' ,
3486 p_log_type_code => 'MERGE',
3487 p_encoded_message => '# xla_mpa_jlt_assgns deleted : '||l_num_rows,
3488 p_component_code => 'merge_journal_line_defns');
3489
3490 DELETE FROM xla_mpa_header_ac_assgns w
3491 WHERE application_id = g_application_id
3492 AND amb_context_code = g_amb_context_code
3493 AND EXISTS (
3494 SELECT 1
3495 FROM xla_mpa_header_ac_assgns s
3496 WHERE s.application_id = g_application_id
3497 AND s.amb_context_code = g_staging_context_code
3498 AND s.event_class_code = w.event_class_code
3499 AND s.event_type_code = w.event_type_code
3500 AND s.line_definition_owner_code = w.line_definition_owner_code
3501 AND s.line_definition_code = w.line_definition_code
3502 AND s.accounting_line_type_code = w.accounting_line_type_code
3503 AND s.accounting_line_code = w.accounting_line_code
3504 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
3505 AND s.analytical_criterion_code = w.analytical_criterion_code
3506 UNION
3507 SELECT 1
3508 FROM xla_acct_line_types_b s
3509 WHERE s.application_id = g_application_id
3510 AND s.amb_context_code = g_staging_context_code
3511 AND s.event_class_code = w.event_class_code
3512 AND s.accounting_line_type_code = w.accounting_line_type_code
3513 AND s.accounting_line_code = w.accounting_line_code
3514 AND s.mpa_option_code = 'NONE');
3515 l_num_rows := SQL%ROWCOUNT;
3516 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3517 trace(p_msg => '# xla_mpa_header_ac_assgns deleted : '||l_num_rows,
3518 p_module => l_log_module,
3519 p_level => C_LEVEL_STATEMENT);
3520 END IF;
3521 -- Bug : 9923803
3522 -- API Call to Insert messages into AAD Loader Log Table.
3523 xla_aad_loader_util_pvt.insert_aadloaderlog(
3524 p_amb_context_code => g_amb_context_code,
3525 p_application_id => g_application_id,
3526 p_request_code => 'IMPORT' ,
3527 p_log_type_code => 'MERGE',
3528 p_encoded_message => '# xla_mpa_header_ac_assgns deleted : '||l_num_rows,
3529 p_component_code => 'merge_journal_line_defns');
3530
3531 -- ADR assignments are not merged, but overwritten, if the MPA JLT exists in
3532 -- the staging area
3533 DELETE FROM xla_mpa_jlt_adr_assgns w
3534 WHERE application_id = g_application_id
3535 AND amb_context_code = g_amb_context_code
3536 AND EXISTS (
3537 SELECT 1
3538 FROM xla_mpa_jlt_assgns s
3539 WHERE s.application_id = g_application_id
3540 AND s.amb_context_code = g_staging_context_code
3541 AND s.event_class_code = w.event_class_code
3542 AND s.event_type_code = w.event_type_code
3543 AND s.line_definition_owner_code = w.line_definition_owner_code
3544 AND s.line_definition_code = w.line_definition_code
3545 AND s.accounting_line_type_code = w.accounting_line_type_code
3546 AND s.accounting_line_code = w.accounting_line_code
3547 AND s.mpa_accounting_line_type_code = w.mpa_accounting_line_type_code
3548 AND s.mpa_accounting_line_code = w.mpa_accounting_line_code
3549 UNION
3550 SELECT 1
3551 FROM xla_acct_line_types_b s
3552 WHERE s.application_id = g_application_id
3553 AND s.amb_context_code = g_staging_context_code
3554 AND s.event_class_code = w.event_class_code
3555 AND s.accounting_line_type_code = w.accounting_line_type_code
3556 AND s.accounting_line_code = w.accounting_line_code
3557 AND s.mpa_option_code = 'NONE');
3558 l_num_rows := SQL%ROWCOUNT;
3559 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3560 trace(p_msg => '# xla_mpa_jlt_adr_assgns deleted : '||l_num_rows,
3561 p_module => l_log_module,
3562 p_level => C_LEVEL_STATEMENT);
3563 END IF;
3564 -- Bug : 9923803
3565 -- API Call to Insert messages into AAD Loader Log Table.
3566 xla_aad_loader_util_pvt.insert_aadloaderlog(
3567 p_amb_context_code => g_amb_context_code,
3568 p_application_id => g_application_id,
3569 p_request_code => 'IMPORT' ,
3570 p_log_type_code => 'MERGE',
3571 p_encoded_message => '# xla_mpa_jlt_adr_assgns deleted : '||l_num_rows,
3572 p_component_code => 'merge_journal_line_defns');
3573
3574 DELETE FROM xla_mpa_jlt_ac_assgns w
3575 WHERE application_id = g_application_id
3576 AND amb_context_code = g_amb_context_code
3577 AND EXISTS (
3578 SELECT 1
3579 FROM xla_mpa_jlt_ac_assgns s
3580 WHERE s.application_id = g_application_id
3581 AND s.amb_context_code = g_staging_context_code
3582 AND s.event_class_code = w.event_class_code
3583 AND s.event_type_code = w.event_type_code
3584 AND s.line_definition_owner_code = w.line_definition_owner_code
3585 AND s.line_definition_code = w.line_definition_code
3586 AND s.accounting_line_type_code = w.accounting_line_type_code
3587 AND s.accounting_line_code = w.accounting_line_code
3588 AND s.mpa_accounting_line_type_code = w.mpa_accounting_line_type_code
3589 AND s.mpa_accounting_line_code = w.mpa_accounting_line_code
3590 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
3591 AND s.analytical_criterion_code = w.analytical_criterion_code
3592 UNION
3593 SELECT 1
3594 FROM xla_acct_line_types_b s
3595 WHERE s.application_id = g_application_id
3596 AND s.amb_context_code = g_staging_context_code
3597 AND s.event_class_code = w.event_class_code
3598 AND s.accounting_line_type_code = w.accounting_line_type_code
3599 AND s.accounting_line_code = w.accounting_line_code
3600 AND s.mpa_option_code = 'NONE');
3601
3602 l_num_rows := SQL%ROWCOUNT;
3603 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3604 trace(p_msg => '# xla_mpa_jlt_ac_assgns deleted : '||l_num_rows,
3605 p_module => l_log_module,
3606 p_level => C_LEVEL_STATEMENT);
3607 END IF;
3608 -- Bug : 9923803
3609 -- API Call to Insert messages into AAD Loader Log Table.
3610 xla_aad_loader_util_pvt.insert_aadloaderlog(
3611 p_amb_context_code => g_amb_context_code,
3612 p_application_id => g_application_id,
3613 p_request_code => 'IMPORT' ,
3614 p_log_type_code => 'MERGE',
3615 p_encoded_message => '# xla_mpa_jlt_ac_assgns deleted : '||l_num_rows,
3616 p_component_code => 'merge_journal_line_defns');
3617
3618 END IF;
3619
3620 -- Move the journal line definitions from staging area to working area
3621 UPDATE xla_line_definitions_b
3622 SET amb_context_code = g_amb_context_code
3623 WHERE application_id = g_application_id
3624 AND amb_context_code = g_staging_context_code;
3625 l_num_rows := SQL%ROWCOUNT;
3626 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3627 trace(p_msg => '# xla_line_definitions_b updated : '||l_num_rows,
3628 p_module => l_log_module,
3629 p_level => C_LEVEL_STATEMENT);
3630 END IF;
3631 -- Bug : 9923803
3632 -- API Call to Insert messages into AAD Loader Log Table.
3633 xla_aad_loader_util_pvt.insert_aadloaderlog(
3634 p_amb_context_code => g_amb_context_code,
3635 p_application_id => g_application_id,
3636 p_request_code => 'IMPORT' ,
3637 p_log_type_code => 'MERGE',
3638 p_encoded_message => '# xla_line_definitions_b updated : '||l_num_rows,
3639 p_component_code => 'merge_journal_line_defns');
3640
3641 UPDATE xla_line_definitions_tl w
3642 SET amb_context_code = g_amb_context_code
3643 WHERE application_id = g_application_id
3644 AND amb_context_code = g_staging_context_code
3645 AND NOT EXISTS (SELECT 1
3646 FROM xla_line_definitions_tl s
3647 WHERE s.application_id = g_application_id
3648 AND s.amb_context_code = g_amb_context_code
3649 AND s.event_class_code = w.event_class_code
3650 AND s.event_type_code = w.event_type_code
3651 AND s.line_definition_owner_code = w.line_definition_owner_code
3652 AND s.name = w.name
3653 AND s.language = w.language);
3654 l_num_rows := SQL%ROWCOUNT;
3655 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3656 trace(p_msg => '# xla_line_definitions_tl 1 updated : '||l_num_rows,
3657 p_module => l_log_module,
3658 p_level => C_LEVEL_STATEMENT);
3659 END IF;
3660 -- Bug : 9923803
3661 -- API Call to Insert messages into AAD Loader Log Table.
3662 xla_aad_loader_util_pvt.insert_aadloaderlog(
3663 p_amb_context_code => g_amb_context_code,
3664 p_application_id => g_application_id,
3665 p_request_code => 'IMPORT' ,
3666 p_log_type_code => 'MERGE',
3667 p_encoded_message => '# xla_line_definitions_tl 1 updated : '||l_num_rows,
3668 p_component_code => 'merge_journal_line_defns');
3669
3670 UPDATE xla_line_definitions_tl w
3671 SET amb_context_code = g_amb_context_code
3672 , name = substr('('||line_definition_code||') '||name,1,80)
3673 WHERE application_id = g_application_id
3674 AND amb_context_code = g_staging_context_code
3675 AND EXISTS (SELECT 1
3676 FROM xla_line_definitions_tl s
3677 WHERE s.application_id = g_application_id
3678 AND s.amb_context_code = g_amb_context_code
3679 AND s.event_class_code = w.event_class_code
3680 AND s.event_type_code = w.event_type_code
3681 AND s.line_definition_owner_code = w.line_definition_owner_code
3682 AND s.name = w.name
3683 AND s.language = w.language);
3684 l_num_rows := SQL%ROWCOUNT;
3685 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3686 trace(p_msg => '# xla_line_definitions_tl 2 updated : '||l_num_rows,
3687 p_module => l_log_module,
3688 p_level => C_LEVEL_STATEMENT);
3689 END IF;
3690 -- Bug : 9923803
3691 -- API Call to Insert messages into AAD Loader Log Table.
3692 xla_aad_loader_util_pvt.insert_aadloaderlog(
3693 p_amb_context_code => g_amb_context_code,
3694 p_application_id => g_application_id,
3695 p_request_code => 'IMPORT' ,
3696 p_log_type_code => 'MERGE',
3697 p_encoded_message => '# xla_line_definitions_tl 2 updated : '||l_num_rows,
3698 p_component_code => 'merge_journal_line_defns');
3699
3700 UPDATE xla_line_defn_jlt_assgns
3701 SET amb_context_code = g_amb_context_code
3702 WHERE application_id = g_application_id
3703 AND amb_context_code = g_staging_context_code;
3704 l_num_rows := SQL%ROWCOUNT;
3705 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3706 trace(p_msg => '# xla_line_defn_jlt_assgns updated : '||l_num_rows,
3707 p_module => l_log_module,
3708 p_level => C_LEVEL_STATEMENT);
3709 END IF;
3710 -- Bug : 9923803
3711 -- API Call to Insert messages into AAD Loader Log Table.
3712 xla_aad_loader_util_pvt.insert_aadloaderlog(
3713 p_amb_context_code => g_amb_context_code,
3714 p_application_id => g_application_id,
3715 p_request_code => 'IMPORT' ,
3716 p_log_type_code => 'MERGE',
3717 p_encoded_message => '# xla_line_defn_jlt_assgns updated : '||l_num_rows,
3718 p_component_code => 'merge_journal_line_defns');
3719
3720 UPDATE xla_line_defn_adr_assgns
3721 SET amb_context_code = g_amb_context_code
3722 WHERE application_id = g_application_id
3723 AND amb_context_code = g_staging_context_code;
3724 l_num_rows := SQL%ROWCOUNT;
3725 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3726 trace(p_msg => '# xla_line_defn_adr_assgns updated : '||l_num_rows,
3727 p_module => l_log_module,
3728 p_level => C_LEVEL_STATEMENT);
3729 END IF;
3730 -- Bug : 9923803
3731 -- API Call to Insert messages into AAD Loader Log Table.
3732 xla_aad_loader_util_pvt.insert_aadloaderlog(
3733 p_amb_context_code => g_amb_context_code,
3734 p_application_id => g_application_id,
3735 p_request_code => 'IMPORT' ,
3736 p_log_type_code => 'MERGE',
3737 p_encoded_message => '# xla_line_defn_adr_assgns updated : '||l_num_rows,
3738 p_component_code => 'merge_journal_line_defns');
3739
3740 UPDATE xla_line_defn_ac_assgns
3741 SET amb_context_code = g_amb_context_code
3742 WHERE application_id = g_application_id
3743 AND amb_context_code = g_staging_context_code;
3744 l_num_rows := SQL%ROWCOUNT;
3745 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3746 trace(p_msg => '# xla_line_defn_ac_assgns updated : '||l_num_rows,
3747 p_module => l_log_module,
3748 p_level => C_LEVEL_STATEMENT);
3749 END IF;
3750 -- Bug : 9923803
3751 -- API Call to Insert messages into AAD Loader Log Table.
3752 xla_aad_loader_util_pvt.insert_aadloaderlog(
3753 p_amb_context_code => g_amb_context_code,
3754 p_application_id => g_application_id,
3755 p_request_code => 'IMPORT' ,
3756 p_log_type_code => 'MERGE',
3757 p_encoded_message => '# xla_line_defn_ac_assgns updated : '||l_num_rows,
3758 p_component_code => 'merge_journal_line_defns');
3759
3760 UPDATE xla_mpa_jlt_assgns
3761 SET amb_context_code = g_amb_context_code
3762 WHERE application_id = g_application_id
3763 AND amb_context_code = g_staging_context_code;
3764 l_num_rows := SQL%ROWCOUNT;
3765 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3766 trace(p_msg => '# xla_mpa_jlt_assgns updated : '||l_num_rows,
3767 p_module => l_log_module,
3768 p_level => C_LEVEL_STATEMENT);
3769 END IF;
3770 -- Bug : 9923803
3771 -- API Call to Insert messages into AAD Loader Log Table.
3772 xla_aad_loader_util_pvt.insert_aadloaderlog(
3773 p_amb_context_code => g_amb_context_code,
3774 p_application_id => g_application_id,
3775 p_request_code => 'IMPORT' ,
3776 p_log_type_code => 'MERGE',
3777 p_encoded_message => '# xla_mpa_jlt_assgns updated : '||l_num_rows,
3778 p_component_code => 'merge_journal_line_defns');
3779
3780 UPDATE xla_mpa_header_ac_assgns
3781 SET amb_context_code = g_amb_context_code
3782 WHERE application_id = g_application_id
3783 AND amb_context_code = g_staging_context_code;
3784 l_num_rows := SQL%ROWCOUNT;
3785 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3786 trace(p_msg => '# xla_mpa_header_ac_assgns updated : '||l_num_rows,
3787 p_module => l_log_module,
3788 p_level => C_LEVEL_STATEMENT);
3789 END IF;
3790 -- Bug : 9923803
3791 -- API Call to Insert messages into AAD Loader Log Table.
3792 xla_aad_loader_util_pvt.insert_aadloaderlog(
3793 p_amb_context_code => g_amb_context_code,
3794 p_application_id => g_application_id,
3795 p_request_code => 'IMPORT' ,
3796 p_log_type_code => 'MERGE',
3797 p_encoded_message => '# xla_mpa_header_ac_assgns updated : '||l_num_rows,
3798 p_component_code => 'merge_journal_line_defns');
3799
3800 UPDATE xla_mpa_jlt_adr_assgns
3801 SET amb_context_code = g_amb_context_code
3802 WHERE application_id = g_application_id
3803 AND amb_context_code = g_staging_context_code;
3804 l_num_rows := SQL%ROWCOUNT;
3805 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3806 trace(p_msg => '# xla_mpa_jlt_adr_assgns updated : '||l_num_rows,
3807 p_module => l_log_module,
3808 p_level => C_LEVEL_STATEMENT);
3809 END IF;
3810 -- Bug : 9923803
3811 -- API Call to Insert messages into AAD Loader Log Table.
3812 xla_aad_loader_util_pvt.insert_aadloaderlog(
3813 p_amb_context_code => g_amb_context_code,
3814 p_application_id => g_application_id,
3815 p_request_code => 'IMPORT' ,
3816 p_log_type_code => 'MERGE',
3817 p_encoded_message => '# xla_mpa_jlt_adr_assgns updated : '||l_num_rows,
3818 p_component_code => 'merge_journal_line_defns');
3819
3820 -- For AC that is not going to be overwritten by those in staging area, it
3821 -- must not exist in the staging area. Therefore, it must not be inherited.
3822 UPDATE xla_mpa_jlt_ac_assgns
3823 SET mpa_inherit_ac_flag = 'N'
3824 WHERE application_id = g_application_id
3825 AND amb_context_code = g_amb_context_code;
3826
3827 UPDATE xla_mpa_jlt_ac_assgns
3828 SET amb_context_code = g_amb_context_code
3829 WHERE application_id = g_application_id
3830 AND amb_context_code = g_staging_context_code;
3831 l_num_rows := SQL%ROWCOUNT;
3832 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3833 trace(p_msg => '# xla_mpa_jlt_ac_assgns updated : '||l_num_rows,
3834 p_module => l_log_module,
3835 p_level => C_LEVEL_STATEMENT);
3836 END IF;
3837 -- Bug : 9923803
3838 -- API Call to Insert messages into AAD Loader Log Table.
3839 xla_aad_loader_util_pvt.insert_aadloaderlog(
3840 p_amb_context_code => g_amb_context_code,
3841 p_application_id => g_application_id,
3842 p_request_code => 'IMPORT' ,
3843 p_log_type_code => 'MERGE',
3844 p_encoded_message => '# xla_mpa_jlt_ac_assgns updated : '||l_num_rows,
3845 p_component_code => 'merge_journal_line_defns');
3846 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3847 trace(p_msg => 'END of procedure merge_journal_line_defns',
3848 p_module => l_log_module,
3849 p_level => C_LEVEL_PROCEDURE);
3850 END IF;
3851
3852 EXCEPTION
3853 WHEN OTHERS THEN
3854 xla_aad_loader_util_pvt.stack_error
3855 (p_appli_s_name => 'XLA'
3856 ,p_msg_name => 'XLA_COMMON_ERROR'
3857 ,p_token_1 => 'LOCATION'
3858 ,p_value_1 => 'xla_aad_merge_pvt.merge_journal_line_defns'
3859 ,p_token_2 => 'ERROR'
3860 ,p_value_2 => 'unhandled exception');
3861 RAISE;
3862
3863 END merge_journal_line_defns;
3864
3865
3866 --=============================================================================
3867 --
3868 -- Name: merge_journal_line_types
3869 -- Description: Merge journal line types from staging to working area
3870 --
3871 --=============================================================================
3872 PROCEDURE merge_journal_line_types
3873 IS
3874
3875 l_log_module VARCHAR2(240);
3876 l_num_rows INTEGER;
3877 BEGIN
3878 IF g_log_enabled THEN
3879 l_log_module := C_DEFAULT_MODULE||'.merge_journal_line_types';
3880 END IF;
3881
3882 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3883 trace(p_msg => 'BEGIN of procedure merge_journal_line_types',
3884 p_module => l_log_module,
3885 p_level => C_LEVEL_PROCEDURE);
3886 END IF;
3887
3888 /*************************************************/
3889 /**** Added by krsankar for Performance changes **/
3890 /*************************************************/
3891
3892 INSERT INTO xla_aads_gt
3893 ( entity_code,
3894 event_class_code,
3895 accounting_line_code,
3896 accounting_class_code,
3897 table_name
3898 )
3899 select entity_code,
3900 event_class_code,
3901 accounting_line_code,
3902 accounting_class_code,
3903 'XLA_ACCT_LINE_TYPES_B'
3904 from
3905 (select entity_code,
3906 event_class_code,
3907 accounting_line_code,
3908 accounting_class_code,
3909 'XLA_ACCT_LINE_TYPES_B',
3910 amb_context_code,
3911 last_update_date ,
3912 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
3913 from
3914 (select entity_code,
3915 event_class_code,
3916 accounting_line_code,
3917 accounting_class_code,
3918 'XLA_ACCT_LINE_TYPES_B',
3919 amb_context_code,
3920 last_update_date,
3921 lag(last_update_date) over (PARTITION by application_id,
3922 event_class_code,
3923 accounting_line_code,
3924 accounting_line_type_code
3925 order by amb_context_code
3926 ) lag_date
3927 from xla_acct_line_types_b
3928 order by amb_context_code
3929 ) x
3930 where x.amb_context_code = g_staging_context_code
3931 )
3932 where flag = 'False';
3933 l_num_rows := SQL%ROWCOUNT;
3934
3935 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3936 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_acct_line_types_b is :'||l_num_rows,
3937 p_module => l_log_module,
3938 p_level => C_LEVEL_PROCEDURE);
3939 END IF;
3940
3941 -- Bug : 9923803
3942 -- API Call to Insert messages into AAD Loader Log Table.
3943 xla_aad_loader_util_pvt.insert_aadloaderlog(
3944 p_amb_context_code => g_amb_context_code,
3945 p_application_id => g_application_id,
3946 p_request_code => 'IMPORT' ,
3947 p_log_type_code => 'MERGE',
3948 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_acct_line_types_b is :'||l_num_rows,
3949 p_component_code => 'merge_journal_line_types');
3950
3951 INSERT INTO xla_aads_gt
3952 ( event_class_code
3953 ,accounting_line_code
3954 ,accounting_attribute_code
3955 ,source_code
3956 ,table_name
3957 )
3958 select jlt_acct_attrs.event_class_code
3959 ,jlt_acct_attrs.accounting_line_code
3960 ,jlt_acct_attrs.accounting_attribute_code
3961 ,jlt_acct_attrs.source_code
3962 ,'xla_jlt_acct_attrs'
3963 from xla_jlt_acct_attrs jlt_acct_attrs
3964 where jlt_acct_attrs.application_id = g_application_id
3965 and jlt_acct_attrs.amb_context_code = g_staging_context_code
3966 and (EXISTS(SELECT 1
3967 FROM xla_jlt_acct_attrs jlt_acct_attrs1
3968 WHERE jlt_acct_attrs.event_class_code = jlt_acct_attrs1.event_class_code
3969 and jlt_acct_attrs.accounting_line_code = jlt_acct_attrs1.accounting_line_code
3970 and jlt_acct_attrs.accounting_line_type_code = jlt_acct_attrs1.accounting_line_type_code
3971 and nvl(jlt_acct_attrs.accounting_attribute_code,' ') = nvl(jlt_acct_attrs1.accounting_attribute_code,' ')
3972 and nvl(jlt_acct_attrs.source_code,' ') = nvl(jlt_acct_attrs1.source_code,' ')
3973 and jlt_acct_attrs.application_id = jlt_acct_attrs1.application_id
3974 and jlt_acct_attrs1.amb_context_code = g_amb_context_code
3975 and to_char(jlt_acct_attrs.last_update_date,'DD-MON-YYYY') <> to_char(jlt_acct_attrs1.last_update_date,'DD-MON-YYYY')
3976 )
3977 OR
3978 NOT EXISTS(SELECT 1
3979 FROM xla_jlt_acct_attrs jlt_acct_attrs1
3980 WHERE jlt_acct_attrs.event_class_code = jlt_acct_attrs1.event_class_code
3981 and jlt_acct_attrs.accounting_line_code = jlt_acct_attrs1.accounting_line_code
3982 and jlt_acct_attrs.accounting_line_type_code = jlt_acct_attrs1.accounting_line_type_code
3983 and nvl(jlt_acct_attrs.accounting_attribute_code,' ') = nvl(jlt_acct_attrs1.accounting_attribute_code,' ')
3984 and nvl(jlt_acct_attrs.source_code,' ') = nvl(jlt_acct_attrs1.source_code,' ')
3985 and jlt_acct_attrs.application_id = jlt_acct_attrs1.application_id
3986 and jlt_acct_attrs1.amb_context_code = g_amb_context_code
3987 )
3988 );
3989 l_num_rows := SQL%ROWCOUNT;
3990 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3991 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_jlt_acct_attrs is :'||l_num_rows,
3992 p_module => l_log_module,
3993 p_level => C_LEVEL_PROCEDURE);
3994 END IF;
3995 -- Bug : 9923803
3996 -- API Call to Insert messages into AAD Loader Log Table.
3997 xla_aad_loader_util_pvt.insert_aadloaderlog(
3998 p_amb_context_code => g_amb_context_code,
3999 p_application_id => g_application_id,
4000 p_request_code => 'IMPORT' ,
4001 p_log_type_code => 'MERGE',
4002 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_jlt_acct_attrs is :'||l_num_rows,
4003 p_component_code => 'merge_journal_line_types');
4004
4005 INSERT INTO xla_aads_gt
4006 ( entity_code
4007 ,event_class_code
4008 ,accounting_line_code
4009 ,source_code
4010 ,table_name
4011 )
4012 select condn.entity_code
4013 ,condn.event_class_code
4014 ,condn.accounting_line_code
4015 ,condn.source_code
4016 ,'xla_conditions'
4017 from xla_conditions condn
4018 where condn.application_id = g_application_id
4019 and condn.amb_context_code = g_staging_context_code
4020 and EXISTS (SELECT 1
4021 FROM xla_acct_line_types_b s
4022 WHERE s.application_id = g_application_id
4023 and s.amb_context_code = g_staging_context_code
4024 and s.event_class_code = condn.event_class_code
4025 and s.accounting_line_type_code = condn.accounting_line_type_code
4026 and s.accounting_line_code = condn.accounting_line_code)
4027 and (EXISTS(SELECT 1
4028 FROM xla_conditions condn1
4029 WHERE condn.entity_code = condn1.entity_code
4030 and condn.event_class_code = condn1.event_class_code
4031 and condn.accounting_line_code = condn1.accounting_line_code
4032 and condn.accounting_line_type_code = condn1.accounting_line_type_code
4033 and nvl(condn.source_code,' ') = nvl(condn1.source_code,' ')
4034 and nvl(condn.source_type_code,' ') = nvl(condn1.source_type_code,' ')
4035 and condn.user_sequence = condn1.user_sequence
4036 and condn.application_id = condn1.application_id
4037 and condn1.amb_context_code = g_amb_context_code
4038 and to_char(condn.last_update_date,'DD-MON-YYYY') <> to_char(condn1.last_update_date,'DD-MON-YYYY')
4039 )
4040 OR
4041 NOT EXISTS(SELECT 1
4042 FROM xla_conditions condn1
4043 WHERE nvl(condn.entity_code,' ') = nvl(condn1.entity_code,' ')
4044 and nvl(condn.event_class_code,' ') = nvl(condn1.event_class_code,' ')
4045 and nvl(condn.accounting_line_code,' ') = nvl(condn1.accounting_line_code,' ')
4046 and nvl(condn.accounting_line_type_code,' ') = nvl(condn1.accounting_line_type_code,' ')
4047 and nvl(condn.source_code,' ') = nvl(condn1.source_code,' ')
4048 and nvl(condn.source_type_code,' ') = nvl(condn1.source_type_code,' ')
4049 and condn.user_sequence = condn1.user_sequence
4050 and condn.application_id = condn1.application_id
4051 and condn1.amb_context_code = g_amb_context_code
4052 )
4053 );
4054 l_num_rows := SQL%ROWCOUNT;
4055 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4056 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_conditions is :'||l_num_rows,
4057 p_module => l_log_module,
4058 p_level => C_LEVEL_PROCEDURE);
4059 END IF;
4060 -- Bug : 9923803
4061 -- API Call to Insert messages into AAD Loader Log Table.
4062 xla_aad_loader_util_pvt.insert_aadloaderlog(
4063 p_amb_context_code => g_amb_context_code,
4064 p_application_id => g_application_id,
4065 p_request_code => 'IMPORT' ,
4066 p_log_type_code => 'MERGE',
4067 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_conditions is :'||l_num_rows,
4068 p_component_code => 'merge_journal_line_types');
4069
4070 IF (g_analyzed_flag = 'Y') THEN
4071 null;
4072
4073 ELSE
4074
4075 -- Delete the journal line types from the working area if it already
4076 -- exists in the staging area
4077 DELETE FROM xla_acct_line_types_b w
4078 WHERE application_id = g_application_id
4079 AND amb_context_code = g_amb_context_code
4080 AND EXISTS (SELECT 1
4081 FROM xla_acct_line_types_b s
4082 WHERE s.application_id = g_application_id
4083 AND s.amb_context_code = g_staging_context_code
4084 AND s.event_class_code = w.event_class_code
4085 AND s.accounting_line_type_code = w.accounting_line_type_code
4086 AND s.accounting_line_code = w.accounting_line_code);
4087 l_num_rows := SQL%ROWCOUNT;
4088 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4089 trace(p_msg => '# xla_acct_line_types_b delete : '||l_num_rows,
4090 p_module => l_log_module,
4091 p_level => C_LEVEL_STATEMENT);
4092 END IF;
4093 -- Bug : 9923803
4094 -- API Call to Insert messages into AAD Loader Log Table.
4095 xla_aad_loader_util_pvt.insert_aadloaderlog(
4096 p_amb_context_code => g_amb_context_code,
4097 p_application_id => g_application_id,
4098 p_request_code => 'IMPORT' ,
4099 p_log_type_code => 'MERGE',
4100 p_encoded_message => '# xla_acct_line_types_b delete : '||l_num_rows,
4101 p_component_code => 'merge_journal_line_types');
4102
4103 DELETE FROM xla_acct_line_types_tl w
4104 WHERE application_id = g_application_id
4105 AND amb_context_code = g_amb_context_code
4106 AND EXISTS (SELECT 1
4107 FROM xla_acct_line_types_tl s
4108 WHERE s.application_id = g_application_id
4109 AND s.amb_context_code = g_staging_context_code
4110 AND s.event_class_code = w.event_class_code
4111 AND s.accounting_line_type_code = w.accounting_line_type_code
4112 AND s.accounting_line_code = w.accounting_line_code
4113 AND s.language = w.language);
4114 l_num_rows := SQL%ROWCOUNT;
4115 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4116 trace(p_msg => '# xla_acct_line_types_tl delete : '||l_num_rows,
4117 p_module => l_log_module,
4118 p_level => C_LEVEL_STATEMENT);
4119 END IF;
4120 -- Bug : 9923803
4121 -- API Call to Insert messages into AAD Loader Log Table.
4122 xla_aad_loader_util_pvt.insert_aadloaderlog(
4123 p_amb_context_code => g_amb_context_code,
4124 p_application_id => g_application_id,
4125 p_request_code => 'IMPORT' ,
4126 p_log_type_code => 'MERGE',
4127 p_encoded_message => '# xla_acct_line_types_tl delete : '||l_num_rows,
4128 p_component_code => 'merge_journal_line_types');
4129
4130 DELETE FROM xla_jlt_acct_attrs w
4131 WHERE application_id = g_application_id
4132 AND amb_context_code = g_amb_context_code
4133 AND EXISTS (SELECT 1
4134 FROM xla_jlt_acct_attrs s
4135 WHERE s.application_id = g_application_id
4136 AND s.amb_context_code = g_staging_context_code
4137 AND s.event_class_code = w.event_class_code
4138 AND s.accounting_line_type_code = w.accounting_line_type_code
4139 AND s.accounting_line_code = w.accounting_line_code);
4140 l_num_rows := SQL%ROWCOUNT;
4141 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4142 trace(p_msg => '# xla_jlt_acct_attrs delete : '||l_num_rows,
4143 p_module => l_log_module,
4144 p_level => C_LEVEL_STATEMENT);
4145 END IF;
4146 -- Bug : 9923803
4147 -- API Call to Insert messages into AAD Loader Log Table.
4148 xla_aad_loader_util_pvt.insert_aadloaderlog(
4149 p_amb_context_code => g_amb_context_code,
4150 p_application_id => g_application_id,
4151 p_request_code => 'IMPORT' ,
4152 p_log_type_code => 'MERGE',
4153 p_encoded_message => '# xla_jlt_acct_attrs delete : '||l_num_rows,
4154 p_component_code => 'merge_journal_line_types');
4155
4156 DELETE FROM xla_conditions w
4157 WHERE application_id = g_application_id
4158 AND amb_context_code = g_amb_context_code
4159 AND EXISTS (SELECT 1
4160 FROM xla_acct_line_types_b s
4161 WHERE s.application_id = g_application_id
4162 AND s.amb_context_code = g_staging_context_code
4163 AND s.event_class_code = w.event_class_code
4164 AND s.accounting_line_type_code = w.accounting_line_type_code
4165 AND s.accounting_line_code = w.accounting_line_code);
4166 l_num_rows := SQL%ROWCOUNT;
4167 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4168 trace(p_msg => '# xla_jlt_acct_attrs delete : '||l_num_rows,
4169 p_module => l_log_module,
4170 p_level => C_LEVEL_STATEMENT);
4171 END IF;
4172 -- Bug : 9923803
4173 -- API Call to Insert messages into AAD Loader Log Table.
4174 xla_aad_loader_util_pvt.insert_aadloaderlog(
4175 p_amb_context_code => g_amb_context_code,
4176 p_application_id => g_application_id,
4177 p_request_code => 'IMPORT' ,
4178 p_log_type_code => 'MERGE',
4179 p_encoded_message => '# xla_jlt_acct_attrs delete : '||l_num_rows,
4180 p_component_code => 'merge_journal_line_types');
4181 END IF;
4182
4183 -- Move the journal line types from staging area to working area
4184 UPDATE xla_acct_line_types_b
4185 SET amb_context_code = g_amb_context_code
4186 WHERE application_id = g_application_id
4187 AND amb_context_code = g_staging_context_code;
4188 l_num_rows := SQL%ROWCOUNT;
4189 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4190 trace(p_msg => '# xla_acct_line_types_b updated : '||l_num_rows,
4191 p_module => l_log_module,
4192 p_level => C_LEVEL_STATEMENT);
4193 END IF;
4194 -- Bug : 9923803
4195 -- API Call to Insert messages into AAD Loader Log Table.
4196 xla_aad_loader_util_pvt.insert_aadloaderlog(
4197 p_amb_context_code => g_amb_context_code,
4198 p_application_id => g_application_id,
4199 p_request_code => 'IMPORT' ,
4200 p_log_type_code => 'MERGE',
4201 p_encoded_message => '# xla_acct_line_types_b updated : '||l_num_rows,
4202 p_component_code => 'merge_journal_line_types');
4203
4204 UPDATE xla_acct_line_types_tl w
4205 SET amb_context_code = g_amb_context_code
4206 WHERE application_id = g_application_id
4207 AND amb_context_code = g_staging_context_code
4208 AND NOT EXISTS (SELECT 1
4209 FROM xla_acct_line_types_tl s
4210 WHERE s.application_id = g_application_id
4211 AND s.amb_context_code = g_amb_context_code
4212 AND s.event_class_code = w.event_class_code
4213 AND s.accounting_line_type_code = w.accounting_line_type_code
4214 AND s.name = w.name
4215 AND s.language = w.language);
4216 l_num_rows := SQL%ROWCOUNT;
4217
4218 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4219 trace(p_msg => '# xla_acct_line_types_tl 1 updated : '||l_num_rows,
4220 p_module => l_log_module,
4221 p_level => C_LEVEL_STATEMENT);
4222 END IF;
4223 -- Bug : 9923803
4224 -- API Call to Insert messages into AAD Loader Log Table.
4225 xla_aad_loader_util_pvt.insert_aadloaderlog(
4226 p_amb_context_code => g_amb_context_code,
4227 p_application_id => g_application_id,
4228 p_request_code => 'IMPORT' ,
4229 p_log_type_code => 'MERGE',
4230 p_encoded_message => '# xla_acct_line_types_tl 1 updated : '||l_num_rows,
4231 p_component_code => 'merge_journal_line_types');
4232
4233 UPDATE xla_acct_line_types_tl w
4234 SET amb_context_code = g_amb_context_code
4235 , name = substr('('||w.accounting_line_code||') '||name,1,80)
4236 WHERE application_id = g_application_id
4237 AND amb_context_code = g_staging_context_code
4238 AND EXISTS (SELECT 1
4239 FROM xla_acct_line_types_tl s
4240 WHERE s.application_id = g_application_id
4241 AND s.amb_context_code = g_amb_context_code
4242 AND s.event_class_code = w.event_class_code
4243 AND s.accounting_line_type_code = w.accounting_line_type_code
4244 AND s.name = w.name
4245 AND s.language = w.language);
4246 l_num_rows := SQL%ROWCOUNT;
4247 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4248 trace(p_msg => '# xla_acct_line_types_tl 2 updated : '||l_num_rows,
4249 p_module => l_log_module,
4250 p_level => C_LEVEL_STATEMENT);
4251 END IF;
4252 -- Bug : 9923803
4253 -- API Call to Insert messages into AAD Loader Log Table.
4254 xla_aad_loader_util_pvt.insert_aadloaderlog(
4255 p_amb_context_code => g_amb_context_code,
4256 p_application_id => g_application_id,
4257 p_request_code => 'IMPORT' ,
4258 p_log_type_code => 'MERGE',
4259 p_encoded_message => '# xla_acct_line_types_tl 2 updated : '||l_num_rows,
4260 p_component_code => 'merge_journal_line_types');
4261
4262 UPDATE xla_jlt_acct_attrs
4263 SET amb_context_code = g_amb_context_code
4264 WHERE application_id = g_application_id
4265 AND amb_context_code = g_staging_context_code;
4266 l_num_rows := SQL%ROWCOUNT;
4267 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4268 trace(p_msg => '# xla_jlt_acct_attrs updated : '||l_num_rows,
4269 p_module => l_log_module,
4270 p_level => C_LEVEL_STATEMENT);
4271 END IF;
4272 -- Bug : 9923803
4273 -- API Call to Insert messages into AAD Loader Log Table.
4274 xla_aad_loader_util_pvt.insert_aadloaderlog(
4275 p_amb_context_code => g_amb_context_code,
4276 p_application_id => g_application_id,
4277 p_request_code => 'IMPORT' ,
4278 p_log_type_code => 'MERGE',
4279 p_encoded_message => '# xla_jlt_acct_attrs updated : '||l_num_rows,
4280 p_component_code => 'merge_journal_line_types');
4281
4282 UPDATE xla_conditions
4283 SET amb_context_code = g_amb_context_code
4284 WHERE amb_context_code = g_staging_context_code
4285 AND application_id = g_application_id
4286 AND accounting_line_code IS NOT NULL;
4287 l_num_rows := SQL%ROWCOUNT;
4288 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4289 trace(p_msg => '# xla_conditions updated : '||l_num_rows,
4290 p_module => l_log_module,
4291 p_level => C_LEVEL_STATEMENT);
4292 END IF;
4293 -- Bug : 9923803
4294 -- API Call to Insert messages into AAD Loader Log Table.
4295 xla_aad_loader_util_pvt.insert_aadloaderlog(
4296 p_amb_context_code => g_amb_context_code,
4297 p_application_id => g_application_id,
4298 p_request_code => 'IMPORT' ,
4299 p_log_type_code => 'MERGE',
4300 p_encoded_message => '# xla_conditions updated : '||l_num_rows,
4301 p_component_code => 'merge_journal_line_types');
4302
4303 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4304 trace(p_msg => 'END of procedure merge_journal_line_types',
4305 p_module => l_log_module,
4306 p_level => C_LEVEL_PROCEDURE);
4307 END IF;
4308
4309 EXCEPTION
4310 WHEN OTHERS THEN
4311 xla_aad_loader_util_pvt.stack_error
4312 (p_appli_s_name => 'XLA'
4313 ,p_msg_name => 'XLA_COMMON_ERROR'
4314 ,p_token_1 => 'LOCATION'
4315 ,p_value_1 => 'xla_aad_merge_pvt.merge_journal_line_types'
4316 ,p_token_2 => 'ERROR'
4317 ,p_value_2 => 'unhandled exception');
4318 RAISE;
4319
4320 END merge_journal_line_types;
4321
4322
4323 --=============================================================================
4324 --
4325 -- Name: merge_descriptions
4326 -- Description: Merge descriptions from staging to working area
4327 --
4328 --=============================================================================
4329 PROCEDURE merge_descriptions
4330 IS
4331 l_log_module VARCHAR2(240);
4332 l_num_rows INTEGER;
4333 BEGIN
4334 IF g_log_enabled THEN
4335 l_log_module := C_DEFAULT_MODULE||'.merge_descriptions';
4336 END IF;
4337
4338 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4339 trace(p_msg => 'BEGIN of procedure merge_descriptions',
4340 p_module => l_log_module,
4341 p_level => C_LEVEL_PROCEDURE);
4342 END IF;
4343
4344 /*************************************************/
4345 /**** Added by krsankar for Performance changes **/
4346 /*************************************************/
4347
4348 INSERT INTO xla_aads_gt
4349 (description_code,
4350 table_name
4351 )
4352 select description_code,
4353 'XLA_DESCRIPTIONS_B'
4354 from
4355 (select description_code,
4356 'XLA_DESCRIPTIONS_B',
4357 amb_context_code,
4358 last_update_date ,
4359 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
4360 from
4361 (select description_code,
4362 'XLA_DESCRIPTIONS_B',
4363 amb_context_code,
4364 last_update_date ,
4365 lag(last_update_date) over (PARTITION by application_id,
4366 description_code,
4367 description_type_code
4368 order by amb_context_code
4369 ) lag_date
4370 from xla_descriptions_b
4371 order by amb_context_code
4372 ) x
4373 where x.amb_context_code = g_staging_context_code
4374 )
4375 where flag = 'False';
4376 l_num_rows := SQL%ROWCOUNT;
4377
4378 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4379 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_descriptions_b is :'||l_num_rows,
4380 p_module => l_log_module,
4381 p_level => C_LEVEL_PROCEDURE);
4382 END IF;
4383 -- Bug : 9923803
4384 -- API Call to Insert messages into AAD Loader Log Table.
4385 xla_aad_loader_util_pvt.insert_aadloaderlog(
4386 p_amb_context_code => g_amb_context_code,
4387 p_application_id => g_application_id,
4388 p_request_code => 'IMPORT' ,
4389 p_log_type_code => 'MERGE',
4390 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_descriptions_b is :'||l_num_rows,
4391 p_component_code => 'merge_descriptions');
4392
4393 INSERT INTO xla_aads_gt
4394 ( description_code,
4395 table_name
4396 )
4397 select description_code,
4398 'XLA_DESC_PRIORITIES'
4399 from
4400 (select description_code,
4401 'XLA_DESC_PRIORITIES',
4402 amb_context_code,
4403 last_update_date ,
4404 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
4405 from
4406 (select description_code,
4407 'XLA_DESC_PRIORITIES',
4408 amb_context_code,
4409 last_update_date ,
4410 lag(last_update_date) over (PARTITION by application_id,
4411 description_code,
4412 description_type_code
4413 order by amb_context_code
4414 ) lag_date
4415 from xla_desc_priorities
4416 order by amb_context_code
4417 ) x
4418 where x.amb_context_code = g_staging_context_code
4419 )
4420 where flag = 'False';
4421 l_num_rows := SQL%ROWCOUNT;
4422 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4423 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_desc_priorities is :'||l_num_rows,
4424 p_module => l_log_module,
4425 p_level => C_LEVEL_PROCEDURE);
4426 END IF;
4427 -- Bug : 9923803
4428 -- API Call to Insert messages into AAD Loader Log Table.
4429 xla_aad_loader_util_pvt.insert_aadloaderlog(
4430 p_amb_context_code => g_amb_context_code,
4431 p_application_id => g_application_id,
4432 p_request_code => 'IMPORT' ,
4433 p_log_type_code => 'MERGE',
4434 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_desc_priorities is :'||l_num_rows,
4435 p_component_code => 'merge_descriptions');
4436
4437 INSERT INTO xla_aads_gt
4438 ( source_code,
4439 table_name
4440 )
4441 SELECT desc_details.source_code,
4442 'xla_descript_details_b'
4443 FROM xla_descript_details_b desc_details
4444 WHERE desc_details.amb_context_code = g_staging_context_code
4445 AND desc_details.description_prio_id IN
4446 (SELECT w.description_prio_id
4447 FROM xla_desc_priorities w
4448 ,xla_desc_priorities s
4449 WHERE s.application_id = g_application_id
4450 AND s.amb_context_code = g_staging_context_code
4451 AND w.application_id = g_application_id
4452 AND w.amb_context_code = g_amb_context_code
4453 AND w.description_type_code = s.description_type_code
4454 AND w.description_code = s.description_code)
4455 AND (EXISTS (SELECT 1
4456 FROM xla_descript_details_b desc_details1
4457 WHERE desc_details1.amb_context_code = g_amb_context_code
4458 AND desc_details.description_prio_id = desc_details1.description_prio_id
4459 AND to_char(desc_details.last_update_date,'DD-MON-YYYY') <> to_char(desc_details1.last_update_date,'DD-MON-YYYY')
4460 )
4461 OR
4462 NOT EXISTS (SELECT 1
4463 FROM xla_descript_details_b desc_details1
4464 WHERE desc_details1.amb_context_code = g_amb_context_code
4465 AND desc_details.description_prio_id = desc_details1.description_prio_id
4466 )
4467 );
4468 l_num_rows := SQL%ROWCOUNT;
4469 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4470 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_descript_details_b is :'||l_num_rows,
4471 p_module => l_log_module,
4472 p_level => C_LEVEL_PROCEDURE);
4473 END IF;
4474 -- Bug : 9923803
4475 -- API Call to Insert messages into AAD Loader Log Table.
4476 xla_aad_loader_util_pvt.insert_aadloaderlog(
4477 p_amb_context_code => g_amb_context_code,
4478 p_application_id => g_application_id,
4479 p_request_code => 'IMPORT' ,
4480 p_log_type_code => 'MERGE',
4481 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_descript_details_b is :'||l_num_rows,
4482 p_component_code => 'merge_descriptions');
4483
4484 IF (g_analyzed_flag = 'Y') THEN
4485 null;
4486
4487 ELSE
4488
4489 -- Delete the descriptions from the working area if it already
4490 -- exists in the staging area
4491 DELETE FROM xla_descriptions_b w
4492 WHERE application_id = g_application_id
4493 AND amb_context_code = g_amb_context_code
4494 AND EXISTS (SELECT 1
4495 FROM xla_descriptions_b s
4496 WHERE s.application_id = g_application_id
4497 AND s.amb_context_code = g_staging_context_code
4498 AND s.description_type_code = w.description_type_code
4499 AND s.description_code = w.description_code);
4500
4501 l_num_rows := SQL%ROWCOUNT;
4502 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4503 trace(p_msg => '# xla_descriptions_b delete : '||l_num_rows,
4504 p_module => l_log_module,
4505 p_level => C_LEVEL_STATEMENT);
4506 END IF;
4507 -- Bug : 9923803
4508 -- API Call to Insert messages into AAD Loader Log Table.
4509 xla_aad_loader_util_pvt.insert_aadloaderlog(
4510 p_amb_context_code => g_amb_context_code,
4511 p_application_id => g_application_id,
4512 p_request_code => 'IMPORT' ,
4513 p_log_type_code => 'MERGE',
4514 p_encoded_message => '# xla_descriptions_b delete : '||l_num_rows,
4515 p_component_code => 'merge_descriptions');
4516
4517 DELETE FROM xla_descriptions_tl w
4518 WHERE application_id = g_application_id
4519 AND amb_context_code = g_amb_context_code
4520 AND EXISTS (SELECT 1
4521 FROM xla_descriptions_tl s
4522 WHERE s.application_id = g_application_id
4523 AND s.amb_context_code = g_staging_context_code
4524 AND s.description_type_code = w.description_type_code
4525 AND s.description_code = w.description_code
4526 AND s.language = w.language);
4527 l_num_rows := SQL%ROWCOUNT;
4528
4529 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4530 trace(p_msg => '# xla_descriptions_tl delete : '||l_num_rows,
4531 p_module => l_log_module,
4532 p_level => C_LEVEL_STATEMENT);
4533 END IF;
4534 -- Bug : 9923803
4535 -- API Call to Insert messages into AAD Loader Log Table.
4536 xla_aad_loader_util_pvt.insert_aadloaderlog(
4537 p_amb_context_code => g_amb_context_code,
4538 p_application_id => g_application_id,
4539 p_request_code => 'IMPORT' ,
4540 p_log_type_code => 'MERGE',
4541 p_encoded_message => '# xla_descriptions_tl delete : '||l_num_rows,
4542 p_component_code => 'merge_descriptions');
4543
4544 DELETE FROM xla_desc_priorities w
4545 WHERE application_id = g_application_id
4546 AND amb_context_code = g_amb_context_code
4547 AND EXISTS (SELECT 1
4548 FROM xla_desc_priorities s
4549 WHERE s.application_id = g_application_id
4550 AND s.amb_context_code = g_staging_context_code
4551 AND s.description_type_code = w.description_type_code
4552 AND s.description_code = w.description_code);
4553 l_num_rows := SQL%ROWCOUNT;
4554 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4555 trace(p_msg => '# xla_desc_priorities delete : '||l_num_rows,
4556 p_module => l_log_module,
4557 p_level => C_LEVEL_STATEMENT);
4558 END IF;
4559 -- Bug : 9923803
4560 -- API Call to Insert messages into AAD Loader Log Table.
4561 xla_aad_loader_util_pvt.insert_aadloaderlog(
4562 p_amb_context_code => g_amb_context_code,
4563 p_application_id => g_application_id,
4564 p_request_code => 'IMPORT' ,
4565 p_log_type_code => 'MERGE',
4566 p_encoded_message => '# xla_desc_priorities delete : '||l_num_rows,
4567 p_component_code => 'merge_descriptions');
4568
4569 DELETE FROM xla_conditions
4570 WHERE description_prio_id IN
4571 (SELECT w.description_prio_id
4572 FROM xla_desc_priorities w
4573 , xla_desc_priorities s
4574 WHERE s.application_id = g_application_id
4575 AND s.amb_context_code = g_staging_context_code
4576 AND w.application_id = g_application_id
4577 AND w.amb_context_code = g_amb_context_code
4578 AND w.description_type_code = s.description_type_code
4579 AND w.description_code = s.description_code);
4580 l_num_rows := SQL%ROWCOUNT;
4581
4582 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4583 trace(p_msg => '# xla_conditions delete : '||l_num_rows,
4584 p_module => l_log_module,
4585 p_level => C_LEVEL_STATEMENT);
4586 END IF;
4587 -- Bug : 9923803
4588 -- API Call to Insert messages into AAD Loader Log Table.
4589 xla_aad_loader_util_pvt.insert_aadloaderlog(
4590 p_amb_context_code => g_amb_context_code,
4591 p_application_id => g_application_id,
4592 p_request_code => 'IMPORT' ,
4593 p_log_type_code => 'MERGE',
4594 p_encoded_message => '# xla_conditions delete : '||l_num_rows,
4595 p_component_code => 'merge_descriptions');
4596
4597 DELETE FROM xla_descript_details_b
4598 WHERE description_prio_id IN
4599 (SELECT w.description_prio_id
4600 FROM xla_desc_priorities w
4601 , xla_desc_priorities s
4602 WHERE s.application_id = g_application_id
4603 AND s.amb_context_code = g_staging_context_code
4604 AND w.application_id = g_application_id
4605 AND w.amb_context_code = g_amb_context_code
4606 AND w.description_type_code = s.description_type_code
4607 AND w.description_code = s.description_code);
4608 l_num_rows := SQL%ROWCOUNT;
4609 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4610 trace(p_msg => '# xla_descript_details_b delete : '||l_num_rows,
4611 p_module => l_log_module,
4612 p_level => C_LEVEL_STATEMENT);
4613 END IF;
4614 -- Bug : 9923803
4615 -- API Call to Insert messages into AAD Loader Log Table.
4616 xla_aad_loader_util_pvt.insert_aadloaderlog(
4617 p_amb_context_code => g_amb_context_code,
4618 p_application_id => g_application_id,
4619 p_request_code => 'IMPORT' ,
4620 p_log_type_code => 'MERGE',
4621 p_encoded_message => '# xla_descript_details_b delete : '||l_num_rows,
4622 p_component_code => 'merge_descriptions');
4623
4624 DELETE FROM xla_descript_details_tl w
4625 WHERE description_detail_id IN
4626 (SELECT description_detail_id
4627 FROM xla_descript_details_b d
4628 , xla_desc_priorities w
4629 , xla_desc_priorities s
4630 WHERE d.description_prio_id = w.description_prio_id
4631 AND s.application_id = g_application_id
4632 AND s.amb_context_code = g_staging_context_code
4633 AND s.application_id = g_application_id
4634 AND s.amb_context_code = g_amb_context_code
4635 AND w.description_type_code = s.description_type_code
4636 AND w.description_code = s.description_code);
4637 l_num_rows := SQL%ROWCOUNT;
4638 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4639 trace(p_msg => '# xla_descript_details_tl delete : '||l_num_rows,
4640 p_module => l_log_module,
4641 p_level => C_LEVEL_STATEMENT);
4642 END IF;
4643 -- Bug : 9923803
4644 -- API Call to Insert messages into AAD Loader Log Table.
4645 xla_aad_loader_util_pvt.insert_aadloaderlog(
4646 p_amb_context_code => g_amb_context_code,
4647 p_application_id => g_application_id,
4648 p_request_code => 'IMPORT' ,
4649 p_log_type_code => 'MERGE',
4650 p_encoded_message => '# xla_descript_details_tl delete : '||l_num_rows,
4651 p_component_code => 'merge_descriptions');
4652 END IF;
4653
4654 -- Move the descriptions from staging area to working area
4655 UPDATE xla_descriptions_b
4656 SET amb_context_code = g_amb_context_code
4657 WHERE application_id = g_application_id
4658 AND amb_context_code = g_staging_context_code;
4659 l_num_rows := SQL%ROWCOUNT;
4660 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4661 trace(p_msg => '# xla_descriptions_b updated : '||l_num_rows,
4662 p_module => l_log_module,
4663 p_level => C_LEVEL_STATEMENT);
4664 END IF;
4665 -- Bug : 9923803
4666 -- API Call to Insert messages into AAD Loader Log Table.
4667 xla_aad_loader_util_pvt.insert_aadloaderlog(
4668 p_amb_context_code => g_amb_context_code,
4669 p_application_id => g_application_id,
4670 p_request_code => 'IMPORT' ,
4671 p_log_type_code => 'MERGE',
4672 p_encoded_message => '# xla_descriptions_b updated : '||l_num_rows,
4673 p_component_code => 'merge_descriptions');
4674
4675 UPDATE xla_descriptions_tl w
4676 SET amb_context_code = g_amb_context_code
4677 WHERE application_id = g_application_id
4678 AND amb_context_code = g_staging_context_code
4679 AND NOT EXISTS (SELECT 1
4680 FROM xla_descriptions_tl s
4681 WHERE s.application_id = g_application_id
4682 AND s.amb_context_code = g_amb_context_code
4683 AND s.description_type_code = w.description_type_code
4684 AND s.name = w.name
4685 AND s.language = w.language);
4686 l_num_rows := SQL%ROWCOUNT;
4687 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4688 trace(p_msg => '# xla_descriptions_tl 1 updated : '||l_num_rows,
4689 p_module => l_log_module,
4690 p_level => C_LEVEL_STATEMENT);
4691 END IF;
4692 -- Bug : 9923803
4693 -- API Call to Insert messages into AAD Loader Log Table.
4694 xla_aad_loader_util_pvt.insert_aadloaderlog(
4695 p_amb_context_code => g_amb_context_code,
4696 p_application_id => g_application_id,
4697 p_request_code => 'IMPORT' ,
4698 p_log_type_code => 'MERGE',
4699 p_encoded_message => '# xla_descriptions_tl 1 updated : '||l_num_rows,
4700 p_component_code => 'merge_descriptions');
4701
4702 UPDATE xla_descriptions_tl w
4703 SET amb_context_code = g_amb_context_code
4704 , name = substr('('||w.description_code||') '||name,1,80)
4705 WHERE application_id = g_application_id
4706 AND amb_context_code = g_staging_context_code
4707 AND EXISTS (SELECT 1
4708 FROM xla_descriptions_tl s
4709 WHERE s.application_id = g_application_id
4710 AND s.amb_context_code = g_amb_context_code
4711 AND s.description_type_code = w.description_type_code
4712 AND s.name = w.name
4713 AND s.language = w.language);
4714 l_num_rows := SQL%ROWCOUNT;
4715
4716 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4717 trace(p_msg => '# xla_descriptions_tl 2 updated : '||l_num_rows,
4718 p_module => l_log_module,
4719 p_level => C_LEVEL_STATEMENT);
4720 END IF;
4721 -- Bug : 9923803
4722 -- API Call to Insert messages into AAD Loader Log Table.
4723 xla_aad_loader_util_pvt.insert_aadloaderlog(
4724 p_amb_context_code => g_amb_context_code,
4725 p_application_id => g_application_id,
4726 p_request_code => 'IMPORT' ,
4727 p_log_type_code => 'MERGE',
4728 p_encoded_message => '# xla_descriptions_tl 2 updated : '||l_num_rows,
4729 p_component_code => 'merge_descriptions');
4730 UPDATE xla_desc_priorities
4731 SET amb_context_code = g_amb_context_code
4732 WHERE application_id = g_application_id
4733 AND amb_context_code = g_staging_context_code;
4734 l_num_rows := SQL%ROWCOUNT;
4735 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4736 trace(p_msg => '# xla_desc_priorities updated : '||l_num_rows,
4737 p_module => l_log_module,
4738 p_level => C_LEVEL_STATEMENT);
4739 END IF;
4740 -- Bug : 9923803
4741 -- API Call to Insert messages into AAD Loader Log Table.
4742 xla_aad_loader_util_pvt.insert_aadloaderlog(
4743 p_amb_context_code => g_amb_context_code,
4744 p_application_id => g_application_id,
4745 p_request_code => 'IMPORT' ,
4746 p_log_type_code => 'MERGE',
4747 p_encoded_message => '# xla_desc_priorities updated : '||l_num_rows,
4748 p_component_code => 'merge_descriptions');
4749
4750 UPDATE xla_conditions
4751 SET amb_context_code = g_amb_context_code
4752 WHERE amb_context_code = g_staging_context_code
4753 AND application_id = g_application_id
4754 AND description_prio_id IS NOT NULL;
4755 l_num_rows := SQL%ROWCOUNT;
4756 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4757 trace(p_msg => '# xla_conditions updated : '||l_num_rows,
4758 p_module => l_log_module,
4759 p_level => C_LEVEL_STATEMENT);
4760 END IF;
4761 -- Bug : 9923803
4762 -- API Call to Insert messages into AAD Loader Log Table.
4763 xla_aad_loader_util_pvt.insert_aadloaderlog(
4764 p_amb_context_code => g_amb_context_code,
4765 p_application_id => g_application_id,
4766 p_request_code => 'IMPORT' ,
4767 p_log_type_code => 'MERGE',
4768 p_encoded_message => '# xla_conditions updated : '||l_num_rows,
4769 p_component_code => 'merge_descriptions');
4770
4771 UPDATE xla_descript_details_b
4772 SET amb_context_code = g_amb_context_code
4773 WHERE amb_context_code = g_staging_context_code;
4774 l_num_rows := SQL%ROWCOUNT;
4775 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4776 trace(p_msg => '# xla_descript_details_b updated : '||l_num_rows,
4777 p_module => l_log_module,
4778 p_level => C_LEVEL_STATEMENT);
4779 END IF;
4780 -- Bug : 9923803
4781 -- API Call to Insert messages into AAD Loader Log Table.
4782 xla_aad_loader_util_pvt.insert_aadloaderlog(
4783 p_amb_context_code => g_amb_context_code,
4784 p_application_id => g_application_id,
4785 p_request_code => 'IMPORT' ,
4786 p_log_type_code => 'MERGE',
4787 p_encoded_message => '# xla_descript_details_b updated : '||l_num_rows,
4788 p_component_code => 'merge_descriptions');
4789
4790 UPDATE xla_descript_details_tl
4791 SET amb_context_code = g_amb_context_code
4792 WHERE amb_context_code = g_staging_context_code;
4793 l_num_rows := SQL%ROWCOUNT;
4794 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4795 trace(p_msg => '# xla_descript_details_tl updated : '||l_num_rows,
4796 p_module => l_log_module,
4797 p_level => C_LEVEL_STATEMENT);
4798 END IF;
4799 -- Bug : 9923803
4800 -- API Call to Insert messages into AAD Loader Log Table.
4801 xla_aad_loader_util_pvt.insert_aadloaderlog(
4802 p_amb_context_code => g_amb_context_code,
4803 p_application_id => g_application_id,
4804 p_request_code => 'IMPORT' ,
4805 p_log_type_code => 'MERGE',
4806 p_encoded_message => '# xla_descript_details_tl updated : '||l_num_rows,
4807 p_component_code => 'merge_descriptions');
4808 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4809 trace(p_msg => 'END of procedure merge_descriptions',
4810 p_module => l_log_module,
4811 p_level => C_LEVEL_PROCEDURE);
4812 END IF;
4813
4814 EXCEPTION
4815 WHEN OTHERS THEN
4816 xla_aad_loader_util_pvt.stack_error
4817 (p_appli_s_name => 'XLA'
4818 ,p_msg_name => 'XLA_COMMON_ERROR'
4819 ,p_token_1 => 'LOCATION'
4820 ,p_value_1 => 'xla_aad_merge_pvt.merge_descriptions'
4821 ,p_token_2 => 'ERROR'
4822 ,p_value_2 => 'unhandled exception');
4823 RAISE;
4824
4825 END merge_descriptions;
4826
4827
4828 --=============================================================================
4829 --
4830 -- Name: merge_analytical_criteria
4831 -- Description: Merge analytical criteria from staging to working area
4832 -- Changes:
4833 -- 8230704 and 7692291 Simran: overriding the changes done as part of bug 7243326
4834 --=============================================================================
4835 PROCEDURE merge_analytical_criteria
4836 IS
4837 -- Retrieve the AC to be merged
4838 CURSOR c_ac IS
4839 SELECT s.analytical_criterion_type_code, s.analytical_criterion_code
4840 FROM xla_analytical_hdrs_b s
4841 , xla_analytical_hdrs_b w
4842 WHERE s.amb_context_code = g_staging_context_code
4843 AND w.amb_context_code(+) = g_amb_context_code
4844 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code(+)
4845 AND s.analytical_criterion_code = w.analytical_criterion_code(+)
4846 AND s.version_num >= w.version_num(+);
4847
4848 -- Added cursor for DTLs as part of bug 7243326 - This is mainly for AR where AR does not have a HDR and following DELETES and UPDATES dont loop
4849
4850 CURSOR c_ac_dtls IS
4851 SELECT s.analytical_criterion_type_code, s.analytical_criterion_code,s.ANALYTICAL_DETAIL_CODE
4852 FROM xla_analytical_dtls_b s
4853 , xla_analytical_dtls_b w
4854 WHERE s.amb_context_code = g_staging_context_code
4855 AND w.amb_context_code(+) = g_amb_context_code
4856 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code(+)
4857 AND s.analytical_criterion_code = w.analytical_criterion_code(+)
4858 AND s.ANALYTICAL_DETAIL_CODE = w.ANALYTICAL_DETAIL_CODE(+) ;
4859
4860 CURSOR c_ac_src IS
4861 SELECT s.analytical_criterion_type_code, s.analytical_criterion_code,s.ANALYTICAL_DETAIL_CODE,
4862 s.event_class_code,s.entity_code,s.source_code,s.source_type_code
4863 FROM xla_analytical_sources s
4864 , xla_analytical_sources w
4865 WHERE s.amb_context_code = g_staging_context_code
4866 AND w.amb_context_code(+) = g_amb_context_code
4867 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code(+)
4868 AND s.analytical_criterion_code = w.analytical_criterion_code(+)
4869 AND s.ANALYTICAL_DETAIL_CODE = w.ANALYTICAL_DETAIL_CODE(+)
4870 AND s.event_class_code = w.event_class_code(+)
4871 AND s.entity_code = w.entity_code(+)
4872 AND s.source_code = w.source_code(+)
4873 AND s.source_type_code = w.source_type_code(+);
4874
4875
4876 l_ac_detail_code t_array_varchar30;
4877 l_ac_dtl_type_codes t_array_varchar30;
4878 l_ac_dtl_codes t_array_varchar30;
4879 l_ac_src_event_class t_array_varchar30;
4880 l_ac_src_entity_code t_array_varchar30;
4881 l_ac_src_source_code t_array_varchar30;
4882 l_ac_src_source_type_code t_array_varchar30;
4883
4884 --Bug 10060589. Creating new arrays to collect the values of cursor c_ac_src
4885 l_ac_src_type_codes t_array_varchar30;
4886 l_ac_src_codes t_array_varchar30;
4887 l_ac_src_detail_code t_array_varchar30;
4888
4889 l_ac_type_codes t_array_varchar30;
4890 l_ac_codes t_array_varchar30;
4891 l_log_module VARCHAR2(240);
4892 l_num_rows NUMBER;
4893 l_exception VARCHAR2(240);
4894 l_excp_code VARCHAR2(100);
4895 BEGIN
4896 IF g_log_enabled THEN
4897 l_log_module := C_DEFAULT_MODULE||'.merge_analytical_criteria';
4898 END IF;
4899
4900 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4901 trace(p_msg => 'BEGIN of procedure merge_analytical_criteria',
4902 p_module => l_log_module,
4903 p_level => C_LEVEL_PROCEDURE);
4904 END IF;
4905
4906 /*************************************************/
4907 /**** Added by krsankar for Performance changes **/
4908 /*************************************************/
4909
4910 INSERT INTO xla_aads_gt
4911 ( analytical_criterion_code,
4912 table_name
4913 )
4914 select analytical_criterion_code,
4915 'XLA_ANALYTICAL_HDRS_B'
4916 from
4917 (select analytical_criterion_code,
4918 'XLA_ANALYTICAL_HDRS_B',
4919 amb_context_code,
4920 last_update_date ,
4921 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
4922 from
4923 (select analytical_criterion_code,
4924 'XLA_ANALYTICAL_HDRS_B',
4925 amb_context_code,
4926 last_update_date ,
4927 lag(last_update_date) over (PARTITION by application_id,
4928 analytical_criterion_code,
4929 analytical_criterion_type_code
4930 order by amb_context_code
4931 ) lag_date
4932 from xla_analytical_hdrs_b
4933 order by amb_context_code
4934 ) x
4935 where x.amb_context_code = g_staging_context_code
4936 )
4937 where flag = 'False';
4938 l_num_rows := SQL%ROWCOUNT;
4939
4940 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4941 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_analytical_hdrs_b is :'||l_num_rows,
4942 p_module => l_log_module,
4943 p_level => C_LEVEL_PROCEDURE);
4944 END IF;
4945
4946 -- Bug : 9923803
4947 -- API Call to Insert messages into AAD Loader Log Table.
4948 xla_aad_loader_util_pvt.insert_aadloaderlog(
4949 p_amb_context_code => g_amb_context_code,
4950 p_application_id => g_application_id,
4951 p_request_code => 'IMPORT' ,
4952 p_log_type_code => 'MERGE',
4953 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_analytical_hdrs_b is :'||l_num_rows,
4954 p_component_code => 'merge_analytical_criteria');
4955
4956 INSERT INTO xla_aads_gt
4957 ( analytical_criterion_code,
4958 analytical_detail_code,
4959 table_name
4960 )
4961 select analytical_criterion_code,
4962 analytical_detail_code,
4963 'XLA_ANALYTICAL_DTLS_B'
4964 from
4965 (select analytical_criterion_code,
4966 analytical_detail_code,
4967 'XLA_ANALYTICAL_DTLS_B',
4968 amb_context_code,
4969 last_update_date ,
4970 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
4971 from
4972 (select analytical_criterion_code,
4973 analytical_detail_code,
4974 'XLA_ANALYTICAL_DTLS_B',
4975 amb_context_code,
4976 last_update_date ,
4977 lag(last_update_date) over (PARTITION by analytical_criterion_code,
4978 analytical_criterion_type_code,
4979 analytical_detail_code
4980 order by amb_context_code
4981 ) lag_date
4982 from xla_analytical_dtls_b
4983 order by amb_context_code
4984 ) x
4985 where x.amb_context_code = g_staging_context_code
4986 )
4987 where flag = 'False';
4988
4989 l_num_rows := SQL%ROWCOUNT;
4990 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4991 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_analytical_dtls_b is :'||l_num_rows,
4992 p_module => l_log_module,
4993 p_level => C_LEVEL_PROCEDURE);
4994 END IF;
4995 -- Bug : 9923803
4996 -- API Call to Insert messages into AAD Loader Log Table.
4997 xla_aad_loader_util_pvt.insert_aadloaderlog(
4998 p_amb_context_code => g_amb_context_code,
4999 p_application_id => g_application_id,
5000 p_request_code => 'IMPORT' ,
5001 p_log_type_code => 'MERGE',
5002 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_analytical_dtls_b is :'||l_num_rows,
5003 p_component_code => 'merge_analytical_criteria');
5004
5005 INSERT INTO xla_aads_gt
5006 ( analytical_criterion_code,
5007 analytical_detail_code,
5008 entity_code,
5009 event_class_code,
5010 source_code,
5011 table_name
5012 )
5013 select analytical_criterion_code,
5014 analytical_detail_code,
5015 entity_code,
5016 event_class_code,
5017 source_code,
5018 'XLA_ANALYTICAL_SOURCES'
5019 from
5020 (select analytical_criterion_code,
5021 analytical_detail_code,
5022 entity_code,
5023 event_class_code,
5024 source_code,
5025 'XLA_ANALYTICAL_SOURCES',
5026 amb_context_code,
5027 last_update_date ,
5028 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
5029 from
5030 (select analytical_criterion_code,
5031 analytical_detail_code,
5032 entity_code,
5033 event_class_code,
5034 source_code,
5035 'XLA_ANALYTICAL_SOURCES',
5036 amb_context_code,
5037 last_update_date ,
5038 lag(last_update_date) over (PARTITION by application_id,
5039 analytical_criterion_code,
5040 analytical_criterion_type_code,
5041 analytical_detail_code,
5042 entity_code,
5043 event_class_code,
5044 source_code,
5045 source_type_code
5046 order by amb_context_code
5047 ) lag_date
5048 from xla_analytical_sources
5049 order by amb_context_code
5050 ) x
5051 where x.amb_context_code = g_staging_context_code
5052 )
5053 where flag = 'False';
5054
5055 l_num_rows := SQL%ROWCOUNT;
5056
5057
5058 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5059 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_analytical_sources is :'||l_num_rows,
5060 p_module => l_log_module,
5061 p_level => C_LEVEL_PROCEDURE);
5062 END IF;
5063
5064 -- Bug : 9923803
5065 -- API Call to Insert messages into AAD Loader Log Table.
5066 xla_aad_loader_util_pvt.insert_aadloaderlog(
5067 p_amb_context_code => g_amb_context_code,
5068 p_application_id => g_application_id,
5069 p_request_code => 'IMPORT' ,
5070 p_log_type_code => 'MERGE',
5071 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_analytical_sources is :'||l_num_rows,
5072 p_component_code => 'merge_analytical_criteria');
5073
5074 IF (g_analyzed_flag = 'Y') THEN
5075 null;
5076
5077 ELSE
5078
5079 /* 8230704 and 7692291: all the 3 tables are independant of each other. AR ldt wouldnt load any header as all headers
5080 r right now with 200 application_id. But AR ldt would load details and would load all sources.
5081 Need to keep sources separate, as the delete should remove only those sources that r in the ldt NOT sources that
5082 belong to a header/dtl loaded.
5083 */
5084
5085 OPEN c_ac;
5086 FETCH c_ac BULK COLLECT INTO l_ac_type_codes, l_ac_codes;
5087 CLOSE c_ac;
5088
5089 OPEN c_ac_dtls ;
5090 FETCH c_ac_dtls BULK COLLECT INTO l_ac_dtl_type_codes, l_ac_dtl_codes, l_ac_detail_code;
5091 CLOSE c_ac_dtls ;
5092
5093 --Bug 10060589- Using different arrays for cursor c_ac_src : l_ac_src_type_codes,l_ac_src_codes,l_ac_src_detail_code
5094 OPEN c_ac_src ;
5095 FETCH c_ac_src BULK COLLECT INTO l_ac_src_type_codes, l_ac_src_codes,
5096 l_ac_src_detail_code, l_ac_src_event_class,l_ac_src_entity_code,
5097 l_ac_src_source_code,l_ac_src_source_type_code;
5098 CLOSE c_ac_src ;
5099
5100 -- Delete the ACs from the working area for the AC to be merged
5101 FORALL i IN 1..l_ac_codes.COUNT
5102 DELETE FROM xla_analytical_hdrs_b w
5103 WHERE amb_context_code = g_amb_context_code
5104 AND analytical_criterion_type_code = l_ac_type_codes(i)
5105 AND analytical_criterion_code = l_ac_codes(i)
5106 AND EXISTS
5107 ( SELECT 1
5108 FROM xla_analytical_hdrs_b s
5109 WHERE s.amb_context_code = g_staging_context_code
5110 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
5111 AND s.analytical_criterion_code = w.analytical_criterion_code );
5112 l_num_rows := SQL%ROWCOUNT;
5113 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5114 trace(p_msg => '# xla_analytical_hdrs_b delete : '||l_num_rows,
5115 p_module => l_log_module,
5116 p_level => C_LEVEL_STATEMENT);
5117 END IF;
5118 -- Bug : 9923803
5119 -- API Call to Insert messages into AAD Loader Log Table.
5120 xla_aad_loader_util_pvt.insert_aadloaderlog(
5121 p_amb_context_code => g_amb_context_code,
5122 p_application_id => g_application_id,
5123 p_request_code => 'IMPORT' ,
5124 p_log_type_code => 'MERGE',
5125 p_encoded_message => '# xla_analytical_hdrs_b delete : '||l_num_rows,
5126 p_component_code => 'merge_analytical_criteria');
5127
5128 FORALL i IN 1..l_ac_codes.COUNT
5129 DELETE FROM xla_analytical_hdrs_tl w
5130 WHERE amb_context_code = g_amb_context_code
5131 AND analytical_criterion_type_code = l_ac_type_codes(i)
5132 AND analytical_criterion_code = l_ac_codes(i)
5133 AND EXISTS
5134 ( SELECT 1
5135 FROM xla_analytical_hdrs_tl s
5136 WHERE s.amb_context_code = g_staging_context_code
5137 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
5138 AND s.analytical_criterion_code = w.analytical_criterion_code
5139 AND s.language = w.language);
5140 l_num_rows := SQL%ROWCOUNT;
5141 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5142 trace(p_msg => '# xla_analytical_hdrs_tl delete : '||l_num_rows,
5143 p_module => l_log_module,
5144 p_level => C_LEVEL_STATEMENT);
5145 END IF;
5146 -- Bug : 9923803
5147 -- API Call to Insert messages into AAD Loader Log Table.
5148 xla_aad_loader_util_pvt.insert_aadloaderlog(
5149 p_amb_context_code => g_amb_context_code,
5150 p_application_id => g_application_id,
5151 p_request_code => 'IMPORT' ,
5152 p_log_type_code => 'MERGE',
5153 p_encoded_message => '# xla_analytical_hdrs_tl delete : '||l_num_rows,
5154 p_component_code => 'merge_analytical_criteria');
5155
5156 -- Delete the AC dtlss from the working area for the AC dtls to be merged
5157 FORALL i IN 1..l_ac_dtl_codes.COUNT
5158 DELETE FROM xla_analytical_dtls_b w
5159 WHERE amb_context_code = g_amb_context_code
5160 AND analytical_criterion_type_code = l_ac_dtl_type_codes(i)
5161 AND analytical_criterion_code = l_ac_dtl_codes(i)
5162 AND analytical_detail_code = l_ac_detail_code(i)
5163 AND EXISTS
5164 ( SELECT 1
5165 FROM xla_analytical_dtls_b s
5166 WHERE s.amb_context_code = g_staging_context_code
5167 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
5168 AND s.analytical_criterion_code = w.analytical_criterion_code
5169 AND s.analytical_detail_code = w.analytical_detail_code);
5170 l_num_rows := SQL%ROWCOUNT;
5171 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5172 trace(p_msg => '# xla_analytical_dtls_b delete : '||l_num_rows,
5173 p_module => l_log_module,
5174 p_level => C_LEVEL_STATEMENT);
5175 END IF;
5176
5177 -- Bug : 9923803
5178 -- API Call to Insert messages into AAD Loader Log Table.
5179 xla_aad_loader_util_pvt.insert_aadloaderlog(
5180 p_amb_context_code => g_amb_context_code,
5181 p_application_id => g_application_id,
5182 p_request_code => 'IMPORT' ,
5183 p_log_type_code => 'UPLOAD',
5184 p_encoded_message => '# row populated in XLA_STAGING_COMPONENTS_H = '||l_num_rows,
5185 p_component_code => 'populate_history');
5186
5187 FORALL i IN 1..l_ac_dtl_codes.COUNT
5188 DELETE FROM xla_analytical_dtls_tl w
5189 WHERE amb_context_code = g_amb_context_code
5190 AND analytical_criterion_type_code = l_ac_dtl_type_codes(i)
5191 AND analytical_criterion_code = l_ac_dtl_codes(i)
5192 AND analytical_detail_code = l_ac_detail_code(i)
5193 AND EXISTS
5194 ( SELECT 1
5195 FROM xla_analytical_dtls_tl s
5196 WHERE s.amb_context_code = g_staging_context_code
5197 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
5198 AND s.analytical_criterion_code = w.analytical_criterion_code
5199 AND s.analytical_detail_code = w.analytical_detail_code
5200 AND s.language = w.language);
5201 l_num_rows := SQL%ROWCOUNT;
5202 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5203 trace(p_msg => '# xla_analytical_dtls_tl delete : '||l_num_rows,
5204 p_module => l_log_module,
5205 p_level => C_LEVEL_STATEMENT);
5206 END IF;
5207 -- Bug : 9923803
5208 -- API Call to Insert messages into AAD Loader Log Table.
5209 xla_aad_loader_util_pvt.insert_aadloaderlog(
5210 p_amb_context_code => g_amb_context_code,
5211 p_application_id => g_application_id,
5212 p_request_code => 'IMPORT' ,
5213 p_log_type_code => 'MERGE',
5214 p_encoded_message => '# xla_analytical_dtls_tl delete : '||l_num_rows,
5215 p_component_code => 'merge_analytical_criteria');
5216
5217 FORALL i IN 1..l_ac_src_event_class.COUNT
5218 DELETE FROM xla_analytical_sources w
5219 WHERE amb_context_code = g_amb_context_code
5220 AND analytical_criterion_type_code = l_ac_src_type_codes(i) --Bug 10060589
5221 AND analytical_criterion_code = l_ac_src_codes(i) --Bug 10060589
5222 AND analytical_detail_code = l_ac_src_detail_code(i) --Bug 10060589 -- Added for bug 8268819
5223 AND event_class_code =l_ac_src_event_class(i)
5224 AND ENTITY_CODE =l_ac_src_entity_code(i)
5225 AND SOURCE_CODE =l_ac_src_source_code(i)
5226 AND SOURCE_TYPE_CODE =l_ac_src_source_type_code(i)
5227 AND EXISTS
5228 ( SELECT 1
5229 FROM xla_analytical_sources s
5230 WHERE s.amb_context_code = g_staging_context_code
5231 AND s.analytical_criterion_type_code = w.analytical_criterion_type_code
5232 AND s.analytical_criterion_code = w.analytical_criterion_code
5233 AND s.analytical_detail_code = w.analytical_detail_code -- Added for bug 8268819
5234 AND s.entity_code = w.entity_code
5235 AND s.event_class_code = w.event_class_code
5236 AND s.source_code = w.source_code
5237 AND s.source_type_code = w.source_type_code);
5238 l_num_rows := SQL%ROWCOUNT;
5239 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5240 trace(p_msg => '# xla_analytical_sources delete : '||l_num_rows,
5241 p_module => l_log_module,
5242 p_level => C_LEVEL_STATEMENT);
5243 END IF;
5244 -- Bug : 9923803
5245 -- API Call to Insert messages into AAD Loader Log Table.
5246 xla_aad_loader_util_pvt.insert_aadloaderlog(
5247 p_amb_context_code => g_amb_context_code,
5248 p_application_id => g_application_id,
5249 p_request_code => 'IMPORT' ,
5250 p_log_type_code => 'MERGE',
5251 p_encoded_message => '# xla_analytical_sources delete : '||l_num_rows,
5252 p_component_code => 'merge_analytical_criteria');
5253 END IF;
5254
5255 -- Move the analytical criteria from staging area to working area
5256 FORALL i IN 1..l_ac_codes.COUNT
5257 UPDATE xla_analytical_hdrs_b
5258 SET amb_context_code = g_amb_context_code
5259 WHERE amb_context_code = g_staging_context_code
5260 AND analytical_criterion_type_code = l_ac_type_codes(i)
5261 AND analytical_criterion_code = l_ac_codes(i);
5262
5263 l_num_rows := SQL%ROWCOUNT;
5264 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5265 trace(p_msg => '# xla_analytical_hdrs_b updated : '||l_num_rows,
5266 p_module => l_log_module,
5267 p_level => C_LEVEL_STATEMENT);
5268 END IF;
5269 -- Bug : 9923803
5270 -- API Call to Insert messages into AAD Loader Log Table.
5271 xla_aad_loader_util_pvt.insert_aadloaderlog(
5272 p_amb_context_code => g_amb_context_code,
5273 p_application_id => g_application_id,
5274 p_request_code => 'IMPORT' ,
5275 p_log_type_code => 'MERGE',
5276 p_encoded_message => '# xla_analytical_hdrs_b updated : '||l_num_rows,
5277 p_component_code => 'merge_analytical_criteria');
5278
5279 FORALL i IN 1..l_ac_codes.COUNT
5280 UPDATE xla_analytical_hdrs_tl s
5281 SET amb_context_code = g_amb_context_code
5282 WHERE amb_context_code = g_staging_context_code
5283 AND analytical_criterion_type_code = l_ac_type_codes(i)
5284 AND analytical_criterion_code = l_ac_codes(i)
5285 AND NOT EXISTS (SELECT 1
5286 FROM xla_analytical_hdrs_tl w
5287 WHERE w.amb_context_code = g_amb_context_code
5288 AND w.analytical_criterion_type_code = s.analytical_criterion_type_code
5289 AND w.name = s.name
5290 AND w.language = s.language);
5291 l_num_rows := SQL%ROWCOUNT;
5292 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5293 trace(p_msg => '# xla_analytical_hdrs_tl 1 updated : '||l_num_rows,
5294 p_module => l_log_module,
5295 p_level => C_LEVEL_STATEMENT);
5296 END IF;
5297 -- Bug : 9923803
5298 -- API Call to Insert messages into AAD Loader Log Table.
5299 xla_aad_loader_util_pvt.insert_aadloaderlog(
5300 p_amb_context_code => g_amb_context_code,
5301 p_application_id => g_application_id,
5302 p_request_code => 'IMPORT' ,
5303 p_log_type_code => 'MERGE',
5304 p_encoded_message => '# xla_analytical_hdrs_tl 1 updated : '||l_num_rows,
5305 p_component_code => 'merge_analytical_criteria');
5306
5307 FORALL i IN 1..l_ac_codes.COUNT
5308 UPDATE xla_analytical_hdrs_tl s
5309 SET amb_context_code = g_amb_context_code
5310 , name = substr('('||s.analytical_criterion_code||') '||name,1,80)
5311 WHERE amb_context_code = g_staging_context_code
5312 AND analytical_criterion_type_code = l_ac_type_codes(i)
5313 AND analytical_criterion_code = l_ac_codes(i)
5314 AND EXISTS (SELECT 1
5315 FROM xla_analytical_hdrs_tl w
5316 WHERE w.amb_context_code = g_amb_context_code
5317 AND w.analytical_criterion_type_code = s.analytical_criterion_type_code
5318 AND w.name = s.name
5319 AND w.language = s.language);
5320 l_num_rows := SQL%ROWCOUNT;
5321 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5322 trace(p_msg => '# xla_analytical_hdrs_tl 2 updated : '||l_num_rows,
5323 p_module => l_log_module,
5324 p_level => C_LEVEL_STATEMENT);
5325 END IF;
5326 -- Bug : 9923803
5327 -- API Call to Insert messages into AAD Loader Log Table.
5328 xla_aad_loader_util_pvt.insert_aadloaderlog(
5329 p_amb_context_code => g_amb_context_code,
5330 p_application_id => g_application_id,
5331 p_request_code => 'IMPORT' ,
5332 p_log_type_code => 'MERGE',
5333 p_encoded_message => '# xla_analytical_hdrs_tl 2 updated : '||l_num_rows,
5334 p_component_code => 'merge_analytical_criteria');
5335
5336 FORALL i IN 1..l_ac_dtl_codes.COUNT
5337 UPDATE xla_analytical_dtls_b
5338 SET amb_context_code = g_amb_context_code
5339 WHERE amb_context_code = g_staging_context_code
5340 AND analytical_criterion_type_code = l_ac_dtl_type_codes(i)
5341 AND analytical_criterion_code = l_ac_dtl_codes(i)
5342 AND analytical_detail_code = l_ac_detail_code(i);
5343 l_num_rows := SQL%ROWCOUNT;
5344 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5345 trace(p_msg => '# xla_analytical_dtls_b updated : '||l_num_rows,
5346 p_module => l_log_module,
5347 p_level => C_LEVEL_STATEMENT);
5348 END IF;
5349 -- Bug : 9923803
5350 -- API Call to Insert messages into AAD Loader Log Table.
5351 xla_aad_loader_util_pvt.insert_aadloaderlog(
5352 p_amb_context_code => g_amb_context_code,
5353 p_application_id => g_application_id,
5354 p_request_code => 'IMPORT' ,
5355 p_log_type_code => 'MERGE',
5356 p_encoded_message => '# xla_analytical_dtls_b updated : '||l_num_rows,
5357 p_component_code => 'merge_analytical_criteria');
5358
5359 FORALL i IN 1..l_ac_dtl_codes.COUNT
5360 UPDATE xla_analytical_dtls_tl s
5361 SET amb_context_code = g_amb_context_code
5362 WHERE amb_context_code = g_staging_context_code
5363 AND analytical_criterion_type_code = l_ac_dtl_type_codes(i)
5364 AND analytical_criterion_code = l_ac_dtl_codes(i)
5365 AND analytical_detail_code = l_ac_detail_code(i)
5366 AND NOT EXISTS (SELECT 1
5367 FROM xla_analytical_dtls_tl w
5368 WHERE w.amb_context_code = g_amb_context_code
5369 AND w.analytical_criterion_type_code = s.analytical_criterion_type_code
5370 AND s.analytical_criterion_code = s.analytical_criterion_code
5371 AND s.analytical_detail_code = s.analytical_detail_code
5372 AND w.name = s.name
5373 AND w.language = s.language);
5374 l_num_rows := SQL%ROWCOUNT;
5375 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5376 trace(p_msg => '# xla_analytical_dtls_tl 1 updated : '||l_num_rows,
5377 p_module => l_log_module,
5378 p_level => C_LEVEL_STATEMENT);
5379 END IF;
5380
5381 -- Bug : 9923803
5382 -- API Call to Insert messages into AAD Loader Log Table.
5383 xla_aad_loader_util_pvt.insert_aadloaderlog(
5384 p_amb_context_code => g_amb_context_code,
5385 p_application_id => g_application_id,
5386 p_request_code => 'IMPORT' ,
5387 p_log_type_code => 'MERGE',
5388 p_encoded_message => '# xla_analytical_dtls_tl 1 updated : '||l_num_rows,
5389 p_component_code => 'merge_analytical_criteria');
5390
5391 FORALL i IN 1..l_ac_dtl_codes.COUNT
5392 UPDATE xla_analytical_dtls_tl w
5393 SET amb_context_code = g_amb_context_code
5394 , name = substr('('||w.analytical_detail_code||') '||name,1,80)
5395 WHERE amb_context_code = g_staging_context_code
5396 AND analytical_criterion_type_code = l_ac_dtl_type_codes(i)
5397 AND analytical_criterion_code = l_ac_dtl_codes(i)
5398 AND analytical_detail_code = l_ac_detail_code(i)
5399 AND EXISTS (SELECT 1
5400 FROM xla_analytical_dtls_tl s
5401 WHERE s.amb_context_code = g_amb_context_code
5402 AND w.analytical_criterion_type_code = s.analytical_criterion_type_code
5403 AND s.analytical_criterion_code = s.analytical_criterion_code
5404 AND s.analytical_detail_code = s.analytical_detail_code
5405 AND s.name = w.name
5406 AND s.language = w.language);
5407 l_num_rows := SQL%ROWCOUNT;
5408 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5409 trace(p_msg => '# xla_analytical_dtls_tl 2 updated : '||l_num_rows,
5410 p_module => l_log_module,
5411 p_level => C_LEVEL_STATEMENT);
5412 END IF;
5413 -- Bug : 9923803
5414 -- API Call to Insert messages into AAD Loader Log Table.
5415 xla_aad_loader_util_pvt.insert_aadloaderlog(
5416 p_amb_context_code => g_amb_context_code,
5417 p_application_id => g_application_id,
5418 p_request_code => 'IMPORT' ,
5419 p_log_type_code => 'MERGE',
5420 p_encoded_message => '# xla_analytical_dtls_tl 2 updated : '||l_num_rows,
5421 p_component_code => 'merge_analytical_criteria');
5422
5423 FORALL i IN 1..l_ac_src_event_class.COUNT
5424 UPDATE xla_analytical_sources
5425 SET amb_context_code = g_amb_context_code
5426 WHERE amb_context_code = g_staging_context_code
5427 AND analytical_criterion_type_code = l_ac_src_type_codes(i)--Bug 10060589
5428 AND analytical_criterion_code = l_ac_src_codes(i) --Bug 10060589
5429 AND analytical_detail_code = l_ac_src_detail_code(i) --Bug 10060589 -- Added for bug 8268819
5430 AND event_class_code =l_ac_src_event_class(i)
5431 AND ENTITY_CODE =l_ac_src_entity_code(i)
5432 AND SOURCE_CODE =l_ac_src_source_code(i)
5433 AND SOURCE_TYPE_CODE =l_ac_src_source_type_code(i);
5434
5435 l_num_rows := SQL%ROWCOUNT;
5436 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5437 trace(p_msg => '# xla_analytical_sources updated : '||l_num_rows,
5438 p_module => l_log_module,
5439 p_level => C_LEVEL_STATEMENT);
5440 END IF;
5441 -- Bug : 9923803
5442 -- API Call to Insert messages into AAD Loader Log Table.
5443 xla_aad_loader_util_pvt.insert_aadloaderlog(
5444 p_amb_context_code => g_amb_context_code,
5445 p_application_id => g_application_id,
5446 p_request_code => 'IMPORT' ,
5447 p_log_type_code => 'MERGE',
5448 p_encoded_message => '# xla_analytical_sources updated : '||l_num_rows,
5449 p_component_code => 'merge_analytical_criteria');
5450
5451 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5452 trace(p_msg => 'END of procedure merge_analytical_criteria',
5453 p_module => l_log_module,
5454 p_level => C_LEVEL_PROCEDURE);
5455 END IF;
5456
5457 EXCEPTION
5458 WHEN OTHERS THEN
5459
5460 l_exception := substr(sqlerrm,1,240);
5461 l_excp_code := sqlcode;
5462
5463 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5464 trace(p_msg => 'In exception of xla_aad_merge_pvt.merge_analytical_criteria',
5465 p_module => l_log_module,
5466 p_level => C_LEVEL_PROCEDURE);
5467 END IF;
5468
5469 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5470 trace(p_msg => 'Error in merge_analytical_criteria is : '||l_excp_code||' - '||l_exception,
5471 p_module => l_log_module,
5472 p_level => C_LEVEL_PROCEDURE);
5473 END IF;
5474
5475 xla_aad_loader_util_pvt.stack_error
5476 (p_appli_s_name => 'XLA'
5477 ,p_msg_name => 'XLA_COMMON_ERROR'
5478 ,p_token_1 => 'LOCATION'
5479 ,p_value_1 => 'xla_aad_merge_pvt.merge_analytical_criteria'
5480 ,p_token_2 => 'ERROR'
5481 ,p_value_2 => 'unhandled exception');
5482
5483 RAISE;
5484
5485 END merge_analytical_criteria;
5486
5487
5488 --=============================================================================
5489 --
5490 -- Name: merge_adrs
5491 -- Description: Merge ADRs from staging to working area
5492 --
5493 --=============================================================================
5494 PROCEDURE merge_adrs
5495 IS
5496 CURSOR c_adr IS
5497 SELECT s.segment_rule_type_code, s.segment_rule_code
5498 FROM xla_seg_rules_b w
5499 , xla_seg_rules_b s
5500 WHERE s.application_id = g_application_id
5501 AND s.amb_context_code = g_staging_context_code
5502 AND s.segment_rule_type_code = w.segment_rule_type_code
5503 AND s.segment_rule_code = w.segment_rule_code
5504 AND w.application_id = g_application_id
5505 AND w.amb_context_code = g_amb_context_code;
5506
5507 l_adr_type_codes t_array_varchar30;
5508 l_adr_codes t_array_varchar30;
5509 l_log_module VARCHAR2(240);
5510 l_num_rows INTEGER;
5511 BEGIN
5512 IF g_log_enabled THEN
5513 l_log_module := C_DEFAULT_MODULE||'.merge_adrs';
5514 END IF;
5515
5516 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5517 trace(p_msg => 'BEGIN of procedure merge_adrs',
5518 p_module => l_log_module,
5519 p_level => C_LEVEL_PROCEDURE);
5520 END IF;
5521
5522 /*************************************************/
5523 /**** Added by krsankar for Performance changes **/
5524 /*************************************************/
5525
5526 INSERT INTO xla_aads_gt
5527 ( segment_rule_code,
5528 table_name
5529 )
5530 select segment_rule_code,
5531 'XLA_SEG_RULE_DETAILS'
5532 from
5533 (select segment_rule_code,
5534 'XLA_SEG_RULE_DETAILS',
5535 amb_context_code,
5536 last_update_date ,
5537 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
5538 from
5539 (select segment_rule_code,
5540 'XLA_SEG_RULE_DETAILS',
5541 amb_context_code,
5542 last_update_date ,
5543 lag(last_update_date) over (PARTITION by application_id,
5544 segment_rule_code,
5545 segment_rule_type_code,
5546 user_sequence
5547 order by amb_context_code
5548 ) lag_date
5549 from xla_seg_rule_details
5550 order by amb_context_code
5551 ) x
5552 where x.amb_context_code = g_staging_context_code
5553 )
5554 where flag = 'False';
5555 l_num_rows := SQL%ROWCOUNT;
5556
5557
5558 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5559 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_seg_rule_details is :'||l_num_rows,
5560 p_module => l_log_module,
5561 p_level => C_LEVEL_PROCEDURE);
5562 END IF;
5563
5564 -- Bug : 9923803
5565 -- API Call to Insert messages into AAD Loader Log Table.
5566 xla_aad_loader_util_pvt.insert_aadloaderlog(
5567 p_amb_context_code => g_amb_context_code,
5568 p_application_id => g_application_id,
5569 p_request_code => 'IMPORT' ,
5570 p_log_type_code => 'MERGE',
5571 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_seg_rule_details is :'||l_num_rows,
5572 p_component_code => 'merge_adrs');
5573
5574 INSERT INTO xla_aads_gt
5575 ( segment_rule_code,
5576 table_name
5577 )
5578 select segment_rule_code,
5579 'XLA_SEG_RULES_B'
5580 from
5581 (select segment_rule_code,
5582 'XLA_SEG_RULES_B',
5583 amb_context_code,
5584 last_update_date ,
5585 nvl2(lag_date, decode(last_update_date,lag_date, 'True','False'),'False') flag
5586 from
5587 (select segment_rule_code,
5588 'XLA_SEG_RULES_B',
5589 amb_context_code,
5590 last_update_date ,
5591 lag(last_update_date) over (PARTITION by application_id,
5592 segment_rule_code,
5593 segment_rule_type_code
5594 order by amb_context_code
5595 ) lag_date
5596 from xla_seg_rules_b
5597 order by amb_context_code
5598 ) x
5599 where x.amb_context_code = g_staging_context_code
5600 )
5601 where flag = 'False';
5602 l_num_rows := SQL%ROWCOUNT;
5603 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5604 trace(p_msg => 'Number of Rows inserted into aads_gt from xla_seg_rules_b is :'||l_num_rows,
5605 p_module => l_log_module,
5606 p_level => C_LEVEL_PROCEDURE);
5607 END IF;
5608 -- Bug : 9923803
5609 -- API Call to Insert messages into AAD Loader Log Table.
5610 xla_aad_loader_util_pvt.insert_aadloaderlog(
5611 p_amb_context_code => g_amb_context_code,
5612 p_application_id => g_application_id,
5613 p_request_code => 'IMPORT' ,
5614 p_log_type_code => 'MERGE',
5615 p_encoded_message => 'Number of Rows inserted into aads_gt from xla_seg_rules_b is :'||l_num_rows,
5616 p_component_code => 'merge_adrs');
5617
5618 IF (g_analyzed_flag = 'Y') THEN
5619 null;
5620
5621 ELSE
5622
5623 OPEN c_adr;
5624 FETCH c_adr BULK COLLECT INTO l_adr_type_codes, l_adr_codes;
5625 CLOSE c_adr;
5626
5627 IF (l_adr_codes.COUNT > 0) THEN
5628 -- Delete the ADRs from the working area to be merged
5629 FORALL i IN 1..l_adr_codes.COUNT
5630 DELETE FROM xla_conditions c
5631 WHERE amb_context_code = g_amb_context_code
5632 AND application_id = g_application_id
5633 AND EXISTS (SELECT 1
5634 FROM xla_seg_rule_details w
5635 WHERE c.segment_rule_detail_id = w.segment_rule_detail_id
5636 AND w.application_id = g_application_id
5637 AND w.amb_context_code = g_amb_context_code
5638 AND w.segment_rule_type_code = l_adr_type_codes(i)
5639 AND w.segment_rule_code = l_adr_codes(i));
5640 l_num_rows := SQL%ROWCOUNT;
5641 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5642 trace(p_msg => '# xla_conditions delete : '||l_num_rows,
5643 p_module => l_log_module,
5644 p_level => C_LEVEL_STATEMENT);
5645 END IF;
5646 -- Bug : 9923803
5647 -- API Call to Insert messages into AAD Loader Log Table.
5648 xla_aad_loader_util_pvt.insert_aadloaderlog(
5649 p_amb_context_code => g_amb_context_code,
5650 p_application_id => g_application_id,
5651 p_request_code => 'IMPORT' ,
5652 p_log_type_code => 'MERGE',
5653 p_encoded_message => '# xla_conditions delete : '||l_num_rows,
5654 p_component_code => 'merge_adrs');
5655
5656 FORALL i IN 1..l_adr_codes.COUNT
5657 DELETE FROM xla_seg_rule_details w
5658 WHERE amb_context_code = g_amb_context_code
5659 AND application_id = g_application_id
5660 AND segment_rule_type_code = l_adr_type_codes(i)
5661 AND segment_rule_code = l_adr_codes(i);
5662 l_num_rows := SQL%ROWCOUNT;
5663 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5664 trace(p_msg => '# xla_seg_rule_details delete : '||l_num_rows,
5665 p_module => l_log_module,
5666 p_level => C_LEVEL_STATEMENT);
5667 END IF;
5668 -- Bug : 9923803
5669 -- API Call to Insert messages into AAD Loader Log Table.
5670 xla_aad_loader_util_pvt.insert_aadloaderlog(
5671 p_amb_context_code => g_amb_context_code,
5672 p_application_id => g_application_id,
5673 p_request_code => 'IMPORT' ,
5674 p_log_type_code => 'MERGE',
5675 p_encoded_message => '# xla_seg_rule_details delete : '||l_num_rows,
5676 p_component_code => 'merge_adrs');
5677
5678 FORALL i IN 1..l_adr_codes.COUNT
5679 DELETE FROM xla_seg_rules_tl w
5680 WHERE amb_context_code = g_amb_context_code
5681 AND application_id = g_application_id
5682 AND segment_rule_type_code = l_adr_type_codes(i)
5683 AND segment_rule_code = l_adr_codes(i);
5684 l_num_rows := SQL%ROWCOUNT;
5685 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5686 trace(p_msg => '# xla_seg_rules_tl delete : '||l_num_rows,
5687 p_module => l_log_module,
5688 p_level => C_LEVEL_STATEMENT);
5689 END IF;
5690 -- Bug : 9923803
5691 -- API Call to Insert messages into AAD Loader Log Table.
5692 xla_aad_loader_util_pvt.insert_aadloaderlog(
5693 p_amb_context_code => g_amb_context_code,
5694 p_application_id => g_application_id,
5695 p_request_code => 'IMPORT' ,
5696 p_log_type_code => 'MERGE',
5697 p_encoded_message => '# xla_seg_rules_tl delete : '||l_num_rows,
5698 p_component_code => 'merge_adrs');
5699
5700 FORALL i IN 1..l_adr_codes.COUNT
5701 DELETE FROM xla_seg_rules_b w
5702 WHERE amb_context_code = g_amb_context_code
5703 AND application_id = g_application_id
5704 AND segment_rule_type_code = l_adr_type_codes(i)
5705 AND segment_rule_code = l_adr_codes(i);
5706 l_num_rows := SQL%ROWCOUNT;
5707 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5708 trace(p_msg => '# xla_seg_rules_b delete : '||l_num_rows,
5709 p_module => l_log_module,
5710 p_level => C_LEVEL_STATEMENT);
5711 END IF;
5712 -- Bug : 9923803
5713 -- API Call to Insert messages into AAD Loader Log Table.
5714 xla_aad_loader_util_pvt.insert_aadloaderlog(
5715 p_amb_context_code => g_amb_context_code,
5716 p_application_id => g_application_id,
5717 p_request_code => 'IMPORT' ,
5718 p_log_type_code => 'MERGE',
5719 p_encoded_message => '# xla_seg_rules_b delete : '||l_num_rows,
5720 p_component_code => 'merge_adrs');
5721 END IF;
5722
5723 END IF;
5724
5725 -- Move the ADRs from staging area to working area
5726 UPDATE xla_seg_rules_b
5727 SET amb_context_code = g_amb_context_code
5728 WHERE amb_context_code = g_staging_context_code
5729 AND application_id = g_application_id;
5730 l_num_rows := SQL%ROWCOUNT;
5731 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5732 trace(p_msg => '# xla_seg_rules_b updated : '||l_num_rows,
5733 p_module => l_log_module,
5734 p_level => C_LEVEL_STATEMENT);
5735 END IF;
5736 -- Bug : 9923803
5737 -- API Call to Insert messages into AAD Loader Log Table.
5738 xla_aad_loader_util_pvt.insert_aadloaderlog(
5739 p_amb_context_code => g_amb_context_code,
5740 p_application_id => g_application_id,
5741 p_request_code => 'IMPORT' ,
5742 p_log_type_code => 'MERGE',
5743 p_encoded_message => '# xla_seg_rules_b updated : '||l_num_rows,
5744 p_component_code => 'merge_adrs');
5745
5746 UPDATE xla_seg_rules_tl w
5747 SET amb_context_code = g_amb_context_code
5748 WHERE amb_context_code = g_staging_context_code
5749 AND application_id = g_application_id
5750 AND NOT EXISTS (SELECT 1
5751 FROM xla_seg_rules_tl s
5752 WHERE s.amb_context_code = g_amb_context_code
5753 AND s.segment_rule_type_code = w.segment_rule_type_code
5754 AND s.name = w.name
5755 AND s.language = w.language);
5756 l_num_rows := SQL%ROWCOUNT;
5757 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5758 trace(p_msg => '# xla_seg_rules_tl 1 updated : '||l_num_rows,
5759 p_module => l_log_module,
5760 p_level => C_LEVEL_STATEMENT);
5761 END IF;
5762 -- Bug : 9923803
5763 -- API Call to Insert messages into AAD Loader Log Table.
5764 xla_aad_loader_util_pvt.insert_aadloaderlog(
5765 p_amb_context_code => g_amb_context_code,
5766 p_application_id => g_application_id,
5767 p_request_code => 'IMPORT' ,
5768 p_log_type_code => 'MERGE',
5769 p_encoded_message => '# xla_seg_rules_tl 1 updated : '||l_num_rows,
5770 p_component_code => 'merge_adrs');
5771
5772 UPDATE xla_seg_rules_tl w
5773 SET amb_context_code = g_amb_context_code
5774 , name = substr('('||w.segment_rule_code||') '||name,1,80)
5775 WHERE amb_context_code = g_staging_context_code
5776 AND application_id = g_application_id
5777 AND EXISTS (SELECT 1
5778 FROM xla_seg_rules_tl s
5779 WHERE s.amb_context_code = g_amb_context_code
5780 AND s.segment_rule_type_code = w.segment_rule_type_code
5781 AND s.name = w.name
5782 AND s.language = w.language);
5783 l_num_rows := SQL%ROWCOUNT;
5784 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5785 trace(p_msg => '# xla_seg_rules_tl 1 updated : '||l_num_rows,
5786 p_module => l_log_module,
5787 p_level => C_LEVEL_STATEMENT);
5788 END IF;
5789 -- Bug : 9923803
5790 -- API Call to Insert messages into AAD Loader Log Table.
5791 xla_aad_loader_util_pvt.insert_aadloaderlog(
5792 p_amb_context_code => g_amb_context_code,
5793 p_application_id => g_application_id,
5794 p_request_code => 'IMPORT' ,
5795 p_log_type_code => 'MERGE',
5796 p_encoded_message => '# xla_seg_rules_tl 1 updated : '||l_num_rows,
5797 p_component_code => 'merge_adrs');
5798
5799 UPDATE xla_seg_rule_details
5800 SET amb_context_code = g_amb_context_code
5801 WHERE amb_context_code = g_staging_context_code
5802 AND application_id = g_application_id;
5803 l_num_rows := SQL%ROWCOUNT;
5804 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5805 trace(p_msg => '# xla_seg_rule_details updated : '||l_num_rows,
5806 p_module => l_log_module,
5807 p_level => C_LEVEL_STATEMENT);
5808 END IF;
5809 -- Bug : 9923803
5810 -- API Call to Insert messages into AAD Loader Log Table.
5811 xla_aad_loader_util_pvt.insert_aadloaderlog(
5812 p_amb_context_code => g_amb_context_code,
5813 p_application_id => g_application_id,
5814 p_request_code => 'IMPORT' ,
5815 p_log_type_code => 'MERGE',
5816 p_encoded_message => '# xla_seg_rule_details updated : '||l_num_rows,
5817 p_component_code => 'merge_adrs');
5818
5819 UPDATE xla_conditions
5820 SET amb_context_code = g_amb_context_code
5821 WHERE amb_context_code = g_staging_context_code
5822 AND application_id = g_application_id
5823 AND segment_rule_detail_id IS NOT NULL;
5824 l_num_rows := SQL%ROWCOUNT;
5825 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5826 trace(p_msg => '# xla_conditions updated : '||l_num_rows,
5827 p_module => l_log_module,
5828 p_level => C_LEVEL_STATEMENT);
5829 END IF;
5830 -- Bug : 9923803
5831 -- API Call to Insert messages into AAD Loader Log Table.
5832 xla_aad_loader_util_pvt.insert_aadloaderlog(
5833 p_amb_context_code => g_amb_context_code,
5834 p_application_id => g_application_id,
5835 p_request_code => 'IMPORT' ,
5836 p_log_type_code => 'MERGE',
5837 p_encoded_message => '# xla_conditions updated : '||l_num_rows,
5838 p_component_code => 'merge_adrs');
5839
5840 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5841 trace(p_msg => 'END of procedure merge_adrs',
5842 p_module => l_log_module,
5843 p_level => C_LEVEL_PROCEDURE);
5844 END IF;
5845
5846 EXCEPTION
5847 WHEN OTHERS THEN
5848 xla_aad_loader_util_pvt.stack_error
5849 (p_appli_s_name => 'XLA'
5850 ,p_msg_name => 'XLA_COMMON_ERROR'
5851 ,p_token_1 => 'LOCATION'
5852 ,p_value_1 => 'xla_aad_merge_pvt.merge_adrs'
5853 ,p_token_2 => 'ERROR'
5854 ,p_value_2 => 'unhandled exception');
5855 RAISE;
5856
5857 END merge_adrs;
5858
5859
5860 --=============================================================================
5861 --
5862 -- Name: merge_mapping_sets
5863 -- Description: Merge mapping sets from staging area to the working area
5864 -- if the version number of the one in the staging area is higher
5865 -- or equal to the one in the working area
5866 --
5867 --=============================================================================
5868 PROCEDURE merge_mapping_sets
5869 IS
5870 -- Retrieve the mapping sets to be merged
5871 CURSOR c_ms IS
5872 SELECT s.mapping_set_code
5873 FROM xla_mapping_sets_b s
5874 , xla_mapping_sets_b w
5875 WHERE s.amb_context_code = g_staging_context_code
5876 AND w.amb_context_code(+) = g_amb_context_code
5877 AND s.mapping_set_code = w.mapping_set_code(+)
5878 AND s.version_num >= w.version_num(+);
5879
5880 l_ms t_array_varchar30;
5881 l_log_module VARCHAR2(240);
5882 l_num_rows INTEGER;
5883 BEGIN
5884 IF g_log_enabled THEN
5885 l_log_module := C_DEFAULT_MODULE||'.merge_mapping_sets';
5886 END IF;
5887
5888 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5889 trace(p_msg => 'BEGIN of procedure merge_mapping_sets',
5890 p_module => l_log_module,
5891 p_level => C_LEVEL_PROCEDURE);
5892 END IF;
5893
5894
5895
5896 IF (g_analyzed_flag = 'Y') THEN
5897 null;
5898
5899 ELSE
5900
5901 OPEN c_ms;
5902 FETCH c_ms BULK COLLECT INTO l_ms;
5903 CLOSE c_ms;
5904
5905 -- Delete the MSs from the working area to be merged
5906 FORALL i in 1 .. l_ms.count
5907 DELETE FROM xla_mapping_sets_b w
5908 WHERE amb_context_code = g_amb_context_code
5909 AND mapping_set_code = l_ms(i);
5910 l_num_rows := SQL%ROWCOUNT;
5911 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5912 trace(p_msg => '# xla_mapping_sets_b delete : '||l_num_rows,
5913 p_module => l_log_module,
5914 p_level => C_LEVEL_STATEMENT);
5915 END IF;
5916 -- Bug : 9923803
5917 -- API Call to Insert messages into AAD Loader Log Table.
5918 xla_aad_loader_util_pvt.insert_aadloaderlog(
5919 p_amb_context_code => g_amb_context_code,
5920 p_application_id => g_application_id,
5921 p_request_code => 'IMPORT' ,
5922 p_log_type_code => 'MERGE',
5923 p_encoded_message => '# xla_conditions updated : '||l_num_rows,
5924 p_component_code => 'merge_mapping_sets');
5925
5926 FORALL i in 1 .. l_ms.count
5927 DELETE FROM xla_mapping_sets_tl w
5928 WHERE amb_context_code = g_amb_context_code
5929 AND mapping_set_code = l_ms(i)
5930 AND EXISTS (SELECT 1
5931 FROM xla_mapping_sets_tl s
5932 WHERE s.amb_context_code = g_staging_context_code
5933 AND s.mapping_set_code = w.mapping_set_code
5934 AND s.language = w.language);
5935 l_num_rows := SQL%ROWCOUNT;
5936 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5937 trace(p_msg => '# xla_mapping_sets_tl delete : '||l_num_rows,
5938 p_module => l_log_module,
5939 p_level => C_LEVEL_STATEMENT);
5940 END IF;
5941 -- Bug : 9923803
5942 -- API Call to Insert messages into AAD Loader Log Table.
5943 xla_aad_loader_util_pvt.insert_aadloaderlog(
5944 p_amb_context_code => g_amb_context_code,
5945 p_application_id => g_application_id,
5946 p_request_code => 'IMPORT' ,
5947 p_log_type_code => 'MERGE',
5948 p_encoded_message => '# xla_mapping_sets_tl delete : '||l_num_rows,
5949 p_component_code => 'merge_mapping_sets');
5950
5951 FORALL i in 1 .. l_ms.count
5952 DELETE FROM xla_mapping_set_values w
5953 WHERE amb_context_code = g_amb_context_code
5954 AND mapping_set_code = l_ms(i);
5955 l_num_rows := SQL%ROWCOUNT;
5956 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5957 trace(p_msg => '# xla_mapping_set_values delete : '||l_num_rows,
5958 p_module => l_log_module,
5959 p_level => C_LEVEL_STATEMENT);
5960 END IF;
5961 -- Bug : 9923803
5962 -- API Call to Insert messages into AAD Loader Log Table.
5963 xla_aad_loader_util_pvt.insert_aadloaderlog(
5964 p_amb_context_code => g_amb_context_code,
5965 p_application_id => g_application_id,
5966 p_request_code => 'IMPORT' ,
5967 p_log_type_code => 'MERGE',
5968 p_encoded_message => '# xla_mapping_set_values delete : '||l_num_rows,
5969 p_component_code => 'merge_mapping_sets');
5970 END IF;
5971
5972 -- Move the mapping sets from staging area to working area
5973 FORALL i in 1 .. l_ms.count
5974 UPDATE xla_mapping_sets_b
5975 SET amb_context_code = g_amb_context_code
5976 WHERE amb_context_code = g_staging_context_code
5977 AND mapping_set_code = l_ms(i);
5978 l_num_rows := SQL%ROWCOUNT;
5979 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5980 trace(p_msg => '# xla_mapping_sets_b updated : '||l_num_rows,
5981 p_module => l_log_module,
5982 p_level => C_LEVEL_STATEMENT);
5983 END IF;
5984 -- Bug : 9923803
5985 -- API Call to Insert messages into AAD Loader Log Table.
5986 xla_aad_loader_util_pvt.insert_aadloaderlog(
5987 p_amb_context_code => g_amb_context_code,
5988 p_application_id => g_application_id,
5989 p_request_code => 'IMPORT' ,
5990 p_log_type_code => 'MERGE',
5991 p_encoded_message => '# xla_mapping_sets_b updated : '||l_num_rows,
5992 p_component_code => 'merge_mapping_sets');
5993
5994 FORALL i in 1 .. l_ms.count
5995 UPDATE xla_mapping_sets_tl s
5996 SET amb_context_code = g_amb_context_code
5997 WHERE amb_context_code = g_staging_context_code
5998 AND mapping_set_code = l_ms(i)
5999 AND NOT EXISTS (SELECT 1
6000 FROM xla_mapping_sets_tl w
6001 WHERE w.amb_context_code = g_amb_context_code
6002 AND w.name = s.name
6003 AND w.language = s.language);
6004 l_num_rows := SQL%ROWCOUNT;
6005 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6006 trace(p_msg => '# xla_mapping_sets_tl 1 updated : '||l_num_rows,
6007 p_module => l_log_module,
6008 p_level => C_LEVEL_STATEMENT);
6009 END IF;
6010 -- Bug : 9923803
6011 -- API Call to Insert messages into AAD Loader Log Table.
6012 xla_aad_loader_util_pvt.insert_aadloaderlog(
6013 p_amb_context_code => g_amb_context_code,
6014 p_application_id => g_application_id,
6015 p_request_code => 'IMPORT' ,
6016 p_log_type_code => 'MERGE',
6017 p_encoded_message => '# xla_mapping_sets_tl 1 updated : '||l_num_rows,
6018 p_component_code => 'merge_mapping_sets');
6019
6020 FORALL i in 1 .. l_ms.count
6021 UPDATE xla_mapping_sets_tl s
6022 SET amb_context_code = g_amb_context_code
6023 , name = substr('('||s.mapping_set_code||') '||name,1,80)
6024 WHERE amb_context_code = g_staging_context_code
6025 AND mapping_set_code = l_ms(i)
6026 AND EXISTS (SELECT 1
6027 FROM xla_mapping_sets_tl w
6028 WHERE w.amb_context_code = g_amb_context_code
6029 AND w.name = s.name
6030 AND w.language = s.language);
6031 l_num_rows := SQL%ROWCOUNT;
6032 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6033 trace(p_msg => '# xla_mapping_sets_tl 2 updated : '||l_num_rows,
6034 p_module => l_log_module,
6035 p_level => C_LEVEL_STATEMENT);
6036 END IF;
6037 -- Bug : 9923803
6038 -- API Call to Insert messages into AAD Loader Log Table.
6039 xla_aad_loader_util_pvt.insert_aadloaderlog(
6040 p_amb_context_code => g_amb_context_code,
6041 p_application_id => g_application_id,
6042 p_request_code => 'IMPORT' ,
6043 p_log_type_code => 'MERGE',
6044 p_encoded_message => '# xla_mapping_sets_tl 2 updated : '||l_num_rows,
6045 p_component_code => 'merge_mapping_sets');
6046
6047 FORALL i in 1 .. l_ms.count
6048 UPDATE xla_mapping_set_values
6049 SET amb_context_code = g_amb_context_code
6050 WHERE amb_context_code = g_staging_context_code
6051 AND mapping_set_code = l_ms(i);
6052 l_num_rows := SQL%ROWCOUNT;
6053 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6054 trace(p_msg => '# xla_mapping_set_values updated : '||l_num_rows,
6055 p_module => l_log_module,
6056 p_level => C_LEVEL_STATEMENT);
6057 END IF;
6058 -- Bug : 9923803
6059 -- API Call to Insert messages into AAD Loader Log Table.
6060 xla_aad_loader_util_pvt.insert_aadloaderlog(
6061 p_amb_context_code => g_amb_context_code,
6062 p_application_id => g_application_id,
6063 p_request_code => 'IMPORT' ,
6064 p_log_type_code => 'MERGE',
6065 p_encoded_message => '# xla_mapping_set_values updated : '||l_num_rows,
6066 p_component_code => 'merge_mapping_sets');
6067
6068 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6069 trace(p_msg => 'END of procedure merge_mapping_sets',
6070 p_module => l_log_module,
6071 p_level => C_LEVEL_PROCEDURE);
6072 END IF;
6073
6074 EXCEPTION
6075 WHEN OTHERS THEN
6076 xla_aad_loader_util_pvt.stack_error
6077 (p_appli_s_name => 'XLA'
6078 ,p_msg_name => 'XLA_COMMON_ERROR'
6079 ,p_token_1 => 'LOCATION'
6080 ,p_value_1 => 'xla_aad_merge_pvt.merge_mapping_sets'
6081 ,p_token_2 => 'ERROR'
6082 ,p_value_2 => 'unhandled exception');
6083 RAISE;
6084
6085 END merge_mapping_sets;
6086
6087
6088 --=============================================================================
6089 --
6090 -- Bug 4685287 addition.
6091 -- Name: merge_acctg_methods
6092 -- Description: This API copies the accounting methods from the staging to the
6093 -- working area if not already exists. Then it moves the
6094 -- accounting method rules from the staging to the working area
6095 -- if no other accounting method rules have been assigned to the
6096 -- method for the application and destination context.
6097 --
6098 --=============================================================================
6099 PROCEDURE merge_acctg_methods
6100 IS
6101 --Added the below cursor for bug 14359104
6102 CURSOR c_slam IS
6103 SELECT s.accounting_method_type_code, s.accounting_method_code, s.product_rule_type_code, s.product_rule_code
6104 FROM xla_acctg_method_rules w
6105 , xla_acctg_method_rules s
6106 WHERE s.application_id = g_application_id
6107 AND s.amb_context_code = g_staging_context_code
6108 AND s.accounting_method_type_code = w.accounting_method_type_code
6109 AND s.accounting_method_code = w.accounting_method_code
6110 AND s.product_rule_code = w.product_rule_code
6111 AND s.product_rule_type_code = w.product_rule_type_code
6112 AND w.application_id = g_application_id
6113 AND w.amb_context_code = g_amb_context_code;
6114
6115 l_acct_method_type_code t_array_varchar30;
6116 l_acct_method_code t_array_varchar80;
6117 l_product_rule_type_code t_array_varchar30;
6118 l_product_rule_code t_array_varchar80;
6119 l_log_module VARCHAR2(240);
6120 --v_count NUMBER; --No Where used in the below code we commented it out as a part pf bug 14359104
6121 l_num_rows INTEGER;
6122 BEGIN
6123 IF g_log_enabled THEN
6124 l_log_module := C_DEFAULT_MODULE||'.merge_acctg_methods';
6125 END IF;
6126
6127 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6128 trace(p_msg => 'BEGIN of procedure merge_acctg_methods',
6129 p_module => l_log_module,
6130 p_level => C_LEVEL_PROCEDURE);
6131 END IF;
6132 /********* Start of Code Change for Bug 14359104 ************************/
6133 /*Added the Logic:
6134 a) Deleteing the the SLAM with Default context, if there exists the same SLAM and Product Rule Code in staging area
6135 b) And the Moving the SLAM from Stanging Context Code to Default(Working Area).
6136 */
6137 OPEN c_slam;
6138 FETCH c_slam BULK COLLECT INTO l_acct_method_type_code, l_acct_method_code,l_product_rule_type_code,l_product_rule_code;
6139 CLOSE c_slam;
6140
6141
6142 IF (l_product_rule_code.COUNT > 0) THEN
6143
6144 FORALL i IN 1..l_acct_method_code.COUNT
6145 DELETE FROM xla_acctg_method_rules w
6146 WHERE amb_context_code = g_amb_context_code
6147 AND application_id = g_application_id
6148 AND accounting_method_type_code = l_acct_method_type_code(i)
6149 AND accounting_method_code = l_acct_method_code(i)
6150 AND product_rule_type_code = l_product_rule_type_code(i)
6151 AND product_rule_code = l_product_rule_code(i);
6152 l_num_rows := SQL%ROWCOUNT;
6153 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6154 trace(p_msg => '# xla_acctg_methods_tl delete : '||l_num_rows,
6155 p_module => l_log_module,
6156 p_level => C_LEVEL_STATEMENT);
6157 END IF;
6158 -- Bug : 9923803
6159 -- API Call to Insert messages into AAD Loader Log Table.
6160 xla_aad_loader_util_pvt.insert_aadloaderlog(
6161 p_amb_context_code => g_amb_context_code,
6162 p_application_id => g_application_id,
6163 p_request_code => 'IMPORT' ,
6164 p_log_type_code => 'MERGE',
6165 p_encoded_message => '# xla_acctg_method_rules delete : '||l_num_rows,
6166 p_component_code => 'merge_acctg_methods');
6167
6168
6169 end if;
6170
6171 -- Move the SLAM from staging area to working area
6172 UPDATE xla_acctg_method_rules
6173 SET amb_context_code = g_amb_context_code
6174 WHERE amb_context_code = g_staging_context_code
6175 AND application_id = g_application_id;
6176 l_num_rows := SQL%ROWCOUNT;
6177 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6178 trace(p_msg => '# xla_acctg_methods_b updated : '||l_num_rows,
6179 p_module => l_log_module,
6180 p_level => C_LEVEL_STATEMENT);
6181 END IF;
6182
6183 -- Bug : 9923803
6184 -- API Call to Insert messages into AAD Loader Log Table.
6185 xla_aad_loader_util_pvt.insert_aadloaderlog(
6186 p_amb_context_code => g_amb_context_code,
6187 p_application_id => g_application_id,
6188 p_request_code => 'IMPORT' ,
6189 p_log_type_code => 'MERGE',
6190 p_encoded_message => '# xla_acctg_method_rules update : '||l_num_rows,
6191 p_component_code => 'merge_acctg_methods');
6192 /********* End of Code Change for Bug 14359104 ************************/
6193
6194 INSERT INTO xla_acctg_methods_b
6195 (accounting_method_type_code
6196 ,accounting_method_code
6197 ,transaction_coa_id
6198 ,accounting_coa_id
6199 ,enabled_flag
6200 ,creation_date
6201 ,created_by
6202 ,last_update_date
6203 ,last_updated_by
6204 ,last_update_login)
6205 SELECT s.accounting_method_type_code
6206 ,s.accounting_method_code
6207 ,s.transaction_coa_id
6208 ,s.accounting_coa_id
6209 ,s.enabled_flag
6210 ,sysdate
6211 ,xla_environment_pkg.g_usr_id
6212 ,sysdate
6213 ,xla_environment_pkg.g_usr_id
6214 ,xla_environment_pkg.g_login_id
6215 FROM xla_stage_acctg_methods s
6216 LEFT OUTER JOIN xla_acctg_methods_b w
6217 ON w.accounting_method_type_code = s.accounting_method_type_code
6218 AND w.accounting_method_code = s.accounting_method_code
6219 WHERE s.staging_amb_context_code = g_staging_context_code
6220 AND w.accounting_method_type_code IS NULL;
6221 l_num_rows := SQL%ROWCOUNT;
6222 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6223 trace(p_msg => '# row inserted in xla_acctg_methods_b = '||l_num_rows,
6224 p_module => l_log_module,
6225 p_level => C_LEVEL_STATEMENT);
6226 END IF;
6227 -- Bug : 9923803
6228 -- API Call to Insert messages into AAD Loader Log Table.
6229 xla_aad_loader_util_pvt.insert_aadloaderlog(
6230 p_amb_context_code => g_amb_context_code,
6231 p_application_id => g_application_id,
6232 p_request_code => 'IMPORT' ,
6233 p_log_type_code => 'MERGE',
6234 p_encoded_message => '# row inserted in xla_acctg_methods_b = '||l_num_rows,
6235 p_component_code => 'merge_acctg_methods');
6236 INSERT INTO xla_acctg_methods_tl
6237 (accounting_method_type_code
6238 ,accounting_method_code
6239 ,language
6240 ,name
6241 ,description
6242 ,source_lang
6243 ,creation_date
6244 ,created_by
6245 ,last_update_date
6246 ,last_updated_by
6247 ,last_update_login)
6248 SELECT s.accounting_method_type_code
6249 ,s.accounting_method_code
6250 ,fl.language_code
6251 ,s.name
6252 ,s.description
6253 ,USERENV('LANG')
6254 ,sysdate
6255 ,xla_environment_pkg.g_usr_id
6256 ,sysdate
6257 ,xla_environment_pkg.g_usr_id
6258 ,xla_environment_pkg.g_login_id
6259 FROM xla_stage_acctg_methods s
6260 JOIN fnd_languages fl
6261 ON fl.installed_flag IN ('I', 'B')
6262 LEFT OUTER JOIN xla_acctg_methods_tl w
6263 ON w.accounting_method_type_code = s.accounting_method_type_code
6264 AND w.accounting_method_code = s.accounting_method_code
6265 AND w.language = fl.language_code
6266 WHERE s.staging_amb_context_code = g_staging_context_code
6267 AND w.accounting_method_type_code IS NULL;
6268 l_num_rows := SQL%ROWCOUNT;
6269 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6270 trace(p_msg => '# row inserted in xla_acctg_methods_tl = '||l_num_rows,
6271 p_module => l_log_module,
6272 p_level => C_LEVEL_STATEMENT);
6273 END IF;
6274 -- Bug : 9923803
6275 -- API Call to Insert messages into AAD Loader Log Table.
6276 xla_aad_loader_util_pvt.insert_aadloaderlog(
6277 p_amb_context_code => g_amb_context_code,
6278 p_application_id => g_application_id,
6279 p_request_code => 'IMPORT' ,
6280 p_log_type_code => 'MERGE',
6281 p_encoded_message => '# row inserted in xla_acctg_methods_tl = '||l_num_rows,
6282 p_component_code => 'merge_acctg_methods');
6283
6284 UPDATE xla_acctg_method_rules xamr
6285 SET amb_context_code = g_amb_context_code
6286 WHERE amb_context_code = g_staging_context_code
6287 AND NOT EXISTS (SELECT 1
6288 FROM xla_acctg_method_rules xamr2
6289 WHERE xamr2.amb_context_code = g_amb_context_code
6290 AND xamr2.accounting_method_type_code = xamr.accounting_method_type_code
6291 AND xamr2.accounting_method_code = xamr.accounting_method_code
6292 AND xamr2.application_id = g_application_id);
6293 l_num_rows := SQL%ROWCOUNT;
6294
6295 INSERT INTO xla_aad_loader_logs
6296 (aad_loader_log_id
6297 ,amb_context_code
6298 ,application_id
6299 ,request_code
6300 ,log_type_code
6301 ,encoded_message
6302 ,aad_application_id
6303 ,product_rule_code
6304 ,product_rule_type_code
6305 ,component_owner_code
6306 ,component_code
6307 ,object_version_number
6308 ,creation_date
6309 ,created_by
6310 ,last_update_date
6311 ,last_updated_by
6312 ,last_update_login
6313 ,program_update_date
6314 ,program_application_id
6315 ,program_id
6316 ,request_id)
6317 SELECT xla_aad_loader_logs_s.nextval
6318 ,g_amb_context_code
6319 ,g_application_id
6320 ,'IMPORT'
6321 ,'UNMERGE_AAD_IN_SLAM'
6322 ,'Rows inserted in xla_acctg_methods_b for staging context code : '||g_staging_context_code||
6323 ', ' ||'application_id : '||g_application_id||' is : '||l_num_rows
6324 ,g_application_id
6325 ,product_rule_code
6326 ,product_rule_type_code
6327 ,accounting_method_type_code
6328 ,accounting_method_code
6329 ,1
6330 ,sysdate
6331 ,xla_environment_pkg.g_usr_id
6332 ,sysdate
6333 ,xla_environment_pkg.g_usr_id
6334 ,xla_environment_pkg.g_login_id
6335 ,sysdate
6336 ,xla_environment_pkg.g_prog_appl_id
6337 ,xla_environment_pkg.g_prog_id
6338 ,xla_environment_pkg.g_req_Id
6339 FROM (SELECT distinct product_rule_type_code
6340 , product_rule_code
6341 , accounting_method_type_code
6342 , accounting_method_code
6343 FROM xla_acctg_method_rules
6344 WHERE amb_context_code = g_staging_context_code);
6345 l_num_rows := SQL%ROWCOUNT;
6346 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6347 trace(p_msg => '# row inserted in xla_acctg_method_rules = '||l_num_rows,
6348 p_module => l_log_module,
6349 p_level => C_LEVEL_STATEMENT);
6350 END IF;
6351 -- Bug : 9923803
6352 -- API Call to Insert messages into AAD Loader Log Table.
6353 xla_aad_loader_util_pvt.insert_aadloaderlog(
6354 p_amb_context_code => g_amb_context_code,
6355 p_application_id => g_application_id,
6356 p_request_code => 'IMPORT' ,
6357 p_log_type_code => 'MERGE',
6358 p_encoded_message => '# row inserted in xla_acctg_method_rules = '||l_num_rows,
6359 p_component_code => 'merge_acctg_methods');
6360 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6361 trace(p_msg => 'END of procedure merge_acctg_methods',
6362 p_module => l_log_module,
6363 p_level => C_LEVEL_PROCEDURE);
6364 END IF;
6365
6366 EXCEPTION
6367 WHEN OTHERS THEN
6368 xla_aad_loader_util_pvt.stack_error
6369 (p_appli_s_name => 'XLA'
6370 ,p_msg_name => 'XLA_COMMON_ERROR'
6371 ,p_token_1 => 'LOCATION'
6372 ,p_value_1 => 'xla_aad_merge_pvt.merge_acctg_methods'
6373 ,p_token_2 => 'ERROR'
6374 ,p_value_2 => 'unhandled exception');
6375 RAISE;
6376
6377 END merge_acctg_methods;
6378
6379
6380 --=============================================================================
6381 --
6382 -- Name: merge_aads_and_setups
6383 -- Description: This API merge the AADs and journal entry setups
6384 --
6385 --=============================================================================
6386 PROCEDURE merge_aads_and_setups
6387 IS
6388 l_log_module VARCHAR2(240);
6389 BEGIN
6390 IF g_log_enabled THEN
6391 l_log_module := C_DEFAULT_MODULE||'.merge_aads_and_setups';
6392 END IF;
6393
6394 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6395 trace(p_msg => 'BEGIN of procedure merge_aads_and_setups',
6396 p_module => l_log_module,
6397 p_level => C_LEVEL_PROCEDURE);
6398 END IF;
6399
6400 IF (g_analyzed_flag = 'Y') THEN
6401 null;
6402 /*
6403 duplicate_journal_line_defns;
6404 duplicate_journal_line_types;
6405 duplicate_descriptions;
6406 duplicate_analytical_criteria;
6407 duplicate_mapping_sets;
6408 duplicate_adrs;
6409 */
6410 END IF;
6411
6412 --Bug 12969337
6413 --Reverting back the commented code.
6414 --As the patch is still in progress.
6415 -- commented for bug11845200 since post this FV and AP are provided via different ldt files
6416 /* IF (g_user_type_code = 'C') THEN
6417 clean_oracle_components;
6418 END IF; */
6419
6420 -- Merge AADs and journal entry setups
6421 merge_aads;
6422 merge_journal_line_defns;
6423 merge_journal_line_types;
6424 merge_descriptions;
6425 merge_analytical_criteria;
6426 merge_mapping_sets;
6427 merge_adrs;
6428 merge_acctg_methods; -- Bug 4685287 addition.
6429
6430 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6431 trace(p_msg => 'END of procedure merge_aads_and_setups',
6432 p_module => l_log_module,
6433 p_level => C_LEVEL_PROCEDURE);
6434 END IF;
6435
6436 EXCEPTION
6437 WHEN OTHERS THEN
6438 xla_aad_loader_util_pvt.stack_error
6439 (p_appli_s_name => 'XLA'
6440 ,p_msg_name => 'XLA_COMMON_ERROR'
6441 ,p_token_1 => 'LOCATION'
6442 ,p_value_1 => 'xla_aad_merge_pvt.merge_aads_and_setups'
6443 ,p_token_2 => 'ERROR'
6444 ,p_value_2 => 'Unhandled exception');
6445 RAISE;
6446
6447 END merge_aads_and_setups;
6448
6449
6450 --=============================================================================
6451 --
6452 -- Name: purge_mapping_sets
6453 -- Description:
6454 --
6455 --=============================================================================
6456 PROCEDURE purge_mapping_sets
6457 IS
6458 l_log_module VARCHAR2(240);
6459 l_num_rows INTEGER;
6460 BEGIN
6461 IF g_log_enabled THEN
6462 l_log_module := C_DEFAULT_MODULE||'.purge_mapping_sets';
6463 END IF;
6464
6465 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6466 trace(p_msg => 'BEGIN of procedure purge_mapping_sets',
6467 p_module => l_log_module,
6468 p_level => C_LEVEL_PROCEDURE);
6469 END IF;
6470
6471 DELETE FROM xla_mapping_set_values
6472 WHERE amb_context_code = g_staging_context_code;
6473 l_num_rows := SQL%ROWCOUNT;
6474 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6475 trace(p_msg => '# xla_mapping_set_values delete : '||l_num_rows,
6476 p_module => l_log_module,
6477 p_level => C_LEVEL_STATEMENT);
6478 END IF;
6479 -- Bug : 9923803
6480 -- API Call to Insert messages into AAD Loader Log Table.
6481 xla_aad_loader_util_pvt.insert_aadloaderlog(
6482 p_amb_context_code => g_amb_context_code,
6483 p_application_id => g_application_id,
6484 p_request_code => 'IMPORT' ,
6485 p_log_type_code => 'MERGE',
6486 p_encoded_message => '# xla_mapping_set_values delete : '||l_num_rows,
6487 p_component_code => 'purge_mapping_sets');
6488 DELETE FROM xla_mapping_sets_tl
6489 WHERE amb_context_code = g_staging_context_code;
6490 l_num_rows := SQL%ROWCOUNT;
6491 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6492 trace(p_msg => '# xla_mapping_sets_tl delete : '||l_num_rows,
6493 p_module => l_log_module,
6494 p_level => C_LEVEL_STATEMENT);
6495 END IF;
6496 -- Bug : 9923803
6497 -- API Call to Insert messages into AAD Loader Log Table.
6498 xla_aad_loader_util_pvt.insert_aadloaderlog(
6499 p_amb_context_code => g_amb_context_code,
6500 p_application_id => g_application_id,
6501 p_request_code => 'IMPORT' ,
6502 p_log_type_code => 'MERGE',
6503 p_encoded_message => '# xla_mapping_sets_tl delete : '||l_num_rows,
6504 p_component_code => 'purge_mapping_sets');
6505 DELETE FROM xla_mapping_sets_b
6506 WHERE amb_context_code = g_staging_context_code;
6507 l_num_rows := SQL%ROWCOUNT;
6508 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6509 trace(p_msg => '# xla_mapping_sets_b delete : '||l_num_rows,
6510 p_module => l_log_module,
6511 p_level => C_LEVEL_STATEMENT);
6512 END IF;
6513 -- Bug : 9923803
6514 -- API Call to Insert messages into AAD Loader Log Table.
6515 xla_aad_loader_util_pvt.insert_aadloaderlog(
6516 p_amb_context_code => g_amb_context_code,
6517 p_application_id => g_application_id,
6518 p_request_code => 'IMPORT' ,
6519 p_log_type_code => 'MERGE',
6520 p_encoded_message => '# xla_mapping_sets_b delete : '||l_num_rows,
6521 p_component_code => 'purge_mapping_sets');
6522 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6523 trace(p_msg => 'END of procedure purge_mapping_sets',
6524 p_module => l_log_module,
6525 p_level => C_LEVEL_PROCEDURE);
6526 END IF;
6527
6528 EXCEPTION
6529 WHEN OTHERS THEN
6530 xla_aad_loader_util_pvt.stack_error
6531 (p_appli_s_name => 'XLA'
6532 ,p_msg_name => 'XLA_COMMON_ERROR'
6533 ,p_token_1 => 'LOCATION'
6534 ,p_value_1 => 'xla_aad_merge_pvt.purge_mapping_sets'
6535 ,p_token_2 => 'ERROR'
6536 ,p_value_2 => 'unhandled exception');
6537 RAISE;
6538
6539 END purge_mapping_sets;
6540
6541
6542 --=============================================================================
6543 --
6544 -- Name: purge_analytical_criteria
6545 -- Description:
6546 --
6547 --=============================================================================
6548 PROCEDURE purge_analytical_criteria
6549 IS
6550 l_log_module VARCHAR2(240);
6551 l_num_rows INTEGER;
6552 BEGIN
6553 IF g_log_enabled THEN
6554 l_log_module := C_DEFAULT_MODULE||'.purge_analytical_criteria';
6555 END IF;
6556
6557 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6558 trace(p_msg => 'BEGIN of procedure purge_analytical_criteria',
6559 p_module => l_log_module,
6560 p_level => C_LEVEL_PROCEDURE);
6561 END IF;
6562
6563 DELETE FROM xla_analytical_sources
6564 WHERE amb_context_code = g_staging_context_code;
6565 l_num_rows := SQL%ROWCOUNT;
6566 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6567 trace(p_msg => '# xla_analytical_sources delete : '||l_num_rows,
6568 p_module => l_log_module,
6569 p_level => C_LEVEL_STATEMENT);
6570 END IF;
6571 -- Bug : 9923803
6572 -- API Call to Insert messages into AAD Loader Log Table.
6573 xla_aad_loader_util_pvt.insert_aadloaderlog(
6574 p_amb_context_code => g_amb_context_code,
6575 p_application_id => g_application_id,
6576 p_request_code => 'IMPORT' ,
6577 p_log_type_code => 'MERGE',
6578 p_encoded_message => '# xla_analytical_sources delete : '||l_num_rows,
6579 p_component_code => 'purge_analytical_criteria');
6580 DELETE FROM xla_analytical_dtls_tl
6581 WHERE amb_context_code = g_staging_context_code;
6582 l_num_rows := SQL%ROWCOUNT;
6583 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6584 trace(p_msg => '# xla_analytical_dtls_tl delete : '||l_num_rows,
6585 p_module => l_log_module,
6586 p_level => C_LEVEL_STATEMENT);
6587 END IF;
6588 -- Bug : 9923803
6589 -- API Call to Insert messages into AAD Loader Log Table.
6590 xla_aad_loader_util_pvt.insert_aadloaderlog(
6591 p_amb_context_code => g_amb_context_code,
6592 p_application_id => g_application_id,
6593 p_request_code => 'IMPORT' ,
6594 p_log_type_code => 'MERGE',
6595 p_encoded_message => '# xla_analytical_dtls_tl delete : '||l_num_rows,
6596 p_component_code => 'purge_analytical_criteria');
6597 DELETE FROM xla_analytical_dtls_b
6598 WHERE amb_context_code = g_staging_context_code;
6599 l_num_rows := SQL%ROWCOUNT;
6600 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6601 trace(p_msg => '# xla_analytical_dtls_b delete : '||l_num_rows,
6602 p_module => l_log_module,
6603 p_level => C_LEVEL_STATEMENT);
6604 END IF;
6605 -- Bug : 9923803
6606 -- API Call to Insert messages into AAD Loader Log Table.
6607 xla_aad_loader_util_pvt.insert_aadloaderlog(
6608 p_amb_context_code => g_amb_context_code,
6609 p_application_id => g_application_id,
6610 p_request_code => 'IMPORT' ,
6611 p_log_type_code => 'MERGE',
6612 p_encoded_message => '# xla_analytical_dtls_b delete : '||l_num_rows,
6613 p_component_code => 'purge_analytical_criteria');
6614 DELETE FROM xla_analytical_hdrs_tl
6615 WHERE amb_context_code = g_staging_context_code;
6616 l_num_rows := SQL%ROWCOUNT;
6617 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6618 trace(p_msg => '# xla_analytical_hdrs_tl delete : '||l_num_rows,
6619 p_module => l_log_module,
6620 p_level => C_LEVEL_STATEMENT);
6621 END IF;
6622 -- Bug : 9923803
6623 -- API Call to Insert messages into AAD Loader Log Table.
6624 xla_aad_loader_util_pvt.insert_aadloaderlog(
6625 p_amb_context_code => g_amb_context_code,
6626 p_application_id => g_application_id,
6627 p_request_code => 'IMPORT' ,
6628 p_log_type_code => 'MERGE',
6629 p_encoded_message => '# xla_analytical_hdrs_tl delete : '||l_num_rows,
6630 p_component_code => 'purge_analytical_criteria');
6631 DELETE FROM xla_analytical_hdrs_b
6632 WHERE amb_context_code = g_staging_context_code;
6633 l_num_rows := SQL%ROWCOUNT;
6634 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6635 trace(p_msg => '# xla_analytical_hdrs_b delete : '||l_num_rows,
6636 p_module => l_log_module,
6637 p_level => C_LEVEL_STATEMENT);
6638 END IF;
6639 -- Bug : 9923803
6640 -- API Call to Insert messages into AAD Loader Log Table.
6641 xla_aad_loader_util_pvt.insert_aadloaderlog(
6642 p_amb_context_code => g_amb_context_code,
6643 p_application_id => g_application_id,
6644 p_request_code => 'IMPORT' ,
6645 p_log_type_code => 'MERGE',
6646 p_encoded_message => '# xla_analytical_hdrs_b delete : '||l_num_rows,
6647 p_component_code => 'purge_analytical_criteria');
6648 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6649 trace(p_msg => 'END of procedure purge_analytical_criteria',
6650 p_module => l_log_module,
6651 p_level => C_LEVEL_PROCEDURE);
6652 END IF;
6653
6654 EXCEPTION
6655 WHEN OTHERS THEN
6656 xla_aad_loader_util_pvt.stack_error
6657 (p_appli_s_name => 'XLA'
6658 ,p_msg_name => 'XLA_COMMON_ERROR'
6659 ,p_token_1 => 'LOCATION'
6660 ,p_value_1 => 'xla_aad_merge_pvt.purge_analytical_criteria'
6661 ,p_token_2 => 'ERROR'
6662 ,p_value_2 => 'unhandled exception');
6663 RAISE;
6664
6665 END purge_analytical_criteria;
6666
6667
6668 --=============================================================================
6669 --
6670 -- Name: purge_adrs
6671 -- Description:
6672 --
6673 --=============================================================================
6674 PROCEDURE purge_adrs
6675 IS
6676 l_log_module VARCHAR2(240);
6677 l_num_rows INTEGER;
6678 BEGIN
6679 IF g_log_enabled THEN
6680 l_log_module := C_DEFAULT_MODULE||'.purge_adrs';
6681 END IF;
6682
6683 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6684 trace(p_msg => 'BEGIN of procedure purge_adrs',
6685 p_module => l_log_module,
6686 p_level => C_LEVEL_PROCEDURE);
6687 END IF;
6688
6689 DELETE FROM xla_conditions
6690 WHERE amb_context_code = g_staging_context_code
6691 AND segment_rule_detail_id IS NOT NULl;
6692 l_num_rows := SQL%ROWCOUNT;
6693 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6694 trace(p_msg => '# xla_conditions delete : '||l_num_rows,
6695 p_module => l_log_module,
6696 p_level => C_LEVEL_STATEMENT);
6697 END IF;
6698 -- Bug : 9923803
6699 -- API Call to Insert messages into AAD Loader Log Table.
6700 xla_aad_loader_util_pvt.insert_aadloaderlog(
6701 p_amb_context_code => g_amb_context_code,
6702 p_application_id => g_application_id,
6703 p_request_code => 'IMPORT' ,
6704 p_log_type_code => 'MERGE',
6705 p_encoded_message => '# xla_conditions delete : '||l_num_rows,
6706 p_component_code => 'purge_adrs');
6707 DELETE FROM xla_seg_rule_details
6708 WHERE amb_context_code = g_staging_context_code;
6709 l_num_rows := SQL%ROWCOUNT;
6710 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6711 trace(p_msg => '# xla_seg_rules_details delete : '||l_num_rows,
6712 p_module => l_log_module,
6713 p_level => C_LEVEL_STATEMENT);
6714 END IF;
6715 -- Bug : 9923803
6716 -- API Call to Insert messages into AAD Loader Log Table.
6717 xla_aad_loader_util_pvt.insert_aadloaderlog(
6718 p_amb_context_code => g_amb_context_code,
6719 p_application_id => g_application_id,
6720 p_request_code => 'IMPORT' ,
6721 p_log_type_code => 'MERGE',
6722 p_encoded_message => '# xla_seg_rules_details delete : '||l_num_rows,
6723 p_component_code => 'purge_adrs');
6724
6725 DELETE FROM xla_seg_rules_tl
6726 WHERE amb_context_code = g_staging_context_code;
6727 l_num_rows := SQL%ROWCOUNT;
6728 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6729 trace(p_msg => '# xla_seg_rules_tl delete : '||l_num_rows,
6730 p_module => l_log_module,
6731 p_level => C_LEVEL_STATEMENT);
6732 END IF;
6733 -- Bug : 9923803
6734 -- API Call to Insert messages into AAD Loader Log Table.
6735 xla_aad_loader_util_pvt.insert_aadloaderlog(
6736 p_amb_context_code => g_amb_context_code,
6737 p_application_id => g_application_id,
6738 p_request_code => 'IMPORT' ,
6739 p_log_type_code => 'MERGE',
6740 p_encoded_message => '# xla_seg_rules_tl delete : '||l_num_rows,
6741 p_component_code => 'purge_adrs');
6742
6743 DELETE FROM xla_seg_rules_b
6744 WHERE amb_context_code = g_staging_context_code;
6745 l_num_rows := SQL%ROWCOUNT;
6746 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6747 trace(p_msg => '# xla_seg_rules_b delete : '||l_num_rows,
6748 p_module => l_log_module,
6749 p_level => C_LEVEL_STATEMENT);
6750 END IF;
6751 -- Bug : 9923803
6752 -- API Call to Insert messages into AAD Loader Log Table.
6753 xla_aad_loader_util_pvt.insert_aadloaderlog(
6754 p_amb_context_code => g_amb_context_code,
6755 p_application_id => g_application_id,
6756 p_request_code => 'IMPORT' ,
6757 p_log_type_code => 'MERGE',
6758 p_encoded_message => '# xla_seg_rules_b delete : '||l_num_rows,
6759 p_component_code => 'purge_adrs');
6760
6761 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6762 trace(p_msg => 'END of procedure purge_adrs',
6763 p_module => l_log_module,
6764 p_level => C_LEVEL_PROCEDURE);
6765 END IF;
6766
6767 EXCEPTION
6768 WHEN OTHERS THEN
6769 xla_aad_loader_util_pvt.stack_error
6770 (p_appli_s_name => 'XLA'
6771 ,p_msg_name => 'XLA_COMMON_ERROR'
6772 ,p_token_1 => 'LOCATION'
6773 ,p_value_1 => 'xla_aad_merge_pvt.purge_adrs'
6774 ,p_token_2 => 'ERROR'
6775 ,p_value_2 => 'unhandled exception');
6776 RAISE;
6777
6778 END purge_adrs;
6779
6780
6781 --=============================================================================
6782 --
6783 -- Name: purge_staging_area
6784 -- Description:
6785 --
6786 --=============================================================================
6787 PROCEDURE purge_staging_area
6788 IS
6789 l_log_module VARCHAR2(240);
6790 BEGIN
6791 IF g_log_enabled THEN
6792 l_log_module := C_DEFAULT_MODULE||'.purge_staging_area';
6793 END IF;
6794
6795 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6796 trace(p_msg => 'BEGIN of procedure purge_staging_area',
6797 p_module => l_log_module,
6798 p_level => C_LEVEL_PROCEDURE);
6799 END IF;
6800
6801 xla_aad_loader_util_pvt.purge
6802 (p_application_id => g_application_id
6803 ,p_amb_context_code => g_staging_context_code);
6804
6805 purge_mapping_sets;
6806 purge_analytical_criteria;
6807 purge_adrs;
6808
6809 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6810 trace(p_msg => 'END of procedure purge_staging_area',
6811 p_module => l_log_module,
6812 p_level => C_LEVEL_PROCEDURE);
6813 END IF;
6814
6815 EXCEPTION
6816 WHEN OTHERS THEN
6817 xla_aad_loader_util_pvt.stack_error
6818 (p_appli_s_name => 'XLA'
6819 ,p_msg_name => 'XLA_COMMON_ERROR'
6820 ,p_token_1 => 'LOCATION'
6821 ,p_value_1 => 'xla_aad_merge_pvt.purge_staging_area'
6822 ,p_token_2 => 'ERROR'
6823 ,p_value_2 => 'unhandled exception');
6824 RAISE;
6825
6826 END purge_staging_area;
6827
6828
6829 --=============================================================================
6830 --
6831 -- Name: template_api
6832 -- Description:
6833 --
6834 --=============================================================================
6835 PROCEDURE template_api
6836 IS
6837 l_log_module VARCHAR2(240);
6838 BEGIN
6839 IF g_log_enabled THEN
6840 l_log_module := C_DEFAULT_MODULE||'.template_api';
6841 END IF;
6842
6843 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6844 trace(p_msg => 'BEGIN of procedure template_api',
6845 p_module => l_log_module,
6846 p_level => C_LEVEL_PROCEDURE);
6847 END IF;
6848
6849 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6850 trace(p_msg => 'END of procedure template_api',
6851 p_module => l_log_module,
6852 p_level => C_LEVEL_PROCEDURE);
6853 END IF;
6854
6855 EXCEPTION
6856 WHEN OTHERS THEN
6857 xla_aad_loader_util_pvt.stack_error
6858 (p_appli_s_name => 'XLA'
6859 ,p_msg_name => 'XLA_COMMON_ERROR'
6860 ,p_token_1 => 'LOCATION'
6861 ,p_value_1 => 'xla_aad_merge_pvt.template_api'
6862 ,p_token_2 => 'ERROR'
6863 ,p_value_2 => 'unhandled exception');
6864 RAISE;
6865
6866 END template_api;
6867
6868
6869
6870 --=============================================================================
6871 --
6872 --
6873 --
6874 --
6875 --
6876 -- *********** public procedures and functions **********
6877 --
6878 --
6879 --
6880 --
6881 --
6882 --=============================================================================
6883
6884 PROCEDURE merge
6885 (p_api_version IN NUMBER
6886 ,x_return_status IN OUT NOCOPY VARCHAR2
6887 ,p_application_id IN INTEGER
6888 ,p_amb_context_code IN VARCHAR2
6889 ,p_analyzed_flag IN VARCHAR2
6890 ,p_compile_flag IN VARCHAR2
6891 ,x_merge_status IN OUT NOCOPY VARCHAR2)
6892 IS
6893 l_api_name CONSTANT VARCHAR2(30) := 'merge';
6894 l_api_version CONSTANT NUMBER := 1.0;
6895
6896 l_staging_context_code VARCHAR2(30);
6897 l_retcode VARCHAR2(30);
6898 l_log_module VARCHAR2(240);
6899 BEGIN
6900 IF g_log_enabled THEN
6901 l_log_module := C_DEFAULT_MODULE||'.merge';
6902 END IF;
6903
6904 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6905 trace(p_msg => 'BEGIN of function merge: '||
6906 'p_application_id = '||p_application_id||
6907 ', p_amb_context_code = '||p_amb_context_code||
6908 ', p_analyzed_flag = '||p_analyzed_flag||
6909 ', p_compile_flag = '||p_compile_flag,
6910 p_module => l_log_module,
6911 p_level => C_LEVEL_PROCEDURE);
6912 END IF;
6913
6914 l_staging_context_code := xla_aad_loader_util_pvt.get_staging_context_code
6915 (p_application_id => p_application_id
6916 ,p_amb_context_code => p_amb_context_code);
6917
6918 xla_aad_merge_pvt.merge
6919 (p_api_version => p_api_version
6920 ,x_return_status => x_return_status
6921 ,p_application_id => p_application_id
6922 ,p_amb_context_code => p_amb_context_code
6923 ,p_staging_context_code => l_staging_context_code
6924 ,p_analyzed_flag => p_analyzed_flag
6925 ,p_compile_flag => p_compile_flag
6926 ,x_merge_status => x_merge_status);
6927
6928 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6929 trace(p_msg => 'END of function merge - Return value = '||x_merge_status,
6930 p_module => l_log_module,
6931 p_level => C_LEVEL_PROCEDURE);
6932 END IF;
6933
6934 EXCEPTION
6935 WHEN G_EXC_WARNING THEN
6936 x_return_status := FND_API.G_RET_STS_SUCCESS ;
6937 x_merge_status := 'ERROR';
6938
6939 WHEN FND_API.G_EXC_ERROR THEN
6940 x_return_status := FND_API.G_RET_STS_ERROR ;
6941 x_merge_status := 'ERROR';
6942
6943 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6944 ROLLBACK;
6945 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6946 x_merge_status := 'ERROR';
6947
6948 WHEN OTHERS THEN
6949 ROLLBACK;
6950 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6951 x_merge_status := 'ERROR';
6952
6953 xla_aad_loader_util_pvt.stack_error
6954 (p_appli_s_name => 'XLA'
6955 ,p_msg_name => 'XLA_COMMON_ERROR'
6956 ,p_token_1 => 'LOCATION'
6957 ,p_value_1 => 'xla_aad_merge_pvt.merge'
6958 ,p_token_2 => 'ERROR'
6959 ,p_value_2 => 'unhandled exception');
6960
6961 --RAISE;
6962
6963 END merge;
6964
6965
6966 --=============================================================================
6967 --
6968 -- Name: merge
6969 -- Description: This API merges the AADs and its components from the
6970 -- staging area to the working area of an AMB context
6971 --
6972 --=============================================================================
6973 PROCEDURE merge
6974 (p_api_version IN NUMBER
6975 ,x_return_status IN OUT NOCOPY VARCHAR2
6976 ,p_application_id IN INTEGER
6977 ,p_amb_context_code IN VARCHAR2
6978 ,p_staging_context_code IN VARCHAR2
6979 ,p_analyzed_flag IN VARCHAR2
6980 ,p_compile_flag IN VARCHAR2
6981 ,x_merge_status IN OUT NOCOPY VARCHAR2)
6982 IS
6983 l_api_name CONSTANT VARCHAR2(30) := 'merge';
6984 l_api_version CONSTANT NUMBER := 1.0;
6985
6986 l_retcode VARCHAR2(30);
6987 l_log_module VARCHAR2(240);
6988
6989 BEGIN
6990 IF g_log_enabled THEN
6991 l_log_module := C_DEFAULT_MODULE||'.merge';
6992 END IF;
6993
6994 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6995 trace(p_msg => 'BEGIN of function merge: '||
6996 'p_application_id = '||p_application_id||
6997 ', p_amb_context_code = '||p_amb_context_code||
6998 ', p_analyzed_flag = '||p_analyzed_flag||
6999 ', p_compile_flag = '||p_compile_flag,
7000 p_module => l_log_module,
7001 p_level => C_LEVEL_PROCEDURE);
7002 END IF;
7003
7004 -- Standard call to check for call compatibility.
7005 IF (NOT xla_aad_loader_util_pvt.compatible_api_call
7006 (p_current_version_number => l_api_version
7007 ,p_caller_version_number => p_api_version
7008 ,p_api_name => l_api_name
7009 ,p_pkg_name => C_DEFAULT_MODULE))
7010 THEN
7011 RAISE FND_API.G_EXC_UNEXPECTED_ERROR ;
7012 END IF;
7013
7014 -- Initialize global variables
7015 x_return_status := FND_API.G_RET_STS_SUCCESS;
7016
7017 g_usr_id := xla_environment_pkg.g_usr_id;
7018 g_login_id := xla_environment_pkg.g_login_id;
7019 g_application_id := p_application_id;
7020 g_amb_context_code := p_amb_context_code;
7021 g_analyzed_flag := p_analyzed_flag;
7022 g_compile_flag := p_compile_flag;
7023 g_staging_context_code := p_staging_context_code;
7024 g_user_type_code := NVL(fnd_profile.value('XLA_SETUP_USER_MODE'),'C');
7025
7026 -- API Logic
7027 x_merge_status := pre_merge;
7028 IF (x_merge_status = 'WARNING') THEN
7029 RAISE G_EXC_WARNING;
7030 END IF;
7031
7032 x_merge_status := validation;
7033 IF (x_merge_status = 'WARNING') THEN
7034 RAISE G_EXC_WARNING;
7035 END IF;
7036
7037 merge_aads_and_setups;
7038
7039
7040 xla_aad_loader_util_pvt.merge_history
7041 (p_application_id => g_application_id
7042 ,p_staging_context_code => g_staging_context_code);
7043
7044
7045 purge_staging_area;
7046
7047 xla_aad_loader_util_pvt.rebuild_ac_views;
7048
7049 IF (p_compile_flag = 'Y') THEN
7050 IF (NOT xla_aad_loader_util_pvt.compile
7051 (p_application_id => g_application_id
7052 ,p_amb_context_code => g_amb_context_code)) THEN
7053 RAISE G_EXC_WARNING;
7054 END IF;
7055 END IF;
7056
7057
7058
7059 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7060 trace(p_msg => 'END of function merge - Return value = '||x_merge_status,
7061 p_module => l_log_module,
7062 p_level => C_LEVEL_PROCEDURE);
7063 END IF;
7064 EXCEPTION
7065 WHEN G_EXC_WARNING THEN
7066 x_return_status := FND_API.G_RET_STS_SUCCESS ;
7067 x_merge_status := 'ERROR';
7068
7069 WHEN FND_API.G_EXC_ERROR THEN
7070 x_return_status := FND_API.G_RET_STS_ERROR ;
7071 x_merge_status := 'ERROR';
7072
7073 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7074 ROLLBACK;
7075 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7076 x_merge_status := 'ERROR';
7077
7078 WHEN OTHERS THEN
7079 ROLLBACK;
7080 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7081 x_merge_status := 'ERROR';
7082
7083 xla_aad_loader_util_pvt.stack_error
7084 (p_appli_s_name => 'XLA'
7085 ,p_msg_name => 'XLA_COMMON_ERROR'
7086 ,p_token_1 => 'LOCATION'
7087 ,p_value_1 => 'xla_aad_merge_pvt.merge'
7088 ,p_token_2 => 'ERROR'
7089 ,p_value_2 => 'unhandled exception');
7090
7091 --RAISE;
7092
7093 END merge;
7094
7095 --=============================================================================
7096 --
7097 -- Following code is executed when the package body is referenced for the first
7098 -- time
7099 --
7100 --=============================================================================
7101 BEGIN
7102 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
7103 g_log_enabled := fnd_log.test
7104 (log_level => g_log_level
7105 ,module => C_DEFAULT_MODULE);
7106
7107 IF NOT g_log_enabled THEN
7108 g_log_level := C_LEVEL_LOG_DISABLED;
7109 END IF;
7110
7111 END xla_aad_merge_pvt;