[Home] [Help]
PACKAGE BODY: APPS.XLA_LINE_TYPES_PKG
Source
1 PACKAGE BODY xla_line_types_pkg AS
2 /* $Header: xlaamdlt.pkb 120.31 2006/02/15 19:51:51 dcshah ship $ */
3 /*======================================================================+
4 | Copyright (c) 1995-2002 Oracle Corporation |
5 | Redwood Shores, CA, USA |
6 | All rights reserved. |
7 +=======================================================================+
8 | PACKAGE NAME |
9 | xla_line_types_pkg |
10 | |
11 | DESCRIPTION |
12 | XLA Line Types Package |
13 | |
14 | HISTORY |
15 | 01-May-01 Dimple Shah Created |
16 | 19-Oct-01 Wynne Chan Modified for the Journal Line Definitions |
17 | 1-Mar-05 W. Shen Modified for the ledger currency project |
18 | 15-May-05 eklau Modified for MPA project - 4262811. |
19 | |
20 +======================================================================*/
21
22 -------------------------------------------------------------------------------
23 -- declaring private package variables
24 -------------------------------------------------------------------------------
25 g_creation_date DATE := sysdate;
26 g_last_update_date DATE := sysdate;
27 g_created_by INTEGER := xla_environment_pkg.g_usr_id;
28 g_last_update_login INTEGER := xla_environment_pkg.g_login_id;
29 g_last_updated_by INTEGER := xla_environment_pkg.g_usr_id;
30
31 -------------------------------------------------------------------------------
32 -- declaring private package arrays
33 -------------------------------------------------------------------------------
34 TYPE t_array_codes IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
35 TYPE t_array_type_codes IS TABLE OF VARCHAR2(1) INDEX BY BINARY_INTEGER;
36 TYPE t_array_id IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
37
38 -------------------------------------------------------------------------------
39 -- forward declarion of private procedures and functions
40 -------------------------------------------------------------------------------
41
42 /*======================================================================+
43 | |
44 | Private Function |
45 | |
46 | Chk_line_accting_sources |
47 | |
48 | Returns false if accounting sources at the line level are invalid |
49 | |
50 +======================================================================*/
51 FUNCTION Chk_line_accting_sources
52 (p_application_id IN NUMBER
53 ,p_amb_context_code IN VARCHAR2
54 ,p_entity_code IN VARCHAR2
55 ,p_event_class_code IN VARCHAR2
56 ,p_accounting_line_type_code IN VARCHAR2
57 ,p_accounting_line_code IN VARCHAR2
58 ,p_message_name IN OUT NOCOPY VARCHAR2
59 ,p_accounting_attribute_name IN OUT NOCOPY VARCHAR2)
60 RETURN BOOLEAN;
61
62
63 /*======================================================================+
64 | |
65 | Public Procedure |
66 | |
67 | delete_line_type_details |
68 | |
69 | Deletes all details of the line type |
70 | |
71 +======================================================================*/
72
73 PROCEDURE delete_line_type_details
74 (p_application_id IN NUMBER
75 ,p_amb_context_code IN VARCHAR2
76 ,p_entity_code IN VARCHAR2
77 ,p_event_class_code IN VARCHAR2
78 ,p_accounting_line_type_code IN VARCHAR2
79 ,p_accounting_line_code IN VARCHAR2)
80 IS
81
82 l_application_id NUMBER(38) := p_application_id;
83 l_entity_code VARCHAR2(30) := p_entity_code;
84 l_event_class_code VARCHAR2(30) := p_event_class_code;
85 l_amb_context_code VARCHAR2(30) := p_amb_context_code;
86 l_accounting_line_code VARCHAR2(30) := p_accounting_line_code;
87 l_accounting_line_type_code VARCHAR2(1) := p_accounting_line_type_code;
88
89 BEGIN
90
91 xla_utility_pkg.trace('> xla_line_types_pkg.delete_line_type_details' , 10);
92
93 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
94 xla_utility_pkg.trace('entity_code = '||p_entity_code , 20);
95 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
96 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code , 20);
97 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
98
99 xla_conditions_pkg.delete_condition
100 (p_context => 'A'
101 ,p_application_id => l_application_id
102 ,p_amb_context_code => l_amb_context_code
103 ,p_entity_code => l_entity_code
104 ,p_event_class_code => l_event_class_code
105 ,p_accounting_line_type_code => l_accounting_line_type_code
106 ,p_accounting_line_code => l_accounting_line_code);
107
108 DELETE
109 FROM xla_jlt_acct_attrs
110 WHERE application_id = p_application_id
111 AND amb_context_code = p_amb_context_code
112 AND event_class_code = p_event_class_code
113 AND accounting_line_type_code = p_accounting_line_type_code
114 AND accounting_line_code = p_accounting_line_code;
115
116 xla_utility_pkg.trace('< xla_line_types_pkg.delete_line_type_details' , 10);
117
118 EXCEPTION
119 WHEN xla_exceptions_pkg.application_exception THEN
120 RAISE;
121 WHEN OTHERS THEN
122 xla_exceptions_pkg.raise_message
123 (p_location => 'xla_line_types_pkg.delete_line_type_details');
124
125 END delete_line_type_details;
126
127 /*======================================================================+
128 | |
129 | Public Procedure |
130 | |
131 | copy_line_type_details |
132 | |
133 | Copies details of a segment rule into a new segment rule |
134 | |
135 +======================================================================*/
136
137 PROCEDURE copy_line_type_details
138 (p_application_id IN NUMBER
139 ,p_amb_context_code IN VARCHAR2
140 ,p_entity_code IN VARCHAR2
141 ,p_event_class_code IN VARCHAR2
142 ,p_old_accting_line_type_code IN VARCHAR2
143 ,p_old_accounting_line_code IN VARCHAR2
144 ,p_new_accting_line_type_code IN VARCHAR2
145 ,p_new_accounting_line_code IN VARCHAR2
146 ,p_old_transaction_coa_id IN NUMBER
147 ,p_new_transaction_coa_id IN NUMBER)
148 IS
149
150 l_condition_id integer;
151 l_creation_date DATE := sysdate;
152 l_last_update_date DATE := sysdate;
153 l_created_by INTEGER := xla_environment_pkg.g_usr_id;
154 l_last_update_login INTEGER := xla_environment_pkg.g_login_id;
155 l_last_updated_by INTEGER := xla_environment_pkg.g_usr_id;
156 l_con_flexfield_segment_code VARCHAR2(30);
157 l_con_v_flexfield_segment_code VARCHAR2(30);
158 l_source_flex_appl_id NUMBER(15);
159 l_source_id_flex_code VARCHAR2(30);
160 l_value_source_flex_appl_id NUMBER(15);
161 l_value_source_id_flex_code VARCHAR2(30);
162
163 CURSOR c_conditions
164 IS
165 SELECT user_sequence, bracket_left_code, bracket_right_code, value_type_code,
166 source_application_id, source_type_code, source_code,
167 flexfield_segment_code, value_flexfield_segment_code,
168 value_source_application_id, value_source_type_code,
169 value_source_code, value_constant, line_operator_code,
170 logical_operator_code, independent_value_constant
171 FROM xla_conditions
172 WHERE application_id = p_application_id
173 AND amb_context_code = p_amb_context_code
174 AND entity_code = p_entity_code
175 AND event_class_code = p_event_class_code
176 AND accounting_line_type_code = p_old_accting_line_type_code
177 AND accounting_line_code = p_old_accounting_line_code;
178
179 l_condition c_conditions%rowtype;
180
181 CURSOR c_acct_sources
182 IS
183 SELECT accounting_attribute_code, source_application_id,
184 source_type_code, source_code, event_class_default_flag
185 FROM xla_jlt_acct_attrs
186 WHERE application_id = p_application_id
187 AND amb_context_code = p_amb_context_code
188 AND event_class_code = p_event_class_code
189 AND accounting_line_type_code = p_old_accting_line_type_code
190 AND accounting_line_code = p_old_accounting_line_code;
191
192 l_acct_source c_acct_sources%rowtype;
193
194 CURSOR c_source
195 IS
196 SELECT flexfield_application_id, id_flex_code
197 FROM xla_sources_b
198 WHERE application_id = l_condition.source_application_id
199 AND source_type_code = l_condition.source_type_code
200 AND source_code = l_condition.source_code;
201
202 CURSOR c_value_source
203 IS
204 SELECT flexfield_application_id, id_flex_code
205 FROM xla_sources_b
206 WHERE application_id = l_condition.value_source_application_id
207 AND source_type_code = l_condition.value_source_type_code
208 AND source_code = l_condition.value_source_code;
209
210 BEGIN
211
212 xla_utility_pkg.trace('> xla_line_types_pkg.copy_line_type_details' , 10);
213
214 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
215 xla_utility_pkg.trace('entity_code = '||p_entity_code , 20);
216 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
217 xla_utility_pkg.trace('old_accounting_line_type_code = '||p_old_accting_line_type_code , 20);
218 xla_utility_pkg.trace('old_accounting_line_code = '||p_old_accounting_line_code , 20);
219 xla_utility_pkg.trace('new_accounting_line_type_code = '||p_new_accting_line_type_code , 20);
220 xla_utility_pkg.trace('new_accounting_line_code = '||p_new_accounting_line_code , 20);
221
222
223 OPEN c_conditions;
224 LOOP
225 FETCH c_conditions
226 INTO l_condition;
227 EXIT WHEN c_conditions%notfound;
228
229 IF l_condition.flexfield_segment_code is not null THEN
230
231 OPEN c_source;
232 FETCH c_source
233 INTO l_source_flex_appl_id, l_source_id_flex_code;
234 CLOSE c_source;
235
236 IF l_source_flex_appl_id = 101 and l_source_id_flex_code = 'GL#' THEN
237
238 IF p_new_transaction_coa_id is not null and p_old_transaction_coa_id is null THEN
239 l_con_flexfield_segment_code := xla_flex_pkg.get_qualifier_segment
240 (p_application_id => 101
241 ,p_id_flex_code => 'GL#'
242 ,p_id_flex_num => p_new_transaction_coa_id
243 ,p_qualifier_segment => l_condition.flexfield_segment_code);
244
245 ELSE
246 l_con_flexfield_segment_code := l_condition.flexfield_segment_code;
247 END IF;
248
249 ELSE
250 -- Other key flexfield segment
251 l_con_flexfield_segment_code := l_condition.flexfield_segment_code;
252 END IF;
253 ELSE
254 l_con_flexfield_segment_code := l_condition.flexfield_segment_code;
255 END IF;
256
257 -- check value_flexfield_segment_code
258 IF l_condition.value_flexfield_segment_code is not null THEN
259
260 OPEN c_value_source;
261 FETCH c_value_source
262 INTO l_value_source_flex_appl_id, l_value_source_id_flex_code;
263 CLOSE c_value_source;
264
265 IF l_value_source_flex_appl_id = 101 and l_value_source_id_flex_code = 'GL#' THEN
266
267 IF p_new_transaction_coa_id is not null and p_old_transaction_coa_id is null THEN
268 l_con_v_flexfield_segment_code := xla_flex_pkg.get_qualifier_segment
269 (p_application_id => 101
270 ,p_id_flex_code => 'GL#'
271 ,p_id_flex_num => p_new_transaction_coa_id
272 ,p_qualifier_segment => l_condition.value_flexfield_segment_code);
273
274 ELSE
275 l_con_v_flexfield_segment_code := l_condition.value_flexfield_segment_code;
276 END IF;
277
278 ELSE
279 -- Other key flexfield segment
280 l_con_v_flexfield_segment_code := l_condition.value_flexfield_segment_code;
281 END IF;
282 ELSE
283 l_con_v_flexfield_segment_code := l_condition.value_flexfield_segment_code;
284 END IF;
285
286 SELECT xla_conditions_s.nextval
287 INTO l_condition_id
288 FROM DUAL;
289
290 INSERT INTO xla_conditions
291 (condition_id
292 ,user_sequence
293 ,application_id
294 ,amb_context_code
295 ,entity_code
296 ,event_class_code
297 ,accounting_line_type_code
298 ,accounting_line_code
299 ,bracket_left_code
300 ,bracket_right_code
301 ,value_type_code
302 ,source_application_id
303 ,source_type_code
304 ,source_code
305 ,flexfield_segment_code
306 ,value_flexfield_segment_code
307 ,value_source_application_id
308 ,value_source_type_code
309 ,value_source_code
310 ,value_constant
311 ,line_operator_code
312 ,logical_operator_code
313 ,creation_date
314 ,created_by
315 ,last_update_date
316 ,last_updated_by
317 ,last_update_login
318 ,independent_value_constant)
319 VALUES
320 (l_condition_id
321 ,l_condition.user_sequence
322 ,p_application_id
323 ,p_amb_context_code
324 ,p_entity_code
325 ,p_event_class_code
326 ,p_new_accting_line_type_code
327 ,p_new_accounting_line_code
328 ,l_condition.bracket_left_code
329 ,l_condition.bracket_right_code
330 ,l_condition.value_type_code
331 ,l_condition.source_application_id
332 ,l_condition.source_type_code
333 ,l_condition.source_code
334 ,l_con_flexfield_segment_code
335 ,l_con_v_flexfield_segment_code
336 ,l_condition.value_source_application_id
337 ,l_condition.value_source_type_code
338 ,l_condition.value_source_code
339 ,l_condition.value_constant
340 ,l_condition.line_operator_code
341 ,l_condition.logical_operator_code
342 ,l_creation_date
343 ,l_created_by
344 ,l_last_update_date
345 ,l_last_updated_by
346 ,l_last_update_login
347 ,l_condition.independent_value_constant);
348
349 END LOOP;
350 CLOSE c_conditions;
351
352 OPEN c_acct_sources;
353 LOOP
354 FETCH c_acct_sources
355 INTO l_acct_source;
356 EXIT WHEN c_acct_sources%notfound;
357
358 INSERT INTO xla_jlt_acct_attrs
359 (application_id
360 ,amb_context_code
361 ,event_class_code
362 ,accounting_line_type_code
363 ,accounting_line_code
364 ,accounting_attribute_code
365 ,source_application_id
366 ,source_type_code
367 ,source_code
368 ,event_class_default_flag
369 ,creation_date
370 ,created_by
371 ,last_update_date
372 ,last_updated_by
373 ,last_update_login)
374 VALUES
375 (p_application_id
376 ,p_amb_context_code
377 ,p_event_class_code
378 ,p_new_accting_line_type_code
379 ,p_new_accounting_line_code
380 ,l_acct_source.accounting_attribute_code
381 ,l_acct_source.source_application_id
382 ,l_acct_source.source_type_code
383 ,l_acct_source.source_code
384 ,l_acct_source.event_class_default_flag
385 ,l_creation_date
386 ,l_created_by
387 ,l_last_update_date
388 ,l_last_updated_by
389 ,l_last_update_login);
390 END LOOP;
391 CLOSE c_acct_sources;
392
393 xla_utility_pkg.trace('< xla_line_types_pkg.copy_line_type_details' , 10);
394
395 EXCEPTION
396 WHEN xla_exceptions_pkg.application_exception THEN
397 IF c_conditions%ISOPEN THEN
398 CLOSE c_conditions;
399 END IF;
400 RAISE;
401 WHEN OTHERS THEN
402 IF c_conditions%ISOPEN THEN
403 CLOSE c_conditions;
404 END IF;
405 xla_exceptions_pkg.raise_message
406 (p_location => 'xla_line_types_pkg.copy_line_type_details');
407
408 END copy_line_type_details;
409
410 /*======================================================================+
411 | |
412 | Public Function |
413 | |
414 | line_type_in_use |
415 | |
416 | Returns true if the line type is in use by a line definition |
417 | |
418 +======================================================================*/
419
420 FUNCTION line_type_in_use
421 (p_event IN VARCHAR2
422 ,p_application_id IN NUMBER
423 ,p_amb_context_code IN VARCHAR2
424 ,p_event_class_code IN VARCHAR2
425 ,p_accounting_line_type_code IN VARCHAR2
426 ,p_accounting_line_code IN VARCHAR2
427 ,x_line_definition_name IN OUT NOCOPY VARCHAR2
428 ,x_line_definition_owner IN OUT NOCOPY VARCHAR2)
429 RETURN BOOLEAN
430 IS
431
432 l_return BOOLEAN;
433 l_exist VARCHAR2(1);
434
435 CURSOR c_assignment_exist
436 IS
437 SELECT event_type_code, line_definition_owner_code, line_definition_code
438 FROM xla_line_defn_jlt_assgns
439 WHERE application_id = p_application_id
440 AND amb_context_code = p_amb_context_code
441 AND event_class_code = p_event_class_code
442 AND accounting_line_type_code = p_accounting_line_type_code
443 AND accounting_line_code = p_accounting_line_code;
444
445 l_assignment_exist c_assignment_exist%rowtype;
446
447 CURSOR c_active_assignment_exist
448 IS
449 SELECT event_type_code, line_definition_owner_code, line_definition_code
450 FROM xla_line_defn_jlt_assgns
451 WHERE application_id = p_application_id
452 AND amb_context_code = p_amb_context_code
453 AND event_class_code = p_event_class_code
454 AND accounting_line_type_code = p_accounting_line_type_code
455 AND accounting_line_code = p_accounting_line_code
456 AND active_flag = 'Y';
457
458 l_active_assignment_exist c_active_assignment_exist%rowtype;
459
460 CURSOR c_mpa_assignment_exist
461 IS
462 SELECT event_type_code, line_definition_owner_code, line_definition_code,
463 accounting_line_type_code, accounting_line_code
464 FROM xla_mpa_jlt_assgns
465 WHERE application_id = p_application_id
466 AND amb_context_code = p_amb_context_code
467 AND event_class_code = p_event_class_code
468 AND mpa_accounting_line_type_code = p_accounting_line_type_code
469 AND mpa_accounting_line_code = p_accounting_line_code;
470
471 l_mpa_assignment_exist c_mpa_assignment_exist%rowtype;
472
473 CURSOR c_mpa_active_assignment_exist
474 IS
475 SELECT mpa_jlt.event_type_code,
476 mpa_jlt.line_definition_owner_code,
477 mpa_jlt.line_definition_code,
478 mpa_jlt.accounting_line_type_code,
479 mpa_jlt.accounting_line_code
480 FROM xla_mpa_jlt_assgns mpa_jlt,
481 xla_line_defn_jlt_assgns jlt
482 WHERE mpa_jlt.application_id = p_application_id
483 AND mpa_jlt.amb_context_code = p_amb_context_code
484 AND mpa_jlt.event_class_code = p_event_class_code
485 AND mpa_jlt.mpa_accounting_line_type_code = p_accounting_line_type_code
486 AND mpa_jlt.mpa_accounting_line_code = p_accounting_line_code
487 and mpa_jlt.application_id = jlt.application_id
488 and mpa_jlt.amb_context_code = jlt.amb_context_code
489 and mpa_jlt.event_class_code = jlt.event_class_code
490 and mpa_jlt.line_definition_owner_code = jlt.line_definition_owner_code
491 and mpa_jlt.line_definition_code = jlt.line_definition_code
492 and mpa_jlt.accounting_line_type_code = jlt.accounting_line_type_code
493 and mpa_jlt.accounting_line_code = jlt.accounting_line_code
494 and jlt.active_flag = 'Y';
495
496 l_mpa_active_assignment_exist c_mpa_active_assignment_exist%rowtype;
497
498 BEGIN
499
500 xla_utility_pkg.trace('> xla_line_types_pkg.line_type_in_use' , 10);
501
502 xla_utility_pkg.trace('event = '||p_event , 20);
503 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
504 xla_utility_pkg.trace('amb_context_code = '||p_amb_context_code , 20);
505 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
506 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code , 20);
507 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
508
509 IF p_event in ('DELETE','UPDATE') THEN
510 OPEN c_assignment_exist;
511 FETCH c_assignment_exist
512 INTO l_assignment_exist;
513 IF c_assignment_exist%found then
514
515 xla_line_definitions_pvt.get_line_definition_info
516 (p_application_id => p_application_id
517 ,p_amb_context_code => p_amb_context_code
518 ,p_event_class_code => p_event_class_code
519 ,p_event_type_code => l_assignment_exist.event_type_code
520 ,p_line_definition_owner_code => l_assignment_exist.line_definition_owner_code
521 ,p_line_definition_code => l_assignment_exist.line_definition_code
522 ,x_line_definition_owner => x_line_definition_owner
523 ,x_line_definition_name => x_line_definition_name);
524
525 l_return := TRUE;
526 ELSE
527 OPEN c_mpa_assignment_exist;
528 FETCH c_mpa_assignment_exist
529 INTO l_mpa_assignment_exist;
530 IF c_mpa_assignment_exist%found then
531
532 xla_line_definitions_pvt.get_line_definition_info
533 (p_application_id => p_application_id
534 ,p_amb_context_code => p_amb_context_code
535 ,p_event_class_code => p_event_class_code
536 ,p_event_type_code => l_mpa_assignment_exist.event_type_code
537 ,p_line_definition_owner_code => l_mpa_assignment_exist.line_definition_owner_code
538 ,p_line_definition_code => l_mpa_assignment_exist.line_definition_code
539 ,x_line_definition_owner => x_line_definition_owner
540 ,x_line_definition_name => x_line_definition_name);
541
542 l_return := TRUE;
543 ELSE
544 l_return := FALSE;
545 END IF;
546 CLOSE c_mpa_assignment_exist;
547 END IF;
548 CLOSE c_assignment_exist;
549
550 ELSIF p_event = ('DISABLE') THEN
551 OPEN c_active_assignment_exist;
552 FETCH c_active_assignment_exist
553 INTO l_active_assignment_exist;
554 IF c_active_assignment_exist%found then
555
556 xla_line_definitions_pvt.get_line_definition_info
557 (p_application_id => p_application_id
558 ,p_amb_context_code => p_amb_context_code
559 ,p_event_class_code => p_event_class_code
560 ,p_event_type_code => l_active_assignment_exist.event_type_code
561 ,p_line_definition_owner_code => l_active_assignment_exist.line_definition_owner_code
562 ,p_line_definition_code => l_active_assignment_exist.line_definition_code
563 ,x_line_definition_owner => x_line_definition_owner
564 ,x_line_definition_name => x_line_definition_name);
565
566 l_return := TRUE;
567 ELSE
568 OPEN c_mpa_active_assignment_exist;
569 FETCH c_mpa_active_assignment_exist
570 INTO l_mpa_active_assignment_exist;
571 IF c_mpa_active_assignment_exist%found then
572
573 xla_line_definitions_pvt.get_line_definition_info
574 (p_application_id => p_application_id
575 ,p_amb_context_code => p_amb_context_code
576 ,p_event_class_code => p_event_class_code
577 ,p_event_type_code => l_mpa_active_assignment_exist.event_type_code
578 ,p_line_definition_owner_code => l_mpa_active_assignment_exist.line_definition_owner_code
579 ,p_line_definition_code => l_mpa_active_assignment_exist.line_definition_code
580 ,x_line_definition_owner => x_line_definition_owner
581 ,x_line_definition_name => x_line_definition_name);
582
583 l_return := TRUE;
584 ELSE
585 l_return := FALSE;
586 END IF;
587 CLOSE c_mpa_active_assignment_exist;
588 END IF;
589 CLOSE c_active_assignment_exist;
590
591 ELSE
592 xla_exceptions_pkg.raise_message
593 ('XLA' ,'XLA_COMMON_ERROR'
594 ,'ERROR' ,'Invalid event passed'
595 ,'LOCATION' ,'xla_line_types_pkg.line_type_in_use');
596
597 END IF;
598
599 xla_utility_pkg.trace('< xla_line_types_pkg.line_type_in_use' , 10);
600
601 return l_return;
602
603 EXCEPTION
604 WHEN xla_exceptions_pkg.application_exception THEN
605 IF c_assignment_exist%ISOPEN THEN
606 CLOSE c_assignment_exist;
607 END IF;
608 IF c_active_assignment_exist%ISOPEN THEN
609 CLOSE c_active_assignment_exist;
610 END IF;
611
612 RAISE;
613 WHEN OTHERS THEN
614 IF c_assignment_exist%ISOPEN THEN
615 CLOSE c_assignment_exist;
616 END IF;
617 IF c_active_assignment_exist%ISOPEN THEN
618 CLOSE c_active_assignment_exist;
619 END IF;
620
621 xla_exceptions_pkg.raise_message
622 (p_location => 'xla_line_types_pkg.line_type_in_use');
623
624 END line_type_in_use;
625
626 /*======================================================================+
627 | |
628 | Public Function |
629 | |
630 | line_type_is_invalid |
631 | |
632 | Returns true if the line type is invalid |
633 | |
634 +======================================================================*/
635
636 FUNCTION line_type_is_invalid
637 (p_application_id IN NUMBER
638 ,p_amb_context_code IN VARCHAR2
639 ,p_entity_code IN VARCHAR2
640 ,p_event_class_code IN VARCHAR2
641 ,p_accounting_line_type_code IN VARCHAR2
642 ,p_accounting_line_code IN VARCHAR2
643 ,p_message_name IN OUT NOCOPY VARCHAR2
644 ,p_accounting_attribute_name IN OUT NOCOPY VARCHAR2)
645 RETURN BOOLEAN
646 IS
647
648 l_return BOOLEAN;
649 l_exist VARCHAR2(1);
650 l_segment_rule_type_code VARCHAR2(1);
651 l_segment_rule_code VARCHAR2(30);
652 l_description_type_code VARCHAR2(1);
653 l_description_code VARCHAR2(30);
654 l_message_name VARCHAR2(30);
655 l_accounting_attribute_name VARCHAR2(80);
656 l_count NUMBER(10);
657 l_application_id NUMBER(38) := p_application_id;
658 l_entity_code VARCHAR2(30) := p_entity_code;
659 l_event_class_code VARCHAR2(30) := p_event_class_code;
660 l_amb_context_code VARCHAR2(30) := p_amb_context_code;
661 l_accounting_line_code VARCHAR2(30) := p_accounting_line_code;
662 l_accounting_line_type_code VARCHAR2(1) := p_accounting_line_type_code;
663
664 BEGIN
665
666 xla_utility_pkg.trace('> xla_line_types_pkg.line_type_is_invalid' , 10);
667
668 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
669 xla_utility_pkg.trace('entity_code = '||p_entity_code , 20);
670 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
671 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code , 20);
672 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
673
674 --
675 -- check if condition is invalid
676 --
677 IF xla_conditions_pkg.acct_condition_is_invalid
678 (p_application_id => l_application_id
679 ,p_amb_context_code => l_amb_context_code
680 ,p_entity_code => l_entity_code
681 ,p_event_class_code => l_event_class_code
682 ,p_accounting_line_type_code => l_accounting_line_type_code
683 ,p_accounting_line_code => l_accounting_line_code
684 ,p_message_name => l_message_name)
685 THEN
686 p_message_name := l_message_name;
687 p_accounting_attribute_name := NULL;
688 l_return := TRUE;
689 ELSE
690 p_message_name := NULL;
691 p_accounting_attribute_name := NULL;
692 l_return := FALSE;
693 END IF;
694
695 IF l_return = FALSE THEN
696 IF NOT chk_line_accting_sources
697 (p_application_id => l_application_id
698 ,p_amb_context_code => l_amb_context_code
699 ,p_entity_code => l_entity_code
700 ,p_event_class_code => l_event_class_code
701 ,p_accounting_line_type_code => l_accounting_line_type_code
702 ,p_accounting_line_code => l_accounting_line_code
703 ,p_message_name => l_message_name
704 ,p_accounting_attribute_name => l_accounting_attribute_name)
705 THEN
706 p_message_name := l_message_name;
707 p_accounting_attribute_name := l_accounting_attribute_name;
708 l_return := TRUE;
709 ELSE
710 p_message_name := NULL;
711 p_accounting_attribute_name := NULL;
712 l_return := FALSE;
713 END IF;
714 END IF;
715
716 xla_utility_pkg.trace('p_message_name = '||p_message_name , 20);
717 xla_utility_pkg.trace('< xla_line_types_pkg.line_type_is_invalid' , 10);
718
719 return l_return;
720
721 EXCEPTION
722 WHEN xla_exceptions_pkg.application_exception THEN
723 RAISE;
724
725 WHEN OTHERS THEN
726 xla_exceptions_pkg.raise_message
727 (p_location => 'xla_line_types_pkg.line_type_is_invalid');
728
729 END line_type_is_invalid;
730
731 /*======================================================================+
732 | |
733 | Public Function |
734 | |
735 | line_type_is_locked |
736 | |
737 | Returns true if the line type is used by a frozen line definition |
738 | |
739 +======================================================================*/
740
741 FUNCTION line_type_is_locked
742 (p_application_id IN NUMBER
743 ,p_amb_context_code IN VARCHAR2
744 ,p_entity_code IN VARCHAR2
745 ,p_event_class_code IN VARCHAR2
746 ,p_accounting_line_type_code IN VARCHAR2
747 ,p_accounting_line_code IN VARCHAR2)
748 RETURN BOOLEAN
749 IS
750
751 l_return BOOLEAN;
752 l_exist VARCHAR2(1);
753
754 CURSOR c_frozen_assignment_exist
755 IS
756 SELECT 'x'
757 FROM xla_line_defn_jlt_assgns s
758 WHERE application_id = p_application_id
759 AND amb_context_code = p_amb_context_code
760 AND event_class_code = p_event_class_code
761 AND accounting_line_type_code = p_accounting_line_type_code
762 AND accounting_line_code = p_accounting_line_code
763 AND exists (SELECT 'x'
764 FROM xla_aad_line_defn_assgns a
765 ,xla_prod_acct_headers h
766 WHERE h.application_id = a.application_id
767 AND h.amb_context_code = a.amb_context_code
768 AND h.product_rule_type_code = a.product_rule_type_code
769 AND h.product_rule_code = a.product_rule_code
770 AND h.event_class_code = a.event_class_code
771 AND h.event_type_code = a.event_type_code
772 AND h.locking_status_flag = 'Y'
773 AND a.application_id = s.application_id
774 AND a.amb_context_code = s.amb_context_code
775 AND a.event_class_code = s.event_class_code
776 AND a.event_type_code = s.event_type_code
777 AND a.line_definition_owner_code = s.line_definition_owner_code
778 AND a.line_definition_code = s.line_definition_code);
779
780 BEGIN
781
782 xla_utility_pkg.trace('> xla_line_types_pkg.line_type_is_locked' , 10);
783
784 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
785 xla_utility_pkg.trace('entity_code = '||p_entity_code , 20);
786 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
787 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code , 20);
788 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
789
790 OPEN c_frozen_assignment_exist;
791 FETCH c_frozen_assignment_exist
792 INTO l_exist;
793 IF c_frozen_assignment_exist%found then
794 l_return := TRUE;
795 ELSE
796 l_return := FALSE;
797 END IF;
798 CLOSE c_frozen_assignment_exist;
799
800 xla_utility_pkg.trace('< xla_line_types_pkg.line_type_is_locked' , 10);
801
802 return l_return;
803
804 EXCEPTION
805 WHEN xla_exceptions_pkg.application_exception THEN
806 IF c_frozen_assignment_exist%ISOPEN THEN
807 CLOSE c_frozen_assignment_exist;
808 END IF;
809
810 RAISE;
811 WHEN OTHERS THEN
812 IF c_frozen_assignment_exist%ISOPEN THEN
813 CLOSE c_frozen_assignment_exist;
814 END IF;
815
816 xla_exceptions_pkg.raise_message
817 (p_location => 'xla_line_types_pkg.line_type_is_locked');
818
819 END line_type_is_locked;
820
821 /* ---------------------------------------------------------------------
822 This is a public procedure. It is used to delete the assignments of
823 those accounting attributes that is not needed for a gain/loss line
824 type. It is called when user change a credit or debit line type to
825 gain/loss line type. Some accounting attribute assignments existed
826 for the line type should be deleted
827 --------------------------------------------------------------------- */
828 PROCEDURE delete_non_gain_acct_attrs(
829 p_application_id IN NUMBER
830 ,p_amb_context_code IN VARCHAR2
831 ,p_event_class_code IN VARCHAR2
832 ,p_accounting_line_type_code IN VARCHAR2
833 ,p_accounting_line_code IN VARCHAR2)
834 IS
835 BEGIN
836 xla_utility_pkg.trace('> xla_line_types_pkg.delete_non_gain_acct_attrs' , 10); xla_utility_pkg.trace('application_id = '||p_application_id , 20);
837 xla_utility_pkg.trace('amb_context_code = '||p_amb_context_code , 20);
838 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
839 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code , 20);
840 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
841
842 delete xla_jlt_acct_attrs
843 WHERE application_id = p_application_id
844 AND amb_context_code = p_amb_context_code
845 AND event_class_code = p_event_class_code
846 AND accounting_line_type_code = p_accounting_line_type_code
847 AND accounting_line_code = p_accounting_line_code
848 AND accounting_attribute_code in (
849 'ENTERED_CURRENCY_AMOUNT'
850 ,'ENTERED_CURRENCY_CODE'
851 ,'EXCHANGE_RATE_TYPE'
852 ,'EXCHANGE_DATE'
853 ,'EXCHANGE_RATE'
854 );
855 xla_utility_pkg.trace('< xla_line_types_pkg.delete_non_gain_acct_attrs' , 10);
856
857 EXCEPTION
858 WHEN xla_exceptions_pkg.application_exception THEN
859 RAISE;
860 WHEN OTHERS THEN
861 xla_exceptions_pkg.raise_message
862 (p_location => 'xla_line_types_pkg.delete_non_gain_acct_attrs');
863 END delete_non_gain_acct_attrs;
864
865
866 /* ---------------------------------------------------------------------
867 This is a public procedure. It is insert the assignments of
868 those accounting attributes that is not needed for a gain/loss line
869 type but needed for normal debit/credit line type. It is called when
870 user change a gain/loss line type to credit or debit line type. Gain/loss
871 line type don't have the assignment for some accounting attributes. This
872 procedure will insert the assignment for those attributes
873 --------------------------------------------------------------------- */
874 PROCEDURE insert_non_gain_acct_attrs(
875 p_application_id IN NUMBER
876 ,p_amb_context_code IN VARCHAR2
877 ,p_event_class_code IN VARCHAR2
878 ,p_accounting_line_type_code IN VARCHAR2
879 ,p_accounting_line_code IN VARCHAR2)
880 IS
881 CURSOR c_attr_source
882 IS
883 SELECT e.accounting_attribute_code, e.source_application_id,
884 e.source_type_code, e.source_code
885 FROM xla_evt_class_acct_attrs e, xla_acct_attributes_b l
886 WHERE e.application_id = p_application_id
887 AND e.event_class_code = p_event_class_code
888 AND e.default_flag = 'Y'
889 AND e.accounting_attribute_code = l.accounting_attribute_code
890 AND l.assignment_level_code = 'EVT_CLASS_JLT'
891 AND e.accounting_attribute_code in (
892 'ENTERED_CURRENCY_AMOUNT'
893 ,'ENTERED_CURRENCY_CODE'
894 ,'EXCHANGE_RATE_TYPE'
895 ,'EXCHANGE_DATE'
896 ,'EXCHANGE_RATE');
897
898 l_arr_acct_attribute_code t_array_codes;
899 l_arr_source_application_id t_array_id;
900 l_arr_source_type_code t_array_codes;
901 l_arr_source_code t_array_codes;
902
903 BEGIN
904 xla_utility_pkg.trace('> xla_line_types_pkg.insert_non_gain_acct_attrs' , 10);
905 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
906 xla_utility_pkg.trace('amb_context_code = '||p_amb_context_code , 20);
907 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
908 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code , 20);
909 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
910
911 INSERT into xla_jlt_acct_attrs(
912 application_id
913 ,amb_context_code
914 ,event_class_code
915 ,accounting_line_type_code
916 ,accounting_line_code
917 ,accounting_attribute_code
918 ,source_application_id
919 ,source_type_code
920 ,source_code
921 ,event_class_default_flag
922 ,creation_date
923 ,created_by
924 ,last_update_date
925 ,last_updated_by
926 ,last_update_login)
927 (SELECT distinct p_application_id
928 ,p_amb_context_code
929 ,p_event_class_code
930 ,p_accounting_line_type_code
931 ,p_accounting_line_code
932 ,e.accounting_attribute_code
933 ,null
934 ,null
935 ,null
936 ,'Y'
937 ,g_creation_date
938 ,g_created_by
939 ,g_last_update_date
940 ,g_last_updated_by
941 ,g_last_update_login
942 FROM xla_evt_class_acct_attrs e, xla_acct_attributes_b l
943 WHERE e.application_id = p_application_id
944 AND e.event_class_code = p_event_class_code
945 AND e.accounting_attribute_code = l.accounting_attribute_code
946 AND l.assignment_level_code = 'EVT_CLASS_JLT'
947 AND e.accounting_attribute_code in (
948 'ENTERED_CURRENCY_AMOUNT'
949 ,'ENTERED_CURRENCY_CODE'
950 ,'EXCHANGE_RATE_TYPE'
951 ,'EXCHANGE_DATE'
952 ,'EXCHANGE_RATE')
953 );
954
955 -- Update the default source mappings on the JLT for
956 -- the accounting attributes just inserted
957 OPEN c_attr_source;
958 FETCH c_attr_source
959 BULK COLLECT INTO l_arr_acct_attribute_code, l_arr_source_application_id,
960 l_arr_source_type_code, l_arr_source_code;
961
962 IF l_arr_acct_attribute_code.COUNT > 0 THEN
963 FORALL i IN l_arr_acct_attribute_code.FIRST..l_arr_acct_attribute_code.LAST
964 UPDATE xla_jlt_acct_attrs
965 SET source_application_id = l_arr_source_application_id(i)
966 ,source_type_code = l_arr_source_type_code(i)
967 ,source_code = l_arr_source_code(i)
968 WHERE application_id = p_application_id
969 AND amb_context_code = p_amb_context_code
970 AND event_class_code = p_event_class_code
971 AND accounting_line_type_code = p_accounting_line_type_code
972 AND accounting_line_code = p_accounting_line_code
973 AND accounting_attribute_code = l_arr_acct_attribute_code(i)
974 AND event_class_default_flag = 'Y';
975 END IF;
976 CLOSE c_attr_source;
977
978 xla_utility_pkg.trace('< xla_line_types_pkg.insert_non_gain_acct_attrs' , 10);
979
980 EXCEPTION
981 WHEN xla_exceptions_pkg.application_exception THEN
982 RAISE;
983 WHEN OTHERS THEN
984 xla_exceptions_pkg.raise_message
985 (p_location => 'xla_line_types_pkg.insert_non_gain_acct_attrs');
986
987 END insert_non_gain_acct_attrs;
988
989 /* ---------------------------------------------------------------------
990 This is a public procedure. It checks if assignment to some accounting
991 attributes exists at the jlt level. For gain/loss line type, some
992 accounting attributes are not needed. This function is used for that
993 purpose
994 --------------------------------------------------------------------- */
995 FUNCTION non_gain_acct_attrs_exists
996 (p_application_id IN NUMBER
997 ,p_amb_context_code IN VARCHAR2
998 ,p_event_class_code IN VARCHAR2
999 ,p_accounting_line_type_code IN VARCHAR2
1000 ,p_accounting_line_code IN VARCHAR2)
1001 return boolean
1002 is
1003 l_temp VARCHAR2(1);
1004 l_result boolean;
1005 cursor c_non_gain_acct_attrs is
1006 SELECT 'x'
1007 FROM xla_jlt_acct_attrs
1008 WHERE application_id = p_application_id
1009 AND amb_context_code = p_amb_context_code
1010 AND event_class_code = p_event_class_code
1011 AND accounting_line_type_code = p_accounting_line_type_code
1012 AND accounting_line_code = p_accounting_line_code
1013 AND accounting_attribute_code in (
1014 'ENTERED_CURRENCY_AMOUNT'
1015 ,'ENTERED_CURRENCY_CODE'
1016 ,'EXCHANGE_RATE_TYPE'
1017 ,'EXCHANGE_DATE'
1018 ,'EXCHANGE_RATE'
1019 );
1020 BEGIN
1021
1022 xla_utility_pkg.trace('> xla_line_types_pkg.non_gain_acct_attrs_exists' , 10);
1023
1024 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
1025 xla_utility_pkg.trace('amb_context_code = '||p_amb_context_code , 20);
1026 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
1027 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code , 20);
1028 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
1029
1030 open c_non_gain_acct_attrs;
1031 fetch c_non_gain_acct_attrs into l_temp;
1032 IF c_non_gain_acct_attrs%notfound THEN
1033 l_result := false;
1034 ELSE
1035 l_result := true;
1036 END IF;
1037
1038 return l_result;
1039
1040 xla_utility_pkg.trace('< xla_line_types_pkg.non_gain_acct_attrs_exists' , 10);
1041
1042 EXCEPTION
1043 WHEN xla_exceptions_pkg.application_exception THEN
1044 RAISE;
1045 WHEN OTHERS THEN
1046 xla_exceptions_pkg.raise_message
1047 (p_location => 'xla_line_types_pkg.non_gain_acct_attrs_exists');
1048 END non_gain_acct_attrs_exists;
1049
1050
1051
1052 /*======================================================================+
1053 | |
1054 | Public Procedure |
1055 | |
1056 | create_accounting_attributes |
1057 | |
1058 | Creates accounting attributes for the line type |
1059 | |
1060 +======================================================================*/
1061
1062 PROCEDURE create_accounting_attributes
1063 (p_application_id IN NUMBER
1064 ,p_amb_context_code IN VARCHAR2
1065 ,p_event_class_code IN VARCHAR2
1066 ,p_accounting_line_type_code IN VARCHAR2
1067 ,p_accounting_line_code IN VARCHAR2
1068 ,p_side_code IN VARCHAR2
1069 ,p_business_method_code IN VARCHAR2
1070 )
1071 IS
1072
1073 -- Array Declaration
1074 l_arr_acct_attribute_code t_array_codes;
1075 l_arr_source_application_id t_array_id;
1076 l_arr_source_type_code t_array_codes;
1077 l_arr_source_code t_array_codes;
1078
1079 l_arr_p_acct_attribute_code t_array_codes;
1080 l_arr_p_source_application_id t_array_id;
1081 l_arr_p_source_type_code t_array_codes;
1082 l_arr_p_source_code t_array_codes;
1083
1084 -- Local Variables
1085 l_exist VARCHAR2(1);
1086
1087 CURSOR c_acct_sources
1088 IS
1089 SELECT 'x'
1090 FROM xla_jlt_acct_attrs
1091 WHERE application_id = p_application_id
1092 AND amb_context_code = p_amb_context_code
1093 AND event_class_code = p_event_class_code
1094 AND accounting_line_type_code = p_accounting_line_type_code
1095 AND accounting_line_code = p_accounting_line_code;
1096
1097 CURSOR c_attr_source
1098 IS
1099 SELECT e.accounting_attribute_code, e.source_application_id,
1100 e.source_type_code, e.source_code
1101 FROM xla_evt_class_acct_attrs e, xla_acct_attributes_b l
1102 WHERE e.application_id = p_application_id
1103 AND e.event_class_code = p_event_class_code
1104 AND e.default_flag = 'Y'
1105 AND e.accounting_attribute_code = l.accounting_attribute_code
1106 AND l.assignment_level_code = 'EVT_CLASS_JLT';
1107
1108 CURSOR c_prior_entry_source
1109 IS
1110 SELECT e.accounting_attribute_code, e.source_application_id,
1111 e.source_type_code, e.source_code
1112 FROM xla_evt_class_acct_attrs e, xla_acct_attributes_b l
1113 WHERE e.application_id = p_application_id
1114 AND e.event_class_code = p_event_class_code
1115 AND e.default_flag = 'Y'
1116 AND e.accounting_attribute_code = l.accounting_attribute_code
1117 AND l.assignment_level_code = 'EVT_CLASS_JLT'
1118 AND l.inherited_flag = 'N';
1119
1120 BEGIN
1121
1122 xla_utility_pkg.trace('> xla_line_types_pkg.create_accounting_attributes' , 10);
1123
1124 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
1125 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
1126 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code, 20);
1127 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
1128
1129 OPEN c_acct_sources;
1130 FETCH c_acct_sources
1131 INTO l_exist;
1132 IF c_acct_sources%notfound THEN
1133
1134 -- Insert accounting attributes of level 'EVT_CLASS_JLT' and 'JLT_ONLY'
1135 -- with null source mapping
1136 IF p_side_code = 'G' THEN
1137 INSERT into xla_jlt_acct_attrs(
1138 application_id
1139 ,amb_context_code
1140 ,event_class_code
1141 ,accounting_line_type_code
1142 ,accounting_line_code
1143 ,accounting_attribute_code
1144 ,source_application_id
1145 ,source_type_code
1146 ,source_code
1147 ,event_class_default_flag
1148 ,creation_date
1149 ,created_by
1150 ,last_update_date
1151 ,last_updated_by
1152 ,last_update_login)
1153 (SELECT distinct p_application_id
1154 ,p_amb_context_code
1155 ,p_event_class_code
1156 ,p_accounting_line_type_code
1157 ,p_accounting_line_code
1158 ,e.accounting_attribute_code
1159 ,null
1160 ,null
1161 ,null
1162 ,'Y'
1163 ,g_creation_date
1164 ,g_created_by
1165 ,g_last_update_date
1166 ,g_last_updated_by
1167 ,g_last_update_login
1168 FROM xla_evt_class_acct_attrs e, xla_acct_attributes_b l
1169 WHERE e.application_id = p_application_id
1170 AND e.event_class_code = p_event_class_code
1171 AND e.accounting_attribute_code = l.accounting_attribute_code
1172 AND l.assignment_level_code = 'EVT_CLASS_JLT'
1173 AND e.accounting_attribute_code not in (
1174 'ENTERED_CURRENCY_AMOUNT'
1175 ,'ENTERED_CURRENCY_CODE'
1176 ,'EXCHANGE_RATE_TYPE'
1177 ,'EXCHANGE_DATE'
1178 ,'EXCHANGE_RATE')
1179 AND l.assignment_group_code NOT IN ('MULTIPERIOD_CODE'
1180 ,'BUSINESS_FLOW')
1181 UNION
1182 SELECT distinct p_application_id
1183 ,p_amb_context_code
1184 ,p_event_class_code
1185 ,p_accounting_line_type_code
1186 ,p_accounting_line_code
1187 ,l.accounting_attribute_code
1188 ,null
1189 ,null
1190 ,null
1191 ,'N'
1192 ,g_creation_date
1193 ,g_created_by
1194 ,g_last_update_date
1195 ,g_last_updated_by
1196 ,g_last_update_login
1197 FROM xla_acct_attributes_b l
1198 WHERE l.assignment_level_code = 'JLT_ONLY'
1199 );
1200 ELSE
1201 INSERT into xla_jlt_acct_attrs(
1202 application_id
1203 ,amb_context_code
1204 ,event_class_code
1205 ,accounting_line_type_code
1206 ,accounting_line_code
1207 ,accounting_attribute_code
1208 ,source_application_id
1209 ,source_type_code
1210 ,source_code
1211 ,event_class_default_flag
1212 ,creation_date
1213 ,created_by
1214 ,last_update_date
1215 ,last_updated_by
1216 ,last_update_login)
1217 (SELECT distinct p_application_id
1218 ,p_amb_context_code
1219 ,p_event_class_code
1220 ,p_accounting_line_type_code
1221 ,p_accounting_line_code
1222 ,e.accounting_attribute_code
1223 ,null
1224 ,null
1225 ,null
1226 ,'Y'
1227 ,g_creation_date
1228 ,g_created_by
1229 ,g_last_update_date
1230 ,g_last_updated_by
1231 ,g_last_update_login
1232 FROM xla_evt_class_acct_attrs e, xla_acct_attributes_b l
1233 WHERE e.application_id = p_application_id
1234 AND e.event_class_code = p_event_class_code
1235 AND e.accounting_attribute_code = l.accounting_attribute_code
1236 AND l.assignment_level_code = 'EVT_CLASS_JLT'
1237 UNION
1238 SELECT distinct p_application_id
1239 ,p_amb_context_code
1240 ,p_event_class_code
1241 ,p_accounting_line_type_code
1242 ,p_accounting_line_code
1243 ,l.accounting_attribute_code
1244 ,null
1245 ,null
1246 ,null
1247 ,'N'
1248 ,g_creation_date
1249 ,g_created_by
1250 ,g_last_update_date
1251 ,g_last_updated_by
1252 ,g_last_update_login
1253 FROM xla_acct_attributes_b l
1254 WHERE l.assignment_level_code = 'JLT_ONLY');
1255 END IF;
1256
1257 IF p_business_method_code = 'PRIOR_ENTRY' THEN
1258 -- Update the default source mappings on the JLT for the accounting
1259 -- attributes that are not inherited
1260
1261 OPEN c_prior_entry_source;
1262 FETCH c_prior_entry_source
1263 BULK COLLECT INTO l_arr_p_acct_attribute_code, l_arr_p_source_application_id,
1264 l_arr_p_source_type_code, l_arr_p_source_code;
1265
1266 IF l_arr_p_acct_attribute_code.COUNT > 0 THEN
1267 FORALL i IN l_arr_p_acct_attribute_code.FIRST..l_arr_p_acct_attribute_code.LAST
1268
1269 UPDATE xla_jlt_acct_attrs
1270 SET source_application_id = l_arr_p_source_application_id(i)
1271 ,source_type_code = l_arr_p_source_type_code(i)
1272 ,source_code = l_arr_p_source_code(i)
1273 WHERE application_id = p_application_id
1274 AND amb_context_code = p_amb_context_code
1275 AND event_class_code = p_event_class_code
1276 AND accounting_line_type_code = p_accounting_line_type_code
1277 AND accounting_line_code = p_accounting_line_code
1278 AND accounting_attribute_code = l_arr_p_acct_attribute_code(i)
1279 AND event_class_default_flag = 'Y';
1280 END IF;
1281 CLOSE c_prior_entry_source;
1282
1283 -- Not a prior entry jlt
1284 ELSE
1285
1286 -- Update the default source mappings on the JLT for all accounting attributes
1287 OPEN c_attr_source;
1288 FETCH c_attr_source
1289 BULK COLLECT INTO l_arr_acct_attribute_code, l_arr_source_application_id,
1290 l_arr_source_type_code, l_arr_source_code;
1291
1292 IF l_arr_acct_attribute_code.COUNT > 0 THEN
1293 FORALL i IN l_arr_acct_attribute_code.FIRST..l_arr_acct_attribute_code.LAST
1294
1295 UPDATE xla_jlt_acct_attrs
1296 SET source_application_id = l_arr_source_application_id(i)
1297 ,source_type_code = l_arr_source_type_code(i)
1298 ,source_code = l_arr_source_code(i)
1299 WHERE application_id = p_application_id
1300 AND amb_context_code = p_amb_context_code
1301 AND event_class_code = p_event_class_code
1302 AND accounting_line_type_code = p_accounting_line_type_code
1303 AND accounting_line_code = p_accounting_line_code
1304 AND accounting_attribute_code = l_arr_acct_attribute_code(i)
1305 AND event_class_default_flag = 'Y';
1306 END IF;
1307 CLOSE c_attr_source;
1308 END IF;
1309 END IF;
1310 CLOSE c_acct_sources;
1311
1312 xla_utility_pkg.trace('< xla_line_types_pkg.create_accounting_attributes' , 10);
1313
1314 EXCEPTION
1315 WHEN xla_exceptions_pkg.application_exception THEN
1316 RAISE;
1317 WHEN OTHERS THEN
1318 xla_exceptions_pkg.raise_message
1319 (p_location => 'xla_line_types_pkg.create_accounting_attributes');
1320
1321 END create_accounting_attributes;
1322
1323 /*======================================================================+
1324 | |
1325 | Public Function |
1326 | |
1327 | uncompile_definitions |
1328 | |
1329 | Returns true if all the application accounting definitions and |
1330 | journal line definitions using this journal line type are uncompiled |
1331 | |
1332 +======================================================================*/
1333
1334 FUNCTION uncompile_definitions
1335 (p_application_id IN NUMBER
1336 ,p_amb_context_code IN VARCHAR2
1337 ,p_event_class_code IN VARCHAR2
1338 ,p_accounting_line_type_code IN VARCHAR2
1339 ,p_accounting_line_code IN VARCHAR2
1340 ,x_product_rule_name IN OUT NOCOPY VARCHAR2
1341 ,x_product_rule_type IN OUT NOCOPY VARCHAR2
1342 ,x_event_class_name IN OUT NOCOPY VARCHAR2
1343 ,x_event_type_name IN OUT NOCOPY VARCHAR2
1344 ,x_locking_status_flag IN OUT NOCOPY VARCHAR2)
1345 RETURN BOOLEAN
1346 IS
1347
1348 l_return BOOLEAN := TRUE;
1349 l_application_name varchar2(240) := null;
1350 l_product_rule_name varchar2(80) := null;
1351 l_product_rule_type varchar2(80) := null;
1352 l_event_class_name varchar2(80) := null;
1353 l_event_type_name varchar2(80) := null;
1354 l_locking_status_flag varchar2(1) := null;
1355
1356 CURSOR c_locked_aads IS
1357 SELECT xpa.entity_code
1358 , xpa.event_class_code
1359 , xpa.event_type_code
1360 , xpa.product_rule_type_code
1361 , xpa.product_rule_code
1362 , xpa.locking_status_flag
1363 , xpa.validation_status_code
1364 FROM xla_line_defn_jlt_assgns xjl
1365 ,xla_aad_line_defn_assgns xal
1366 ,xla_prod_acct_headers xpa
1367 WHERE xpa.application_id = xal.application_id
1368 AND xpa.amb_context_code = xal.amb_context_code
1369 AND xpa.product_rule_type_code = xal.product_rule_type_code
1370 AND xpa.product_rule_code = xal.product_rule_code
1371 AND xpa.event_class_code = xal.event_class_code
1372 AND xpa.event_type_code = xal.event_type_code
1373 AND xal.application_id = xjl.application_id
1374 AND xal.amb_context_code = xjl.amb_context_code
1375 AND xal.event_class_code = xjl.event_class_code
1376 AND xal.event_type_code = xjl.event_type_code
1377 AND xal.line_definition_owner_code = xjl.line_definition_owner_code
1378 AND xal.line_definition_code = xjl.line_definition_code
1379 AND xjl.application_id = p_application_id
1380 AND xjl.amb_context_code = p_amb_context_code
1381 AND xjl.event_class_code = p_event_class_code
1382 AND xjl.accounting_line_type_code = p_accounting_line_type_code
1383 AND xjl.accounting_line_code = p_accounting_line_code
1384 FOR UPDATE NOWAIT;
1385
1386 CURSOR c_update_aads IS
1387 SELECT xal.event_class_code
1388 , xal.product_rule_type_code
1389 , xal.product_rule_code
1390 FROM xla_line_defn_jlt_assgns xjl
1391 ,xla_aad_line_defn_assgns xal
1392 ,xla_prod_acct_headers xpa
1393 ,xla_product_rules_b xpr
1394 WHERE xpr.application_id = xpa.application_id
1395 AND xpr.amb_context_code = xpa.amb_context_code
1396 AND xpr.product_rule_type_code = xpa.product_rule_type_code
1397 AND xpr.product_rule_code = xpa.product_rule_code
1398 AND xpa.application_id = xal.application_id
1399 AND xpa.amb_context_code = xal.amb_context_code
1400 AND xpa.event_class_code = xal.event_class_code
1401 AND xpa.event_type_code = xal.event_type_code
1402 AND xal.application_id = xjl.application_id
1403 AND xal.amb_context_code = xjl.amb_context_code
1404 AND xal.event_class_code = xjl.event_class_code
1405 AND xal.event_type_code = xjl.event_type_code
1406 AND xal.line_definition_owner_code = xjl.line_definition_owner_code
1407 AND xal.line_definition_code = xjl.line_definition_code
1408 AND xjl.application_id = p_application_id
1409 AND xjl.amb_context_code = p_amb_context_code
1410 AND xjl.event_class_code = p_event_class_code
1411 AND xjl.accounting_line_type_code = p_accounting_line_type_code
1412 AND xjl.accounting_line_code = p_accounting_line_code;
1413
1414 l_event_class_codes t_array_codes;
1415 l_product_rule_type_codes t_array_type_codes;
1416 l_product_rule_codes t_array_codes;
1417 BEGIN
1418
1419 xla_utility_pkg.trace('> xla_line_types_pkg.uncompile_definitions' , 10);
1420
1421 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
1422 xla_utility_pkg.trace('amb_context_code = '||p_amb_context_code , 20);
1423 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
1424 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code , 20);
1425 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
1426
1427 l_return := TRUE;
1428
1429 FOR l_lock_aad IN c_locked_aads LOOP
1430 IF (l_lock_aad.validation_status_code NOT IN ('E', 'Y', 'N') OR
1431 l_lock_aad.locking_status_flag = 'Y') THEN
1432
1433 xla_validations_pkg.get_product_rule_info
1434 (p_application_id => p_application_id
1435 ,p_amb_context_code => p_amb_context_code
1436 ,p_product_rule_type_code => l_lock_aad.product_rule_type_code
1437 ,p_product_rule_code => l_lock_aad.product_rule_code
1438 ,p_application_name => l_application_name
1439 ,p_product_rule_name => l_product_rule_name
1440 ,p_product_rule_type => l_product_rule_type);
1441
1442 xla_validations_pkg.get_event_class_info
1443 (p_application_id => p_application_id
1444 ,p_entity_code => l_lock_aad.entity_code
1445 ,p_event_class_code => l_lock_aad.event_class_code
1446 ,p_event_class_name => l_event_class_name);
1447
1448 xla_validations_pkg.get_event_type_info
1449 (p_application_id => p_application_id
1450 ,p_entity_code => l_lock_aad.entity_code
1451 ,p_event_class_code => l_lock_aad.event_class_code
1452 ,p_event_type_code => l_lock_aad.event_type_code
1453 ,p_event_type_name => l_event_type_name);
1454
1455 l_locking_status_flag := l_lock_aad.locking_status_flag;
1456 l_return := FALSE;
1457 EXIT;
1458 END IF;
1459 END LOOP;
1460
1461 IF (l_return) THEN
1462
1463 UPDATE xla_line_definitions_b xld
1464 SET validation_status_code = 'N'
1465 WHERE xld.application_id = p_application_id
1466 AND xld.amb_context_code = p_amb_context_code
1467 AND xld.event_class_code = p_event_class_code
1468 AND xld.validation_status_code <> 'N'
1469 AND EXISTS
1470 (SELECT 1
1471 FROM xla_line_defn_jlt_assgns xjl
1472 WHERE xjl.application_id = p_application_id
1473 AND xjl.amb_context_code = p_amb_context_code
1474 AND xjl.event_class_code = p_event_class_code
1475 AND xjl.accounting_line_type_code = p_accounting_line_type_code
1476 AND xjl.accounting_line_code = p_accounting_line_code
1477 AND xjl.event_type_code = xld.event_type_code
1478 AND xjl.line_definition_owner_code = xld.line_definition_owner_code
1479 AND xjl.line_definition_code = xld.line_definition_code);
1480
1481 OPEN c_update_aads;
1482 FETCH c_update_aads BULK COLLECT INTO l_event_class_codes
1483 ,l_product_rule_type_codes
1484 ,l_product_rule_codes;
1485 CLOSE c_update_aads;
1486
1487 IF (l_event_class_codes.count > 0) THEN
1488
1489 FORALL i IN 1..l_event_class_codes.LAST
1490 UPDATE xla_product_rules_b xpr
1491 SET compile_status_code = 'N'
1492 , updated_flag = 'Y'
1493 , last_update_date = sysdate
1494 , last_updated_by = xla_environment_pkg.g_usr_id
1495 , last_update_login = xla_environment_pkg.g_login_id
1496 WHERE application_id = p_application_id
1497 AND amb_context_code = p_amb_context_code
1498 AND product_rule_type_code = l_product_rule_type_codes(i)
1499 AND product_rule_code = l_product_rule_codes(i)
1500 AND (compile_status_code <> 'N' OR
1501 updated_flag <> 'Y');
1502
1503 FORALL i IN 1..l_event_class_codes.LAST
1504 UPDATE xla_prod_acct_headers xpa
1505 SET validation_status_code = 'N'
1506 , last_update_date = sysdate
1507 , last_updated_by = xla_environment_pkg.g_usr_id
1508 , last_update_login = xla_environment_pkg.g_login_id
1509 WHERE application_id = p_application_id
1510 AND amb_context_code = p_amb_context_code
1511 AND event_class_code = l_event_class_codes(i)
1512 AND product_rule_type_code = l_product_rule_type_codes(i)
1513 AND product_rule_code = l_product_rule_codes(i)
1514 AND validation_status_code <> 'N';
1515
1516 END IF;
1517
1518 UPDATE xla_appli_amb_contexts
1519 SET updated_flag = 'Y'
1520 , last_update_date = sysdate
1521 , last_updated_by = xla_environment_pkg.g_usr_id
1522 , last_update_login = xla_environment_pkg.g_login_id
1523 WHERE application_id = p_application_id
1524 AND amb_context_code = p_amb_context_code
1525 AND updated_flag <> 'Y';
1526
1527 END IF;
1528
1529 x_product_rule_name := l_product_rule_name;
1530 x_product_rule_type := l_product_rule_type;
1531 x_event_class_name := l_event_class_name;
1532 x_event_type_name := l_event_type_name;
1533 x_locking_status_flag := l_locking_status_flag;
1534
1535 xla_utility_pkg.trace('< xla_line_types_pkg.uncompile_definitions' , 10);
1536
1537 return l_return;
1538
1539 EXCEPTION
1540 WHEN xla_exceptions_pkg.application_exception THEN
1541 IF c_update_aads%ISOPEN THEN
1542 CLOSE c_update_aads;
1543 END IF;
1544 IF c_locked_aads%ISOPEN THEN
1545 CLOSE c_locked_aads;
1546 END IF;
1547
1548 RAISE;
1549 WHEN OTHERS THEN
1550 IF c_update_aads%ISOPEN THEN
1551 CLOSE c_update_aads;
1552 END IF;
1553 IF c_locked_aads%ISOPEN THEN
1554 CLOSE c_locked_aads;
1555 END IF;
1556
1557 xla_exceptions_pkg.raise_message
1558 (p_location => 'xla_line_types_pkg.uncompile_definitions');
1559
1560 END uncompile_definitions;
1561
1562 /*======================================================================+
1563 | |
1564 | Public Procedure |
1565 | |
1566 | get_default_attr_assignment |
1567 | |
1568 | Gets the default source assignments for the accounting attribute |
1569 | |
1570 +======================================================================*/
1571
1572 PROCEDURE get_default_attr_assignment
1573 (p_application_id IN NUMBER
1574 ,p_event_class_code IN VARCHAR2
1575 ,p_accounting_attribute_code IN VARCHAR2
1576 ,p_source_application_id IN OUT NOCOPY NUMBER
1577 ,p_source_type_code IN OUT NOCOPY VARCHAR2
1578 ,p_source_code IN OUT NOCOPY VARCHAR2
1579 ,p_source_name IN OUT NOCOPY VARCHAR2
1580 ,p_source_type_dsp IN OUT NOCOPY VARCHAR2)
1581 IS
1582
1583 l_exist VARCHAR2(1);
1584
1585 CURSOR c_dflt_source
1586 IS
1587 SELECT e.source_application_id, e.source_type_code, e.source_code,
1588 s.name, l.meaning source_type_dsp
1589 FROM xla_evt_class_acct_attrs e, xla_sources_tl s, xla_lookups l
1590 WHERE e.application_id = p_application_id
1591 AND e.event_class_code = p_event_class_code
1592 AND e.accounting_attribute_code = p_accounting_attribute_code
1593 AND e.default_flag = 'Y'
1594 AND e.source_application_id = s.application_id (+)
1595 AND e.source_type_code = s.source_type_code (+)
1596 AND e.source_code = s.source_code (+)
1597 AND s.language (+) = USERENV('LANG')
1598 AND e.source_type_code = l.lookup_code (+)
1599 AND l.lookup_type (+) = 'XLA_SOURCE_TYPE';
1600
1601 BEGIN
1602
1603 xla_utility_pkg.trace('> xla_line_types_pkg.get_default_attr_assignment' , 10);
1604
1605 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
1606 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
1607
1608 OPEN c_dflt_source;
1609 FETCH c_dflt_source
1610 INTO p_source_application_id, p_source_type_code, p_source_code,
1611 p_source_name, p_source_type_dsp;
1612 IF c_dflt_source%notfound THEN
1613 p_source_application_id := null;
1614 p_source_type_code := null;
1615 p_source_code := null;
1616 p_source_name := null;
1617 p_source_type_dsp := null;
1618
1619 END IF;
1620 CLOSE c_dflt_source;
1621
1622 xla_utility_pkg.trace('< xla_line_types_pkg.get_default_attr_assignment' , 10);
1623
1624 EXCEPTION
1625 WHEN xla_exceptions_pkg.application_exception THEN
1626 RAISE;
1627 WHEN OTHERS THEN
1628 xla_exceptions_pkg.raise_message
1629 (p_location => 'xla_line_types_pkg.get_default_attr_assignment');
1630
1631 END get_default_attr_assignment;
1632
1633 /*======================================================================+
1634 | |
1635 | Private Function |
1636 | |
1637 | Chk_line_accting_sources |
1638 | |
1639 | Returns false if accounting sources at the line level are invalid |
1640 | |
1641 +======================================================================*/
1642 FUNCTION Chk_line_accting_sources
1643 (p_application_id IN NUMBER
1644 ,p_amb_context_code IN VARCHAR2
1645 ,p_entity_code IN VARCHAR2
1646 ,p_event_class_code IN VARCHAR2
1647 ,p_accounting_line_type_code IN VARCHAR2
1648 ,p_accounting_line_code IN VARCHAR2
1649 ,p_message_name IN OUT NOCOPY VARCHAR2
1650 ,p_accounting_attribute_name IN OUT NOCOPY VARCHAR2)
1651 RETURN BOOLEAN
1652 IS
1653
1654 l_return BOOLEAN := TRUE;
1655 l_exist VARCHAR2(1) := null;
1656 l_application_id NUMBER(38) := p_application_id;
1657 l_amb_context_code VARCHAR2(30) := p_amb_context_code;
1658 l_entity_code VARCHAR2(30) := p_entity_code;
1659 l_event_class_code VARCHAR2(30) := p_event_class_code;
1660 l_accounting_line_type_code VARCHAR2(1) := p_accounting_line_type_code;
1661 l_accounting_line_code VARCHAR2(30) := p_accounting_line_code;
1662 l_count NUMBER(38);
1663 l_source_name VARCHAR2(80) := null;
1664 l_source_type VARCHAR2(80) := null;
1665 l_meaning VARCHAR2(80) := null;
1666 l_accounting_attribute_name VARCHAR2(80) := null;
1667 l_business_method_code VARCHAR2(30);
1668
1669 -- Get the business flow method for the JLT
1670 CURSOR c_business_method
1671 IS
1672 SELECT business_method_code
1673 FROM xla_acct_line_types_b
1674 WHERE application_id = p_application_id
1675 AND amb_context_code = p_amb_context_code
1676 AND event_class_code = p_event_class_code
1677 AND accounting_line_type_code = p_accounting_line_type_code
1678 AND accounting_line_code = p_accounting_line_code;
1679
1680 -- Get all mapping groups that have accounting sources mapped for the line type
1681 CURSOR c_mapping_group
1682 IS
1683 SELECT distinct s.assignment_group_code
1684 FROM xla_acct_attributes_b s
1685 WHERE s.assignment_group_code IS NOT NULL
1686 AND EXISTS (SELECT 'x'
1687 FROM xla_jlt_acct_attrs a
1688 WHERE a.application_id = p_application_id
1689 AND a.amb_context_code = p_amb_context_code
1690 AND a.event_class_code = p_event_class_code
1691 AND a.accounting_line_type_code = p_accounting_line_type_code
1692 AND a.accounting_line_code = p_accounting_line_code
1693 AND a.accounting_attribute_code = s.accounting_attribute_code
1694 AND a.source_code IS NOT NULL
1695 UNION
1696 SELECT 'x'
1697 FROM xla_evt_class_acct_attrs_fvl e
1698 WHERE e.application_id = p_application_id
1699 AND e.event_class_code = p_event_class_code
1700 AND e.accounting_attribute_code = s.accounting_attribute_code
1701 AND e.assignment_level_code = 'EVT_CLASS_ONLY'
1702 AND e.default_flag = 'Y');
1703
1704 l_mapping_group c_mapping_group%rowtype;
1705
1706 -- Get all accounting attributes required within the group that are not
1707 -- mapped for the line type
1708 CURSOR c_group_accting_sources
1709 IS
1710 SELECT s.name
1711 FROM xla_acct_attributes_vl s
1712 WHERE assignment_level_code = 'EVT_CLASS_JLT'
1713 AND assignment_required_code = 'G'
1714 AND assignment_group_code = l_mapping_group.assignment_group_code
1715 AND exists (SELECT 'x'
1716 FROM xla_jlt_acct_attrs a
1717 WHERE a.application_id = p_application_id
1718 AND a.amb_context_code = p_amb_context_code
1719 AND a.event_class_code = p_event_class_code
1720 AND a.accounting_line_type_code = p_accounting_line_type_code
1721 AND a.accounting_line_code = p_accounting_line_code
1722 AND a.source_code IS NULL
1723 AND a.accounting_attribute_code = s.accounting_attribute_code);
1724
1725 -- Get all accounting attributes required within the group that are not
1726 -- mapped for the line type and have the inherited flag set to 'N'
1727 CURSOR c_prior_entry
1728 IS
1729 SELECT s.name
1730 FROM xla_acct_attributes_vl s
1731 WHERE assignment_level_code = 'EVT_CLASS_JLT'
1732 AND assignment_required_code = 'G'
1733 AND inherited_flag = 'N'
1734 AND assignment_group_code = l_mapping_group.assignment_group_code
1735 AND exists (SELECT 'x'
1736 FROM xla_jlt_acct_attrs a
1737 WHERE a.application_id = p_application_id
1738 AND a.amb_context_code = p_amb_context_code
1739 AND a.event_class_code = p_event_class_code
1740 AND a.accounting_line_type_code = p_accounting_line_type_code
1741 AND a.accounting_line_code = p_accounting_line_code
1742 AND a.source_code IS NULL
1743 AND a.accounting_attribute_code = s.accounting_attribute_code);
1744
1745 BEGIN
1746
1747 -- Get the business flow method for the JLT
1748 OPEN c_business_method;
1749 FETCH c_business_method
1750 INTO l_business_method_code;
1751 CLOSE c_business_method;
1752
1753 --
1754 -- Check if all or none of group accounting sources identifiers have a mapping
1755 --
1756 OPEN c_mapping_group;
1757 LOOP
1758 FETCH c_mapping_group
1759 INTO l_mapping_group;
1760 EXIT WHEN c_mapping_group%notfound OR l_return = FALSE;
1761
1762 IF l_business_method_code = 'PRIOR_ENTRY' THEN
1763 OPEN c_prior_entry;
1764 FETCH c_prior_entry
1765 INTO l_accounting_attribute_name;
1766 IF c_prior_entry%found THEN
1767 p_message_name := 'XLA_AB_LINE_GRP_ACCT_ATTR';
1768 p_accounting_attribute_name := l_accounting_attribute_name;
1769 l_return := FALSE;
1770 END IF;
1771 CLOSE c_prior_entry;
1772 ELSE
1773 OPEN c_group_accting_sources;
1774 FETCH c_group_accting_sources
1775 INTO l_accounting_attribute_name;
1776 IF c_group_accting_sources%found THEN
1777
1778 p_message_name := 'XLA_AB_LINE_GRP_ACCT_ATTR';
1779 p_accounting_attribute_name := l_accounting_attribute_name;
1780 l_return := FALSE;
1781
1782 END IF;
1783 CLOSE c_group_accting_sources;
1784 END IF;
1785 END LOOP;
1786 CLOSE c_mapping_group;
1787
1788 return l_return;
1789
1790 EXCEPTION
1791 WHEN xla_exceptions_pkg.application_exception THEN
1792 RAISE;
1793
1794 WHEN OTHERS THEN
1795
1796 xla_exceptions_pkg.raise_message
1797 (p_location => 'xla_line_types_pkg.Chk_line_accting_sources');
1798
1799 END Chk_line_accting_sources;
1800
1801 /*======================================================================+
1802 | |
1803 | Public Function |
1804 | |
1805 | check_copy_line_type_details |
1806 | |
1807 | Checks if line type can be copied into a new one |
1808 | |
1809 +======================================================================*/
1810
1811 FUNCTION check_copy_line_type_details
1812 (p_application_id IN NUMBER
1813 ,p_amb_context_code IN VARCHAR2
1814 ,p_entity_code IN VARCHAR2
1815 ,p_event_class_code IN VARCHAR2
1816 ,p_old_accting_line_type_code IN VARCHAR2
1817 ,p_old_accounting_line_code IN VARCHAR2
1818 ,p_old_transaction_coa_id IN NUMBER
1819 ,p_new_transaction_coa_id IN NUMBER
1820 ,p_message IN OUT NOCOPY VARCHAR2
1821 ,p_token_1 IN OUT NOCOPY VARCHAR2
1822 ,p_value_1 IN OUT NOCOPY VARCHAR2)
1823 RETURN BOOLEAN
1824
1825 IS
1826
1827 l_condition_id integer;
1828 l_creation_date DATE := sysdate;
1829 l_last_update_date DATE := sysdate;
1830 l_created_by INTEGER := xla_environment_pkg.g_usr_id;
1831 l_last_update_login INTEGER := xla_environment_pkg.g_login_id;
1832 l_last_updated_by INTEGER := xla_environment_pkg.g_usr_id;
1833 l_con_flexfield_segment_code VARCHAR2(30);
1834 l_con_flexfield_segment_name VARCHAR2(80);
1835 l_con_v_flexfield_segment_code VARCHAR2(30);
1836 l_con_v_flexfield_segment_name VARCHAR2(80);
1837 l_source_flex_appl_id NUMBER(15);
1838 l_source_id_flex_code VARCHAR2(30);
1839 l_value_source_flex_appl_id NUMBER(15);
1840 l_value_source_id_flex_code VARCHAR2(30);
1841 l_return BOOLEAN := TRUE;
1842
1843 CURSOR c_conditions
1844 IS
1845 SELECT user_sequence, bracket_left_code, bracket_right_code, value_type_code,
1846 source_application_id, source_type_code, source_code,
1847 flexfield_segment_code, value_flexfield_segment_code,
1848 value_source_application_id, value_source_type_code,
1849 value_source_code, value_constant, line_operator_code,
1850 logical_operator_code, independent_value_constant
1851 FROM xla_conditions
1852 WHERE application_id = p_application_id
1853 AND amb_context_code = p_amb_context_code
1854 AND entity_code = p_entity_code
1855 AND event_class_code = p_event_class_code
1856 AND accounting_line_type_code = p_old_accting_line_type_code
1857 AND accounting_line_code = p_old_accounting_line_code;
1858
1859 l_condition c_conditions%rowtype;
1860
1861 CURSOR c_source
1862 IS
1863 SELECT flexfield_application_id, id_flex_code
1864 FROM xla_sources_b
1865 WHERE application_id = l_condition.source_application_id
1866 AND source_type_code = l_condition.source_type_code
1867 AND source_code = l_condition.source_code;
1868
1869 CURSOR c_value_source
1870 IS
1871 SELECT flexfield_application_id, id_flex_code
1872 FROM xla_sources_b
1873 WHERE application_id = l_condition.value_source_application_id
1874 AND source_type_code = l_condition.value_source_type_code
1875 AND source_code = l_condition.value_source_code;
1876
1877 BEGIN
1878
1879 xla_utility_pkg.trace('> xla_line_types_pkg.check_copy_line_type_details' , 10);
1880
1881 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
1882 xla_utility_pkg.trace('entity_code = '||p_entity_code , 20);
1883 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
1884 xla_utility_pkg.trace('old_accounting_line_type_code = '||p_old_accting_line_type_code , 20);
1885 xla_utility_pkg.trace('old_accounting_line_code = '||p_old_accounting_line_code , 20);
1886
1887 OPEN c_conditions;
1888 LOOP
1889 FETCH c_conditions
1890 INTO l_condition;
1891 EXIT WHEN c_conditions%notfound or l_return = FALSE;
1892
1893 IF l_condition.flexfield_segment_code is not null THEN
1894
1895 OPEN c_source;
1896 FETCH c_source
1897 INTO l_source_flex_appl_id, l_source_id_flex_code;
1898 CLOSE c_source;
1899
1900 IF l_source_flex_appl_id = 101 and l_source_id_flex_code = 'GL#' THEN
1901
1902 IF p_new_transaction_coa_id is not null and p_old_transaction_coa_id is null THEN
1903 l_con_flexfield_segment_code := xla_flex_pkg.get_qualifier_segment
1904 (p_application_id => 101
1905 ,p_id_flex_code => 'GL#'
1906 ,p_id_flex_num => p_new_transaction_coa_id
1907 ,p_qualifier_segment => l_condition.flexfield_segment_code);
1908
1909 IF l_con_flexfield_segment_code is null THEN
1910 l_con_flexfield_segment_name := xla_flex_pkg.get_qualifier_name
1911 (p_application_id => 101
1912 ,p_id_flex_code => 'GL#'
1913 ,p_qualifier_segment => l_condition.flexfield_segment_code);
1914
1915 p_message := 'XLA_AB_TRX_COA_NO_QUAL';
1916 p_token_1 := 'QUALIFIER_NAME';
1917 p_value_1 := l_con_flexfield_segment_name;
1918 l_return := FALSE;
1919
1920 END IF;
1921 END IF;
1922 END IF;
1923 END IF;
1924
1925 IF l_return = TRUE THEN
1926 -- check value_flexfield_segment_code
1927 IF l_condition.value_flexfield_segment_code is not null THEN
1928
1929 OPEN c_value_source;
1930 FETCH c_value_source
1931 INTO l_value_source_flex_appl_id, l_value_source_id_flex_code;
1932 CLOSE c_value_source;
1933
1934 IF l_value_source_flex_appl_id = 101 and l_value_source_id_flex_code = 'GL#' THEN
1935
1936 IF p_new_transaction_coa_id is not null and p_old_transaction_coa_id is null THEN
1937 l_con_v_flexfield_segment_code := xla_flex_pkg.get_qualifier_segment
1938 (p_application_id => 101
1939 ,p_id_flex_code => 'GL#'
1940 ,p_id_flex_num => p_new_transaction_coa_id
1941 ,p_qualifier_segment => l_condition.value_flexfield_segment_code);
1942
1943 IF l_con_v_flexfield_segment_code is null THEN
1944 l_con_v_flexfield_segment_name := xla_flex_pkg.get_qualifier_name
1945 (p_application_id => 101
1946 ,p_id_flex_code => 'GL#'
1947 ,p_qualifier_segment => l_condition.value_flexfield_segment_code);
1948
1949 p_message := 'XLA_AB_TRX_COA_NO_QUAL';
1950 p_token_1 := 'QUALIFIER_NAME';
1951 p_value_1 := l_con_v_flexfield_segment_name;
1952 l_return := FALSE;
1953
1954 END IF;
1955 END IF;
1956 END IF;
1957 END IF;
1958 END IF;
1959 END LOOP;
1960 CLOSE c_conditions;
1961
1962 xla_utility_pkg.trace('< xla_line_types_pkg.check_copy_line_type_details' , 10);
1963
1964 RETURN l_return;
1965
1966 EXCEPTION
1967 WHEN xla_exceptions_pkg.application_exception THEN
1968 IF c_conditions%ISOPEN THEN
1969 CLOSE c_conditions;
1970 END IF;
1971 RAISE;
1972 WHEN OTHERS THEN
1973 IF c_conditions%ISOPEN THEN
1974 CLOSE c_conditions;
1975 END IF;
1976 xla_exceptions_pkg.raise_message
1977 (p_location => 'xla_line_types_pkg.check_copy_line_type_details');
1978
1979 END check_copy_line_type_details;
1980
1981 /*======================================================================+
1982 | |
1983 | Public Procedure |
1984 | |
1985 | update_acct_attrs |
1986 | |
1987 | Updates accounting attributes for the line type |
1988 | |
1989 +======================================================================*/
1990
1991 PROCEDURE update_acct_attrs(
1992 p_application_id IN NUMBER
1993 ,p_amb_context_code IN VARCHAR2
1994 ,p_event_class_code IN VARCHAR2
1995 ,p_accounting_line_type_code IN VARCHAR2
1996 ,p_accounting_line_code IN VARCHAR2
1997 ,p_business_method_code IN VARCHAR2)
1998 IS
1999
2000 -- Array Declaration
2001 l_arr_acct_attribute_code t_array_codes;
2002 l_arr_source_application_id t_array_id;
2003 l_arr_source_type_code t_array_codes;
2004 l_arr_source_code t_array_codes;
2005
2006 l_arr_p_acct_attribute_code t_array_codes;
2007 l_arr_p_source_application_id t_array_id;
2008 l_arr_p_source_type_code t_array_codes;
2009 l_arr_p_source_code t_array_codes;
2010
2011 -- Local Variables
2012 l_exist VARCHAR2(1);
2013
2014
2015 CURSOR c_prior_entry
2016 IS
2017 SELECT e.accounting_attribute_code
2018 FROM xla_evt_class_acct_attrs e, xla_acct_attributes_b l
2019 WHERE e.application_id = p_application_id
2020 AND e.event_class_code = p_event_class_code
2021 AND e.default_flag = 'Y'
2022 AND e.accounting_attribute_code = l.accounting_attribute_code
2023 AND l.assignment_level_code = 'EVT_CLASS_JLT'
2024 AND l.inherited_flag = 'Y';
2025
2026 CURSOR c_non_prior_entry
2027 IS
2028 SELECT e.accounting_attribute_code, e.source_application_id,
2029 e.source_type_code, e.source_code
2030 FROM xla_evt_class_acct_attrs e, xla_acct_attributes_b l
2031 WHERE e.application_id = p_application_id
2032 AND e.event_class_code = p_event_class_code
2033 AND e.default_flag = 'Y'
2034 AND e.accounting_attribute_code = l.accounting_attribute_code
2035 AND l.assignment_level_code = 'EVT_CLASS_JLT'
2036 AND l.inherited_flag = 'Y';
2037
2038 BEGIN
2039
2040 xla_utility_pkg.trace('> xla_line_types_pkg.update_acct_attrs' , 10);
2041
2042 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
2043 xla_utility_pkg.trace('event_class_code = '||p_event_class_code , 20);
2044 xla_utility_pkg.trace('accounting_line_type_code = '||p_accounting_line_type_code , 20);
2045 xla_utility_pkg.trace('accounting_line_code = '||p_accounting_line_code , 20);
2046
2047 IF p_business_method_code = 'PRIOR_ENTRY' THEN
2048 -- Update the inherited accounting attributes to null source mapping
2049
2050 OPEN c_prior_entry;
2051 FETCH c_prior_entry
2052 BULK COLLECT INTO l_arr_p_acct_attribute_code;
2053
2054 IF l_arr_p_acct_attribute_code.COUNT > 0 THEN
2055 FORALL i IN l_arr_p_acct_attribute_code.FIRST..l_arr_p_acct_attribute_code.LAST
2056
2057 UPDATE xla_jlt_acct_attrs
2058 SET source_application_id = null
2059 ,source_type_code = null
2060 ,source_code = null
2061 WHERE application_id = p_application_id
2062 AND amb_context_code = p_amb_context_code
2063 AND event_class_code = p_event_class_code
2064 AND accounting_line_type_code = p_accounting_line_type_code
2065 AND accounting_line_code = p_accounting_line_code
2066 AND accounting_attribute_code = l_arr_p_acct_attribute_code(i);
2067 END IF;
2068 CLOSE c_prior_entry;
2069 -- Not a prior entry jlt
2070 ELSE
2071
2072 -- Update the default source mappings on the JLT for the accounting attributes
2073 -- whose inherited flag is 'Y'
2074 OPEN c_non_prior_entry;
2075 FETCH c_non_prior_entry
2076 BULK COLLECT INTO l_arr_acct_attribute_code, l_arr_source_application_id,
2077 l_arr_source_type_code, l_arr_source_code;
2078
2079 IF l_arr_acct_attribute_code.COUNT > 0 THEN
2080 FORALL i IN l_arr_acct_attribute_code.FIRST..l_arr_acct_attribute_code.LAST
2081
2082 UPDATE xla_jlt_acct_attrs
2083 SET source_application_id = l_arr_source_application_id(i)
2084 ,source_type_code = l_arr_source_type_code(i)
2085 ,source_code = l_arr_source_code(i)
2086 ,event_class_default_flag = 'Y'
2087 WHERE application_id = p_application_id
2088 AND amb_context_code = p_amb_context_code
2089 AND event_class_code = p_event_class_code
2090 AND accounting_line_type_code = p_accounting_line_type_code
2091 AND accounting_line_code = p_accounting_line_code
2092 AND accounting_attribute_code = l_arr_acct_attribute_code(i);
2093 END IF;
2094 CLOSE c_non_prior_entry;
2095 END IF;
2096
2097 xla_utility_pkg.trace('< xla_line_types_pkg.update_acct_attrs' , 10);
2098
2099 EXCEPTION
2100 WHEN xla_exceptions_pkg.application_exception THEN
2101 RAISE;
2102 WHEN OTHERS THEN
2103 xla_exceptions_pkg.raise_message
2104 (p_location => 'xla_line_types_pkg.update_acct_attrs');
2105
2106 END update_acct_attrs;
2107
2108 /*======================================================================+
2109 | |
2110 | Public Function |
2111 | |
2112 | mpa_line_type_in_use |
2113 | |
2114 | Returns true if the line is in used by a JLD |
2115 | |
2116 +======================================================================*/
2117
2118 FUNCTION mpa_line_type_in_use
2119 (p_application_id IN NUMBER
2120 ,p_amb_context_code IN VARCHAR2
2121 ,p_event_class_code IN VARCHAR2
2122 ,p_accounting_line_type_code IN VARCHAR2
2123 ,p_accounting_line_code IN VARCHAR2
2124 ,x_mpa_option_code IN OUT NOCOPY VARCHAR2
2125 ,x_line_definition_name IN OUT NOCOPY VARCHAR2
2126 ,x_line_definition_owner IN OUT NOCOPY VARCHAR2)
2127 RETURN BOOLEAN
2128 IS
2129
2130 l_return BOOLEAN;
2131 l_exist VARCHAR2(1);
2132 l_mpa_option_code VARCHAR2(30);
2133
2134 CURSOR c_mpa_option_code
2135 IS
2136 SELECT mpa_option_code
2137 FROM xla_acct_line_types_b
2138 WHERE application_id = p_application_id
2139 AND amb_context_code = p_amb_context_code
2140 AND event_class_code = p_event_class_code
2141 AND accounting_line_type_code = p_accounting_line_type_code
2142 AND accounting_line_code = p_accounting_line_code;
2143
2144 CURSOR c_assignment_exist
2145 IS
2146 SELECT event_type_code, line_definition_owner_code, line_definition_code
2147 FROM xla_line_defn_jlt_assgns
2148 WHERE application_id = p_application_id
2149 AND amb_context_code = p_amb_context_code
2150 AND event_class_code = p_event_class_code
2151 AND accounting_line_type_code = p_accounting_line_type_code
2152 AND accounting_line_code = p_accounting_line_code;
2153
2154 l_assignment_exist c_assignment_exist%rowtype;
2155
2156 CURSOR c_mpa_assignment_exist
2157 IS
2158 SELECT event_type_code, line_definition_owner_code, line_definition_code,
2159 accounting_line_type_code, accounting_line_code
2160 FROM xla_mpa_jlt_assgns
2161 WHERE application_id = p_application_id
2162 AND amb_context_code = p_amb_context_code
2163 AND event_class_code = p_event_class_code
2164 AND mpa_accounting_line_type_code = p_accounting_line_type_code
2165 AND mpa_accounting_line_code = p_accounting_line_code;
2166
2167 l_mpa_assignment_exist c_mpa_assignment_exist%rowtype;
2168
2169 BEGIN
2170
2171 xla_utility_pkg.trace('> xla_line_types_pkg.mpa_line_type_in_use' , 10);
2172
2173 OPEN c_mpa_option_code;
2174 FETCH c_mpa_option_code
2175 INTO l_mpa_option_code;
2176 CLOSE c_mpa_option_code;
2177
2178 IF l_mpa_option_code = 'ACCRUAL' THEN
2179 OPEN c_assignment_exist;
2180 FETCH c_assignment_exist
2181 INTO l_assignment_exist;
2182 IF c_assignment_exist%found then
2183
2184 xla_line_definitions_pvt.get_line_definition_info
2185 (p_application_id => p_application_id
2186 ,p_amb_context_code => p_amb_context_code
2187 ,p_event_class_code => p_event_class_code
2188 ,p_event_type_code => l_assignment_exist.event_type_code
2189 ,p_line_definition_owner_code => l_assignment_exist.line_definition_owner_code
2190 ,p_line_definition_code => l_assignment_exist.line_definition_code
2191 ,x_line_definition_owner => x_line_definition_owner
2192 ,x_line_definition_name => x_line_definition_name);
2193
2194 l_return := TRUE;
2195 ELSE
2196 l_return := FALSE;
2197 END IF;
2198 CLOSE c_assignment_exist;
2199
2200 ELSIF l_mpa_option_code = 'RECOGNITION' THEN
2201 OPEN c_mpa_assignment_exist;
2202 FETCH c_mpa_assignment_exist
2203 INTO l_mpa_assignment_exist;
2204 IF c_mpa_assignment_exist%found then
2205
2206 xla_line_definitions_pvt.get_line_definition_info
2207 (p_application_id => p_application_id
2208 ,p_amb_context_code => p_amb_context_code
2209 ,p_event_class_code => p_event_class_code
2210 ,p_event_type_code => l_mpa_assignment_exist.event_type_code
2211 ,p_line_definition_owner_code => l_mpa_assignment_exist.line_definition_owner_code
2212 ,p_line_definition_code => l_mpa_assignment_exist.line_definition_code
2213 ,x_line_definition_owner => x_line_definition_owner
2214 ,x_line_definition_name => x_line_definition_name);
2215
2216 l_return := TRUE;
2217 ELSE
2218 l_return := FALSE;
2219 END IF;
2220 CLOSE c_mpa_assignment_exist;
2221
2222 END IF;
2223
2224 xla_utility_pkg.trace('< xla_line_types_pkg.mpa_line_type_in_use' , 10);
2225 x_mpa_option_code := l_mpa_option_code;
2226
2227 return l_return;
2228
2229 EXCEPTION
2230 WHEN xla_exceptions_pkg.application_exception THEN
2231 IF c_assignment_exist%ISOPEN THEN
2232 CLOSE c_assignment_exist;
2233 END IF;
2234
2235 RAISE;
2236 WHEN OTHERS THEN
2237 IF c_assignment_exist%ISOPEN THEN
2238 CLOSE c_assignment_exist;
2239 END IF;
2240
2241 xla_exceptions_pkg.raise_message
2242 (p_location => 'xla_line_types_pkg.mpa_line_type_in_use');
2243
2244 END mpa_line_type_in_use;
2245
2246 END xla_line_types_pkg;