[Home] [Help]
PACKAGE BODY: APPS.XLA_00240_AAD_S_000003_PKG
Source
1 PACKAGE BODY XLA_00240_AAD_S_000003_PKG AS
2 --
3 /*======================================================================+
4 | Copyright (c) 1997 Oracle Corporation |
5 | Redwood Shores, CA, USA |
6 | All rights reserved. |
7 +=======================================================================+
8 | Package Name |
9 | XLA_00240_AAD_S_000003_PKG |
10 | |
11 | DESCRIPTION |
12 | Package generated From Product Accounting Definition |
13 | Name : Property Manager Normalized Accounting |
14 | Code : PN_LEASE_ACCOUNTING |
15 | Owner : PRODUCT |
16 | Version : |
17 | AMB Context Code: DEFAULT |
18 | HISTORY |
19 | Generated at 30-03-2009 at 06:03:21 by user ANONYMOUS |
20 +=======================================================================*/
21 --
22 --
23 TYPE t_rec_array_event IS RECORD
24 (array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
25 ,array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
26 ,array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
27 ,array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
28 ,array_event_id xla_number_array_type --XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
29 ,array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
30 ,array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
31 ,array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
32 ,array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
33 ,array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
34 ,array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
35 ,array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
36 ,array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
37 ,array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
38 ,array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
39 ,array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
40 ,array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
41 ,array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
42 ,array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
43 ,array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
44 ,array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
45 ,array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L
46 );
47 --
48 type t_array_value_num is table of number index by varchar2(30);
49 type t_array_value_char is table of varchar2(240) index by varchar2(30);
50 type t_array_value_date is table of date index by varchar2(30);
51
52 type t_rec_value is record
53 (array_value_num t_array_value_num
54 ,array_value_char t_array_value_char
55 ,array_value_date t_array_value_date);
56
57 type t_array_event is table of t_rec_value index by binary_integer;
58
59 g_array_event t_array_event;
60
61 --=============================================================================
62 -- *********** Diagnostics **********
63 --=============================================================================
64
65 g_diagnostics_mode VARCHAR2(1);
66 g_last_hdr_idx NUMBER; -- 4262811 MPA
67 g_hdr_extract_count PLS_INTEGER;
68
69 --=============================================================================
70 -- *********** Local Trace Routine **********
71 --=============================================================================
72
73 C_LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
74 C_LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
75 C_LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
76 C_LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
77 C_LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
78 C_LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
79
80 C_LEVEL_LOG_DISABLED CONSTANT NUMBER := 99;
81 C_DEFAULT_MODULE CONSTANT VARCHAR2(240) := 'xla.plsql.XLA_00240_AAD_S_000003_PKG';
82
83 C_CHAR CONSTANT VARCHAR2(30) := fnd_global.local_chr(12); -- 4219869 Business flow
84 C_NUM CONSTANT NUMBER := 9.99E125; -- 4219869 Business flow
85
86 g_log_level NUMBER;
87 g_log_enabled BOOLEAN;
88
89 PROCEDURE trace
90 (p_msg IN VARCHAR2
91 ,p_level IN NUMBER
92 ,p_module IN VARCHAR2 ) IS
93 BEGIN
94 ----------------------------------------------------------------------------
95 -- Following is for FND log.
96 ----------------------------------------------------------------------------
97 IF (p_msg IS NULL AND p_level >= g_log_level) THEN
98 fnd_log.message(p_level, p_module);
99 ELSIF p_level >= g_log_level THEN
100 fnd_log.string(p_level, p_module, p_msg);
101 END IF;
102
103 EXCEPTION
104 WHEN xla_exceptions_pkg.application_exception THEN
105 RAISE;
106 WHEN OTHERS THEN
107 xla_exceptions_pkg.raise_message
108 (p_location => 'XLA_00240_AAD_S_000003_PKG.trace');
109 END trace;
110
111 --
112 --+============================================+
113 --| |
114 --| PRIVATE PROCEDURES/FUNCTIONS |
115 --| |
116 --+============================================+
117 --
118
119 --
120 /*======================================================================+
121 | |
122 | Private Function |
123 | ValidateLookupMeaning |
124 | |
125 +======================================================================*/
126 FUNCTION ValidateLookupMeaning(
127 p_meaning IN VARCHAR2
128 , p_lookup_code IN VARCHAR2
129 , p_lookup_type IN VARCHAR2
130 , p_source_code IN VARCHAR2
131 , p_source_type_code IN VARCHAR2
132 , p_source_application_id IN INTEGER
133 )
134 RETURN VARCHAR2
135 IS
136 l_log_module VARCHAR2(240);
137 BEGIN
138 IF g_log_enabled THEN
139 l_log_module := C_DEFAULT_MODULE||'.ValidateLookupMeaning';
140 END IF;
141 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
142 trace
143 (p_msg => 'BEGIN of ValidateLookupMeaning'
144 ,p_level => C_LEVEL_PROCEDURE
145 ,p_module => l_log_module);
146 END IF;
147 --
148 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
149 trace
150 (p_msg => 'p_source_code = '|| p_source_code||
151 ' - p_source_type_code = '|| p_source_type_code||
152 ' - p_source_application_id = '|| p_source_application_id||
153 ' - p_lookup_code = '|| p_lookup_code||
154 ' - p_lookup_type = '|| p_lookup_type||
155 ' - p_meaning = '|| p_meaning
156 ,p_level => C_LEVEL_PROCEDURE
157 ,p_module => l_log_module);
158
159 END IF;
160
161 IF p_lookup_code IS NOT NULL AND p_meaning IS NULL THEN
162 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
163 xla_accounting_err_pkg. build_message
164 (p_appli_s_name => 'XLA'
165 ,p_msg_name => 'XLA_AP_NO_LOOKUP_MEANING'
166 ,p_token_1 => 'SOURCE_NAME'
167 ,p_value_1 => xla_ae_sources_pkg.GetSourceName(
168 p_source_code
169 , p_source_type_code
170 , p_source_application_id
171 )
172 ,p_token_2 => 'LOOKUP_CODE'
173 ,p_value_2 => p_lookup_code
174 ,p_token_3 => 'LOOKUP_TYPE'
175 ,p_value_3 => p_lookup_type
176 ,p_token_4 => 'PRODUCT_NAME'
177 ,p_value_4 => xla_ae_journal_entry_pkg.g_cache_event.application_name
178 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
179 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
180 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
181 );
182
183 IF (C_LEVEL_ERROR >= g_log_level) THEN
184 trace
185 (p_msg => 'ERROR: XLA_AP_NO_LOOKUP_MEANING'
186 ,p_level => C_LEVEL_ERROR
187 ,p_module => l_log_module);
188 END IF;
189 END IF;
190
191 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
192 trace
193 (p_msg => 'END of ValidateLookupMeaning'
194 ,p_level => C_LEVEL_PROCEDURE
195 ,p_module => l_log_module);
196 END IF;
197 RETURN p_meaning;
198 EXCEPTION
199 WHEN xla_exceptions_pkg.application_exception THEN
200 RETURN p_meaning;
201 WHEN OTHERS THEN
202 xla_exceptions_pkg.raise_message
203 (p_location => 'XLA_00240_AAD_S_000003_PKG.ValidateLookupMeaning');
204 --
205 END ValidateLookupMeaning;
206 --
207 --
208
209 FUNCTION GetMeaning (
210 p_flex_value_set_id IN INTEGER
211 , p_flex_value IN VARCHAR2
212 , p_source_code IN VARCHAR2
213 , p_source_type_code IN VARCHAR2
214 , p_source_application_id IN INTEGER
215 )
216 RETURN VARCHAR2
217 IS
218 BEGIN
219 --
220 RETURN NULL ;
221 --
222 EXCEPTION
223 WHEN xla_exceptions_pkg.application_exception THEN
224 RAISE;
225 WHEN OTHERS THEN
226 xla_exceptions_pkg.raise_message
227 (p_location => 'XLA_00240_AAD_S_000003_PKG.GetMeaning');
228 END GetMeaning;
229 --
230
231 ---------------------------------------
232 --
233 -- PRIVATE FUNCTION
234 -- Description_1
235 --
236 ---------------------------------------
237 FUNCTION Description_1 (
238 p_application_id IN NUMBER
239 , p_ae_header_id IN NUMBER DEFAULT NULL
240 --Supplier Name
241 , p_source_1 IN VARCHAR2
242 --Supplier Site
243 , p_source_2 IN VARCHAR2
244 --Payment / Billing Purpose
245 , p_source_3 IN VARCHAR2
246 --Payment / BillingType
247 , p_source_4 IN VARCHAR2
248 --Location Code
249 , p_source_5 IN VARCHAR2
250 --Lease Number
251 , p_source_6 IN VARCHAR2
252 --Property Code
253 , p_source_7 IN VARCHAR2
254 )
255 RETURN VARCHAR2
256 IS
257 l_component_type VARCHAR2(80) ;
258 l_component_code VARCHAR2(30) ;
259 l_component_type_code VARCHAR2(1) ;
260 l_component_appl_id INTEGER ;
261 l_amb_context_code VARCHAR2(30) ;
262 l_ledger_language VARCHAR2(30) ;
263 l_source VARCHAR2(1996) ;
264 l_description VARCHAR2(2000) ;
265 l_log_module VARCHAR2(240) ;
266 BEGIN
267 IF g_log_enabled THEN
268 l_log_module := C_DEFAULT_MODULE||'.Description_1';
269 END IF;
270 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
271 trace
272 (p_msg => 'BEGIN of Description_1'
273 ,p_level => C_LEVEL_PROCEDURE
274 ,p_module => l_log_module);
275 END IF;
276
277 l_ledger_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
278 l_component_type := 'AMB_DESCRIPTION';
279 l_component_code := 'PN_EXPENSE_DESCRIPTION';
280 l_component_type_code := 'S';
281 l_component_appl_id := 240;
282 l_amb_context_code := 'DEFAULT';
283 l_source := NULL;
284 l_description := NULL;
285
286
287
288 l_source := SUBSTR(p_source_1,1,1996);
289 IF l_source IS NOT NULL THEN
290 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
291 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
292 END IF;
293 l_source := SUBSTR(p_source_2,1,1996);
294 IF l_source IS NOT NULL THEN
295 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
296 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
297 END IF;
298 l_source := SUBSTR(p_source_3,1,1996);
299 IF l_source IS NOT NULL THEN
300 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
301 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
302 END IF;
303 l_source := SUBSTR(p_source_4,1,1996);
304 IF l_source IS NOT NULL THEN
305 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
306 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
307 END IF;
308 l_source := SUBSTR(p_source_5,1,1996);
309 IF l_source IS NOT NULL THEN
310 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
311 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
312 END IF;
313 l_source := SUBSTR(p_source_6,1,1996);
314 IF l_source IS NOT NULL THEN
315 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
316 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
317 END IF;
318 l_source := SUBSTR(p_source_7,1,1996);
319 IF l_source IS NOT NULL THEN
320 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
321 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
322 END IF;
323 l_description := SUBSTR(l_description,1,1996);
324 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
325 trace
326 (p_msg => 'END of Description_1'
327 ,p_level => C_LEVEL_PROCEDURE
328 ,p_module => l_log_module);
329
330 END IF;
331 RETURN l_description;
332
333 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
334 trace
335 (p_msg => 'END of Description_1'
336 ,p_level => C_LEVEL_PROCEDURE
337 ,p_module => l_log_module);
338 END IF;
339 RETURN NULL;
340 EXCEPTION
341 WHEN VALUE_ERROR THEN
342 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
343 trace
344 (p_msg => 'ERROR: '||sqlerrm
345 ,p_level => C_LEVEL_EXCEPTION
346 ,p_module => l_log_module);
347 END IF;
348 RAISE;
349 WHEN xla_exceptions_pkg.application_exception THEN
350 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
351 trace
352 (p_msg => 'ERROR: '||sqlerrm
353 ,p_level => C_LEVEL_EXCEPTION
354 ,p_module => l_log_module);
355 END IF;
356 RAISE;
357 WHEN OTHERS THEN
358 xla_exceptions_pkg.raise_message
359 (p_location => 'XLA_00240_AAD_S_000003_PKG.Description_1');
360 END Description_1;
361
362 ---------------------------------------
363 --
364 -- PRIVATE FUNCTION
368 FUNCTION Description_2 (
365 -- Description_2
366 --
367 ---------------------------------------
369 p_application_id IN NUMBER
370 , p_ae_header_id IN NUMBER DEFAULT NULL
371 --Payment / Billing Purpose
372 , p_source_3 IN VARCHAR2
373 --Payment / BillingType
374 , p_source_4 IN VARCHAR2
375 --Location Code
376 , p_source_5 IN VARCHAR2
377 --Lease Number
378 , p_source_6 IN VARCHAR2
379 --Property Code
380 , p_source_7 IN VARCHAR2
381 --Customer Name
382 , p_source_8 IN VARCHAR2
383 --Customer Site
384 , p_source_9 IN VARCHAR2
385 )
386 RETURN VARCHAR2
387 IS
388 l_component_type VARCHAR2(80) ;
389 l_component_code VARCHAR2(30) ;
390 l_component_type_code VARCHAR2(1) ;
391 l_component_appl_id INTEGER ;
392 l_amb_context_code VARCHAR2(30) ;
393 l_ledger_language VARCHAR2(30) ;
394 l_source VARCHAR2(1996) ;
395 l_description VARCHAR2(2000) ;
396 l_log_module VARCHAR2(240) ;
397 BEGIN
398 IF g_log_enabled THEN
399 l_log_module := C_DEFAULT_MODULE||'.Description_2';
400 END IF;
401 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
402 trace
403 (p_msg => 'BEGIN of Description_2'
404 ,p_level => C_LEVEL_PROCEDURE
405 ,p_module => l_log_module);
406 END IF;
407
408 l_ledger_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
409 l_component_type := 'AMB_DESCRIPTION';
410 l_component_code := 'PN_REVENUE_DESCRIPTION';
411 l_component_type_code := 'S';
412 l_component_appl_id := 240;
413 l_amb_context_code := 'DEFAULT';
414 l_source := NULL;
415 l_description := NULL;
416
417
418
419 l_source := SUBSTR(p_source_8,1,1996);
420 IF l_source IS NOT NULL THEN
421 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
422 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
423 END IF;
424 l_source := SUBSTR(p_source_9,1,1996);
425 IF l_source IS NOT NULL THEN
426 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
427 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
428 END IF;
429 l_source := SUBSTR(p_source_3,1,1996);
430 IF l_source IS NOT NULL THEN
431 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
432 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
433 END IF;
434 l_source := SUBSTR(p_source_4,1,1996);
435 IF l_source IS NOT NULL THEN
436 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
437 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
438 END IF;
439 l_source := SUBSTR(p_source_5,1,1996);
440 IF l_source IS NOT NULL THEN
441 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
442 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
443 END IF;
444 l_source := SUBSTR(p_source_6,1,1996);
445 IF l_source IS NOT NULL THEN
446 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
447 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
448 END IF;
449 l_source := SUBSTR(p_source_7,1,1996);
450 IF l_source IS NOT NULL THEN
451 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
452 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
453 END IF;
454 l_description := SUBSTR(l_description,1,1996);
455 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
456 trace
457 (p_msg => 'END of Description_2'
458 ,p_level => C_LEVEL_PROCEDURE
459 ,p_module => l_log_module);
460
461 END IF;
462 RETURN l_description;
463
464 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
465 trace
466 (p_msg => 'END of Description_2'
467 ,p_level => C_LEVEL_PROCEDURE
468 ,p_module => l_log_module);
469 END IF;
470 RETURN NULL;
471 EXCEPTION
472 WHEN VALUE_ERROR THEN
473 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
474 trace
475 (p_msg => 'ERROR: '||sqlerrm
476 ,p_level => C_LEVEL_EXCEPTION
477 ,p_module => l_log_module);
478 END IF;
479 RAISE;
480 WHEN xla_exceptions_pkg.application_exception THEN
481 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
482 trace
483 (p_msg => 'ERROR: '||sqlerrm
484 ,p_level => C_LEVEL_EXCEPTION
485 ,p_module => l_log_module);
486 END IF;
487 RAISE;
488 WHEN OTHERS THEN
489 xla_exceptions_pkg.raise_message
490 (p_location => 'XLA_00240_AAD_S_000003_PKG.Description_2');
491 END Description_2;
492
493 ---------------------------------------
494 --
495 -- PRIVATE FUNCTION
496 -- AcctDerRule_3
497 --
498 ---------------------------------------
499 FUNCTION AcctDerRule_3 (
500 p_application_id IN NUMBER
501 , p_ae_header_id IN NUMBER
502 , p_side IN VARCHAR2
503 --Code Combination Identifier
504 , p_source_10 IN NUMBER
505 , x_transaction_coa_id OUT NOCOPY NUMBER
509 RETURN NUMBER
506 , x_accounting_coa_id OUT NOCOPY NUMBER
507 , x_value_type_code OUT NOCOPY VARCHAR2
508 )
510 IS
511 l_component_type VARCHAR2(80) ;
512 l_component_code VARCHAR2(30) ;
513 l_component_type_code VARCHAR2(1) ;
514 l_component_appl_id INTEGER ;
515 l_amb_context_code VARCHAR2(30) ;
516 l_log_module VARCHAR2(240) ;
517 l_output_value NUMBER ;
518 BEGIN
519 IF g_log_enabled THEN
520 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_3';
521 END IF;
522 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
523 trace
524 (p_msg => 'BEGIN of AcctDerRule_3'
525 ,p_level => C_LEVEL_PROCEDURE
526 ,p_module => l_log_module);
527 END IF;
528 --
529 l_component_type := 'AMB_ADR';
530 l_component_code := 'PN_STANDARD';
531 l_component_type_code := 'S';
532 l_component_appl_id := 240;
533 l_amb_context_code := 'DEFAULT';
534 x_transaction_coa_id := null;
535 x_accounting_coa_id := null;
536 --
537
538 --
539 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
540 trace
541 (p_msg => 'END of AcctDerRule_3'
542 ,p_level => C_LEVEL_PROCEDURE
543 ,p_module => l_log_module);
544 END IF;
545 x_value_type_code := 'S';
546 l_output_value := TO_NUMBER(TO_NUMBER(p_source_10));
547 RETURN l_output_value;
548
549 --
550 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
551 trace
552 (p_msg => 'END of AcctDerRule_3(invalid)'
553 ,p_level => C_LEVEL_PROCEDURE
554 ,p_module => l_log_module);
555 END IF;
556 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
557 x_value_type_code := null;
558 l_output_value := null;
559 xla_accounting_err_pkg.build_message
560 (p_appli_s_name => 'XLA'
561 ,p_msg_name => 'XLA_AP_INVALID_ADR'
562 ,p_token_1 => 'COMPONENT_NAME'
563 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
564 l_component_type
565 , l_component_code
566 , l_component_type_code
567 , l_component_appl_id
568 , l_amb_context_code
569 )
570 ,p_token_2 => 'OWNER'
571 ,p_value_2 => xla_lookups_pkg.get_meaning(
572 'XLA_OWNER_TYPE'
573 ,l_component_type_code
574 )
575 ,p_token_3 => 'PAD_NAME'
576 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
577 ,p_token_4 => 'PAD_OWNER'
578 ,p_value_4 => xla_lookups_pkg.get_meaning(
579 'XLA_OWNER_TYPE'
580 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
581 )
582 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
583 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
584 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
585 ,p_ae_header_id => NULL
586 );
587 RETURN l_output_value;
588 EXCEPTION
589 WHEN xla_exceptions_pkg.application_exception THEN
590 RAISE;
591 WHEN OTHERS THEN
592 xla_exceptions_pkg.raise_message
593 (p_location => 'XLA_00240_AAD_S_000003_PKG.AcctDerRule_3');
594 END AcctDerRule_3;
595 --
596
597 ---------------------------------------
598 --
599 -- PRIVATE FUNCTION
600 -- AcctLineType_4
601 --
602 ---------------------------------------
603 PROCEDURE AcctLineType_4 (
604 p_application_id IN NUMBER
605 ,p_event_id IN NUMBER
606 ,p_calculate_acctd_flag IN VARCHAR2
607 ,p_calculate_g_l_flag IN VARCHAR2
608 ,p_actual_flag IN OUT VARCHAR2
609 ,p_balance_type_code OUT VARCHAR2
610 ,p_gain_or_loss_ref OUT VARCHAR2
611
612 --Supplier Name
613 , p_source_1 IN VARCHAR2
614 --Supplier Site
615 , p_source_2 IN VARCHAR2
616 --Payment / Billing Purpose
617 , p_source_3 IN VARCHAR2
618 --Payment / BillingType
619 , p_source_4 IN VARCHAR2
620 --Location Code
621 , p_source_5 IN VARCHAR2
622 --Lease Number
623 , p_source_6 IN VARCHAR2
624 --Property Code
625 , p_source_7 IN VARCHAR2
626 --Code Combination Identifier
627 , p_source_10 IN NUMBER
628 --Distribution Type
629 , p_source_11 IN VARCHAR2
630 --Payment / Billing Item Identifier
634 --Currency Code
631 , p_source_12 IN NUMBER
632 --Entered Amount
633 , p_source_13 IN NUMBER
635 , p_source_14 IN VARCHAR2
636 --Conversion Date
637 , p_source_15 IN DATE
638 --Conversion Rate
639 , p_source_16 IN NUMBER
640 --Conversion Rate Type
641 , p_source_17 IN VARCHAR2
642 --Accounted Amount
643 , p_source_18 IN NUMBER
644 )
645 IS
646
647 l_component_type VARCHAR2(80);
648 l_component_code VARCHAR2(30);
649 l_component_type_code VARCHAR2(1);
650 l_component_appl_id INTEGER;
651 l_amb_context_code VARCHAR2(30);
652 l_entity_code VARCHAR2(30);
653 l_event_class_code VARCHAR2(30);
654 l_ae_header_id NUMBER;
655 l_event_type_code VARCHAR2(30);
656 l_line_definition_code VARCHAR2(30);
657 l_line_definition_owner_code VARCHAR2(1);
658 --
659 -- adr variables
660 l_segment VARCHAR2(30);
661 l_ccid NUMBER;
662 l_adr_transaction_coa_id NUMBER;
663 l_adr_accounting_coa_id NUMBER;
664 l_adr_flexfield_segment_code VARCHAR2(30);
665 l_adr_flex_value_set_id NUMBER;
666 l_adr_value_type_code VARCHAR2(30);
667 l_adr_value_combination_id NUMBER;
668 l_adr_value_segment_code VARCHAR2(30);
669
670 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
671 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
672 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
673 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
674
675 -- 4262811 Variables ------------------------------------------------------------------------------------------
676 l_entered_amt_idx NUMBER;
677 l_accted_amt_idx NUMBER;
678 l_acc_rev_flag VARCHAR2(1);
679 l_accrual_line_num NUMBER;
680 l_tmp_amt NUMBER;
681 l_acc_rev_natural_side_code VARCHAR2(1);
682
683 l_num_entries NUMBER;
684 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
685 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
686 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
687 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
688 l_recog_line_1 NUMBER;
689 l_recog_line_2 NUMBER;
690
691 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
692 l_bflow_applied_to_amt NUMBER; -- 5132302
693 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
694
695 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
696
697 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
698 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
699
700 ---------------------------------------------------------------------------------------------------------------
701
702
703 --
704 -- bulk performance
705 --
706 l_balance_type_code VARCHAR2(1);
707 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
708 l_log_module VARCHAR2(240);
709
710 --
711 -- Upgrade strategy
712 --
713 l_actual_upg_option VARCHAR2(1);
714 l_enc_upg_option VARCHAR2(1);
715
716 --
717 BEGIN
718 --
719 IF g_log_enabled THEN
720 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_4';
721 END IF;
722 --
723 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
724
725 trace
726 (p_msg => 'BEGIN of AcctLineType_4'
727 ,p_level => C_LEVEL_PROCEDURE
728 ,p_module => l_log_module);
729
730 END IF;
731 --
732 l_component_type := 'AMB_JLT';
733 l_component_code := 'PN_ACCR_LIA';
734 l_component_type_code := 'S';
735 l_component_appl_id := 240;
736 l_amb_context_code := 'DEFAULT';
737 l_entity_code := 'TRANSACTION';
738 l_event_class_code := 'LEASE_EXPENSE';
739 l_event_type_code := 'LEASE_EXPENSE_TRANSFER';
740 l_line_definition_owner_code := 'S';
741 l_line_definition_code := 'PN_LEASE_EXPENSE';
742 --
743 l_balance_type_code := 'A';
744 l_segment := NULL;
745 l_ccid := NULL;
746 l_adr_transaction_coa_id := NULL;
747 l_adr_accounting_coa_id := NULL;
748 l_adr_flexfield_segment_code := NULL;
749 l_adr_flex_value_set_id := NULL;
750 l_adr_value_type_code := NULL;
751 l_adr_value_combination_id := NULL;
752 l_adr_value_segment_code := NULL;
753
754 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
755 l_bflow_class_code := ''; -- 4219869 Business Flow
756 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
757 l_budgetary_control_flag := 'N';
758
759 l_bflow_applied_to_amt_idx := NULL; -- 5132302
760 l_bflow_applied_to_amt := NULL; -- 5132302
761 l_entered_amt_idx := NULL; -- 4262811
762 l_accted_amt_idx := NULL; -- 4262811
763 l_acc_rev_flag := NULL; -- 4262811
764 l_accrual_line_num := NULL; -- 4262811
768 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
765 l_tmp_amt := NULL; -- 4262811
766 --
767
769 l_balance_type_code <> 'B' THEN
770 IF NVL(p_source_11,'
771 ') = 'ACC'
772 THEN
773
774 --
775 XLA_AE_LINES_PKG.SetNewLine;
776
777 p_balance_type_code := l_balance_type_code;
778 -- set the flag so later we will know whether the gain loss line needs to be created
779
780 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
781 p_actual_flag :='A';
782 END IF;
783
784 --
785 -- bulk performance
786 --
787 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
788 p_header_num => 0); -- 4262811
789 --
790 -- set accounting line options
791 --
792 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
793 p_natural_side_code => 'C'
794 , p_gain_or_loss_flag => 'N'
795 , p_gl_transfer_mode_code => 'D'
796 , p_acct_entry_type_code => 'A'
797 , p_switch_side_flag => 'Y'
798 , p_merge_duplicate_code => 'N'
799 );
800 --
801 l_acc_rev_natural_side_code := 'D'; -- 4262811
802 --
803 --
804 -- set accounting line type info
805 --
806 xla_ae_lines_pkg.SetAcctLineType
807 (p_component_type => l_component_type
808 ,p_event_type_code => l_event_type_code
809 ,p_line_definition_owner_code => l_line_definition_owner_code
810 ,p_line_definition_code => l_line_definition_code
811 ,p_accounting_line_code => l_component_code
812 ,p_accounting_line_type_code => l_component_type_code
813 ,p_accounting_line_appl_id => l_component_appl_id
814 ,p_amb_context_code => l_amb_context_code
815 ,p_entity_code => l_entity_code
816 ,p_event_class_code => l_event_class_code);
817 --
818 -- set accounting class
819 --
820 xla_ae_lines_pkg.SetAcctClass(
821 p_accounting_class_code => 'ACCRUAL'
822 , p_ae_header_id => l_ae_header_id
823 );
824
825 --
826 -- set rounding class
827 --
828 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
829 'ACCRUAL';
830
831 --
832 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
833 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
834 --
835 -- bulk performance
836 --
837 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
838
839 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
840 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
841
842 -- 4955764
843 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
844 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
845
846 -- 4458381 Public Sector Enh
847
848 --
849 -- set accounting attributes for the line type
850 --
851 l_entered_amt_idx := 3;
852 l_accted_amt_idx := 8;
853 l_bflow_applied_to_amt_idx := NULL; -- 5132302
854 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
855 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
856 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
857 l_rec_acct_attrs.array_char_value(2) := p_source_11;
858 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
859 l_rec_acct_attrs.array_num_value(3) := p_source_13;
860 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
861 l_rec_acct_attrs.array_char_value(4) := p_source_14;
862 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
863 l_rec_acct_attrs.array_date_value(5) := p_source_15;
864 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
865 l_rec_acct_attrs.array_num_value(6) := p_source_16;
866 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
867 l_rec_acct_attrs.array_char_value(7) := p_source_17;
868 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
869 l_rec_acct_attrs.array_num_value(8) := p_source_18;
870
871 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
872 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
873
874 ---------------------------------------------------------------------------------------------------------------
875 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
876 ---------------------------------------------------------------------------------------------------------------
877 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
878
879 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
880 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
881
885 AND l_bflow_method_code = 'PRIOR_ENTRY'
882 IF xla_accounting_cache_pkg.GetValueChar
883 (p_source_code => 'LEDGER_CATEGORY_CODE'
884 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
886 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
887 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
888 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
889 )
890 THEN
891 xla_ae_lines_pkg.BflowUpgEntry
892 (p_business_method_code => l_bflow_method_code
893 ,p_business_class_code => l_bflow_class_code
894 ,p_balance_type => l_balance_type_code);
895 ELSE
896 NULL;
897 -- No business flow processing for business flow method of NONE.
898 END IF;
899
900 --
901 -- call analytical criteria
902 --
903
904 --
905 -- call description
906 --
907
908 xla_ae_lines_pkg.SetLineDescription(
909 p_ae_header_id => l_ae_header_id
910 ,p_description => Description_1 (
911 p_application_id => p_application_id
912 , p_ae_header_id => l_ae_header_id
913 , p_source_1 => p_source_1
914 , p_source_2 => p_source_2
915 , p_source_3 => p_source_3
916 , p_source_4 => p_source_4
917 , p_source_5 => p_source_5
918 , p_source_6 => p_source_6
919 , p_source_7 => p_source_7
920 )
921 );
922
923
924 --
925 -- call ADRs
926 -- Bug 4922099
927 --
928 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
929 (NVL(l_actual_upg_option, 'N') = 'O') OR
930 (NVL(l_enc_upg_option, 'N') = 'O')
931 )
932 THEN
933 NULL;
934 --
935 --
936
937 l_ccid := AcctDerRule_3(
938 p_application_id => p_application_id
939 , p_ae_header_id => l_ae_header_id
940 , p_source_10 => p_source_10
941 , x_transaction_coa_id => l_adr_transaction_coa_id
942 , x_accounting_coa_id => l_adr_accounting_coa_id
943 , x_value_type_code => l_adr_value_type_code
944 , p_side => 'NA'
945 );
946
947 xla_ae_lines_pkg.set_ccid(
948 p_code_combination_id => l_ccid
949 , p_value_type_code => l_adr_value_type_code
950 , p_transaction_coa_id => l_adr_transaction_coa_id
951 , p_accounting_coa_id => l_adr_accounting_coa_id
952 , p_adr_code => 'PN_STANDARD'
953 , p_adr_type_code => 'S'
954 , p_component_type => l_component_type
955 , p_component_code => l_component_code
956 , p_component_type_code => l_component_type_code
957 , p_component_appl_id => l_component_appl_id
958 , p_amb_context_code => l_amb_context_code
959 , p_side => 'NA'
960 );
961
962
963 --
964 --
965 END IF;
966 --
967 -- Bug 4922099
968 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
969 (NVL(l_enc_upg_option, 'N') = 'O')
970 ) AND
971 (l_bflow_method_code = 'PRIOR_ENTRY')
972 )
973 THEN
974 IF
975 --
976 1 = 2
977 --
978 THEN
979 xla_accounting_err_pkg.build_message
980 (p_appli_s_name => 'XLA'
981 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
982 ,p_token_1 => 'LINE_NUMBER'
983 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
984 ,p_token_2 => 'LINE_TYPE_NAME'
985 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
986 l_component_type
987 ,l_component_code
988 ,l_component_type_code
989 ,l_component_appl_id
990 ,l_amb_context_code
991 ,l_entity_code
992 ,l_event_class_code
993 )
994 ,p_token_3 => 'OWNER'
995 ,p_value_3 => xla_lookups_pkg.get_meaning(
996 p_lookup_type => 'XLA_OWNER_TYPE'
997 ,p_lookup_code => l_component_type_code
998 )
999 ,p_token_4 => 'PRODUCT_NAME'
1000 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
1004 ,p_ae_header_id => NULL
1001 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1002 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1003 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
1005 );
1006
1007 IF (C_LEVEL_ERROR>= g_log_level) THEN
1008 trace
1009 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
1010 ,p_level => C_LEVEL_ERROR
1011 ,p_module => l_log_module);
1012 END IF;
1013 END IF;
1014 END IF;
1015 --
1016 --
1017 ------------------------------------------------------------------------------------------------
1018 -- 4219869 Business Flow
1019 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
1020 -- Prior Entry. Currently, the following code is always generated.
1021 ------------------------------------------------------------------------------------------------
1022 XLA_AE_LINES_PKG.ValidateCurrentLine;
1023
1024 ------------------------------------------------------------------------------------
1025 -- 4219869 Business Flow
1026 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
1027 ------------------------------------------------------------------------------------
1028 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
1029
1030 ----------------------------------------------------------------------------------
1031 -- 4219869 Business Flow
1032 -- Update journal entry status -- Need to generate this within IF <condition>
1033 ----------------------------------------------------------------------------------
1034 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
1035 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
1036 ,p_balance_type_code => l_balance_type_code
1037 );
1038
1039 -------------------------------------------------------------------------------------------
1040 -- 4262811 - Generate the Accrual Reversal lines
1041 -------------------------------------------------------------------------------------------
1042 BEGIN
1043 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
1044 (g_array_event(p_event_id).array_value_num('header_index'));
1045 IF l_acc_rev_flag IS NULL THEN
1046 l_acc_rev_flag := 'N';
1047 END IF;
1048 EXCEPTION
1049 WHEN OTHERS THEN
1050 l_acc_rev_flag := 'N';
1051 END;
1052 --
1053 IF (l_acc_rev_flag = 'Y') THEN
1054
1055 -- 4645092 ------------------------------------------------------------------------------
1056 -- To allow MPA report to determine if it should generate report process
1057 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
1058 ------------------------------------------------------------------------------------------
1059
1060 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
1061 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
1062 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
1063 -- call ADRs
1064 -- Bug 4922099
1065 --
1066 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
1067 (NVL(l_actual_upg_option, 'N') = 'O') OR
1068 (NVL(l_enc_upg_option, 'N') = 'O')
1069 )
1070 THEN
1071 NULL;
1072 --
1073 --
1074
1075 l_ccid := AcctDerRule_3(
1076 p_application_id => p_application_id
1077 , p_ae_header_id => l_ae_header_id
1078 , p_source_10 => p_source_10
1079 , x_transaction_coa_id => l_adr_transaction_coa_id
1080 , x_accounting_coa_id => l_adr_accounting_coa_id
1081 , x_value_type_code => l_adr_value_type_code
1082 , p_side => 'NA'
1083 );
1084
1085 xla_ae_lines_pkg.set_ccid(
1086 p_code_combination_id => l_ccid
1087 , p_value_type_code => l_adr_value_type_code
1088 , p_transaction_coa_id => l_adr_transaction_coa_id
1089 , p_accounting_coa_id => l_adr_accounting_coa_id
1090 , p_adr_code => 'PN_STANDARD'
1091 , p_adr_type_code => 'S'
1092 , p_component_type => l_component_type
1093 , p_component_code => l_component_code
1094 , p_component_type_code => l_component_type_code
1095 , p_component_appl_id => l_component_appl_id
1096 , p_amb_context_code => l_amb_context_code
1097 , p_side => 'NA'
1098 );
1099
1100
1101 --
1102 --
1103 END IF;
1104
1105 --
1106 -- Update the line information that should be overwritten
1107 --
1108 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
1109 p_header_num => 1);
1110 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
1111
1112 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
1113
1114 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
1115 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
1116 END IF;
1117
1118 --
1122 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
1119 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
1120 --
1121 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
1123 ELSE
1124 ---------------------------------------------------------------------------------------------------
1125 -- 4262811a Switch Sign
1126 ---------------------------------------------------------------------------------------------------
1127 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
1128 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
1129 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
1130 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
1131 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
1132 -- 5132302
1133 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
1134 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
1135
1136 END IF;
1137
1138 -- 4955764
1139 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
1140 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
1141
1142
1143 XLA_AE_LINES_PKG.ValidateCurrentLine;
1144 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
1145
1146 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
1147 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
1148 ,p_balance_type_code => l_balance_type_code);
1149
1150 END IF;
1151
1152 -----------------------------------------------------------------------------------------
1153 -- 4262811 Multiperiod Accounting
1154 -----------------------------------------------------------------------------------------
1155 -- No MPA option is assigned.
1156
1157
1158 END IF;
1159 END IF;
1160 --
1161
1162 --
1163 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1164 trace
1165 (p_msg => 'END of AcctLineType_4'
1166 ,p_level => C_LEVEL_PROCEDURE
1167 ,p_module => l_log_module);
1168 END IF;
1169 --
1170 EXCEPTION
1171 WHEN xla_exceptions_pkg.application_exception THEN
1172 RAISE;
1173 WHEN OTHERS THEN
1174 xla_exceptions_pkg.raise_message
1175 (p_location => 'XLA_00240_AAD_S_000003_PKG.AcctLineType_4');
1176 END AcctLineType_4;
1177 --
1178
1179 ---------------------------------------
1180 --
1181 -- PRIVATE FUNCTION
1182 -- AcctLineType_5
1183 --
1184 ---------------------------------------
1185 PROCEDURE AcctLineType_5 (
1186 p_application_id IN NUMBER
1187 ,p_event_id IN NUMBER
1188 ,p_calculate_acctd_flag IN VARCHAR2
1189 ,p_calculate_g_l_flag IN VARCHAR2
1190 ,p_actual_flag IN OUT VARCHAR2
1191 ,p_balance_type_code OUT VARCHAR2
1192 ,p_gain_or_loss_ref OUT VARCHAR2
1193
1194 --Payment / Billing Purpose
1195 , p_source_3 IN VARCHAR2
1196 --Payment / BillingType
1197 , p_source_4 IN VARCHAR2
1198 --Location Code
1199 , p_source_5 IN VARCHAR2
1200 --Lease Number
1201 , p_source_6 IN VARCHAR2
1202 --Property Code
1203 , p_source_7 IN VARCHAR2
1204 --Customer Name
1205 , p_source_8 IN VARCHAR2
1206 --Customer Site
1207 , p_source_9 IN VARCHAR2
1208 --Code Combination Identifier
1209 , p_source_10 IN NUMBER
1210 --Distribution Type
1211 , p_source_11 IN VARCHAR2
1212 --Payment / Billing Item Identifier
1213 , p_source_12 IN NUMBER
1214 --Entered Amount
1215 , p_source_13 IN NUMBER
1216 --Currency Code
1217 , p_source_14 IN VARCHAR2
1218 --Conversion Date
1219 , p_source_15 IN DATE
1220 --Conversion Rate
1221 , p_source_16 IN NUMBER
1222 --Conversion Rate Type
1223 , p_source_17 IN VARCHAR2
1224 --Accounted Amount
1225 , p_source_18 IN NUMBER
1226 )
1227 IS
1228
1229 l_component_type VARCHAR2(80);
1230 l_component_code VARCHAR2(30);
1231 l_component_type_code VARCHAR2(1);
1232 l_component_appl_id INTEGER;
1233 l_amb_context_code VARCHAR2(30);
1234 l_entity_code VARCHAR2(30);
1235 l_event_class_code VARCHAR2(30);
1236 l_ae_header_id NUMBER;
1237 l_event_type_code VARCHAR2(30);
1238 l_line_definition_code VARCHAR2(30);
1239 l_line_definition_owner_code VARCHAR2(1);
1240 --
1241 -- adr variables
1242 l_segment VARCHAR2(30);
1243 l_ccid NUMBER;
1244 l_adr_transaction_coa_id NUMBER;
1245 l_adr_accounting_coa_id NUMBER;
1246 l_adr_flexfield_segment_code VARCHAR2(30);
1247 l_adr_flex_value_set_id NUMBER;
1248 l_adr_value_type_code VARCHAR2(30);
1249 l_adr_value_combination_id NUMBER;
1253 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
1250 l_adr_value_segment_code VARCHAR2(30);
1251
1252 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
1254 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
1255 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
1256
1257 -- 4262811 Variables ------------------------------------------------------------------------------------------
1258 l_entered_amt_idx NUMBER;
1259 l_accted_amt_idx NUMBER;
1260 l_acc_rev_flag VARCHAR2(1);
1261 l_accrual_line_num NUMBER;
1262 l_tmp_amt NUMBER;
1263 l_acc_rev_natural_side_code VARCHAR2(1);
1264
1265 l_num_entries NUMBER;
1266 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
1267 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
1268 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
1269 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
1270 l_recog_line_1 NUMBER;
1271 l_recog_line_2 NUMBER;
1272
1273 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
1274 l_bflow_applied_to_amt NUMBER; -- 5132302
1275 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
1276
1277 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
1278
1279 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
1280 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
1281
1282 ---------------------------------------------------------------------------------------------------------------
1283
1284
1285 --
1286 -- bulk performance
1287 --
1288 l_balance_type_code VARCHAR2(1);
1289 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
1290 l_log_module VARCHAR2(240);
1291
1292 --
1293 -- Upgrade strategy
1294 --
1295 l_actual_upg_option VARCHAR2(1);
1296 l_enc_upg_option VARCHAR2(1);
1297
1298 --
1299 BEGIN
1300 --
1301 IF g_log_enabled THEN
1302 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_5';
1303 END IF;
1304 --
1305 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1306
1307 trace
1308 (p_msg => 'BEGIN of AcctLineType_5'
1309 ,p_level => C_LEVEL_PROCEDURE
1310 ,p_module => l_log_module);
1311
1312 END IF;
1313 --
1314 l_component_type := 'AMB_JLT';
1315 l_component_code := 'PN_ACC_AST';
1316 l_component_type_code := 'S';
1317 l_component_appl_id := 240;
1318 l_amb_context_code := 'DEFAULT';
1319 l_entity_code := 'TRANSACTION';
1320 l_event_class_code := 'LEASE_REVENUE';
1321 l_event_type_code := 'LEASE_REVENUE_TRANSFER';
1322 l_line_definition_owner_code := 'S';
1323 l_line_definition_code := 'PN_LEASE_REVENUE';
1324 --
1325 l_balance_type_code := 'A';
1326 l_segment := NULL;
1327 l_ccid := NULL;
1328 l_adr_transaction_coa_id := NULL;
1329 l_adr_accounting_coa_id := NULL;
1330 l_adr_flexfield_segment_code := NULL;
1331 l_adr_flex_value_set_id := NULL;
1332 l_adr_value_type_code := NULL;
1333 l_adr_value_combination_id := NULL;
1334 l_adr_value_segment_code := NULL;
1335
1336 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
1337 l_bflow_class_code := ''; -- 4219869 Business Flow
1338 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
1339 l_budgetary_control_flag := 'N';
1340
1341 l_bflow_applied_to_amt_idx := NULL; -- 5132302
1342 l_bflow_applied_to_amt := NULL; -- 5132302
1343 l_entered_amt_idx := NULL; -- 4262811
1344 l_accted_amt_idx := NULL; -- 4262811
1345 l_acc_rev_flag := NULL; -- 4262811
1346 l_accrual_line_num := NULL; -- 4262811
1347 l_tmp_amt := NULL; -- 4262811
1348 --
1349
1350 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
1351 l_balance_type_code <> 'B' THEN
1352 IF NVL(p_source_11,'
1353 ') = 'UNEARN'
1354 THEN
1355
1356 --
1357 XLA_AE_LINES_PKG.SetNewLine;
1358
1359 p_balance_type_code := l_balance_type_code;
1360 -- set the flag so later we will know whether the gain loss line needs to be created
1361
1362 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
1363 p_actual_flag :='A';
1364 END IF;
1365
1366 --
1367 -- bulk performance
1368 --
1369 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
1370 p_header_num => 0); -- 4262811
1371 --
1372 -- set accounting line options
1373 --
1374 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
1375 p_natural_side_code => 'D'
1376 , p_gain_or_loss_flag => 'N'
1377 , p_gl_transfer_mode_code => 'D'
1378 , p_acct_entry_type_code => 'A'
1379 , p_switch_side_flag => 'Y'
1383 l_acc_rev_natural_side_code := 'C'; -- 4262811
1380 , p_merge_duplicate_code => 'N'
1381 );
1382 --
1384 --
1385 --
1386 -- set accounting line type info
1387 --
1388 xla_ae_lines_pkg.SetAcctLineType
1389 (p_component_type => l_component_type
1390 ,p_event_type_code => l_event_type_code
1391 ,p_line_definition_owner_code => l_line_definition_owner_code
1392 ,p_line_definition_code => l_line_definition_code
1393 ,p_accounting_line_code => l_component_code
1394 ,p_accounting_line_type_code => l_component_type_code
1395 ,p_accounting_line_appl_id => l_component_appl_id
1396 ,p_amb_context_code => l_amb_context_code
1397 ,p_entity_code => l_entity_code
1398 ,p_event_class_code => l_event_class_code);
1399 --
1400 -- set accounting class
1401 --
1402 xla_ae_lines_pkg.SetAcctClass(
1403 p_accounting_class_code => 'UNEARNED_REVENUE'
1404 , p_ae_header_id => l_ae_header_id
1405 );
1406
1407 --
1408 -- set rounding class
1409 --
1410 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
1411 'UNEARNED_REVENUE';
1412
1413 --
1414 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
1415 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
1416 --
1417 -- bulk performance
1418 --
1419 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
1420
1421 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
1422 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
1423
1424 -- 4955764
1425 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
1426 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
1427
1428 -- 4458381 Public Sector Enh
1429
1430 --
1431 -- set accounting attributes for the line type
1432 --
1433 l_entered_amt_idx := 3;
1434 l_accted_amt_idx := 8;
1435 l_bflow_applied_to_amt_idx := NULL; -- 5132302
1436 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
1437 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
1438 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
1439 l_rec_acct_attrs.array_char_value(2) := p_source_11;
1440 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
1441 l_rec_acct_attrs.array_num_value(3) := p_source_13;
1442 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
1443 l_rec_acct_attrs.array_char_value(4) := p_source_14;
1444 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
1445 l_rec_acct_attrs.array_date_value(5) := p_source_15;
1446 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
1447 l_rec_acct_attrs.array_num_value(6) := p_source_16;
1448 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
1449 l_rec_acct_attrs.array_char_value(7) := p_source_17;
1450 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
1451 l_rec_acct_attrs.array_num_value(8) := p_source_18;
1452
1453 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
1454 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
1455
1456 ---------------------------------------------------------------------------------------------------------------
1457 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
1458 ---------------------------------------------------------------------------------------------------------------
1459 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
1460
1461 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
1462 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
1463
1464 IF xla_accounting_cache_pkg.GetValueChar
1465 (p_source_code => 'LEDGER_CATEGORY_CODE'
1466 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
1467 AND l_bflow_method_code = 'PRIOR_ENTRY'
1468 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
1469 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
1470 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
1471 )
1472 THEN
1473 xla_ae_lines_pkg.BflowUpgEntry
1474 (p_business_method_code => l_bflow_method_code
1475 ,p_business_class_code => l_bflow_class_code
1476 ,p_balance_type => l_balance_type_code);
1477 ELSE
1478 NULL;
1479 -- No business flow processing for business flow method of NONE.
1480 END IF;
1481
1482 --
1483 -- call analytical criteria
1484 --
1485
1486 --
1487 -- call description
1488 --
1489
1490 xla_ae_lines_pkg.SetLineDescription(
1494 , p_ae_header_id => l_ae_header_id
1491 p_ae_header_id => l_ae_header_id
1492 ,p_description => Description_2 (
1493 p_application_id => p_application_id
1495 , p_source_3 => p_source_3
1496 , p_source_4 => p_source_4
1497 , p_source_5 => p_source_5
1498 , p_source_6 => p_source_6
1499 , p_source_7 => p_source_7
1500 , p_source_8 => p_source_8
1501 , p_source_9 => p_source_9
1502 )
1503 );
1504
1505
1506 --
1507 -- call ADRs
1508 -- Bug 4922099
1509 --
1510 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
1511 (NVL(l_actual_upg_option, 'N') = 'O') OR
1512 (NVL(l_enc_upg_option, 'N') = 'O')
1513 )
1514 THEN
1515 NULL;
1516 --
1517 --
1518
1519 l_ccid := AcctDerRule_3(
1520 p_application_id => p_application_id
1521 , p_ae_header_id => l_ae_header_id
1522 , p_source_10 => p_source_10
1523 , x_transaction_coa_id => l_adr_transaction_coa_id
1524 , x_accounting_coa_id => l_adr_accounting_coa_id
1525 , x_value_type_code => l_adr_value_type_code
1526 , p_side => 'NA'
1527 );
1528
1529 xla_ae_lines_pkg.set_ccid(
1530 p_code_combination_id => l_ccid
1531 , p_value_type_code => l_adr_value_type_code
1532 , p_transaction_coa_id => l_adr_transaction_coa_id
1533 , p_accounting_coa_id => l_adr_accounting_coa_id
1534 , p_adr_code => 'PN_STANDARD'
1535 , p_adr_type_code => 'S'
1536 , p_component_type => l_component_type
1537 , p_component_code => l_component_code
1538 , p_component_type_code => l_component_type_code
1539 , p_component_appl_id => l_component_appl_id
1540 , p_amb_context_code => l_amb_context_code
1541 , p_side => 'NA'
1542 );
1543
1544
1545 --
1546 --
1547 END IF;
1548 --
1549 -- Bug 4922099
1550 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
1551 (NVL(l_enc_upg_option, 'N') = 'O')
1552 ) AND
1553 (l_bflow_method_code = 'PRIOR_ENTRY')
1554 )
1555 THEN
1556 IF
1557 --
1558 1 = 2
1559 --
1560 THEN
1561 xla_accounting_err_pkg.build_message
1562 (p_appli_s_name => 'XLA'
1563 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
1564 ,p_token_1 => 'LINE_NUMBER'
1565 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
1566 ,p_token_2 => 'LINE_TYPE_NAME'
1567 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
1568 l_component_type
1569 ,l_component_code
1570 ,l_component_type_code
1571 ,l_component_appl_id
1572 ,l_amb_context_code
1573 ,l_entity_code
1574 ,l_event_class_code
1575 )
1576 ,p_token_3 => 'OWNER'
1577 ,p_value_3 => xla_lookups_pkg.get_meaning(
1578 p_lookup_type => 'XLA_OWNER_TYPE'
1579 ,p_lookup_code => l_component_type_code
1580 )
1581 ,p_token_4 => 'PRODUCT_NAME'
1582 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
1583 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1584 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1585 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
1586 ,p_ae_header_id => NULL
1587 );
1588
1589 IF (C_LEVEL_ERROR>= g_log_level) THEN
1590 trace
1591 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
1592 ,p_level => C_LEVEL_ERROR
1593 ,p_module => l_log_module);
1594 END IF;
1595 END IF;
1596 END IF;
1597 --
1598 --
1599 ------------------------------------------------------------------------------------------------
1600 -- 4219869 Business Flow
1601 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
1602 -- Prior Entry. Currently, the following code is always generated.
1606 ------------------------------------------------------------------------------------
1603 ------------------------------------------------------------------------------------------------
1604 XLA_AE_LINES_PKG.ValidateCurrentLine;
1605
1607 -- 4219869 Business Flow
1608 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
1609 ------------------------------------------------------------------------------------
1610 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
1611
1612 ----------------------------------------------------------------------------------
1613 -- 4219869 Business Flow
1614 -- Update journal entry status -- Need to generate this within IF <condition>
1615 ----------------------------------------------------------------------------------
1616 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
1617 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
1618 ,p_balance_type_code => l_balance_type_code
1619 );
1620
1621 -------------------------------------------------------------------------------------------
1622 -- 4262811 - Generate the Accrual Reversal lines
1623 -------------------------------------------------------------------------------------------
1624 BEGIN
1625 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
1626 (g_array_event(p_event_id).array_value_num('header_index'));
1627 IF l_acc_rev_flag IS NULL THEN
1628 l_acc_rev_flag := 'N';
1629 END IF;
1630 EXCEPTION
1631 WHEN OTHERS THEN
1632 l_acc_rev_flag := 'N';
1633 END;
1634 --
1635 IF (l_acc_rev_flag = 'Y') THEN
1636
1637 -- 4645092 ------------------------------------------------------------------------------
1638 -- To allow MPA report to determine if it should generate report process
1639 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
1640 ------------------------------------------------------------------------------------------
1641
1642 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
1643 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
1644 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
1645 -- call ADRs
1646 -- Bug 4922099
1647 --
1648 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
1649 (NVL(l_actual_upg_option, 'N') = 'O') OR
1650 (NVL(l_enc_upg_option, 'N') = 'O')
1651 )
1652 THEN
1653 NULL;
1654 --
1655 --
1656
1657 l_ccid := AcctDerRule_3(
1658 p_application_id => p_application_id
1659 , p_ae_header_id => l_ae_header_id
1660 , p_source_10 => p_source_10
1661 , x_transaction_coa_id => l_adr_transaction_coa_id
1662 , x_accounting_coa_id => l_adr_accounting_coa_id
1663 , x_value_type_code => l_adr_value_type_code
1664 , p_side => 'NA'
1665 );
1666
1667 xla_ae_lines_pkg.set_ccid(
1668 p_code_combination_id => l_ccid
1669 , p_value_type_code => l_adr_value_type_code
1670 , p_transaction_coa_id => l_adr_transaction_coa_id
1671 , p_accounting_coa_id => l_adr_accounting_coa_id
1672 , p_adr_code => 'PN_STANDARD'
1673 , p_adr_type_code => 'S'
1674 , p_component_type => l_component_type
1675 , p_component_code => l_component_code
1676 , p_component_type_code => l_component_type_code
1677 , p_component_appl_id => l_component_appl_id
1678 , p_amb_context_code => l_amb_context_code
1679 , p_side => 'NA'
1680 );
1681
1682
1683 --
1684 --
1685 END IF;
1686
1687 --
1688 -- Update the line information that should be overwritten
1689 --
1690 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
1691 p_header_num => 1);
1692 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
1693
1694 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
1695
1696 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
1697 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
1698 END IF;
1699
1700 --
1701 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
1702 --
1703 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
1704 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
1705 ELSE
1706 ---------------------------------------------------------------------------------------------------
1707 -- 4262811a Switch Sign
1708 ---------------------------------------------------------------------------------------------------
1709 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
1710 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
1714 -- 5132302
1711 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
1712 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
1713 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
1715 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
1716 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
1717
1718 END IF;
1719
1720 -- 4955764
1721 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
1722 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
1723
1724
1725 XLA_AE_LINES_PKG.ValidateCurrentLine;
1726 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
1727
1728 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
1729 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
1730 ,p_balance_type_code => l_balance_type_code);
1731
1732 END IF;
1733
1734 -----------------------------------------------------------------------------------------
1735 -- 4262811 Multiperiod Accounting
1736 -----------------------------------------------------------------------------------------
1737 -- No MPA option is assigned.
1738
1739
1740 END IF;
1741 END IF;
1742 --
1743
1744 --
1745 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1746 trace
1747 (p_msg => 'END of AcctLineType_5'
1748 ,p_level => C_LEVEL_PROCEDURE
1749 ,p_module => l_log_module);
1750 END IF;
1751 --
1752 EXCEPTION
1753 WHEN xla_exceptions_pkg.application_exception THEN
1754 RAISE;
1755 WHEN OTHERS THEN
1756 xla_exceptions_pkg.raise_message
1757 (p_location => 'XLA_00240_AAD_S_000003_PKG.AcctLineType_5');
1758 END AcctLineType_5;
1759 --
1760
1761 ---------------------------------------
1762 --
1763 -- PRIVATE FUNCTION
1764 -- AcctLineType_6
1765 --
1766 ---------------------------------------
1767 PROCEDURE AcctLineType_6 (
1768 p_application_id IN NUMBER
1769 ,p_event_id IN NUMBER
1770 ,p_calculate_acctd_flag IN VARCHAR2
1771 ,p_calculate_g_l_flag IN VARCHAR2
1772 ,p_actual_flag IN OUT VARCHAR2
1773 ,p_balance_type_code OUT VARCHAR2
1774 ,p_gain_or_loss_ref OUT VARCHAR2
1775
1776 --Supplier Name
1777 , p_source_1 IN VARCHAR2
1778 --Supplier Site
1779 , p_source_2 IN VARCHAR2
1780 --Payment / Billing Purpose
1781 , p_source_3 IN VARCHAR2
1782 --Payment / BillingType
1783 , p_source_4 IN VARCHAR2
1784 --Location Code
1785 , p_source_5 IN VARCHAR2
1786 --Lease Number
1787 , p_source_6 IN VARCHAR2
1788 --Property Code
1789 , p_source_7 IN VARCHAR2
1790 --Code Combination Identifier
1791 , p_source_10 IN NUMBER
1792 --Distribution Type
1793 , p_source_11 IN VARCHAR2
1794 --Payment / Billing Item Identifier
1795 , p_source_12 IN NUMBER
1796 --Entered Amount
1797 , p_source_13 IN NUMBER
1798 --Currency Code
1799 , p_source_14 IN VARCHAR2
1800 --Conversion Date
1801 , p_source_15 IN DATE
1802 --Conversion Rate
1803 , p_source_16 IN NUMBER
1804 --Conversion Rate Type
1805 , p_source_17 IN VARCHAR2
1806 --Accounted Amount
1807 , p_source_18 IN NUMBER
1808 )
1809 IS
1810
1811 l_component_type VARCHAR2(80);
1812 l_component_code VARCHAR2(30);
1813 l_component_type_code VARCHAR2(1);
1814 l_component_appl_id INTEGER;
1815 l_amb_context_code VARCHAR2(30);
1816 l_entity_code VARCHAR2(30);
1817 l_event_class_code VARCHAR2(30);
1818 l_ae_header_id NUMBER;
1819 l_event_type_code VARCHAR2(30);
1820 l_line_definition_code VARCHAR2(30);
1821 l_line_definition_owner_code VARCHAR2(1);
1822 --
1823 -- adr variables
1824 l_segment VARCHAR2(30);
1825 l_ccid NUMBER;
1826 l_adr_transaction_coa_id NUMBER;
1827 l_adr_accounting_coa_id NUMBER;
1828 l_adr_flexfield_segment_code VARCHAR2(30);
1829 l_adr_flex_value_set_id NUMBER;
1830 l_adr_value_type_code VARCHAR2(30);
1831 l_adr_value_combination_id NUMBER;
1832 l_adr_value_segment_code VARCHAR2(30);
1833
1834 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
1835 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
1836 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
1837 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
1838
1839 -- 4262811 Variables ------------------------------------------------------------------------------------------
1840 l_entered_amt_idx NUMBER;
1841 l_accted_amt_idx NUMBER;
1842 l_acc_rev_flag VARCHAR2(1);
1843 l_accrual_line_num NUMBER;
1844 l_tmp_amt NUMBER;
1845 l_acc_rev_natural_side_code VARCHAR2(1);
1846
1847 l_num_entries NUMBER;
1851 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
1848 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
1849 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
1850 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
1852 l_recog_line_1 NUMBER;
1853 l_recog_line_2 NUMBER;
1854
1855 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
1856 l_bflow_applied_to_amt NUMBER; -- 5132302
1857 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
1858
1859 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
1860
1861 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
1862 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
1863
1864 ---------------------------------------------------------------------------------------------------------------
1865
1866
1867 --
1868 -- bulk performance
1869 --
1870 l_balance_type_code VARCHAR2(1);
1871 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
1872 l_log_module VARCHAR2(240);
1873
1874 --
1875 -- Upgrade strategy
1876 --
1877 l_actual_upg_option VARCHAR2(1);
1878 l_enc_upg_option VARCHAR2(1);
1879
1880 --
1881 BEGIN
1882 --
1883 IF g_log_enabled THEN
1884 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_6';
1885 END IF;
1886 --
1887 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1888
1889 trace
1890 (p_msg => 'BEGIN of AcctLineType_6'
1891 ,p_level => C_LEVEL_PROCEDURE
1892 ,p_module => l_log_module);
1893
1894 END IF;
1895 --
1896 l_component_type := 'AMB_JLT';
1897 l_component_code := 'PN_EXP';
1898 l_component_type_code := 'S';
1899 l_component_appl_id := 240;
1900 l_amb_context_code := 'DEFAULT';
1901 l_entity_code := 'TRANSACTION';
1902 l_event_class_code := 'LEASE_EXPENSE';
1903 l_event_type_code := 'LEASE_EXPENSE_TRANSFER';
1904 l_line_definition_owner_code := 'S';
1905 l_line_definition_code := 'PN_LEASE_EXPENSE';
1906 --
1907 l_balance_type_code := 'A';
1908 l_segment := NULL;
1909 l_ccid := NULL;
1910 l_adr_transaction_coa_id := NULL;
1911 l_adr_accounting_coa_id := NULL;
1912 l_adr_flexfield_segment_code := NULL;
1913 l_adr_flex_value_set_id := NULL;
1914 l_adr_value_type_code := NULL;
1915 l_adr_value_combination_id := NULL;
1916 l_adr_value_segment_code := NULL;
1917
1918 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
1919 l_bflow_class_code := ''; -- 4219869 Business Flow
1920 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
1921 l_budgetary_control_flag := 'N';
1922
1923 l_bflow_applied_to_amt_idx := NULL; -- 5132302
1924 l_bflow_applied_to_amt := NULL; -- 5132302
1925 l_entered_amt_idx := NULL; -- 4262811
1926 l_accted_amt_idx := NULL; -- 4262811
1927 l_acc_rev_flag := NULL; -- 4262811
1928 l_accrual_line_num := NULL; -- 4262811
1929 l_tmp_amt := NULL; -- 4262811
1930 --
1931
1932 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
1933 l_balance_type_code <> 'B' THEN
1934 IF NVL(p_source_11,'
1935 ') = 'EXP'
1936 THEN
1937
1938 --
1939 XLA_AE_LINES_PKG.SetNewLine;
1940
1941 p_balance_type_code := l_balance_type_code;
1942 -- set the flag so later we will know whether the gain loss line needs to be created
1943
1944 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
1945 p_actual_flag :='A';
1946 END IF;
1947
1948 --
1949 -- bulk performance
1950 --
1951 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
1952 p_header_num => 0); -- 4262811
1953 --
1954 -- set accounting line options
1955 --
1956 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
1957 p_natural_side_code => 'D'
1958 , p_gain_or_loss_flag => 'N'
1959 , p_gl_transfer_mode_code => 'D'
1960 , p_acct_entry_type_code => 'A'
1961 , p_switch_side_flag => 'Y'
1962 , p_merge_duplicate_code => 'N'
1963 );
1964 --
1965 l_acc_rev_natural_side_code := 'C'; -- 4262811
1966 --
1967 --
1968 -- set accounting line type info
1969 --
1970 xla_ae_lines_pkg.SetAcctLineType
1971 (p_component_type => l_component_type
1972 ,p_event_type_code => l_event_type_code
1973 ,p_line_definition_owner_code => l_line_definition_owner_code
1974 ,p_line_definition_code => l_line_definition_code
1975 ,p_accounting_line_code => l_component_code
1976 ,p_accounting_line_type_code => l_component_type_code
1977 ,p_accounting_line_appl_id => l_component_appl_id
1978 ,p_amb_context_code => l_amb_context_code
1982 -- set accounting class
1979 ,p_entity_code => l_entity_code
1980 ,p_event_class_code => l_event_class_code);
1981 --
1983 --
1984 xla_ae_lines_pkg.SetAcctClass(
1985 p_accounting_class_code => 'EXPENSE'
1986 , p_ae_header_id => l_ae_header_id
1987 );
1988
1989 --
1990 -- set rounding class
1991 --
1992 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
1993 'EXPENSE';
1994
1995 --
1996 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
1997 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
1998 --
1999 -- bulk performance
2000 --
2001 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
2002
2003 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
2004 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
2005
2006 -- 4955764
2007 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2008 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
2009
2010 -- 4458381 Public Sector Enh
2011
2012 --
2013 -- set accounting attributes for the line type
2014 --
2015 l_entered_amt_idx := 3;
2016 l_accted_amt_idx := 8;
2017 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2018 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
2019 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
2020 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
2021 l_rec_acct_attrs.array_char_value(2) := p_source_11;
2022 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
2023 l_rec_acct_attrs.array_num_value(3) := p_source_13;
2024 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
2025 l_rec_acct_attrs.array_char_value(4) := p_source_14;
2026 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
2027 l_rec_acct_attrs.array_date_value(5) := p_source_15;
2028 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
2029 l_rec_acct_attrs.array_num_value(6) := p_source_16;
2030 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
2031 l_rec_acct_attrs.array_char_value(7) := p_source_17;
2032 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
2033 l_rec_acct_attrs.array_num_value(8) := p_source_18;
2034
2035 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
2036 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
2037
2038 ---------------------------------------------------------------------------------------------------------------
2039 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
2040 ---------------------------------------------------------------------------------------------------------------
2041 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
2042
2043 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2044 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2045
2046 IF xla_accounting_cache_pkg.GetValueChar
2047 (p_source_code => 'LEDGER_CATEGORY_CODE'
2048 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
2049 AND l_bflow_method_code = 'PRIOR_ENTRY'
2050 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
2051 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
2052 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
2053 )
2054 THEN
2055 xla_ae_lines_pkg.BflowUpgEntry
2056 (p_business_method_code => l_bflow_method_code
2057 ,p_business_class_code => l_bflow_class_code
2058 ,p_balance_type => l_balance_type_code);
2059 ELSE
2060 NULL;
2061 -- No business flow processing for business flow method of NONE.
2062 END IF;
2063
2064 --
2065 -- call analytical criteria
2066 --
2067
2068 --
2069 -- call description
2070 --
2071
2072 xla_ae_lines_pkg.SetLineDescription(
2073 p_ae_header_id => l_ae_header_id
2074 ,p_description => Description_1 (
2075 p_application_id => p_application_id
2076 , p_ae_header_id => l_ae_header_id
2077 , p_source_1 => p_source_1
2078 , p_source_2 => p_source_2
2079 , p_source_3 => p_source_3
2080 , p_source_4 => p_source_4
2081 , p_source_5 => p_source_5
2082 , p_source_6 => p_source_6
2083 , p_source_7 => p_source_7
2084 )
2085 );
2086
2087
2088 --
2089 -- call ADRs
2090 -- Bug 4922099
2091 --
2092 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2093 (NVL(l_actual_upg_option, 'N') = 'O') OR
2094 (NVL(l_enc_upg_option, 'N') = 'O')
2095 )
2096 THEN
2097 NULL;
2098 --
2099 --
2100
2101 l_ccid := AcctDerRule_3(
2102 p_application_id => p_application_id
2103 , p_ae_header_id => l_ae_header_id
2104 , p_source_10 => p_source_10
2108 , p_side => 'NA'
2105 , x_transaction_coa_id => l_adr_transaction_coa_id
2106 , x_accounting_coa_id => l_adr_accounting_coa_id
2107 , x_value_type_code => l_adr_value_type_code
2109 );
2110
2111 xla_ae_lines_pkg.set_ccid(
2112 p_code_combination_id => l_ccid
2113 , p_value_type_code => l_adr_value_type_code
2114 , p_transaction_coa_id => l_adr_transaction_coa_id
2115 , p_accounting_coa_id => l_adr_accounting_coa_id
2116 , p_adr_code => 'PN_STANDARD'
2117 , p_adr_type_code => 'S'
2118 , p_component_type => l_component_type
2119 , p_component_code => l_component_code
2120 , p_component_type_code => l_component_type_code
2121 , p_component_appl_id => l_component_appl_id
2122 , p_amb_context_code => l_amb_context_code
2123 , p_side => 'NA'
2124 );
2125
2126
2127 --
2128 --
2129 END IF;
2130 --
2131 -- Bug 4922099
2132 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
2133 (NVL(l_enc_upg_option, 'N') = 'O')
2134 ) AND
2135 (l_bflow_method_code = 'PRIOR_ENTRY')
2136 )
2137 THEN
2138 IF
2139 --
2140 1 = 2
2141 --
2142 THEN
2143 xla_accounting_err_pkg.build_message
2144 (p_appli_s_name => 'XLA'
2145 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2146 ,p_token_1 => 'LINE_NUMBER'
2147 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
2148 ,p_token_2 => 'LINE_TYPE_NAME'
2149 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
2150 l_component_type
2151 ,l_component_code
2152 ,l_component_type_code
2153 ,l_component_appl_id
2154 ,l_amb_context_code
2155 ,l_entity_code
2156 ,l_event_class_code
2157 )
2158 ,p_token_3 => 'OWNER'
2159 ,p_value_3 => xla_lookups_pkg.get_meaning(
2160 p_lookup_type => 'XLA_OWNER_TYPE'
2161 ,p_lookup_code => l_component_type_code
2162 )
2163 ,p_token_4 => 'PRODUCT_NAME'
2164 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
2165 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
2166 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
2167 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
2168 ,p_ae_header_id => NULL
2169 );
2170
2171 IF (C_LEVEL_ERROR>= g_log_level) THEN
2172 trace
2173 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2174 ,p_level => C_LEVEL_ERROR
2175 ,p_module => l_log_module);
2176 END IF;
2177 END IF;
2178 END IF;
2179 --
2180 --
2181 ------------------------------------------------------------------------------------------------
2182 -- 4219869 Business Flow
2183 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
2184 -- Prior Entry. Currently, the following code is always generated.
2185 ------------------------------------------------------------------------------------------------
2186 XLA_AE_LINES_PKG.ValidateCurrentLine;
2187
2188 ------------------------------------------------------------------------------------
2189 -- 4219869 Business Flow
2190 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
2191 ------------------------------------------------------------------------------------
2192 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2193
2194 ----------------------------------------------------------------------------------
2195 -- 4219869 Business Flow
2196 -- Update journal entry status -- Need to generate this within IF <condition>
2197 ----------------------------------------------------------------------------------
2198 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2199 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
2200 ,p_balance_type_code => l_balance_type_code
2201 );
2202
2203 -------------------------------------------------------------------------------------------
2204 -- 4262811 - Generate the Accrual Reversal lines
2208 (g_array_event(p_event_id).array_value_num('header_index'));
2205 -------------------------------------------------------------------------------------------
2206 BEGIN
2207 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
2209 IF l_acc_rev_flag IS NULL THEN
2210 l_acc_rev_flag := 'N';
2211 END IF;
2212 EXCEPTION
2213 WHEN OTHERS THEN
2214 l_acc_rev_flag := 'N';
2215 END;
2216 --
2217 IF (l_acc_rev_flag = 'Y') THEN
2218
2219 -- 4645092 ------------------------------------------------------------------------------
2220 -- To allow MPA report to determine if it should generate report process
2221 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
2222 ------------------------------------------------------------------------------------------
2223
2224 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
2225 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
2226 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
2227 -- call ADRs
2228 -- Bug 4922099
2229 --
2230 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2231 (NVL(l_actual_upg_option, 'N') = 'O') OR
2232 (NVL(l_enc_upg_option, 'N') = 'O')
2233 )
2234 THEN
2235 NULL;
2236 --
2237 --
2238
2239 l_ccid := AcctDerRule_3(
2240 p_application_id => p_application_id
2241 , p_ae_header_id => l_ae_header_id
2242 , p_source_10 => p_source_10
2243 , x_transaction_coa_id => l_adr_transaction_coa_id
2244 , x_accounting_coa_id => l_adr_accounting_coa_id
2245 , x_value_type_code => l_adr_value_type_code
2246 , p_side => 'NA'
2247 );
2248
2249 xla_ae_lines_pkg.set_ccid(
2250 p_code_combination_id => l_ccid
2251 , p_value_type_code => l_adr_value_type_code
2252 , p_transaction_coa_id => l_adr_transaction_coa_id
2253 , p_accounting_coa_id => l_adr_accounting_coa_id
2254 , p_adr_code => 'PN_STANDARD'
2255 , p_adr_type_code => 'S'
2256 , p_component_type => l_component_type
2257 , p_component_code => l_component_code
2258 , p_component_type_code => l_component_type_code
2259 , p_component_appl_id => l_component_appl_id
2260 , p_amb_context_code => l_amb_context_code
2261 , p_side => 'NA'
2262 );
2263
2264
2265 --
2266 --
2267 END IF;
2268
2269 --
2270 -- Update the line information that should be overwritten
2271 --
2272 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
2273 p_header_num => 1);
2274 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
2275
2276 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
2277
2278 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
2279 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
2280 END IF;
2281
2282 --
2283 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
2284 --
2285 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
2286 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
2287 ELSE
2288 ---------------------------------------------------------------------------------------------------
2289 -- 4262811a Switch Sign
2290 ---------------------------------------------------------------------------------------------------
2291 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
2292 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2293 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2294 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2295 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2296 -- 5132302
2297 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
2298 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2299
2300 END IF;
2301
2302 -- 4955764
2303 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2304 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
2305
2306
2307 XLA_AE_LINES_PKG.ValidateCurrentLine;
2308 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2309
2310 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2311 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
2312 ,p_balance_type_code => l_balance_type_code);
2313
2314 END IF;
2315
2316 -----------------------------------------------------------------------------------------
2317 -- 4262811 Multiperiod Accounting
2321
2318 -----------------------------------------------------------------------------------------
2319 -- No MPA option is assigned.
2320
2322 END IF;
2323 END IF;
2324 --
2325
2326 --
2327 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2328 trace
2329 (p_msg => 'END of AcctLineType_6'
2330 ,p_level => C_LEVEL_PROCEDURE
2331 ,p_module => l_log_module);
2332 END IF;
2333 --
2334 EXCEPTION
2335 WHEN xla_exceptions_pkg.application_exception THEN
2336 RAISE;
2337 WHEN OTHERS THEN
2338 xla_exceptions_pkg.raise_message
2339 (p_location => 'XLA_00240_AAD_S_000003_PKG.AcctLineType_6');
2340 END AcctLineType_6;
2341 --
2342
2343 ---------------------------------------
2344 --
2345 -- PRIVATE FUNCTION
2346 -- AcctLineType_7
2347 --
2348 ---------------------------------------
2349 PROCEDURE AcctLineType_7 (
2350 p_application_id IN NUMBER
2351 ,p_event_id IN NUMBER
2352 ,p_calculate_acctd_flag IN VARCHAR2
2353 ,p_calculate_g_l_flag IN VARCHAR2
2354 ,p_actual_flag IN OUT VARCHAR2
2355 ,p_balance_type_code OUT VARCHAR2
2356 ,p_gain_or_loss_ref OUT VARCHAR2
2357
2358 --Payment / Billing Purpose
2359 , p_source_3 IN VARCHAR2
2360 --Payment / BillingType
2361 , p_source_4 IN VARCHAR2
2362 --Location Code
2363 , p_source_5 IN VARCHAR2
2364 --Lease Number
2365 , p_source_6 IN VARCHAR2
2366 --Property Code
2367 , p_source_7 IN VARCHAR2
2368 --Customer Name
2369 , p_source_8 IN VARCHAR2
2370 --Customer Site
2371 , p_source_9 IN VARCHAR2
2372 --Code Combination Identifier
2373 , p_source_10 IN NUMBER
2374 --Distribution Type
2375 , p_source_11 IN VARCHAR2
2376 --Payment / Billing Item Identifier
2377 , p_source_12 IN NUMBER
2378 --Entered Amount
2379 , p_source_13 IN NUMBER
2380 --Currency Code
2381 , p_source_14 IN VARCHAR2
2382 --Conversion Date
2383 , p_source_15 IN DATE
2384 --Conversion Rate
2385 , p_source_16 IN NUMBER
2386 --Conversion Rate Type
2387 , p_source_17 IN VARCHAR2
2388 --Accounted Amount
2389 , p_source_18 IN NUMBER
2390 )
2391 IS
2392
2393 l_component_type VARCHAR2(80);
2394 l_component_code VARCHAR2(30);
2395 l_component_type_code VARCHAR2(1);
2396 l_component_appl_id INTEGER;
2397 l_amb_context_code VARCHAR2(30);
2398 l_entity_code VARCHAR2(30);
2399 l_event_class_code VARCHAR2(30);
2400 l_ae_header_id NUMBER;
2401 l_event_type_code VARCHAR2(30);
2402 l_line_definition_code VARCHAR2(30);
2403 l_line_definition_owner_code VARCHAR2(1);
2404 --
2405 -- adr variables
2406 l_segment VARCHAR2(30);
2407 l_ccid NUMBER;
2408 l_adr_transaction_coa_id NUMBER;
2409 l_adr_accounting_coa_id NUMBER;
2410 l_adr_flexfield_segment_code VARCHAR2(30);
2411 l_adr_flex_value_set_id NUMBER;
2412 l_adr_value_type_code VARCHAR2(30);
2413 l_adr_value_combination_id NUMBER;
2414 l_adr_value_segment_code VARCHAR2(30);
2415
2416 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
2417 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
2418 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
2419 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
2420
2421 -- 4262811 Variables ------------------------------------------------------------------------------------------
2422 l_entered_amt_idx NUMBER;
2423 l_accted_amt_idx NUMBER;
2424 l_acc_rev_flag VARCHAR2(1);
2425 l_accrual_line_num NUMBER;
2426 l_tmp_amt NUMBER;
2427 l_acc_rev_natural_side_code VARCHAR2(1);
2428
2429 l_num_entries NUMBER;
2430 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
2431 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
2432 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
2433 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
2434 l_recog_line_1 NUMBER;
2435 l_recog_line_2 NUMBER;
2436
2437 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
2438 l_bflow_applied_to_amt NUMBER; -- 5132302
2439 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
2440
2441 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
2442
2443 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
2444 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
2445
2446 ---------------------------------------------------------------------------------------------------------------
2447
2448
2449 --
2450 -- bulk performance
2451 --
2452 l_balance_type_code VARCHAR2(1);
2453 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
2454 l_log_module VARCHAR2(240);
2455
2459 l_actual_upg_option VARCHAR2(1);
2456 --
2457 -- Upgrade strategy
2458 --
2460 l_enc_upg_option VARCHAR2(1);
2461
2462 --
2463 BEGIN
2464 --
2465 IF g_log_enabled THEN
2466 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_7';
2467 END IF;
2468 --
2469 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2470
2471 trace
2472 (p_msg => 'BEGIN of AcctLineType_7'
2473 ,p_level => C_LEVEL_PROCEDURE
2474 ,p_module => l_log_module);
2475
2476 END IF;
2477 --
2478 l_component_type := 'AMB_JLT';
2479 l_component_code := 'PN_REV';
2480 l_component_type_code := 'S';
2481 l_component_appl_id := 240;
2482 l_amb_context_code := 'DEFAULT';
2483 l_entity_code := 'TRANSACTION';
2484 l_event_class_code := 'LEASE_REVENUE';
2485 l_event_type_code := 'LEASE_REVENUE_TRANSFER';
2486 l_line_definition_owner_code := 'S';
2487 l_line_definition_code := 'PN_LEASE_REVENUE';
2488 --
2489 l_balance_type_code := 'A';
2490 l_segment := NULL;
2491 l_ccid := NULL;
2492 l_adr_transaction_coa_id := NULL;
2493 l_adr_accounting_coa_id := NULL;
2494 l_adr_flexfield_segment_code := NULL;
2495 l_adr_flex_value_set_id := NULL;
2496 l_adr_value_type_code := NULL;
2497 l_adr_value_combination_id := NULL;
2498 l_adr_value_segment_code := NULL;
2499
2500 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
2501 l_bflow_class_code := ''; -- 4219869 Business Flow
2502 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
2503 l_budgetary_control_flag := 'N';
2504
2505 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2506 l_bflow_applied_to_amt := NULL; -- 5132302
2507 l_entered_amt_idx := NULL; -- 4262811
2508 l_accted_amt_idx := NULL; -- 4262811
2509 l_acc_rev_flag := NULL; -- 4262811
2510 l_accrual_line_num := NULL; -- 4262811
2511 l_tmp_amt := NULL; -- 4262811
2512 --
2513
2514 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
2515 l_balance_type_code <> 'B' THEN
2516 IF NVL(p_source_11,'
2517 ') = 'REV'
2518 THEN
2519
2520 --
2521 XLA_AE_LINES_PKG.SetNewLine;
2522
2523 p_balance_type_code := l_balance_type_code;
2524 -- set the flag so later we will know whether the gain loss line needs to be created
2525
2526 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
2527 p_actual_flag :='A';
2528 END IF;
2529
2530 --
2531 -- bulk performance
2532 --
2533 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
2534 p_header_num => 0); -- 4262811
2535 --
2536 -- set accounting line options
2537 --
2538 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
2539 p_natural_side_code => 'C'
2540 , p_gain_or_loss_flag => 'N'
2541 , p_gl_transfer_mode_code => 'D'
2542 , p_acct_entry_type_code => 'A'
2543 , p_switch_side_flag => 'Y'
2544 , p_merge_duplicate_code => 'N'
2545 );
2546 --
2547 l_acc_rev_natural_side_code := 'D'; -- 4262811
2548 --
2549 --
2550 -- set accounting line type info
2551 --
2552 xla_ae_lines_pkg.SetAcctLineType
2553 (p_component_type => l_component_type
2554 ,p_event_type_code => l_event_type_code
2555 ,p_line_definition_owner_code => l_line_definition_owner_code
2556 ,p_line_definition_code => l_line_definition_code
2557 ,p_accounting_line_code => l_component_code
2558 ,p_accounting_line_type_code => l_component_type_code
2559 ,p_accounting_line_appl_id => l_component_appl_id
2560 ,p_amb_context_code => l_amb_context_code
2561 ,p_entity_code => l_entity_code
2562 ,p_event_class_code => l_event_class_code);
2563 --
2564 -- set accounting class
2565 --
2566 xla_ae_lines_pkg.SetAcctClass(
2567 p_accounting_class_code => 'REVENUE'
2568 , p_ae_header_id => l_ae_header_id
2569 );
2570
2571 --
2572 -- set rounding class
2573 --
2574 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
2575 'REVENUE';
2576
2577 --
2578 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
2579 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
2580 --
2581 -- bulk performance
2582 --
2583 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
2584
2585 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
2586 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
2587
2588 -- 4955764
2589 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2590 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
2591
2592 -- 4458381 Public Sector Enh
2593
2594 --
2598 l_accted_amt_idx := 8;
2595 -- set accounting attributes for the line type
2596 --
2597 l_entered_amt_idx := 3;
2599 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2600 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
2601 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_12);
2602 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
2603 l_rec_acct_attrs.array_char_value(2) := p_source_11;
2604 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
2605 l_rec_acct_attrs.array_num_value(3) := p_source_13;
2606 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
2607 l_rec_acct_attrs.array_char_value(4) := p_source_14;
2608 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
2609 l_rec_acct_attrs.array_date_value(5) := p_source_15;
2610 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
2611 l_rec_acct_attrs.array_num_value(6) := p_source_16;
2612 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
2613 l_rec_acct_attrs.array_char_value(7) := p_source_17;
2614 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
2615 l_rec_acct_attrs.array_num_value(8) := p_source_18;
2616
2617 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
2618 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
2619
2620 ---------------------------------------------------------------------------------------------------------------
2621 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
2622 ---------------------------------------------------------------------------------------------------------------
2623 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
2624
2625 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2626 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2627
2628 IF xla_accounting_cache_pkg.GetValueChar
2629 (p_source_code => 'LEDGER_CATEGORY_CODE'
2630 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
2631 AND l_bflow_method_code = 'PRIOR_ENTRY'
2632 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
2633 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
2634 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
2635 )
2636 THEN
2637 xla_ae_lines_pkg.BflowUpgEntry
2638 (p_business_method_code => l_bflow_method_code
2639 ,p_business_class_code => l_bflow_class_code
2640 ,p_balance_type => l_balance_type_code);
2641 ELSE
2642 NULL;
2643 -- No business flow processing for business flow method of NONE.
2644 END IF;
2645
2646 --
2647 -- call analytical criteria
2648 --
2649
2650 --
2651 -- call description
2652 --
2653
2654 xla_ae_lines_pkg.SetLineDescription(
2655 p_ae_header_id => l_ae_header_id
2656 ,p_description => Description_2 (
2657 p_application_id => p_application_id
2658 , p_ae_header_id => l_ae_header_id
2659 , p_source_3 => p_source_3
2660 , p_source_4 => p_source_4
2661 , p_source_5 => p_source_5
2662 , p_source_6 => p_source_6
2663 , p_source_7 => p_source_7
2664 , p_source_8 => p_source_8
2665 , p_source_9 => p_source_9
2666 )
2667 );
2668
2669
2670 --
2671 -- call ADRs
2672 -- Bug 4922099
2673 --
2674 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2675 (NVL(l_actual_upg_option, 'N') = 'O') OR
2676 (NVL(l_enc_upg_option, 'N') = 'O')
2677 )
2678 THEN
2679 NULL;
2680 --
2681 --
2682
2683 l_ccid := AcctDerRule_3(
2684 p_application_id => p_application_id
2685 , p_ae_header_id => l_ae_header_id
2686 , p_source_10 => p_source_10
2687 , x_transaction_coa_id => l_adr_transaction_coa_id
2688 , x_accounting_coa_id => l_adr_accounting_coa_id
2689 , x_value_type_code => l_adr_value_type_code
2690 , p_side => 'NA'
2691 );
2692
2693 xla_ae_lines_pkg.set_ccid(
2694 p_code_combination_id => l_ccid
2695 , p_value_type_code => l_adr_value_type_code
2696 , p_transaction_coa_id => l_adr_transaction_coa_id
2697 , p_accounting_coa_id => l_adr_accounting_coa_id
2698 , p_adr_code => 'PN_STANDARD'
2699 , p_adr_type_code => 'S'
2700 , p_component_type => l_component_type
2701 , p_component_code => l_component_code
2702 , p_component_type_code => l_component_type_code
2703 , p_component_appl_id => l_component_appl_id
2704 , p_amb_context_code => l_amb_context_code
2705 , p_side => 'NA'
2706 );
2707
2708
2709 --
2710 --
2711 END IF;
2712 --
2713 -- Bug 4922099
2714 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
2715 (NVL(l_enc_upg_option, 'N') = 'O')
2716 ) AND
2717 (l_bflow_method_code = 'PRIOR_ENTRY')
2718 )
2719 THEN
2720 IF
2721 --
2725 xla_accounting_err_pkg.build_message
2722 1 = 2
2723 --
2724 THEN
2726 (p_appli_s_name => 'XLA'
2727 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2728 ,p_token_1 => 'LINE_NUMBER'
2729 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
2730 ,p_token_2 => 'LINE_TYPE_NAME'
2731 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
2732 l_component_type
2733 ,l_component_code
2734 ,l_component_type_code
2735 ,l_component_appl_id
2736 ,l_amb_context_code
2737 ,l_entity_code
2738 ,l_event_class_code
2739 )
2740 ,p_token_3 => 'OWNER'
2741 ,p_value_3 => xla_lookups_pkg.get_meaning(
2742 p_lookup_type => 'XLA_OWNER_TYPE'
2743 ,p_lookup_code => l_component_type_code
2744 )
2745 ,p_token_4 => 'PRODUCT_NAME'
2746 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
2747 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
2748 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
2749 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
2750 ,p_ae_header_id => NULL
2751 );
2752
2753 IF (C_LEVEL_ERROR>= g_log_level) THEN
2754 trace
2755 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2756 ,p_level => C_LEVEL_ERROR
2757 ,p_module => l_log_module);
2758 END IF;
2759 END IF;
2760 END IF;
2761 --
2762 --
2763 ------------------------------------------------------------------------------------------------
2764 -- 4219869 Business Flow
2765 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
2766 -- Prior Entry. Currently, the following code is always generated.
2767 ------------------------------------------------------------------------------------------------
2768 XLA_AE_LINES_PKG.ValidateCurrentLine;
2769
2770 ------------------------------------------------------------------------------------
2771 -- 4219869 Business Flow
2772 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
2773 ------------------------------------------------------------------------------------
2774 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2775
2776 ----------------------------------------------------------------------------------
2777 -- 4219869 Business Flow
2778 -- Update journal entry status -- Need to generate this within IF <condition>
2779 ----------------------------------------------------------------------------------
2780 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2781 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
2782 ,p_balance_type_code => l_balance_type_code
2783 );
2784
2785 -------------------------------------------------------------------------------------------
2786 -- 4262811 - Generate the Accrual Reversal lines
2787 -------------------------------------------------------------------------------------------
2788 BEGIN
2789 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
2790 (g_array_event(p_event_id).array_value_num('header_index'));
2791 IF l_acc_rev_flag IS NULL THEN
2792 l_acc_rev_flag := 'N';
2793 END IF;
2794 EXCEPTION
2795 WHEN OTHERS THEN
2796 l_acc_rev_flag := 'N';
2797 END;
2798 --
2799 IF (l_acc_rev_flag = 'Y') THEN
2800
2801 -- 4645092 ------------------------------------------------------------------------------
2802 -- To allow MPA report to determine if it should generate report process
2803 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
2804 ------------------------------------------------------------------------------------------
2805
2806 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
2807 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
2808 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
2809 -- call ADRs
2810 -- Bug 4922099
2811 --
2815 )
2812 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2813 (NVL(l_actual_upg_option, 'N') = 'O') OR
2814 (NVL(l_enc_upg_option, 'N') = 'O')
2816 THEN
2817 NULL;
2818 --
2819 --
2820
2821 l_ccid := AcctDerRule_3(
2822 p_application_id => p_application_id
2823 , p_ae_header_id => l_ae_header_id
2824 , p_source_10 => p_source_10
2825 , x_transaction_coa_id => l_adr_transaction_coa_id
2826 , x_accounting_coa_id => l_adr_accounting_coa_id
2827 , x_value_type_code => l_adr_value_type_code
2828 , p_side => 'NA'
2829 );
2830
2831 xla_ae_lines_pkg.set_ccid(
2832 p_code_combination_id => l_ccid
2833 , p_value_type_code => l_adr_value_type_code
2834 , p_transaction_coa_id => l_adr_transaction_coa_id
2835 , p_accounting_coa_id => l_adr_accounting_coa_id
2836 , p_adr_code => 'PN_STANDARD'
2837 , p_adr_type_code => 'S'
2838 , p_component_type => l_component_type
2839 , p_component_code => l_component_code
2840 , p_component_type_code => l_component_type_code
2841 , p_component_appl_id => l_component_appl_id
2842 , p_amb_context_code => l_amb_context_code
2843 , p_side => 'NA'
2844 );
2845
2846
2847 --
2848 --
2849 END IF;
2850
2851 --
2852 -- Update the line information that should be overwritten
2853 --
2854 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
2855 p_header_num => 1);
2856 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
2857
2858 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
2859
2860 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
2861 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
2862 END IF;
2863
2864 --
2865 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
2866 --
2867 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
2868 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
2869 ELSE
2870 ---------------------------------------------------------------------------------------------------
2871 -- 4262811a Switch Sign
2872 ---------------------------------------------------------------------------------------------------
2873 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
2874 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2875 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2876 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2877 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2878 -- 5132302
2879 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
2880 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2881
2882 END IF;
2883
2884 -- 4955764
2885 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2886 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
2887
2888
2889 XLA_AE_LINES_PKG.ValidateCurrentLine;
2890 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2891
2892 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2893 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
2894 ,p_balance_type_code => l_balance_type_code);
2895
2896 END IF;
2897
2898 -----------------------------------------------------------------------------------------
2899 -- 4262811 Multiperiod Accounting
2900 -----------------------------------------------------------------------------------------
2901 -- No MPA option is assigned.
2902
2903
2904 END IF;
2905 END IF;
2906 --
2907
2908 --
2909 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2910 trace
2911 (p_msg => 'END of AcctLineType_7'
2912 ,p_level => C_LEVEL_PROCEDURE
2913 ,p_module => l_log_module);
2914 END IF;
2915 --
2916 EXCEPTION
2917 WHEN xla_exceptions_pkg.application_exception THEN
2918 RAISE;
2919 WHEN OTHERS THEN
2920 xla_exceptions_pkg.raise_message
2921 (p_location => 'XLA_00240_AAD_S_000003_PKG.AcctLineType_7');
2922 END AcctLineType_7;
2923 --
2924
2925 ---------------------------------------
2926 --
2927 -- PRIVATE PROCEDURE
2928 -- insert_sources_8
2929 --
2930 ----------------------------------------
2931 --
2932 PROCEDURE insert_sources_8(
2933 p_target_ledger_id IN NUMBER
2934 , p_language IN VARCHAR2
2938 )
2935 , p_sla_ledger_id IN NUMBER
2936 , p_pad_start_date IN DATE
2937 , p_pad_end_date IN DATE
2939 IS
2940
2941 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'LEASE_EXPENSE_TRANSFER';
2942 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'LEASE_EXPENSE';
2943 p_apps_owner VARCHAR2(30);
2944 l_log_module VARCHAR2(240);
2945 BEGIN
2946 IF g_log_enabled THEN
2947 l_log_module := C_DEFAULT_MODULE||'.insert_sources_8';
2948 END IF;
2949 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2950
2951 trace
2952 (p_msg => 'BEGIN of insert_sources_8'
2953 ,p_level => C_LEVEL_PROCEDURE
2954 ,p_module => l_log_module);
2955
2956 END IF;
2957
2958 -- select APPS owner
2959 SELECT oracle_username
2960 INTO p_apps_owner
2961 FROM fnd_oracle_userid
2962 WHERE read_only_flag = 'U'
2963 ;
2964
2965 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2966 trace
2967 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
2968 ' - p_language = '||p_language||
2969 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
2970 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
2971 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
2972 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
2973 ,p_level => C_LEVEL_STATEMENT
2974 ,p_module => l_log_module);
2975 END IF;
2976
2977
2978 --
2979 INSERT INTO xla_diag_sources --hdr1
2980 (
2981 event_id
2982 , ledger_id
2983 , sla_ledger_id
2984 , description_language
2985 , object_name
2986 , object_type_code
2987 , line_number
2988 , source_application_id
2989 , source_type_code
2990 , source_code
2991 , source_value
2992 , source_meaning
2993 , created_by
2994 , creation_date
2995 , last_update_date
2996 , last_updated_by
2997 , last_update_login
2998 , program_update_date
2999 , program_application_id
3000 , program_id
3001 , request_id
3002 )
3003 SELECT
3004 event_id
3005 , p_target_ledger_id
3006 , p_sla_ledger_id
3007 , p_language
3008 , object_name
3009 , object_type_code
3010 , line_number
3011 , source_application_id
3012 , source_type_code
3013 , source_code
3014 , SUBSTR(source_value ,1,1996)
3015 , SUBSTR(source_meaning,1,200)
3016 , xla_environment_pkg.g_Usr_Id
3017 , TRUNC(SYSDATE)
3018 , TRUNC(SYSDATE)
3019 , xla_environment_pkg.g_Usr_Id
3020 , xla_environment_pkg.g_Login_Id
3021 , TRUNC(SYSDATE)
3022 , xla_environment_pkg.g_Prog_Appl_Id
3023 , xla_environment_pkg.g_Prog_Id
3024 , xla_environment_pkg.g_Req_Id
3025 FROM (
3026 SELECT xet.event_id event_id
3027 , 0 line_number
3028 , CASE r
3029 WHEN 1 THEN 'PN_XLA_EXTRACT_HEADERS_V'
3030 WHEN 2 THEN 'PN_XLA_EXTRACT_HEADERS_V'
3031 WHEN 3 THEN 'PN_XLA_EXTRACT_HEADERS_V'
3032 WHEN 4 THEN 'PN_XLA_EXTRACT_HEADERS_V'
3033 WHEN 5 THEN 'PN_XLA_EXTRACT_HEADERS_V'
3034 WHEN 6 THEN 'PN_XLA_EXTRACT_HEADERS_V'
3035 WHEN 7 THEN 'PN_XLA_EXTRACT_HEADERS_V'
3036 WHEN 8 THEN 'PN_XLA_EXTRACT_HEADERS_V'
3037
3038 ELSE null
3039 END object_name
3040 , CASE r
3041 WHEN 1 THEN 'HEADER'
3042 WHEN 2 THEN 'HEADER'
3043 WHEN 3 THEN 'HEADER'
3044 WHEN 4 THEN 'HEADER'
3045 WHEN 5 THEN 'HEADER'
3046 WHEN 6 THEN 'HEADER'
3047 WHEN 7 THEN 'HEADER'
3048 WHEN 8 THEN 'HEADER'
3049
3050 ELSE null
3051 END object_type_code
3052 , CASE r
3053 WHEN 1 THEN '240'
3054 WHEN 2 THEN '240'
3055 WHEN 3 THEN '240'
3056 WHEN 4 THEN '240'
3057 WHEN 5 THEN '240'
3058 WHEN 6 THEN '240'
3059 WHEN 7 THEN '240'
3060 WHEN 8 THEN '240'
3061
3062 ELSE null
3063 END source_application_id
3064 , 'S' source_type_code
3065 , CASE r
3066 WHEN 1 THEN 'SUPPLIER_NAME'
3067 WHEN 2 THEN 'SUPPLIER_SITE'
3068 WHEN 3 THEN 'PAYMENT_PURPOSE'
3069 WHEN 4 THEN 'PAYMENT_TYPE'
3070 WHEN 5 THEN 'LOCATION_CODE'
3071 WHEN 6 THEN 'LEASE_NUMBER'
3072 WHEN 7 THEN 'PROPERTY_CODE'
3073 WHEN 8 THEN 'PAYMENT_ITEM_ID'
3074
3075 ELSE null
3076 END source_code
3077 , CASE r
3078 WHEN 1 THEN TO_CHAR(h1.SUPPLIER_NAME)
3082 WHEN 5 THEN TO_CHAR(h1.LOCATION_CODE)
3079 WHEN 2 THEN TO_CHAR(h1.SUPPLIER_SITE)
3080 WHEN 3 THEN TO_CHAR(h1.PAYMENT_PURPOSE)
3081 WHEN 4 THEN TO_CHAR(h1.PAYMENT_TYPE)
3083 WHEN 6 THEN TO_CHAR(h1.LEASE_NUMBER)
3084 WHEN 7 THEN TO_CHAR(h1.PROPERTY_CODE)
3085 WHEN 8 THEN TO_CHAR(h1.PAYMENT_ITEM_ID)
3086
3087 ELSE null
3088 END source_value
3089 , null source_meaning
3090 FROM xla_events_gt xet
3091 , PN_XLA_EXTRACT_HEADERS_V h1
3092 ,(select rownum r from all_objects where rownum <= 8 and owner = p_apps_owner)
3093 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
3094 AND xet.event_type_code = C_EVENT_TYPE_CODE
3095 AND h1.event_id = xet.event_id
3096
3097 )
3098 ;
3099 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3100
3101 trace
3102 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
3103 ,p_level => C_LEVEL_STATEMENT
3104 ,p_module => l_log_module);
3105
3106 END IF;
3107 --
3108
3109
3110
3111 --
3112 INSERT INTO xla_diag_sources --line1
3113 (
3114 event_id
3115 , ledger_id
3116 , sla_ledger_id
3117 , description_language
3118 , object_name
3119 , object_type_code
3120 , line_number
3121 , source_application_id
3122 , source_type_code
3123 , source_code
3124 , source_value
3125 , source_meaning
3126 , created_by
3127 , creation_date
3128 , last_update_date
3129 , last_updated_by
3130 , last_update_login
3131 , program_update_date
3132 , program_application_id
3133 , program_id
3134 , request_id
3135 )
3136 SELECT event_id
3137 , p_target_ledger_id
3138 , p_sla_ledger_id
3139 , p_language
3140 , object_name
3141 , object_type_code
3142 , line_number
3143 , source_application_id
3144 , source_type_code
3145 , source_code
3146 , SUBSTR(source_value,1,1996)
3147 , SUBSTR(source_meaning,1,200)
3148 , xla_environment_pkg.g_Usr_Id
3149 , TRUNC(SYSDATE)
3150 , TRUNC(SYSDATE)
3151 , xla_environment_pkg.g_Usr_Id
3152 , xla_environment_pkg.g_Login_Id
3153 , TRUNC(SYSDATE)
3154 , xla_environment_pkg.g_Prog_Appl_Id
3155 , xla_environment_pkg.g_Prog_Id
3156 , xla_environment_pkg.g_Req_Id
3157 FROM (
3158 SELECT xet.event_id event_id
3159 , l2.line_number line_number
3160 , CASE r
3161 WHEN 1 THEN 'PN_XLA_EXTRACT_LINES_V'
3162 WHEN 2 THEN 'PN_XLA_EXTRACT_LINES_V'
3163 WHEN 3 THEN 'PN_XLA_EXTRACT_LINES_V'
3164 WHEN 4 THEN 'PN_XLA_EXTRACT_LINES_V'
3165 WHEN 5 THEN 'PN_XLA_EXTRACT_LINES_V'
3166 WHEN 6 THEN 'PN_XLA_EXTRACT_LINES_V'
3167 WHEN 7 THEN 'PN_XLA_EXTRACT_LINES_V'
3168 WHEN 8 THEN 'PN_XLA_EXTRACT_LINES_V'
3169
3170 ELSE null
3171 END object_name
3172 , CASE r
3173 WHEN 1 THEN 'LINE'
3174 WHEN 2 THEN 'LINE'
3175 WHEN 3 THEN 'LINE'
3176 WHEN 4 THEN 'LINE'
3177 WHEN 5 THEN 'LINE'
3178 WHEN 6 THEN 'LINE'
3179 WHEN 7 THEN 'LINE'
3180 WHEN 8 THEN 'LINE'
3181
3182 ELSE null
3183 END object_type_code
3184 , CASE r
3185 WHEN 1 THEN '240'
3186 WHEN 2 THEN '240'
3187 WHEN 3 THEN '240'
3188 WHEN 4 THEN '240'
3189 WHEN 5 THEN '240'
3190 WHEN 6 THEN '240'
3191 WHEN 7 THEN '240'
3192 WHEN 8 THEN '240'
3193
3194 ELSE null
3195 END source_application_id
3196 , 'S' source_type_code
3197 , CASE r
3198 WHEN 1 THEN 'CODE_COMBINATION_ID'
3199 WHEN 2 THEN 'DISTRIBUTION_TYPE'
3200 WHEN 3 THEN 'ENTERED_AMOUNT'
3201 WHEN 4 THEN 'CURRENCY_CODE'
3202 WHEN 5 THEN 'CONVERSION_DATE'
3203 WHEN 6 THEN 'CONVERSION_RATE'
3204 WHEN 7 THEN 'CONVERSION_RATE_TYPE'
3205 WHEN 8 THEN 'ACCOUNTED_AMOUNT'
3206
3207 ELSE null
3208 END source_code
3209 , CASE r
3210 WHEN 1 THEN TO_CHAR(l2.CODE_COMBINATION_ID)
3211 WHEN 2 THEN TO_CHAR(l2.DISTRIBUTION_TYPE)
3212 WHEN 3 THEN TO_CHAR(l2.ENTERED_AMOUNT)
3213 WHEN 4 THEN TO_CHAR(l2.CURRENCY_CODE)
3214 WHEN 5 THEN TO_CHAR(l2.CONVERSION_DATE)
3215 WHEN 6 THEN TO_CHAR(l2.CONVERSION_RATE)
3216 WHEN 7 THEN TO_CHAR(l2.CONVERSION_RATE_TYPE)
3220 END source_value
3217 WHEN 8 THEN TO_CHAR(l2.ACCOUNTED_AMOUNT)
3218
3219 ELSE null
3221 , null source_meaning
3222 FROM xla_events_gt xet
3223 , PN_XLA_EXTRACT_LINES_V l2
3224 ,(select rownum r from all_objects where rownum <= 8 and owner = p_apps_owner)
3225 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
3226 AND xet.event_type_code = C_EVENT_TYPE_CODE
3227 AND l2.event_id = xet.event_id
3228 AND l2.ledger_id (+) = p_sla_ledger_id
3229
3230 )
3231 ;
3232 --
3233 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3234
3235 trace
3236 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
3237 ,p_level => C_LEVEL_STATEMENT
3238 ,p_module => l_log_module);
3239
3240 END IF;
3241
3242
3243 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3244 trace
3245 (p_msg => 'END of insert_sources_8'
3246 ,p_level => C_LEVEL_PROCEDURE
3247 ,p_module => l_log_module);
3248 END IF;
3249 EXCEPTION
3250 WHEN xla_exceptions_pkg.application_exception THEN
3251 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3252 trace
3253 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
3254 ,p_level => C_LEVEL_EXCEPTION
3255 ,p_module => l_log_module);
3256 END IF;
3257 RAISE;
3258 WHEN OTHERS THEN
3259 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3260 trace
3261 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
3262 ,p_level => C_LEVEL_EXCEPTION
3263 ,p_module => l_log_module);
3264 END IF;
3265 xla_exceptions_pkg.raise_message
3266 (p_location => 'XLA_00240_AAD_S_000003_PKG.insert_sources_8');
3267 END insert_sources_8;
3268 --
3269
3270 ---------------------------------------
3271 --
3272 -- PRIVATE FUNCTION
3273 -- EventType_8
3274 --
3275 ----------------------------------------
3276 --
3277 FUNCTION EventType_8
3278 (p_application_id IN NUMBER
3279 ,p_base_ledger_id IN NUMBER
3280 ,p_target_ledger_id IN NUMBER
3281 ,p_language IN VARCHAR2
3282 ,p_currency_code IN VARCHAR2
3283 ,p_sla_ledger_id IN NUMBER
3284 ,p_pad_start_date IN DATE
3285 ,p_pad_end_date IN DATE
3286 ,p_primary_ledger_id IN NUMBER)
3287 RETURN BOOLEAN IS
3288 --
3289 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'LEASE_EXPENSE_TRANSFER';
3290 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'LEASE_EXPENSE';
3291
3292 l_calculate_acctd_flag VARCHAR2(1) :='N';
3293 l_calculate_g_l_flag VARCHAR2(1) :='N';
3294 --
3295 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
3296 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
3297 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
3298 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
3299 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
3300 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
3301 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
3302 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
3303 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
3304 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
3305 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
3306 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
3307 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
3308 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
3309 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
3310 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
3311 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
3312 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
3313 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
3314 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
3315 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
3316 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
3317 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
3318 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
3319 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
3320 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
3321
3322 l_event_id NUMBER;
3323 l_previous_event_id NUMBER;
3324 l_first_event_id NUMBER;
3325 l_last_event_id NUMBER;
3326
3327 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
3328 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
3329 --
3330 --
3331 l_result BOOLEAN := TRUE;
3332 l_rows NUMBER := 1000;
3333 l_event_type_name VARCHAR2(80) := 'Lease Expense Item Transfer';
3337 l_ae_header_id NUMBER;
3334 l_event_class_name VARCHAR2(80) := 'Lease Expense';
3335 l_description VARCHAR2(4000);
3336 l_transaction_reversal NUMBER;
3338 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
3339 l_log_module VARCHAR2(240);
3340 --
3341 l_acct_reversal_source VARCHAR2(30);
3342 l_trx_reversal_source VARCHAR2(30);
3343
3344 l_continue_with_lines BOOLEAN := TRUE;
3345 --
3346 l_acc_rev_gl_date_source DATE; -- 4262811
3347 --
3348 type t_array_event_id is table of number index by binary_integer;
3349
3350 l_rec_array_event t_rec_array_event;
3351 l_null_rec_array_event t_rec_array_event;
3352 l_array_ae_header_id xla_number_array_type;
3353 l_actual_flag VARCHAR2(1) := NULL;
3354 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
3355 l_balance_type_code VARCHAR2(1) :=NULL;
3356 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
3357
3358 --
3359 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
3360 --
3361
3362 TYPE t_array_source_1 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.SUPPLIER_NAME%TYPE INDEX BY BINARY_INTEGER;
3363 TYPE t_array_source_2 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.SUPPLIER_SITE%TYPE INDEX BY BINARY_INTEGER;
3364 TYPE t_array_source_3 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.PAYMENT_PURPOSE%TYPE INDEX BY BINARY_INTEGER;
3365 TYPE t_array_source_4 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.PAYMENT_TYPE%TYPE INDEX BY BINARY_INTEGER;
3366 TYPE t_array_source_5 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.LOCATION_CODE%TYPE INDEX BY BINARY_INTEGER;
3367 TYPE t_array_source_6 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.LEASE_NUMBER%TYPE INDEX BY BINARY_INTEGER;
3368 TYPE t_array_source_7 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.PROPERTY_CODE%TYPE INDEX BY BINARY_INTEGER;
3369 TYPE t_array_source_12 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.PAYMENT_ITEM_ID%TYPE INDEX BY BINARY_INTEGER;
3370
3371 TYPE t_array_source_10 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
3372 TYPE t_array_source_11 IS TABLE OF PN_XLA_EXTRACT_LINES_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
3373 TYPE t_array_source_13 IS TABLE OF PN_XLA_EXTRACT_LINES_V.ENTERED_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
3374 TYPE t_array_source_14 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
3375 TYPE t_array_source_15 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
3376 TYPE t_array_source_16 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
3377 TYPE t_array_source_17 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CONVERSION_RATE_TYPE%TYPE INDEX BY BINARY_INTEGER;
3378 TYPE t_array_source_18 IS TABLE OF PN_XLA_EXTRACT_LINES_V.ACCOUNTED_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
3379
3380 l_array_source_1 t_array_source_1;
3381 l_array_source_2 t_array_source_2;
3382 l_array_source_3 t_array_source_3;
3383 l_array_source_4 t_array_source_4;
3384 l_array_source_5 t_array_source_5;
3385 l_array_source_6 t_array_source_6;
3386 l_array_source_7 t_array_source_7;
3387 l_array_source_12 t_array_source_12;
3388
3389 l_array_source_10 t_array_source_10;
3390 l_array_source_11 t_array_source_11;
3391 l_array_source_13 t_array_source_13;
3392 l_array_source_14 t_array_source_14;
3393 l_array_source_15 t_array_source_15;
3394 l_array_source_16 t_array_source_16;
3395 l_array_source_17 t_array_source_17;
3396 l_array_source_18 t_array_source_18;
3397
3398 --
3399 CURSOR header_cur
3400 IS
3401 SELECT /*+ leading(xet) cardinality(xet,1) */
3402 -- Event Type Code: LEASE_EXPENSE_TRANSFER
3403 -- Event Class Code: LEASE_EXPENSE
3404 xet.entity_id
3405 , xet.legal_entity_id
3406 , xet.entity_code
3407 , xet.transaction_number
3408 , xet.event_id
3409 , xet.event_class_code
3410 , xet.event_type_code
3411 , xet.event_number
3412 , xet.event_date
3413 , xet.transaction_date
3414 , xet.reference_num_1
3415 , xet.reference_num_2
3416 , xet.reference_num_3
3417 , xet.reference_num_4
3418 , xet.reference_char_1
3419 , xet.reference_char_2
3420 , xet.reference_char_3
3421 , xet.reference_char_4
3422 , xet.reference_date_1
3423 , xet.reference_date_2
3424 , xet.reference_date_3
3425 , xet.reference_date_4
3426 , xet.event_created_by
3427 , xet.budgetary_control_flag
3428 , h1.SUPPLIER_NAME source_1
3429 , h1.SUPPLIER_SITE source_2
3430 , h1.PAYMENT_PURPOSE source_3
3431 , h1.PAYMENT_TYPE source_4
3432 , h1.LOCATION_CODE source_5
3433 , h1.LEASE_NUMBER source_6
3434 , h1.PROPERTY_CODE source_7
3435 , h1.PAYMENT_ITEM_ID source_12
3436 FROM xla_events_gt xet
3437 , PN_XLA_EXTRACT_HEADERS_V h1
3438 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
3439 and xet.event_type_code = C_EVENT_TYPE_CODE
3440 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
3441
3442 ORDER BY event_id
3443 ;
3444
3445
3446 --
3447 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
3448 IS
3449 SELECT /*+ leading(xet) cardinality(xet,1) */
3450 -- Event Type Code: LEASE_EXPENSE_TRANSFER
3451 -- Event Class Code: LEASE_EXPENSE
3455 ,xet.transaction_number
3452 xet.entity_id
3453 ,xet.legal_entity_id
3454 ,xet.entity_code
3456 ,xet.event_id
3457 ,xet.event_class_code
3458 ,xet.event_type_code
3459 ,xet.event_number
3460 ,xet.event_date
3461 ,xet.transaction_date
3462 ,xet.reference_num_1
3463 ,xet.reference_num_2
3464 ,xet.reference_num_3
3465 ,xet.reference_num_4
3466 ,xet.reference_char_1
3467 ,xet.reference_char_2
3468 ,xet.reference_char_3
3469 ,xet.reference_char_4
3470 ,xet.reference_date_1
3471 ,xet.reference_date_2
3472 ,xet.reference_date_3
3473 ,xet.reference_date_4
3474 ,xet.event_created_by
3475 ,xet.budgetary_control_flag , l2.LINE_NUMBER
3476 , l2.CODE_COMBINATION_ID source_10
3477 , l2.DISTRIBUTION_TYPE source_11
3478 , l2.ENTERED_AMOUNT source_13
3479 , l2.CURRENCY_CODE source_14
3480 , l2.CONVERSION_DATE source_15
3481 , l2.CONVERSION_RATE source_16
3482 , l2.CONVERSION_RATE_TYPE source_17
3483 , l2.ACCOUNTED_AMOUNT source_18
3484 FROM xla_events_gt xet
3485 , PN_XLA_EXTRACT_LINES_V l2
3486 WHERE xet.event_id between x_first_event_id and x_last_event_id
3487 and xet.event_date between p_pad_start_date and p_pad_end_date
3488 and xet.event_type_code = C_EVENT_TYPE_CODE
3489 and xet.event_status_code <> 'N' AND l2.event_id = xet.event_id
3490 AND l2.ledger_id = p_sla_ledger_id
3491 ;
3492
3493 --
3494 BEGIN
3495 IF g_log_enabled THEN
3496 l_log_module := C_DEFAULT_MODULE||'.EventType_8';
3497 END IF;
3498 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3499 trace
3500 (p_msg => 'BEGIN of EventType_8'
3501 ,p_level => C_LEVEL_PROCEDURE
3502 ,p_module => l_log_module);
3503 END IF;
3504
3505 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3506 trace
3507 (p_msg => 'p_application_id = '||p_application_id||
3508 ' - p_base_ledger_id = '||p_base_ledger_id||
3509 ' - p_target_ledger_id = '||p_target_ledger_id||
3510 ' - p_language = '||p_language||
3511 ' - p_currency_code = '||p_currency_code||
3512 ' - p_sla_ledger_id = '||p_sla_ledger_id
3513 ,p_level => C_LEVEL_STATEMENT
3514 ,p_module => l_log_module);
3515 END IF;
3516 --
3517 -- initialze arrays
3518 --
3519 g_array_event.DELETE;
3520 l_rec_array_event := l_null_rec_array_event;
3521 --
3522 --------------------------------------
3523 -- 4262811 Initialze MPA Line Number
3524 --------------------------------------
3525 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
3526
3527 --
3528
3529 --
3530 OPEN header_cur;
3531 --
3532 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3533 trace
3534 (p_msg => 'SQL - FETCH header_cur'
3535 ,p_level => C_LEVEL_STATEMENT
3536 ,p_module => l_log_module);
3537 END IF;
3538 --
3539 LOOP
3540 FETCH header_cur BULK COLLECT INTO
3541 l_array_entity_id
3542 , l_array_legal_entity_id
3543 , l_array_entity_code
3544 , l_array_transaction_num
3545 , l_array_event_id
3546 , l_array_class_code
3547 , l_array_event_type
3548 , l_array_event_number
3549 , l_array_event_date
3550 , l_array_transaction_date
3551 , l_array_reference_num_1
3552 , l_array_reference_num_2
3553 , l_array_reference_num_3
3554 , l_array_reference_num_4
3555 , l_array_reference_char_1
3556 , l_array_reference_char_2
3557 , l_array_reference_char_3
3558 , l_array_reference_char_4
3559 , l_array_reference_date_1
3560 , l_array_reference_date_2
3561 , l_array_reference_date_3
3562 , l_array_reference_date_4
3563 , l_array_event_created_by
3564 , l_array_budgetary_control_flag
3565 , l_array_source_1
3566 , l_array_source_2
3567 , l_array_source_3
3568 , l_array_source_4
3569 , l_array_source_5
3570 , l_array_source_6
3571 , l_array_source_7
3572 , l_array_source_12
3573 LIMIT l_rows;
3574 --
3575 IF (C_LEVEL_EVENT >= g_log_level) THEN
3576 trace
3577 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
3578 ,p_level => C_LEVEL_EVENT
3579 ,p_module => l_log_module);
3580 END IF;
3581 --
3582 EXIT WHEN l_array_entity_id.COUNT = 0;
3583
3584 -- initialize arrays
3585 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
3586 XLA_AE_LINES_PKG.g_rec_lines := NULL;
3587
3588 --
3589 -- Bug 4458708
3590 --
3591 XLA_AE_LINES_PKG.g_LineNumber := 0;
3592
3593
3594 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
3595 g_last_hdr_idx := l_array_event_id.LAST;
3596 --
3597 -- loop for the headers. Each iteration is for each header extract row
3598 -- fetched in header cursor
3599 --
3600 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
3601
3602 --
3603 -- set event info as cache for other routines to refer event attributes
3604 --
3605 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
3606 (p_application_id => p_application_id
3607 ,p_primary_ledger_id => p_primary_ledger_id
3608 ,p_base_ledger_id => p_base_ledger_id
3612 ,p_entity_code => l_array_entity_code(hdr_idx)
3609 ,p_target_ledger_id => p_target_ledger_id
3610 ,p_entity_id => l_array_entity_id(hdr_idx)
3611 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
3613 ,p_transaction_num => l_array_transaction_num(hdr_idx)
3614 ,p_event_id => l_array_event_id(hdr_idx)
3615 ,p_event_class_code => l_array_class_code(hdr_idx)
3616 ,p_event_type_code => l_array_event_type(hdr_idx)
3617 ,p_event_number => l_array_event_number(hdr_idx)
3618 ,p_event_date => l_array_event_date(hdr_idx)
3619 ,p_transaction_date => l_array_transaction_date(hdr_idx)
3620 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
3621 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
3622 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
3623 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
3624 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
3625 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
3626 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
3627 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
3628 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
3629 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
3630 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
3631 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
3632 ,p_event_created_by => l_array_event_created_by(hdr_idx)
3633 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
3634
3635 --
3636 -- set the status of entry to C_VALID (0)
3637 --
3638 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
3639
3640 --
3641 -- initialize a row for ae header
3642 --
3643 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
3644
3645 l_event_id := l_array_event_id(hdr_idx);
3646
3647 --
3648 -- storing the hdr_idx for event. May be used by line cursor.
3649 --
3650 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
3651
3652 --
3653 -- store sources from header extract. This can be improved to
3654 -- store only those sources from header extract that may be used in lines
3655 --
3656
3657 g_array_event(l_event_id).array_value_char('source_1') := l_array_source_1(hdr_idx);
3658 g_array_event(l_event_id).array_value_char('source_2') := l_array_source_2(hdr_idx);
3659 g_array_event(l_event_id).array_value_char('source_3') := l_array_source_3(hdr_idx);
3660 g_array_event(l_event_id).array_value_char('source_4') := l_array_source_4(hdr_idx);
3661 g_array_event(l_event_id).array_value_char('source_5') := l_array_source_5(hdr_idx);
3662 g_array_event(l_event_id).array_value_char('source_6') := l_array_source_6(hdr_idx);
3663 g_array_event(l_event_id).array_value_char('source_7') := l_array_source_7(hdr_idx);
3664 g_array_event(l_event_id).array_value_num('source_12') := l_array_source_12(hdr_idx);
3665
3666 --
3667 -- initilaize the status of ae headers for diffrent balance types
3668 -- the status is initialised to C_NOT_CREATED (2)
3669 --
3670 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
3671 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
3672 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
3673
3674 --
3675 -- call api to validate and store accounting attributes for header
3676 --
3677
3678 ------------------------------------------------------------
3679 -- Accrual Reversal : to get date for Standard Source (NONE)
3680 ------------------------------------------------------------
3681 l_acc_rev_gl_date_source := NULL;
3682
3683 l_rec_acct_attrs.array_acct_attr_code(1) := 'GL_DATE';
3684 l_rec_acct_attrs.array_date_value(1) :=
3685 xla_ae_sources_pkg.GetSystemSourceDate(
3686 p_source_code => 'XLA_EVENT_DATE'
3687 , p_source_type_code => 'Y'
3688 , p_source_application_id => 602
3689 );
3690
3691
3692 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
3693
3694 XLA_AE_HEADER_PKG.SetJeCategoryName;
3695
3696 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
3697 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
3698 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
3699 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
3700 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
3701
3702
3703 --
3704 xla_ae_header_pkg.SetHdrDescription(
3705 p_description => Description_1 (
3706 p_application_id => p_application_id
3707 , p_source_1 => g_array_event(l_event_id).array_value_char('source_1')
3708 , p_source_2 => g_array_event(l_event_id).array_value_char('source_2')
3709 , p_source_3 => g_array_event(l_event_id).array_value_char('source_3')
3710 , p_source_4 => g_array_event(l_event_id).array_value_char('source_4')
3711 , p_source_5 => g_array_event(l_event_id).array_value_char('source_5')
3712 , p_source_6 => g_array_event(l_event_id).array_value_char('source_6')
3713 , p_source_7 => g_array_event(l_event_id).array_value_char('source_7')
3714 )
3715 );
3716 --
3717
3718 -- No header level analytical criteria
3722 --
3719
3720 --
3721 --accounting attribute enhancement, bug 3612931
3723 l_trx_reversal_source := SUBSTR(NULL, 1,30);
3724
3725 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
3726 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3727
3728 xla_accounting_err_pkg.build_message
3729 (p_appli_s_name => 'XLA'
3730 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
3731 ,p_token_1 => 'ACCT_ATTR_NAME'
3732 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
3733 ,p_token_2 => 'PRODUCT_NAME'
3734 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
3735 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3736 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3737 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
3738
3739 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
3740 --
3741 -- following sets the accounting attributes needed to reverse
3742 -- accounting for a distributeion
3743 --
3744 xla_ae_lines_pkg.SetTrxReversalAttrs
3745 (p_event_id => l_event_id
3746 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
3747 ,p_trx_reversal_source => l_trx_reversal_source);
3748
3749 END IF;
3750
3751
3752 ----------------------------------------------------------------
3753 -- 4262811 - update the header statuses to invalid in need be
3754 ----------------------------------------------------------------
3755 --
3756 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
3757
3758
3759 -----------------------------------------------
3760 -- No accrual reversal for the event class/type
3761 -----------------------------------------------
3762 ----------------------------------------------------------------
3763
3764 --
3765 -- this ends the header loop iteration for one bulk fetch
3766 --
3767 END LOOP;
3768
3769 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
3770 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
3771
3772 --
3773 -- insert dummy rows into lines gt table that were created due to
3774 -- transaction reversals
3775 --
3776 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
3777 l_result := XLA_AE_LINES_PKG.InsertLines;
3778 END IF;
3779
3780 --
3781 -- reset the temp_line_num for each set of events fetched from header
3782 -- cursor rather than doing it for each new event in line cursor
3783 -- Bug 3939231
3784 --
3785 xla_ae_lines_pkg.g_temp_line_num := 0;
3786
3787
3788
3789 --
3790 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
3791 --
3792 --
3793 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3794
3795 trace
3796 (p_msg => 'SQL - FETCH line_cur'
3797 ,p_level => C_LEVEL_STATEMENT
3798 ,p_module => l_log_module);
3799
3800 END IF;
3801 --
3802 --
3803 LOOP
3804 --
3805 FETCH line_cur BULK COLLECT INTO
3806 l_array_entity_id
3807 , l_array_legal_entity_id
3808 , l_array_entity_code
3809 , l_array_transaction_num
3810 , l_array_event_id
3811 , l_array_class_code
3812 , l_array_event_type
3813 , l_array_event_number
3814 , l_array_event_date
3815 , l_array_transaction_date
3816 , l_array_reference_num_1
3817 , l_array_reference_num_2
3818 , l_array_reference_num_3
3819 , l_array_reference_num_4
3820 , l_array_reference_char_1
3821 , l_array_reference_char_2
3822 , l_array_reference_char_3
3823 , l_array_reference_char_4
3824 , l_array_reference_date_1
3825 , l_array_reference_date_2
3826 , l_array_reference_date_3
3827 , l_array_reference_date_4
3828 , l_array_event_created_by
3829 , l_array_budgetary_control_flag
3830 , l_array_extract_line_num
3831 , l_array_source_10
3832 , l_array_source_11
3833 , l_array_source_13
3834 , l_array_source_14
3835 , l_array_source_15
3836 , l_array_source_16
3837 , l_array_source_17
3838 , l_array_source_18
3839 LIMIT l_rows;
3840
3841 --
3842 IF (C_LEVEL_EVENT >= g_log_level) THEN
3843 trace
3844 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
3845 ,p_level => C_LEVEL_EVENT
3846 ,p_module => l_log_module);
3847 END IF;
3848 --
3849 EXIT WHEN l_array_entity_id.count = 0;
3850
3851 XLA_AE_LINES_PKG.g_rec_lines := null;
3852
3853 --
3854 -- Bug 4458708
3855 --
3856 XLA_AE_LINES_PKG.g_LineNumber := 0;
3857 --
3858 --
3859
3860 FOR Idx IN 1..l_array_event_id.count LOOP
3861 --
3862 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
3863 --
3864 l_event_id := l_array_event_id(idx); -- 5648433
3865
3866 --
3867 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
3868 --
3869
3870 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
3871 (g_array_event(l_event_id).array_value_num('header_index'))
3875 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3872 ,'N'
3873 ) <> 'Y'
3874 THEN
3876 trace
3877 (p_msg => 'Trancaction revesal option is not Y '
3878 ,p_level => C_LEVEL_STATEMENT
3879 ,p_module => l_log_module);
3880 END IF;
3881
3882 --
3883 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
3884 --
3885 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
3886 --
3887 -- set event info as cache for other routines to refer event attributes
3888 --
3889
3890 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
3891 l_previous_event_id := l_event_id;
3892
3893 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
3894 (p_application_id => p_application_id
3895 ,p_primary_ledger_id => p_primary_ledger_id
3896 ,p_base_ledger_id => p_base_ledger_id
3897 ,p_target_ledger_id => p_target_ledger_id
3898 ,p_entity_id => l_array_entity_id(Idx)
3899 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
3900 ,p_entity_code => l_array_entity_code(Idx)
3901 ,p_transaction_num => l_array_transaction_num(Idx)
3902 ,p_event_id => l_array_event_id(Idx)
3903 ,p_event_class_code => l_array_class_code(Idx)
3904 ,p_event_type_code => l_array_event_type(Idx)
3905 ,p_event_number => l_array_event_number(Idx)
3906 ,p_event_date => l_array_event_date(Idx)
3907 ,p_transaction_date => l_array_transaction_date(Idx)
3908 ,p_reference_num_1 => l_array_reference_num_1(Idx)
3909 ,p_reference_num_2 => l_array_reference_num_2(Idx)
3910 ,p_reference_num_3 => l_array_reference_num_3(Idx)
3911 ,p_reference_num_4 => l_array_reference_num_4(Idx)
3912 ,p_reference_char_1 => l_array_reference_char_1(Idx)
3913 ,p_reference_char_2 => l_array_reference_char_2(Idx)
3914 ,p_reference_char_3 => l_array_reference_char_3(Idx)
3915 ,p_reference_char_4 => l_array_reference_char_4(Idx)
3916 ,p_reference_date_1 => l_array_reference_date_1(Idx)
3917 ,p_reference_date_2 => l_array_reference_date_2(Idx)
3918 ,p_reference_date_3 => l_array_reference_date_3(Idx)
3919 ,p_reference_date_4 => l_array_reference_date_4(Idx)
3920 ,p_event_created_by => l_array_event_created_by(Idx)
3921 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
3922 --
3923 END IF;
3924
3925
3926
3927 --
3928 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
3929
3930 l_acct_reversal_source := SUBSTR(NULL, 1,30);
3931
3932 IF l_continue_with_lines THEN
3933 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
3934 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3935
3936 xla_accounting_err_pkg.build_message
3937 (p_appli_s_name => 'XLA'
3938 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
3939 ,p_token_1 => 'LINE_NUMBER'
3940 ,p_value_1 => l_array_extract_line_num(Idx)
3941 ,p_token_2 => 'PRODUCT_NAME'
3942 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
3943 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3944 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3945 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
3946
3947 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
3948 --
3949 -- following sets the accounting attributes needed to reverse
3950 -- accounting for a distributeion
3951 --
3952
3953 --
3954 -- 5217187
3955 --
3956 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
3957 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
3958 g_array_event(l_event_id).array_value_num('header_index'));
3959 --
3960 --
3961
3962 -- No reversal code generated
3963
3964 xla_ae_lines_pkg.SetAcctReversalAttrs
3965 (p_event_id => l_event_id
3966 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
3967 ,p_calculate_acctd_flag => l_calculate_acctd_flag
3968 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
3969 END IF;
3970
3971 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
3972 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
3973
3974 --
3975 AcctLineType_4 (
3976 p_application_id => p_application_id
3977 ,p_event_id => l_event_id
3978 ,p_calculate_acctd_flag => l_calculate_acctd_flag
3979 ,p_calculate_g_l_flag => l_calculate_g_l_flag
3980 ,p_actual_flag => l_actual_flag
3981 ,p_balance_type_code => l_balance_type_code
3982 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
3983
3984 , p_source_1 => g_array_event(l_event_id).array_value_char('source_1')
3985 , p_source_2 => g_array_event(l_event_id).array_value_char('source_2')
3986 , p_source_3 => g_array_event(l_event_id).array_value_char('source_3')
3987 , p_source_4 => g_array_event(l_event_id).array_value_char('source_4')
3988 , p_source_5 => g_array_event(l_event_id).array_value_char('source_5')
3992 , p_source_11 => l_array_source_11(Idx)
3989 , p_source_6 => g_array_event(l_event_id).array_value_char('source_6')
3990 , p_source_7 => g_array_event(l_event_id).array_value_char('source_7')
3991 , p_source_10 => l_array_source_10(Idx)
3993 , p_source_12 => g_array_event(l_event_id).array_value_num('source_12')
3994 , p_source_13 => l_array_source_13(Idx)
3995 , p_source_14 => l_array_source_14(Idx)
3996 , p_source_15 => l_array_source_15(Idx)
3997 , p_source_16 => l_array_source_16(Idx)
3998 , p_source_17 => l_array_source_17(Idx)
3999 , p_source_18 => l_array_source_18(Idx)
4000 );
4001 If(l_balance_type_code = 'A') THEN
4002 l_actual_gain_loss_ref := l_gain_or_loss_ref;
4003 END IF;
4004
4005 --
4006
4007
4008 --
4009 AcctLineType_6 (
4010 p_application_id => p_application_id
4011 ,p_event_id => l_event_id
4012 ,p_calculate_acctd_flag => l_calculate_acctd_flag
4013 ,p_calculate_g_l_flag => l_calculate_g_l_flag
4014 ,p_actual_flag => l_actual_flag
4015 ,p_balance_type_code => l_balance_type_code
4016 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
4017
4018 , p_source_1 => g_array_event(l_event_id).array_value_char('source_1')
4019 , p_source_2 => g_array_event(l_event_id).array_value_char('source_2')
4020 , p_source_3 => g_array_event(l_event_id).array_value_char('source_3')
4021 , p_source_4 => g_array_event(l_event_id).array_value_char('source_4')
4022 , p_source_5 => g_array_event(l_event_id).array_value_char('source_5')
4023 , p_source_6 => g_array_event(l_event_id).array_value_char('source_6')
4024 , p_source_7 => g_array_event(l_event_id).array_value_char('source_7')
4025 , p_source_10 => l_array_source_10(Idx)
4026 , p_source_11 => l_array_source_11(Idx)
4027 , p_source_12 => g_array_event(l_event_id).array_value_num('source_12')
4028 , p_source_13 => l_array_source_13(Idx)
4029 , p_source_14 => l_array_source_14(Idx)
4030 , p_source_15 => l_array_source_15(Idx)
4031 , p_source_16 => l_array_source_16(Idx)
4032 , p_source_17 => l_array_source_17(Idx)
4033 , p_source_18 => l_array_source_18(Idx)
4034 );
4035 If(l_balance_type_code = 'A') THEN
4036 l_actual_gain_loss_ref := l_gain_or_loss_ref;
4037 END IF;
4038
4039 --
4040
4041 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
4042 -- or secondary ledger that has different currency with primary
4043 -- or alc that is calculated by sla
4044 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
4045 (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code in ('ALC', 'SECONDARY') AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.calculate_amts_flag='Y'))
4046
4047 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
4048 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
4049 AND (l_actual_flag = 'A')) THEN
4050 XLA_AE_LINES_PKG.CreateGainOrLossLines(
4051 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4052 ,p_application_id => p_application_id
4053 ,p_amb_context_code => 'DEFAULT'
4054 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
4055 ,p_event_class_code => C_EVENT_CLASS_CODE
4056 ,p_event_type_code => C_EVENT_TYPE_CODE
4057
4058 ,p_gain_ccid => -1
4059 ,p_loss_ccid => -1
4060
4061 ,p_actual_flag => l_actual_flag
4062 ,p_enc_flag => null
4063 ,p_actual_g_l_ref => l_actual_gain_loss_ref
4064 ,p_enc_g_l_ref => null
4065 );
4066 END IF;
4067 END IF;
4068 END IF;
4069
4070 ELSE
4071 --
4072 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
4073 --
4074 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4075 trace
4076 (p_msg => 'Trancaction revesal option is Y'
4077 ,p_level => C_LEVEL_STATEMENT
4078 ,p_module => l_log_module);
4079 END IF;
4080 END IF;
4081
4082 END LOOP;
4083 l_result := XLA_AE_LINES_PKG.InsertLines ;
4084 end loop;
4085 close line_cur;
4086
4087
4088 --
4089 -- insert headers into xla_ae_headers_gt table
4090 --
4091 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
4092
4093 -- insert into errors table here.
4094
4095 END LOOP;
4096
4097 --
4098 -- 4865292
4099 --
4100 -- Compare g_hdr_extract_count with event count in
4101 -- CreateHeadersAndLines.
4102 --
4103 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
4104
4105 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4106 trace (p_msg => '# rows extracted from header extract objects '
4107 || ' (running total): '
4108 || g_hdr_extract_count
4109 ,p_level => C_LEVEL_STATEMENT
4110 ,p_module => l_log_module);
4111 END IF;
4112
4113 CLOSE header_cur;
4114 --
4115
4116 --
4117 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4118 trace
4119 (p_msg => 'END of EventType_8'
4120 ,p_level => C_LEVEL_PROCEDURE
4121 ,p_module => l_log_module);
4122 END IF;
4123 --
4124 RETURN l_result;
4125 EXCEPTION
4129
4126 WHEN xla_exceptions_pkg.application_exception THEN
4127
4128 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
4130
4131 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
4132
4133 RAISE;
4134
4135 WHEN NO_DATA_FOUND THEN
4136
4137 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
4138 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
4139
4140 FOR header_record IN header_cur
4141 LOOP
4142 l_array_header_events(header_record.event_id) := header_record.event_id;
4143 END LOOP;
4144
4145 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
4146 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
4147
4148 fnd_file.put_line(fnd_file.LOG, ' ');
4149 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
4150 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
4151 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
4152
4153 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
4154 LOOP
4155 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
4156 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
4157 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
4158 END IF;
4159 END LOOP;
4160
4161 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
4162 fnd_file.put_line(fnd_file.LOG, ' ');
4163
4164
4165 xla_exceptions_pkg.raise_message
4166 (p_location => 'XLA_00240_AAD_S_000003_PKG.EventType_8');
4167
4168
4169 WHEN OTHERS THEN
4170 xla_exceptions_pkg.raise_message
4171 (p_location => 'XLA_00240_AAD_S_000003_PKG.EventType_8');
4172 END EventType_8;
4173 --
4174
4175 ---------------------------------------
4176 --
4177 -- PRIVATE PROCEDURE
4178 -- insert_sources_9
4179 --
4180 ----------------------------------------
4181 --
4182 PROCEDURE insert_sources_9(
4183 p_target_ledger_id IN NUMBER
4184 , p_language IN VARCHAR2
4185 , p_sla_ledger_id IN NUMBER
4186 , p_pad_start_date IN DATE
4187 , p_pad_end_date IN DATE
4188 )
4189 IS
4190
4191 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'LEASE_REVENUE_TRANSFER';
4192 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'LEASE_REVENUE';
4193 p_apps_owner VARCHAR2(30);
4194 l_log_module VARCHAR2(240);
4195 BEGIN
4196 IF g_log_enabled THEN
4197 l_log_module := C_DEFAULT_MODULE||'.insert_sources_9';
4198 END IF;
4199 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4200
4201 trace
4202 (p_msg => 'BEGIN of insert_sources_9'
4203 ,p_level => C_LEVEL_PROCEDURE
4204 ,p_module => l_log_module);
4205
4206 END IF;
4207
4208 -- select APPS owner
4209 SELECT oracle_username
4210 INTO p_apps_owner
4211 FROM fnd_oracle_userid
4212 WHERE read_only_flag = 'U'
4213 ;
4214
4215 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4216 trace
4217 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
4218 ' - p_language = '||p_language||
4219 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
4220 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
4221 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
4222 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
4223 ,p_level => C_LEVEL_STATEMENT
4224 ,p_module => l_log_module);
4225 END IF;
4226
4227
4228 --
4229 INSERT INTO xla_diag_sources --hdr1
4230 (
4231 event_id
4232 , ledger_id
4233 , sla_ledger_id
4234 , description_language
4235 , object_name
4236 , object_type_code
4237 , line_number
4238 , source_application_id
4239 , source_type_code
4240 , source_code
4241 , source_value
4242 , source_meaning
4243 , created_by
4244 , creation_date
4245 , last_update_date
4246 , last_updated_by
4247 , last_update_login
4248 , program_update_date
4249 , program_application_id
4250 , program_id
4251 , request_id
4252 )
4253 SELECT
4254 event_id
4255 , p_target_ledger_id
4256 , p_sla_ledger_id
4257 , p_language
4258 , object_name
4259 , object_type_code
4260 , line_number
4261 , source_application_id
4262 , source_type_code
4263 , source_code
4264 , SUBSTR(source_value ,1,1996)
4265 , SUBSTR(source_meaning,1,200)
4266 , xla_environment_pkg.g_Usr_Id
4267 , TRUNC(SYSDATE)
4268 , TRUNC(SYSDATE)
4269 , xla_environment_pkg.g_Usr_Id
4270 , xla_environment_pkg.g_Login_Id
4271 , TRUNC(SYSDATE)
4272 , xla_environment_pkg.g_Prog_Appl_Id
4273 , xla_environment_pkg.g_Prog_Id
4274 , xla_environment_pkg.g_Req_Id
4275 FROM (
4279 WHEN 1 THEN 'PN_XLA_EXTRACT_HEADERS_V'
4276 SELECT xet.event_id event_id
4277 , 0 line_number
4278 , CASE r
4280 WHEN 2 THEN 'PN_XLA_EXTRACT_HEADERS_V'
4281 WHEN 3 THEN 'PN_XLA_EXTRACT_HEADERS_V'
4282 WHEN 4 THEN 'PN_XLA_EXTRACT_HEADERS_V'
4283 WHEN 5 THEN 'PN_XLA_EXTRACT_HEADERS_V'
4284 WHEN 6 THEN 'PN_XLA_EXTRACT_HEADERS_V'
4285 WHEN 7 THEN 'PN_XLA_EXTRACT_HEADERS_V'
4286 WHEN 8 THEN 'PN_XLA_EXTRACT_HEADERS_V'
4287
4288 ELSE null
4289 END object_name
4290 , CASE r
4291 WHEN 1 THEN 'HEADER'
4292 WHEN 2 THEN 'HEADER'
4293 WHEN 3 THEN 'HEADER'
4294 WHEN 4 THEN 'HEADER'
4295 WHEN 5 THEN 'HEADER'
4296 WHEN 6 THEN 'HEADER'
4297 WHEN 7 THEN 'HEADER'
4298 WHEN 8 THEN 'HEADER'
4299
4300 ELSE null
4301 END object_type_code
4302 , CASE r
4303 WHEN 1 THEN '240'
4304 WHEN 2 THEN '240'
4305 WHEN 3 THEN '240'
4306 WHEN 4 THEN '240'
4307 WHEN 5 THEN '240'
4308 WHEN 6 THEN '240'
4309 WHEN 7 THEN '240'
4310 WHEN 8 THEN '240'
4311
4312 ELSE null
4313 END source_application_id
4314 , 'S' source_type_code
4315 , CASE r
4316 WHEN 1 THEN 'PAYMENT_PURPOSE'
4317 WHEN 2 THEN 'PAYMENT_TYPE'
4318 WHEN 3 THEN 'LOCATION_CODE'
4319 WHEN 4 THEN 'LEASE_NUMBER'
4320 WHEN 5 THEN 'PROPERTY_CODE'
4321 WHEN 6 THEN 'CUSTOMER_NAME'
4322 WHEN 7 THEN 'CUSTOMER_SITE'
4323 WHEN 8 THEN 'PAYMENT_ITEM_ID'
4324
4325 ELSE null
4326 END source_code
4327 , CASE r
4328 WHEN 1 THEN TO_CHAR(h1.PAYMENT_PURPOSE)
4329 WHEN 2 THEN TO_CHAR(h1.PAYMENT_TYPE)
4330 WHEN 3 THEN TO_CHAR(h1.LOCATION_CODE)
4331 WHEN 4 THEN TO_CHAR(h1.LEASE_NUMBER)
4332 WHEN 5 THEN TO_CHAR(h1.PROPERTY_CODE)
4333 WHEN 6 THEN TO_CHAR(h1.CUSTOMER_NAME)
4334 WHEN 7 THEN TO_CHAR(h1.CUSTOMER_SITE)
4335 WHEN 8 THEN TO_CHAR(h1.PAYMENT_ITEM_ID)
4336
4337 ELSE null
4338 END source_value
4339 , null source_meaning
4340 FROM xla_events_gt xet
4341 , PN_XLA_EXTRACT_HEADERS_V h1
4342 ,(select rownum r from all_objects where rownum <= 8 and owner = p_apps_owner)
4343 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
4344 AND xet.event_type_code = C_EVENT_TYPE_CODE
4345 AND h1.event_id = xet.event_id
4346
4347 )
4348 ;
4349 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4350
4351 trace
4352 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
4353 ,p_level => C_LEVEL_STATEMENT
4354 ,p_module => l_log_module);
4355
4356 END IF;
4357 --
4358
4359
4360
4361 --
4362 INSERT INTO xla_diag_sources --line1
4363 (
4364 event_id
4365 , ledger_id
4366 , sla_ledger_id
4367 , description_language
4368 , object_name
4369 , object_type_code
4370 , line_number
4371 , source_application_id
4372 , source_type_code
4373 , source_code
4374 , source_value
4375 , source_meaning
4376 , created_by
4377 , creation_date
4378 , last_update_date
4379 , last_updated_by
4380 , last_update_login
4381 , program_update_date
4382 , program_application_id
4383 , program_id
4384 , request_id
4385 )
4386 SELECT event_id
4387 , p_target_ledger_id
4388 , p_sla_ledger_id
4389 , p_language
4390 , object_name
4391 , object_type_code
4392 , line_number
4393 , source_application_id
4394 , source_type_code
4395 , source_code
4396 , SUBSTR(source_value,1,1996)
4397 , SUBSTR(source_meaning,1,200)
4398 , xla_environment_pkg.g_Usr_Id
4399 , TRUNC(SYSDATE)
4400 , TRUNC(SYSDATE)
4401 , xla_environment_pkg.g_Usr_Id
4402 , xla_environment_pkg.g_Login_Id
4403 , TRUNC(SYSDATE)
4404 , xla_environment_pkg.g_Prog_Appl_Id
4405 , xla_environment_pkg.g_Prog_Id
4406 , xla_environment_pkg.g_Req_Id
4407 FROM (
4408 SELECT xet.event_id event_id
4409 , l2.line_number line_number
4410 , CASE r
4411 WHEN 1 THEN 'PN_XLA_EXTRACT_LINES_V'
4412 WHEN 2 THEN 'PN_XLA_EXTRACT_LINES_V'
4413 WHEN 3 THEN 'PN_XLA_EXTRACT_LINES_V'
4414 WHEN 4 THEN 'PN_XLA_EXTRACT_LINES_V'
4415 WHEN 5 THEN 'PN_XLA_EXTRACT_LINES_V'
4416 WHEN 6 THEN 'PN_XLA_EXTRACT_LINES_V'
4420 ELSE null
4417 WHEN 7 THEN 'PN_XLA_EXTRACT_LINES_V'
4418 WHEN 8 THEN 'PN_XLA_EXTRACT_LINES_V'
4419
4421 END object_name
4422 , CASE r
4423 WHEN 1 THEN 'LINE'
4424 WHEN 2 THEN 'LINE'
4425 WHEN 3 THEN 'LINE'
4426 WHEN 4 THEN 'LINE'
4427 WHEN 5 THEN 'LINE'
4428 WHEN 6 THEN 'LINE'
4429 WHEN 7 THEN 'LINE'
4430 WHEN 8 THEN 'LINE'
4431
4432 ELSE null
4433 END object_type_code
4434 , CASE r
4435 WHEN 1 THEN '240'
4436 WHEN 2 THEN '240'
4437 WHEN 3 THEN '240'
4438 WHEN 4 THEN '240'
4439 WHEN 5 THEN '240'
4440 WHEN 6 THEN '240'
4441 WHEN 7 THEN '240'
4442 WHEN 8 THEN '240'
4443
4444 ELSE null
4445 END source_application_id
4446 , 'S' source_type_code
4447 , CASE r
4448 WHEN 1 THEN 'CODE_COMBINATION_ID'
4449 WHEN 2 THEN 'DISTRIBUTION_TYPE'
4450 WHEN 3 THEN 'ENTERED_AMOUNT'
4451 WHEN 4 THEN 'CURRENCY_CODE'
4452 WHEN 5 THEN 'CONVERSION_DATE'
4453 WHEN 6 THEN 'CONVERSION_RATE'
4454 WHEN 7 THEN 'CONVERSION_RATE_TYPE'
4455 WHEN 8 THEN 'ACCOUNTED_AMOUNT'
4456
4457 ELSE null
4458 END source_code
4459 , CASE r
4460 WHEN 1 THEN TO_CHAR(l2.CODE_COMBINATION_ID)
4461 WHEN 2 THEN TO_CHAR(l2.DISTRIBUTION_TYPE)
4462 WHEN 3 THEN TO_CHAR(l2.ENTERED_AMOUNT)
4463 WHEN 4 THEN TO_CHAR(l2.CURRENCY_CODE)
4464 WHEN 5 THEN TO_CHAR(l2.CONVERSION_DATE)
4465 WHEN 6 THEN TO_CHAR(l2.CONVERSION_RATE)
4466 WHEN 7 THEN TO_CHAR(l2.CONVERSION_RATE_TYPE)
4467 WHEN 8 THEN TO_CHAR(l2.ACCOUNTED_AMOUNT)
4468
4469 ELSE null
4470 END source_value
4471 , null source_meaning
4472 FROM xla_events_gt xet
4473 , PN_XLA_EXTRACT_LINES_V l2
4474 ,(select rownum r from all_objects where rownum <= 8 and owner = p_apps_owner)
4475 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
4476 AND xet.event_type_code = C_EVENT_TYPE_CODE
4477 AND l2.event_id = xet.event_id
4478 AND l2.ledger_id (+) = p_sla_ledger_id
4479
4480 )
4481 ;
4482 --
4483 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4484
4485 trace
4486 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
4487 ,p_level => C_LEVEL_STATEMENT
4488 ,p_module => l_log_module);
4489
4490 END IF;
4491
4492
4493 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4494 trace
4495 (p_msg => 'END of insert_sources_9'
4496 ,p_level => C_LEVEL_PROCEDURE
4497 ,p_module => l_log_module);
4498 END IF;
4499 EXCEPTION
4500 WHEN xla_exceptions_pkg.application_exception THEN
4501 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
4502 trace
4503 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
4504 ,p_level => C_LEVEL_EXCEPTION
4505 ,p_module => l_log_module);
4506 END IF;
4507 RAISE;
4508 WHEN OTHERS THEN
4509 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
4510 trace
4511 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
4512 ,p_level => C_LEVEL_EXCEPTION
4513 ,p_module => l_log_module);
4514 END IF;
4515 xla_exceptions_pkg.raise_message
4516 (p_location => 'XLA_00240_AAD_S_000003_PKG.insert_sources_9');
4517 END insert_sources_9;
4518 --
4519
4520 ---------------------------------------
4521 --
4522 -- PRIVATE FUNCTION
4523 -- EventType_9
4524 --
4525 ----------------------------------------
4526 --
4527 FUNCTION EventType_9
4528 (p_application_id IN NUMBER
4529 ,p_base_ledger_id IN NUMBER
4530 ,p_target_ledger_id IN NUMBER
4531 ,p_language IN VARCHAR2
4532 ,p_currency_code IN VARCHAR2
4533 ,p_sla_ledger_id IN NUMBER
4534 ,p_pad_start_date IN DATE
4535 ,p_pad_end_date IN DATE
4536 ,p_primary_ledger_id IN NUMBER)
4537 RETURN BOOLEAN IS
4538 --
4539 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'LEASE_REVENUE_TRANSFER';
4540 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'LEASE_REVENUE';
4541
4542 l_calculate_acctd_flag VARCHAR2(1) :='N';
4543 l_calculate_g_l_flag VARCHAR2(1) :='N';
4544 --
4545 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
4546 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
4550 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
4547 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
4548 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
4549 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
4551 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
4552 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
4553 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
4554 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
4555 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
4556 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
4557 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
4558 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
4559 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
4560 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
4561 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
4562 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
4563 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
4564 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
4565 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
4566 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
4567 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
4568 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
4569 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
4570 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
4571
4572 l_event_id NUMBER;
4573 l_previous_event_id NUMBER;
4574 l_first_event_id NUMBER;
4575 l_last_event_id NUMBER;
4576
4577 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
4578 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
4579 --
4580 --
4581 l_result BOOLEAN := TRUE;
4582 l_rows NUMBER := 1000;
4583 l_event_type_name VARCHAR2(80) := 'Lease Revenue Item Transfer';
4584 l_event_class_name VARCHAR2(80) := 'Lease Revenue';
4585 l_description VARCHAR2(4000);
4586 l_transaction_reversal NUMBER;
4587 l_ae_header_id NUMBER;
4588 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
4589 l_log_module VARCHAR2(240);
4590 --
4591 l_acct_reversal_source VARCHAR2(30);
4592 l_trx_reversal_source VARCHAR2(30);
4593
4594 l_continue_with_lines BOOLEAN := TRUE;
4595 --
4596 l_acc_rev_gl_date_source DATE; -- 4262811
4597 --
4598 type t_array_event_id is table of number index by binary_integer;
4599
4600 l_rec_array_event t_rec_array_event;
4601 l_null_rec_array_event t_rec_array_event;
4602 l_array_ae_header_id xla_number_array_type;
4603 l_actual_flag VARCHAR2(1) := NULL;
4604 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
4605 l_balance_type_code VARCHAR2(1) :=NULL;
4606 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
4607
4608 --
4609 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
4610 --
4611
4612 TYPE t_array_source_3 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.PAYMENT_PURPOSE%TYPE INDEX BY BINARY_INTEGER;
4613 TYPE t_array_source_4 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.PAYMENT_TYPE%TYPE INDEX BY BINARY_INTEGER;
4614 TYPE t_array_source_5 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.LOCATION_CODE%TYPE INDEX BY BINARY_INTEGER;
4615 TYPE t_array_source_6 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.LEASE_NUMBER%TYPE INDEX BY BINARY_INTEGER;
4616 TYPE t_array_source_7 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.PROPERTY_CODE%TYPE INDEX BY BINARY_INTEGER;
4617 TYPE t_array_source_8 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.CUSTOMER_NAME%TYPE INDEX BY BINARY_INTEGER;
4618 TYPE t_array_source_9 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.CUSTOMER_SITE%TYPE INDEX BY BINARY_INTEGER;
4619 TYPE t_array_source_12 IS TABLE OF PN_XLA_EXTRACT_HEADERS_V.PAYMENT_ITEM_ID%TYPE INDEX BY BINARY_INTEGER;
4620
4621 TYPE t_array_source_10 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
4622 TYPE t_array_source_11 IS TABLE OF PN_XLA_EXTRACT_LINES_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
4623 TYPE t_array_source_13 IS TABLE OF PN_XLA_EXTRACT_LINES_V.ENTERED_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
4624 TYPE t_array_source_14 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
4625 TYPE t_array_source_15 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
4626 TYPE t_array_source_16 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
4627 TYPE t_array_source_17 IS TABLE OF PN_XLA_EXTRACT_LINES_V.CONVERSION_RATE_TYPE%TYPE INDEX BY BINARY_INTEGER;
4628 TYPE t_array_source_18 IS TABLE OF PN_XLA_EXTRACT_LINES_V.ACCOUNTED_AMOUNT%TYPE INDEX BY BINARY_INTEGER;
4629
4630 l_array_source_3 t_array_source_3;
4631 l_array_source_4 t_array_source_4;
4632 l_array_source_5 t_array_source_5;
4633 l_array_source_6 t_array_source_6;
4634 l_array_source_7 t_array_source_7;
4638
4635 l_array_source_8 t_array_source_8;
4636 l_array_source_9 t_array_source_9;
4637 l_array_source_12 t_array_source_12;
4639 l_array_source_10 t_array_source_10;
4640 l_array_source_11 t_array_source_11;
4641 l_array_source_13 t_array_source_13;
4642 l_array_source_14 t_array_source_14;
4643 l_array_source_15 t_array_source_15;
4644 l_array_source_16 t_array_source_16;
4645 l_array_source_17 t_array_source_17;
4646 l_array_source_18 t_array_source_18;
4647
4648 --
4649 CURSOR header_cur
4650 IS
4651 SELECT /*+ leading(xet) cardinality(xet,1) */
4652 -- Event Type Code: LEASE_REVENUE_TRANSFER
4653 -- Event Class Code: LEASE_REVENUE
4654 xet.entity_id
4655 , xet.legal_entity_id
4656 , xet.entity_code
4657 , xet.transaction_number
4658 , xet.event_id
4659 , xet.event_class_code
4660 , xet.event_type_code
4661 , xet.event_number
4662 , xet.event_date
4663 , xet.transaction_date
4664 , xet.reference_num_1
4665 , xet.reference_num_2
4666 , xet.reference_num_3
4667 , xet.reference_num_4
4668 , xet.reference_char_1
4669 , xet.reference_char_2
4670 , xet.reference_char_3
4671 , xet.reference_char_4
4672 , xet.reference_date_1
4673 , xet.reference_date_2
4674 , xet.reference_date_3
4675 , xet.reference_date_4
4676 , xet.event_created_by
4677 , xet.budgetary_control_flag
4678 , h1.PAYMENT_PURPOSE source_3
4679 , h1.PAYMENT_TYPE source_4
4680 , h1.LOCATION_CODE source_5
4681 , h1.LEASE_NUMBER source_6
4682 , h1.PROPERTY_CODE source_7
4683 , h1.CUSTOMER_NAME source_8
4684 , h1.CUSTOMER_SITE source_9
4685 , h1.PAYMENT_ITEM_ID source_12
4686 FROM xla_events_gt xet
4687 , PN_XLA_EXTRACT_HEADERS_V h1
4688 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
4689 and xet.event_type_code = C_EVENT_TYPE_CODE
4690 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
4691
4692 ORDER BY event_id
4693 ;
4694
4695
4696 --
4697 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
4698 IS
4699 SELECT /*+ leading(xet) cardinality(xet,1) */
4700 -- Event Type Code: LEASE_REVENUE_TRANSFER
4701 -- Event Class Code: LEASE_REVENUE
4702 xet.entity_id
4703 ,xet.legal_entity_id
4704 ,xet.entity_code
4705 ,xet.transaction_number
4706 ,xet.event_id
4707 ,xet.event_class_code
4708 ,xet.event_type_code
4709 ,xet.event_number
4710 ,xet.event_date
4711 ,xet.transaction_date
4712 ,xet.reference_num_1
4713 ,xet.reference_num_2
4714 ,xet.reference_num_3
4715 ,xet.reference_num_4
4716 ,xet.reference_char_1
4717 ,xet.reference_char_2
4718 ,xet.reference_char_3
4719 ,xet.reference_char_4
4720 ,xet.reference_date_1
4721 ,xet.reference_date_2
4722 ,xet.reference_date_3
4723 ,xet.reference_date_4
4724 ,xet.event_created_by
4725 ,xet.budgetary_control_flag , l2.LINE_NUMBER
4726 , l2.CODE_COMBINATION_ID source_10
4727 , l2.DISTRIBUTION_TYPE source_11
4728 , l2.ENTERED_AMOUNT source_13
4729 , l2.CURRENCY_CODE source_14
4730 , l2.CONVERSION_DATE source_15
4731 , l2.CONVERSION_RATE source_16
4732 , l2.CONVERSION_RATE_TYPE source_17
4733 , l2.ACCOUNTED_AMOUNT source_18
4734 FROM xla_events_gt xet
4735 , PN_XLA_EXTRACT_LINES_V l2
4736 WHERE xet.event_id between x_first_event_id and x_last_event_id
4737 and xet.event_date between p_pad_start_date and p_pad_end_date
4738 and xet.event_type_code = C_EVENT_TYPE_CODE
4739 and xet.event_status_code <> 'N' AND l2.event_id = xet.event_id
4740 AND l2.ledger_id = p_sla_ledger_id
4741 ;
4742
4743 --
4744 BEGIN
4745 IF g_log_enabled THEN
4746 l_log_module := C_DEFAULT_MODULE||'.EventType_9';
4747 END IF;
4748 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4749 trace
4750 (p_msg => 'BEGIN of EventType_9'
4751 ,p_level => C_LEVEL_PROCEDURE
4752 ,p_module => l_log_module);
4753 END IF;
4754
4755 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4756 trace
4757 (p_msg => 'p_application_id = '||p_application_id||
4758 ' - p_base_ledger_id = '||p_base_ledger_id||
4759 ' - p_target_ledger_id = '||p_target_ledger_id||
4760 ' - p_language = '||p_language||
4761 ' - p_currency_code = '||p_currency_code||
4762 ' - p_sla_ledger_id = '||p_sla_ledger_id
4763 ,p_level => C_LEVEL_STATEMENT
4764 ,p_module => l_log_module);
4765 END IF;
4766 --
4767 -- initialze arrays
4768 --
4769 g_array_event.DELETE;
4770 l_rec_array_event := l_null_rec_array_event;
4771 --
4772 --------------------------------------
4773 -- 4262811 Initialze MPA Line Number
4774 --------------------------------------
4775 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
4776
4777 --
4778
4779 --
4780 OPEN header_cur;
4781 --
4782 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4783 trace
4784 (p_msg => 'SQL - FETCH header_cur'
4785 ,p_level => C_LEVEL_STATEMENT
4786 ,p_module => l_log_module);
4787 END IF;
4788 --
4789 LOOP
4790 FETCH header_cur BULK COLLECT INTO
4791 l_array_entity_id
4792 , l_array_legal_entity_id
4793 , l_array_entity_code
4794 , l_array_transaction_num
4798 , l_array_event_number
4795 , l_array_event_id
4796 , l_array_class_code
4797 , l_array_event_type
4799 , l_array_event_date
4800 , l_array_transaction_date
4801 , l_array_reference_num_1
4802 , l_array_reference_num_2
4803 , l_array_reference_num_3
4804 , l_array_reference_num_4
4805 , l_array_reference_char_1
4806 , l_array_reference_char_2
4807 , l_array_reference_char_3
4808 , l_array_reference_char_4
4809 , l_array_reference_date_1
4810 , l_array_reference_date_2
4811 , l_array_reference_date_3
4812 , l_array_reference_date_4
4813 , l_array_event_created_by
4814 , l_array_budgetary_control_flag
4815 , l_array_source_3
4816 , l_array_source_4
4817 , l_array_source_5
4818 , l_array_source_6
4819 , l_array_source_7
4820 , l_array_source_8
4821 , l_array_source_9
4822 , l_array_source_12
4823 LIMIT l_rows;
4824 --
4825 IF (C_LEVEL_EVENT >= g_log_level) THEN
4826 trace
4827 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
4828 ,p_level => C_LEVEL_EVENT
4829 ,p_module => l_log_module);
4830 END IF;
4831 --
4832 EXIT WHEN l_array_entity_id.COUNT = 0;
4833
4834 -- initialize arrays
4835 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
4836 XLA_AE_LINES_PKG.g_rec_lines := NULL;
4837
4838 --
4839 -- Bug 4458708
4840 --
4841 XLA_AE_LINES_PKG.g_LineNumber := 0;
4842
4843
4844 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
4845 g_last_hdr_idx := l_array_event_id.LAST;
4846 --
4847 -- loop for the headers. Each iteration is for each header extract row
4848 -- fetched in header cursor
4849 --
4850 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
4851
4852 --
4853 -- set event info as cache for other routines to refer event attributes
4854 --
4855 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
4856 (p_application_id => p_application_id
4857 ,p_primary_ledger_id => p_primary_ledger_id
4858 ,p_base_ledger_id => p_base_ledger_id
4859 ,p_target_ledger_id => p_target_ledger_id
4860 ,p_entity_id => l_array_entity_id(hdr_idx)
4861 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
4862 ,p_entity_code => l_array_entity_code(hdr_idx)
4863 ,p_transaction_num => l_array_transaction_num(hdr_idx)
4864 ,p_event_id => l_array_event_id(hdr_idx)
4865 ,p_event_class_code => l_array_class_code(hdr_idx)
4866 ,p_event_type_code => l_array_event_type(hdr_idx)
4867 ,p_event_number => l_array_event_number(hdr_idx)
4868 ,p_event_date => l_array_event_date(hdr_idx)
4869 ,p_transaction_date => l_array_transaction_date(hdr_idx)
4870 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
4871 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
4872 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
4873 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
4874 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
4875 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
4876 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
4877 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
4878 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
4879 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
4880 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
4881 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
4882 ,p_event_created_by => l_array_event_created_by(hdr_idx)
4883 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
4884
4885 --
4886 -- set the status of entry to C_VALID (0)
4887 --
4888 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
4889
4890 --
4891 -- initialize a row for ae header
4892 --
4893 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
4894
4895 l_event_id := l_array_event_id(hdr_idx);
4896
4897 --
4898 -- storing the hdr_idx for event. May be used by line cursor.
4899 --
4900 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
4901
4902 --
4903 -- store sources from header extract. This can be improved to
4904 -- store only those sources from header extract that may be used in lines
4905 --
4906
4907 g_array_event(l_event_id).array_value_char('source_3') := l_array_source_3(hdr_idx);
4908 g_array_event(l_event_id).array_value_char('source_4') := l_array_source_4(hdr_idx);
4909 g_array_event(l_event_id).array_value_char('source_5') := l_array_source_5(hdr_idx);
4910 g_array_event(l_event_id).array_value_char('source_6') := l_array_source_6(hdr_idx);
4911 g_array_event(l_event_id).array_value_char('source_7') := l_array_source_7(hdr_idx);
4912 g_array_event(l_event_id).array_value_char('source_8') := l_array_source_8(hdr_idx);
4913 g_array_event(l_event_id).array_value_char('source_9') := l_array_source_9(hdr_idx);
4914 g_array_event(l_event_id).array_value_num('source_12') := l_array_source_12(hdr_idx);
4915
4916 --
4917 -- initilaize the status of ae headers for diffrent balance types
4921 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
4918 -- the status is initialised to C_NOT_CREATED (2)
4919 --
4920 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
4922 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
4923
4924 --
4925 -- call api to validate and store accounting attributes for header
4926 --
4927
4928 ------------------------------------------------------------
4929 -- Accrual Reversal : to get date for Standard Source (NONE)
4930 ------------------------------------------------------------
4931 l_acc_rev_gl_date_source := NULL;
4932
4933 l_rec_acct_attrs.array_acct_attr_code(1) := 'GL_DATE';
4934 l_rec_acct_attrs.array_date_value(1) :=
4935 xla_ae_sources_pkg.GetSystemSourceDate(
4936 p_source_code => 'XLA_EVENT_DATE'
4937 , p_source_type_code => 'Y'
4938 , p_source_application_id => 602
4939 );
4940
4941
4942 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
4943
4944 XLA_AE_HEADER_PKG.SetJeCategoryName;
4945
4946 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
4947 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
4948 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
4949 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
4950 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
4951
4952
4953 --
4954 xla_ae_header_pkg.SetHdrDescription(
4955 p_description => Description_2 (
4956 p_application_id => p_application_id
4957 , p_source_3 => g_array_event(l_event_id).array_value_char('source_3')
4958 , p_source_4 => g_array_event(l_event_id).array_value_char('source_4')
4959 , p_source_5 => g_array_event(l_event_id).array_value_char('source_5')
4960 , p_source_6 => g_array_event(l_event_id).array_value_char('source_6')
4961 , p_source_7 => g_array_event(l_event_id).array_value_char('source_7')
4962 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
4963 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
4964 )
4965 );
4966 --
4967
4968 -- No header level analytical criteria
4969
4970 --
4971 --accounting attribute enhancement, bug 3612931
4972 --
4973 l_trx_reversal_source := SUBSTR(NULL, 1,30);
4974
4975 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
4976 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
4977
4978 xla_accounting_err_pkg.build_message
4979 (p_appli_s_name => 'XLA'
4980 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
4981 ,p_token_1 => 'ACCT_ATTR_NAME'
4982 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
4983 ,p_token_2 => 'PRODUCT_NAME'
4984 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
4985 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
4986 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
4987 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
4988
4989 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
4990 --
4991 -- following sets the accounting attributes needed to reverse
4992 -- accounting for a distributeion
4993 --
4994 xla_ae_lines_pkg.SetTrxReversalAttrs
4995 (p_event_id => l_event_id
4996 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
4997 ,p_trx_reversal_source => l_trx_reversal_source);
4998
4999 END IF;
5000
5001
5002 ----------------------------------------------------------------
5003 -- 4262811 - update the header statuses to invalid in need be
5004 ----------------------------------------------------------------
5005 --
5006 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
5007
5008
5009 -----------------------------------------------
5010 -- No accrual reversal for the event class/type
5011 -----------------------------------------------
5012 ----------------------------------------------------------------
5013
5014 --
5015 -- this ends the header loop iteration for one bulk fetch
5016 --
5017 END LOOP;
5018
5019 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
5020 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
5021
5022 --
5023 -- insert dummy rows into lines gt table that were created due to
5024 -- transaction reversals
5025 --
5026 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
5027 l_result := XLA_AE_LINES_PKG.InsertLines;
5028 END IF;
5029
5030 --
5031 -- reset the temp_line_num for each set of events fetched from header
5032 -- cursor rather than doing it for each new event in line cursor
5033 -- Bug 3939231
5034 --
5035 xla_ae_lines_pkg.g_temp_line_num := 0;
5036
5037
5038
5039 --
5040 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
5041 --
5042 --
5043 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5044
5045 trace
5049
5046 (p_msg => 'SQL - FETCH line_cur'
5047 ,p_level => C_LEVEL_STATEMENT
5048 ,p_module => l_log_module);
5050 END IF;
5051 --
5052 --
5053 LOOP
5054 --
5055 FETCH line_cur BULK COLLECT INTO
5056 l_array_entity_id
5057 , l_array_legal_entity_id
5058 , l_array_entity_code
5059 , l_array_transaction_num
5060 , l_array_event_id
5061 , l_array_class_code
5062 , l_array_event_type
5063 , l_array_event_number
5064 , l_array_event_date
5065 , l_array_transaction_date
5066 , l_array_reference_num_1
5067 , l_array_reference_num_2
5068 , l_array_reference_num_3
5069 , l_array_reference_num_4
5070 , l_array_reference_char_1
5071 , l_array_reference_char_2
5072 , l_array_reference_char_3
5073 , l_array_reference_char_4
5074 , l_array_reference_date_1
5075 , l_array_reference_date_2
5076 , l_array_reference_date_3
5077 , l_array_reference_date_4
5078 , l_array_event_created_by
5079 , l_array_budgetary_control_flag
5080 , l_array_extract_line_num
5081 , l_array_source_10
5082 , l_array_source_11
5083 , l_array_source_13
5084 , l_array_source_14
5085 , l_array_source_15
5086 , l_array_source_16
5087 , l_array_source_17
5088 , l_array_source_18
5089 LIMIT l_rows;
5090
5091 --
5092 IF (C_LEVEL_EVENT >= g_log_level) THEN
5093 trace
5094 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
5095 ,p_level => C_LEVEL_EVENT
5096 ,p_module => l_log_module);
5097 END IF;
5098 --
5099 EXIT WHEN l_array_entity_id.count = 0;
5100
5101 XLA_AE_LINES_PKG.g_rec_lines := null;
5102
5103 --
5104 -- Bug 4458708
5105 --
5106 XLA_AE_LINES_PKG.g_LineNumber := 0;
5107 --
5108 --
5109
5110 FOR Idx IN 1..l_array_event_id.count LOOP
5111 --
5112 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
5113 --
5114 l_event_id := l_array_event_id(idx); -- 5648433
5115
5116 --
5117 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
5118 --
5119
5120 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
5121 (g_array_event(l_event_id).array_value_num('header_index'))
5122 ,'N'
5123 ) <> 'Y'
5124 THEN
5125 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5126 trace
5127 (p_msg => 'Trancaction revesal option is not Y '
5128 ,p_level => C_LEVEL_STATEMENT
5129 ,p_module => l_log_module);
5130 END IF;
5131
5132 --
5133 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
5134 --
5135 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
5136 --
5137 -- set event info as cache for other routines to refer event attributes
5138 --
5139
5140 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
5141 l_previous_event_id := l_event_id;
5142
5143 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
5144 (p_application_id => p_application_id
5145 ,p_primary_ledger_id => p_primary_ledger_id
5146 ,p_base_ledger_id => p_base_ledger_id
5147 ,p_target_ledger_id => p_target_ledger_id
5148 ,p_entity_id => l_array_entity_id(Idx)
5149 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
5150 ,p_entity_code => l_array_entity_code(Idx)
5151 ,p_transaction_num => l_array_transaction_num(Idx)
5152 ,p_event_id => l_array_event_id(Idx)
5153 ,p_event_class_code => l_array_class_code(Idx)
5154 ,p_event_type_code => l_array_event_type(Idx)
5155 ,p_event_number => l_array_event_number(Idx)
5156 ,p_event_date => l_array_event_date(Idx)
5157 ,p_transaction_date => l_array_transaction_date(Idx)
5158 ,p_reference_num_1 => l_array_reference_num_1(Idx)
5159 ,p_reference_num_2 => l_array_reference_num_2(Idx)
5160 ,p_reference_num_3 => l_array_reference_num_3(Idx)
5161 ,p_reference_num_4 => l_array_reference_num_4(Idx)
5162 ,p_reference_char_1 => l_array_reference_char_1(Idx)
5163 ,p_reference_char_2 => l_array_reference_char_2(Idx)
5164 ,p_reference_char_3 => l_array_reference_char_3(Idx)
5165 ,p_reference_char_4 => l_array_reference_char_4(Idx)
5166 ,p_reference_date_1 => l_array_reference_date_1(Idx)
5167 ,p_reference_date_2 => l_array_reference_date_2(Idx)
5168 ,p_reference_date_3 => l_array_reference_date_3(Idx)
5169 ,p_reference_date_4 => l_array_reference_date_4(Idx)
5170 ,p_event_created_by => l_array_event_created_by(Idx)
5171 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
5172 --
5173 END IF;
5174
5175
5176
5177 --
5178 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
5179
5180 l_acct_reversal_source := SUBSTR(NULL, 1,30);
5181
5182 IF l_continue_with_lines THEN
5183 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
5184 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
5185
5189 ,p_token_1 => 'LINE_NUMBER'
5186 xla_accounting_err_pkg.build_message
5187 (p_appli_s_name => 'XLA'
5188 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
5190 ,p_value_1 => l_array_extract_line_num(Idx)
5191 ,p_token_2 => 'PRODUCT_NAME'
5192 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
5193 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
5194 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
5195 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
5196
5197 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
5198 --
5199 -- following sets the accounting attributes needed to reverse
5200 -- accounting for a distributeion
5201 --
5202
5203 --
5204 -- 5217187
5205 --
5206 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
5207 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
5208 g_array_event(l_event_id).array_value_num('header_index'));
5209 --
5210 --
5211
5212 -- No reversal code generated
5213
5214 xla_ae_lines_pkg.SetAcctReversalAttrs
5215 (p_event_id => l_event_id
5216 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
5217 ,p_calculate_acctd_flag => l_calculate_acctd_flag
5218 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
5219 END IF;
5220
5221 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
5222 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
5223
5224 --
5225 AcctLineType_5 (
5226 p_application_id => p_application_id
5227 ,p_event_id => l_event_id
5228 ,p_calculate_acctd_flag => l_calculate_acctd_flag
5229 ,p_calculate_g_l_flag => l_calculate_g_l_flag
5230 ,p_actual_flag => l_actual_flag
5231 ,p_balance_type_code => l_balance_type_code
5232 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
5233
5234 , p_source_3 => g_array_event(l_event_id).array_value_char('source_3')
5235 , p_source_4 => g_array_event(l_event_id).array_value_char('source_4')
5236 , p_source_5 => g_array_event(l_event_id).array_value_char('source_5')
5237 , p_source_6 => g_array_event(l_event_id).array_value_char('source_6')
5238 , p_source_7 => g_array_event(l_event_id).array_value_char('source_7')
5239 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
5240 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
5241 , p_source_10 => l_array_source_10(Idx)
5242 , p_source_11 => l_array_source_11(Idx)
5243 , p_source_12 => g_array_event(l_event_id).array_value_num('source_12')
5244 , p_source_13 => l_array_source_13(Idx)
5245 , p_source_14 => l_array_source_14(Idx)
5246 , p_source_15 => l_array_source_15(Idx)
5247 , p_source_16 => l_array_source_16(Idx)
5248 , p_source_17 => l_array_source_17(Idx)
5249 , p_source_18 => l_array_source_18(Idx)
5250 );
5251 If(l_balance_type_code = 'A') THEN
5252 l_actual_gain_loss_ref := l_gain_or_loss_ref;
5253 END IF;
5254
5255 --
5256
5257
5258 --
5259 AcctLineType_7 (
5260 p_application_id => p_application_id
5261 ,p_event_id => l_event_id
5262 ,p_calculate_acctd_flag => l_calculate_acctd_flag
5263 ,p_calculate_g_l_flag => l_calculate_g_l_flag
5264 ,p_actual_flag => l_actual_flag
5265 ,p_balance_type_code => l_balance_type_code
5266 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
5267
5268 , p_source_3 => g_array_event(l_event_id).array_value_char('source_3')
5269 , p_source_4 => g_array_event(l_event_id).array_value_char('source_4')
5270 , p_source_5 => g_array_event(l_event_id).array_value_char('source_5')
5271 , p_source_6 => g_array_event(l_event_id).array_value_char('source_6')
5272 , p_source_7 => g_array_event(l_event_id).array_value_char('source_7')
5273 , p_source_8 => g_array_event(l_event_id).array_value_char('source_8')
5274 , p_source_9 => g_array_event(l_event_id).array_value_char('source_9')
5275 , p_source_10 => l_array_source_10(Idx)
5276 , p_source_11 => l_array_source_11(Idx)
5277 , p_source_12 => g_array_event(l_event_id).array_value_num('source_12')
5278 , p_source_13 => l_array_source_13(Idx)
5279 , p_source_14 => l_array_source_14(Idx)
5280 , p_source_15 => l_array_source_15(Idx)
5281 , p_source_16 => l_array_source_16(Idx)
5282 , p_source_17 => l_array_source_17(Idx)
5283 , p_source_18 => l_array_source_18(Idx)
5284 );
5285 If(l_balance_type_code = 'A') THEN
5286 l_actual_gain_loss_ref := l_gain_or_loss_ref;
5287 END IF;
5288
5289 --
5290
5291 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
5292 -- or secondary ledger that has different currency with primary
5293 -- or alc that is calculated by sla
5294 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
5295 (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code in ('ALC', 'SECONDARY') AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.calculate_amts_flag='Y'))
5296
5297 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
5298 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
5299 AND (l_actual_flag = 'A')) THEN
5300 XLA_AE_LINES_PKG.CreateGainOrLossLines(
5301 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
5302 ,p_application_id => p_application_id
5303 ,p_amb_context_code => 'DEFAULT'
5307
5304 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
5305 ,p_event_class_code => C_EVENT_CLASS_CODE
5306 ,p_event_type_code => C_EVENT_TYPE_CODE
5308 ,p_gain_ccid => -1
5309 ,p_loss_ccid => -1
5310
5311 ,p_actual_flag => l_actual_flag
5312 ,p_enc_flag => null
5313 ,p_actual_g_l_ref => l_actual_gain_loss_ref
5314 ,p_enc_g_l_ref => null
5315 );
5316 END IF;
5317 END IF;
5318 END IF;
5319
5320 ELSE
5321 --
5322 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
5323 --
5324 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5325 trace
5326 (p_msg => 'Trancaction revesal option is Y'
5327 ,p_level => C_LEVEL_STATEMENT
5328 ,p_module => l_log_module);
5329 END IF;
5330 END IF;
5331
5332 END LOOP;
5333 l_result := XLA_AE_LINES_PKG.InsertLines ;
5334 end loop;
5335 close line_cur;
5336
5337
5338 --
5339 -- insert headers into xla_ae_headers_gt table
5340 --
5341 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
5342
5343 -- insert into errors table here.
5344
5345 END LOOP;
5346
5347 --
5348 -- 4865292
5349 --
5353 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
5350 -- Compare g_hdr_extract_count with event count in
5351 -- CreateHeadersAndLines.
5352 --
5354
5355 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5356 trace (p_msg => '# rows extracted from header extract objects '
5357 || ' (running total): '
5358 || g_hdr_extract_count
5359 ,p_level => C_LEVEL_STATEMENT
5360 ,p_module => l_log_module);
5361 END IF;
5362
5363 CLOSE header_cur;
5364 --
5365
5366 --
5367 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5368 trace
5369 (p_msg => 'END of EventType_9'
5370 ,p_level => C_LEVEL_PROCEDURE
5371 ,p_module => l_log_module);
5372 END IF;
5373 --
5374 RETURN l_result;
5375 EXCEPTION
5376 WHEN xla_exceptions_pkg.application_exception THEN
5377
5378 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
5379
5380
5381 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
5382
5383 RAISE;
5384
5385 WHEN NO_DATA_FOUND THEN
5386
5387 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
5388 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
5389
5390 FOR header_record IN header_cur
5391 LOOP
5392 l_array_header_events(header_record.event_id) := header_record.event_id;
5393 END LOOP;
5394
5395 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
5396 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
5397
5398 fnd_file.put_line(fnd_file.LOG, ' ');
5399 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
5403 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
5400 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
5401 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
5402
5404 LOOP
5405 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
5406 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
5407 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
5408 END IF;
5409 END LOOP;
5410
5411 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
5412 fnd_file.put_line(fnd_file.LOG, ' ');
5413
5414
5415 xla_exceptions_pkg.raise_message
5416 (p_location => 'XLA_00240_AAD_S_000003_PKG.EventType_9');
5417
5418
5419 WHEN OTHERS THEN
5420 xla_exceptions_pkg.raise_message
5421 (p_location => 'XLA_00240_AAD_S_000003_PKG.EventType_9');
5422 END EventType_9;
5423 --
5424
5425 --
5426 --+============================================+
5427 --| |
5428 --| PRIVATE FUNCTION |
5429 --| |
5430 --+============================================+
5431 --
5432 FUNCTION CreateHeadersAndLines
5433 (p_application_id IN NUMBER
5434 ,p_base_ledger_id IN NUMBER
5435 ,p_target_ledger_id IN NUMBER
5436 ,p_pad_start_date IN DATE
5437 ,p_pad_end_date IN DATE
5438 ,p_primary_ledger_id IN NUMBER)
5439 RETURN BOOLEAN IS
5440 l_created BOOLEAN:=FALSE;
5441 l_event_id NUMBER;
5442 l_event_date DATE;
5443 l_language VARCHAR2(30);
5444 l_currency_code VARCHAR2(30);
5445 l_sla_ledger_id NUMBER;
5446 l_log_module VARCHAR2(240);
5450 IF g_log_enabled THEN
5447
5448 BEGIN
5449 --
5451 l_log_module := C_DEFAULT_MODULE||'.CreateHeadersAndLines';
5452 END IF;
5453 --
5454 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5455 trace
5456 (p_msg => 'BEGIN of CreateHeadersAndLines'
5457 ,p_level => C_LEVEL_PROCEDURE
5458 ,p_module => l_log_module);
5459 END IF;
5460
5461 l_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
5462 l_currency_code := xla_ae_journal_entry_pkg.g_cache_ledgers_info.currency_code;
5463 l_sla_ledger_id := xla_ae_journal_entry_pkg.g_cache_ledgers_info.sla_ledger_id;
5464
5465 --
5466 -- initialize array of lines with NULL
5467 --
5468 xla_ae_lines_pkg.SetNullLine;
5469
5470 --
5471 -- initialize header extract count -- Bug 4865292
5472 --
5473 g_hdr_extract_count:= 0;
5474
5475
5476 l_created := EventType_8(
5477 p_application_id => p_application_id
5478 , p_base_ledger_id => p_base_ledger_id
5479 , p_target_ledger_id => p_target_ledger_id
5480 , p_language => l_language
5481 , p_currency_code => l_currency_code
5482 , p_sla_ledger_id => l_sla_ledger_id
5483 , p_pad_start_date => p_pad_start_date
5484 , p_pad_end_date => p_pad_end_date
5485 , p_primary_ledger_id => p_primary_ledger_id
5486 );
5487
5488
5489
5490 IF ( g_diagnostics_mode ='Y' ) THEN
5491
5492 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5493 trace
5494 (p_msg => 'CALL Transaction Objects Diagnostics'
5495 ,p_level => C_LEVEL_STATEMENT
5496 ,p_module => l_log_module);
5497
5498 END IF;
5499
5500 insert_sources_8(
5501 p_target_ledger_id => p_target_ledger_id
5502 , p_language => l_language
5503 , p_sla_ledger_id => l_sla_ledger_id
5504 , p_pad_start_date => p_pad_start_date
5505 , p_pad_end_date => p_pad_end_date
5506 );
5507
5508 END IF;
5509
5510 l_created := EventType_9(
5511 p_application_id => p_application_id
5512 , p_base_ledger_id => p_base_ledger_id
5513 , p_target_ledger_id => p_target_ledger_id
5514 , p_language => l_language
5515 , p_currency_code => l_currency_code
5516 , p_sla_ledger_id => l_sla_ledger_id
5517 , p_pad_start_date => p_pad_start_date
5518 , p_pad_end_date => p_pad_end_date
5519 , p_primary_ledger_id => p_primary_ledger_id
5520 );
5521
5522
5523
5524 IF ( g_diagnostics_mode ='Y' ) THEN
5525
5526 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5527 trace
5528 (p_msg => 'CALL Transaction Objects Diagnostics'
5529 ,p_level => C_LEVEL_STATEMENT
5530 ,p_module => l_log_module);
5531
5532 END IF;
5533
5534 insert_sources_9(
5535 p_target_ledger_id => p_target_ledger_id
5536 , p_language => l_language
5537 , p_sla_ledger_id => l_sla_ledger_id
5538 , p_pad_start_date => p_pad_start_date
5539 , p_pad_end_date => p_pad_end_date
5540 );
5541
5542 END IF;
5543
5544
5545 --
5546 -- Bug 4865292
5547 -- When the number of events and that of header extract do not match,
5548 -- set the no header extract flag to indicate there are some issues
5549 -- in header extract.
5550 --
5551 -- Event count context is set in xla_accounting_pkg.unit_processor.
5552 -- Build_Message for this error is called in xla_accounting_pkg.post_accounting
5553 -- to report it as a general error.
5554 --
5555 IF xla_context_pkg.get_event_count_context <> g_hdr_extract_count
5556 AND xla_context_pkg.get_event_nohdr_context <> 'Y' THEN
5557
5558 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5559 trace
5560 (p_msg => '# of extracted headers and events does not match'
5561 ,p_level => C_LEVEL_STATEMENT
5562 ,p_module => l_log_module);
5563
5564 trace
5565 (p_msg => '# of extracted headers: '
5566 ||g_hdr_extract_count
5567 ,p_level => C_LEVEL_STATEMENT
5568 ,p_module => l_log_module);
5569
5570 trace
5571 (p_msg => '# of events in xla_events_gt: '
5572 ||xla_context_pkg.get_event_count_context
5573 ,p_level => C_LEVEL_STATEMENT
5574 ,p_module => l_log_module);
5575
5576 trace
5577 (p_msg => 'Event No Header Extract Context: '
5578 ||xla_context_pkg.get_event_nohdr_context
5579 ,p_level => C_LEVEL_STATEMENT
5580 ,p_module => l_log_module);
5581
5582 END IF;
5583
5584
5585 xla_context_pkg.set_event_nohdr_context
5586 (p_nohdr_extract_flag => 'Y'
5587 ,p_client_id => sys_context('USERENV','CLIENT_IDENTIFIER'));
5588
5589 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5590 trace
5591 (p_msg => 'No Header Extract Flag is set to Y'
5595
5592 ,p_level => C_LEVEL_STATEMENT
5593 ,p_module => l_log_module);
5594 END IF;
5596 END IF;
5597
5598 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5599 trace
5600 (p_msg => 'END of CreateHeadersAndLines'
5601 ,p_level => C_LEVEL_PROCEDURE
5602 ,p_module => l_log_module);
5603 END IF;
5604
5605 RETURN l_created;
5606 EXCEPTION
5607 WHEN xla_exceptions_pkg.application_exception THEN
5608 RAISE;
5609 WHEN OTHERS THEN
5610 xla_exceptions_pkg.raise_message
5611 (p_location => 'XLA_00240_AAD_S_000003_PKG.CreateHeadersAndLines');
5612 END CreateHeadersAndLines;
5613 --
5614 --
5615
5616 --
5617 --+============================================+
5618 --| |
5619 --| PUBLIC FUNCTION |
5620 --| |
5621 --+============================================+
5622 --
5623 FUNCTION CreateJournalEntries
5624 (p_application_id IN NUMBER
5625 ,p_base_ledger_id IN NUMBER
5626 ,p_pad_start_date IN DATE
5627 ,p_pad_end_date IN DATE
5628 ,p_primary_ledger_id IN NUMBER)
5629 RETURN NUMBER IS
5630 l_log_module VARCHAR2(240);
5631 l_array_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
5632 l_temp_result BOOLEAN;
5633 l_result NUMBER;
5634 BEGIN
5635 --
5636 IF g_log_enabled THEN
5637 l_log_module := C_DEFAULT_MODULE||'.CreateJournalEntries';
5638 END IF;
5639 --
5640 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5641 trace
5642 (p_msg => 'BEGIN of CreateJournalEntries'||
5643 ' - p_base_ledger_id = '||TO_CHAR(p_base_ledger_id)
5644 ,p_level => C_LEVEL_PROCEDURE
5645 ,p_module => l_log_module);
5646
5647 END IF;
5648
5649 --
5650 g_diagnostics_mode:= xla_accounting_engine_pkg.g_diagnostics_mode;
5651
5652 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5653 trace
5654 (p_msg => 'g_diagnostics_mode = '||g_diagnostics_mode
5655 ,p_level => C_LEVEL_STATEMENT
5656 ,p_module => l_log_module);
5657 END IF;
5658 --
5659 xla_ae_journal_entry_pkg.SetProductAcctDefinition
5660 (p_product_rule_code => 'PN_LEASE_ACCOUNTING'
5661 ,p_product_rule_type_code => 'S'
5662 ,p_product_rule_version => ''
5663 ,p_product_rule_name => 'Property Manager Normalized Accounting'
5664 ,p_amb_context_code => 'DEFAULT'
5665 );
5666
5667 l_array_ledgers :=
5668 xla_ae_journal_entry_pkg.GetAlternateCurrencyLedger
5669 (p_base_ledger_id => p_base_ledger_id);
5670
5671 FOR Idx IN 1 .. l_array_ledgers.COUNT LOOP
5672 l_temp_result :=
5673 XLA_AE_JOURNAL_ENTRY_PKG.GetLedgersInfo
5674 (p_application_id => p_application_id
5675 ,p_base_ledger_id => p_base_ledger_id
5676 ,p_target_ledger_id => l_array_ledgers(Idx)
5677 ,p_primary_ledger_id => p_primary_ledger_id
5678 ,p_pad_start_date => p_pad_start_date
5679 ,p_pad_end_date => p_pad_end_date);
5680
5681 l_temp_result :=
5682 l_temp_result AND
5683 CreateHeadersAndLines
5684 (p_application_id => p_application_id
5685 ,p_base_ledger_id => p_base_ledger_id
5686 ,p_target_ledger_id => l_array_ledgers(Idx)
5687 ,p_pad_start_date => p_pad_start_date
5688 ,p_pad_end_date => p_pad_end_date
5689 ,p_primary_ledger_id => p_primary_ledger_id
5690 );
5691 END LOOP;
5692
5693
5694 IF (g_diagnostics_mode = 'Y' AND
5695 C_LEVEL_UNEXPECTED >= g_log_level AND
5696 xla_environment_pkg.g_Req_Id IS NOT NULL ) THEN
5697
5698 xla_accounting_dump_pkg.acctg_event_extract_log(
5699 p_application_id => p_application_id
5700 ,p_request_id => xla_environment_pkg.g_Req_Id
5701 );
5702
5703 END IF;
5704
5705 CASE l_temp_result
5706 WHEN TRUE THEN l_result := 0;
5707 ELSE l_result := 2;
5708 END CASE;
5709
5710 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5711 trace
5712 (p_msg => 'return value. = '||TO_CHAR(l_result)
5713 ,p_level => C_LEVEL_PROCEDURE
5714 ,p_module => l_log_module);
5715 trace
5716 (p_msg => 'END of CreateJournalEntries '
5717 ,p_level => C_LEVEL_PROCEDURE
5718 ,p_module => l_log_module);
5719 END IF;
5720
5721 RETURN l_result;
5722 EXCEPTION
5723 WHEN xla_exceptions_pkg.application_exception THEN
5724 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5725 trace
5726 (p_msg => 'ERROR. = '||sqlerrm
5727 ,p_level => C_LEVEL_PROCEDURE
5728 ,p_module => l_log_module);
5729 END IF;
5730 RAISE;
5731 WHEN OTHERS THEN
5732 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5733 trace
5734 (p_msg => 'ERROR. = '||sqlerrm
5735 ,p_level => C_LEVEL_PROCEDURE
5736 ,p_module => l_log_module);
5737 END IF;
5738 xla_exceptions_pkg.raise_message
5739 (p_location => 'XLA_00240_AAD_S_000003_PKG.CreateJournalEntries');
5740 END CreateJournalEntries;
5741 --
5742 --=============================================================================
5743 --
5744 --
5745 --
5746 --
5747 --
5748 --
5749 --
5750 --
5751 --
5752 --
5753 --
5754 --
5755 --
5756 --
5757 --
5758 --
5759 --
5760 --
5761 --
5762 --
5763 --
5764 --
5765 --=============================================================================
5766 --=============================================================================
5767 -- *********** Initialization routine **********
5768 --=============================================================================
5769
5770 BEGIN
5771 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
5772 g_log_enabled := fnd_log.test
5773 (log_level => g_log_level
5774 ,module => C_DEFAULT_MODULE);
5775
5776 IF NOT g_log_enabled THEN
5777 g_log_level := C_LEVEL_LOG_DISABLED;
5778 END IF;
5779 --
5780 END XLA_00240_AAD_S_000003_PKG;
5781 --