[Home] [Help]
PACKAGE BODY: APPS.XLA_AE_HEADER_PKG
Source
1 PACKAGE BODY xla_ae_header_pkg AS
2 /* $Header: xlajehdr.pkb 120.74.12020000.2 2012/08/25 00:03:09 vdamerla ship $ */
3 /*===========================================================================+
4 | Copyright (c) 2001-2002 Oracle Corporation |
5 | Redwood Shores, CA, USA |
6 | All rights reserved. |
7 +============================================================================+
8 | PACKAGE NAME |
9 | XLA_AE_HEADER_PKG |
10 | |
11 | DESCRIPTION |
12 | |
13 | |
14 | HISTORY |
15 | 20-NOV-2002 K.Boussema Created |
16 | 08-JAN-2003 K.Boussema Changed xla_temp_journal_entries by |
17 | xla_journal_entries_temp |
18 | 10-JAN-2003 K.Boussema Removed gl_sl_link_id column from temp table |
19 | Added 'dbdrv' command |
20 | 10-MAR-2003 K.Boussema Made changes for the new bulk approach of the|
21 | accounting engine |
22 | Changed xla_journal_entries_temp by |
23 | xla_je_lines_temp |
24 | 01-APR-2003 K.Boussema Included amb_context_code |
25 | 03-APR-2003 K.Boussema Included Analytical criteria feature |
26 | 19-APR-2003 K.Boussema Included Error messages |
27 | 22-APR-2003 K.Boussema Added DOC_CATEGORY_NAME source |
28 | 28-APR-2003 K.Boussema Added validation of Accounting Event Extract |
29 | bug 2925651 |
30 | 06-MAI-2003 K.Boussema Modifcation included for bug2936071 |
31 | 13-MAI-2003 K.Boussema Renamed temporary tables xla_je_lines_gt by |
32 | xla_ae_lines_gt, xla_je_headers_gt by |
33 | xla_ae_headers_gt |
34 | Renamed in xla_distribution_links the column |
35 | base_amount by ledger_amount |
36 | 20-MAI-2003 K.Boussema Added a Token to XLA_AP_CANNOT_INSERT_JE |
37 | message |
38 | 27-MAI-2003 K.Boussema Renamed the Document seq. Accounting sources |
39 | 27-MAI-2003 K.Boussema Renamed code_combination_status by |
40 | code_combination_status_flag |
41 | Renamed base_amount by ledger_amount |
42 | 30-MAI-2003 K.Boussema Renamed BUSGET_VERSION_ID by BUDGET_VERSION_ID|
43 | bug 2981358 |
44 | 11-JUN-2003 K.Boussema Renamed Sequence columns, bug 3000007 |
45 | 23-JUN-2003 K.Boussema Updated the call to get_period_name bug3005754|
46 | 17-JUL-2003 K.Boussema Reviewd the code |
47 | 17-SEP-2003 K.Boussema Updated to Get je_category from cache:3109690|
48 | 19-SEP-2003 K.Boussema Code changed to include reversed_ae_header_id|
49 | and reversed_line_num, see bug 3143095 |
50 | 03-OCT-2003 K.Boussema Changed description width to 1996 |
51 | 16-OCT-2003 K.Boussema Fixed the issue when the entered and |
52 | accounted amounts are reversed. |
53 | 22-OCT-2003 K.Boussema Changed to capture the Merge Matching Lines |
54 | preference for Accounting Reversal from JLT |
55 | 26-NOV-2003 K.Boussema Removed the insert of the sl_coa_mapping name|
56 | for change third party lines, bug 3278955 |
57 | 12-DEC-2003 K. Boussema Renamed target_coa_id in xla_ae_lines_gt |
58 | by ccid_coa_id |
59 | Reviewed the InsertHeaders, bug 3042840 |
60 | 18-DEC-2003 K.Boussema Changed to fix bug 3042840,3307761,3268940 |
61 | 3310291 and 3320689 |
62 | 07-JAN-2004 K.Boussema Changed to populate switch_side_flag column |
63 | 19-JAN-2004 K.Boussema Removed the validation of doc sequence |
64 | 05-FEB-2004 S.Singhania Changes based on bug 3419803. |
65 | - correct column names are used |
66 | TAX_LINE_REF_ID, TAX_SUMMARY_LINE_REF_ID,|
67 | TAX_REC_NREC_DIST_REF_ID |
68 | - reference to the column is removed. |
69 | TAX_REC_NREC_SUMMARY_DIST_REF |
70 | 17-FEB-2004 K.Boussema Made changes for the FND_LOG. |
71 | passed ae_header_id to error messages |
72 | 12-MAR-2004 K.Boussema Removed the validation of the party type |
73 | 22-MAR-2004 K.Boussema Added a parameter p_module to the TRACE calls|
74 | and the procedure. |
75 | 29-MAR-2204 K.Boussema Changed based on bug 3528667 |
76 | - added get_period_name function to retrieve|
77 | the period_name from gl_period_statuses |
78 | - added the cache of period_name |
79 | - changed the insert into xla_ae_headers_gt |
80 | 11-MAY-2004 K.Boussema Removed the call to XLA trace routine from |
81 | trace() procedure |
82 | 17-MAY-2004 W.Shen change for attribute enhancement project |
83 | 1. add TransactionReversal procedure from |
84 | lines package |
85 | 2. SetHdrAccountingSource, add gl_transfer_flag|
86 | and trx_acct_reversal_option |
87 | 3. SetHdrAccountingSource, add gl_date |
88 | 4. change to InsertHeaders procedure |
89 | 5. rename reversed_ae_header_id to |
90 | ref_ae_header_id, reversed_ae_line_num to |
91 | ref_ae_line_num |
92 | 26-MAY-2004 W.Shen change error message |
93 | 02-JUL-2004 W.Shen if gl_transfer_flag is not mapped at all, set |
94 | the default value to 'N' instead of 'NT' |
95 | bug 3741223 |
96 | 27-JUL-2004 W.Shen In SetHeaderId, if all the 3 flag is 'N', |
97 | (which is the case when transaction reversal)|
98 | 3 header ids are generated and assigned |
99 | bug 3786980 |
100 | 23-Sep-2004 S.Singhania Made changes for the bulk peroformance. It has |
101 | changed the code at number of places. |
102 | 25-May-2005 W. Shen Remove column ledger_amount,entered amount |
103 | from xla_distribution_links, change the |
104 | function change_third_party to remove the |
105 | reference to the columns. |
106 | 11-Jul-2005 A. Wan Changed for MPA. 4262811 |
107 | 01-Aug-2005 W. Chan 4458381 - Public Sector Enhancement |
108 | 18-Oct-2005 V. Kumar Removed code for Analytical Criteria |
109 | 23-Nov-2005 V. Kumar Bug 4752774 - Added Hints for performance |
110 | 3-Jan-2006 W. Chan Bug 4924492 - Populate budget version id for |
111 | accounting reversal |
112 | 20-JAN-2006 A.Wan 4884853 add GetAccrualRevDate |
113 | 07-FEB-2006 A.Wan 4897417 error if MPA's GL periods not defined. |
114 | 13-Feb-2006 A.Wan 4955764 - set MPA's g_rec_lines.array_gl_date |
115 | 16-Apr-2006 A.Wan 5132302 - applied to amt for Gain/Loss |
116 | 09-May-2006 A.Wan 5161760 - chk header attributes is valid. |
117 | 21-Jun-2006 A.Wan 5100860 Performance fix, see bug for detail |
118 | 01-Mar-2009 VGOPISET 7109881 Changed the call of CopyLineInfo from |
119 | CreateRecongitionEntries procedure |
120 | 01-Mar-2009 VGOPISET 8214450 Changed GetRecognitionEntries to use |
121 | CEIL rather than ROUND in calculating |
122 | future GL_DATE for ORIGINATIONDAY option|
123 | 14-May-2010 VGOPISET 9630931 Added filter of 6 Months while deriving|
124 | the next transaction date. |
125 | 1-Sep-2010 VGOPISET 10047074 Perf Change to Lines Update in |
126 | in ValidateBusinessDate |
127 | 06-Sep-2010 VGOPISET 9954676 Added call to InsertMpaTrxAcctCopyInfo |
128 | to populate MPA Recog Line Trx COA data in the |
129 | procedure CreateRecongitionEntries |
130 | 02-Nov-2010 VGOPISET 10229047 U1 Hint added in Headers update of |
131 | accounting date in ValidateBusinessDate |
132 | 27-Jan-2011 VGOPISET 11654120 GetRecognitionEntries change for MPA |
133 | with proration code as FIRST_PERIOD |
134 | 11-Oct-2011 VGOPISET 13018752 added P_TRX_GL_DATE as the new param |
135 | in GetRecognitionEntries to ensure Recog Period|
136 | is never before the Accrual Entry Period. |
137 +===========================================================================*/
138 --
139 --+==========================================================================+
140 --| |
141 --| |
142 --| CONSTANTS |
143 --| |
144 --| |
145 --+==========================================================================+
146 --
147 --
148 C_VALID CONSTANT NUMBER := 0;
149 C_INVALID CONSTANT NUMBER := 1;
150 --
151 --
152 C_STANDARD CONSTANT VARCHAR2(30) := 'STANDARD';
153 C_INVALID_STATUS CONSTANT VARCHAR2(1) := 'I';
154 C_DRAFT_STATUS CONSTANT VARCHAR2(1) := 'D';
155 C_FINAL_STATUS CONSTANT VARCHAR2(1) := 'F';
156 --
157 -- bulk performance
158 C_INCOMPLETE CONSTANT VARCHAR2(1) := 'X';
159 --
160 C_ACTUAL CONSTANT VARCHAR2(1) := 'A';
161 C_BUDGET CONSTANT VARCHAR2(1) := 'B';
162 C_ENCUMBRANCE CONSTANT VARCHAR2(1) := 'E';
163 --
164 --
165 C_ALL CONSTANT VARCHAR2(1) := 'A';
166 C_SAME_SIDE CONSTANT VARCHAR2(1) := 'W';
167 C_NO_MERGE CONSTANT VARCHAR2(1) := 'N';
168 --
169 C_CCID CONSTANT VARCHAR2(30) := 'CREATED';
170
171 -- Application id for GL
172 C_GL_APPLICATION_ID CONSTANT INTEGER := 101;
173 --
174 C_SWITCH CONSTANT VARCHAR2(1) := 'Y';
175 C_NO_SWITCH CONSTANT VARCHAR2(1) := 'N';
176 --
177 --====================================================================
178 --
179 --
180 --
181 --
182 --
183 -- FND_LOG trace
184 --
185 --
189 --
186 --
187 --
188 --
190 --
191 --
192 --
193 --
194 --
195 --
196 --
197 --
198 --
199 --
200 --======================================================================
201 --=============================================================================
202 -- *********** Local Trace Routine **********
203 --=============================================================================
204
205 C_LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
206 C_LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
207 C_LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
208 C_LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
209 C_LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
210 C_LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
211
212 C_LEVEL_LOG_DISABLED CONSTANT NUMBER := 99;
213 C_DEFAULT_MODULE CONSTANT VARCHAR2(240) := 'xla.plsql.XLA_AE_HEADER_PKG';
214
215 --
216 --+==========================================================================+
217 --| |
218 --| |
219 --| PL/SQL structures |
220 --| |
221 --| |
222 --+==========================================================================+
223 --
224 -- period_name cache structure
225 --
226 TYPE t_rec_period_name IS RECORD
227 (period_name VARCHAR2(25)
228 ,ledger_id NUMBER
229 ,start_date DATE
230 ,end_date DATE
231 )
232 ;
233 --
234 --
235 --+==========================================================================+
236 --| |
237 --| |
238 --| Global Variables |
239 --| |
240 --| |
241 --+==========================================================================+
242 --
243 -- period_name cache
244 --
245 g_cache_period_name t_rec_period_name;
246 g_application_id INTEGER := xla_accounting_cache_pkg.GetValueNum('XLA_EVENT_APPL_ID');
247
248 --
249 --
250 -- FND log global variables
251 --
252
253 g_log_level NUMBER;
254 g_log_enabled BOOLEAN;
255
256 --====================================================================
257 --
258 --
259 --
260 --
261 --
262 -- list of PRIVATE procedures and functions
263 --
264 --
265 --
266 --
267 --
268 --
269 --
270 --
271 --
272 --
273 --
274 --
275 --
276 --
277 --
278 --
279 --======================================================================
280 PROCEDURE trace (
281 p_msg IN VARCHAR2
282 ,p_level IN NUMBER
283 ,p_module IN VARCHAR2 DEFAULT C_DEFAULT_MODULE
284 )
285 ;
286
287 --====================================================================
288 --
289 --
290 --
291 --
292 --
293 -- PRIVATE procedures and functions
294 --
295 --
296 --
297 --
298 --
299 --
300 --
301 --
302 --
303 --
304 --
305 --
306 --
307 --
308 --
309 --
310 --======================================================================
311 --
312 /*======================================================================+
313 | |
314 | Private Procedure |
315 | |
316 | trace |
317 +======================================================================*/
318 PROCEDURE trace
319 (p_msg IN VARCHAR2
320 ,p_level IN NUMBER
321 ,p_module IN VARCHAR2 DEFAULT C_DEFAULT_MODULE) IS
322 BEGIN
323
324 ----------------------------------------------------------------------------
325 -- Following is for FND log.
326 ----------------------------------------------------------------------------
327 IF (p_msg IS NULL AND p_level >= g_log_level) THEN
328 fnd_log.message(p_level, p_module);
329 ELSIF p_level >= g_log_level THEN
330 fnd_log.string(p_level, p_module, p_msg);
331 END IF;
332
333 EXCEPTION
334 WHEN xla_exceptions_pkg.application_exception THEN
335 RAISE;
336 WHEN OTHERS THEN
337 xla_exceptions_pkg.raise_message
338 (p_location => 'XLA_AE_HEADER_PKG.trace');
339 END trace;
340 --
341 --
342 --====================================================================
343 --
344 --
345 --
346 --
347 --
348 -- PUBLIC procedures and functions
349 --
350 --
351 --
352 --
353 --
354 --
355 --
356 --
357 --
358 --
359 --
360 --
361 --
362 --
363 --
364 --
368 | |
365 --======================================================================
366 --
367 /*======================================================================+
369 | Public Procedure |
370 | |
371 | |
372 +======================================================================*/
373 --bulk performance
374 -- modified to initilize a record in array
375 PROCEDURE InitHeader
376 (p_header_idx in number)
377 IS
378 --l_rec_header_new_line t_rec_header_new;
379 l_log_module VARCHAR2(240);
380 BEGIN
381 --
382 IF g_log_enabled THEN
383 l_log_module := C_DEFAULT_MODULE||'.InitHeader';
384 END IF;
385 --
386 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
387 trace
388 (p_msg => 'BEGIN of InitHeader'
389 ,p_level => C_LEVEL_PROCEDURE
390 ,p_module => l_log_module);
391 trace
392 (p_msg => 'p_header_idx = '||p_header_idx
393 ,p_level => C_LEVEL_PROCEDURE
394 ,p_module => l_log_module);
395
396 END IF;
397 -- g_header_idx is used as index for array values in g_rec_header_new
398 -- This is a counter coming from header loop in aad package. For each
399 -- header fetched (one header per event) incremented counter value is passed
400 -- as p_header_idx
401 g_header_idx := p_header_idx;
402
403 -- This initializes a new row in the array values in g_rec_header_new to NULL;
404 g_rec_header_new.array_event_type_code(g_header_idx) := NULL;
405 g_rec_header_new.array_event_id(g_header_idx) := NULL;
406 g_rec_header_new.array_entity_id(g_header_idx) := NULL;
407 --
408 g_rec_header_new.array_header_num(g_header_idx) := 0; -- 4262811
409 g_rec_header_new.array_parent_header_id(g_header_idx) := NULL; -- 4262811
410 g_rec_header_new.array_parent_line_num(g_header_idx) := NULL; -- 4262811
411 g_rec_header_new.array_accrual_reversal_flag(g_header_idx) := 'N'; -- 4262811
412 g_rec_header_new.array_acc_rev_gl_date_option(g_header_idx) := 'NONE'; -- 4262811
413 --
414 g_rec_header_new.array_target_ledger_id(g_header_idx) := NULL;
415 g_rec_header_new.array_actual_header_id(g_header_idx) := NULL;
416 g_rec_header_new.array_budget_header_id(g_header_idx) := NULL;
417 g_rec_header_new.array_encumb_header_id(g_header_idx) := NULL;
418 g_rec_header_new.array_je_category_name(g_header_idx) := NULL;
419 g_rec_header_new.array_period_name(g_header_idx) := NULL;
420 g_rec_header_new.array_description(g_header_idx) := NULL;
421 g_rec_header_new.array_doc_sequence_id(g_header_idx) := NULL;
422 g_rec_header_new.array_doc_sequence_value(g_header_idx) := NULL;
423 g_rec_header_new.array_doc_category_code(g_header_idx) := NULL;
424 g_rec_header_new.array_budget_version_id(g_header_idx) := NULL;
425 --g_rec_header_new.array_encumbrance_type_id(g_header_idx) := NULL; -- 4458381
426 g_rec_header_new.array_party_change_option(g_header_idx) := NULL;
427 g_rec_header_new.array_party_change_type(g_header_idx) := NULL;
428 g_rec_header_new.array_new_party_id(g_header_idx) := NULL;
429 g_rec_header_new.array_new_party_site_id(g_header_idx) := NULL;
430 g_rec_header_new.array_previous_party_id(g_header_idx) := NULL;
431 g_rec_header_new.array_previous_party_site_id(g_header_idx) := NULL;
432 g_rec_header_new.array_gl_transfer_flag(g_header_idx) := NULL;
433 g_rec_header_new.array_trx_acct_reversal_option(g_header_idx) := NULL;
434 g_rec_header_new.array_gl_date(g_header_idx) := NULL;
435 --
436 g_rec_header_new.array_anc_id_1(g_header_idx) := NULL;
437 g_rec_header_new.array_anc_id_2(g_header_idx) := NULL;
438 g_rec_header_new.array_anc_id_3(g_header_idx) := NULL;
439 g_rec_header_new.array_anc_id_4(g_header_idx) := NULL;
440 g_rec_header_new.array_anc_id_5(g_header_idx) := NULL;
441 g_rec_header_new.array_anc_id_6(g_header_idx) := NULL;
442 g_rec_header_new.array_anc_id_7(g_header_idx) := NULL;
443 g_rec_header_new.array_anc_id_8(g_header_idx) := NULL;
444 g_rec_header_new.array_anc_id_9(g_header_idx) := NULL;
445 g_rec_header_new.array_anc_id_10(g_header_idx) := NULL;
446 g_rec_header_new.array_anc_id_11(g_header_idx) := NULL;
447 g_rec_header_new.array_anc_id_12(g_header_idx) := NULL;
448 g_rec_header_new.array_anc_id_13(g_header_idx) := NULL;
449 g_rec_header_new.array_anc_id_14(g_header_idx) := NULL;
450 g_rec_header_new.array_anc_id_15(g_header_idx) := NULL;
451 g_rec_header_new.array_anc_id_16(g_header_idx) := NULL;
452 g_rec_header_new.array_anc_id_17(g_header_idx) := NULL;
453 g_rec_header_new.array_anc_id_18(g_header_idx) := NULL;
454 g_rec_header_new.array_anc_id_19(g_header_idx) := NULL;
455 g_rec_header_new.array_anc_id_20(g_header_idx) := NULL;
456 g_rec_header_new.array_anc_id_21(g_header_idx) := NULL;
457 g_rec_header_new.array_anc_id_22(g_header_idx) := NULL;
458 g_rec_header_new.array_anc_id_23(g_header_idx) := NULL;
459 g_rec_header_new.array_anc_id_24(g_header_idx) := NULL;
460 g_rec_header_new.array_anc_id_25(g_header_idx) := NULL;
461 g_rec_header_new.array_anc_id_26(g_header_idx) := NULL;
462 g_rec_header_new.array_anc_id_27(g_header_idx) := NULL;
463 g_rec_header_new.array_anc_id_28(g_header_idx) := NULL;
464 g_rec_header_new.array_anc_id_29(g_header_idx) := NULL;
465 g_rec_header_new.array_anc_id_30(g_header_idx) := NULL;
466 g_rec_header_new.array_anc_id_31(g_header_idx) := NULL;
467 g_rec_header_new.array_anc_id_32(g_header_idx) := NULL;
471 g_rec_header_new.array_anc_id_36(g_header_idx) := NULL;
468 g_rec_header_new.array_anc_id_33(g_header_idx) := NULL;
469 g_rec_header_new.array_anc_id_34(g_header_idx) := NULL;
470 g_rec_header_new.array_anc_id_35(g_header_idx) := NULL;
472 g_rec_header_new.array_anc_id_37(g_header_idx) := NULL;
473 g_rec_header_new.array_anc_id_38(g_header_idx) := NULL;
474 g_rec_header_new.array_anc_id_39(g_header_idx) := NULL;
475 g_rec_header_new.array_anc_id_40(g_header_idx) := NULL;
476 g_rec_header_new.array_anc_id_41(g_header_idx) := NULL;
477 g_rec_header_new.array_anc_id_42(g_header_idx) := NULL;
478 g_rec_header_new.array_anc_id_43(g_header_idx) := NULL;
479 g_rec_header_new.array_anc_id_44(g_header_idx) := NULL;
480 g_rec_header_new.array_anc_id_45(g_header_idx) := NULL;
481 g_rec_header_new.array_anc_id_46(g_header_idx) := NULL;
482 g_rec_header_new.array_anc_id_47(g_header_idx) := NULL;
483 g_rec_header_new.array_anc_id_48(g_header_idx) := NULL;
484 g_rec_header_new.array_anc_id_49(g_header_idx) := NULL;
485 g_rec_header_new.array_anc_id_50(g_header_idx) := NULL;
486 g_rec_header_new.array_anc_id_51(g_header_idx) := NULL;
487 g_rec_header_new.array_anc_id_52(g_header_idx) := NULL;
488 g_rec_header_new.array_anc_id_53(g_header_idx) := NULL;
489 g_rec_header_new.array_anc_id_54(g_header_idx) := NULL;
490 g_rec_header_new.array_anc_id_55(g_header_idx) := NULL;
491 g_rec_header_new.array_anc_id_56(g_header_idx) := NULL;
492 g_rec_header_new.array_anc_id_57(g_header_idx) := NULL;
493 g_rec_header_new.array_anc_id_58(g_header_idx) := NULL;
494 g_rec_header_new.array_anc_id_59(g_header_idx) := NULL;
495 g_rec_header_new.array_anc_id_60(g_header_idx) := NULL;
496 g_rec_header_new.array_anc_id_61(g_header_idx) := NULL;
497 g_rec_header_new.array_anc_id_62(g_header_idx) := NULL;
498 g_rec_header_new.array_anc_id_63(g_header_idx) := NULL;
499 g_rec_header_new.array_anc_id_64(g_header_idx) := NULL;
500 g_rec_header_new.array_anc_id_65(g_header_idx) := NULL;
501 g_rec_header_new.array_anc_id_66(g_header_idx) := NULL;
502 g_rec_header_new.array_anc_id_67(g_header_idx) := NULL;
503 g_rec_header_new.array_anc_id_68(g_header_idx) := NULL;
504 g_rec_header_new.array_anc_id_69(g_header_idx) := NULL;
505 g_rec_header_new.array_anc_id_70(g_header_idx) := NULL;
506 g_rec_header_new.array_anc_id_71(g_header_idx) := NULL;
507 g_rec_header_new.array_anc_id_72(g_header_idx) := NULL;
508 g_rec_header_new.array_anc_id_73(g_header_idx) := NULL;
509 g_rec_header_new.array_anc_id_74(g_header_idx) := NULL;
510 g_rec_header_new.array_anc_id_75(g_header_idx) := NULL;
511 g_rec_header_new.array_anc_id_76(g_header_idx) := NULL;
512 g_rec_header_new.array_anc_id_77(g_header_idx) := NULL;
513 g_rec_header_new.array_anc_id_78(g_header_idx) := NULL;
514 g_rec_header_new.array_anc_id_79(g_header_idx) := NULL;
515 g_rec_header_new.array_anc_id_80(g_header_idx) := NULL;
516 g_rec_header_new.array_anc_id_81(g_header_idx) := NULL;
517 g_rec_header_new.array_anc_id_82(g_header_idx) := NULL;
518 g_rec_header_new.array_anc_id_83(g_header_idx) := NULL;
519 g_rec_header_new.array_anc_id_84(g_header_idx) := NULL;
520 g_rec_header_new.array_anc_id_85(g_header_idx) := NULL;
521 g_rec_header_new.array_anc_id_86(g_header_idx) := NULL;
522 g_rec_header_new.array_anc_id_87(g_header_idx) := NULL;
523 g_rec_header_new.array_anc_id_88(g_header_idx) := NULL;
524 g_rec_header_new.array_anc_id_89(g_header_idx) := NULL;
525 g_rec_header_new.array_anc_id_90(g_header_idx) := NULL;
526 g_rec_header_new.array_anc_id_91(g_header_idx) := NULL;
527 g_rec_header_new.array_anc_id_92(g_header_idx) := NULL;
528 g_rec_header_new.array_anc_id_93(g_header_idx) := NULL;
529 g_rec_header_new.array_anc_id_94(g_header_idx) := NULL;
530 g_rec_header_new.array_anc_id_95(g_header_idx) := NULL;
531 g_rec_header_new.array_anc_id_96(g_header_idx) := NULL;
532 g_rec_header_new.array_anc_id_97(g_header_idx) := NULL;
533 g_rec_header_new.array_anc_id_98(g_header_idx) := NULL;
534 g_rec_header_new.array_anc_id_99(g_header_idx) := NULL;
535 g_rec_header_new.array_anc_id_100(g_header_idx) := NULL;
536
537 --
538 g_rec_header_new.array_event_number(g_header_idx) := NULL;
539
540 --
541 -- bulk performance
542 -- Following may not be needed in the bulk approach as
543 -- je status is handled in a different way.
544 -- XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
545 --
546 -- bulk performance
547 -- following initial1ses the status of je headers for each balance type
548 -- initial status is kept as 'valid'
549 g_rec_header_new.array_actual_status(g_header_idx) := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
550 g_rec_header_new.array_budget_status(g_header_idx) := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
551 g_rec_header_new.array_encumbrance_status(g_header_idx) := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
552
553 /* Events Process_Status_Code Update is soley written with X as SUCCESS so any
554 * change in the code to represent SUCCESS/New Status Code changes please revisit the code
555 * changes in xlajeaex.pkb PostAccountingEngine code done for bug#9086275 */
556
557 g_rec_header_new.array_event_status(g_header_idx) := 'X'; -- X indicates processed sucessfully.
558
559 --
560 --
561 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
562 trace
563 (p_msg => 'END of InitHeader'
564 ,p_level => C_LEVEL_PROCEDURE
565 ,p_module => l_log_module);
566
567 END IF;
568 EXCEPTION
569 WHEN xla_exceptions_pkg.application_exception THEN
570 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
571 RAISE;
572 WHEN OTHERS THEN
573 xla_exceptions_pkg.raise_message
574 (p_location => 'XLA_AE_HEADER_PKG.InitHeader');
575 --
576 END InitHeader;
577 --
578
579
583 | |
580 /*======================================================================+
581 | |
582 | Public Procedure - 4884853 |
584 | |
585 +======================================================================*/
586 PROCEDURE GetAccrualRevDate(
587 p_hdr_idx IN NUMBER
588 , p_ledger_id IN NUMBER
589 , p_gl_date IN DATE
590 , p_gl_date_option IN VARCHAR2
591 )
592 IS
593 --
594 CURSOR c_one_period IS
595 SELECT period_name
596 ,CASE p_gl_date_option
597 WHEN 'XLA_FIRST_DAY_NEXT_GL_PERIOD' THEN start_date
598 WHEN 'XLA_LAST_DAY_NEXT_GL_PERIOD' THEN end_date
599 ELSE p_gl_date + 1
600 END GL_DATE
601 FROM gl_period_statuses gps
602 WHERE gps.application_id = 101
603 AND gps.ledger_id = p_ledger_id
604 AND gps.adjustment_period_flag = 'N'
605 AND p_gl_date < gps.start_date
606 ORDER BY gps.start_date ASC;
607
608
609 l_period_name gl_period_statuses.period_name%TYPE;
610 l_accrev_date DATE;
611 l_log_module VARCHAR2(240);
612
613
614 BEGIN
615
616 IF g_log_enabled THEN
617 l_log_module := C_DEFAULT_MODULE||'.GetAccrualRevDate';
618 END IF;
619 --
620 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
621 trace
622 (p_msg => 'BEGIN of GetAccrualRevDate'
623 ,p_level => C_LEVEL_PROCEDURE
624 ,p_module => l_log_module);
625
626 END IF;
627
628 l_period_name := NULL;
629 OPEN c_one_period;
630 FETCH c_one_period INTO l_period_name, l_accrev_date;
631 IF c_one_period%NOTFOUND or l_accrev_date < p_gl_date THEN
632 l_accrev_date := p_gl_date;
633 END IF;
634 CLOSE c_one_period;
635
636 g_rec_header_new.array_gl_date(p_hdr_idx) := l_accrev_date;
637 IF l_period_name IS NOT NULL THEN
638 g_rec_header_new.array_period_name(p_hdr_idx) := l_period_name;
639 END IF;
640
641 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
642 trace
643 (p_msg => 'g_rec_header_new.array_gl_date = '||g_rec_header_new.array_gl_date(p_hdr_idx)||
644 ' g_rec_header_new.array_period_name = '||g_rec_header_new.array_period_name(p_hdr_idx)
645 ,p_level => C_LEVEL_STATEMENT
646 ,p_module => l_log_module);
647 END IF;
648
649
650 EXCEPTION
651 WHEN xla_exceptions_pkg.application_exception THEN
652 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
653 trace
654 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
655 ,p_level => C_LEVEL_EXCEPTION
656 ,p_module => l_log_module);
657 END IF;
658 RAISE;
659 WHEN OTHERS THEN
660 xla_exceptions_pkg.raise_message
661 (p_location => 'xla_ae_header_pkg.GetAccrualRevDate');
662 END GetAccrualRevDate;
663
664
665 /*======================================================================+
666 | |
667 | Public Procedure - 4262811 |
668 | |
669 | |
670 +======================================================================*/
671 PROCEDURE GetRecognitionEntriesInfo(
672 p_ledger_id IN NUMBER
673 , p_start_date IN DATE
674 , p_end_date IN DATE
675 , p_gl_date_option IN VARCHAR2
676 , p_num_entries_option IN VARCHAR2
677 , p_proration_code IN VARCHAR2
678 , p_calculate_acctd_flag IN VARCHAR2 -- 4262811b for accounted amount
679 , p_same_currency IN BOOLEAN -- 4262811b for accounted amount
680 , p_accted_amt IN NUMBER -- this should be the unrounded_accounted_amount
681 , p_entered_amt IN NUMBER -- this should be the unrounded_entered_amount
682 , p_bflow_applied_to_amt IN NUMBER -- 5132302
683 , x_num_entries IN OUT NOCOPY NUMBER
684 , x_gl_dates IN OUT NOCOPY xla_ae_journal_entry_pkg.t_array_date
685 , x_accted_amts IN OUT NOCOPY xla_ae_journal_entry_pkg.t_array_num
686 , x_entered_amts IN OUT NOCOPY xla_ae_journal_entry_pkg.t_array_num
687 , x_period_names IN OUT NOCOPY xla_ae_journal_entry_pkg.t_array_V15L
688 , x_bflow_applied_to_amts IN OUT NOCOPY xla_ae_journal_entry_pkg.t_array_num -- 5132302
689 , p_trx_gl_date IN DATE -- added for bug13018752
690 )
691 IS
692 --
693 /* commented cursor for bug13018752
694 cursor c_one_period is
695 SELECT period_name
696 ,CASE p_gl_date_option
697 WHEN 'FIRST_DAY_GL_PERIOD' THEN start_date
698 WHEN 'LAST_DAY_GL_PERIOD' THEN end_date
699 -- ELSE ADD_MONTHS(p_start_date, ROUND(MONTHS_BETWEEN(start_date, p_start_date))) -- originating_day
700 ELSE ADD_MONTHS(p_start_date, CEIL(MONTHS_BETWEEN(start_date, p_start_date))) -- originating_day
701 -- changed from ROUND to CEIL for bug: 8214450
702 END GL_DATE
703 FROM gl_period_statuses gps
704 WHERE gps.application_id = 101
705 AND gps.ledger_id = p_ledger_id
706 AND gps.adjustment_period_flag = 'N'
707 AND p_end_date BETWEEN gps.start_date AND gps.end_date
708 ORDER BY gps.start_date DESC;
709 */
710
711 -- bug13018752
715 -- Accrual Entry Gl Date is passed in the new paramter p_trx_gl_date
712 -- Re-wrote the Cursor to ensure that MPA Recognition Entry Date should be reset to the
713 -- Period in which Accrual Entry is Created when the Final Recognition Entry Period is Prior to
714 -- Accrual Entry period.
716 cursor c_one_period is
717 SELECT CASE
718 WHEN gps_mpa.effective_period_num < gps_orig.effective_period_num
719 THEN gps_orig.period_name
720 ELSE gps_mpa.period_name
721 END period_name
722 ,CASE p_gl_date_option
723 WHEN 'FIRST_DAY_GL_PERIOD' THEN CASE
724 WHEN gps_mpa.effective_period_num < gps_orig.effective_period_num
725 THEN gps_orig.start_date
726 ELSE gps_mpa.start_date
727 END
728 WHEN 'LAST_DAY_GL_PERIOD' THEN CASE
729 WHEN gps_mpa.effective_period_num < gps_orig.effective_period_num
730 THEN gps_orig.end_date
731 ELSE gps_mpa.end_date
732 END
733 ELSE CASE
734 WHEN gps_mpa.effective_period_num < gps_orig.effective_period_num
735 THEN ADD_MONTHS(p_start_date, CEIL(MONTHS_BETWEEN(gps_orig.start_date, p_start_date)))
736 ELSE ADD_MONTHS(p_start_date, CEIL(MONTHS_BETWEEN(gps_mpa.start_date, p_start_date)))
737 END
738 END GL_DATE
739 FROM gl_period_statuses gps_mpa
740 , gl_period_statuses gps_orig
741 WHERE gps_mpa.application_id = 101
742 AND gps_mpa.ledger_id = p_ledger_id
743 AND gps_mpa.adjustment_period_flag = 'N'
744 AND p_end_date BETWEEN gps_mpa.start_date AND gps_mpa.end_date
745 AND gps_orig.application_id = 101
746 AND gps_orig.ledger_id = p_ledger_id
747 AND gps_orig.adjustment_period_flag = 'N'
748 AND p_trx_gl_date between gps_orig.start_date and gps_orig.end_date
749 ORDER BY gps_mpa.start_date DESC;
750
751 --
752 -- Cursor to populate the recognition journal entry
753 --
754 /*
755 CURSOR c_periods IS
756 SELECT period_name,
757 CASE p_gl_date_option
758 WHEN 'FIRST_DAY_GL_PERIOD' THEN start_date
759 WHEN 'LAST_DAY_GL_PERIOD' THEN end_date
760 --ELSE ADD_MONTHS(p_start_date, ROUND(MONTHS_BETWEEN(start_date, p_start_date))) -- originating_day
761 ELSE ADD_MONTHS(p_start_date, CEIL(MONTHS_BETWEEN(start_date, p_start_date))) -- originating_day
762 -- changed from ROUND to CEIL for bug: 8214450
763 END GL_DATE,
764 -- closing_status, -- Not needed. Updated in PostAccountingEngine (?)
765 CASE p_proration_code
766 WHEN '360_DAYS' THEN 30
767 ELSE end_date-start_date+1
768 END DAYS_IN_PERIOD,
769 CASE p_proration_code
770 WHEN '360_DAYS' THEN least(end_date-p_start_date+1,30)
771 ELSE end_date-p_start_date+1
772 END DAYS_IN_FIRST_PERIOD, -- only valid for first period
773 CASE p_proration_code
774 WHEN '360_DAYS' THEN least(p_end_date-start_date+1,30)
775 ELSE p_end_date-start_date+1
776 END DAYS_IN_LAST_PERIOD -- only valid for last period
777 FROM gl_period_statuses
778 WHERE application_id = 101
779 AND ledger_id = p_ledger_id
780 AND adjustment_period_flag = 'N'
781 AND end_date >= p_start_date -- included boundary conditions for bug12939974
782 AND start_date <= p_end_date -- included boundary conditions for bug12939974
783 ORDER BY start_date;
784 */
785 -- bug13018752
786 -- Re-wrote the Cursor to ensure that MPA Recognition Entry Date should be reset to the
787 -- Period in which Accrual Entry is Created when the Recognition Entry Period is Prior to
788 -- Accrual Entry period.
789 -- Accrual Entry Gl Date is passed in the new paramter p_trx_gl_date
790 CURSOR c_periods IS
791 SELECT CASE
792 WHEN gps_mpa.effective_period_num < gps_orig.effective_period_num
793 THEN gps_orig.period_name
794 ELSE gps_mpa.period_name
795 END period_name ,
796 CASE p_gl_date_option
797 WHEN 'FIRST_DAY_GL_PERIOD' THEN CASE
798 WHEN gps_mpa.effective_period_num < gps_orig.effective_period_num
799 THEN gps_orig.start_date
800 ELSE gps_mpa.start_date
801 END
802 WHEN 'LAST_DAY_GL_PERIOD' THEN CASE
803 WHEN gps_mpa.effective_period_num < gps_orig.effective_period_num
804 THEN gps_orig.end_date
805 ELSE gps_mpa.end_date
806 END
807 ELSE CASE
808 WHEN gps_mpa.effective_period_num < gps_orig.effective_period_num
809 THEN ADD_MONTHS(p_start_date, CEIL(MONTHS_BETWEEN(gps_orig.start_date, p_start_date)))
810 ELSE ADD_MONTHS(p_start_date, CEIL(MONTHS_BETWEEN(gps_mpa.start_date, p_start_date)))
811 END
812 END GL_DATE,
813 CASE p_proration_code
814 WHEN '360_DAYS' THEN 30
815 ELSE gps_mpa.end_date-gps_mpa.start_date+1
819 ELSE gps_mpa.end_date-p_start_date+1
816 END DAYS_IN_PERIOD,
817 CASE p_proration_code
818 WHEN '360_DAYS' THEN least(gps_mpa.end_date-p_start_date+1,30)
820 END DAYS_IN_FIRST_PERIOD, -- only valid for first period
821 CASE p_proration_code
822 WHEN '360_DAYS' THEN least(p_end_date-gps_mpa.start_date+1,30)
823 ELSE p_end_date-gps_mpa.start_date+1
824 END DAYS_IN_LAST_PERIOD -- only valid for last period
825 FROM gl_period_statuses gps_mpa
826 ,gl_period_statuses gps_orig
827 WHERE gps_mpa.application_id = 101
828 AND gps_mpa.ledger_id = p_ledger_id
829 AND gps_mpa.adjustment_period_flag = 'N'
830 AND gps_mpa.end_date >= p_start_date -- included boundary conditions for bug12939974
831 AND gps_mpa.start_date <= p_end_date -- included boundary conditions for bug12939974
832 AND gps_orig.application_id = 101
833 AND gps_orig.ledger_id = p_ledger_id
834 AND gps_orig.adjustment_period_flag = 'N'
835 AND p_trx_gl_date between gps_orig.start_date and gps_orig.end_date
836 ORDER BY gps_mpa.start_date ;
837
838 --l_closing_statuses xla_ae_journal_entry_pkg.t_array_V30L;
839 l_days_in_periods xla_ae_journal_entry_pkg.t_array_num;
840 l_days_in_first_periods xla_ae_journal_entry_pkg.t_array_num;
841 l_days_in_last_periods xla_ae_journal_entry_pkg.t_array_num;
842
843 l_total_months NUMBER;
844 l_whole_months NUMBER;
845 l_other_accted_amt NUMBER;
846 l_other_entered_amt NUMBER;
847 l_total_days NUMBER;
848 l_total_accted_amt NUMBER;
849 l_total_entered_amt NUMBER;
850 l_log_module VARCHAR2(240);
851
852 l_other_bflow_applied_to_amt NUMBER; -- 5132302
853 l_total_bflow_applied_to_amt NUMBER; -- 5132302
854
855 -- l_rounding_fac NUMBER; -- 4262811b
856
857 BEGIN
858
859 IF g_log_enabled THEN
860 l_log_module := C_DEFAULT_MODULE||'.GetRecognitionEntriesInfo';
861 END IF;
862 --
863 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
864 trace
865 (p_msg => 'BEGIN of GetRecognitionEntriesInfo'
866 ,p_level => C_LEVEL_PROCEDURE
867 ,p_module => l_log_module);
868
869 END IF;
870
871
872 IF (p_num_entries_option = 'ONE') THEN -- see XLA_MPA_NUM_OF_ENTRIES
873
874 --x_gl_dates(1) := p_end_date; -- depends on Gl period option
875 open c_one_period;
876 fetch c_one_period into x_period_names(1), x_gl_dates(1);
877 close c_one_period;
878
879 IF x_period_names.count=0 THEN -- 4897417
880 x_num_entries := 0;
881
882 ELSE
883 x_num_entries := 1;
884
885 x_entered_amts (1) := p_entered_amt;
886 IF p_calculate_acctd_flag = 'N' THEN -- 4262811b
887 IF p_same_currency THEN -- 4262811b
888 x_accted_amts (1) := p_entered_amt;
889 ELSE
890 x_accted_amts (1) := p_accted_amt;
891 END IF;
892 ELSE
893 x_accted_amts (1) := NULL;
894 END IF;
895
896 x_bflow_applied_to_amts (1) := p_bflow_applied_to_amt; -- 5132302
897
898 END IF;
899
900
901 ELSE -- ONE_PER_PERIOD
902 OPEN c_periods;
903 FETCH c_periods BULK COLLECT INTO x_period_names
904 , x_gl_dates
905 --, l_closing_statuses
906 , l_days_in_periods
907 , l_days_in_first_periods
908 , l_days_in_last_periods;
909 CLOSE c_periods;
910
911 x_num_entries := x_period_names.count;
912
913 IF x_num_entries > 0 THEN -- 4897417
914 ----------------------------------------------------------------------------------
915 -- If the GL date of the first period is before the start date, use the start date
916 ----------------------------------------------------------------------------------
917 IF (x_gl_dates(1) < p_start_date) THEN
918 x_gl_dates(1) := p_start_date;
919 END IF;
920
921 /* awan Let cursor determine the last period date
922 --------------------------------------------------------------------------------
923 -- If the GL date of the last period is after the end date, use the end date
924 --------------------------------------------------------------------------------
925 IF (x_gl_dates(x_num_entries) > p_end_date) THEN
926 x_gl_dates(x_num_entries) := p_end_date;
927 END IF;
928 */
929
930 IF x_num_entries = 1 THEN
931
932 x_entered_amts (1) := p_entered_amt;
933 IF p_calculate_acctd_flag = 'N' THEN -- 4262811b
934 IF p_same_currency THEN -- 4262811b
935 x_accted_amts (1) := p_entered_amt;
936 ELSE
937 x_accted_amts (1) := p_accted_amt;
938 END IF;
939 ELSE
940 x_accted_amts (1) := NULL;
941 END IF;
942
943 x_bflow_applied_to_amts (1) := p_bflow_applied_to_amt; -- 5132302
944
945 ELSE
946
947 -----------------------------------------
948 -- Calculate whole months
949 -----------------------------------------
953 l_whole_months := 0;
950 IF x_num_entries > 2 THEN
951 l_whole_months := x_num_entries - 2;
952 ELSE
954 END IF;
955
956 --===================================================================================================
957 -- Calculate the accounted amount and entered amount of the first, last,
958 -- and 'the other' period for the different proration types.
959 -- See XLA_MPA_PRORATION lookup type
960 --===================================================================================================
961
962 ---------------------------------------------------------------------------
963 IF (p_proration_code = 'DAYS_IN_PERIOD') THEN -- actual days in each month
964 ---------------------------------------------------------------------------
965 l_total_months := (l_days_in_first_periods(1) / l_days_in_periods(1)) +
966 (l_days_in_last_periods(x_num_entries) / l_days_in_periods(x_num_entries)) + l_whole_months;
967
968 l_other_entered_amt := p_entered_amt / l_total_months;
969 x_entered_amts (1) := l_other_entered_amt * l_days_in_first_periods(1) / l_days_in_periods(1);
970
971 IF p_calculate_acctd_flag = 'N' THEN -- 4262811b
972 IF p_same_currency THEN -- 4262811b
973 l_other_accted_amt := l_other_entered_amt;
974 x_accted_amts (1) := x_entered_amts (1);
975 ELSE
976 l_other_accted_amt := p_accted_amt / l_total_months;
977 x_accted_amts (1) := l_other_accted_amt * l_days_in_first_periods(1) / l_days_in_periods(1);
978 END IF;
979 ELSE
980 l_other_accted_amt := NULL;
981 x_accted_amts (1) := NULL;
982 END IF;
983
984 -- 5132302
985 l_other_bflow_applied_to_amt := p_bflow_applied_to_amt / l_total_months;
986 x_bflow_applied_to_amts (1) := l_other_bflow_applied_to_amt * l_days_in_first_periods(1) / l_days_in_periods(1);
987
988 ---------------------------------------------------------------------------------
989 ELSIF (p_proration_code = '360_DAYS') THEN -- 30 days per month, 360 days a year
990 ---------------------------------------------------------------------------------
991 l_total_months := (l_days_in_first_periods(1) / 360 * 12) +
992 (l_days_in_last_periods(x_num_entries) / 360 * 12) + l_whole_months;
993
994 l_other_entered_amt := p_entered_amt / l_total_months;
995 x_entered_amts (1) := l_other_entered_amt * l_days_in_first_periods(1) / 360 * 12;
996
997 IF p_calculate_acctd_flag = 'N' THEN -- 4262811b
998 IF p_same_currency THEN -- 4262811b
999 l_other_accted_amt := l_other_entered_amt;
1000 x_accted_amts (1) := x_entered_amts (1);
1001 ELSE
1002 l_other_accted_amt := p_accted_amt / l_total_months;
1003 x_accted_amts (1) := l_other_accted_amt * l_days_in_first_periods(1) / 360 * 12;
1004 END IF;
1005 ELSE
1006 l_other_accted_amt := NULL;
1007 x_accted_amts (1) := NULL;
1008 END IF;
1009
1010 -- 5132302
1011 l_other_bflow_applied_to_amt := p_bflow_applied_to_amt / l_total_months;
1012 x_bflow_applied_to_amts (1) := l_other_bflow_applied_to_amt * l_days_in_first_periods(1) / 360 * 12;
1013
1014 -------------------------------------------------------------------------------------
1015 ELSIF (p_proration_code = 'TOTAL_DAYS_IN_PERIOD') THEN -- total days in all periods
1016 -------------------------------------------------------------------------------------
1017 -- NOTE: the result is one penny different after rounding for the following example:
1018 -- 1) US$23000 * 17 / 366
1019 -- 2) 17 / 366 * US$23000
1020 -------------------------------------------------------------------------------------
1021
1022 l_total_days := l_days_in_first_periods(1) + l_days_in_last_periods(x_num_entries);
1023
1024 FOR i IN 2..x_num_entries-1 LOOP
1025 l_total_days := l_total_days + l_days_in_periods(i);
1026 END LOOP;
1027
1028 x_entered_amts (1) := p_entered_amt * l_days_in_first_periods(1) / l_total_days;
1029 IF p_calculate_acctd_flag = 'N' THEN -- 4262811b
1030 IF p_same_currency THEN -- 4262811b
1031 x_accted_amts (1) := x_entered_amts (1);
1032 ELSE
1033 x_accted_amts (1) := p_accted_amt * l_days_in_first_periods(1) / l_total_days;
1034 END IF;
1035 ELSE
1036 x_accted_amts (1) := NULL;
1037 END IF;
1038
1039 -- 5132302
1040 x_bflow_applied_to_amts (1) := p_bflow_applied_to_amt * l_days_in_first_periods(1) / l_total_days;
1041 l_total_bflow_applied_to_amt := x_bflow_applied_to_amts (1);
1042
1043 l_total_accted_amt := x_accted_amts (1);
1044 l_total_entered_amt := x_entered_amts (1);
1045
1046 FOR i IN 2..x_num_entries-1 LOOP
1047 x_entered_amts (i) := p_entered_amt * l_days_in_periods(i) / l_total_days;
1048 l_total_entered_amt := l_total_entered_amt + x_entered_amts (i);
1049
1050 IF p_calculate_acctd_flag = 'N' THEN -- 4262811b
1051 IF p_same_currency THEN -- 4262811b
1055 x_accted_amts (i) := p_accted_amt * l_days_in_periods(i) / l_total_days;
1052 x_accted_amts (i) := x_entered_amts (i);
1053 l_total_accted_amt := l_total_entered_amt;
1054 ELSE
1056 l_total_accted_amt := l_total_accted_amt + x_accted_amts (i);
1057 END IF;
1058 ELSE
1059 x_accted_amts (i) := NULL;
1060 l_total_accted_amt := NULL;
1061 END IF;
1062
1063 -- 5132302
1064 x_bflow_applied_to_amts (i) := p_bflow_applied_to_amt * l_days_in_periods(i) / l_total_days;
1065 l_total_bflow_applied_to_amt := l_total_bflow_applied_to_amt + x_bflow_applied_to_amts (i);
1066
1067 END LOOP;
1068
1069 -------------------------------------------
1070 -- To adjust rounding for last MPA period
1071 -------------------------------------------
1072 x_entered_amts (x_num_entries) := p_entered_amt - l_total_entered_amt;
1073 IF p_calculate_acctd_flag = 'N' THEN -- 4262811b
1074 IF p_same_currency THEN -- 4262811b
1075 x_accted_amts (x_num_entries) := x_entered_amts (x_num_entries);
1076 ELSE
1077 x_accted_amts (x_num_entries) := p_accted_amt - l_total_accted_amt;
1078 END IF;
1079 ELSE
1080 x_accted_amts (x_num_entries) := NULL;
1081 END IF;
1082
1083 x_bflow_applied_to_amts (x_num_entries) := p_bflow_applied_to_amt - l_total_bflow_applied_to_amt; -- 5132302
1084
1085 ----------------------------------------------------------------------
1086 ELSE -- FIRST_PERIOD (zero amount on the last period)
1087 ----------------------------------------------------------------------
1088 -- commented the deletion of the last period for bug11654120, as amount
1089 -- needs to be split across all the periods equally.
1090 ------------------------------------------------------------------------------------
1091 -- Removing final period
1092 ------------------------------------------------------------------------------------
1093 /* IF x_num_entries > 1 THEN
1094 x_period_names.DELETE(x_num_entries);
1095 x_num_entries := x_period_names.count;
1096 END IF; */ -- commented for bug11654120
1097
1098 x_entered_amts (1) := p_entered_amt / x_num_entries;
1099 l_other_entered_amt := x_entered_amts (1);
1100
1101 IF p_calculate_acctd_flag = 'N' THEN -- 4262811b
1102 IF p_same_currency THEN -- 4262811b
1103 x_accted_amts (1) := x_entered_amts (1);
1104 l_other_accted_amt := l_other_entered_amt;
1105 ELSE
1106 x_accted_amts (1) := p_accted_amt / x_num_entries;
1107 l_other_accted_amt := x_accted_amts (1);
1108 END IF;
1109 ELSE
1110 x_accted_amts (1) := NULL;
1111 l_total_accted_amt := NULL;
1112 END IF;
1113
1114 -- 5132302
1115 x_bflow_applied_to_amts (1) := p_bflow_applied_to_amt / x_num_entries;
1116 l_other_bflow_applied_to_amt := x_bflow_applied_to_amts (1);
1117
1118
1119 END IF; -- p_proration_code = 'DAYS_IN_PERIOD'
1120
1121 --==============================================================================
1122 -- Populate 'the other' periods and adjust rounding for last MPA period
1123 --==============================================================================
1124 IF (p_proration_code <> 'TOTAL_DAYS_IN_PERIOD') THEN
1125 --
1126 -- Copy the accounted amount and the entered amount of 'the other' period
1127 -- from the 'second' to the 'second-to-last' entries.
1128 --
1129 l_total_accted_amt := x_accted_amts (1);
1130 l_total_entered_amt := x_entered_amts (1);
1131
1132 l_total_bflow_applied_to_amt := x_bflow_applied_to_amts (1); -- 5132302
1133
1134 -- To handle final period
1135 FOR i IN 2.. x_num_entries-1 LOOP
1136 x_accted_amts (i) := l_other_accted_amt;
1137 x_entered_amts (i) := l_other_entered_amt;
1138 l_total_accted_amt := l_total_accted_amt + x_accted_amts (i);
1139 l_total_entered_amt := l_total_entered_amt + x_entered_amts (i);
1140 --
1141 x_bflow_applied_to_amts (i) := l_other_bflow_applied_to_amt; -- 5132302
1142 l_total_bflow_applied_to_amt := l_total_bflow_applied_to_amt + x_bflow_applied_to_amts (i); -- 5132302
1143 END LOOP;
1144
1145 ------------------------------------------------------------------------
1146 -- awan To adjust rounding for last MPA period
1147 ------------------------------------------------------------------------
1148 IF x_num_entries <> 1 THEN -- in case FIRST_PERIOD results in only one period
1149 x_accted_amts (x_num_entries) := p_accted_amt - l_total_accted_amt;
1150 x_entered_amts (x_num_entries) := p_entered_amt - l_total_entered_amt;
1151 x_bflow_applied_to_amts (x_num_entries) := p_bflow_applied_to_amt - l_total_bflow_applied_to_amt;
1152 END IF;
1153
1154 END IF;
1155
1156 END IF; -- x_num_entries = 1
1157
1158 END IF; -- x_num_entries > 0
1159
1160 END IF; -- p_num_entries_option = 'ONE'
1161
1165 trace
1162 EXCEPTION
1163 WHEN xla_exceptions_pkg.application_exception THEN
1164 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
1166 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
1167 ,p_level => C_LEVEL_EXCEPTION
1168 ,p_module => l_log_module);
1169 END IF;
1170 RAISE;
1171 WHEN OTHERS THEN
1172 xla_exceptions_pkg.raise_message
1173 (p_location => 'xla_ae_header_pkg.GetRecognitionEntriesInfo');
1174 END GetRecognitionEntriesInfo;
1175
1176
1177 /*======================================================================+
1178 | |
1179 | Public Procedure - 4262811 |
1180 | |
1181 | |
1182 +======================================================================*/
1183 PROCEDURE CopyHeaderInfo(
1184 p_parent_hdr_idx IN NUMBER
1185 , p_hdr_idx IN NUMBER
1186 )
1187 IS
1188 l_log_module VARCHAR2(240);
1189
1190 BEGIN
1191
1192 IF g_log_enabled THEN
1193 l_log_module := C_DEFAULT_MODULE||'.CopyHeaderInfo';
1194 END IF;
1195 --
1196 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1197 trace
1198 (p_msg => 'BEGIN of CopyHeaderInfo'
1199 ,p_level => C_LEVEL_PROCEDURE
1200 ,p_module => l_log_module);
1201
1202 END IF;
1203
1204 -------------------------------------------
1205 -- Create a new header
1206 -------------------------------------------
1207 InitHeader(p_hdr_idx);
1208
1209 -------------------------------------------------------------------------------
1210 -- Copy all information in g_rec_header_new from p_parent_hdr_idx to p_hdr_idx:
1211 -- with the following exceptions:
1212 --
1213 -- Not copied:
1217 --------------------------------------------------------------------------------------------------
1214 -- array_accrual_reversal_flag
1215 -- array_acc_rev_gl_date_option
1216 --------------------------------------------------------------------------------------------------
1218 g_rec_header_new.array_event_type_code(p_hdr_idx) := g_rec_header_new.array_event_type_code(p_parent_hdr_idx);
1219 g_rec_header_new.array_event_id(p_hdr_idx) := g_rec_header_new.array_event_id(p_parent_hdr_idx);
1220
1221 g_rec_header_new.array_header_num(p_hdr_idx) := g_rec_header_new.array_header_num(p_parent_hdr_idx);
1222 g_rec_header_new.array_entity_id(p_hdr_idx) := g_rec_header_new.array_entity_id(p_parent_hdr_idx);
1223
1224 g_rec_header_new.array_parent_header_id(p_hdr_idx) := g_rec_header_new.array_parent_header_id(p_parent_hdr_idx);
1225 g_rec_header_new.array_parent_line_num(p_hdr_idx) := g_rec_header_new.array_parent_line_num(p_parent_hdr_idx);
1226
1227 --
1228 g_rec_header_new.array_target_ledger_id(p_hdr_idx) := g_rec_header_new.array_target_ledger_id(p_parent_hdr_idx);
1229 g_rec_header_new.array_actual_header_id(p_hdr_idx) := g_rec_header_new.array_actual_header_id(p_parent_hdr_idx);
1230 g_rec_header_new.array_budget_header_id(p_hdr_idx) := g_rec_header_new.array_budget_header_id(p_parent_hdr_idx);
1231 g_rec_header_new.array_encumb_header_id(p_hdr_idx) := g_rec_header_new.array_encumb_header_id(p_parent_hdr_idx);
1232 g_rec_header_new.array_je_category_name(p_hdr_idx) := g_rec_header_new.array_je_category_name(p_parent_hdr_idx);
1233 g_rec_header_new.array_period_name(p_hdr_idx) := g_rec_header_new.array_period_name(p_parent_hdr_idx);
1234 g_rec_header_new.array_description(p_hdr_idx) := g_rec_header_new.array_description(p_parent_hdr_idx);
1235 g_rec_header_new.array_doc_sequence_id(p_hdr_idx) := g_rec_header_new.array_doc_sequence_id(p_parent_hdr_idx);
1236 g_rec_header_new.array_doc_sequence_value(p_hdr_idx) := g_rec_header_new.array_doc_sequence_value(p_parent_hdr_idx);
1237 g_rec_header_new.array_doc_category_code(p_hdr_idx) := g_rec_header_new.array_doc_category_code(p_parent_hdr_idx);
1238 g_rec_header_new.array_budget_version_id(p_hdr_idx) := g_rec_header_new.array_budget_version_id(p_parent_hdr_idx);
1239 -- g_rec_header_new.array_encumbrance_type_id(p_hdr_idx) := g_rec_header_new.array_encumbrance_type_id(p_parent_hdr_idx);
1240 g_rec_header_new.array_party_change_option(p_hdr_idx) := g_rec_header_new.array_party_change_option(p_parent_hdr_idx);
1241 g_rec_header_new.array_party_change_type(p_hdr_idx) := g_rec_header_new.array_party_change_type(p_parent_hdr_idx);
1242 g_rec_header_new.array_new_party_id(p_hdr_idx) := g_rec_header_new.array_new_party_id(p_parent_hdr_idx);
1243 g_rec_header_new.array_new_party_site_id(p_hdr_idx) := g_rec_header_new.array_new_party_site_id(p_parent_hdr_idx);
1244 g_rec_header_new.array_previous_party_id(p_hdr_idx) := g_rec_header_new.array_previous_party_id(p_parent_hdr_idx);
1248 g_rec_header_new.array_gl_date(p_hdr_idx) := g_rec_header_new.array_gl_date(p_parent_hdr_idx);
1245 g_rec_header_new.array_previous_party_site_id(p_hdr_idx) := g_rec_header_new.array_previous_party_site_id(p_parent_hdr_idx);
1246 g_rec_header_new.array_gl_transfer_flag(p_hdr_idx) := g_rec_header_new.array_gl_transfer_flag(p_parent_hdr_idx);
1247 g_rec_header_new.array_trx_acct_reversal_option(p_hdr_idx) := g_rec_header_new.array_trx_acct_reversal_option(p_parent_hdr_idx);
1249 --
1250 IF NVL(g_rec_header_new.array_accrual_reversal_flag(p_parent_hdr_idx),'N') = 'Y' OR
1251 g_rec_header_new.array_parent_header_id(p_parent_hdr_idx) IS NOT NULL THEN
1252 g_rec_header_new.array_anc_id_1(p_hdr_idx) := g_rec_header_new.array_anc_id_1(p_parent_hdr_idx);
1253 g_rec_header_new.array_anc_id_2(p_hdr_idx) := g_rec_header_new.array_anc_id_2(p_parent_hdr_idx);
1254 g_rec_header_new.array_anc_id_3(p_hdr_idx) := g_rec_header_new.array_anc_id_3(p_parent_hdr_idx);
1255 g_rec_header_new.array_anc_id_4(p_hdr_idx) := g_rec_header_new.array_anc_id_4(p_parent_hdr_idx);
1256 g_rec_header_new.array_anc_id_5(p_hdr_idx) := g_rec_header_new.array_anc_id_5(p_parent_hdr_idx);
1257 g_rec_header_new.array_anc_id_6(p_hdr_idx) := g_rec_header_new.array_anc_id_6(p_parent_hdr_idx);
1258 g_rec_header_new.array_anc_id_7(p_hdr_idx) := g_rec_header_new.array_anc_id_7(p_parent_hdr_idx);
1259 g_rec_header_new.array_anc_id_8(p_hdr_idx) := g_rec_header_new.array_anc_id_8(p_parent_hdr_idx);
1260 g_rec_header_new.array_anc_id_9(p_hdr_idx) := g_rec_header_new.array_anc_id_9(p_parent_hdr_idx);
1261 g_rec_header_new.array_anc_id_10(p_hdr_idx) := g_rec_header_new.array_anc_id_10(p_parent_hdr_idx);
1262 g_rec_header_new.array_anc_id_11(p_hdr_idx) := g_rec_header_new.array_anc_id_11(p_parent_hdr_idx);
1263 g_rec_header_new.array_anc_id_12(p_hdr_idx) := g_rec_header_new.array_anc_id_12(p_parent_hdr_idx);
1264 g_rec_header_new.array_anc_id_13(p_hdr_idx) := g_rec_header_new.array_anc_id_13(p_parent_hdr_idx);
1265 g_rec_header_new.array_anc_id_14(p_hdr_idx) := g_rec_header_new.array_anc_id_14(p_parent_hdr_idx);
1266 g_rec_header_new.array_anc_id_15(p_hdr_idx) := g_rec_header_new.array_anc_id_15(p_parent_hdr_idx);
1267 g_rec_header_new.array_anc_id_16(p_hdr_idx) := g_rec_header_new.array_anc_id_16(p_parent_hdr_idx);
1268 g_rec_header_new.array_anc_id_17(p_hdr_idx) := g_rec_header_new.array_anc_id_17(p_parent_hdr_idx);
1269 g_rec_header_new.array_anc_id_18(p_hdr_idx) := g_rec_header_new.array_anc_id_18(p_parent_hdr_idx);
1270 g_rec_header_new.array_anc_id_19(p_hdr_idx) := g_rec_header_new.array_anc_id_19(p_parent_hdr_idx);
1271 g_rec_header_new.array_anc_id_20(p_hdr_idx) := g_rec_header_new.array_anc_id_20(p_parent_hdr_idx);
1272 g_rec_header_new.array_anc_id_21(p_hdr_idx) := g_rec_header_new.array_anc_id_21(p_parent_hdr_idx);
1273 g_rec_header_new.array_anc_id_22(p_hdr_idx) := g_rec_header_new.array_anc_id_22(p_parent_hdr_idx);
1274 g_rec_header_new.array_anc_id_23(p_hdr_idx) := g_rec_header_new.array_anc_id_23(p_parent_hdr_idx);
1275 g_rec_header_new.array_anc_id_24(p_hdr_idx) := g_rec_header_new.array_anc_id_24(p_parent_hdr_idx);
1276 g_rec_header_new.array_anc_id_25(p_hdr_idx) := g_rec_header_new.array_anc_id_25(p_parent_hdr_idx);
1277 g_rec_header_new.array_anc_id_26(p_hdr_idx) := g_rec_header_new.array_anc_id_26(p_parent_hdr_idx);
1278 g_rec_header_new.array_anc_id_27(p_hdr_idx) := g_rec_header_new.array_anc_id_27(p_parent_hdr_idx);
1279 g_rec_header_new.array_anc_id_28(p_hdr_idx) := g_rec_header_new.array_anc_id_28(p_parent_hdr_idx);
1280 g_rec_header_new.array_anc_id_29(p_hdr_idx) := g_rec_header_new.array_anc_id_29(p_parent_hdr_idx);
1281 g_rec_header_new.array_anc_id_30(p_hdr_idx) := g_rec_header_new.array_anc_id_30(p_parent_hdr_idx);
1282 g_rec_header_new.array_anc_id_31(p_hdr_idx) := g_rec_header_new.array_anc_id_31(p_parent_hdr_idx);
1283 g_rec_header_new.array_anc_id_32(p_hdr_idx) := g_rec_header_new.array_anc_id_32(p_parent_hdr_idx);
1284 g_rec_header_new.array_anc_id_33(p_hdr_idx) := g_rec_header_new.array_anc_id_33(p_parent_hdr_idx);
1285 g_rec_header_new.array_anc_id_34(p_hdr_idx) := g_rec_header_new.array_anc_id_34(p_parent_hdr_idx);
1286 g_rec_header_new.array_anc_id_35(p_hdr_idx) := g_rec_header_new.array_anc_id_35(p_parent_hdr_idx);
1287 g_rec_header_new.array_anc_id_36(p_hdr_idx) := g_rec_header_new.array_anc_id_36(p_parent_hdr_idx);
1288 g_rec_header_new.array_anc_id_37(p_hdr_idx) := g_rec_header_new.array_anc_id_37(p_parent_hdr_idx);
1289 g_rec_header_new.array_anc_id_38(p_hdr_idx) := g_rec_header_new.array_anc_id_38(p_parent_hdr_idx);
1290 g_rec_header_new.array_anc_id_39(p_hdr_idx) := g_rec_header_new.array_anc_id_39(p_parent_hdr_idx);
1291 g_rec_header_new.array_anc_id_40(p_hdr_idx) := g_rec_header_new.array_anc_id_40(p_parent_hdr_idx);
1292 g_rec_header_new.array_anc_id_41(p_hdr_idx) := g_rec_header_new.array_anc_id_41(p_parent_hdr_idx);
1293 g_rec_header_new.array_anc_id_42(p_hdr_idx) := g_rec_header_new.array_anc_id_42(p_parent_hdr_idx);
1294 g_rec_header_new.array_anc_id_43(p_hdr_idx) := g_rec_header_new.array_anc_id_43(p_parent_hdr_idx);
1295 g_rec_header_new.array_anc_id_44(p_hdr_idx) := g_rec_header_new.array_anc_id_44(p_parent_hdr_idx);
1296 g_rec_header_new.array_anc_id_45(p_hdr_idx) := g_rec_header_new.array_anc_id_45(p_parent_hdr_idx);
1297 g_rec_header_new.array_anc_id_46(p_hdr_idx) := g_rec_header_new.array_anc_id_46(p_parent_hdr_idx);
1298 g_rec_header_new.array_anc_id_47(p_hdr_idx) := g_rec_header_new.array_anc_id_47(p_parent_hdr_idx);
1299 g_rec_header_new.array_anc_id_48(p_hdr_idx) := g_rec_header_new.array_anc_id_48(p_parent_hdr_idx);
1300 g_rec_header_new.array_anc_id_49(p_hdr_idx) := g_rec_header_new.array_anc_id_49(p_parent_hdr_idx);
1301 g_rec_header_new.array_anc_id_50(p_hdr_idx) := g_rec_header_new.array_anc_id_50(p_parent_hdr_idx);
1302 g_rec_header_new.array_anc_id_51(p_hdr_idx) := g_rec_header_new.array_anc_id_51(p_parent_hdr_idx);
1303 g_rec_header_new.array_anc_id_52(p_hdr_idx) := g_rec_header_new.array_anc_id_52(p_parent_hdr_idx);
1304 g_rec_header_new.array_anc_id_53(p_hdr_idx) := g_rec_header_new.array_anc_id_53(p_parent_hdr_idx);
1305 g_rec_header_new.array_anc_id_54(p_hdr_idx) := g_rec_header_new.array_anc_id_54(p_parent_hdr_idx);
1309 g_rec_header_new.array_anc_id_58(p_hdr_idx) := g_rec_header_new.array_anc_id_58(p_parent_hdr_idx);
1306 g_rec_header_new.array_anc_id_55(p_hdr_idx) := g_rec_header_new.array_anc_id_55(p_parent_hdr_idx);
1307 g_rec_header_new.array_anc_id_56(p_hdr_idx) := g_rec_header_new.array_anc_id_56(p_parent_hdr_idx);
1308 g_rec_header_new.array_anc_id_57(p_hdr_idx) := g_rec_header_new.array_anc_id_57(p_parent_hdr_idx);
1310 g_rec_header_new.array_anc_id_59(p_hdr_idx) := g_rec_header_new.array_anc_id_59(p_parent_hdr_idx);
1311 g_rec_header_new.array_anc_id_60(p_hdr_idx) := g_rec_header_new.array_anc_id_60(p_parent_hdr_idx);
1312 g_rec_header_new.array_anc_id_61(p_hdr_idx) := g_rec_header_new.array_anc_id_61(p_parent_hdr_idx);
1313 g_rec_header_new.array_anc_id_62(p_hdr_idx) := g_rec_header_new.array_anc_id_62(p_parent_hdr_idx);
1314 g_rec_header_new.array_anc_id_63(p_hdr_idx) := g_rec_header_new.array_anc_id_63(p_parent_hdr_idx);
1315 g_rec_header_new.array_anc_id_64(p_hdr_idx) := g_rec_header_new.array_anc_id_64(p_parent_hdr_idx);
1316 g_rec_header_new.array_anc_id_65(p_hdr_idx) := g_rec_header_new.array_anc_id_65(p_parent_hdr_idx);
1317 g_rec_header_new.array_anc_id_66(p_hdr_idx) := g_rec_header_new.array_anc_id_66(p_parent_hdr_idx);
1318 g_rec_header_new.array_anc_id_67(p_hdr_idx) := g_rec_header_new.array_anc_id_67(p_parent_hdr_idx);
1319 g_rec_header_new.array_anc_id_68(p_hdr_idx) := g_rec_header_new.array_anc_id_68(p_parent_hdr_idx);
1320 g_rec_header_new.array_anc_id_69(p_hdr_idx) := g_rec_header_new.array_anc_id_69(p_parent_hdr_idx);
1321 g_rec_header_new.array_anc_id_70(p_hdr_idx) := g_rec_header_new.array_anc_id_70(p_parent_hdr_idx);
1322 g_rec_header_new.array_anc_id_71(p_hdr_idx) := g_rec_header_new.array_anc_id_71(p_parent_hdr_idx);
1323 g_rec_header_new.array_anc_id_72(p_hdr_idx) := g_rec_header_new.array_anc_id_72(p_parent_hdr_idx);
1324 g_rec_header_new.array_anc_id_73(p_hdr_idx) := g_rec_header_new.array_anc_id_73(p_parent_hdr_idx);
1325 g_rec_header_new.array_anc_id_74(p_hdr_idx) := g_rec_header_new.array_anc_id_74(p_parent_hdr_idx);
1326 g_rec_header_new.array_anc_id_75(p_hdr_idx) := g_rec_header_new.array_anc_id_75(p_parent_hdr_idx);
1327 g_rec_header_new.array_anc_id_76(p_hdr_idx) := g_rec_header_new.array_anc_id_76(p_parent_hdr_idx);
1328 g_rec_header_new.array_anc_id_77(p_hdr_idx) := g_rec_header_new.array_anc_id_77(p_parent_hdr_idx);
1329 g_rec_header_new.array_anc_id_78(p_hdr_idx) := g_rec_header_new.array_anc_id_78(p_parent_hdr_idx);
1330 g_rec_header_new.array_anc_id_79(p_hdr_idx) := g_rec_header_new.array_anc_id_79(p_parent_hdr_idx);
1331 g_rec_header_new.array_anc_id_80(p_hdr_idx) := g_rec_header_new.array_anc_id_80(p_parent_hdr_idx);
1332 g_rec_header_new.array_anc_id_81(p_hdr_idx) := g_rec_header_new.array_anc_id_81(p_parent_hdr_idx);
1333 g_rec_header_new.array_anc_id_82(p_hdr_idx) := g_rec_header_new.array_anc_id_82(p_parent_hdr_idx);
1334 g_rec_header_new.array_anc_id_83(p_hdr_idx) := g_rec_header_new.array_anc_id_83(p_parent_hdr_idx);
1335 g_rec_header_new.array_anc_id_84(p_hdr_idx) := g_rec_header_new.array_anc_id_84(p_parent_hdr_idx);
1336 g_rec_header_new.array_anc_id_85(p_hdr_idx) := g_rec_header_new.array_anc_id_85(p_parent_hdr_idx);
1337 g_rec_header_new.array_anc_id_86(p_hdr_idx) := g_rec_header_new.array_anc_id_86(p_parent_hdr_idx);
1338 g_rec_header_new.array_anc_id_87(p_hdr_idx) := g_rec_header_new.array_anc_id_87(p_parent_hdr_idx);
1339 g_rec_header_new.array_anc_id_88(p_hdr_idx) := g_rec_header_new.array_anc_id_88(p_parent_hdr_idx);
1340 g_rec_header_new.array_anc_id_89(p_hdr_idx) := g_rec_header_new.array_anc_id_89(p_parent_hdr_idx);
1341 g_rec_header_new.array_anc_id_90(p_hdr_idx) := g_rec_header_new.array_anc_id_90(p_parent_hdr_idx);
1342 g_rec_header_new.array_anc_id_91(p_hdr_idx) := g_rec_header_new.array_anc_id_91(p_parent_hdr_idx);
1343 g_rec_header_new.array_anc_id_92(p_hdr_idx) := g_rec_header_new.array_anc_id_92(p_parent_hdr_idx);
1344 g_rec_header_new.array_anc_id_93(p_hdr_idx) := g_rec_header_new.array_anc_id_93(p_parent_hdr_idx);
1345 g_rec_header_new.array_anc_id_94(p_hdr_idx) := g_rec_header_new.array_anc_id_94(p_parent_hdr_idx);
1346 g_rec_header_new.array_anc_id_95(p_hdr_idx) := g_rec_header_new.array_anc_id_95(p_parent_hdr_idx);
1347 g_rec_header_new.array_anc_id_96(p_hdr_idx) := g_rec_header_new.array_anc_id_96(p_parent_hdr_idx);
1348 g_rec_header_new.array_anc_id_97(p_hdr_idx) := g_rec_header_new.array_anc_id_97(p_parent_hdr_idx);
1349 g_rec_header_new.array_anc_id_98(p_hdr_idx) := g_rec_header_new.array_anc_id_98(p_parent_hdr_idx);
1350 g_rec_header_new.array_anc_id_99(p_hdr_idx) := g_rec_header_new.array_anc_id_99(p_parent_hdr_idx);
1351 g_rec_header_new.array_anc_id_100(p_hdr_idx) := g_rec_header_new.array_anc_id_100(p_parent_hdr_idx);
1352 END IF;
1353
1354 --
1355 g_rec_header_new.array_event_number(p_hdr_idx) := g_rec_header_new.array_event_number(p_parent_hdr_idx);
1356 g_rec_header_new.array_actual_status(p_hdr_idx) := g_rec_header_new.array_actual_status(p_parent_hdr_idx);
1357 g_rec_header_new.array_budget_status(p_hdr_idx) := g_rec_header_new.array_budget_status(p_parent_hdr_idx);
1358 g_rec_header_new.array_encumbrance_status(p_hdr_idx) := g_rec_header_new.array_encumbrance_status(p_parent_hdr_idx);
1359 g_rec_header_new.array_event_status(p_hdr_idx) := g_rec_header_new.array_event_status(p_parent_hdr_idx);
1360
1361 --------------------------------------------------------------------------------------------------
1362 --------------------------------------------------------------------------------------------------
1363
1364 -------------------------------------------
1365 -- Validate header accounting attributes
1366 -------------------------------------------
1367 IF NVL(g_rec_header_new.array_party_change_option(p_hdr_idx),'N') NOT IN ('Y','N') THEN
1368 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
1369 xla_accounting_err_pkg.build_message
1370 (p_appli_s_name => 'XLA'
1371 ,p_msg_name => 'XLA_AP_THIRD_PARTY_OPTION'
1372 ,p_token_1 => 'PRODUCT_NAME'
1373 ,p_value_1 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
1377 END IF;
1374 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1375 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1376 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id);
1378
1379 IF g_rec_header_new.array_gl_transfer_flag(p_hdr_idx) NOT IN ('Y', 'N') THEN
1380 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
1381 xla_accounting_err_pkg.build_message
1382 (p_appli_s_name => 'XLA'
1383 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
1384 ,p_token_1 => 'ACCT_ATTR_NAME'
1385 ,p_value_1 => XLA_AE_SOURCES_PKG.GetAccountingSourceName('GL_TRANSFER_FLAG')
1386 ,p_token_2 => 'PRODUCT_NAME'
1387 ,p_value_2 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
1388 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1389 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1390 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id);
1391 END IF;
1392
1393 IF g_rec_header_new.array_trx_acct_reversal_option(p_hdr_idx) NOT IN ('Y', 'N') THEN
1394 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
1395 xla_accounting_err_pkg.build_message
1396 (p_appli_s_name => 'XLA'
1397 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
1398 ,p_token_1 => 'ACCT_ATTR_NAME'
1399 ,p_value_1 => XLA_AE_SOURCES_PKG.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
1400 ,p_token_2 => 'PRODUCT_NAME'
1401 ,p_value_2 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
1402 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1403 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1404 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id);
1405 END IF;
1406
1407 IF g_rec_header_new.array_gl_date(p_hdr_idx) is NULL THEN
1408 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
1409 xla_accounting_err_pkg.build_message
1410 (p_appli_s_name => 'XLA'
1411 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
1412 ,p_token_1 => 'ACCT_ATTR_NAME'
1413 ,p_value_1 => XLA_AE_SOURCES_PKG.GetAccountingSourceName('GL_DATE')
1414 ,p_token_2 => 'PRODUCT_NAME'
1415 ,p_value_2 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
1416 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1417 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1418 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id);
1419 END IF;
1420
1421 --
1422 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1423 trace
1424 (p_msg => 'END of CopyHeaderInfo'
1425 ,p_level => C_LEVEL_PROCEDURE
1426 ,p_module => l_log_module);
1427 END IF;
1428
1429 EXCEPTION
1430
1431 WHEN xla_exceptions_pkg.application_exception THEN
1432 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
1433 trace
1434 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
1435 ,p_level => C_LEVEL_EXCEPTION
1436 ,p_module => l_log_module);
1437 END IF;
1438 RAISE;
1439 WHEN OTHERS THEN
1440 xla_exceptions_pkg.raise_message
1441 (p_location => 'xla_ae_header_pkg.CopyHeaderInfo');
1442 END CopyHeaderInfo;
1443
1444
1445 /*======================================================================+
1446 | |
1447 | Public Procedure - 4262811 |
1448 | |
1449 | |
1450 +======================================================================*/
1451 FUNCTION CreateRecognitionEntries(
1452 p_event_id IN INTEGER
1453 , p_num_entries IN INTEGER
1454 , p_last_hdr_idx IN INTEGER
1455 , p_recog_line_num_1 IN INTEGER
1456 , p_recog_line_num_2 IN INTEGER
1457 , p_gl_dates IN xla_ae_journal_entry_pkg.t_array_date
1458 , p_accted_amts IN xla_ae_journal_entry_pkg.t_array_num
1459 , p_entered_amts IN xla_ae_journal_entry_pkg.t_array_num
1460 , p_bflow_applied_to_amts IN xla_ae_journal_entry_pkg.t_array_num -- 5132302
1461 ) RETURN NUMBER
1462 IS
1463
1464 l_hdr_idx NUMBER;
1465 l_log_module VARCHAR2(240);
1466
1467 i NUMBER;
1468
1469 BEGIN
1470
1471 IF g_log_enabled THEN
1472 l_log_module := C_DEFAULT_MODULE||'.CreateRecognitionEntries';
1473 END IF;
1474 --
1475 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1476 trace
1477 (p_msg => 'BEGIN of CreateRecognitionEntries'
1478 ,p_level => C_LEVEL_PROCEDURE
1479 ,p_module => l_log_module);
1480 END IF;
1481
1482 l_hdr_idx := p_last_hdr_idx; -- initialise
1483
1484 -------------------------------------------------------------------------------------
1485 -- Copy the following information from the first recognition line to the current line
1486 -------------------------------------------------------------------------------------
1487 FOR i IN 2..p_num_entries LOOP
1488
1492 --**************************************************************************************************************
1489 --**************************************************************************************************************
1490 -- awan Problem with multiple Accrual JLT, they are all created under the first Accrual JLT
1491 -- Need to differentiate the different JLT journal lines
1493 g_mpa_line_num := NVL(g_mpa_line_num,0) + 1;
1494 --**************************************************************************************************************
1495
1496 -----------------------------------
1497 -- create header
1498 -----------------------------------
1499 l_hdr_idx := l_hdr_idx + 1;
1500
1501 CopyHeaderInfo( p_parent_hdr_idx => p_last_hdr_idx
1502 , p_hdr_idx => l_hdr_idx);
1503
1504 --**************************************************************************************************************
1505 -- 4262811a Copy the MPA Gl date Option to be used in PostAccountingEngine
1506 g_rec_header_new.array_acc_rev_gl_date_option (l_hdr_idx) :=
1507 g_rec_header_new.array_acc_rev_gl_date_option (p_last_hdr_idx);
1508 --**************************************************************************************************************
1509
1510 --**************************************************************************************************************
1511 g_rec_header_new.array_header_num(l_hdr_idx) := g_mpa_line_num ; -- multiple JLT
1512 --g_rec_header_new.array_header_num(l_hdr_idx) := i; -- multiple JLT original
1513 --**************************************************************************************************************
1514 g_rec_header_new.array_gl_date(l_hdr_idx) := trunc(p_gl_dates(i));
1515
1516
1517 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => l_hdr_idx
1518 ,p_balance_type_code => 'A');
1519
1520 -----------------------------------------------------------
1521 -- create recognition line - for Recognition JLT1
1522 -----------------------------------------------------------
1523 -- changed the call of CopyLineInfo to pass the data source for copy process: bug-7109881
1524 -- XLA_AE_LINES_PKG.CopyLineInfo(p_recog_line_num_1);
1525 XLA_AE_LINES_PKG.CopyLineInfo(p_recog_line_num_1 , XLA_AE_LINES_PKG.g_mpa_recog_lines );
1526 -- bug9954676
1527 XLA_AE_LINES_PKG.CopyMpaTrxAcctCopyInfo( XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id(XLA_AE_LINES_PKG.g_LineNumber)
1528 , p_recog_line_num_1
1529 , XLA_AE_LINES_PKG.g_LineNumber );
1530 --**************************************************************************************************************
1531 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id
1532 ,p_header_num => g_mpa_line_num ); -- multiple JLT
1533 --,p_header_num => i); -- original multiple JLT
1534 --**************************************************************************************************************
1535 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount (XLA_AE_LINES_PKG.g_LineNumber) := p_accted_amts(i);
1536 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount (XLA_AE_LINES_PKG.g_LineNumber) := p_entered_amts(i);
1537 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt (XLA_AE_LINES_PKG.g_LineNumber) := p_bflow_applied_to_amts(i); -- 5132302
1538
1539 -- 4955764
1540 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
1541 g_rec_header_new.array_gl_date(l_hdr_idx);
1542
1543 XLA_AE_LINES_PKG.ValidateCurrentLine;
1544 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
1545
1546
1547 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => l_hdr_idx
1548 ,p_balance_type_code => 'A');
1549
1550 -----------------------------------------------------------
1551 -- create recognition line - for Recognition JLT2
1552 -----------------------------------------------------------
1553 -- changed the call of CopyLineInfo to pass the data source for copy process: bug-7109881
1554 -- XLA_AE_LINES_PKG.CopyLineInfo(p_recog_line_num_2);
1555 XLA_AE_LINES_PKG.CopyLineInfo(p_recog_line_num_2 , XLA_AE_LINES_PKG.g_mpa_recog_lines );
1556 -- bug9954676
1557 XLA_AE_LINES_PKG.CopyMpaTrxAcctCopyInfo( XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id(XLA_AE_LINES_PKG.g_LineNumber)
1558 , p_recog_line_num_2
1559 , XLA_AE_LINES_PKG.g_LineNumber );
1560 --**************************************************************************************************************
1561 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id
1562 ,p_header_num => g_mpa_line_num ); -- multiple JLT
1563 --,p_header_num => i); -- original multiple JLT
1564 --**************************************************************************************************************
1565 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount (XLA_AE_LINES_PKG.g_LineNumber) := p_accted_amts(i);
1566 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount (XLA_AE_LINES_PKG.g_LineNumber) := p_entered_amts(i);
1567 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt (XLA_AE_LINES_PKG.g_LineNumber) := p_bflow_applied_to_amts(i); -- 5132302
1568
1569 -- 4955764
1570 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
1571 g_rec_header_new.array_gl_date(l_hdr_idx);
1572 XLA_AE_LINES_PKG.ValidateCurrentLine;
1573 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
1574
1578 END LOOP;
1575 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => l_hdr_idx
1576 ,p_balance_type_code => 'A');
1577
1579
1580 --
1581 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1582 trace
1583 (p_msg => 'END of CreateRecognitionEntries'
1584 ,p_level => C_LEVEL_PROCEDURE
1585 ,p_module => l_log_module);
1586 END IF;
1587
1588 RETURN l_hdr_idx; -- return to g_last_hdr_idx
1589
1590 EXCEPTION
1591 WHEN xla_exceptions_pkg.application_exception THEN
1592 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
1593 trace
1594 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
1595 ,p_level => C_LEVEL_EXCEPTION
1596 ,p_module => l_log_module);
1597 END IF;
1598 RETURN NULL;
1599 WHEN OTHERS THEN
1600 xla_exceptions_pkg.raise_message
1601 (p_location => 'xla_ae_header_pkg.CreateRecognitionEntries');
1602
1603 END CreateRecognitionEntries;
1604
1605 /*======================================================================+
1606 | |
1607 | Public Procedure |
1608 | |
1609 | |
1610 +======================================================================*/
1611 PROCEDURE SetJeCategoryName
1612 IS
1613 l_log_module VARCHAR2(240);
1614 BEGIN
1615 --
1616 IF g_log_enabled THEN
1617 l_log_module := C_DEFAULT_MODULE||'.SetJeCategoryName';
1618 END IF;
1619 --
1620 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1621
1622 trace
1623 (p_msg => 'BEGIN of SetJeCategoryName'
1624 ,p_level => C_LEVEL_PROCEDURE
1625 ,p_module => l_log_module);
1626 END IF;
1627 --
1628 g_rec_header_new.array_je_category_name(g_header_idx) := xla_accounting_cache_pkg.get_je_category(
1629 p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.base_ledger_id
1630 ,p_event_class_code => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_class);
1631 --
1632
1633 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1634
1635 trace
1636 (p_msg => 'return value. = '||g_rec_header_new.array_je_category_name(g_header_idx)
1637 ,p_level => C_LEVEL_PROCEDURE
1638 ,p_module => l_log_module);
1639
1640 trace
1641 (p_msg => 'END of SetJeCategoryName'
1642 ,p_level => C_LEVEL_PROCEDURE
1643 ,p_module => l_log_module);
1644 END IF;
1645 --
1646 EXCEPTION
1647 WHEN xla_exceptions_pkg.application_exception THEN
1648 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
1649 RAISE;
1650 WHEN OTHERS THEN
1651 xla_exceptions_pkg.raise_message
1652 (p_location => 'XLA_AE_HEADER_PKG.InitHeader');
1653 --
1654 END SetJeCategoryName;
1655 --
1656 --
1657 /*======================================================================+
1658 | |
1659 | Public Function |
1660 | |
1661 | SetAnalyticalCriteria |
1662 | |
1663 +======================================================================*/
1664 --
1665 FUNCTION SetAnalyticalCriteria(
1666 p_analytical_criterion_name IN VARCHAR2
1667 , p_analytical_criterion_owner IN VARCHAR2
1668 , p_analytical_criterion_code IN VARCHAR2
1669 , p_amb_context_code IN VARCHAR2
1670 , p_balancing_flag IN VARCHAR2
1671 --
1672 , p_analytical_detail_char_1 IN VARCHAR2
1673 , p_analytical_detail_num_1 IN NUMBER
1674 , p_analytical_detail_date_1 IN DATE
1675 , p_analytical_detail_char_2 IN VARCHAR2
1676 , p_analytical_detail_num_2 IN NUMBER
1677 , p_analytical_detail_date_2 IN DATE
1678 , p_analytical_detail_char_3 IN VARCHAR2
1679 , p_analytical_detail_num_3 IN NUMBER
1680 , p_analytical_detail_date_3 IN DATE
1681 , p_analytical_detail_char_4 IN VARCHAR2
1682 , p_analytical_detail_num_4 IN NUMBER
1683 , p_analytical_detail_date_4 IN DATE
1684 , p_analytical_detail_char_5 IN VARCHAR2
1685 , p_analytical_detail_num_5 IN NUMBER
1686 , p_analytical_detail_date_5 IN DATE
1687 --
1688 )
1689 RETURN VARCHAR2
1690 IS
1691 l_analytical_criteria VARCHAR2(240);
1692 l_log_module VARCHAR2(240);
1693 BEGIN
1694 --
1695 IF g_log_enabled THEN
1696 l_log_module := C_DEFAULT_MODULE||'.SetAnalyticalCriteria';
1697 END IF;
1698 --
1699 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1700
1701 trace
1702 (p_msg => 'BEGIN of SetAnalyticalCriteria'
1703 ,p_level => C_LEVEL_PROCEDURE
1704 ,p_module => l_log_module);
1705
1706 END IF;
1707 --
1708 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1709
1710 trace
1711 (p_msg => 'p_analytical_criterion_name = '||p_analytical_criterion_name
1712 ,p_level => C_LEVEL_STATEMENT
1713 ,p_module => l_log_module);
1714
1715 trace
1716 (p_msg => 'p_analytical_criterion_owner = '||p_analytical_criterion_owner
1717 ,p_level => C_LEVEL_STATEMENT
1718 ,p_module => l_log_module);
1719
1720 trace
1724
1721 (p_msg => 'p_analytical_criterion_code = '||p_analytical_criterion_code
1722 ,p_level => C_LEVEL_STATEMENT
1723 ,p_module => l_log_module);
1725 trace
1726 (p_msg => 'p_amb_context_code = '||p_amb_context_code
1727 ,p_level => C_LEVEL_STATEMENT
1728 ,p_module => l_log_module);
1729
1730 trace
1731 (p_msg => 'p_balancing_flag = '||p_balancing_flag
1732 ,p_level => C_LEVEL_STATEMENT
1733 ,p_module => l_log_module);
1734 trace
1735 (p_msg => 'p_analytical_detail_char_1 = '||p_analytical_detail_char_1
1736 ,p_level => C_LEVEL_STATEMENT
1737 ,p_module => l_log_module);
1738
1739 trace
1740 (p_msg => 'p_analytical_detail_char_2 = '||p_analytical_detail_char_2
1741 ,p_level => C_LEVEL_STATEMENT
1742 ,p_module => l_log_module);
1743
1744 trace
1745 (p_msg => 'p_analytical_detail_char_3 = '||p_analytical_detail_char_3
1746 ,p_level => C_LEVEL_STATEMENT
1747 ,p_module => l_log_module);
1748
1749 trace
1750 (p_msg => 'p_analytical_detail_char_4 = '||p_analytical_detail_char_4
1751 ,p_level => C_LEVEL_STATEMENT
1752 ,p_module => l_log_module);
1753
1754 trace
1755 (p_msg => 'p_analytical_detail_char_5 = '||p_analytical_detail_char_5
1756 ,p_level => C_LEVEL_STATEMENT
1757 ,p_module => l_log_module);
1758
1759 trace
1760 (p_msg => 'p_analytical_detail_num_1 = '||p_analytical_detail_num_1
1761 ,p_level => C_LEVEL_STATEMENT
1762 ,p_module => l_log_module);
1763
1764 trace
1765 (p_msg => 'p_analytical_detail_num_2 = '||p_analytical_detail_num_2
1766 ,p_level => C_LEVEL_STATEMENT
1767 ,p_module => l_log_module);
1768
1769 trace
1770 (p_msg => 'p_analytical_detail_num_3 = '||p_analytical_detail_num_3
1771 ,p_level => C_LEVEL_STATEMENT
1772 ,p_module => l_log_module);
1773 trace
1774 (p_msg => 'p_analytical_detail_num_4 = '||p_analytical_detail_num_4
1775 ,p_level => C_LEVEL_STATEMENT
1776 ,p_module => l_log_module);
1777
1778 trace
1779 (p_msg => 'p_analytical_detail_num_5 = '||p_analytical_detail_num_5
1780 ,p_level => C_LEVEL_STATEMENT
1781 ,p_module => l_log_module);
1782
1783 trace
1784 (p_msg => 'p_analytical_detail_date_1 = '||p_analytical_detail_date_1
1785 ,p_level => C_LEVEL_STATEMENT
1786 ,p_module => l_log_module);
1787
1788 trace
1789 (p_msg => 'p_analytical_detail_date_2 = '||p_analytical_detail_date_2
1790 ,p_level => C_LEVEL_STATEMENT
1791 ,p_module => l_log_module);
1792
1793 trace
1794 (p_msg => 'p_analytical_detail_date_3 = '||p_analytical_detail_date_3
1795 ,p_level => C_LEVEL_STATEMENT
1796 ,p_module => l_log_module);
1797
1798 trace
1799 (p_msg => 'p_analytical_detail_date_4 = '||p_analytical_detail_date_4
1800 ,p_level => C_LEVEL_STATEMENT
1801 ,p_module => l_log_module);
1802
1803 trace
1804 (p_msg => 'p_analytical_detail_date_5 = '||p_analytical_detail_date_5
1805 ,p_level => C_LEVEL_STATEMENT
1806 ,p_module => l_log_module);
1807
1808 END IF;
1809 --
1810 l_analytical_criteria := XLA_ANALYTICAL_CRITERIA_PKG.concat_detail_values
1811 ( p_anacri_code => p_analytical_criterion_code
1812 ,p_anacri_type_code => p_analytical_criterion_owner
1813 ,p_amb_context_code => p_amb_context_code
1814 ,p_detail_char_1 => p_analytical_detail_char_1
1815 ,p_detail_date_1 => p_analytical_detail_date_1
1816 ,p_detail_number_1 => p_analytical_detail_num_1
1817 ,p_detail_char_2 => p_analytical_detail_char_2
1818 ,p_detail_date_2 => p_analytical_detail_date_2
1819 ,p_detail_number_2 => p_analytical_detail_num_2
1820 ,p_detail_char_3 => p_analytical_detail_char_3
1821 ,p_detail_date_3 => p_analytical_detail_date_3
1822 ,p_detail_number_3 => p_analytical_detail_num_3
1823 ,p_detail_char_4 => p_analytical_detail_char_4
1824 ,p_detail_date_4 => p_analytical_detail_date_4
1825 ,p_detail_number_4 => p_analytical_detail_num_4
1826 ,p_detail_char_5 => p_analytical_detail_char_5
1827 ,p_detail_date_5 => p_analytical_detail_date_5
1828 ,p_detail_number_5 => p_analytical_detail_num_5
1829 );
1830 --
1831 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1832 trace
1833 (p_msg => 'return value. = '||TO_CHAR(l_analytical_criteria)
1834 ,p_level => C_LEVEL_PROCEDURE
1835 ,p_module => l_log_module);
1836
1837 trace
1838 (p_msg => 'END of SetAnalyticalCriteria'
1839 ,p_level => C_LEVEL_PROCEDURE
1840 ,p_module => l_log_module);
1841
1842 END IF;
1843 RETURN l_analytical_criteria;
1844 EXCEPTION
1845 WHEN xla_exceptions_pkg.application_exception THEN
1846 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
1847 RETURN NULL;
1848 WHEN OTHERS THEN
1849 xla_exceptions_pkg.raise_message
1850 (p_location => 'XLA_AE_HEADER_PKG.SetAnalyticalCriteria');
1851 --
1852 END SetAnalyticalCriteria;
1853
1857 | Public Procedure |
1854
1855 /*======================================================================+
1856 | |
1858 | |
1859 | SetHdrDescription |
1860 | |
1861 +======================================================================*/
1862 PROCEDURE SetHdrDescription(
1863 p_description IN VARCHAR2
1864 )
1865 IS
1866 l_log_module VARCHAR2(240);
1867 BEGIN
1868 --
1869 IF g_log_enabled THEN
1870 l_log_module := C_DEFAULT_MODULE||'.SetHdrDescription';
1871 END IF;
1872 --
1873 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1874
1875 trace
1876 (p_msg => 'BEGIN of SetHdrDescription'
1877 ,p_level => C_LEVEL_PROCEDURE
1878 ,p_module => l_log_module);
1879 END IF;
1880 --
1881 g_rec_header_new.array_description(g_header_idx) := SUBSTR(p_description,1,1996);
1882 --
1883 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1884
1885 trace
1886 (p_msg => 'END of SetHdrDescription'
1887 ,p_level => C_LEVEL_PROCEDURE
1888 ,p_module => l_log_module);
1889 END IF;
1890 EXCEPTION
1891 --
1892 WHEN xla_exceptions_pkg.application_exception THEN
1893 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
1894 RAISE;
1895 WHEN OTHERS THEN
1896 xla_exceptions_pkg.raise_message
1897 (p_location => 'XLA_AE_HEADER_PKG.SetHdrDescription');
1898 END SetHdrDescription;
1899 --
1900 /*======================================================================+
1901 | |
1902 | PRIVATE Procedure |
1903 | InsertHeaders |
1904 | |
1905 +======================================================================*/
1906 FUNCTION InsertHeaders
1907 RETURN BOOLEAN
1908 IS
1909 --
1910 l_period_name VARCHAR2(25);
1914 l_Idx BINARY_INTEGER := 0;
1911 l_array_header_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
1912 l_array_balance_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V1L;
1913 l_result BOOLEAN;
1915 l_log_module VARCHAR2(240);
1916 -- added 7526530
1917 errors NUMBER;
1918 ERR_IND NUMBER;
1919 ERR_CODE VARCHAR2(100);
1920 dml_errors EXCEPTION;
1921 PRAGMA exception_init(dml_errors, -24381);
1922 -- end 7526530
1923 BEGIN
1924 --
1925 IF g_log_enabled THEN
1926 l_log_module := C_DEFAULT_MODULE||'.InsertHeaders';
1927 END IF;
1928 --
1929 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1930
1931 trace
1932 (p_msg => 'BEGIN of InsertHeaders'
1933 ,p_level => C_LEVEL_PROCEDURE
1934 ,p_module => l_log_module);
1935
1936 END IF;
1937 --
1938 l_result := TRUE;
1939
1940 --
1941 -- create headers
1942 --
1943 -- how is the following used??
1944 /*
1945 IF g_rec_header_new.array_actual_header_id(g_header_idx) > 0 THEN
1946 --
1947 l_Idx := l_Idx + 1;
1948 l_array_header_id(l_Idx) := g_rec_header_new.array_actual_header_id(g_header_idx);
1949 l_array_balance_type(l_Idx) := C_ACTUAL;
1950 --
1951 l_period_name := get_period_name(
1952 p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
1953 , p_accounting_date => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_date
1954 , p_ae_header_id => g_rec_header_new.array_actual_header_id(g_header_idx)
1955 );
1956 END IF;
1957 --
1958 IF g_rec_header_new.array_budget_header_id(g_header_idx) > 0 THEN
1959 --
1960 l_Idx := l_Idx + 1;
1961 l_array_header_id(l_Idx) := g_rec_header_new.array_budget_header_id(g_header_idx);
1962 l_array_balance_type(l_Idx) := C_BUDGET;
1963 --
1964 l_period_name := get_period_name(
1965 p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
1966 , p_accounting_date => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_date
1967 , p_ae_header_id => g_rec_header_new.array_budget_header_id(g_header_idx)
1968 );
1969 END IF;
1970 --
1974 l_array_header_id(l_Idx) := g_rec_header_new.array_encumb_header_id(g_header_idx);
1971 IF g_rec_header_new.array_encumb_header_id(g_header_idx) > 0 THEN
1972 --
1973 l_Idx := l_Idx + 1;
1975 l_array_balance_type(l_Idx) := C_ENCUMBRANCE;
1976 --
1977 l_period_name := get_period_name(
1978 p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
1979 , p_accounting_date => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_date
1980 , p_ae_header_id => g_rec_header_new.array_encumb_header_id(g_header_idx)
1981 );
1982 END IF;
1983 */
1984 --
1985 -- insert the headers created
1986 --
1987 --
1988 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1989 trace
1990 (p_msg => 'g_rec_header_new.array_je_category_name.count = '||
1991 g_rec_header_new.array_je_category_name.count
1992 ,p_level => C_LEVEL_STATEMENT
1993 ,p_module => l_log_module);
1994 END IF;
1995 --
1996 --
1997 --IF l_array_header_id.COUNT > 0 AND l_period_name IS NOT NULL THEN
1998
1999 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2000
2001 trace
2002 (p_msg => 'SQL - Insert into xla_ae_headers_gt'
2003 ,p_level => C_LEVEL_STATEMENT
2004 ,p_module => l_log_module);
2005 END IF;
2006
2007
2008 FORALL Idx IN 1..g_rec_header_new.array_je_category_name.count SAVE EXCEPTIONS --added Save exception 7526530
2009 INSERT /*+ opt_param('_gby_hash_aggregation_enabled','false') */ INTO xla_ae_headers_gt -- added hint for bug 14246749
2010 ( ae_header_id
2011 , accounting_entry_status_code
2012 , accounting_entry_type_code
2013 , ledger_id
2014 , entity_id
2015 , event_id
2016 , event_type_code
2017 , accounting_date
2018 , product_rule_type_code
2019 , product_rule_code
2020 , product_rule_version
2021 , je_category_name
2022 --, period_name
2023 , doc_sequence_id
2024 , doc_sequence_value
2025 , description
2026 , budget_version_id
2027 --, encumbrance_type_id
2028 , balance_type_code
2029 , amb_context_code
2030 , doc_category_code
2031 , gl_transfer_status_code
2032 , event_status_code
2033 , anc_id_1
2034 , anc_id_2
2035 , anc_id_3
2036 , anc_id_4
2037 , anc_id_5
2038 , anc_id_6
2039 , anc_id_7
2040 , anc_id_8
2041 , anc_id_9
2042 , anc_id_10
2043 , anc_id_11
2044 , anc_id_12
2045 , anc_id_13
2046 , anc_id_14
2047 , anc_id_15
2048 , anc_id_16
2049 , anc_id_17
2050 , anc_id_18
2051 , anc_id_19
2052 , anc_id_20
2053 , anc_id_21
2054 , anc_id_22
2055 , anc_id_23
2056 , anc_id_24
2057 , anc_id_25
2058 , anc_id_26
2059 , anc_id_27
2060 , anc_id_28
2061 , anc_id_29
2062 , anc_id_30
2063 , anc_id_31
2064 , anc_id_32
2065 , anc_id_33
2066 , anc_id_34
2067 , anc_id_35
2068 , anc_id_36
2069 , anc_id_37
2070 , anc_id_38
2071 , anc_id_39
2072 , anc_id_40
2073 , anc_id_41
2074 , anc_id_42
2075 , anc_id_43
2076 , anc_id_44
2077 , anc_id_45
2078 , anc_id_46
2079 , anc_id_47
2080 , anc_id_48
2081 , anc_id_49
2082 , anc_id_50
2083 , anc_id_51
2084 , anc_id_52
2085 , anc_id_53
2086 , anc_id_54
2087 , anc_id_55
2088 , anc_id_56
2089 , anc_id_57
2090 , anc_id_58
2091 , anc_id_59
2092 , anc_id_60
2093 , anc_id_61
2094 , anc_id_62
2095 , anc_id_63
2096 , anc_id_64
2097 , anc_id_65
2098 , anc_id_66
2099 , anc_id_67
2100 , anc_id_68
2101 , anc_id_69
2102 , anc_id_70
2103 , anc_id_71
2104 , anc_id_72
2105 , anc_id_73
2106 , anc_id_74
2107 , anc_id_75
2108 , anc_id_76
2109 , anc_id_77
2110 , anc_id_78
2111 , anc_id_79
2112 , anc_id_80
2113 , anc_id_81
2114 , anc_id_82
2115 , anc_id_83
2116 , anc_id_84
2117 , anc_id_85
2118 , anc_id_86
2119 , anc_id_87
2120 , anc_id_88
2121 , anc_id_89
2122 , anc_id_90
2123 , anc_id_91
2124 , anc_id_92
2125 , anc_id_93
2126 , anc_id_94
2127 , anc_id_95
2128 , anc_id_96
2129 , anc_id_97
2130 , anc_id_98
2131 , anc_id_99
2132 , anc_id_100
2133 --
2134 , event_number
2135 , header_num -- 4262811
2136 , accrual_reversal_flag -- 4262811
2137 , acc_rev_gl_date_option -- 4262811
2138 , parent_header_id -- 4262811
2139 , parent_ae_line_num) -- 4262811
2140 (SELECT /*+ INDEX (AEL, XLA_AE_LINES_GT_N3) */ -- 4752774 -- changed in 8319065 performance changes
2141 g_rec_header_new.array_event_id(Idx)
2142 , CASE ael.balance_type_code
2143 when C_BUDGET THEN
2147 when C_ACTUAL THEN
2144 g_rec_header_new.array_budget_status(Idx)
2145 when C_ENCUMBRANCE THEN
2146 g_rec_header_new.array_encumbrance_status(Idx)
2148 g_rec_header_new.array_actual_status(Idx)
2149 ELSE
2150 XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED
2151 END CASE
2152 , C_STANDARD
2153 , g_rec_header_new.array_target_ledger_id(Idx)
2154 , g_rec_header_new.array_entity_id(Idx)
2155 , g_rec_header_new.array_event_id(Idx)
2156 , g_rec_header_new.array_event_type_code(Idx)
2157 , g_rec_header_new.array_gl_date(Idx)
2158 , XLA_AE_JOURNAL_ENTRY_PKG.g_cache_pad.product_rule_type_code
2159 , XLA_AE_JOURNAL_ENTRY_PKG.g_cache_pad.product_rule_code
2160 , XLA_AE_JOURNAL_ENTRY_PKG.g_cache_pad.product_rule_version
2161 , g_rec_header_new.array_je_category_name(Idx)
2162 --, 'XYZ' --l_period_name
2163 , g_rec_header_new.array_doc_sequence_id(Idx)
2164 , g_rec_header_new.array_doc_sequence_value(Idx)
2165 , g_rec_header_new.array_description(Idx)
2166 , DECODE(ael.balance_type_code -- 4924492
2167 ,C_BUDGET, g_rec_header_new.array_budget_version_id(Idx)
2168 ,'X', g_rec_header_new.array_budget_version_id(Idx)
2169 ,NULL)
2170 --, DECODE(ael.balance_type_code, C_ENCUMBRANCE, g_rec_header_new.array_encumbrance_type_id(Idx)
2171 -- , NULL) -- 4458381 Public Sector Enh
2172 , ael.balance_type_code
2173 , XLA_AE_JOURNAL_ENTRY_PKG.g_cache_pad.amb_context_code
2174 , g_rec_header_new.array_doc_category_code(Idx)
2175 , DECODE(g_rec_header_new.array_gl_transfer_flag(Idx), 'N', 'NT', 'Y', 'N', 'N')
2176 , g_rec_header_new.array_event_status(Idx)
2177 , g_rec_header_new.array_anc_id_1(Idx)
2178 , g_rec_header_new.array_anc_id_2(Idx)
2179 , g_rec_header_new.array_anc_id_3(Idx)
2180 , g_rec_header_new.array_anc_id_4(Idx)
2181 , g_rec_header_new.array_anc_id_5(Idx)
2182 , g_rec_header_new.array_anc_id_6(Idx)
2183 , g_rec_header_new.array_anc_id_7(Idx)
2184 , g_rec_header_new.array_anc_id_8(Idx)
2185 , g_rec_header_new.array_anc_id_9(Idx)
2186 , g_rec_header_new.array_anc_id_10(Idx)
2187 , g_rec_header_new.array_anc_id_11(Idx)
2188 , g_rec_header_new.array_anc_id_12(Idx)
2189 , g_rec_header_new.array_anc_id_13(Idx)
2190 , g_rec_header_new.array_anc_id_14(Idx)
2191 , g_rec_header_new.array_anc_id_15(Idx)
2192 , g_rec_header_new.array_anc_id_16(Idx)
2193 , g_rec_header_new.array_anc_id_17(Idx)
2194 , g_rec_header_new.array_anc_id_18(Idx)
2195 , g_rec_header_new.array_anc_id_19(Idx)
2196 , g_rec_header_new.array_anc_id_20(Idx)
2197 , g_rec_header_new.array_anc_id_21(Idx)
2198 , g_rec_header_new.array_anc_id_22(Idx)
2199 , g_rec_header_new.array_anc_id_23(Idx)
2200 , g_rec_header_new.array_anc_id_24(Idx)
2201 , g_rec_header_new.array_anc_id_25(Idx)
2202 , g_rec_header_new.array_anc_id_26(Idx)
2203 , g_rec_header_new.array_anc_id_27(Idx)
2204 , g_rec_header_new.array_anc_id_28(Idx)
2205 , g_rec_header_new.array_anc_id_29(Idx)
2206 , g_rec_header_new.array_anc_id_30(Idx)
2207 , g_rec_header_new.array_anc_id_31(Idx)
2208 , g_rec_header_new.array_anc_id_32(Idx)
2209 , g_rec_header_new.array_anc_id_33(Idx)
2210 , g_rec_header_new.array_anc_id_34(Idx)
2211 , g_rec_header_new.array_anc_id_35(Idx)
2212 , g_rec_header_new.array_anc_id_36(Idx)
2213 , g_rec_header_new.array_anc_id_37(Idx)
2214 , g_rec_header_new.array_anc_id_38(Idx)
2215 , g_rec_header_new.array_anc_id_39(Idx)
2216 , g_rec_header_new.array_anc_id_40(Idx)
2217 , g_rec_header_new.array_anc_id_41(Idx)
2218 , g_rec_header_new.array_anc_id_42(Idx)
2219 , g_rec_header_new.array_anc_id_43(Idx)
2220 , g_rec_header_new.array_anc_id_44(Idx)
2221 , g_rec_header_new.array_anc_id_45(Idx)
2222 , g_rec_header_new.array_anc_id_46(Idx)
2223 , g_rec_header_new.array_anc_id_47(Idx)
2224 , g_rec_header_new.array_anc_id_48(Idx)
2225 , g_rec_header_new.array_anc_id_49(Idx)
2226 , g_rec_header_new.array_anc_id_50(Idx)
2227 , g_rec_header_new.array_anc_id_51(Idx)
2228 , g_rec_header_new.array_anc_id_52(Idx)
2229 , g_rec_header_new.array_anc_id_53(Idx)
2230 , g_rec_header_new.array_anc_id_54(Idx)
2231 , g_rec_header_new.array_anc_id_55(Idx)
2232 , g_rec_header_new.array_anc_id_56(Idx)
2233 , g_rec_header_new.array_anc_id_57(Idx)
2234 , g_rec_header_new.array_anc_id_58(Idx)
2235 , g_rec_header_new.array_anc_id_59(Idx)
2236 , g_rec_header_new.array_anc_id_60(Idx)
2237 , g_rec_header_new.array_anc_id_61(Idx)
2238 , g_rec_header_new.array_anc_id_62(Idx)
2239 , g_rec_header_new.array_anc_id_63(Idx)
2240 , g_rec_header_new.array_anc_id_64(Idx)
2241 , g_rec_header_new.array_anc_id_65(Idx)
2242 , g_rec_header_new.array_anc_id_66(Idx)
2243 , g_rec_header_new.array_anc_id_67(Idx)
2244 , g_rec_header_new.array_anc_id_68(Idx)
2245 , g_rec_header_new.array_anc_id_69(Idx)
2249 , g_rec_header_new.array_anc_id_73(Idx)
2246 , g_rec_header_new.array_anc_id_70(Idx)
2247 , g_rec_header_new.array_anc_id_71(Idx)
2248 , g_rec_header_new.array_anc_id_72(Idx)
2250 , g_rec_header_new.array_anc_id_74(Idx)
2251 , g_rec_header_new.array_anc_id_75(Idx)
2252 , g_rec_header_new.array_anc_id_76(Idx)
2253 , g_rec_header_new.array_anc_id_77(Idx)
2254 , g_rec_header_new.array_anc_id_78(Idx)
2255 , g_rec_header_new.array_anc_id_79(Idx)
2256 , g_rec_header_new.array_anc_id_80(Idx)
2257 , g_rec_header_new.array_anc_id_81(Idx)
2258 , g_rec_header_new.array_anc_id_82(Idx)
2259 , g_rec_header_new.array_anc_id_83(Idx)
2260 , g_rec_header_new.array_anc_id_84(Idx)
2261 , g_rec_header_new.array_anc_id_85(Idx)
2262 , g_rec_header_new.array_anc_id_86(Idx)
2263 , g_rec_header_new.array_anc_id_87(Idx)
2264 , g_rec_header_new.array_anc_id_88(Idx)
2265 , g_rec_header_new.array_anc_id_89(Idx)
2266 , g_rec_header_new.array_anc_id_90(Idx)
2267 , g_rec_header_new.array_anc_id_91(Idx)
2268 , g_rec_header_new.array_anc_id_92(Idx)
2269 , g_rec_header_new.array_anc_id_93(Idx)
2270 , g_rec_header_new.array_anc_id_94(Idx)
2271 , g_rec_header_new.array_anc_id_95(Idx)
2272 , g_rec_header_new.array_anc_id_96(Idx)
2273 , g_rec_header_new.array_anc_id_97(Idx)
2274 , g_rec_header_new.array_anc_id_98(Idx)
2275 , g_rec_header_new.array_anc_id_99(Idx)
2276 , g_rec_header_new.array_anc_id_100(Idx)
2277 --
2278 , g_rec_header_new.array_event_number(Idx)
2279 , g_rec_header_new.array_header_num(Idx) -- 4262811
2280 , g_rec_header_new.array_accrual_reversal_flag(Idx) -- 4262811
2281 , g_rec_header_new.array_acc_rev_gl_date_option(Idx) -- 4262811
2282 , g_rec_header_new.array_parent_header_id(Idx) -- 4262811
2283 , g_rec_header_new.array_parent_line_num(Idx) -- 4262811
2284 FROM xla_ae_lines_gt ael
2285 WHERE ael.ae_header_id = g_rec_header_new.array_event_id(Idx)
2286 AND ael.ledger_id = g_rec_header_new.array_target_ledger_id(Idx)
2287 AND (nvl(ael.gain_or_loss_flag, 'N') <> 'Y' or nvl(ael.calculate_g_l_amts_flag, 'N') <> 'Y')
2288 AND ael.header_num =
2289 NVL2(g_rec_header_new.array_parent_header_id(Idx),g_rec_header_new.array_header_num(Idx)
2290 , NVL(g_rec_header_new.array_header_num(Idx),0) )
2291 -- added for bug#9162117
2292
2293 -- AND nvl(ael.entered_amount,0) > 0
2294 -- AND ael.temp_line_num <> 0
2295 group by ael.balance_type_code
2296 );
2297 --
2298
2299
2300 IF (C_LEVEL_EVENT >= g_log_level) THEN
2301
2302 trace
2303 (p_msg => '# temporary headers inserted into GT xla_ae_headers_gt = '||SQL%ROWCOUNT
2304 ,p_level => C_LEVEL_EVENT
2305 ,p_module => l_log_module);
2306 END IF;
2307 --
2308 l_result:= ( (SQL%ROWCOUNT > 0) OR
2309 (XLA_AE_JOURNAL_ENTRY_PKG.g_global_status = XLA_AE_JOURNAL_ENTRY_PKG.C_VALID)) ;
2310
2311 --
2312 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2313
2314 trace
2315 (p_msg => 'END of InsertHeaders'
2316 ,p_level => C_LEVEL_PROCEDURE
2317 ,p_module => l_log_module);
2318
2319 END IF;
2320 --
2321 RETURN l_result;
2322 --
2323 EXCEPTION
2324
2325 WHEN xla_exceptions_pkg.application_exception THEN
2326 RAISE;
2327 -- added 7526530
2328
2329 ----Added to handle Exceptions and send to Out file ------------
2330 WHEN dml_errors THEN
2331 errors := SQL%BULK_EXCEPTIONS.COUNT;
2332 FOR i IN 1..errors LOOP
2333 ERR_IND:= SQL%BULK_EXCEPTIONS(i).ERROR_INDEX;
2334 ERR_CODE:= SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE);
2335 fnd_file.put_line(fnd_file.log, 'ERROR : '|| UPPER(ERR_CODE));
2336 fnd_file.put_line(fnd_file.log, 'event_id: '||g_rec_header_new.array_event_id(ERR_IND));
2337 fnd_file.put_line(fnd_file.log, 'header_num: '||g_rec_header_new.array_header_num(ERR_IND));
2338 fnd_file.put_line(fnd_file.log, 'ledger_id: '||g_rec_header_new.array_target_ledger_id(ERR_IND));
2339
2340 END LOOP;
2341 xla_exceptions_pkg.raise_message
2342 (p_location => 'XLA_AE_HEADER_PKG.InsertHeaders');
2343 WHEN OTHERS THEN
2344 xla_exceptions_pkg.raise_message
2345 (p_location => 'XLA_AE_HEADER_PKG.InsertHeaders');
2346 END InsertHeaders;
2347 --
2348 /*======================================================================+
2349 | |
2350 | Public Procedure |
2351 | |
2352 | |
2353 +======================================================================*/
2354 PROCEDURE change_third_party
2355
2356 IS
2357 l_log_module VARCHAR2(240);
2358 BEGIN
2359 --
2360 IF g_log_enabled THEN
2361 l_log_module := C_DEFAULT_MODULE||'.change_third_party';
2362 END IF;
2363 --
2364 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2365
2366 trace
2367 (p_msg => 'BEGIN of change_third_party'
2368 ,p_level => C_LEVEL_PROCEDURE
2369 ,p_module => l_log_module);
2370
2371 END IF;
2372 --
2373 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2374
2378 ,p_module => l_log_module);
2375 trace
2376 (p_msg => 'SQL - Insert into xla_ae_lines_gt '
2377 ,p_level => C_LEVEL_STATEMENT
2379 END IF;
2380 --
2381 INSERT INTO xla_ae_lines_gt
2382 (
2383 ae_header_id
2384 , temp_line_num
2385 , event_id
2386 --
2387 , ref_ae_header_id
2388 , ref_ae_line_num
2389 , ref_temp_line_num
2390 --
2391 , accounting_class_code
2392 , event_class_code
2393 , event_type_code
2394 , line_definition_owner_code
2395 , line_definition_code
2396 , accounting_line_type_code
2397 , accounting_line_code
2398 --
2399 , code_combination_status_code
2400 , code_combination_id
2401 , sl_coa_mapping_name
2402 , dynamic_insert_flag
2403 , source_coa_id
2404 , ccid_coa_id
2405 --
2406 , description
2407 , gl_transfer_mode_code
2408 , merge_duplicate_code
2409 , switch_side_flag
2410 --
2411 --, entered_amount
2412 --, ledger_amount
2413 , unrounded_entered_cr
2414 , unrounded_entered_dr
2415 , unrounded_accounted_cr
2416 , unrounded_accounted_dr
2417 , entered_cr
2418 , entered_dr
2419 , accounted_cr
2420 , accounted_dr
2421 , currency_code
2422 , currency_conversion_date
2423 , currency_conversion_rate
2424 , currency_conversion_type
2425 , statistical_amount
2426 --
2427 , party_id
2428 , party_site_id
2429 , party_type_code
2430 --
2431 , ussgl_transaction_code
2432 , jgzz_recon_ref
2433 --
2434 , source_distribution_id_char_1
2435 , source_distribution_id_char_2
2436 , source_distribution_id_char_3
2437 , source_distribution_id_char_4
2438 , source_distribution_id_char_5
2439 , source_distribution_id_num_1
2440 , source_distribution_id_num_2
2441 , source_distribution_id_num_3
2442 , source_distribution_id_num_4
2443 , source_distribution_id_num_5
2444 , source_distribution_type
2445 --
2446 , tax_line_ref_id
2447 , tax_summary_line_ref_id
2448 , tax_rec_nrec_dist_ref_id
2449 , anc_id_1
2450 , anc_id_2
2451 , anc_id_3
2452 , anc_id_4
2453 , anc_id_5
2454 , anc_id_6
2455 , anc_id_7
2456 , anc_id_8
2457 , anc_id_9
2458 , anc_id_10
2459 , anc_id_11
2460 , anc_id_12
2461 , anc_id_13
2462 , anc_id_14
2463 , anc_id_15
2464 , anc_id_16
2465 , anc_id_17
2466 , anc_id_18
2467 , anc_id_19
2468 , anc_id_20
2469 , anc_id_21
2470 , anc_id_22
2471 , anc_id_23
2472 , anc_id_24
2473 , anc_id_25
2474 , anc_id_26
2475 , anc_id_27
2476 , anc_id_28
2477 , anc_id_29
2478 , anc_id_30
2479 , anc_id_31
2480 , anc_id_32
2481 , anc_id_33
2482 , anc_id_34
2483 , anc_id_35
2484 , anc_id_36
2485 , anc_id_37
2486 , anc_id_38
2487 , anc_id_39
2488 , anc_id_40
2489 , anc_id_41
2490 , anc_id_42
2491 , anc_id_43
2492 , anc_id_44
2493 , anc_id_45
2494 , anc_id_46
2495 , anc_id_47
2496 , anc_id_48
2497 , anc_id_49
2498 , anc_id_50
2499 , anc_id_51
2500 , anc_id_52
2501 , anc_id_53
2502 , anc_id_54
2503 , anc_id_55
2504 , anc_id_56
2505 , anc_id_57
2506 , anc_id_58
2507 , anc_id_59
2508 , anc_id_60
2509 , anc_id_61
2510 , anc_id_62
2511 , anc_id_63
2512 , anc_id_64
2513 , anc_id_65
2514 , anc_id_66
2515 , anc_id_67
2516 , anc_id_68
2517 , anc_id_69
2518 , anc_id_70
2519 , anc_id_71
2520 , anc_id_72
2521 , anc_id_73
2522 , anc_id_74
2523 , anc_id_75
2524 , anc_id_76
2525 , anc_id_77
2526 , anc_id_78
2527 , anc_id_79
2528 , anc_id_80
2529 , anc_id_81
2530 , anc_id_82
2531 , anc_id_83
2532 , anc_id_84
2533 , anc_id_85
2534 , anc_id_86
2535 , anc_id_87
2536 , anc_id_88
2537 , anc_id_89
2538 , anc_id_90
2539 , anc_id_91
2540 , anc_id_92
2541 , anc_id_93
2542 , anc_id_94
2543 , anc_id_95
2544 , anc_id_96
2545 , anc_id_97
2546 , anc_id_98
2547 , anc_id_99
2548 , anc_id_100
2549 , inherit_desc_flag -- 4219869
2550 , mpa_accrual_entry_flag -- 4262811
2551 , encumbrance_type_id -- 4458381 Public Sector Enh
2552 , header_num -- 5100860 assign value to avoid using function index
2553 )
2554
2555 SELECT
2556 CASE xah.balance_type_code
2557 WHEN C_ACTUAL THEN g_rec_header_new.array_actual_header_id(g_header_idx)
2558 WHEN C_BUDGET THEN g_rec_header_new.array_budget_header_id(g_header_idx)
2559 WHEN C_ENCUMBRANCE THEN g_rec_header_new.array_encumb_header_id(g_header_idx)
2560 END
2561 , XLA_AE_LINES_PKG.SetLineNum(xah.balance_type_code)
2562 , XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
2563 --
2564 , xal.ae_header_id
2565 , xal.ae_line_num
2566 , xdl.temp_line_num
2567 --
2568 , xal.accounting_class_code
2569 , xdl.event_class_code
2570 , xdl.event_type_code
2571 , xdl.line_definition_owner_code
2572 , xdl.line_definition_code
2573 , xdl.accounting_line_type_code
2574 , xdl.accounting_line_code
2575 --
2576 , C_CCID
2577 , xal.code_combination_id
2578 , NULL
2579 , NULL
2580 , NULL
2581 , NULL
2582 , xal.description
2583 , xal.gl_transfer_mode_code
2584 , xdl.merge_duplicate_code
2585 , DECODE(XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option,
2586 'SIDE', C_SWITCH,
2587 C_NO_SWITCH
2588 )
2589 /* , xdl.entered_amount
2593 , xal.unrounded_entered_cr
2590 , xdl.ledger_amount */
2591 --
2592 , xal.unrounded_entered_dr
2594 , xal.unrounded_accounted_dr
2595 , xal.unrounded_accounted_cr
2596 , xal.entered_dr
2597 , xal.entered_cr
2598 , xal.accounted_dr
2599 , xal.accounted_cr
2600 --
2601 , xal.currency_code
2602 , xal.currency_conversion_date
2603 , xal.currency_conversion_rate
2604 , xal.currency_conversion_type
2605 , xal.statistical_amount
2606 --
2607 , xal.party_id
2608 , xal.party_site_id
2609 , xal.party_type_code
2610 --
2611 , xal.ussgl_transaction_code
2612 , xal.jgzz_recon_ref
2613 --
2614 , xdl.source_distribution_id_char_1
2615 , xdl.source_distribution_id_char_2
2616 , xdl.source_distribution_id_char_3
2617 , xdl.source_distribution_id_char_4
2618 , xdl.source_distribution_id_char_5
2619 , xdl.source_distribution_id_num_1
2620 , xdl.source_distribution_id_num_2
2621 , xdl.source_distribution_id_num_3
2622 , xdl.source_distribution_id_num_4
2623 , xdl.source_distribution_id_num_5
2624 , xdl.source_distribution_type
2625 --
2626 , xdl.tax_line_ref_id
2627 , xdl.tax_summary_line_ref_id
2628 , xdl.tax_rec_nrec_dist_ref_id
2629 , anc_id_1
2630 , anc_id_2
2631 , anc_id_3
2632 , anc_id_4
2633 , anc_id_5
2634 , anc_id_6
2635 , anc_id_7
2636 , anc_id_8
2637 , anc_id_9
2638 , anc_id_10
2639 , anc_id_11
2640 , anc_id_12
2641 , anc_id_13
2642 , anc_id_14
2643 , anc_id_15
2644 , anc_id_16
2645 , anc_id_17
2646 , anc_id_18
2647 , anc_id_19
2648 , anc_id_20
2649 , anc_id_21
2650 , anc_id_22
2651 , anc_id_23
2652 , anc_id_24
2653 , anc_id_25
2654 , anc_id_26
2655 , anc_id_27
2656 , anc_id_28
2657 , anc_id_29
2658 , anc_id_30
2659 , anc_id_31
2660 , anc_id_32
2661 , anc_id_33
2662 , anc_id_34
2663 , anc_id_35
2664 , anc_id_36
2665 , anc_id_37
2666 , anc_id_38
2667 , anc_id_39
2668 , anc_id_40
2669 , anc_id_41
2670 , anc_id_42
2671 , anc_id_43
2672 , anc_id_44
2673 , anc_id_45
2674 , anc_id_46
2675 , anc_id_47
2676 , anc_id_48
2677 , anc_id_49
2678 , anc_id_50
2679 , anc_id_51
2680 , anc_id_52
2681 , anc_id_53
2682 , anc_id_54
2683 , anc_id_55
2684 , anc_id_56
2685 , anc_id_57
2686 , anc_id_58
2687 , anc_id_59
2688 , anc_id_60
2689 , anc_id_61
2690 , anc_id_62
2691 , anc_id_63
2692 , anc_id_64
2693 , anc_id_65
2694 , anc_id_66
2695 , anc_id_67
2696 , anc_id_68
2697 , anc_id_69
2698 , anc_id_70
2699 , anc_id_71
2700 , anc_id_72
2701 , anc_id_73
2702 , anc_id_74
2703 , anc_id_75
2704 , anc_id_76
2705 , anc_id_77
2706 , anc_id_78
2707 , anc_id_79
2708 , anc_id_80
2709 , anc_id_81
2710 , anc_id_82
2711 , anc_id_83
2712 , anc_id_84
2713 , anc_id_85
2714 , anc_id_86
2715 , anc_id_87
2716 , anc_id_88
2717 , anc_id_89
2718 , anc_id_90
2719 , anc_id_91
2720 , anc_id_92
2721 , anc_id_93
2722 , anc_id_94
2723 , anc_id_95
2724 , anc_id_96
2725 , anc_id_97
2726 , anc_id_98
2727 , anc_id_99
2728 , anc_id_100
2729 , 'N' -- 4219869 inherit_desc_flag
2730 , 'N' -- 4262811 mpa_accrual_entry_flag
2731 , xal.encumbrance_type_id -- 4458381 Public Sector Enh
2732 , 0 -- 5100860 assign value to avoid using function index
2733 --
2734 FROM xla_ae_lines xal,
2735 xla_ae_headers xah,
2736 xla_distribution_links xdl,
2737 xla_events xe,
2738 (SELECT ae_header_id
2739 ,ae_line_num
2740 ,MAX(DECODE(rank,1,anc_id)) anc_id_1
2741 ,MAX(DECODE(rank,2,anc_id)) anc_id_2
2742 ,MAX(DECODE(rank,3,anc_id)) anc_id_3
2743 ,MAX(DECODE(rank,4,anc_id)) anc_id_4
2744 ,MAX(DECODE(rank,5,anc_id)) anc_id_5
2745 ,MAX(DECODE(rank,6,anc_id)) anc_id_6
2746 ,MAX(DECODE(rank,7,anc_id)) anc_id_7
2747 ,MAX(DECODE(rank,8,anc_id)) anc_id_8
2748 ,MAX(DECODE(rank,9,anc_id)) anc_id_9
2749 ,MAX(DECODE(rank,10,anc_id)) anc_id_10
2750 ,MAX(DECODE(rank,11,anc_id)) anc_id_11
2751 ,MAX(DECODE(rank,12,anc_id)) anc_id_12
2752 ,MAX(DECODE(rank,13,anc_id)) anc_id_13
2753 ,MAX(DECODE(rank,14,anc_id)) anc_id_14
2754 ,MAX(DECODE(rank,15,anc_id)) anc_id_15
2755 ,MAX(DECODE(rank,16,anc_id)) anc_id_16
2756 ,MAX(DECODE(rank,17,anc_id)) anc_id_17
2757 ,MAX(DECODE(rank,18,anc_id)) anc_id_18
2758 ,MAX(DECODE(rank,19,anc_id)) anc_id_19
2759 ,MAX(DECODE(rank,20,anc_id)) anc_id_20
2760 ,MAX(DECODE(rank,21,anc_id)) anc_id_21
2761 ,MAX(DECODE(rank,22,anc_id)) anc_id_22
2762 ,MAX(DECODE(rank,23,anc_id)) anc_id_23
2763 ,MAX(DECODE(rank,24,anc_id)) anc_id_24
2764 ,MAX(DECODE(rank,25,anc_id)) anc_id_25
2765 ,MAX(DECODE(rank,26,anc_id)) anc_id_26
2766 ,MAX(DECODE(rank,27,anc_id)) anc_id_27
2770 ,MAX(DECODE(rank,31,anc_id)) anc_id_31
2767 ,MAX(DECODE(rank,28,anc_id)) anc_id_28
2768 ,MAX(DECODE(rank,29,anc_id)) anc_id_29
2769 ,MAX(DECODE(rank,30,anc_id)) anc_id_30
2771 ,MAX(DECODE(rank,32,anc_id)) anc_id_32
2772 ,MAX(DECODE(rank,33,anc_id)) anc_id_33
2773 ,MAX(DECODE(rank,34,anc_id)) anc_id_34
2774 ,MAX(DECODE(rank,35,anc_id)) anc_id_35
2775 ,MAX(DECODE(rank,36,anc_id)) anc_id_36
2776 ,MAX(DECODE(rank,37,anc_id)) anc_id_37
2777 ,MAX(DECODE(rank,38,anc_id)) anc_id_38
2778 ,MAX(DECODE(rank,39,anc_id)) anc_id_39
2779 ,MAX(DECODE(rank,40,anc_id)) anc_id_40
2780 ,MAX(DECODE(rank,41,anc_id)) anc_id_41
2781 ,MAX(DECODE(rank,42,anc_id)) anc_id_42
2782 ,MAX(DECODE(rank,43,anc_id)) anc_id_43
2783 ,MAX(DECODE(rank,44,anc_id)) anc_id_44
2784 ,MAX(DECODE(rank,45,anc_id)) anc_id_45
2785 ,MAX(DECODE(rank,46,anc_id)) anc_id_46
2786 ,MAX(DECODE(rank,47,anc_id)) anc_id_47
2787 ,MAX(DECODE(rank,48,anc_id)) anc_id_48
2788 ,MAX(DECODE(rank,49,anc_id)) anc_id_49
2789 ,MAX(DECODE(rank,50,anc_id)) anc_id_50
2790 ,MAX(DECODE(rank,51,anc_id)) anc_id_51
2791 ,MAX(DECODE(rank,52,anc_id)) anc_id_52
2792 ,MAX(DECODE(rank,53,anc_id)) anc_id_53
2793 ,MAX(DECODE(rank,54,anc_id)) anc_id_54
2794 ,MAX(DECODE(rank,55,anc_id)) anc_id_55
2795 ,MAX(DECODE(rank,56,anc_id)) anc_id_56
2796 ,MAX(DECODE(rank,57,anc_id)) anc_id_57
2797 ,MAX(DECODE(rank,58,anc_id)) anc_id_58
2798 ,MAX(DECODE(rank,59,anc_id)) anc_id_59
2799 ,MAX(DECODE(rank,60,anc_id)) anc_id_60
2800 ,MAX(DECODE(rank,61,anc_id)) anc_id_61
2801 ,MAX(DECODE(rank,62,anc_id)) anc_id_62
2802 ,MAX(DECODE(rank,63,anc_id)) anc_id_63
2803 ,MAX(DECODE(rank,64,anc_id)) anc_id_64
2804 ,MAX(DECODE(rank,65,anc_id)) anc_id_65
2805 ,MAX(DECODE(rank,66,anc_id)) anc_id_66
2806 ,MAX(DECODE(rank,67,anc_id)) anc_id_67
2807 ,MAX(DECODE(rank,68,anc_id)) anc_id_68
2808 ,MAX(DECODE(rank,69,anc_id)) anc_id_69
2809 ,MAX(DECODE(rank,70,anc_id)) anc_id_70
2810 ,MAX(DECODE(rank,71,anc_id)) anc_id_71
2811 ,MAX(DECODE(rank,72,anc_id)) anc_id_72
2812 ,MAX(DECODE(rank,73,anc_id)) anc_id_73
2813 ,MAX(DECODE(rank,74,anc_id)) anc_id_74
2814 ,MAX(DECODE(rank,75,anc_id)) anc_id_75
2815 ,MAX(DECODE(rank,76,anc_id)) anc_id_76
2816 ,MAX(DECODE(rank,77,anc_id)) anc_id_77
2817 ,MAX(DECODE(rank,78,anc_id)) anc_id_78
2818 ,MAX(DECODE(rank,79,anc_id)) anc_id_79
2819 ,MAX(DECODE(rank,80,anc_id)) anc_id_80
2820 ,MAX(DECODE(rank,81,anc_id)) anc_id_81
2821 ,MAX(DECODE(rank,82,anc_id)) anc_id_82
2822 ,MAX(DECODE(rank,83,anc_id)) anc_id_83
2823 ,MAX(DECODE(rank,84,anc_id)) anc_id_84
2824 ,MAX(DECODE(rank,85,anc_id)) anc_id_85
2825 ,MAX(DECODE(rank,86,anc_id)) anc_id_86
2826 ,MAX(DECODE(rank,87,anc_id)) anc_id_87
2827 ,MAX(DECODE(rank,88,anc_id)) anc_id_88
2828 ,MAX(DECODE(rank,89,anc_id)) anc_id_89
2829 ,MAX(DECODE(rank,90,anc_id)) anc_id_90
2830 ,MAX(DECODE(rank,91,anc_id)) anc_id_91
2831 ,MAX(DECODE(rank,92,anc_id)) anc_id_92
2832 ,MAX(DECODE(rank,93,anc_id)) anc_id_93
2833 ,MAX(DECODE(rank,94,anc_id)) anc_id_94
2834 ,MAX(DECODE(rank,95,anc_id)) anc_id_95
2835 ,MAX(DECODE(rank,96,anc_id)) anc_id_96
2836 ,MAX(DECODE(rank,97,anc_id)) anc_id_97
2837 ,MAX(DECODE(rank,98,anc_id)) anc_id_98
2838 ,MAX(DECODE(rank,99,anc_id)) anc_id_99
2839 ,MAX(DECODE(rank,100,anc_id)) anc_id_100
2840 FROM
2841 (SELECT xald.ae_header_id
2842 , xald.ae_line_num
2843 , xald.analytical_criterion_code || '(]' ||
2844 xald.analytical_criterion_type_code || '(]' ||
2845 xald.amb_context_code || '(]' ||
2846 xald.ac1 || '(]' ||
2847 xald.ac2 || '(]' ||
2848 xald.ac3 || '(]' ||
2849 xald.ac4 || '(]' ||
2850 xald.ac5 anc_id
2851 , RANK() OVER (
2852 PARTITION BY ae_header_id, ae_line_num
2853 ORDER BY analytical_criterion_code
2854 ,analytical_criterion_type_code
2855 ,amb_context_code
2856 ,ac1
2857 ,ac2
2858 ,ac3
2859 ,ac4
2860 ,ac5) rank
2861 FROM xla_ae_line_acs xald)
2862 GROUP BY ae_header_id, ae_line_num) anc
2863
2864 WHERE xe.event_id = xdl.event_id
2865 AND xe.event_id = xah.event_id
2866 AND xal.ae_header_id = xdl.ae_header_id
2867 AND xal.ae_header_id = xah.ae_header_id
2868 AND xal.ae_line_num = xdl.ae_line_num
2869 AND xe.entity_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
2870 AND anc.ae_header_id = xdl.ae_header_id
2871 AND anc.ae_line_num = xdl.ae_line_num
2872 AND xah.ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
2873 AND (g_rec_header_new.array_previous_party_id(g_header_idx) IS NULL
2874 OR
2875 xal.party_id = g_rec_header_new.array_previous_party_id(g_header_idx))
2876 AND (g_rec_header_new.array_previous_party_site_id(g_header_idx) IS NULL
2880 OR
2877 OR
2878 xal.party_site_id = g_rec_header_new.array_previous_party_site_id(g_header_idx))
2879 AND (g_rec_header_new.array_party_change_type(g_header_idx) IS NULL
2881 xal.party_type_code = g_rec_header_new.array_party_change_type(g_header_idx))
2882 ;
2883
2884 IF (C_LEVEL_EVENT >= g_log_level) THEN
2885
2886 trace
2887 (p_msg => '# temporary journal lines inserted into GT xla_ae_lines_gt = '||SQL%ROWCOUNT
2888 ,p_level => C_LEVEL_EVENT
2889 ,p_module => l_log_module);
2890
2891 END IF;
2892
2893
2894 IF SQL%ROWCOUNT > 0 THEN
2895 --
2896 --
2897 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2898
2899 trace
2900 (p_msg => 'SQL - Insert into xla_ae_lines_gt '
2901 ,p_level => C_LEVEL_STATEMENT
2902 ,p_module => l_log_module);
2903 END IF;
2904 --
2905 --
2906 INSERT INTO xla_ae_lines_gt
2907 (
2908 ae_header_id
2909 , temp_line_num
2910 , event_id
2911 --
2912 , ref_ae_header_id
2913 , ref_ae_line_num
2914 , ref_temp_line_num
2915 --
2916 , accounting_class_code
2917 , event_class_code
2918 , event_type_code
2919 , line_definition_owner_code
2920 , line_definition_code
2921 , accounting_line_type_code
2922 , accounting_line_code
2923 --
2924 , code_combination_status_code
2925 , code_combination_id
2926 , sl_coa_mapping_name
2927 , dynamic_insert_flag
2928 , source_coa_id
2929 , ccid_coa_id
2930 --
2931 , description
2932 , gl_transfer_mode_code
2933 , merge_duplicate_code
2934 , switch_side_flag
2935 --
2936 --, entered_amount
2937 --, ledger_amount
2938 , unrounded_entered_dr
2939 , unrounded_entered_cr
2940 , unrounded_accounted_dr
2941 , unrounded_accounted_cr
2942 , entered_dr
2943 , entered_cr
2944 , accounted_dr
2945 , accounted_cr
2946 , currency_code
2947 , currency_conversion_date
2948 , currency_conversion_rate
2949 , currency_conversion_type
2950 , statistical_amount
2951 --
2952 , party_id
2953 , party_site_id
2954 , party_type_code
2955 --
2956 , ussgl_transaction_code
2957 , jgzz_recon_ref
2958 --
2959 , source_distribution_id_char_1
2960 , source_distribution_id_char_2
2961 , source_distribution_id_char_3
2962 , source_distribution_id_char_4
2963 , source_distribution_id_char_5
2964 , source_distribution_id_num_1
2965 , source_distribution_id_num_2
2966 , source_distribution_id_num_3
2967 , source_distribution_id_num_4
2968 , source_distribution_id_num_5
2969 , source_distribution_type
2970 --
2971 , tax_line_ref_id
2972 , tax_summary_line_ref_id
2973 , tax_rec_nrec_dist_ref_id
2974 , inherit_desc_flag -- 4219869
2975 , mpa_accrual_entry_flag -- 4262811
2976 , encumbrance_type_id -- 4458381 Public Sector Enh
2977 , header_num -- 5100860 assign value to avoid using function index
2978 )
2979
2980 SELECT
2981 CASE xah.balance_type_code
2982 WHEN C_ACTUAL THEN g_rec_header_new.array_actual_header_id(g_header_idx)
2983 WHEN C_BUDGET THEN g_rec_header_new.array_budget_header_id(g_header_idx)
2984 WHEN C_ENCUMBRANCE THEN g_rec_header_new.array_encumb_header_id(g_header_idx)
2985 END
2986 , XLA_AE_LINES_PKG.SetLineNum(xah.balance_type_code)
2987 , XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
2988 --
2989 , xal.ae_header_id
2990 , xal.ae_line_num
2991 , xdl.temp_line_num
2992 --
2993 , xal.accounting_class_code
2994 , xdl.event_class_code
2995 , xdl.event_type_code
2996 , xdl.line_definition_owner_code
2997 , xdl.line_definition_code
2998 , xdl.accounting_line_type_code
2999 , xdl.accounting_line_code
3000 --
3001 , C_CCID
3002 , xal.code_combination_id
3003 , NULL
3004 , NULL
3005 , NULL
3006 , NULL
3007 , xal.description
3008 , xal.gl_transfer_mode_code
3009 , xdl.merge_duplicate_code
3010 , DECODE(XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option,
3011 'SIDE', C_SWITCH,
3012 C_NO_SWITCH
3013 )
3014 -- , xdl.entered_amount
3015 -- , xdl.ledger_amount
3016 --
3017 , xal.unrounded_entered_dr
3018 , xal.unrounded_entered_cr
3019 , xal.unrounded_accounted_dr
3020 , xal.unrounded_accounted_cr
3021 , xal.entered_dr
3022 , xal.entered_cr
3023 , xal.accounted_dr
3024 , xal.accounted_cr
3025 --
3026 , xal.currency_code
3027 , xal.currency_conversion_date
3028 , xal.currency_conversion_rate
3029 , xal.currency_conversion_type
3030 , xal.statistical_amount
3031 --
3032 , g_rec_header_new.array_new_party_id(g_header_idx)
3033 , g_rec_header_new.array_new_party_site_id(g_header_idx)
3034 , g_rec_header_new.array_party_change_type(g_header_idx)
3035 --
3036 , xal.ussgl_transaction_code
3037 , xal.jgzz_recon_ref
3038 --
3039 , xdl.source_distribution_id_char_1
3040 , xdl.source_distribution_id_char_2
3041 , xdl.source_distribution_id_char_3
3042 , xdl.source_distribution_id_char_4
3043 , xdl.source_distribution_id_char_5
3044 , xdl.source_distribution_id_num_1
3045 , xdl.source_distribution_id_num_2
3046 , xdl.source_distribution_id_num_3
3047 , xdl.source_distribution_id_num_4
3048 , xdl.source_distribution_id_num_5
3049 , xdl.source_distribution_type
3050 --
3051 , xdl.tax_line_ref_id
3055 , 'N' -- 4262811 mpa_accrual_entry_flag
3052 , xdl.tax_summary_line_ref_id
3053 , xdl.tax_rec_nrec_dist_ref_id
3054 , 'N' -- 4219869 inherit_desc_flag
3056 , xal.encumbrance_type_id -- 4458381 Public Sector Enh
3057 , 0 -- 5100860 assign value to avoid using function index
3058 --
3059 FROM xla_ae_lines xal,
3060 xla_ae_headers xah,
3061 xla_distribution_links xdl,
3062 xla_events xe
3063 WHERE xe.event_id = xdl.event_id
3064 AND xe.event_id = xah.event_id
3065 AND xal.ae_header_id = xdl.ae_header_id
3066 AND xal.ae_header_id = xah.ae_header_id
3067 AND xal.ae_line_num = xdl.ae_line_num
3068 AND xe.entity_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3069 AND xah.ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
3070 AND ( g_rec_header_new.array_previous_party_id(g_header_idx) IS NULL
3071 OR
3072 xal.party_id = g_rec_header_new.array_previous_party_id(g_header_idx))
3073 AND ( g_rec_header_new.array_previous_party_site_id(g_header_idx) IS NULL
3074 OR
3075 xal.party_site_id = g_rec_header_new.array_previous_party_site_id(g_header_idx))
3076 AND ( g_rec_header_new.array_party_change_type(g_header_idx) IS NULL
3077 OR
3078 xal.party_type_code = g_rec_header_new.array_party_change_type(g_header_idx))
3079 ;
3080 --
3081 --
3082 IF (C_LEVEL_EVENT >= g_log_level) THEN
3083
3084 trace
3085 (p_msg => '# temporary journal lines inserted into GT xla_ae_lines_gt = '||SQL%ROWCOUNT
3086 ,p_level => C_LEVEL_EVENT
3087 ,p_module => l_log_module);
3088 END IF;
3089
3090 END IF;
3091 --
3092 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3093
3094 trace
3095 (p_msg => 'END of change_third_party'
3096 ,p_level => C_LEVEL_PROCEDURE
3097 ,p_module => l_log_module);
3098
3099 END IF;
3100 EXCEPTION
3101 WHEN xla_exceptions_pkg.application_exception THEN
3102 RAISE;
3103 WHEN OTHERS THEN
3104 xla_exceptions_pkg.raise_message
3105 (p_location => 'XLA_AE_HEADER_PKG.change_third_party');
3106 --
3107 END change_third_party;
3108 --
3109 --
3110 /*======================================================================+
3111 | |
3112 | Public Procedure |
3113 | |
3114 | |
3115 +======================================================================*/
3116 PROCEDURE RefreshHeader
3117 IS
3118 l_null_rec_header_new t_rec_header_new;
3119 l_null_rec_period_name t_rec_period_name;
3120 l_log_module VARCHAR2(240);
3121 BEGIN
3122 --
3123 IF g_log_enabled THEN
3124 l_log_module := C_DEFAULT_MODULE||'.RefreshHeader';
3125 END IF;
3126 --
3127
3128 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3129
3130 trace
3131 (p_msg => 'BEGIN of RefreshHeader'
3132 ,p_level => C_LEVEL_PROCEDURE
3133 ,p_module => l_log_module);
3134
3135 END IF;
3136 --
3137 g_rec_header_new := l_null_rec_header_new ;
3138 g_cache_period_name := l_null_rec_period_name;
3139 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := NULL;
3140 --
3141 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3142
3143 trace
3144 (p_msg => 'END of RefreshHeader'
3145 ,p_level => C_LEVEL_PROCEDURE
3146 ,p_module => l_log_module);
3147
3148 END IF;
3149 --
3150 EXCEPTION
3151 WHEN xla_exceptions_pkg.application_exception THEN
3152 RAISE;
3153 WHEN OTHERS THEN
3154 xla_exceptions_pkg.raise_message
3155 (p_location => 'XLA_AE_HEADER_PKG.RefreshHeader');
3156 --
3157 END RefreshHeader;
3158 --
3159 /*======================================================================+
3160 | |
3161 | |
3162 | |
3163 +======================================================================*/
3164 procedure SetHdrAcctAttrs
3165 (p_rec_acct_attrs in t_rec_acct_attrs) is
3166 l_log_module VARCHAR2(240);
3167 BEGIN
3168 --
3169 IF g_log_enabled THEN
3170 l_log_module := C_DEFAULT_MODULE||'.SetHdrAcctAttrs';
3171 END IF;
3172
3173 FOR i in 1..p_rec_acct_attrs.array_acct_attr_code.count loop
3174
3175 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3176 IF p_rec_acct_attrs.array_char_value.EXISTS(i) THEN
3177 trace(p_msg => 'Loop count = '||i||
3178 ' (char) : '||p_rec_acct_attrs.array_acct_attr_code(i)||
3179 ' = '||p_rec_acct_attrs.array_char_value(i)
3180 ,p_level => C_LEVEL_STATEMENT
3181 ,p_module => l_log_module);
3182 ELSIF p_rec_acct_attrs.array_date_value.EXISTS(i) THEN
3183 trace(p_msg => 'Loop count = '||i||
3184 ' (date) : '||p_rec_acct_attrs.array_acct_attr_code(i)||
3185 ' = '||p_rec_acct_attrs.array_date_value(i)
3186 ,p_level => C_LEVEL_STATEMENT
3187 ,p_module => l_log_module);
3188 ELSE
3192 ,p_level => C_LEVEL_STATEMENT
3189 trace(p_msg => 'Loop count = '||i||
3190 ' (num) : '||p_rec_acct_attrs.array_acct_attr_code(i)||
3191 ' = '||p_rec_acct_attrs.array_num_value(i)
3193 ,p_module => l_log_module);
3194 END IF;
3195
3196 END IF;
3197
3198 CASE p_rec_acct_attrs.array_acct_attr_code(i)
3199 WHEN 'DOC_CATEGORY_CODE' THEN
3200 IF p_rec_acct_attrs.array_char_value.EXISTS(i) THEN
3201 g_rec_header_new.array_doc_category_code(g_header_idx) := p_rec_acct_attrs.array_char_value(i);
3202 ELSE
3203 g_rec_header_new.array_doc_category_code(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3204 END IF;
3205
3206 WHEN 'PARTY_CHANGE_OPTION' THEN
3207 -- 5161760
3208 IF p_rec_acct_attrs.array_char_value.EXISTS(i) THEN
3209 IF length(p_rec_acct_attrs.array_char_value(i)) > 1 THEN
3210 g_rec_header_new.array_party_change_option(g_header_idx) := 'X';
3211 ELSE
3212 g_rec_header_new.array_party_change_option(g_header_idx) := p_rec_acct_attrs.array_char_value(i);
3213 END IF;
3214 ELSE
3215 g_rec_header_new.array_party_change_option(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3216 END IF;
3217
3218 IF NVL(g_rec_header_new.array_party_change_option(g_header_idx),'N') NOT IN ('Y','N') THEN
3219 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
3220 xla_accounting_err_pkg.build_message
3221 (p_appli_s_name => 'XLA'
3222 ,p_msg_name => 'XLA_AP_THIRD_PARTY_OPTION'
3223 ,p_token_1 => 'PRODUCT_NAME'
3224 ,p_value_1 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
3225 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3226 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
3227 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id);
3228 END IF;
3229
3230 WHEN 'GL_TRANSFER_FLAG' THEN
3231 -- 5161760
3232 IF p_rec_acct_attrs.array_char_value.EXISTS(i) THEN
3233 IF length(p_rec_acct_attrs.array_char_value(i)) > 1 THEN
3234 g_rec_header_new.array_gl_transfer_flag(g_header_idx) := 'X';
3235 ELSE
3236 g_rec_header_new.array_gl_transfer_flag(g_header_idx) := nvl(p_rec_acct_attrs.array_char_value(i), 'Y');
3237 END IF;
3238 ELSE
3239 g_rec_header_new.array_gl_transfer_flag(g_header_idx) := nvl(p_rec_acct_attrs.array_num_value(i), 'Y');
3240 END IF;
3241
3242 IF NVL(g_rec_header_new.array_gl_transfer_flag(g_header_idx),'Y') NOT IN ('Y', 'N') THEN
3243 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
3244 xla_accounting_err_pkg.build_message
3245 (p_appli_s_name => 'XLA'
3246 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
3247 ,p_token_1 => 'ACCT_ATTR_NAME'
3248 ,p_value_1 => XLA_AE_SOURCES_PKG.GetAccountingSourceName('GL_TRANSFER_FLAG')
3249 ,p_token_2 => 'PRODUCT_NAME'
3250 ,p_value_2 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
3251 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3252 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
3253 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id);
3254 END IF;
3255
3256 WHEN 'TRX_ACCT_REVERSAL_OPTION' THEN
3257 -- 5161760
3258 IF p_rec_acct_attrs.array_char_value.EXISTS(i) THEN
3259 IF length(p_rec_acct_attrs.array_char_value(i)) > 1 THEN
3260 g_rec_header_new.array_trx_acct_reversal_option(g_header_idx) := 'X';
3261 ELSE
3262 g_rec_header_new.array_trx_acct_reversal_option(g_header_idx) := nvl(p_rec_acct_attrs.array_char_value(i), 'N');
3263 END IF;
3264 ELSE
3265 g_rec_header_new.array_trx_acct_reversal_option(g_header_idx) := nvl(p_rec_acct_attrs.array_num_value(i), 'N');
3266 END IF;
3267
3268 IF NVL(g_rec_header_new.array_trx_acct_reversal_option(g_header_idx),'N') NOT IN ('Y', 'N') THEN
3269 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
3270 xla_accounting_err_pkg.build_message
3271 (p_appli_s_name => 'XLA'
3272 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
3273 ,p_token_1 => 'ACCT_ATTR_NAME'
3274 ,p_value_1 => XLA_AE_SOURCES_PKG.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
3275 ,p_token_2 => 'PRODUCT_NAME'
3276 ,p_value_2 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
3277 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3278 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
3279 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id);
3280 END IF;
3281
3282 WHEN 'PARTY_CHANGE_TYPE' THEN
3283 IF p_rec_acct_attrs.array_char_value.EXISTS(i) THEN
3284 g_rec_header_new.array_party_change_type(g_header_idx) := p_rec_acct_attrs.array_char_value(i);
3285 ELSE
3289 WHEN 'DOC_SEQUENCE_ID' THEN
3286 g_rec_header_new.array_party_change_type(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3287 END IF;
3288
3290 g_rec_header_new.array_doc_sequence_id(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3291
3292 WHEN 'DOC_SEQUENCE_VALUE' THEN
3293 g_rec_header_new.array_doc_sequence_value(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3294
3295 /* -- 4458381 Public Sector Enh
3296 WHEN 'ENCUMBRANCE_TYPE_ID' THEN
3297 g_rec_header_new.array_encumbrance_type_id(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3298 */
3299
3300 WHEN 'BUDGET_VERSION_ID' THEN
3301 g_rec_header_new.array_budget_version_id(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3302
3303 WHEN 'NEW_PARTY_ID' THEN
3304 g_rec_header_new.array_new_party_id(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3305
3306 WHEN 'NEW_PARTY_SITE_ID' THEN
3307 g_rec_header_new.array_new_party_site_id(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3308
3309 WHEN 'PREVIOUS_PARTY_ID' THEN
3310 g_rec_header_new.array_previous_party_id(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3311
3312 WHEN 'PREVIOUS_PARTY_SITE_ID' THEN
3313 g_rec_header_new.array_previous_party_site_id(g_header_idx) := p_rec_acct_attrs.array_num_value(i);
3314
3315 WHEN 'GL_DATE' THEN
3316 g_rec_header_new.array_gl_date(g_header_idx) := trunc(p_rec_acct_attrs.array_date_value(i));
3317 IF p_rec_acct_attrs.array_date_value(i) is NULL THEN
3318 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_INVALID;
3319 xla_accounting_err_pkg.build_message
3320 (p_appli_s_name => 'XLA'
3321 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
3322 ,p_token_1 => 'ACCT_ATTR_NAME'
3323 ,p_value_1 => XLA_AE_SOURCES_PKG.GetAccountingSourceName('GL_DATE')
3324 ,p_token_2 => 'PRODUCT_NAME'
3325 ,p_value_2 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
3326 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3327 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
3328 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id);
3329 END IF;
3330 ELSE null;
3331 END CASE;
3332 end loop;
3333 EXCEPTION
3334 WHEN xla_exceptions_pkg.application_exception THEN
3335 RAISE;
3336 WHEN OTHERS THEN
3337 xla_exceptions_pkg.raise_message
3338 (p_location => 'XLA_AE_HEADER_PKG.SetHdrAcctAttrs');
3339 --
3340 end SetHdrAcctAttrs;
3341 --
3342 /*======================================================================+
3343 | |
3344 | |
3345 | |
3346 | |
3347 +======================================================================*/
3348 PROCEDURE ValidateBusinessDate
3349 (p_ledger_id IN NUMBER
3350 )
3351 IS
3352 l_transaction_calendar_id INTEGER;
3353 l_effective_date_rule_code VARCHAR2(1);
3354
3355 l_log_module VARCHAR2(240);
3356 l_count NUMBER DEFAULT 0; --bug7025386
3357
3358 BEGIN
3359
3360 IF g_log_enabled THEN
3361 l_log_module := C_DEFAULT_MODULE||'.ValidateBusinessDate';
3362 END IF;
3363
3364 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3365 trace
3366 (p_msg => 'BEGIN of ValidateBusinessDate'
3367 ,p_level => C_LEVEL_PROCEDURE
3368 ,p_module => l_log_module);
3369 END IF;
3370
3371 l_transaction_calendar_id := xla_accounting_cache_pkg.GetValueNum('TRANSACTION_CALENDAR_ID', p_ledger_id);
3372
3373 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3374 trace
3375 (p_msg => 'l_transaction_calendar_id ='||l_transaction_calendar_id
3376 ,p_level => C_LEVEL_STATEMENT
3377 ,p_module => l_log_module);
3378 END IF;
3379
3380 IF (xla_accounting_cache_pkg.getValueChar('ENABLE_AVERAGE_BALANCES_FLAG',p_ledger_id) = 'Y' AND
3381 xla_accounting_cache_pkg.getValueChar('EFFECTIVE_DATE_RULE_CODE',p_ledger_id) = 'R' AND
3382 l_transaction_calendar_id IS NOT NULL) THEN
3383
3384 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3385 trace
3386 (p_msg => 'SQL - update xla_ae_headers_gt'
3387 ,p_level => C_LEVEL_STATEMENT
3388 ,p_module => l_log_module);
3389 END IF;
3390
3391
3392 -- performance fix bug9781991 fixes both SQLs in this procedure, overriding both bug9630931 and bug8898196
3393 --
3394 -- UPDATE xla_ae_headers_gt xah
3395 -- SET accounting_date =
3396 -- DECODE(xah.acc_rev_gl_date_option,
3397 -- 'XLA_NEXT_DAY',
3398 -- (SELECT min(transaction_date)
3399 -- FROM gl_transaction_dates d1
3400 -- WHERE d1.business_day_flag = 'Y'
3401 -- AND d1.transaction_date >= xah.accounting_date
3402 -- AND d1.transaction_calendar_id = l_transaction_calendar_id),
3403 -- -- XLA_FIRST_DAY_NEXT_GL_PERIOD, XLA_LAST_DAY_NEXT_GL_PERIOD, NONE
3404 -- (SELECT transaction_date
3405 -- FROM (SELECT /*+ USE_NL_WITH_INDEX(XAH2, GL_TRANSACTION_DATES_U1) */ xah2.ae_header_id
3409 -- WHERE d.transaction_calendar_id = l_transaction_calendar_id
3406 -- , d.transaction_date
3407 -- FROM xla_ae_headers_gt xah2
3408 -- , gl_transaction_dates d
3410 -- AND d.business_day_flag = 'Y'
3411 -- AND d.transaction_date >= xah2.period_start_date
3412 -- /* restricting the future dates to a maximum of 6 Months ( 6 * 31 ) for bug9630931 */
3413 -- AND d.transaction_date <= ( xah2.period_start_date + 186 )
3414 -- ORDER by CASE WHEN d.transaction_date = xah2.accounting_date
3415 -- THEN 0
3416 -- -- added vdamerla bug 8898196
3417 -- -- WHEN d.transaction_date < xah2.accounting_date
3418 -- -- THEN xah2.accounting_date - d.transaction_date
3419 -- WHEN d.transaction_date > xah2.accounting_date
3420 -- THEN 1000 + d.transaction_date - xah2.accounting_date
3421 -- END ) tmp
3422 -- WHERE ROWNUM = 1
3423 -- AND xah.ae_header_id = tmp.ae_header_id
3424 -- and tmp.TRANSACTION_DATE >= XAH.PERIOD_START_DATE /* added vdamerla bug 8898196 */));
3425
3426
3427 FORALL i IN xla_ae_journal_entry_pkg.g_array_ae_header_id.FIRST .. xla_ae_journal_entry_pkg.g_array_ae_header_id.LAST
3428 UPDATE /*+ index(xah XLA_AE_HEADERS_GT_U1) */ xla_ae_headers_gt xah --added U1 hint for bug#10229047
3429 SET accounting_date =
3430 DECODE(xah.acc_rev_gl_date_option,
3431 'XLA_NEXT_DAY',
3432 ( SELECT min(transaction_date)
3433 FROM gl_transaction_dates d
3434 WHERE d.business_day_flag = 'Y'
3435 AND d.transaction_date >= xah.accounting_date
3436 AND d.transaction_calendar_id = l_transaction_calendar_id),
3437 -- XLA_FIRST_DAY_NEXT_GL_PERIOD, XLA_LAST_DAY_NEXT_GL_PERIOD, NONE
3438 ( SELECT transaction_date
3439 FROM (SELECT /*+ USE_NL(xah2,gps,d) INDEX(d GL_TRANSACTION_DATES_U1) index(xah2 XLA_AE_HEADERS_GT_U1) */ xah2.ae_header_id
3440 --added U1 hint for bug#10229047
3441 , d.transaction_date
3442 FROM xla_ae_headers_gt xah2
3443 , gl_transaction_dates d
3444 , gl_period_statuses gps
3445 WHERE d.transaction_calendar_id = l_transaction_calendar_id
3446 AND d.business_day_flag = 'Y'
3447 AND d.transaction_date >= xah2.period_start_date
3448 AND gps.application_id = 101
3449 AND gps.ledger_id = xah2.ledger_id
3450 AND gps.period_name = xah2.period_name
3451 AND d.transaction_date <= gps.end_date
3452 AND d.transaction_date >= gps.start_date
3453 AND xah2.ae_header_id = xla_ae_journal_entry_pkg.g_array_ae_header_id(i)
3454 ORDER by CASE WHEN d.transaction_date = xah2.accounting_date
3455 THEN 0
3456 WHEN d.transaction_date < xah2.accounting_date
3457 THEN xah2.accounting_date - d.transaction_date
3458 WHEN d.transaction_date > xah2.accounting_date
3459 THEN 1000 + d.transaction_date - xah2.accounting_date
3460 END ) tmp
3461 WHERE ROWNUM = 1 )
3462 )
3463 WHERE xah.ae_header_id = xla_ae_journal_entry_pkg.g_array_ae_header_id(i);
3464
3465
3466 -- above query will always update rows, even if all days are business days, same accounting date will be
3467 -- restamped, as a result, removed the l_count > 0 check in below query, only retained l_count for fnd logging
3468
3469 l_count := 0;
3470
3471 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3472
3473 FOR i IN 1..xla_ae_journal_entry_pkg.g_array_ae_header_id.COUNT
3474 LOOP
3475 l_count := SQL%BULK_ROWCOUNT(i) + l_count;
3476 END LOOP;
3477
3478 trace
3479 (p_msg => '# rows updated in xla_ae_headers_gt(1.2) ='|| l_count
3480 ,p_level => C_LEVEL_STATEMENT
3481 ,p_module => l_log_module);
3482 END IF;
3483
3484
3485
3486
3487 --
3488 --IF l_count > 0 THEN
3489 --
3490 --
3491 -- added hints for the perf change via bug#10047074
3492 FORALL i IN xla_ae_journal_entry_pkg.g_array_ae_header_id.FIRST .. xla_ae_journal_entry_pkg.g_array_ae_header_id.LAST
3493 UPDATE /*+ INDEX(XAL XLA_AE_LINES_GT_N4) */ xla_ae_lines_gt XAL
3494 SET XAL.ACCOUNTING_DATE = (SELECT /*+ INDEX(xah XLA_AE_HEADERS_GT_U1) */xah.accounting_date
3495 FROM xla_ae_headers_gt xah
3496 WHERE xah.ae_header_id = xla_ae_journal_entry_pkg.g_array_ae_header_id(i)
3497 and xah.ledger_id = xla_ae_journal_entry_pkg.g_array_ledger_id(i)
3498 and xah.event_id = xla_ae_journal_entry_pkg.g_array_event_id(i)
3499 and xah.balance_type_code = xla_ae_journal_entry_pkg.g_array_balance_type(i)
3500 )
3501 WHERE xal.ae_header_id = xla_ae_journal_entry_pkg.g_array_event_id(i)
3502 and xal.ledger_id = xla_ae_journal_entry_pkg.g_array_ledger_id(i)
3503 and xal.event_id = xla_ae_journal_entry_pkg.g_array_event_id(i)
3504 and xal.balance_type_code = xla_ae_journal_entry_pkg.g_array_balance_type(i);
3505
3506
3507
3508 l_count := SQL%ROWCOUNT;
3509
3510 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3511 trace
3512 (p_msg => '# rows updated in xla_ae_lines_gt(date_adjust) =' || l_count
3513 ,p_level => C_LEVEL_STATEMENT
3517
3514 ,p_module => l_log_module);
3515 END IF;
3516
3518 --END IF; bug9781991
3519
3520
3521
3522 END IF;
3523
3524
3525
3526 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3527 trace
3528 (p_msg => 'END of ValidateBusinessDate'
3529 ,p_level => C_LEVEL_PROCEDURE
3530 ,p_module => l_log_module);
3531 END IF;
3532
3533 EXCEPTION
3534 WHEN xla_exceptions_pkg.application_exception THEN
3535 RAISE;
3536 WHEN OTHERS THEN
3537 xla_exceptions_pkg.raise_message
3538 (p_location => 'xla_ae_header_pkg.ValidateBusinessDate');
3539 END ValidateBusinessDate;
3540
3541 --=============================================================================
3542 --
3543 --
3544 --
3545 --
3546 --
3547 --
3548 --
3549 --
3550 --
3551 --
3552 --
3553 --
3554 --
3555 --
3556 --
3557 --
3558 --
3559 --
3560 --
3561 --
3562 --
3563 --
3564 --=============================================================================
3565 --=============================================================================
3566 -- *********** Initialization routine **********
3567 --=============================================================================
3568
3569 BEGIN
3570
3571 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
3572 g_log_enabled := fnd_log.test
3573 (log_level => g_log_level
3574 ,module => C_DEFAULT_MODULE);
3575
3576 IF NOT g_log_enabled THEN
3577 g_log_level := C_LEVEL_LOG_DISABLED;
3578 END IF;
3579
3580 END xla_ae_header_pkg; --