[Home] [Help]
PACKAGE BODY: APPS.XLA_ACCOUNTING_PKG
Source
1 PACKAGE BODY XLA_ACCOUNTING_PKG AS
2 /* $Header: xlaapeng.pkb 120.187.12020000.3 2012/08/09 08:35:18 sragadde ship $ */
3 /*===========================================================================+
4 | Copyright (c) 2001-2002 Oracle Corporation |
5 | Redwood Shores, CA, USA |
6 | ALL rights reserved. |
7 +============================================================================+
8 | PACKAGE NAME |
9 | xla_accounting_pkg |
10 | |
11 | DESCRIPTION |
12 | Package body for the Accounting Program. |
13 | |
14 | HISTORY |
15 | 11/08/2002 S. Singhania Created |
16 | 02/07/2003 S. Singhania Made changes TO improve performance using|
17 | BULK architecture. |
18 | 05/21/2003 S. Singhania Fix FOR bug # 2970204. |
19 | 06/11/2003 S. Singhania Added calls TO: |
20 | -XLA_TRANSFER_PKG.GL_TRANSFER_MAIN |
21 | -XLA_BALANCE_PKG.MASSIVE_UPDATE FOR |
22 | UPDATE OF balance |
23 | -post_commit_procedure bug #2957496 |
24 | 06/16/2003 S. Singhania Added code TO LOCK entities BEFORE |
25 | updating EVENTS TABLE. PROCEDURE |
26 | modified : BATCH_ACCOUNTING |
27 | Modified THE CURSOR TO REF CURSOR IN |
28 | ENQUEUE_MESSAGES. included filters |
29 | based ON xla_events. |
30 | 06/17/2003 S. Singhania Changed THE NAME OF THE VIEW used |
31 | XLA_EVENT_ENTITIES_V TO |
32 | XLA_ENTITY_EVENTS_V |
33 | 06/26/2003 S. Singhania Bug fix FOR bug # 3022532. (TABLE NAME |
34 | changes.) |
35 | 07/05/2003 S. Singhania Modified code 'spawn child' TO make sure |
36 | children are NOT spawned IF there are |
37 | NO EVENTS TO process. |
38 | 07/17/2003 S. Singhania Fix FOR Bug # 3051978. THE STATEMENT FOR |
39 | UPDATE OF EVENTS IN 'complete_entries' |
40 | IS modified. |
41 | 07/22/2003 S. Singhania Removed THE USE OF CHR FROM THE code |
42 | 07/29/2003 S. Singhania NAME CHANGE FOR objects used IN THE queue|
43 | Removed THE code that does PAD |
44 | incompatibility CHECK. |
45 | Added code TO INSERT program LEVEL errors|
46 | INTO xla_accounting_errors. |
47 | Commented OUT code IN xla_accounting_log |
48 | routine. |
49 | Added THE funtion IS_PARENT_RUNNING |
50 | 07/30/2003 S. Singhania Modified ACCOUNTING_PROGRAM_BATCH, |
51 | UNIT_PROCESSOR_BATCH TO RETURN THE |
52 | p_retcode = 1 IN CASE OF EVENTS IN |
53 | error (bug # 2709397) |
54 | 07/31/2003 S. Singhania Added anonymous BLOCK around EXECUTE |
55 | IMMEDIATE calls. |
56 | 08/05/2003 S. Singhania Added parameter P_ACCOUNTING_FLAG TO |
57 | ACCOUNTING_PROGRAM_DOCUMENT |
58 | Document MODE routines are rewritten. |
59 | Added code IN UNIT_PROCESSOR TO CHECK THE|
60 | error count AND EXIT OUT OF THE LOOP |
61 | AND STOP processing. |
62 | 08/06/2003 S. Singhania Correct PARAMETERS are passed TO THE |
63 | calls TO THE 'pre-processing procedure,|
64 | 'post-processing procedure' AND 'post- |
65 | COMMIT PROCEDURE'. |
66 | 09/09/2003 S. Singhania TO SET error SOURCE, changed THE CALL TO |
67 | XLA_ACCOUNTING_ERR_PKG.SET_ERROR_SOURCE|
68 | 09/17/2003 S. Singhania Performance changes (bug # 3118344) |
69 | - Modified ACCOUNTING_PROGRAM_BATCH TO |
70 | build WHERE condition FOR dynamic SQL|
71 | based ON security PARAMETERS AND |
72 | process CATEGORY code |
73 | - Modified BATCH_ACCOUNTING TO WRITE |
74 | dynamic SQL TO prevent NVL. |
75 | - Modified cursors IN ENQUEUE_MESSAGES |
76 | Added filter FOR MANUAL EVENTS. |
77 | 10/01/2003 S. Singhania NOTE:THIS IS BASED ON xlaapeng.pkb 116.12|
78 | 10/01/2003 S. Singhania Made SOURCE Application Changes. |
79 | (major REWRITE) |
80 | Added semicolon TO THE EXIT STATEMENT. |
81 | (Bug # 3165900) |
82 | Handle THE CASE WHEN Extract PROCEDURE IS|
83 | NOT defined FOR an application. |
84 | (Bug # 3182763) |
85 | 10/15/2003 S. Singhania Fix FOR bug # 2709397 TO SET THE correct |
86 | request status. |
87 | - FOR this defined AND used EXCEPTION |
88 | 'normal_termination' |
89 | 10/31/2003 Shishir Joshi Bug 3220355. Modified INSERT INTO THE |
90 | XLA_EVENTS_GT TABLE. |
91 | 11/18/2003 S. Singhania Bug 3220355. Modified INSERT INTO THE |
92 | XLA_EVENTS_GT TABLE. |
93 | Removed THE NOWAIT FROM THE FOR UPDATE |
94 | statements IN THE batch MODE. |
95 | (Bug # 2697222) |
96 | 11/19/2003 S. Singhania Initilaized 'g_report_request_id' IN THE |
97 | ACCOUNTING_PROGRAM_DOCUMENT so that THE|
98 | EVENTS are stamped correctly WITH THE |
99 | request_id IN THE OFFLINE MODE. |
100 | 11/24/2003 Shishir Joshi Bug 3275659. Modified INSERT INTO THE |
101 | XLA_EVENTS_GT TABLE. |
102 | 11/24/2003 S. Singhania Bug 3275659. |
103 | - Modified INSERT INTO XLA_EVENTS_GT. |
104 | - Added 'p_report_request_id' param TO |
105 | UNIT_PROCESSOR_BATCH |
106 | - Modified SPAWN_CHILD_PROCESSES TO |
107 | included THE NEW parameter WHILE |
108 | submitting XLAACCUP. |
109 | 11/24/2003 S. Singhania Bug 3239212. |
110 | - Added more IF condition TO SET OUT |
111 | variables IN ACCOUNTING_PROGRAM_BATCH|
112 | - Added two OUT PARAMETERS TO routnie |
113 | WAIT_FOR_REQUESTS |
114 | 12/19/2003 S. Singhania Added calls TO sequencing apis FOR THE |
115 | batch MODE. Bug 3000020. |
116 | - modified specs UNIT_PROCESSOR_BATCH |
117 | - added routine SEQUENCING_BATCH_INIT |
118 | - added calls TO sequencing apis IN |
119 | - POST_ACCOUNTING |
120 | - COMPLETE_ENTRIES |
121 | moved COMMIT down AFTER CALL TO THE |
122 | pre-processing PROCEDURE |
123 | 12/19/2003 S. Singhania Modified THE CURSOR's where clause in |
124 | ENQUEUE_MESSAGES. Bug 3327641 |
125 | 01/12/2004 S. Singhania Bug # 3365680. Added hint TO THE UPDATE |
126 | STATEMENT so that INDEX XLA_EVENTS_U1 |
127 | IS always used. |
128 | 01/26/2004 W. Shen Bug # 3339505. replace THE program hook |
129 | WITH workflow business event. |
130 | 02/13/2004 S. Singhania FIXED NOCOPY warnings. |
131 | 02/28/2004 S. Singhania Bug 3416534. Added FND_LOG messages. |
132 | 03/23/2004 S. Singhania Added a parameter p_module TO THE TRACE |
133 | calls AND THE PROCEDURE. |
134 | Made changes FOR handling THE accounting |
135 | OF THE gapless EVENTS. Ffg modified: |
136 | - PRE_ACCOUNTING |
137 | - DOCUMENT_PROCESSOR |
138 | 03/26/2004 S. Singhania Bug 3498491. Added CLEAR messages, WHERE |
139 | ever possible, TO make sure IF there IS|
140 | an EXCEPTION a CLEAR message IS given |
141 | IN THE log FILE. |
142 | 04/28/2004 S. Singhania Cleaned THE FILE, removed commented code|
143 | 05/05/2004 S. Singhania Made changes TO CALL THE NEW api FOR |
144 | balance UPDATE/reversal. |
145 | Verified that ALL THE workflow EVENTS are|
146 | raised IN FINAL AND DRAFT modes. |
147 | Document MODE accounting: |
148 | - Reviewed THE code path |
149 | - Verified CALL TO THE workflows EVENTS|
150 | - Verified CALL TO THE Sequencing apis |
151 | 07/15/2004 W. Shen NEW event status 'R' introduced. |
152 | 08/03/2004 S. Singhania Bug 3808349. |
153 | Modified THE code that build THE string|
154 | g_security_condition TO USE THE COLUMN |
155 | 'valuation_method' |
156 | 09/28/2004 K. Boussema Modified procedures TO cleanup Accounting |
157 | Event Extract Diagnostics data: |
158 | - delete_request_je() AND |
159 | - delete_transaction_je() |
160 | 12/08/2004 K. Boussema Renamed THE diagnostic framework TABLES: |
161 | - xla_extract_events BY xla_diag_events |
162 | - xla_extract_ledgers BY xla_diag_ledgers |
163 | - xla_extract_sources BY xla_diag_sources |
164 | 01/04/2005 S. Singhania Bug 3928357. g_total_error_Count IS SET TO|
165 | have THE right value IN document MODE |
166 | API. |
167 | Bug 3571389. Made changes TO refer TO THE |
168 | XLA_ACCTOUNTING_QTAB queue TABLE IN XLA |
169 | SCHEMA. |
170 | Made changes TO refer TO THE TYPE |
171 | XLA_QUEUE_MSG_TYPE IN APPS SCHEMA |
172 | 01/04/2005 S. Singhania Bug 4364612. WHILE loading xla_events_gt, |
173 | valuation method COLUMN IS populated. |
174 | 05/27/2005 V. Kumar Bug 4339454 Added handle_accounting_hook |
175 | procedure to replace business event by |
176 | APIS in accounting program |
177 | 01/06/2005 W. Shen Modify insert into xla_events_gt to insert|
178 | transaction_date |
179 | 06/06/2005 M. Asada Bug 4259032 Processing Unit Enhancement |
180 | 14/06/2005 V. Swapna Bug 4426342 Enabled business events for |
181 | all products |
182 | 15/06/2005 V. Swapna Bug 3071916 Made changes to call balance |
183 | calculation routine only if there are |
184 | valid entries |
185 | 06/24/2005 S. Singhania Bug 3443872. Added code to set security |
186 | context in unit_processor_batch for |
187 | child threads (XLAACCUP) |
188 | 06/30/2005 V. Kumar Bug 4459117 Added Cash Management in |
189 | handle_accounting_hooks |
190 | 07/11/2005 A. Wan Bug 4262811 MPA Project |
191 | 08/01/2005 W. Chan 4458381 - Public Sector Enhancement |
192 | 09/12/2005 V.Swapna 4599690 - Added Process Manufacturing |
193 | Financials to handle_accounting_hooks |
194 | 09/14/2005 W.Chan 4606566 - Pass budgetary_control_mode to |
195 | AP hook if calling for BC mode |
196 | 10/12/2005 A.Wan 4645092 - MPA report changes |
197 | 18-Oct-2005 V. Kumar Removed code for Analytical Criteria |
198 | 28-Oct-2005 W. Shen Third party merge, add logic to prevent |
199 | third party merge event been processed |
200 | here |
201 | 07-Nov-2005 S. Singhania Modofied event_application_manager to |
202 | print accounting, transfer time in log |
203 | 16-Nov-2005 Shishir Joshi Bug #4677032. Performance Improvement. |
204 | 17-Nov-2005 V. Kumar Bug#4736699 Added hint for performance |
205 | 23-Nov-2005 V. Kumar Bug#4752936 Added join on application_id |
206 | 30-Nov-2005 V.Swapna 4745309 - Added Payroll |
207 | to handle_accounting_hooks |
208 | 30-Nov-2005 V. Kumar Bug#4769388/4769270 Added hints |
209 | 12-Dec-2005 S. Singhania Bug 4883192. Modified the delete statement|
210 | that deletes from xla_distribution_links|
211 | 14-Dec-2005 V. Kumar Bug#4727703 Added condition to avoid unne-|
212 | -cessary execution of DELETE statements |
213 | 29-Dec-2005 V. Kumar Bug#4879954 Added hint for performance |
214 | 12-Jan-2006 V. Kumar Modified the logic to call GL transfer API|
215 | within child thread when transfer mode is |
216 | COMBINED (accounting and transfering to GL|
217 | 01-Feb-2006 V. Swapna Bug 4963736: Modified the call to |
218 | event_application_manager |
219 | 10-Feb-2006 A.Wan Bug 4670097 - budgetary control='N' |
220 | 12-Feb-2006 A.Wan 4860037 - anytime process order issue |
221 | 17-Feb-2006 V.Kumar 5034929 - Modified Cursor csr_event_class |
222 | 23-Feb-2006 V.Kumar 5056659 - Changed date mask to HH24:MI:SS |
223 | 02-Mar-2006 V. Swapna Bug 5018098: Added an exception to handle |
224 | no data found error in batch_accounting |
225 | 19-Apr-2006 A.Wan Bug 5149363 - performance fix |
226 | 20-Apr-2006 A.Wan Bug 5054831 - duplicate entires |
227 | 11-May-2006 A.Wan Bug 5221578 - log message is too long |
228 | 08/31/2006 V. Swapna Bug: 5257343. Add a new parameter to |
229 | unit_processor_batch, also, add this in |
230 | the call to submit the child program. |
231 | 14-Sep-2006 A.Wan Bug 5531502 - AAD_dbase_invalid need to |
232 | check if it is called in BC mode. If so |
233 | then validate for _BC_PKG, else _PKG. |
234 | 13-Oct-2009 VGOPISET bug:8423174 UNIT_PROCESSOR cursor changed |
235 | to exclude budgetary events |
236 | 13-JUN-2012 VKANTETI bug:14105024 To eliminate the duplicates |
237 | while building event classes list |
238 | 17-JUL-2012 NMIKKILI Bug 14307411 Codefix to support new |
239 | costing security function |
240 +===========================================================================*/
241
242 --=============================================================================
243 -- **************** declarations ********************
244 --=============================================================================
245 -------------------------------------------------------------------------------
246 -- declaring private constants and structures
247 -------------------------------------------------------------------------------
248 C_QUEUE_TABLE CONSTANT VARCHAR2(30) := 'xla_accounting_qtab';
249 C_CHAR CONSTANT VARCHAR2(30) := '##UNDEFINED##'; -- CHR(12);
250 C_NUM CONSTANT NUMBER := 9.99E125;
251
252 C_BATCH_PROGRAM CONSTANT VARCHAR2(80) := 'Batch Accounting Program';
253 C_UNIT_PROCESSOR CONSTANT VARCHAR2(80) := 'Unit Processor';
254 C_MANUAL CONSTANT VARCHAR2(30) := 'MANUAL';
255
256 ------------------------------------------------------------------------
257 -- 4597150 Process Event
258 ------------------------------------------------------------------------
259 C_DELIMITER CONSTANT VARCHAR2(30) := '#-#-#-#-#-#-#-#';
260 C_COMMA CONSTANT VARCHAR2(30) := ''',''';
261 C_QUOTE CONSTANT VARCHAR2(30) := '''';
262
263 -- 8423174 added join on BUDGETARY CONTROL FLAG to exclude Budgetary Events
264 C_LOCK_EVENTS_STR CONSTANT VARCHAR2(32000) :=
265 '
266 SELECT /*+ leading(tab,evt) use_nl(evt) */
267 evt.event_id
268 FROM xla_events evt
269 ,xla_event_types_b xet
270 ,TABLE(CAST(:1 AS xla_array_number_type)) tab
271 WHERE evt.application_id = :2
272 AND evt.event_date <= :3
273 AND evt.entity_id = tab.column_value
274 AND evt.application_id = xet.application_id
275 AND evt.event_type_code = xet.event_type_code
276 AND xet.event_class_code IN ($event_classes$)
277 AND evt.event_type_code NOT IN (''FULL_MERGE'', ''PARTIAL_MERGE'')
278 AND evt.process_status_code IN (''U'',''D'',''E'',''R'',''I'')
279 AND evt.event_status_code IN (''U'', DECODE(:4, ''F'',''N'',''U''))
280 AND nvl(evt.budgetary_control_flag, ''N'') = ''N'' -- bug:8423174
281 FOR UPDATE OF evt.event_id skip locked
282 ';
283
284 -- 8423174 added join on BUDGETARY CONTROL FLAG to exclude Budgetary Events
285 C_CURR_INS_EVENTS CONSTANT VARCHAR2(32000) := '
286 INSERT INTO xla_events_gt
287 (entity_id
288 ,application_id
289 ,ledger_id
290 ,legal_entity_id
291 ,entity_code
292 ,transaction_number
293 ,source_id_int_1
294 ,source_id_int_2
295 ,source_id_int_3
296 ,source_id_int_4
297 ,source_id_char_1
298 ,source_id_char_2
299 ,source_id_char_3
300 ,source_id_char_4
301 ,event_id
302 ,event_class_code
303 ,event_type_code
304 ,event_number
305 ,event_date
306 ,transaction_date
307 ,event_status_code
308 ,process_status_code
309 ,valuation_method
310 ,budgetary_control_flag
311 ,reference_num_1
312 ,reference_num_2
313 ,reference_num_3
314 ,reference_num_4
315 ,reference_char_1
316 ,reference_char_2
317 ,reference_char_3
318 ,reference_char_4
319 ,reference_date_1
320 ,reference_date_2
321 ,reference_date_3
322 ,reference_date_4)
323 SELECT /*+ LEADING(EVT,XET,ENT,ECA) USE_NL(EVT,XET,ENT,ECA) */
324 evt.entity_id
325 ,evt.application_id
326 ,ent.ledger_id
327 ,ent.legal_entity_id
328 ,ent.entity_code
329 ,ent.transaction_number
330 ,ent.source_id_int_1
331 ,ent.source_id_int_2
332 ,ent.source_id_int_3
333 ,ent.source_id_int_4
334 ,ent.source_id_char_1
335 ,ent.source_id_char_2
336 ,ent.source_id_char_3
337 ,ent.source_id_char_4
338 ,evt.event_id
339 ,xet.event_class_code
340 ,evt.event_type_code
341 ,evt.event_number
342 ,evt.event_date
343 ,evt.transaction_date
344 ,evt.event_status_code
345 ,evt.process_status_code
346 ,ent.valuation_method
347 ,NVL(evt.budgetary_control_flag,''N'')
348 ,evt.reference_num_1
349 ,evt.reference_num_2
350 ,evt.reference_num_3
351 ,evt.reference_num_4
352 ,evt.reference_char_1
353 ,evt.reference_char_2
354 ,evt.reference_char_3
355 ,evt.reference_char_4
356 ,evt.reference_date_1
357 ,evt.reference_date_2
358 ,evt.reference_date_3
359 ,evt.reference_date_4
360 FROM xla_events evt
361 ,xla_transaction_entities ent
362 ,xla_event_types_b xet
363 ,xla_event_class_attrs eca
364 WHERE evt.application_id = :1
365 AND evt.event_date <= :2
366 AND evt.event_id = :3
367 AND evt.application_id = ent.application_id
368 AND evt.entity_id = ent.entity_id
369 AND evt.application_id = xet.application_id
370 AND evt.event_type_code = xet.event_type_code
371 AND eca.application_id = xet.application_id
372 AND eca.entity_code = xet.entity_code
373 AND eca.event_class_code = xet.event_class_code
374 AND xet.event_class_code IN ($event_classes$)
375 AND evt.event_type_code NOT IN (''FULL_MERGE'', ''PARTIAL_MERGE'')
376 AND evt.process_status_code IN (''U'',''D'',''E'',''R'',''I'')
377 AND evt.event_status_code IN
378 (''U'', DECODE(:4, ''F'',''N'',''U''))
379 AND nvl(evt.budgetary_control_flag, ''N'') = ''N'' -- bug:8423174
380 ';
381
382 --
383 -- Unprocessed Event Number of Process Order -1 must be lower than
384 -- those of all Process Order higher than the current Process Order.
385 --
386 -- 8423174 added join on BUDGETARY CONTROL FLAG to exclude Budgetary Events
387 C_ANYTIME_INS_EVENTS CONSTANT VARCHAR2(32000) := '
388 INSERT INTO xla_events_gt
389 (entity_id
390 ,application_id
391 ,ledger_id
392 ,legal_entity_id
393 ,entity_code
394 ,transaction_number
395 ,source_id_int_1
396 ,source_id_int_2
397 ,source_id_int_3
398 ,source_id_int_4
399 ,source_id_char_1
400 ,source_id_char_2
401 ,source_id_char_3
402 ,source_id_char_4
403 ,event_id
404 ,event_class_code
405 ,event_type_code
406 ,event_number
407 ,event_date
408 ,transaction_date
409 ,event_status_code
410 ,process_status_code
411 ,valuation_method
412 ,budgetary_control_flag
413 ,reference_num_1
414 ,reference_num_2
415 ,reference_num_3
416 ,reference_num_4
417 ,reference_char_1
418 ,reference_char_2
419 ,reference_char_3
420 ,reference_char_4
421 ,reference_date_1
422 ,reference_date_2
423 ,reference_date_3
424 ,reference_date_4)
425 SELECT /*+ LEADING(EVT,XET,ENT,ECA) USE_NL(EVT,XET,ENT,ECA) */
426 evt.entity_id
427 ,evt.application_id
428 ,ent.ledger_id
429 ,ent.legal_entity_id
430 ,ent.entity_code
431 ,ent.transaction_number
432 ,ent.source_id_int_1
433 ,ent.source_id_int_2
434 ,ent.source_id_int_3
435 ,ent.source_id_int_4
436 ,ent.source_id_char_1
437 ,ent.source_id_char_2
438 ,ent.source_id_char_3
439 ,ent.source_id_char_4
440 ,evt.event_id
441 ,xet.event_class_code
442 ,evt.event_type_code
443 ,evt.event_number
444 ,evt.event_date
445 ,evt.transaction_date
446 ,evt.event_status_code
447 ,evt.process_status_code
448 ,ent.valuation_method
449 ,NVL(evt.budgetary_control_flag,''N'')
450 ,evt.reference_num_1
451 ,evt.reference_num_2
452 ,evt.reference_num_3
453 ,evt.reference_num_4
454 ,evt.reference_char_1
455 ,evt.reference_char_2
456 ,evt.reference_char_3
457 ,evt.reference_char_4
458 ,evt.reference_date_1
459 ,evt.reference_date_2
460 ,evt.reference_date_3
461 ,evt.reference_date_4
462 FROM xla_events evt
463 ,xla_transaction_entities ent
464 ,xla_event_types_b xet
465 ,xla_event_class_attrs eca
466 WHERE evt.application_id = :1
467 AND evt.event_date <= :2
468 AND evt.event_id = :3
469 AND evt.application_id = ent.application_id
470 AND evt.entity_id = ent.entity_id
471 AND evt.application_id = xet.application_id
472 AND evt.event_type_code = xet.event_type_code
473 AND eca.application_id = xet.application_id
474 AND eca.entity_code = xet.entity_code
475 AND eca.event_class_code = xet.event_class_code
476 AND xet.event_class_code IN ($event_classes$)
477 AND evt.event_type_code NOT IN (''FULL_MERGE'', ''PARTIAL_MERGE'')
478 AND evt.process_status_code IN (''U'',''D'',''E'',''R'',''I'')
479 AND nvl(evt.budgetary_control_flag, ''N'') = ''N'' -- bug:8423174
480 AND evt.event_status_code IN
481 (''U'', DECODE(:4, ''F'',''N'',''U''))
482 AND evt.event_number <
483 (SELECT NVL(MIN(evt2.event_number), evt.event_number + 1)
484 FROM xla_events evt2
485 ,xla_transaction_entities_upg ent2
486 ,xla_event_types_b xet2
487 ,xla_event_class_attrs eca2
488 WHERE evt2.application_id = evt.application_id
489 AND evt2.entity_id = evt.entity_id
490 AND evt2.event_date = :5
491 AND evt2.application_id = ent2.application_id
492 AND evt2.entity_id = ent2.entity_id
493 AND evt2.application_id = xet2.application_id
494 AND evt2.event_type_code = xet2.event_type_code
495 AND eca2.application_id = xet2.application_id
496 AND eca2.entity_code = xet2.entity_code
497 AND eca2.event_class_code = xet2.event_class_code
498 AND xet2.event_class_code NOT IN ($event_class_current_order$)
499 AND xet2.event_class_code NOT IN ($event_class_anytime_order$)
500 AND evt2.event_type_code NOT IN (''FULL_MERGE'', ''PARTIAL_MERGE'')
501 AND evt2.process_status_code IN (''U'',''D'',''E'',''R'',''I'')
502 AND evt2.event_status_code IN
503 (''U'', DECODE(:6, ''F'',''N'',''U''))
504 )
505 ';
506 ------------------------------------------------------------------------
507
508
509 TYPE r_parent_data IS RECORD
510 (total_entity_count NUMBER
511 ,enqueued_msg_count NUMBER);
512
513 TYPE r_child_data IS RECORD
514 (selected_entity_count NUMBER
515 ,dequeued_msg_count NUMBER
516 ,selected_event_count NUMBER);
517
518 TYPE t_array_char_code IS TABLE OF VARCHAR2(1) INDEX BY BINARY_INTEGER;
519 TYPE t_array_char IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
520 TYPE t_array_char_ext IS TABLE OF VARCHAR2(240) INDEX BY BINARY_INTEGER;
521 TYPE t_array_date IS TABLE OF DATE INDEX BY BINARY_INTEGER;
522 TYPE t_array_integer IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;
523
524 -------------------------------------------------------------------------------
525 -- declaring named exceptions
526 -------------------------------------------------------------------------------
527 normal_termination EXCEPTION;
528 resource_busy EXCEPTION;
529 PRAGMA EXCEPTION_INIT(resource_busy, -54);
530
531 -------------------------------------------------------------------------------
532 -- declaring private variables
533 -------------------------------------------------------------------------------
534 g_accounting_batch_id PLS_INTEGER;
535 g_queue_table_name VARCHAR2(80);
536 g_xla_schema_name VARCHAR2(30);
537 g_queue_name VARCHAR2(30);
538 g_comp_queue_name VARCHAR2(30);
539 g_ledger_ids xla_accounting_pkg.t_array_number;
540 g_process_count PLS_INTEGER;
541 g_ep_request_ids xla_accounting_pkg.t_array_number;
542 g_ep_reqid PLS_INTEGER;
543 g_unit_size PLS_INTEGER;
544 g_error_limit PLS_INTEGER;
545 g_seq_enabled_flag VARCHAR2(1);
546 g_global_context VARCHAR2(30);
547 g_conc_hold VARCHAR2(1);
548
549 g_current_entity_id NUMBER; -- 8761772
550 g_failed_event_id NUMBER; -- 8761772
551 g_processing_mode VARCHAR2(30);
552 g_execution_mode VARCHAR2(10);
553 g_budgetary_control_mode VARCHAR2(30); -- 4458381
554
555 g_total_error_count NUMBER := 0; -- This is used by parent thread to set request status
556 g_parent_data r_parent_data;
557 g_child_data r_child_data;
558
559 -- Bug 8282549
560 g_queue_created_flag VARCHAR2(1) :='N';
561 g_queue_started_flag VARCHAR2(1) :='N';
562
563
564 -------------------------------------------------------------------------------
565 -- forward declarion of private procedures and functions
566 -------------------------------------------------------------------------------
567 --PROCEDURE accounting_manager_batch;
568
569 PROCEDURE batch_accounting;
570
571 PROCEDURE enqueue_messages
572 (p_processing_order INTEGER
573 ,p_max_processing_order INTEGER
574 ,p_children_spawned IN OUT NOCOPY BOOLEAN
575 ,p_msg_count IN OUT NOCOPY INTEGER);
576
577 PROCEDURE process_events;
578
579 -- 5054831
580 FUNCTION AAD_dbase_invalid(p_pad_name IN VARCHAR2,p_ledger_category_code IN VARCHAR2,p_enable_bc_flag IN VARCHAR2) return BOOLEAN;
581 PROCEDURE ValidateAAD(p_array_event_dates IN t_array_date);
582
583 PROCEDURE ValidateAAD
584 (p_max_event_date IN DATE);
585
586
587 PROCEDURE unit_processor;
588
589 PROCEDURE complete_entries;
590
591 PROCEDURE wait_for_requests
592 (p_array_request_id IN t_array_number
593 ,p_error_status OUT NOCOPY VARCHAR2
594 ,p_warning_status OUT NOCOPY VARCHAR2);
595
596 --FSAH-PSFT FP
597 PROCEDURE wait_for_combo_edit_req
598 (p_request_id IN NUMBER
599 ,p_error_status OUT NOCOPY VARCHAR2
600 ,p_warning_status OUT NOCOPY VARCHAR2);
601
602
603 FUNCTION is_any_child_running
604 RETURN BOOLEAN;
605
606 FUNCTION is_parent_running
607 RETURN BOOLEAN;
608
609 PROCEDURE events_processor(l_processing_order IN NUMBER); -- bug 7193986
610
611 PROCEDURE delete_batch_je;
612
613 PROCEDURE delete_request_je;
614
615 /*
616 PROCEDURE document_processor
617 (p_entity_id IN NUMBER);
618
619 PROCEDURE delete_transaction_je
620 (p_entity_id IN NUMBER);
621 */
622
623 PROCEDURE spawn_child_processes;
624
625 PROCEDURE pre_accounting;
626
627 PROCEDURE post_accounting
628 (p_queue_started_flag IN OUT NOCOPY VARCHAR2
629 ,p_queue_created_flag IN OUT NOCOPY VARCHAR2
630 ,p_seq_api_called_flag IN OUT NOCOPY VARCHAR2);
631
632 PROCEDURE event_application_manager
633 (p_source_application_id IN NUMBER
634 ,p_application_id IN NUMBER
635 ,p_ledger_id IN NUMBER
636 ,p_process_category IN VARCHAR2
637 ,p_end_date IN DATE
638 ,p_accounting_flag IN VARCHAR2
639 ,p_accounting_mode IN VARCHAR2
640 ,p_error_only_flag IN VARCHAR2
641 ,p_transfer_flag IN VARCHAR2
642 ,p_gl_posting_flag IN VARCHAR2
643 ,p_gl_batch_name IN VARCHAR2
644 ,p_valuation_method IN VARCHAR2
645 ,p_security_id_int_1 IN NUMBER
646 ,p_security_id_int_2 IN NUMBER
647 ,p_security_id_int_3 IN NUMBER
648 ,p_security_id_char_1 IN VARCHAR2
649 ,p_security_id_char_2 IN VARCHAR2
650 ,p_security_id_char_3 IN VARCHAR2);
651
652 PROCEDURE sequencing_batch_init
653 (p_seq_enabled_flag IN OUT NOCOPY VARCHAR2);
654
655 PROCEDURE raise_accounting_event
656 (p_application_id IN NUMBER
657 ,p_ledger_id IN NUMBER
658 ,p_process_category IN VARCHAR2
659 ,p_end_date IN DATE
660 ,p_accounting_mode IN VARCHAR2
661 ,p_valuation_method IN VARCHAR2
662 ,p_security_id_int_1 IN NUMBER
663 ,p_security_id_int_2 IN NUMBER
664 ,p_security_id_int_3 IN NUMBER
665 ,p_security_id_char_1 IN VARCHAR2
666 ,p_security_id_char_2 IN VARCHAR2
667 ,p_security_id_char_3 IN VARCHAR2
668 ,p_report_request_id IN NUMBER
669 ,p_event_name IN VARCHAR2
670 ,p_event_key IN VARCHAR2);
671
672 PROCEDURE raise_unit_event
673 (p_application_id IN NUMBER
674 ,p_accounting_mode IN VARCHAR2
675 ,p_event_name IN VARCHAR2
676 ,p_event_key IN VARCHAR2);
677
678 PROCEDURE handle_accounting_hook
679 (p_application_id IN NUMBER
680 ,p_ledger_id IN NUMBER
681 ,p_process_category IN VARCHAR2
682 ,p_end_date IN DATE
683 ,p_accounting_mode IN VARCHAR2
684 ,p_budgetary_control_mode IN VARCHAR2
685 ,p_valuation_method IN VARCHAR2
686 ,p_security_id_int_1 IN NUMBER
687 ,p_security_id_int_2 IN NUMBER
688 ,p_security_id_int_3 IN NUMBER
689 ,p_security_id_char_1 IN VARCHAR2
690 ,p_security_id_char_2 IN VARCHAR2
691 ,p_security_id_char_3 IN VARCHAR2
692 ,p_report_request_id IN NUMBER
693 ,p_event_name IN VARCHAR2
694 ,p_event_key IN VARCHAR2);
695
696 FUNCTION concat_event_classes
697 (p_processing_order IN NUMBER)
698 RETURN VARCHAR2;
699
700 --=============================================================================
701 -- *********** Local Trace Routine **********
702 --=============================================================================
703 C_LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
704 C_LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
705 C_LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
706 C_LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
707 C_LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
708 C_LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
709
710 C_LEVEL_LOG_DISABLED CONSTANT NUMBER := 99;
711 C_DEFAULT_MODULE CONSTANT VARCHAR2(240) := 'xla.plsql.xla_accounting_pkg';
712
713 g_log_level NUMBER;
714 g_log_enabled BOOLEAN;
715
716 C_LOG_SIZE CONSTANT NUMBER := 2000; -- 5221578 actual size is 4000, but maybe too long to be readable
717
718 PROCEDURE trace
719 (p_msg IN VARCHAR2
720 ,p_level IN NUMBER
721 ,p_module IN VARCHAR2 DEFAULT C_DEFAULT_MODULE) IS
722
723 l_max NUMBER;
724 l_pos NUMBER := 1;
725
726 BEGIN
727
728 l_pos := 1;
729
730 IF (p_msg IS NULL AND p_level >= g_log_level) THEN
731 fnd_log.message(p_level, p_module);
732 ELSIF p_level >= g_log_level THEN
733
734 l_max := length(p_msg);
735 IF l_max <= C_LOG_SIZE THEN
736 fnd_log.string(p_level, p_module, p_msg);
737 ELSE
738 -- 5221578 log messages in C_LOG_SIZE
739 WHILE (l_pos-1)*C_LOG_SIZE <= l_max LOOP
740 fnd_log.string(p_level, p_module, substr(p_msg, (l_pos-1)*C_LOG_SIZE+1, C_LOG_SIZE));
741 l_pos := l_pos+1;
742 END LOOP;
743 END IF;
744 END IF;
745
746 EXCEPTION
747 WHEN xla_exceptions_pkg.application_exception THEN
748 RAISE;
749 WHEN OTHERS THEN
750 xla_exceptions_pkg.raise_message
751 (p_location => 'xla_accounting_pkg.trace');
752 END trace;
753
754 --=============================================================================
755 -- ******* Print Log File **********
756 --=============================================================================
757 PROCEDURE print_logfile(p_msg IN VARCHAR2) IS
758 BEGIN
759
760 fnd_file.put_line(fnd_file.log,p_msg);
761
762 EXCEPTION
763 WHEN xla_exceptions_pkg.application_exception THEN
764 RAISE;
765 WHEN OTHERS THEN
766 xla_exceptions_pkg.raise_message
767 (p_location => 'xla_accounting_pkg.print_logfile');
768 END print_logfile;
769
770
771 --=============================================================================
772 -- *********** public procedures and functions **********
773 --=============================================================================
774 --=============================================================================
775 --
776 --
777 --
778 --
779 --
780 --
781 --
782 --
783 --
784 --
785 -- Following routines are used while accounting for a batch of documents
786 --
787 -- 1. accounting_program_batch (procedure)
788 -- 2. event_application_cp (conc executible procedure)
789 -- 3. event_application_manager
790 -- 4. unit_processor_batch (conc executible procedure)
791 --
792 --
793 --
794 --
795 --
796 --
797 --
798 --
799 --
800 --
801 --
802 --=============================================================================
803
804 --=============================================================================
805 --
806 --
807 --
808 --=============================================================================
809 PROCEDURE accounting_program_batch
810 (p_source_application_id IN NUMBER
811 ,p_application_id IN NUMBER
812 ,p_ledger_id IN NUMBER
813 ,p_process_category IN VARCHAR2
814 ,p_end_date IN DATE
815 ,p_accounting_flag IN VARCHAR2
816 ,p_accounting_mode IN VARCHAR2
817 ,p_error_only_flag IN VARCHAR2
818 ,p_transfer_flag IN VARCHAR2
819 ,p_gl_posting_flag IN VARCHAR2
820 ,p_gl_batch_name IN VARCHAR2
821 ,p_valuation_method IN VARCHAR2
822 ,p_security_id_int_1 IN NUMBER
823 ,p_security_id_int_2 IN NUMBER
824 ,p_security_id_int_3 IN NUMBER
825 ,p_security_id_char_1 IN VARCHAR2
826 ,p_security_id_char_2 IN VARCHAR2
827 ,p_security_id_char_3 IN VARCHAR2
828 ,p_accounting_batch_id OUT NOCOPY NUMBER
829 ,p_errbuf OUT NOCOPY VARCHAR2
830 ,p_retcode OUT NOCOPY NUMBER) IS
831 l_array_event_appl_id xla_number_array_type;
832 l_array_request_id t_array_number;
833 l_array_mpa_request_id t_array_number;
834 l_mpa_request_id NUMBER(10);
835 l_xml_output BOOLEAN;
836 l_str_event_application VARCHAR2(2000);
837 l_error_status VARCHAR2(1) := 'N';
838 l_warning_status VARCHAR2(1) := 'N';
839 l_log_module VARCHAR2(240);
840 l_xla_val_ccid_req_id NUMBER(10); -- FSAH-PSFT FP
841 l_iso_language FND_LANGUAGES.iso_language%TYPE;
842 l_iso_territory FND_LANGUAGES.iso_territory%TYPE;
843 l_code NUMBER; -- FSAH-PSFT FP
844 BEGIN
845 --
846 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Starting of the Parent Thread');
847
848 IF g_log_enabled THEN
849 l_log_module := C_DEFAULT_MODULE||'.accounting_program_batch';
850 END IF;
851 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
852 trace
853 (p_msg => 'BEGIN of procedure ACCOUNTING_PROGRAM_BATCH'
854 ,p_level => C_LEVEL_PROCEDURE
855 ,p_module => l_log_module);
856 trace
857 (p_msg => 'p_source_application_id = '||to_char(p_source_application_id)
858 ,p_level => C_LEVEL_PROCEDURE
859 ,p_module => l_log_module);
860 trace
861 (p_msg => 'p_application_id = '||to_char(p_application_id)
862 ,p_level => C_LEVEL_PROCEDURE
863 ,p_module => l_log_module);
864 trace
865 (p_msg => 'p_ledger_id = '||p_ledger_id
866 ,p_level => C_LEVEL_PROCEDURE
867 ,p_module => l_log_module);
868 trace
869 (p_msg => 'p_process_category = '||p_process_category
870 ,p_level => C_LEVEL_PROCEDURE
871 ,p_module => l_log_module);
872 trace
873 (p_msg => 'p_end_date = '||to_char(p_end_date,'DD-MON-YYYY')
874 ,p_level => C_LEVEL_PROCEDURE
875 ,p_module => l_log_module);
876 trace
877 (p_msg => 'p_accounting_flag = '||p_accounting_flag
878 ,p_level => C_LEVEL_PROCEDURE
879 ,p_module => l_log_module);
880 trace
881 (p_msg => 'p_accounting_mode = '||p_accounting_mode
882 ,p_level => C_LEVEL_PROCEDURE
883 ,p_module => l_log_module);
884 trace
885 (p_msg => 'p_error_only_flag = '||p_error_only_flag
886 ,p_level => C_LEVEL_PROCEDURE
887 ,p_module => l_log_module);
888 trace
889 (p_msg => 'p_transfer_flag = '||p_transfer_flag
890 ,p_level => C_LEVEL_PROCEDURE
891 ,p_module => l_log_module);
892 trace
893 (p_msg => 'p_gl_posting_flag = '||p_gl_posting_flag
894 ,p_level => C_LEVEL_PROCEDURE
895 ,p_module => l_log_module);
896 trace
897 (p_msg => 'p_gl_batch_name = '||p_gl_batch_name
898 ,p_level => C_LEVEL_PROCEDURE
899 ,p_module => l_log_module);
900 trace
901 (p_msg => 'p_valuation_method = '||p_valuation_method
902 ,p_level => C_LEVEL_PROCEDURE
903 ,p_module => l_log_module);
904 trace
905 (p_msg => 'p_security_id_int_1 = '||p_security_id_int_1
906 ,p_level => C_LEVEL_PROCEDURE
907 ,p_module => l_log_module);
908 trace
909 (p_msg => 'p_security_id_int_1 = '||p_security_id_int_1
910 ,p_level => C_LEVEL_PROCEDURE
911 ,p_module => l_log_module);
912 trace
913 (p_msg => 'p_security_id_int_3 = '||p_security_id_int_3
914 ,p_level => C_LEVEL_PROCEDURE
915 ,p_module => l_log_module);
916 trace
917 (p_msg => 'p_security_id_char_1 = '||p_security_id_char_1
918 ,p_level => C_LEVEL_PROCEDURE
919 ,p_module => l_log_module);
920 trace
921 (p_msg => 'p_security_id_char_2 = '||p_security_id_char_2
922 ,p_level => C_LEVEL_PROCEDURE
923 ,p_module => l_log_module);
924 trace
925 (p_msg => 'p_security_id_char_3 = '||p_security_id_char_3
926 ,p_level => C_LEVEL_PROCEDURE
927 ,p_module => l_log_module);
928 END IF;
929
930
931 print_logfile('Starting main program for the source application = '||p_source_application_id);
932
933 g_report_request_id := fnd_global.conc_request_id();
934
935 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
936 trace
937 (p_msg => 'g_report_request_id = '||g_report_request_id
938 ,p_level => C_LEVEL_STATEMENT
939 ,p_module => l_log_module);
940 END IF;
941
942 ----------------------------------------------------------------------------
943 -- Making sure at leat source application or event application is passed
944 -- This condition should never arise, as it should be validated in the
945 -- request parameters.
946 ----------------------------------------------------------------------------
947 IF ((p_source_application_id IS NULL) AND (p_application_id IS NULL)) THEN
948 xla_exceptions_pkg.raise_message
949 (p_appli_s_name => 'XLA'
950 ,p_msg_name => 'XLA_COMMON_ERROR'
951 ,p_token_1 => 'LOCATION'
952 ,p_value_1 => 'xla_accounting_pkg.accounting_program_batch'
953 ,p_token_2 => 'ERROR'
954 ,p_value_2 => 'Source application and event application both cannot be NULL');
955 END IF;
956
957 ----------------------------------------------------------------------------
958 -- Fetching Accounting Batch Id
959 ----------------------------------------------------------------------------
960 SELECT xla_accounting_batches_s.NEXTVAL INTO g_accounting_batch_id FROM DUAL;
961
962 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
963 trace
964 (p_msg => 'g_accounting_batch_id = '||g_accounting_batch_id
965 ,p_level => C_LEVEL_STATEMENT
966 ,p_module => l_log_module);
967 END IF;
968
969 ----------------------------------------------------------------------------
970 -- Initializing errors package
971 ----------------------------------------------------------------------------
972 xla_accounting_err_pkg.set_options
973 (p_error_source => xla_accounting_err_pkg.C_ACCT_PROGRAM
974 ,p_request_id => g_report_request_id
975 ,p_application_id => p_application_id);
976
977 ----------------------------------------------------------------------------
978 -- Building filter condition based on security columns and valuation method
979 -- This condition will be added dynamically to select statemtents.
980 ----------------------------------------------------------------------------
981 SELECT
982 DECODE(p_valuation_method,NULL,NULL,'and valuation_method = '''||p_valuation_method||''' ')||
983 --DECODE(p_security_id_int_1,NULL,NULL,'and security_id_int_1 = '||p_security_id_int_1||' ')|| --14307411
984 DECODE(p_security_id_int_1,NULL,NULL
985 ,DECODE(p_application_id,707, 'and NVL(security_id_int_1,'||p_security_id_int_1||') = '||p_security_id_int_1||' ',
986 'and security_id_int_1 = '||p_security_id_int_1||' '))|| --14307411
987 DECODE(p_security_id_int_2,NULL,NULL,'and security_id_int_2 = '||p_security_id_int_2||' ')||
988 DECODE(p_security_id_int_3,NULL,NULL,'and security_id_int_3 = '||p_security_id_int_3||' ')||
989 DECODE(p_security_id_char_1,NULL,NULL,'and security_id_char_1 = '''||p_security_id_char_1||''' ')||
990 DECODE(p_security_id_char_2,NULL,NULL,'and security_id_char_2 = '''||p_security_id_char_2||''' ')||
991 DECODE(p_security_id_char_3,NULL,NULL,'and security_id_char_3 = '''||p_security_id_char_3||''' ')
992 INTO g_security_condition
993 FROM DUAL;
994
995 ----------------------------------------------------------------------------
996 -- Building filter condition based process_category.
997 -- This condition will be added dynamically to select statemtents.
998 ----------------------------------------------------------------------------
999 SELECT
1000 DECODE(p_process_category,NULL,NULL,'and event_class_group_code = '''||p_process_category||'''')
1001 INTO g_process_category_condition
1002 FROM DUAL;
1003
1004 ----------------------------------------------------------------------------
1005 -- Building filter condition based on source_application_id.
1006 ----------------------------------------------------------------------------
1007 SELECT
1008 DECODE(p_source_application_id,NULL,NULL,'and source_application_id = '||p_source_application_id)
1009 INTO g_source_appl_condition
1010 FROM DUAL;
1011
1012 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1013 trace
1014 (p_msg => 'g_security_condition = '||g_security_condition
1015 ,p_level => C_LEVEL_STATEMENT
1016 ,p_module => l_log_module);
1017 trace
1018 (p_msg => 'g_process_category_condition = '||g_process_category_condition
1019 ,p_level => C_LEVEL_STATEMENT
1020 ,p_module => l_log_module);
1021 trace
1022 (p_msg => 'g_source_appl_condition = '||g_source_appl_condition
1023 ,p_level => C_LEVEL_STATEMENT
1024 ,p_module => l_log_module);
1025 END IF;
1026
1027 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Dynamic conditions built');
1028
1029 ----------------------------------------------------------------------------
1030 -- Finding Event Applications.
1031 ----------------------------------------------------------------------------
1032
1033 IF p_application_id IS NOT NULL THEN
1034 l_array_event_appl_id := xla_number_array_type(p_application_id);
1035 ELSIF p_application_id IS NULL THEN
1036 l_str_event_application :=
1037 'SELECT application_id
1038 FROM xla_entity_events_v
1039 WHERE source_application_id = :2
1040 AND ledger_id = :3
1041 AND event_date <= :4
1042 AND process_status_code IN (''R'',''I'',''E'',DECODE(:5,''N'',''D'',''E'')
1043 ,DECODE(:6,''N'',''U'',''E'')
1044 )
1045 AND event_status_code IN (''U'',DECODE(:7,''F'',''N'',''U''))
1046 AND entity_code <> '''||C_MANUAL||'''
1047 AND NVL(budgetary_control_flag,''N'') = ''N'' '||
1048 g_security_condition||' '||
1049 g_process_category_condition||' '||
1050 'GROUP BY application_id';
1051
1052 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1053 trace
1054 (p_msg => 'l_str_event_application = '||l_str_event_application
1055 ,p_level => C_LEVEL_STATEMENT
1056 ,p_module => l_log_module);
1057 END IF;
1058
1059 EXECUTE IMMEDIATE l_str_event_application
1060 BULK COLLECT INTO l_array_event_appl_id
1061 USING p_source_application_id
1062 ,p_ledger_id
1063 ,p_end_Date
1064 ,p_error_only_flag
1065 ,p_error_only_flag
1066 ,p_accounting_mode;
1067 END IF;
1068
1069 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Event Applications Determined');
1070 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1071 trace
1072 (p_msg => 'Number of Event Applications = '||l_array_event_appl_id.COUNT
1073 ,p_level => C_LEVEL_STATEMENT
1074 ,p_module => l_log_module);
1075 END IF;
1076
1077 IF l_array_event_appl_id.COUNT = 0 THEN
1078 IF (C_LEVEL_EVENT >= g_log_level) THEN
1079 trace
1080 (p_msg => 'No event applications fetched for the source application. '||
1081 'There are no events to process in this run.'
1082 ,p_level => C_LEVEL_EVENT
1083 ,p_module => l_log_module);
1084 END IF;
1085 xla_accounting_err_pkg.build_message
1086 (p_appli_s_name => 'XLA'
1087 ,p_msg_name => 'XLA_AP_NO_EVENT_TO_PROCESS'
1088 ,p_entity_id => NULL
1089 ,p_event_id => NULL);
1090
1091 print_logfile('Technical warning : There are no events to process.');
1092
1093 -------------------------------------------------------------------------
1094 -- Following exception is added to make sure the request ends normal when
1095 -- no event is found to process for the given criteria.
1096 -- bug # 2709397
1097 -------------------------------------------------------------------------
1098 RAISE normal_termination;
1099 ELSIF l_array_event_appl_id.COUNT = 1 THEN
1100 IF (C_LEVEL_EVENT >= g_log_level) THEN
1101 trace
1102 (p_msg => 'Processing event application = '||l_array_event_appl_id(1)
1103 ,p_level => C_LEVEL_EVENT
1104 ,p_module => l_log_module);
1105 END IF;
1106
1107 event_application_manager
1108 (p_source_application_id => p_source_application_id
1109 ,p_application_id => l_array_event_appl_id(1)
1110 ,p_ledger_id => p_ledger_id
1111 ,p_process_category => p_process_category
1112 ,p_end_date => p_end_date
1113 ,p_accounting_flag => p_accounting_flag
1114 ,p_accounting_mode => p_accounting_mode
1115 ,p_error_only_flag => p_error_only_flag
1116 ,p_transfer_flag => p_transfer_flag
1117 ,p_gl_posting_flag => p_gl_posting_flag
1118 ,p_gl_batch_name => p_gl_batch_name
1119 ,p_valuation_method => p_valuation_method
1120 ,p_security_id_int_1 => p_security_id_int_1
1121 ,p_security_id_int_2 => p_security_id_int_2
1122 ,p_security_id_int_3 => p_security_id_int_3
1123 ,p_security_id_char_1 => p_security_id_char_1
1124 ,p_security_id_char_2 => p_security_id_char_2
1125 ,p_security_id_char_3 => p_security_id_char_3);
1126
1127
1128 ELSE
1129
1130 FOR i IN 1..l_array_event_appl_id.COUNT LOOP
1131 l_array_request_id(i) :=
1132 fnd_request.submit_request
1133 (application => 'XLA'
1134 ,program => 'XLAACCEA'
1135 ,description => NULL
1136 ,start_time => NULL
1137 ,sub_request => FALSE
1138 ,argument1 => p_source_application_id
1139 ,argument2 => l_array_event_appl_id(i)
1140 ,argument3 => p_ledger_id
1141 ,argument4 => p_process_category
1142 ,argument5 => p_end_date
1143 ,argument6 => p_accounting_flag
1144 ,argument7 => p_accounting_mode
1145 ,argument8 => p_error_only_flag
1146 ,argument9 => p_transfer_flag
1147 ,argument10 => p_gl_posting_flag
1148 ,argument11 => p_gl_batch_name
1149 ,argument12 => g_accounting_batch_id
1150 ,argument13 => g_report_request_id
1151 ,argument14 => p_valuation_method
1152 ,argument15 => p_security_id_int_1
1153 ,argument16 => p_security_id_int_2
1154 ,argument17 => p_security_id_int_3
1155 ,argument18 => p_security_id_char_1
1156 ,argument19 => p_security_id_char_2
1157 ,argument20 => p_security_id_char_3);
1158 IF l_array_request_id(i) = 0 THEN
1159 xla_accounting_err_pkg.build_message
1160 (p_appli_s_name => 'XLA'
1161 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
1162 ,p_token_1 => 'APPLICATION_NAME'
1163 ,p_value_1 => 'SLA'
1164 ,p_entity_id => NULL
1165 ,p_event_id => NULL);
1166
1167 print_logfile('Technical Error : Unable to submit accounting program request for '||
1168 'application '||l_array_event_appl_id(i));
1169
1170 xla_exceptions_pkg.raise_message
1171 (p_appli_s_name => 'XLA'
1172 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
1173 ,p_token_1 => 'APPLICATION_NAME'
1174 ,p_value_1 => 'SLA');
1175 END IF;
1176 END LOOP;
1177
1178
1179 IF (C_LEVEL_EVENT >= g_log_level) THEN
1180 FOR i IN 1 .. l_array_request_id.count LOOP
1181 trace
1182 (p_msg => 'Submitted request '||l_array_request_id(i)||
1183 'to process event application = '||l_array_event_appl_id(i)
1184 ,p_level => C_LEVEL_EVENT
1185 ,p_module => l_log_module);
1186 END LOOP;
1187 END IF;
1188
1189 -------------------------------------------------------------------------
1190 -- Commit is required after fnd_request.submit_request
1191 -------------------------------------------------------------------------
1192 COMMIT;
1193
1194 -------------------------------------------------------------------------
1195 -- wait for requests to complete
1196 -------------------------------------------------------------------------
1197 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Waiting for Acct Prg - parent requests to complete.');
1198 wait_for_requests
1199 (p_array_request_id => l_array_request_id
1200 ,p_error_status => l_error_status
1201 ,p_warning_status => l_warning_status);
1202 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Monitoring of Acct Prg - parent requests completed.');
1203 END IF;
1204
1205
1206 --------------------------------------------------------
1207 -- 4645092 set request id for get_mpa_accrual_context
1208 --------------------------------------------------------
1209 dbms_session.set_identifier (client_id => g_report_request_id);
1210 IF xla_context_pkg.get_mpa_accrual_context = 'Y' THEN
1211 g_mpa_accrual_exists := 'Y';
1212 ELSE
1213 g_mpa_accrual_exists := 'N';
1214 END IF;
1215 --------------------------------------------------------
1216
1217 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1218 trace('g_mpa_accrual_exists= '|| g_mpa_accrual_exists,
1219 C_LEVEL_STATEMENT,l_log_module);
1220 end if;
1221
1222 IF NVL(g_mpa_accrual_exists,'N') = 'Y' THEN -- 4645092
1223
1224 SELECT lower(iso_language),iso_territory
1225 INTO l_iso_language,l_iso_territory
1226 FROM FND_LANGUAGES
1227 WHERE language_code = USERENV('LANG');
1228
1229 l_xml_output := fnd_request.add_layout(
1230 'XLA', 'XLARPMPB'
1231 ,l_iso_language, l_iso_territory, 'PDF');
1232
1233 FOR i IN 1..l_array_event_appl_id.COUNT LOOP
1234
1235 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1236 trace('p_source_application_id = '|| to_char(p_source_application_id),
1237 C_LEVEL_STATEMENT,l_log_module);
1238 trace('p_application_id = '|| to_char(l_array_event_appl_id(i)),
1239 C_LEVEL_STATEMENT,l_log_module);
1240 trace('p_ledger_id = '|| to_char(p_ledger_id),
1241 C_LEVEL_STATEMENT,l_log_module);
1242 trace('p_process_category_code = '|| p_process_category,
1243 C_LEVEL_STATEMENT,l_log_module);
1244 trace('p_create_accounting = '|| p_accounting_flag,
1245 C_LEVEL_STATEMENT,l_log_module);
1246 trace('p_end_date = '|| to_char(p_end_date,'DD-MON-YYYY'),
1247 C_LEVEL_STATEMENT,l_log_module);
1248 trace('p_accounting_mode = '|| p_accounting_mode,
1249 C_LEVEL_STATEMENT,l_log_module);
1250 trace('p_errors_only_flag = '|| p_error_only_flag,
1251 C_LEVEL_STATEMENT,l_log_module);
1252 trace('p_transfer_to_gl_flag = '|| p_transfer_flag,
1253 C_LEVEL_STATEMENT,l_log_module);
1254 trace('p_post_in_gl_flag = '|| p_gl_posting_flag,
1255 C_LEVEL_STATEMENT,l_log_module);
1256 trace('p_gl_batch_name = '|| p_gl_batch_name,
1257 C_LEVEL_STATEMENT,l_log_module);
1258 trace('g_accounting_batch_id = '|| g_accounting_batch_id,
1259 C_LEVEL_STATEMENT,l_log_module);
1260 END IF;
1261
1262 l_array_mpa_request_id(i) := xla_mpa_accrual_rprtg_pkg.run_report
1263 (p_source_application_id
1264 ,l_array_event_appl_id(i)
1265 ,p_ledger_id
1266 ,p_process_category
1267 ,p_end_date
1268 ,p_accounting_flag
1269 ,p_accounting_mode
1270 ,p_error_only_flag
1271 ,p_transfer_flag
1272 ,p_gl_posting_flag
1273 ,p_gl_batch_name
1274 ,g_accounting_batch_id);
1275
1276
1277 IF l_array_mpa_request_id(i) = 0 THEN
1278 xla_accounting_err_pkg.build_message
1279 (p_appli_s_name => 'XLA'
1280 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
1281 ,p_token_1 => 'APPLICATION_NAME'
1282 ,p_value_1 => 'SLA'
1283 ,p_entity_id => NULL
1284 ,p_event_id => NULL);
1285
1286 print_logfile('Technical Error : '||
1287 'Unable to submit Subledger Multiperiod Accounting'||
1288 ' and Accrual Reversal Report request for '||
1289 'application '||l_array_event_appl_id(i));
1290
1291 xla_exceptions_pkg.raise_message
1292 (p_appli_s_name => 'XLA'
1293 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
1294 ,p_token_1 => 'APPLICATION_NAME'
1295 ,p_value_1 => 'SLA');
1296 END IF;
1297
1298 END LOOP;
1299
1300 IF (C_LEVEL_EVENT >= g_log_level) THEN
1301 FOR i IN 1 .. l_array_mpa_request_id.count LOOP
1302 trace
1303 (p_msg => 'Submitted request '||l_array_mpa_request_id(i)||
1304 'to process mpa report for application = '||
1305 l_array_event_appl_id(i)
1306 ,p_level => C_LEVEL_EVENT
1307 ,p_module => l_log_module);
1308 END LOOP;
1309 END IF;
1310
1311 -------------------------------------------------------------------------
1312 -- Commit is required after fnd_request.submit_request
1313 -------------------------------------------------------------------------
1314 COMMIT;
1315
1316 -------------------------------------------------------------------------
1317 -- wait for requests to complete
1318 -------------------------------------------------------------------------
1319 print_logfile(to_char(sysdate,'DD-MON-YYYY HH:MI:SS')||
1320 '- Waiting for MPA Prg - parent requests to complete.');
1321 wait_for_requests
1322 (p_array_request_id => l_array_mpa_request_id
1323 ,p_error_status => l_error_status
1324 ,p_warning_status => l_warning_status);
1325 print_logfile(to_char(sysdate,'DD-MON-YYYY HH:MI:SS')||
1326 ' - Monitoring of MPA Prg - parent requests completed.');
1327
1328 END IF;
1329
1330 --------------------------------------------------------
1331 -- 4645092 clear out MPA-Accrual flag
1332 --------------------------------------------------------
1333 xla_context_pkg.clear_mpa_accrual_context(p_client_id => g_report_request_id);
1334
1335 ----------------------------------------------------------------------------
1336 -- insert any errors that were build in this session (for them to appear
1337 -- on the report).
1338 ----------------------------------------------------------------------------
1339 xla_accounting_err_pkg.insert_errors;
1340
1341
1342 -- FSAH-PSFT FP
1343
1344 -- profile value XLA:Enable External Code Combination Validation
1345
1346 /* IF ( nvl(fnd_profile.value('XLA_FSAH_EXT_CCID_VAL'),'N') = 'Y') THEN
1347
1348 l_xla_val_ccid_req_id:= fnd_request.submit_request
1349 (application => 'XLA'
1350 ,program => 'XLACCIDVAL'
1351 ,description => NULL
1352 ,start_time => NULL
1353 ,sub_request => FALSE
1354 ,argument1 => p_application_id
1355 ,argument2 => g_accounting_batch_id
1356 ,argument3 => p_ledger_id
1357 ,argument4 => g_parent_request_id
1358 );
1359
1360 IF l_xla_val_ccid_req_id = 0 THEN
1361 xla_accounting_err_pkg.build_message
1362 (p_appli_s_name => 'XLA'
1363 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
1364 ,p_token_1 => 'APPLICATION_NAME'
1365 ,p_value_1 => 'SLA'
1366 ,p_entity_id => NULL
1367 ,p_event_id => NULL);
1368
1369 print_logfile('Technical Error : Unable to submit java
1370 concurrent program request');
1371
1372 xla_exceptions_pkg.raise_message
1373 (p_appli_s_name => 'XLA'
1374 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
1375 ,p_token_1 => 'APPLICATION_NAME'
1376 ,p_value_1 => 'SLA');
1377 END IF;
1378
1379 END IF; */
1380 -- FSAH-PSFT FP
1381
1382 COMMIT;
1383
1384 --FSAH-PSFT FP
1385
1386 /*-------------------------------------------------------------------------
1387 -- wait for requests to complete
1388 -------------------------------------------------------------------------
1389 print_logfile(to_char(sysdate,'DD-MON-YYYY HH:MI:SS')||
1390 '- Waiting for Combo Edit Validation - parent requests to complete.');
1391 wait_for_combo_edit_req
1392 (p_request_id => l_xla_val_ccid_req_id
1393 ,p_error_status => l_error_status
1394 ,p_warning_status => l_warning_status);
1395 print_logfile(to_char(sysdate,'DD-MON-YYYY HH:MI:SS')||
1396 ' - Monitoring of Combo Edit Validation - parent requests completed.');
1397
1398 xla_accounting_err_pkg.insert_errors; */
1399
1400 ----------------------------------------------------------------------------
1401 -- set out variables
1402 ----------------------------------------------------------------------------
1403 ----------------------------------------------------------------------------
1404 -- Following if conditioin is added to set the retcode to 1 when there are
1405 -- events with errors for that run of accounting program. (bug # 2709397)
1406 -- The if condition is modified to make sure the report request ends in
1407 -- ERROR/WARNING if any of the Parent request end in ERROR/WARNING.
1408 -- (Bug # 3239212).
1409 ----------------------------------------------------------------------------
1410 p_accounting_batch_id := g_accounting_batch_id;
1411
1412 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1413 trace
1414 (p_msg => 'l_error_status = '||l_error_status
1415 ,p_level => C_LEVEL_STATEMENT
1416 ,p_module => l_log_module);
1417 trace
1418 (p_msg => 'l_warning_status = '||l_warning_status
1419 ,p_level => C_LEVEL_STATEMENT
1420 ,p_module => l_log_module);
1421 trace
1422 (p_msg => 'g_total_error_count = '||g_total_error_count
1423 ,p_level => C_LEVEL_STATEMENT
1424 ,p_module => l_log_module);
1425 END IF;
1426
1427 -- FSAH-PSFT FP
1428 -- Set retcode as warning when ever CmboEdit returns Invalid CCID's -- 7502532
1429 IF ( nvl(fnd_profile.value('XLA_FSAH_EXT_CCID_VAL'),'N') = 'Y') THEN
1430 BEGIN
1431 SELECT 1 INTO l_code FROM dual WHERE EXISTS
1432 (SELECT 1 FROM xla_events xe, xla_ae_headers xah WHERE
1433 xe.application_id= p_application_id AND
1434 xe.application_id=xah.application_id AND
1435 xe.process_status_code in ('I','R') AND
1436 xe.event_status_code ='U' AND
1437 xah.ledger_id = p_ledger_id AND
1438 xah.accounting_batch_id = g_accounting_batch_id AND
1439 xah.accounting_entry_status_code in ('R','I'));
1440 EXCEPTION
1441 WHEN NO_DATA_FOUND THEN
1442 NULL;
1443 END;
1444
1445 IF l_code >=1 THEN
1446 l_warning_status:='Y';
1447 END IF;
1448 END IF;
1449 -- FSAH-PSFT FP
1450
1451 IF l_error_status = 'Y' THEN
1452 -------------------------------------------------------------------------
1453 -- This is effective only if there are multiple event applications
1454 -------------------------------------------------------------------------
1455 p_retcode := 2;
1456 p_errbuf := 'Accouting Report ended in Error because one '||
1457 'of the Parent Accounting Program ended in Error';
1458 ELSIF l_warning_status = 'Y' THEN
1459 -------------------------------------------------------------------------
1460 -- This is effective only if there are multiple event applications
1461 -------------------------------------------------------------------------
1462 p_retcode := 1;
1463 p_errbuf := 'Accouting Report ended in Warning because one '||
1464 'of the Parent Accounting Program ended in Warning';
1465 ELSIF g_total_error_count = 0 THEN
1466 p_retcode := 0;
1467 p_errbuf := 'Accounting Program completed Normal';
1468 ELSIF g_total_error_count <> 0 THEN
1469 -------------------------------------------------------------------------
1470 -- This is effective only if there is one event application
1471 -------------------------------------------------------------------------
1472 p_retcode := 1;
1473 p_errbuf := 'Accounting Program ended in Warning because '||
1474 'there are some events that are in error';
1475 END IF;
1476
1477 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1478 trace
1479 (p_msg => 'p_retcode = '||p_retcode
1480 ,p_level => C_LEVEL_PROCEDURE
1481 ,p_module => l_log_module);
1482 trace
1483 (p_msg => 'p_errbuf = '||p_errbuf
1484 ,p_level => C_LEVEL_PROCEDURE
1485 ,p_module => l_log_module);
1486 trace
1487 (p_msg => 'END of procedure ACCOUNTING_PROGRAM_BATCH'
1488 ,p_level => C_LEVEL_PROCEDURE
1489 ,p_module => l_log_module);
1490 END IF;
1491
1492 EXCEPTION
1493 WHEN normal_termination THEN
1494 ----------------------------------------------------------------------------
1495 -- set out variables
1496 ----------------------------------------------------------------------------
1497 p_accounting_batch_id := g_accounting_batch_id;
1498 p_retcode := 0;
1499 p_errbuf := 'Accounting Program did not find any events.';
1500
1501 print_logfile(p_errbuf);
1502
1503 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
1504 trace
1505 (p_msg => 'NORMAL_TERMINATION exception was raised in the code'
1506 ,p_level => C_LEVEL_EXCEPTION
1507 ,p_module => l_log_module);
1508 END IF;
1509
1510 -- Bug 8282549
1511 IF g_queue_started_flag = 'Y' THEN
1512 IF (C_LEVEL_EVENT >= g_log_level) THEN
1513 trace
1514 (p_msg => 'Ready to stop the message queue'
1515 ,p_level => C_LEVEL_EVENT
1516 ,p_module => l_log_module);
1517 END IF;
1518
1519 dbms_aqadm.stop_queue(queue_name => g_queue_name
1520 ,wait => TRUE); --5056507
1521 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue stopped = '||g_queue_name);
1522 dbms_aqadm.stop_queue(queue_name => g_comp_queue_name
1523 ,wait => TRUE); --5056507
1524 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue stopped = '||g_comp_queue_name);
1525 g_queue_started_flag := 'N';
1526
1527 IF (C_LEVEL_EVENT >= g_log_level) THEN
1528 trace
1529 (p_msg => 'Message queue stopped'
1530 ,p_level => C_LEVEL_EVENT
1531 ,p_module => l_log_module);
1532 END IF;
1533 END IF;
1534
1535 IF g_queue_created_flag = 'Y' THEN
1536 IF (C_LEVEL_EVENT >= g_log_level) THEN
1537 trace
1538 (p_msg => 'Ready to drop the message queue'
1539 ,p_level => C_LEVEL_EVENT
1540 ,p_module => l_log_module);
1541 END IF;
1542
1543 dbms_aqadm.drop_queue(queue_name => g_queue_name);
1544 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue dropped = '||g_queue_name);
1545 dbms_aqadm.drop_queue(queue_name => g_comp_queue_name);
1546 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue dropped = '||g_comp_queue_name);
1547 g_queue_created_flag := 'N';
1548
1549 IF (C_LEVEL_EVENT >= g_log_level) THEN
1550 trace
1551 (p_msg => 'Message queue dropped'
1552 ,p_level => C_LEVEL_EVENT
1553 ,p_module => l_log_module);
1554 END IF;
1555 END IF;
1556 ----------------------------------------------------------------------------
1557 -- insert any errors that were build in this session (for them to appear
1558 -- on the report).
1559 ----------------------------------------------------------------------------
1560 xla_accounting_err_pkg.insert_errors;
1561
1562 COMMIT;
1563
1564 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1565 trace
1566 (p_msg => 'p_retcode = '||p_retcode
1567 ,p_level => C_LEVEL_PROCEDURE
1568 ,p_module => l_log_module);
1569 trace
1570 (p_msg => 'p_errbuf = '||p_errbuf
1571 ,p_level => C_LEVEL_PROCEDURE
1572 ,p_module => l_log_module);
1573 trace
1574 (p_msg => 'END of procedure ACCOUNTING_PROGRAM_BATCH'
1575 ,p_level => C_LEVEL_PROCEDURE
1576 ,p_module => l_log_module);
1577 END IF;
1578 WHEN xla_exceptions_pkg.application_exception THEN
1579 ----------------------------------------------------------------------------
1580 -- set out variables
1581 ----------------------------------------------------------------------------
1582 p_accounting_batch_id := g_accounting_batch_id;
1583 p_retcode := 2;
1584 p_errbuf := xla_messages_pkg.get_message;
1585
1586 print_logfile(p_errbuf);
1587
1588 IF (C_LEVEL_ERROR >= g_log_level) THEN
1589 trace
1590 (p_msg => NULL
1591 ,p_level => C_LEVEL_ERROR
1592 ,p_module => l_log_module);
1593 END IF;
1594
1595 ----------------------------------------------------------------------------
1596 -- insert any errors that were build in this session (for them to appear
1597 -- on the report).
1598 ----------------------------------------------------------------------------
1599 xla_accounting_err_pkg.insert_errors;
1600 COMMIT;
1601
1602
1603 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1604 trace
1605 (p_msg => 'p_retcode = '||p_retcode
1606 ,p_level => C_LEVEL_PROCEDURE
1607 ,p_module => l_log_module);
1608 trace
1609 (p_msg => 'p_errbuf = '||p_errbuf
1610 ,p_level => C_LEVEL_PROCEDURE
1611 ,p_module => l_log_module);
1612 trace
1613 (p_msg => 'END of procedure ACCOUNTING_PROGRAM_BATCH'
1614 ,p_level => C_LEVEL_PROCEDURE
1615 ,p_module => l_log_module);
1616 END IF;
1617 WHEN OTHERS THEN
1618 ----------------------------------------------------------------------------
1619 -- set out variables
1620 ----------------------------------------------------------------------------
1621 p_accounting_batch_id := g_accounting_batch_id;
1622 p_retcode := 2;
1623 p_errbuf := sqlerrm;
1624
1625 print_logfile(p_errbuf);
1626
1627 IF (C_LEVEL_UNEXPECTED >= g_log_level) THEN
1628 trace
1629 (p_msg => NULL
1630 ,p_level => C_LEVEL_UNEXPECTED
1631 ,p_module => l_log_module);
1632 END IF;
1633
1634 ----------------------------------------------------------------------------
1635 -- insert any errors that were build in this session (for them to appear
1636 -- on the report).
1637 ----------------------------------------------------------------------------
1638 xla_accounting_err_pkg.build_message
1639 (p_appli_s_name => 'XLA'
1640 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
1641 ,p_token_1 => 'APPLICATION_NAME'
1642 ,p_value_1 => 'SLA'
1643 ,p_entity_id => NULL
1644 ,p_event_id => NULL);
1645
1646 xla_accounting_err_pkg.insert_errors;
1647 COMMIT;
1648
1649 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1650 trace
1651 (p_msg => 'p_retcode = '||p_retcode
1652 ,p_level => C_LEVEL_PROCEDURE
1653 ,p_module => l_log_module);
1654 trace
1655 (p_msg => 'p_errbuf = '||p_errbuf
1656 ,p_level => C_LEVEL_PROCEDURE
1657 ,p_module => l_log_module);
1658 trace
1659 (p_msg => 'END of procedure ACCOUNTING_PROGRAM_BATCH'
1660 ,p_level => C_LEVEL_PROCEDURE
1661 ,p_module => l_log_module);
1662 END IF;
1663 END accounting_program_batch; -- end of procedure
1664
1665
1666 --=============================================================================
1667 --
1668 --
1669 --
1670 --=============================================================================
1671 PROCEDURE event_application_cp
1672 (p_errbuf OUT NOCOPY VARCHAR2
1673 ,p_retcode OUT NOCOPY NUMBER
1674 ,p_source_application_id IN NUMBER
1675 ,p_application_id IN NUMBER
1676 ,p_ledger_id IN NUMBER
1677 ,p_process_category IN VARCHAR2
1678 ,p_end_date IN DATE
1679 ,p_accounting_flag IN VARCHAR2
1680 ,p_accounting_mode IN VARCHAR2
1681 ,p_error_only_flag IN VARCHAR2
1682 ,p_transfer_flag IN VARCHAR2
1683 ,p_gl_posting_flag IN VARCHAR2
1684 ,p_gl_batch_name IN VARCHAR2
1685 ,p_accounting_batch_id IN NUMBER
1686 ,p_report_request_id IN NUMBER
1687 ,p_valuation_method IN VARCHAR2
1688 ,p_security_id_int_1 IN NUMBER
1689 ,p_security_id_int_2 IN NUMBER
1690 ,p_security_id_int_3 IN NUMBER
1691 ,p_security_id_char_1 IN VARCHAR2
1692 ,p_security_id_char_2 IN VARCHAR2
1693 ,p_security_id_char_3 IN VARCHAR2) IS
1694 l_log_module VARCHAR2(240);
1695 BEGIN
1696 IF g_log_enabled THEN
1697 l_log_module := C_DEFAULT_MODULE||'.event_application_cp';
1698 END IF;
1699 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1700 trace
1701 (p_msg => 'BEGIN of procedure EVENT_APPLICATION_CP'
1702 ,p_level => C_LEVEL_PROCEDURE
1703 ,p_module => l_log_module);
1704 trace
1705 (p_msg => 'p_source_application_id = '||p_source_application_id
1706 ,p_level => C_LEVEL_PROCEDURE
1707 ,p_module => l_log_module);
1708 trace
1709 (p_msg => 'p_application_id = '||p_application_id
1710 ,p_level => C_LEVEL_PROCEDURE
1711 ,p_module => l_log_module);
1712 trace
1713 (p_msg => 'p_ledger_id = '||p_ledger_id
1714 ,p_level => C_LEVEL_PROCEDURE
1715 ,p_module => l_log_module);
1716 trace
1717 (p_msg => 'p_process_category = '||p_process_category
1718 ,p_level => C_LEVEL_PROCEDURE
1719 ,p_module => l_log_module);
1720 trace
1721 (p_msg => 'p_end_date = '||p_end_date
1722 ,p_level => C_LEVEL_PROCEDURE
1723 ,p_module => l_log_module);
1724 trace
1725 (p_msg => 'p_accounting_flag = '||p_accounting_flag
1726 ,p_level => C_LEVEL_PROCEDURE
1727 ,p_module => l_log_module);
1728 trace
1729 (p_msg => 'p_accounting_mode = '||p_accounting_mode
1730 ,p_level => C_LEVEL_PROCEDURE
1731 ,p_module => l_log_module);
1732 trace
1733 (p_msg => 'p_error_only_flag = '||p_error_only_flag
1734 ,p_level => C_LEVEL_PROCEDURE
1735 ,p_module => l_log_module);
1736 trace
1737 (p_msg => 'p_transfer_flag = '||p_transfer_flag
1738 ,p_level => C_LEVEL_PROCEDURE
1739 ,p_module => l_log_module);
1740 trace
1741 (p_msg => 'p_gl_posting_flag = '||p_gl_posting_flag
1742 ,p_level => C_LEVEL_PROCEDURE
1743 ,p_module => l_log_module);
1744 trace
1745 (p_msg => 'p_gl_batch_name = '||p_gl_batch_name
1746 ,p_level => C_LEVEL_PROCEDURE
1747 ,p_module => l_log_module);
1748 trace
1749 (p_msg => 'p_accounting_batch_id = '||p_accounting_batch_id
1750 ,p_level => C_LEVEL_PROCEDURE
1751 ,p_module => l_log_module);
1752 trace
1753 (p_msg => 'p_report_request_id = '||p_report_request_id
1754 ,p_level => C_LEVEL_PROCEDURE
1755 ,p_module => l_log_module);
1756 trace
1757 (p_msg => 'p_valuation_method = '||p_valuation_method
1758 ,p_level => C_LEVEL_PROCEDURE
1759 ,p_module => l_log_module);
1760 trace
1761 (p_msg => 'p_security_id_int_1 = '||p_security_id_int_1
1762 ,p_level => C_LEVEL_PROCEDURE
1763 ,p_module => l_log_module);
1764 trace
1765 (p_msg => 'p_security_id_int_1 = '||p_security_id_int_1
1766 ,p_level => C_LEVEL_PROCEDURE
1767 ,p_module => l_log_module);
1768 trace
1769 (p_msg => 'p_security_id_int_3 = '||p_security_id_int_3
1770 ,p_level => C_LEVEL_PROCEDURE
1771 ,p_module => l_log_module);
1772 trace
1773 (p_msg => 'p_security_id_char_1 = '||p_security_id_char_1
1774 ,p_level => C_LEVEL_PROCEDURE
1775 ,p_module => l_log_module);
1776 trace
1777 (p_msg => 'p_security_id_char_2 = '||p_security_id_char_2
1778 ,p_level => C_LEVEL_PROCEDURE
1779 ,p_module => l_log_module);
1780 trace
1781 (p_msg => 'p_security_id_char_3 = '||p_security_id_char_3
1782 ,p_level => C_LEVEL_PROCEDURE
1783 ,p_module => l_log_module);
1784 END IF;
1785
1786
1787 print_logfile('Starting request for the event application = '||p_application_id);
1788
1789 ----------------------------------------------------------------------------
1790 -- Initializing errors package
1791 ----------------------------------------------------------------------------
1792 xla_accounting_err_pkg.set_options
1793 (p_error_source => xla_accounting_err_pkg.C_ACCT_PROGRAM
1794 ,p_request_id => p_report_request_id
1795 ,p_application_id => p_application_id);
1796
1797 g_accounting_batch_id := p_accounting_batch_id;
1798 g_report_request_id := p_report_request_id;
1799
1800 ----------------------------------------------------------------------------
1801 -- Building filter condition based on security columns and valuation method
1802 -- This condition will be added dynamically to select statemtents.
1803 ----------------------------------------------------------------------------
1804 SELECT
1805 DECODE(p_valuation_method,NULL,NULL,'and valuation_method = '''||p_valuation_method||''' ')||
1806 --DECODE(p_security_id_int_1,NULL,NULL,'and security_id_int_1 = '||p_security_id_int_1||' ')|| --14307411
1807 DECODE(p_security_id_int_1,NULL,NULL
1808 ,DECODE(p_application_id,707, 'and NVL(security_id_int_1,p_security_id_int_1) = '||p_security_id_int_1||' ',
1809 'and security_id_int_1 = '||p_security_id_int_1||' '))|| --14307411
1810 DECODE(p_security_id_int_2,NULL,NULL,'and security_id_int_2 = '||p_security_id_int_2||' ')||
1811 DECODE(p_security_id_int_3,NULL,NULL,'and security_id_int_3 = '||p_security_id_int_3||' ')||
1812 DECODE(p_security_id_char_1,NULL,NULL,'and security_id_char_1 = '''||p_security_id_char_1||''' ')||
1813 DECODE(p_security_id_char_2,NULL,NULL,'and security_id_char_2 = '''||p_security_id_char_2||''' ')||
1814 DECODE(p_security_id_char_3,NULL,NULL,'and security_id_char_3 = '''||p_security_id_char_3||''' ')
1815 INTO g_security_condition
1816 FROM DUAL;
1817
1818 ----------------------------------------------------------------------------
1819 -- Building filter condition based process_category.
1820 -- This condition will be added dynamically to select statemtents.
1821 ----------------------------------------------------------------------------
1822 SELECT
1823 DECODE(p_process_category,NULL,NULL,'and event_class_group_code = '''||p_process_category||'''')
1824 INTO g_process_category_condition
1825 FROM DUAL;
1826
1827 ----------------------------------------------------------------------------
1828 -- Building filter condition based on source_application_id.
1829 ----------------------------------------------------------------------------
1830 SELECT
1831 DECODE(p_source_application_id,NULL,NULL,'and source_application_id = '||p_source_application_id)
1832 INTO g_source_appl_condition
1833 FROM DUAL;
1834 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Dynamic conditions built');
1835
1836 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1837 trace
1838 (p_msg => 'g_security_condition = '||g_security_condition
1839 ,p_level => C_LEVEL_STATEMENT
1840 ,p_module => l_log_module);
1841 trace
1842 (p_msg => 'g_process_category_condition = '||g_process_category_condition
1843 ,p_level => C_LEVEL_STATEMENT
1844 ,p_module => l_log_module);
1845 trace
1846 (p_msg => 'g_source_appl_condition = '||g_source_appl_condition
1847 ,p_level => C_LEVEL_STATEMENT
1848 ,p_module => l_log_module);
1849 END IF;
1850
1851 ----------------------------------------------------------------------------
1852 -- call event_application_manager
1853 ----------------------------------------------------------------------------
1854 event_application_manager
1855 (p_source_application_id => p_source_application_id
1856 ,p_application_id => p_application_id
1857 ,p_ledger_id => p_ledger_id
1858 ,p_process_category => p_process_category
1859 ,p_end_date => p_end_date
1860 ,p_accounting_flag => p_accounting_flag
1861 ,p_accounting_mode => p_accounting_mode
1862 ,p_error_only_flag => p_error_only_flag
1863 ,p_transfer_flag => p_transfer_flag
1864 ,p_gl_posting_flag => p_gl_posting_flag
1865 ,p_gl_batch_name => p_gl_batch_name
1866 ,p_valuation_method => p_valuation_method
1867 ,p_security_id_int_1 => p_security_id_int_1
1868 ,p_security_id_int_2 => p_security_id_int_2
1869 ,p_security_id_int_3 => p_security_id_int_3
1870 ,p_security_id_char_1 => p_security_id_char_1
1871 ,p_security_id_char_2 => p_security_id_char_2
1872 ,p_security_id_char_3 => p_security_id_char_3);
1873
1874 ----------------------------------------------------------------------------
1875 -- set out variables
1876 ----------------------------------------------------------------------------
1877 ----------------------------------------------------------------------------
1878 -- Following if conditioin is added to set the retcode to 1 when there are
1879 -- events with errors for that run of accounting program. (bug # 2709397)
1880 ----------------------------------------------------------------------------
1881 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1882 trace
1883 (p_msg => 'g_total_error_count = '||g_total_error_count
1884 ,p_level => C_LEVEL_STATEMENT
1885 ,p_module => l_log_module);
1886 END IF;
1887
1888 IF g_total_error_count = 0 THEN
1889 p_retcode := 0;
1890 p_errbuf := 'Accounting Program completed Normal';
1891 ELSE
1892 p_retcode := 1;
1893 p_errbuf := 'Accounting Program completed Normal with some events in error';
1894 END IF;
1895
1896
1897 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1898 trace
1899 (p_msg => 'p_retcode = '||p_retcode
1900 ,p_level => C_LEVEL_PROCEDURE
1901 ,p_module => l_log_module);
1902 trace
1903 (p_msg => 'p_errbuf = '||p_errbuf
1904 ,p_level => C_LEVEL_PROCEDURE
1905 ,p_module => l_log_module);
1906 trace
1907 (p_msg => 'END of procedure EVENT_APPLICATION_CP'
1908 ,p_level => C_LEVEL_PROCEDURE
1909 ,p_module => l_log_module);
1910 END IF;
1911 EXCEPTION
1912 WHEN normal_termination THEN
1913 ----------------------------------------------------------------------------
1914 -- set out variables
1915 ----------------------------------------------------------------------------
1916 p_retcode := 0;
1917 p_errbuf := 'Accounting Program did not find any events.';
1918
1919 print_logfile(p_errbuf);
1920
1921 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
1922 trace
1923 (p_msg => 'NORMAL_TERMINATION exception was raised in the code'
1924 ,p_level => C_LEVEL_EXCEPTION
1925 ,p_module => l_log_module);
1926 END IF;
1927 ----------------------------------------------------------------------------
1928 -- insert any errors that were build in this session (for them to appear
1929 -- on the report).
1930 ----------------------------------------------------------------------------
1931 xla_accounting_err_pkg.insert_errors;
1932
1933 COMMIT;
1934
1935
1936 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1937 trace
1938 (p_msg => 'p_retcode = '||p_retcode
1939 ,p_level => C_LEVEL_PROCEDURE
1940 ,p_module => l_log_module);
1941 trace
1942 (p_msg => 'p_errbuf = '||p_errbuf
1943 ,p_level => C_LEVEL_PROCEDURE
1944 ,p_module => l_log_module);
1945 trace
1946 (p_msg => 'END of procedure EVENT_APPLICATION_CP'
1947 ,p_level => C_LEVEL_PROCEDURE
1948 ,p_module => l_log_module);
1949 END IF;
1950 WHEN xla_exceptions_pkg.application_exception THEN
1951 ----------------------------------------------------------------------------
1952 -- set out variables
1953 ----------------------------------------------------------------------------
1954 p_retcode := 2;
1955 p_errbuf := xla_messages_pkg.get_message;
1956
1957 print_logfile(p_errbuf);
1958
1959 IF (C_LEVEL_ERROR >= g_log_level) THEN
1960 trace
1961 (p_msg => NULL
1962 ,p_level => C_LEVEL_ERROR
1963 ,p_module => l_log_module);
1964 END IF;
1965
1966 ----------------------------------------------------------------------------
1967 -- insert any errors that were build in this session (for them to appear
1968 -- on the report).
1969 ----------------------------------------------------------------------------
1970 xla_accounting_err_pkg.insert_errors;
1971
1972 COMMIT;
1973
1974
1975 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1976 trace
1977 (p_msg => 'p_retcode = '||p_retcode
1978 ,p_level => C_LEVEL_PROCEDURE
1979 ,p_module => l_log_module);
1980 trace
1981 (p_msg => 'p_errbuf = '||p_errbuf
1982 ,p_level => C_LEVEL_PROCEDURE
1983 ,p_module => l_log_module);
1984 trace
1985 (p_msg => 'END of procedure EVENT_APPLICATION_CP'
1986 ,p_level => C_LEVEL_PROCEDURE
1987 ,p_module => l_log_module);
1988 END IF;
1989 WHEN OTHERS THEN
1990 ----------------------------------------------------------------------------
1991 -- set out variables
1992 ----------------------------------------------------------------------------
1993 p_retcode := 2;
1994 p_errbuf := sqlerrm;
1995
1996 print_logfile(p_errbuf);
1997
1998 IF (C_LEVEL_UNEXPECTED >= g_log_level) THEN
1999 trace
2000 (p_msg => NULL
2001 ,p_level => C_LEVEL_UNEXPECTED
2002 ,p_module => l_log_module);
2003 END IF;
2004
2005 ----------------------------------------------------------------------------
2006 -- insert any errors that were build in this session (for them to appear
2007 -- on the report).
2008 ----------------------------------------------------------------------------
2009 xla_accounting_err_pkg.build_message
2010 (p_appli_s_name => 'XLA'
2011 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
2012 ,p_token_1 => 'APPLICATION_NAME'
2013 ,p_value_1 => 'SLA'
2014 ,p_entity_id => NULL
2015 ,p_event_id => NULL);
2016
2017 xla_accounting_err_pkg.insert_errors;
2018
2019 COMMIT;
2020
2021
2022 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2023 trace
2024 (p_msg => 'p_retcode = '||p_retcode
2025 ,p_level => C_LEVEL_PROCEDURE
2026 ,p_module => l_log_module);
2027 trace
2028 (p_msg => 'p_errbuf = '||p_errbuf
2029 ,p_level => C_LEVEL_PROCEDURE
2030 ,p_module => l_log_module);
2031 trace
2032 (p_msg => 'END of procedure EVENT_APPLICATION_CP'
2033 ,p_level => C_LEVEL_PROCEDURE
2034 ,p_module => l_log_module);
2035 END IF;
2036 END event_application_cp; -- end of procedure
2037
2038
2039 --=============================================================================
2040 --
2041 --
2042 --
2043 --=============================================================================
2044 PROCEDURE event_application_manager
2045 (p_source_application_id IN NUMBER
2046 ,p_application_id IN NUMBER
2047 ,p_ledger_id IN NUMBER
2048 ,p_process_category IN VARCHAR2
2049 ,p_end_date IN DATE
2050 ,p_accounting_flag IN VARCHAR2
2051 ,p_accounting_mode IN VARCHAR2
2052 ,p_error_only_flag IN VARCHAR2
2053 ,p_transfer_flag IN VARCHAR2
2054 ,p_gl_posting_flag IN VARCHAR2
2055 ,p_gl_batch_name IN VARCHAR2
2056 ,p_valuation_method IN VARCHAR2
2057 ,p_security_id_int_1 IN NUMBER
2058 ,p_security_id_int_2 IN NUMBER
2059 ,p_security_id_int_3 IN NUMBER
2060 ,p_security_id_char_1 IN VARCHAR2
2061 ,p_security_id_char_2 IN VARCHAR2
2062 ,p_security_id_char_3 IN VARCHAR2) IS
2063
2064 l_transfer_mode VARCHAR2(30);
2065 l_sqlerrm VARCHAR2(2000);
2066 l_log_module VARCHAR2(240);
2067
2068 l_temp BOOLEAN;
2069 l_status VARCHAR2(80);
2070 l_industry VARCHAR2(80);
2071 l_xla_schema_name VARCHAR2(30);
2072
2073 l_acct_begin_time NUMBER;
2074 l_acct_end_time NUMBER;
2075 l_transfer_begin_time NUMBER;
2076 l_transfer_end_time NUMBER;
2077
2078 --FSAH-PSFT FP
2079 l_xla_val_ccid_req_id NUMBER(10);--FSAH
2080 l_error_status VARCHAR2(1) := 'N'; --FSAH
2081 l_warning_status VARCHAR2(1) := 'N'; --FSAH
2082
2083 BEGIN
2084 IF g_log_enabled THEN
2085 l_log_module := C_DEFAULT_MODULE||'.event_application_manager';
2086 END IF;
2087 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2088 trace
2089 (p_msg => 'BEGIN of procedure EVENT_APPLICATION_MANAGER'
2090 ,p_level => C_LEVEL_PROCEDURE
2091 ,p_module => l_log_module);
2092 trace
2093 (p_msg => 'p_source_application_id = '||p_source_application_id
2094 ,p_level => C_LEVEL_PROCEDURE
2095 ,p_module => l_log_module);
2096 trace
2097 (p_msg => 'p_application_id = '||p_application_id
2098 ,p_level => C_LEVEL_PROCEDURE
2099 ,p_module => l_log_module);
2100 trace
2101 (p_msg => 'p_ledger_id = '||p_ledger_id
2102 ,p_level => C_LEVEL_PROCEDURE
2103 ,p_module => l_log_module);
2104 trace
2105 (p_msg => 'p_process_category = '||p_process_category
2106 ,p_level => C_LEVEL_PROCEDURE
2107 ,p_module => l_log_module);
2108 trace
2109 (p_msg => 'p_end_date = '||p_end_date
2110 ,p_level => C_LEVEL_PROCEDURE
2111 ,p_module => l_log_module);
2112 trace
2113 (p_msg => 'p_accounting_flag = '||p_accounting_flag
2114 ,p_level => C_LEVEL_PROCEDURE
2115 ,p_module => l_log_module);
2116 trace
2117 (p_msg => 'p_accounting_mode = '||p_accounting_mode
2118 ,p_level => C_LEVEL_PROCEDURE
2119 ,p_module => l_log_module);
2120 trace
2121 (p_msg => 'p_error_only_flag = '||p_error_only_flag
2122 ,p_level => C_LEVEL_PROCEDURE
2123 ,p_module => l_log_module);
2124 trace
2125 (p_msg => 'p_transfer_flag = '||p_transfer_flag
2126 ,p_level => C_LEVEL_PROCEDURE
2127 ,p_module => l_log_module);
2128 trace
2129 (p_msg => 'p_gl_posting_flag = '||p_gl_posting_flag
2130 ,p_level => C_LEVEL_PROCEDURE
2131 ,p_module => l_log_module);
2132 trace
2133 (p_msg => 'p_gl_batch_name = '||p_gl_batch_name
2134 ,p_level => C_LEVEL_PROCEDURE
2135 ,p_module => l_log_module);
2136 trace
2137 (p_msg => 'p_valuation_method = '||p_valuation_method
2138 ,p_level => C_LEVEL_PROCEDURE
2139 ,p_module => l_log_module);
2140 trace
2141 (p_msg => 'p_security_id_int_1 = '||p_security_id_int_1
2142 ,p_level => C_LEVEL_PROCEDURE
2143 ,p_module => l_log_module);
2144 trace
2145 (p_msg => 'p_security_id_int_2 = '||p_security_id_int_2
2146 ,p_level => C_LEVEL_PROCEDURE
2147 ,p_module => l_log_module);
2148 trace
2149 (p_msg => 'p_security_id_int_3 = '||p_security_id_int_3
2150 ,p_level => C_LEVEL_PROCEDURE
2151 ,p_module => l_log_module);
2152 trace
2153 (p_msg => 'p_security_id_char_1 = '||p_security_id_char_1
2154 ,p_level => C_LEVEL_PROCEDURE
2155 ,p_module => l_log_module);
2156 trace
2157 (p_msg => 'p_security_id_char_2 = '||p_security_id_char_2
2158 ,p_level => C_LEVEL_PROCEDURE
2159 ,p_module => l_log_module);
2160 trace
2161 (p_msg => 'p_security_id_char_3 = '||p_security_id_char_3
2162 ,p_level => C_LEVEL_PROCEDURE
2163 ,p_module => l_log_module);
2164 END IF;
2165
2166 ----------------------------------------------------------------------------
2167 -- Initializing global variables
2168 ----------------------------------------------------------------------------
2169 g_application_id := p_application_id;
2170 g_ledger_id := p_ledger_id;
2171 g_process_category := p_process_category;
2172 g_end_date := p_end_date;
2173 g_accounting_flag := p_accounting_flag;
2174 g_accounting_mode := p_accounting_mode;
2175 g_error_only_flag := p_error_only_flag;
2176 g_transfer_flag := p_transfer_flag;
2177 g_gl_posting_flag := p_gl_posting_flag;
2178 g_gl_batch_name := p_gl_batch_name;
2179 -- Bug 4963736
2180 g_valuation_method := p_valuation_method;
2181 g_security_id_int_1 := p_security_id_int_1;
2182 g_security_id_int_2 := p_security_id_int_2;
2183 g_security_id_int_3 := p_security_id_int_3;
2184 g_security_id_char_1 := p_security_id_char_1;
2185 g_security_id_char_2 := p_security_id_char_2;
2186 g_security_id_char_3 := p_security_id_char_3;
2187
2188 g_processing_mode := 'BATCH';
2189 g_execution_mode := 'OFFLINE';
2190 g_total_error_count := 0;
2191 g_parent_request_id := fnd_global.conc_request_id;
2192
2193 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2194 trace
2195 (p_msg => 'g_processing_mode = '||g_processing_mode
2196 ,p_level => C_LEVEL_STATEMENT
2197 ,p_module => l_log_module);
2198 trace
2199 (p_msg => 'g_execution_mode = '||g_execution_mode
2200 ,p_level => C_LEVEL_STATEMENT
2201 ,p_module => l_log_module);
2202 trace
2203 (p_msg => 'g_parent_request_id = '||g_parent_request_id
2204 ,p_level => C_LEVEL_STATEMENT
2205 ,p_module => l_log_module);
2206 END IF;
2207
2208 l_acct_begin_time := 0;
2209 l_acct_end_time := 0;
2210 l_transfer_begin_time := 0;
2211 l_transfer_end_time := 0;
2212
2213
2214 ----------------------------------------------------------------------------
2215 -- Following sets the Security Context for the execution. This enables the
2216 -- the accounting program to respect the transaction security.
2217 ----------------------------------------------------------------------------
2218 xla_security_pkg.set_security_context(p_application_id);
2219
2220 IF (C_LEVEL_EVENT >= g_log_level) THEN
2221 trace
2222 (p_msg => 'Security_context set for application = '||p_application_id
2223 ,p_level => C_LEVEL_EVENT
2224 ,p_module => l_log_module);
2225 END IF;
2226
2227 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Security Context Set ');
2228
2229 ----------------------------------------------------------------------------
2230 -- Following sets the session's client identifier for the purpose of global
2231 -- application context.
2232 ----------------------------------------------------------------------------
2233 dbms_session.set_identifier
2234 (client_id => g_parent_request_id);
2235
2236 IF (C_LEVEL_EVENT >= g_log_level) THEN
2237 trace
2238 (p_msg => 'Session identifier set to = '||g_parent_request_id
2239 ,p_level => C_LEVEL_EVENT
2240 ,p_module => l_log_module);
2241 END IF;
2242
2243 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Session Identifier Set ');
2244
2245 ----------------------------------------------------------------------------
2246 -- Determining xla_schema_name and queue_table_name
2247 ----------------------------------------------------------------------------
2248 l_temp := fnd_installation.get_app_info
2249 (application_short_name => 'XLA'
2250 ,status => l_status
2251 ,industry => l_industry
2252 ,oracle_schema => l_xla_schema_name);
2253
2254 g_queue_table_name := l_xla_schema_name||'.'||C_QUEUE_TABLE;
2255
2256 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2257 trace
2258 (p_msg => 'g_queue_table_name = '||g_queue_table_name
2259 ,p_level => C_LEVEL_STATEMENT
2260 ,p_module => l_log_module);
2261 END IF;
2262
2263 ----------------------------------------------------------------------------
2264 -- Determining queue_name based on request id
2265 ----------------------------------------------------------------------------
2266 g_queue_name := l_xla_schema_name || '.XLA_'||TO_CHAR(g_parent_request_id)||'_DOC_Q';
2267 g_comp_queue_name := l_xla_schema_name || '.XLA_'||TO_CHAR(g_parent_request_id)||'_COMP_Q';
2268
2269 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2270 trace
2271 (p_msg => 'g_queue_name = '||g_queue_name
2272 ,p_level => C_LEVEL_STATEMENT
2273 ,p_module => l_log_module);
2274 END IF;
2275
2276 ----------------------------------------------------------------------------
2277 -- call routines to create accounting entries
2278 ----------------------------------------------------------------------------
2279 IF g_accounting_flag = 'Y' THEN
2280 IF (C_LEVEL_EVENT >= g_log_level) THEN
2281 trace
2282 (p_msg => 'Accounting process being called'
2283 ,p_level => C_LEVEL_EVENT
2284 ,p_module => l_log_module);
2285 END IF;
2286
2287 l_acct_begin_time := dbms_utility.get_time;
2288
2289 batch_accounting;
2290
2291 l_acct_end_time := dbms_utility.get_time;
2292
2293
2294 IF (C_LEVEL_EVENT >= g_log_level) THEN
2295 trace
2296 (p_msg => 'Accounting process completed'
2297 ,p_level => C_LEVEL_EVENT
2298 ,p_module => l_log_module);
2299 END IF;
2300 END IF;
2301
2302 ----------------------------------------------------------------------------
2303 -- call routines to perform 'Transfer to GL'
2304 ----------------------------------------------------------------------------
2305 IF ((g_transfer_flag = 'Y') AND (g_accounting_flag = 'N'))
2306 THEN
2307
2308 IF (C_LEVEL_EVENT >= g_log_level) THEN
2309 trace
2310 (p_msg => 'Transfer to GL process being called'
2311 ,p_level => C_LEVEL_EVENT
2312 ,p_module => l_log_module);
2313 END IF;
2314
2315 l_transfer_begin_time := dbms_utility.get_time;
2316
2317 xla_accounting_err_pkg.set_options
2318 (p_error_source => xla_accounting_err_pkg.C_TRANSFER_TO_GL);
2319
2320 l_transfer_mode := 'STANDALONE';
2321
2322 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2323 trace
2324 (p_msg => 'l_transfer_mode = '||l_transfer_mode
2325 ,p_level => C_LEVEL_STATEMENT
2326 ,p_module => l_log_module);
2327 END IF;
2328
2329 IF (C_LEVEL_EVENT >= g_log_level) THEN
2330 trace
2331 (p_msg => 'Calling transfer routine XLA_TRANSFER_PKG.GL_TRANSFER_MAIN'
2332 ,p_level => C_LEVEL_EVENT
2333 ,p_module => l_log_module);
2334 END IF;
2335
2336 --
2337 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Submitting the transfer to GL');
2338 xla_transfer_pkg.gl_transfer_main
2339 (p_application_id => g_application_id
2340 ,p_transfer_mode => l_transfer_mode
2341 ,p_ledger_id => g_ledger_id
2342 ,p_securiy_id_int_1 => g_security_id_int_1
2343 ,p_securiy_id_int_2 => g_security_id_int_2
2344 ,p_securiy_id_int_3 => g_security_id_int_3
2345 ,p_securiy_id_char_1 => g_security_id_char_1
2346 ,p_securiy_id_char_2 => g_security_id_char_2
2347 ,p_securiy_id_char_3 => g_security_id_char_3
2348 ,p_valuation_method => g_valuation_method
2349 ,p_process_category => g_process_category
2350 ,p_accounting_batch_id => g_accounting_batch_id
2351 ,p_entity_id => NULL
2352 ,p_batch_name => g_gl_batch_name
2353 ,p_end_date => g_end_date
2354 ,p_submit_gl_post => g_gl_posting_flag
2355 ,p_caller => xla_transfer_pkg.C_ACCTPROG_BATCH); -- Bug 5056632
2356
2357 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - End of the transfer to GL');
2358 IF (C_LEVEL_EVENT >= g_log_level) THEN
2359 trace
2360 (p_msg => 'Transfer routine XLA_TRANSFER_PKG.GL_TRANSFER_MAIN executed'
2361 ,p_level => C_LEVEL_EVENT
2362 ,p_module => l_log_module);
2363 END IF;
2364
2365 xla_accounting_err_pkg.set_options
2366 (p_error_source => xla_accounting_err_pkg.C_ACCT_PROGRAM);
2367
2368 l_transfer_end_time := dbms_utility.get_time;
2369
2370 IF (C_LEVEL_EVENT >= g_log_level) THEN
2371 trace
2372 (p_msg => 'Transfer to GL process completed'
2373 ,p_level => C_LEVEL_EVENT
2374 ,p_module => l_log_module);
2375 END IF;
2376 END IF;
2377
2378 -- FSAH-PSFT FP
2379 -- profile value XLA:Enable External Code Combination Validation
2380 if(fnd_profile.value('XLA_FSAH_EXT_CCID_VAL') IS NOT NULL) THEN
2381 IF ( nvl(fnd_profile.value('XLA_FSAH_EXT_CCID_VAL'),'N') = 'Y') THEN
2382
2383 l_xla_val_ccid_req_id:= fnd_request.submit_request
2384 (application => 'XLA'
2385 ,program => 'XLACCIDVAL'
2386 ,description => NULL
2387 ,start_time => NULL
2388 ,sub_request => FALSE
2389 ,argument1 => p_application_id
2390 ,argument2 => g_accounting_batch_id
2391 ,argument3 => p_ledger_id
2392 ,argument4 => g_parent_request_id
2393 );
2394
2395 IF l_xla_val_ccid_req_id = 0 THEN
2396 xla_accounting_err_pkg.build_message
2397 (p_appli_s_name => 'XLA'
2398 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
2399 ,p_token_1 => 'APPLICATION_NAME'
2400 ,p_value_1 => 'SLA'
2401 ,p_entity_id => NULL
2402 ,p_event_id => NULL);
2403
2404 print_logfile('Technical Error : Unable to submit java
2405 concurrent program request');
2406
2407 xla_exceptions_pkg.raise_message
2408 (p_appli_s_name => 'XLA'
2409 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
2410 ,p_token_1 => 'APPLICATION_NAME'
2411 ,p_value_1 => 'SLA');
2412 END IF;
2413
2414 END IF;
2415 COMMIT;
2416
2417 -------------------------------------------------------------------------
2418 -- wait for requests to complete
2419 -------------------------------------------------------------------------
2420 print_logfile(to_char(sysdate,'DD-MON-YYYY HH:MI:SS')||
2421 '- Waiting for Combo Edit Validation - parent requests to complete.');
2422 wait_for_combo_edit_req
2423 (p_request_id => l_xla_val_ccid_req_id
2424 ,p_error_status => l_error_status
2425 ,p_warning_status => l_warning_status);
2426 print_logfile(to_char(sysdate,'DD-MON-YYYY HH:MI:SS')||
2427 ' - Monitoring of Combo Edit Validation - parent requests completed.');
2428
2429 xla_accounting_err_pkg.insert_errors;
2430 END IF;
2431 -- FSAH-PSFT FP
2432 ----------------------------------------------------------------------------
2433 -- Handle postaccounting hook
2434 ----------------------------------------------------------------------------
2435 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - executing postaccounting hook');
2436 handle_accounting_hook
2437 (p_application_id => g_application_id
2438 ,p_ledger_id => g_ledger_id
2439 ,p_process_category => g_process_category
2440 ,p_end_date => g_end_date
2441 ,p_accounting_mode => g_accounting_mode
2442 ,p_budgetary_control_mode => g_budgetary_control_mode
2443 ,p_valuation_method => g_valuation_method
2444 ,p_security_id_int_1 => g_security_id_int_1
2445 ,p_security_id_int_2 => g_security_id_int_2
2446 ,p_security_id_int_3 => g_security_id_int_3
2447 ,p_security_id_char_1 => g_security_id_char_1
2448 ,p_security_id_char_2 => g_security_id_char_2
2449 ,p_security_id_char_3 => g_security_id_char_3
2450 ,p_report_request_id => g_report_request_id
2451 ,p_event_name => 'postaccounting'
2452 ,p_event_key => to_char(g_accounting_batch_id)||'-'
2453 ||to_char(g_parent_request_id));
2454 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - postaccounting hook executed successfully');
2455
2456 COMMIT;
2457 dbms_session.set_identifier(client_id => g_parent_request_id); -- added for bug11903966
2458 print_logfile('- Accounting Time = '||((l_acct_end_time - l_acct_begin_time)/100)||' secs');
2459 print_logfile('- Transfer Time = '||((l_transfer_end_time - l_transfer_begin_time)/100)||' secs');
2460
2461 IF (C_LEVEL_EVENT >= g_log_level) THEN
2462 trace
2463 (p_msg => 'COMMIT issued in the procedure EVENT_APPLICATION_MANAGER'
2464 ,p_level => C_LEVEL_EVENT
2465 ,p_module => l_log_module);
2466 END IF;
2467
2468 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2469 trace
2470 (p_msg => 'END of procedure EVENT_APPLICATION_MANAGER'
2471 ,p_level => C_LEVEL_PROCEDURE
2472 ,p_module => l_log_module);
2473 END IF;
2474 EXCEPTION
2475 WHEN normal_termination THEN
2476 RAISE;
2477 WHEN xla_exceptions_pkg.application_exception THEN
2478 RAISE;
2479 WHEN OTHERS THEN
2480 xla_accounting_err_pkg.build_message
2481 (p_appli_s_name => 'XLA'
2482 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
2483 ,p_token_1 => 'APPLICATION_NAME'
2484 ,p_value_1 => 'SLA'
2485 ,p_entity_id => NULL
2486 ,p_event_id => NULL);
2487 xla_exceptions_pkg.raise_message
2488 (p_location => 'xla_accounting_pkg.event_application_manager');
2489 END event_application_manager; -- end of procedure
2490
2491
2492 --=============================================================================
2493 --
2494 --
2495 --
2496 --=============================================================================
2497 PROCEDURE unit_processor_batch
2498 (p_errbuf OUT NOCOPY VARCHAR2
2499 ,p_retcode OUT NOCOPY NUMBER
2500 ,p_application_id IN NUMBER
2501 ,p_ledger_id IN NUMBER
2502 ,p_end_date IN VARCHAR2 -- Bug 5151844
2503 ,p_accounting_mode IN VARCHAR2
2504 ,p_error_only_flag IN VARCHAR2
2505 ,p_accounting_batch_id IN NUMBER
2506 ,p_parent_request_id IN NUMBER
2507 ,p_report_request_id IN NUMBER
2508 ,p_queue_name IN VARCHAR2
2509 ,p_comp_queue_name IN VARCHAR2
2510 ,p_error_limit IN NUMBER
2511 ,p_seq_enabled_flag IN VARCHAR2
2512 ,p_transfer_flag IN VARCHAR2
2513 ,p_gl_posting_flag IN VARCHAR2
2514 ,p_gl_batch_name IN VARCHAR2) IS -- Bug 5257343
2515
2516 l_log_module VARCHAR2(240);
2517
2518 BEGIN
2519 IF g_log_enabled THEN
2520 l_log_module := C_DEFAULT_MODULE||'.unit_processor_batch';
2521 END IF;
2522 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2523 trace
2524 (p_msg => 'BEGIN of procedure UNIT_PROCESSOR_BATCH'
2525 ,p_level => C_LEVEL_PROCEDURE
2526 ,p_module => l_log_module);
2527 trace
2528 (p_msg => 'p_application_id = '||p_application_id
2529 ,p_level => C_LEVEL_PROCEDURE
2530 ,p_module => l_log_module);
2531 trace
2532 (p_msg => 'p_ledger_id = '||p_ledger_id
2533 ,p_level => C_LEVEL_PROCEDURE
2534 ,p_module => l_log_module);
2535 trace
2536 (p_msg => 'p_end_date = '||p_end_date
2537 ,p_level => C_LEVEL_PROCEDURE
2538 ,p_module => l_log_module);
2539 trace
2540 (p_msg => 'p_accounting_mode = '||p_accounting_mode
2541 ,p_level => C_LEVEL_PROCEDURE
2542 ,p_module => l_log_module);
2543 trace
2544 (p_msg => 'p_error_only_flag = '||p_error_only_flag
2545 ,p_level => C_LEVEL_PROCEDURE
2546 ,p_module => l_log_module);
2547 trace
2548 (p_msg => 'p_accounting_batch_id = '||p_accounting_batch_id
2549 ,p_level => C_LEVEL_PROCEDURE
2550 ,p_module => l_log_module);
2551 trace
2552 (p_msg => 'p_parent_request_id = '||p_parent_request_id
2553 ,p_level => C_LEVEL_PROCEDURE
2554 ,p_module => l_log_module);
2555 trace
2556 (p_msg => 'p_report_request_id = '||p_report_request_id
2557 ,p_level => C_LEVEL_PROCEDURE
2558 ,p_module => l_log_module);
2559 trace
2560 (p_msg => 'p_queue_name = '||p_queue_name
2561 ,p_level => C_LEVEL_PROCEDURE
2562 ,p_module => l_log_module);
2563 trace
2564 (p_msg => 'p_comp_queue_name = '||p_comp_queue_name
2565 ,p_level => C_LEVEL_PROCEDURE
2566 ,p_module => l_log_module);
2567 trace
2568 (p_msg => 'p_error_limit = '||p_error_limit
2569 ,p_level => C_LEVEL_PROCEDURE
2570 ,p_module => l_log_module);
2571 trace
2572 (p_msg => 'p_seq_enabled_flag = '||p_seq_enabled_flag
2573 ,p_level => C_LEVEL_PROCEDURE
2574 ,p_module => l_log_module);
2575 trace
2576 (p_msg => 'p_gl_batch_name = '||p_gl_batch_name
2577 ,p_level => C_LEVEL_PROCEDURE
2578 ,p_module => l_log_module);
2579
2580 END IF;
2581
2582
2583 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Executing Unit Processor ...');
2584 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Initializing variables');
2585
2586 ----------------------------------------------------------------------------
2587 -- Initializing global variables
2588 ----------------------------------------------------------------------------
2589 g_application_id := p_application_id;
2590 g_ledger_id := p_ledger_id;
2591 g_end_date := to_date(p_end_date,'YYYY/MM/DD');
2592 g_accounting_mode := p_accounting_mode;
2593 g_accounting_batch_id := p_accounting_batch_id;
2594 g_parent_request_id := p_parent_request_id;
2595 g_report_request_id := p_report_request_id;
2596 g_queue_name := p_queue_name;
2597 g_comp_queue_name := p_comp_queue_name;
2598 g_error_limit := p_error_limit;
2599 g_seq_enabled_flag := p_seq_enabled_flag;
2600
2601 g_ep_reqid := fnd_global.conc_request_id;
2602 g_execution_mode := 'OFFLINE';
2603 g_processing_mode := 'BATCH';
2604 g_current_entity_id := NULL;
2605 g_transfer_flag := p_transfer_flag;
2606 g_gl_posting_flag := p_gl_posting_flag;
2607 g_gl_batch_name := p_gl_batch_name; -- Bug 5257343
2608
2609
2610 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2611 trace
2612 (p_msg => 'g_ep_reqid = '||g_ep_reqid
2613 ,p_level => C_LEVEL_STATEMENT
2614 ,p_module => l_log_module);
2615 trace
2616 (p_msg => 'g_execution_mode = '||g_execution_mode
2617 ,p_level => C_LEVEL_STATEMENT
2618 ,p_module => l_log_module);
2619 trace
2620 (p_msg => 'g_processing_mode = '||g_processing_mode
2621 ,p_level => C_LEVEL_STATEMENT
2622 ,p_module => l_log_module);
2623 END IF;
2624
2625 g_child_data.selected_entity_count := 0;
2626 g_child_data.dequeued_msg_count := 0;
2627 g_child_data.selected_event_count := 0;
2628
2629 ----------------------------------------------------------------------------
2630 -- Following sets the Security Context for the execution. This enables the
2631 -- the accounting program to respect the transaction security.
2632 ----------------------------------------------------------------------------
2633 xla_security_pkg.set_security_context(p_application_id);
2634
2635 IF (C_LEVEL_EVENT >= g_log_level) THEN
2636 trace
2637 (p_msg => 'Security_context set for application = '||p_application_id
2638 ,p_level => C_LEVEL_EVENT
2639 ,p_module => l_log_module);
2640 END IF;
2641
2642 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Security Context Set ');
2643
2644 ----------------------------------------------------------------------------
2645 -- Following sets the session's client identifier for the purpose of global
2646 -- application context.
2647 ----------------------------------------------------------------------------
2648 dbms_session.set_identifier
2649 (client_id => g_parent_request_id);
2650
2651 IF (C_LEVEL_EVENT >= g_log_level) THEN
2652 trace
2653 (p_msg => 'Session identifier set to = '||g_parent_request_id
2654 ,p_level => C_LEVEL_EVENT
2655 ,p_module => l_log_module);
2656 END IF;
2657
2658 ----------------------------------------------------------------------------
2659 -- Initializing error package
2660 ----------------------------------------------------------------------------
2661 xla_accounting_err_pkg.initialize
2662 (p_client_id => g_parent_request_id
2663 ,p_error_limit => g_error_limit
2664 ,p_error_source => xla_accounting_err_pkg.C_ACCT_ENGINE
2665 ,p_application_id => g_application_id);
2666
2667 ----------------------------------------------------------------------------
2668 -- Call the main accounting routine 'unit_processor'
2669 ----------------------------------------------------------------------------
2670 unit_processor;
2671
2672 ----------------------------------------------------------------------------
2673 -- 4645092 Set report request for MPA report
2674 ----------------------------------------------------------------------------
2675 IF g_mpa_accrual_exists = 'Y' THEN
2676 xla_context_pkg.set_mpa_accrual_context
2677 (p_mpa_accrual_exists => 'Y'
2678 ,p_client_id => g_report_request_id);
2679 END IF;
2680
2681 ----------------------------------------------------------------------------
2682 -- Following if conditioin is added to set the retcode to 1 when there are
2683 -- events with errors for that run of child thread in accounting program.
2684 -- (bug # 2709397)
2685 ----------------------------------------------------------------------------
2686
2687 --bug 7253269 condition included
2688 IF xla_accounting_err_pkg.g_error_count = 0 AND NOT XLA_ACCOUNTING_CACHE_PKG.g_hist_bflow_error_exists
2689 AND NOT XLA_AE_LINES_PKG.g_hist_reversal_error_exists AND NOT xla_accounting_cache_pkg.g_reversal_error THEN
2690 p_errbuf := 'Unit Processor completed normally';
2691 p_retcode := 0;
2692 ELSE
2693 p_errbuf := 'Unit Processor completed normally with some events in error';
2694 p_retcode := 1;
2695 END IF;
2696
2697
2698 COMMIT;
2699 IF (C_LEVEL_EVENT >= g_log_level) THEN
2700 trace
2701 (p_msg => 'COMMIT issued in the procedure UNIT_PROCESSOR_BATCH'
2702 ,p_level => C_LEVEL_EVENT
2703 ,p_module => l_log_module);
2704 END IF;
2705
2706 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Unit Processor completed successfully ...');
2707
2708 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2709 trace
2710 (p_msg => 'p_errbuf = '||p_errbuf
2711 ,p_level => C_LEVEL_PROCEDURE
2712 ,p_module => l_log_module);
2713 trace
2714 (p_msg => 'p_retcode = '||p_retcode
2715 ,p_level => C_LEVEL_PROCEDURE
2716 ,p_module => l_log_module);
2717 trace
2718 (p_msg => 'END of procedure UNIT_PROCESSOR_BATCH'
2719 ,p_level => C_LEVEL_PROCEDURE
2720 ,p_module => l_log_module);
2721 END IF;
2722
2723 EXCEPTION
2724 WHEN xla_exceptions_pkg.application_exception THEN
2725 ----------------------------------------------------------------------------
2726 -- Following stores the error message in the accounting log table
2727 ----------------------------------------------------------------------------
2728 p_errbuf := xla_messages_pkg.get_message;
2729 p_retcode := 2;
2730
2731 IF (C_LEVEL_ERROR >= g_log_level) THEN
2732 trace
2733 (p_msg => NULL
2734 ,p_level => C_LEVEL_ERROR
2735 ,p_module => l_log_module);
2736 END IF;
2737
2738 ROLLBACK;
2739
2740 IF (C_LEVEL_EVENT >= g_log_level) THEN
2741 trace
2742 (p_msg => 'ROLLBACK issued in the procedure UNIT_PROCESSOR_BATCH'
2743 ,p_level => C_LEVEL_EVENT
2744 ,p_module => l_log_module);
2745 END IF;
2746
2747
2748 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2749 trace
2750 (p_msg => 'p_errbuf = '||p_errbuf
2751 ,p_level => C_LEVEL_PROCEDURE
2752 ,p_module => l_log_module);
2753 trace
2754 (p_msg => 'p_retcode = '||p_retcode
2755 ,p_level => C_LEVEL_PROCEDURE
2756 ,p_module => l_log_module);
2757 trace
2758 (p_msg => 'END of procedure UNIT_PROCESSOR_BATCH'
2759 ,p_level => C_LEVEL_PROCEDURE
2760 ,p_module => l_log_module);
2761 END IF;
2762 WHEN OTHERS THEN
2763 ----------------------------------------------------------------------------
2764 -- Following stores the error message in the accounting log table
2765 ----------------------------------------------------------------------------
2766 IF SQLCODE = -25228 AND g_conc_hold = 'Y' /* Timeout; queue is likely empty... */
2767 THEN
2768 p_retcode := 1;
2769 ELSE
2770 p_retcode := 2;
2771 END IF;
2772
2773 p_errbuf := sqlerrm;
2774 IF (C_LEVEL_UNEXPECTED >= g_log_level) THEN
2775 trace
2776 (p_msg => NULL
2777 ,p_level => C_LEVEL_UNEXPECTED
2778 ,p_module => l_log_module);
2779 END IF;
2780
2781 ROLLBACK;
2782
2783 IF (C_LEVEL_EVENT >= g_log_level) THEN
2784 trace
2785 (p_msg => 'ROLLBACK issued in the procedure UNIT_PROCESSOR_BATCH'
2786 ,p_level => C_LEVEL_EVENT
2787 ,p_module => l_log_module);
2788 END IF;
2789
2790
2791 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2792 trace
2793 (p_msg => 'p_errbuf = '||p_errbuf
2794 ,p_level => C_LEVEL_PROCEDURE
2795 ,p_module => l_log_module);
2796 trace
2797 (p_msg => 'p_retcode = '||p_retcode
2798 ,p_level => C_LEVEL_PROCEDURE
2799 ,p_module => l_log_module);
2800 trace
2801 (p_msg => 'END of procedure UNIT_PROCESSOR_BATCH'
2802 ,p_level => C_LEVEL_PROCEDURE
2803 ,p_module => l_log_module);
2804 END IF;
2805 END unit_processor_batch; -- end of function
2806
2807 --=============================================================================
2808 --
2809 --
2810 --
2811 --=============================================================================
2812 PROCEDURE accounting_program_events
2813 (p_application_id IN INTEGER
2814 ,p_accounting_mode IN VARCHAR2
2815 ,p_gl_posting_flag IN VARCHAR2
2816 ,p_offline_flag IN VARCHAR2
2817 ,p_accounting_batch_id IN OUT NOCOPY INTEGER
2818 ,p_errbuf IN OUT NOCOPY VARCHAR2
2819 ,p_retcode IN OUT NOCOPY INTEGER)
2820 IS
2821 -- Retrieve any ledgers that does not enable budgetary control
2822 CURSOR c_invalid_bc_ledgers IS
2823 SELECT gl.ledger_id, gl.name ledger_name
2824 FROM xla_acct_prog_events_gt xpa
2825 , gl_ledgers gl
2826 WHERE xpa.ledger_id = gl.ledger_id
2827 AND enable_budgetary_control_flag = 'N'
2828 AND ROWNUM = 1;
2829
2830 -- Retrieve any ledgers that does not contains any JLD that indicates budgetary
2831 -- control validation
2832 CURSOR c_invalid_ledger_id IS
2833 SELECT xgl.ledger_id
2834 , xgl.name ledger_name
2835 , xam.name slam_name
2836 FROM xla_acct_prog_events_gt xap
2837 , xla_gl_ledgers_v xgl
2838 , xla_acctg_methods_tl xam
2839 , xla_acctg_method_rules xar
2840 , xla_aad_line_defn_assgns xal
2841 , xla_line_definitions_b xld
2842 WHERE xld.application_id(+) = xal.application_id
2843 AND xld.amb_context_code(+) = xal.amb_context_code
2844 AND xld.event_class_code(+) = xal.event_class_code
2845 AND xld.event_type_code(+) = xal.event_type_code
2846 AND xld.line_definition_owner_code(+) = xal.line_definition_owner_code
2847 AND xld.line_definition_code(+) = xal.line_definition_code
2848 AND xld.budgetary_control_flag(+) = 'Y'
2849 AND xal.application_id(+) = xar.application_id
2850 AND xal.amb_context_code(+) = xar.amb_context_code
2851 AND xal.product_rule_type_code(+) = xar.product_rule_type_code
2852 AND xal.product_rule_code(+) = xar.product_rule_code
2853 AND xar.accounting_method_type_code(+) = xgl.sla_accounting_method_type
2854 AND xar.accounting_method_code(+) = xgl.sla_accounting_method_code
2855 AND xar.application_id(+) = p_application_id
2856 AND xar.amb_context_code(+) = NVL(fnd_profile.value('XLA_AMB_CONTEXT'),'DEFAULT')
2857 AND xam.accounting_method_type_code(+) = xgl.sla_accounting_method_type
2858 AND xam.accounting_method_code(+) = xgl.sla_accounting_method_code
2859 AND xam.language(+) = USERENV('LANG')
2860 AND xgl.ledger_id = xap.ledger_id
2861 GROUP BY xgl.ledger_id
2862 , xgl.name
2863 , xam.name
2864 HAVING count(*) = 0;
2865
2866 CURSOR c_lock_entity_events IS
2867 SELECT /*+ LEADING (XAP) USE_NL (XAP XE XTE) */
2868 xe.event_id
2869 FROM xla_transaction_entities xte
2870 , xla_events xe
2871 , xla_acct_prog_events_gt xap
2872 WHERE xte.application_id = xe.application_id
2873 AND xte.entity_id = xe.entity_id
2874 AND xe.application_id = p_application_id
2875 AND xe.event_id = xap.event_id
2876 FOR UPDATE NOWAIT;
2877
2878 CURSOR c_entities IS
2879 SELECT distinct entity_id
2880 FROM xla_acct_prog_events_gt xap
2881 , xla_events xe
2882 WHERE xe.application_id = p_application_id
2883 AND xe.event_id = xap.event_id;
2884
2885 -- Retrieve list of ledgers to be processed
2886 CURSOR c_ledgers IS
2887 SELECT DISTINCT ledger_id
2888 FROM xla_acct_prog_events_gt;
2889
2890 i INTEGER;
2891 l_request_id INTEGER;
2892 l_array_event_id t_array_integer;
2893 l_ret_flag_bal_update BOOLEAN;
2894 l_transfer_mode VARCHAR2(30);
2895 l_event_source_info xla_events_pub_pkg.t_event_source_info;
2896
2897 l_log_module VARCHAR2(240);
2898 BEGIN
2899 IF g_log_enabled THEN
2900 l_log_module := C_DEFAULT_MODULE||'.accounting_program_events';
2901 END IF;
2902 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2903 trace
2904 (p_msg => 'BEGIN of procedure accounting_program_events'
2905 ,p_level => C_LEVEL_PROCEDURE
2906 ,p_module => l_log_module);
2907 trace
2908 (p_msg => 'p_application_id = '||p_application_id
2909 ,p_level => C_LEVEL_PROCEDURE
2910 ,p_module => l_log_module);
2911 trace
2912 (p_msg => 'p_accounting_mode = '||p_accounting_mode
2913 ,p_level => C_LEVEL_PROCEDURE
2914 ,p_module => l_log_module);
2915 trace
2916 (p_msg => 'p_gl_posting_flag = '||p_gl_posting_flag
2917 ,p_level => C_LEVEL_PROCEDURE
2918 ,p_module => l_log_module);
2919 trace
2920 (p_msg => 'p_offline_flag = '||p_offline_flag
2921 ,p_level => C_LEVEL_PROCEDURE
2922 ,p_module => l_log_module);
2923 END IF;
2924
2925 SAVEPOINT SP_EVENTS;
2926
2927 IF (C_LEVEL_EVENT >= g_log_level) THEN
2928 trace
2929 (p_msg => 'Established a savepoint SP_EVENTS'
2930 ,p_level => C_LEVEL_EVENT
2931 ,p_module => l_log_module);
2932 END IF;
2933
2934
2935 --
2936 -- Initializing errors package
2937 --
2938 xla_accounting_err_pkg.initialize
2939 (p_client_id => NULL
2940 ,p_error_limit => NULL
2941 ,p_error_source => xla_accounting_err_pkg.C_ACCT_PROGRAM
2942 ,p_application_id => p_application_id);
2943
2944 --
2945 -- If called with budgetary control mode, ensure all ledgers of the entity
2946 -- have budgetary control enabled.
2947 --
2948 IF (p_accounting_mode IN ('FUNDS_RESERVE', 'FUNDS_CHECK')) THEN
2949 IF (C_LEVEL_EVENT >= g_log_level) THEN
2950 trace
2951 (p_msg => 'BEGIN LOOP: XLA_AP_INVALID_BC_LEDGER'
2952 ,p_level => C_LEVEL_EVENT
2953 ,p_module => l_log_module);
2954 END IF;
2955
2956 FOR l_err IN c_invalid_bc_ledgers LOOP
2957 IF (C_LEVEL_ERROR >= g_log_level) THEN
2958 trace
2959 (p_msg => 'LOOP: Error XLA_AP_INVALID_BC_LEDGER - '||
2960 'ledger = '||l_err.ledger_name
2961 ,p_level => C_LEVEL_ERROR
2962 ,p_module => l_log_module);
2963 END IF;
2964
2965 xla_accounting_err_pkg.build_message
2966 (p_appli_s_name => 'XLA'
2967 ,p_msg_name => 'XLA_AP_INVALID_BC_LEDGER'
2968 ,p_token_1 => 'LEDGER_NAME'
2969 ,p_value_1 => l_err.ledger_name
2970 ,p_entity_id => NULL
2971 ,p_event_id => NULL);
2972 END LOOP;
2973
2974 IF (C_LEVEL_EVENT >= g_log_level) THEN
2975 trace
2976 (p_msg => 'END LOOP: XLA_AP_INVALID_BC_LEDGER'
2977 ,p_level => C_LEVEL_EVENT
2978 ,p_module => l_log_module);
2979 END IF;
2980
2981 IF (C_LEVEL_EVENT >= g_log_level) THEN
2982 trace
2983 (p_msg => 'BEGIN LOOP: XLA_AP_INVALID_LEDGER_JLD'
2984 ,p_level => C_LEVEL_EVENT
2985 ,p_module => l_log_module);
2986 END IF;
2987
2988 FOR l_err IN c_invalid_ledger_id LOOP
2989 IF (C_LEVEL_ERROR >= g_log_level) THEN
2990 trace
2991 (p_msg => 'LOOP: Error XLA_AP_INVALID_LEDGER_JLD - '||
2992 'slam = '||l_err.slam_name||
2993 ', ledger = '||l_err.ledger_name
2994 ,p_level => C_LEVEL_ERROR
2995 ,p_module => l_log_module);
2996 END IF;
2997
2998 xla_accounting_err_pkg.build_message
2999 (p_appli_s_name => 'XLA'
3000 ,p_msg_name => 'XLA_AP_INVALID_LEDGER_JLD'
3001 ,p_token_1 => 'SLAM_NAME'
3002 ,p_value_1 => l_err.slam_name
3003 ,p_token_2 => 'LEDGER_NAME'
3004 ,p_value_2 => l_err.ledger_name
3005 ,p_entity_id => NULL
3006 ,p_event_id => NULL);
3007 END LOOP;
3008
3009 IF (C_LEVEL_EVENT >= g_log_level) THEN
3010 trace
3011 (p_msg => 'END LOOP: XLA_AP_INVALID_LEDGER_JLD'
3012 ,p_level => C_LEVEL_EVENT
3013 ,p_module => l_log_module);
3014 END IF;
3015
3016 END IF;
3017
3018 g_application_id := p_application_id;
3019 g_processing_mode := 'DOCUMENT';
3020
3021 IF (p_accounting_mode = 'NONE') THEN
3022 g_accounting_mode := 'N';
3023 g_budgetary_control_mode := 'NONE';
3024 ELSIF (p_accounting_mode = 'FUNDS_RESERVE') THEN
3025 g_accounting_mode := 'F';
3026 g_budgetary_control_mode := p_accounting_mode;
3027 ELSIF (p_accounting_mode = 'FUNDS_CHECK') THEN
3028 g_accounting_mode := 'D';
3029 g_budgetary_control_mode := p_accounting_mode;
3030 ELSIF (p_accounting_mode = 'DRAFT') THEN
3031 g_accounting_mode := 'D';
3032 g_budgetary_control_mode := 'NONE';
3033 ELSE -- FINAL
3034 g_accounting_mode := 'F';
3035 g_budgetary_control_mode := 'NONE';
3036 END IF;
3037
3038 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3039 trace
3040 (p_msg => 'g_accounting_mode = '||g_accounting_mode
3041 ,p_level => C_LEVEL_STATEMENT
3042 ,p_module => l_log_module);
3043 trace
3044 (p_msg => 'g_budgetary_control_mode = '||g_budgetary_control_mode
3045 ,p_level => C_LEVEL_STATEMENT
3046 ,p_module => l_log_module);
3047 END IF;
3048
3049 ----------------------------------------------------------------------------
3050 -- Following sets the Security Context for the execution. This enables the
3051 -- the accounting program to respect the transaction security.
3052 ----------------------------------------------------------------------------
3053 xla_security_pkg.set_security_context(p_application_id);
3054
3055 IF (C_LEVEL_EVENT >= g_log_level) THEN
3056 trace
3057 (p_msg => 'Security_context set for application = '||p_application_id
3058 ,p_level => C_LEVEL_EVENT
3059 ,p_module => l_log_module);
3060 END IF;
3061
3062 --
3063 -- Lock all entity and events in xla_entity_events_v that exists in the
3064 -- xla_acct_prog_events_gt
3065 --
3066 OPEN c_lock_entity_events;
3067 FETCH c_lock_entity_events BULK COLLECT INTO l_array_event_id;
3068 CLOSE c_lock_entity_events;
3069
3070 --
3071 -- Following sets the session's client identifier for the purpose of global
3072 --
3073 -- application context.
3074 --
3075 SELECT xla_accounting_batches_s.nextval INTO p_accounting_batch_id FROM DUAL;
3076 g_accounting_batch_id := p_accounting_batch_id;
3077
3078 dbms_session.set_identifier
3079 (client_id => g_accounting_batch_id);
3080
3081 IF (g_accounting_mode ='F' AND g_budgetary_control_mode = 'NONE') THEN
3082 IF fnd_profile.value('XLA_BAL_PARALLEL_MODE') IS NULL THEN
3083 l_ret_flag_bal_update := xla_balances_pkg.massive_update_for_events
3084 (p_application_id => g_application_id);
3085
3086 IF (C_LEVEL_EVENT >= g_log_level) THEN
3087 trace
3088 (p_msg => 'Fucntion XLA_BALANCES_PKG.MASSIVE_UPDATE executed'
3089 ,p_level => C_LEVEL_EVENT
3090 ,p_module => l_log_module);
3091 END IF;
3092
3093 IF (C_LEVEL_EVENT >= g_log_level) THEN
3094 trace
3095 (p_msg => 'l_ret_flag_bal_update = '||CASE WHEN l_ret_flag_bal_update
3096 THEN 'TRUE'
3097 ELSE 'FALSE' END
3098 ,p_level => C_LEVEL_EVENT
3099 ,p_module => l_log_module);
3100 END IF;
3101
3102 IF NOT l_ret_flag_bal_update THEN
3103 xla_accounting_err_pkg.build_message
3104 (p_appli_s_name => 'XLA'
3105 ,p_msg_name => 'XLA_AP_BAL_UPDATE_FAILED'
3106 ,p_entity_id => NULL
3107 ,p_event_id => NULL);
3108
3109 print_logfile
3110 ('Technical problem : Problem in submitting request for balance update');
3111
3112 xla_exceptions_pkg.raise_message
3113 (p_appli_s_name => 'XLA'
3114 ,p_msg_name => 'XLA_AP_BAL_UPDATE_FAILED');
3115 ELSE
3116 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - request for balance calulation submitted');
3117 END IF;
3118 END IF;
3119 END IF;
3120
3121 --
3122 -- Delete the journal entries created for the events and entities to be processed
3123 --
3124
3125 IF (g_accounting_mode IN ('D','F')) THEN
3126 delete_batch_je;
3127
3128 FORALL i IN 1..l_array_event_id.COUNT
3129 UPDATE xla_events xe
3130 SET process_status_code = 'U'
3131 WHERE xe.on_hold_flag = 'N'
3132 AND xe.process_status_code <> 'P'
3133 AND xe.event_type_code not in ('FULL_MERGE', 'PARTIAL_MERGE')
3134 AND xe.event_id = l_array_event_id(i);
3135 END IF;
3136
3137 --
3138 -- Process the events by ledger
3139 --
3140 IF (C_LEVEL_EVENT >= g_log_level) THEN
3141 trace
3142 (p_msg => 'BEGIN LOOP: loop ledger'
3143 ,p_level => C_LEVEL_EVENT
3144 ,p_module => l_log_module);
3145 END IF;
3146
3147 FOR l_ledger IN c_ledgers LOOP
3148 IF (C_LEVEL_EVENT >= g_log_level) THEN
3149 trace
3150 (p_msg => 'LOOP: ledger_id = '||l_ledger.ledger_id
3151 ,p_level => C_LEVEL_EVENT
3152 ,p_module => l_log_module);
3153 trace
3154 (p_msg => 'g_accounting_mode = '||g_accounting_mode
3155 ,p_level => C_LEVEL_EVENT
3156 ,p_module => l_log_module);
3157 END IF;
3158
3159 g_ledger_id := l_ledger.ledger_id;
3160
3161
3162 IF (g_accounting_mode IN ('D','F')) THEN
3163
3164 -- 7193986 start
3165
3166 FOR x IN (
3167 SELECT DISTINCT xla_evt_class_orders_gt.processing_order
3168 FROM xla_acct_prog_events_gt ,
3169 xla_events ,
3170 xla_event_types_b ,
3171 xla_transaction_entities,
3172 xla_evt_class_orders_gt
3173 WHERE xla_events.event_id = xla_acct_prog_events_gt.event_id
3174 AND xla_events.application_id = p_application_id
3175 AND xla_transaction_entities.application_id = p_application_id
3176 AND xla_events.entity_id = xla_transaction_entities.entity_id
3177 AND xla_event_types_b.application_id = p_application_id
3178 AND xla_transaction_entities.entity_code = xla_event_types_b.entity_code
3179 AND xla_events.event_type_code = xla_event_types_b.event_type_code
3180 AND xla_event_types_b.event_class_code = xla_evt_class_orders_gt.event_class_code
3181 AND xla_events.process_status_code <> 'P' --condition added, bug8680284
3182 ORDER BY xla_evt_class_orders_gt.processing_order ASC)
3183 LOOP
3184
3185 IF (C_LEVEL_EVENT >= g_log_level) THEN
3186 trace
3187 (p_msg => 'BEGIN LOOP: event processor for order = ' || x.processing_order
3188 ,p_level => C_LEVEL_EVENT
3189 ,p_module => l_log_module);
3190 END IF;
3191
3192 events_processor (x.processing_order);
3193
3194 IF (C_LEVEL_EVENT >= g_log_level) THEN
3195 trace
3196 (p_msg => 'END LOOP: event processor for order = ' || x.processing_order
3197 ,p_level => C_LEVEL_EVENT
3198 ,p_module => l_log_module);
3199 END IF;
3200
3201 END LOOP;
3202
3203
3204 -- 7193986 end
3205
3206
3207 IF (g_accounting_mode = 'F' AND g_budgetary_control_mode = 'NONE') THEN
3208 IF fnd_profile.value('XLA_BAL_PARALLEL_MODE') IS NULL THEN
3209 l_ret_flag_bal_update := xla_balances_pkg.massive_update
3210 (p_application_id => g_application_id
3211 ,p_ledger_id => NULL
3212 ,p_entity_id => NULL
3213 ,p_event_id => NULL
3214 ,p_request_id => NULL
3215 ,p_accounting_batch_id => g_accounting_batch_id
3216 ,p_update_mode => 'A'
3217 ,p_execution_mode => 'O');
3218 ELSE
3219 l_ret_flag_bal_update := xla_balances_calc_pkg.massive_update
3220 (p_application_id => g_application_id
3221 ,p_ledger_id => g_ledger_id
3222 ,p_entity_id => NULL
3223 ,p_event_id => NULL
3224 ,p_request_id => NULL
3225 ,p_accounting_batch_id => g_accounting_batch_id
3226 ,p_update_mode => 'A'
3227 ,p_execution_mode => 'O');
3228 END IF;
3229
3230 IF (C_LEVEL_EVENT >= g_log_level) THEN
3231 trace
3232 (p_msg => 'l_ret_flag_bal_update = '||CASE WHEN l_ret_flag_bal_update
3233 THEN 'TRUE'
3234 ELSE 'FALSE' END
3235 ,p_level => C_LEVEL_EVENT
3236 ,p_module => l_log_module);
3237 END IF;
3238
3239 IF NOT l_ret_flag_bal_update THEN
3240 --bug 11666797
3241 /*xla_accounting_err_pkg.build_message
3242 (p_appli_s_name => 'XLA'
3243 ,p_msg_name => 'XLA_AP_BAL_UPDATE_FAILED'
3244 ,p_entity_id => NULL
3245 ,p_event_id => NULL);*/
3246
3247 /*print_logfile
3248 ('Technical problem : Problem in submitting request for balance update');*/
3249 NULL;
3250
3251 /*xla_exceptions_pkg.raise_message
3252 (p_appli_s_name => 'XLA'
3253 ,p_msg_name => 'XLA_AP_BAL_UPDATE_FAILED');*/
3254 ELSE
3255 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - request for balance calulation submitted');
3256 END IF;
3257 END IF;
3258 END IF;
3259
3260 --
3261 -- Call transfer to GL if requested
3262 --
3263 IF (p_gl_posting_flag = 'Y' AND
3264 g_accounting_mode IN ('F', 'N')) THEN
3265
3266 IF (C_LEVEL_EVENT >= g_log_level) THEN
3267 trace
3268 (p_msg => 'Transfer to GL process being called'
3269 ,p_level => C_LEVEL_EVENT
3270 ,p_module => l_log_module);
3271 END IF;
3272
3273 IF p_offline_flag = 'Y' THEN
3274
3275 xla_accounting_err_pkg.set_options
3276 (p_error_source => xla_accounting_err_pkg.C_TRANSFER_TO_GL);
3277
3278 IF p_accounting_mode = 'NONE' THEN
3279 l_transfer_mode := 'STANDALONE';
3280 ELSE
3281 l_transfer_mode := 'COMBINED';
3282 END IF;
3283
3284 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3285 trace
3286 (p_msg => 'l_transfer_mode = '||l_transfer_mode
3287 ,p_level => C_LEVEL_STATEMENT
3288 ,p_module => l_log_module);
3289 END IF;
3290
3291 IF (C_LEVEL_EVENT >= g_log_level) THEN
3292 trace
3293 (p_msg => 'Calling transfer routine XLA_TRANSFER_PKG.GL_TRANSFER_MAIN'
3294 ,p_level => C_LEVEL_EVENT
3295 ,p_module => l_log_module);
3296 END IF;
3297
3298 FOR l in c_entities LOOP
3299 xla_transfer_pkg.gl_transfer_main
3300 (p_application_id => p_application_id
3301 ,p_transfer_mode => l_transfer_mode
3302 ,p_ledger_id => g_ledger_id
3303 ,p_securiy_id_int_1 => NULL
3304 ,p_securiy_id_int_2 => NULL
3305 ,p_securiy_id_int_3 => NULL
3306 ,p_securiy_id_char_1 => NULL
3307 ,p_securiy_id_char_2 => NULL
3308 ,p_securiy_id_char_3 => NULL
3309 ,p_valuation_method => NULL
3310 ,p_process_category => NULL
3311 ,p_accounting_batch_id => g_accounting_batch_id
3312 ,p_entity_id => l.entity_id
3313 ,p_batch_name => NULL
3314 ,p_end_date => NULL
3315 ,p_submit_gl_post => 'Y'
3316 ,p_caller => xla_transfer_pkg.C_ACCTPROG_DOCUMENT); -- Bug 5056632
3317 END LOOP;
3318
3319 IF (C_LEVEL_EVENT >= g_log_level) THEN
3320 trace
3321 (p_msg => 'Transfer routine XLA_TRANSFER_PKG.GL_TRANSFER_MAIN executed'
3322 ,p_level => C_LEVEL_EVENT
3323 ,p_module => l_log_module);
3324 END IF;
3325
3326 xla_accounting_err_pkg.set_options
3327 (p_error_source => xla_accounting_err_pkg.C_ACCT_PROGRAM);
3328 ELSE
3329 IF (C_LEVEL_EVENT >= g_log_level) THEN
3330 trace
3331 (p_msg => 'Calling XLA_ACCOUNTING_PUB_PKG.ACCOUNTING_PROGRAM_DOCUMENT '||
3332 'to submit concurrent request for the transfer'
3333 ,p_level => C_LEVEL_EVENT
3334 ,p_module => l_log_module);
3335 END IF;
3336
3337 l_event_source_info.application_id := p_application_id;
3338 FOR l in c_entities LOOP
3339 xla_accounting_pub_pkg.accounting_program_document
3340 (p_event_source_info => l_event_source_info
3341 ,p_entity_id => l.entity_id
3342 ,p_accounting_flag => 'N'
3343 ,p_accounting_mode => NULL
3344 ,p_transfer_flag => 'Y'
3345 ,p_gl_posting_flag => 'Y'
3346 ,p_offline_flag => 'Y'
3347 ,p_accounting_batch_id => p_accounting_batch_id
3348 ,p_errbuf => p_errbuf
3349 ,p_retcode => p_retcode
3350 ,p_request_id => l_request_id);
3351 END LOOP;
3352
3353 END IF;
3354 END IF;
3355
3356 END LOOP;
3357
3358 IF (C_LEVEL_EVENT >= g_log_level) THEN
3359 trace
3360 (p_msg => 'END LOOP: loop ledger'
3361 ,p_level => C_LEVEL_EVENT
3362 ,p_module => l_log_module);
3363 END IF;
3364
3365
3366 --
3367 -- Insert errors
3368 --
3369 xla_accounting_err_pkg.insert_errors;
3370
3371 IF xla_accounting_err_pkg.g_error_count-xla_accounting_err_pkg.g_warning_count = 0 THEN
3372 p_retcode := 0;
3373 p_errbuf := 'Accounting Program completed Normal';
3374 ELSE
3375 p_retcode := 1;
3376 p_errbuf := 'Accounting Program completed Normal with some events in error';
3377 END IF;
3378
3379 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3380 trace
3381 (p_msg => 'p_errbuf = '||p_errbuf
3382 ,p_level => C_LEVEL_PROCEDURE
3383 ,p_module => l_log_module);
3384 trace
3385 (p_msg => 'p_retcode = '||p_retcode
3386 ,p_level => C_LEVEL_PROCEDURE
3387 ,p_module => l_log_module);
3388 trace
3389 (p_msg => 'END of procedure accounting_program_events'
3390 ,p_level => C_LEVEL_PROCEDURE
3391 ,p_module => l_log_module);
3392 END IF;
3393 EXCEPTION
3394 WHEN xla_exceptions_pkg.application_exception THEN
3395 ----------------------------------------------------------------------------
3396 -- set out variables
3397 ----------------------------------------------------------------------------
3398 p_accounting_batch_id := g_accounting_batch_id;
3399 p_retcode := 2;
3400 p_errbuf := xla_messages_pkg.get_message;
3401
3402 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3403 trace
3404 (p_msg => p_errbuf
3405 ,p_level => C_LEVEL_EVENT
3406 ,p_module => l_log_module);
3407 END IF;
3408
3409 ROLLBACK TO SP_EVENTS;
3410
3411 IF (C_LEVEL_EVENT >= g_log_level) THEN
3412 trace
3413 (p_msg => 'ROLLBACK issued in the procedure accounting_program_events'
3414 ,p_level => C_LEVEL_EVENT
3415 ,p_module => l_log_module);
3416 END IF;
3417
3418 xla_accounting_err_pkg.insert_errors;
3419
3420 WHEN OTHERS THEN
3421 ----------------------------------------------------------------------------
3422 -- set out variables
3423 ----------------------------------------------------------------------------
3424 p_accounting_batch_id := g_accounting_batch_id;
3425 p_retcode := 2;
3426 p_errbuf := sqlerrm;
3427
3428 IF (C_LEVEL_ERROR >= g_log_level) THEN
3429 trace
3430 (p_msg => NULL
3431 ,p_level => C_LEVEL_ERROR
3432 ,p_module => l_log_module);
3433 END IF;
3434
3435 ROLLBACK TO SP_EVENTS;
3436
3437 IF (C_LEVEL_EVENT >= g_log_level) THEN
3438 trace
3439 (p_msg => 'ROLLBACK issued in the procedure accounting_program_events'
3440 ,p_level => C_LEVEL_EVENT
3441 ,p_module => l_log_module);
3442 END IF;
3443
3444 xla_accounting_err_pkg.insert_errors;
3445
3446 END accounting_program_events; -- end of procedure
3447
3448 --=============================================================================
3449 --
3450 --
3451 --
3452 --
3453 --
3454 --
3455 --
3456 --
3457 --
3458 --
3459 -- Following routines are used while accounting for a document
3460 --
3461 -- 1. accounting_program_document (procedure)
3462 --
3463 --
3464 --
3465 --
3466 --
3467 --
3468 --
3469 --
3470 --
3471 --
3472 --
3473 --=============================================================================
3474 --=============================================================================
3475 --
3476 --
3477 --
3478 --=============================================================================
3479 PROCEDURE accounting_program_document
3480 (p_application_id IN INTEGER
3481 ,p_entity_id IN NUMBER
3482 ,p_accounting_flag IN VARCHAR2 DEFAULT 'Y'
3483 ,p_accounting_mode IN VARCHAR2
3484 ,p_gl_posting_flag IN VARCHAR2
3485 ,p_offline_flag IN VARCHAR2
3486 ,p_accounting_batch_id OUT NOCOPY NUMBER
3487 ,p_errbuf OUT NOCOPY VARCHAR2
3488 ,p_retcode OUT NOCOPY NUMBER) IS
3489 l_log_module VARCHAR2(240);
3490 BEGIN
3491 IF g_log_enabled THEN
3492 l_log_module := C_DEFAULT_MODULE||'.accounting_program_document';
3493 END IF;
3494 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3495 trace
3496 (p_msg => 'BEGIN of procedure ACCOUNTING_PROGRAM_DOCUMENT'
3497 ,p_level => C_LEVEL_PROCEDURE
3498 ,p_module => l_log_module);
3499 END IF;
3500
3501 -- Bug 7560116 Journal Import not getting spawned as Security Context is not getting set correctly when
3502 -- this procedure is called directly to perform GL xfer
3503 xla_security_pkg.set_security_context(p_application_id);
3504
3505
3506 INSERT INTO xla_acct_prog_events_gt (event_id, ledger_id)
3507 SELECT xe.event_id, xte.ledger_id
3508 FROM xla_events xe
3509 , xla_transaction_entities xte
3510 WHERE xte.application_id = p_application_id
3511 AND xte.entity_id = p_entity_id
3512 AND xe.application_id = p_application_id
3513 AND xe.entity_id = p_entity_id
3514 AND (p_accounting_flag = 'N' OR
3515 NVL(xe.budgetary_control_flag,'N') = DECODE(p_accounting_mode
3516 ,'D','N'
3517 ,'F','N'
3518 ,'Y'));
3519
3520
3521
3522 -- 7193986 start
3523
3524
3525 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3526 trace
3527 (p_msg => 'Rows inserted into xla_acct_prog_events_gt = '||SQL%ROWCOUNT
3528 ,p_level => C_LEVEL_STATEMENT
3529 ,p_module => l_log_module);
3530 END IF;
3531
3532
3533 INSERT INTO xla_evt_class_orders_gt
3534 (event_class_code
3535 ,processing_order
3536 )
3537 SELECT xec.event_class_code
3538 , NVL(t.max_level, -1)
3539 FROM xla_event_classes_b xec
3540 , (SELECT application_id, event_class_code, max(LEVEL) AS max_level
3541 FROM (SELECT application_id, event_class_code, prior_event_class_code
3542 FROM xla_event_class_predecs
3543 WHERE application_id = p_application_id
3544 UNION
3545 SELECT application_id, prior_event_class_code, NULL
3546 FROM xla_event_class_predecs
3547 WHERE application_id = p_application_id) xep
3548 CONNECT BY application_id = PRIOR application_id
3549 AND prior_event_class_code = PRIOR event_class_code
3550 GROUP BY application_id, event_class_code) t
3551 WHERE xec.event_class_code = t.event_class_code(+)
3552 AND xec.application_id = t.application_id(+)
3553 AND xec.application_id = p_application_id
3554 AND xec.event_class_code <> 'MANUAL';
3555
3556
3557 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3558 trace
3559 (p_msg => 'Number of rows inserted into xla_evt_class_orders_gt = '||SQL%ROWCOUNT
3560 ,p_level => C_LEVEL_STATEMENT
3561 ,p_module => l_log_module);
3562 END IF;
3563
3564 -- 7193986 end
3565
3566
3567
3568
3569 xla_accounting_pkg.accounting_program_events
3570 (p_application_id => p_application_id
3571 ,p_accounting_mode => CASE WHEN p_accounting_flag = 'N'
3572 THEN 'NONE'
3573 WHEN p_accounting_mode = 'D'
3574 THEN 'DRAFT'
3575 when p_accounting_mode = 'F'
3576 THEN 'FINAL'
3577 ELSE p_accounting_mode END
3578 ,p_gl_posting_flag => p_gl_posting_flag
3579 ,p_offline_flag => p_offline_flag
3580 ,p_accounting_batch_id => p_accounting_batch_id
3581 ,p_errbuf => p_errbuf
3582 ,p_retcode => p_retcode);
3583
3584 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3585 trace
3586 (p_msg => 'END of procedure ACCOUNTING_PROGRAM_DOCUMENT'
3587 ,p_level => C_LEVEL_PROCEDURE
3588 ,p_module => l_log_module);
3589 END IF;
3590 EXCEPTION
3591 WHEN xla_exceptions_pkg.application_exception THEN
3592 RAISE;
3593 WHEN OTHERS THEN
3594 xla_exceptions_pkg.raise_message
3595 (p_location => 'xla_accounting_pkg.accounting_program_document');
3596 END accounting_program_document; -- end of procedure
3597
3598
3599 --=============================================================================
3600 -- *********** private procedures and functions **********
3601 --=============================================================================
3602 --=============================================================================
3603 --
3604 --
3605 --
3606 --
3607 --
3608 --
3609 --
3610 --
3611 --
3612 --
3613 -- Following routines are used while accounting for batch of documents
3614 --
3615 -- 1. batch_accounting
3616 -- 2. pre_accounting
3617 -- 3. delete_request_je
3618 -- 4. post_accounting
3619 -- 5. enqueue_messages
3620 -- 6. spawn_child_processes
3621 -- 7. wait_for_requests
3622 -- 8. unit_processor
3623 -- 9. is_parent_running
3624 -- 10. sequencing_batch_init
3625 -- 11. process_events
3626 --
3627 --
3628 --
3629 --
3630 --
3631 --
3632 --
3633 --
3634 --
3635 --
3636 --
3637 --=============================================================================
3638
3639 --=============================================================================
3640 --
3641 --
3642 --
3643 --=============================================================================
3644 PROCEDURE batch_accounting IS
3645 l_pre_processing_str VARCHAR2(2000);
3646
3647
3648
3649 l_seq_api_called_flag VARCHAR2(1) := 'N';
3650
3651 l_ret_flag_bal_reversal BOOLEAN := FALSE;
3652 l_ret_flag_bal_update BOOLEAN := FALSE;
3653
3654 l_str_lock_entities VARCHAR2(2000);
3655 l_str_update_events VARCHAR2(2000);
3656
3657 l_error_status VARCHAR2(1) := 'N';
3658 l_warning_status VARCHAR2(1) := 'N';
3659 l_log_module VARCHAR2(240);
3660
3661 l_acct_batch_entries NUMBER;
3662
3663
3664 BEGIN
3665 IF g_log_enabled THEN
3666 l_log_module := C_DEFAULT_MODULE||'.batch_accounting';
3667 END IF;
3668 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3669 trace
3670 (p_msg => 'BEGIN of procedure BATCH_ACCOUNTING'
3671 ,p_level => C_LEVEL_PROCEDURE
3672 ,p_module => l_log_module);
3673 END IF;
3674
3675 -------------------------------------------------------------------------
3676 -- Reading setup options for the event application and the ledger
3677 -------------------------------------------------------------------------
3678 BEGIN
3679
3680 SELECT xso.error_limit
3681 ,NVL(xso.processes,1)
3682 ,NVL(xso.processing_unit_size,1)
3683 INTO g_error_limit
3684 ,g_process_count
3685 ,g_unit_size
3686 FROM xla_subledger_options_v xso
3687 WHERE xso.application_id = g_application_id
3688 AND xso.ledger_id = g_ledger_id;
3689
3690 EXCEPTION
3691 WHEN NO_DATA_FOUND THEN
3692 xla_exceptions_pkg.raise_message
3693 (p_appli_s_name => 'XLA'
3694 ,p_msg_name => 'XLA_COMMON_ERROR'
3695 ,p_token_1 => 'ERROR'
3696 ,p_value_1 => 'ERROR: Subledger Accounting Options are not defined for this ledger and application.'||
3697 'Please run Update Subledger Accounting Options program for your application.'
3698 ,p_token_2 => 'LOCATION'
3699 ,p_value_2 => 'xla_accounting_pkg.batch_accounting');
3700 END;
3701
3702 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3703 trace
3704 (p_msg => 'g_error_limit = '||g_error_limit
3705 ,p_level => C_LEVEL_STATEMENT
3706 ,p_module => l_log_module);
3707 trace
3708 (p_msg => 'g_process_count = '||g_process_count
3709 ,p_level => C_LEVEL_STATEMENT
3710 ,p_module => l_log_module);
3711 trace
3712 (p_msg => 'g_unit_size = '||g_unit_size
3713 ,p_level => C_LEVEL_STATEMENT
3714 ,p_module => l_log_module);
3715 END IF;
3716
3717 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Setup for the ledger and Event applications Read');
3718
3719 ----------------------------------------------------------------------------
3720 -- perform pre-accounting steps
3721 ----------------------------------------------------------------------------
3722 pre_accounting();
3723 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Pre-Accounting steps performed');
3724
3725 ----------------------------------------------------------------------------
3726 -- initialize queue for loading documents and completion message
3727 ----------------------------------------------------------------------------
3728 IF (C_LEVEL_EVENT >= g_log_level) THEN
3729 trace
3730 (p_msg => 'Creating message queue'
3731 ,p_level => C_LEVEL_EVENT
3732 ,p_module => l_log_module);
3733 END IF;
3734
3735 dbms_aqadm.create_queue
3736 (queue_name => g_queue_name
3737 ,queue_table => g_queue_table_name); --C_QUEUE_TABLE);
3738 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue Created = '||g_queue_name);
3739
3740 dbms_aqadm.create_queue
3741 (queue_name => g_comp_queue_name
3742 ,queue_table => g_queue_table_name); --C_QUEUE_TABLE);
3743 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue Created = '||g_comp_queue_name);
3744
3745 g_queue_created_flag := 'Y';
3746
3747 IF (C_LEVEL_EVENT >= g_log_level) THEN
3748 trace
3749 (p_msg => 'Message queue created'
3750 ,p_level => C_LEVEL_EVENT
3751 ,p_module => l_log_module);
3752 trace
3753 (p_msg => 'Starting Message queue'
3754 ,p_level => C_LEVEL_EVENT
3755 ,p_module => l_log_module);
3756 END IF;
3757
3758 dbms_aqadm.start_queue
3759 (queue_name => g_queue_name);
3760 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue Started = '||g_queue_name);
3761
3762 dbms_aqadm.start_queue
3763 (queue_name => g_comp_queue_name);
3764 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue Started = '||g_comp_queue_name);
3765
3766 g_queue_started_flag := 'Y';
3767
3768 IF (C_LEVEL_EVENT >= g_log_level) THEN
3769 trace
3770 (p_msg => 'Message queue started'
3771 ,p_level => C_LEVEL_EVENT
3772 ,p_module => l_log_module);
3773 END IF;
3774 ----------------------------------------------------------------------------
3775 -- Initialize the error count in the Global Application Context
3776 -- (for keeping error count accross multiple child processes)
3777 -- The context is set in context of "parent request id" which is same as
3778 -- "sys_context('USERENV','CLIENT_IDENTIFIER').
3779 ----------------------------------------------------------------------------
3780 xla_context_pkg.set_acct_err_context
3781 (p_error_count => 0
3782 ,p_client_id => g_parent_request_id);
3783
3784 xla_context_pkg.set_event_count_context
3785 (p_event_count => 0
3786 ,p_client_id => g_parent_request_id);
3787
3788 xla_context_pkg.set_event_nohdr_context
3789 (p_nohdr_extract_flag => 'N'
3790 ,p_client_id => g_parent_request_id);
3791
3792 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Global Context Initialized');
3793
3794 ----------------------------------------------------------------------------
3795 -- Call sequencing routine batch_init in FINAL accounting
3796 ----------------------------------------------------------------------------
3797 IF g_accounting_mode = 'F' THEN
3798 sequencing_batch_init
3799 (p_seq_enabled_flag => g_seq_enabled_flag);
3800 l_seq_api_called_flag := 'Y';
3801 END IF;
3802
3803 dbms_session.set_identifier(client_id => g_parent_request_id); -- added for bug11903966
3804 ----------------------------------------------------------------------------
3805 -- enqueue messages in the queue
3806 ----------------------------------------------------------------------------
3807 --enqueue_messages;
3808 process_events;
3809
3810 ----------------------------------------------------------------------------
3811 -- Check and wait for Event Processors to complete
3812 ----------------------------------------------------------------------------
3813 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Waiting for Unit Processor requests to complete');
3814 wait_for_requests
3815 (p_array_request_id => g_ep_request_ids
3816 ,p_error_status => l_error_status
3817 ,p_warning_status => l_warning_status);
3818 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Child Threads completed');
3819
3820 ----------------------------------------------------------------------------
3821 -- calling post-accounting
3822 ----------------------------------------------------------------------------
3823 -- Bug 8282549 modified the call to pass g_queue_started_flag and g_queue_created_flag
3824 post_accounting
3825 (p_queue_started_flag => g_queue_started_flag
3826 ,p_queue_created_flag => g_queue_created_flag
3827 ,p_seq_api_called_flag => l_seq_api_called_flag);
3828
3829 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Executed post-accounting routine');
3830
3831 IF ((g_error_limit IS NOT NULL) AND
3832 (g_total_error_count >= g_error_limit)
3833 )
3834 THEN
3835 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Message: The error limit defined in the setups was reached for this application');
3836
3837 -- Bug 2742357. Print the message in the report also
3838 xla_accounting_err_pkg.build_message
3839 (p_appli_s_name => 'XLA'
3840 ,p_msg_name => 'XLA_AP_ERROR_LIMIT'
3841 ,p_entity_id => NULL
3842 ,p_event_id => NULL);
3843
3844
3845 END IF;
3846
3847 COMMIT;
3848
3849 IF (C_LEVEL_EVENT >= g_log_level) THEN
3850 trace
3851 (p_msg => 'COMMIT issued in BATCH_ACCOUNTING'
3852 ,p_level => C_LEVEL_EVENT
3853 ,p_module => l_log_module);
3854 END IF;
3855
3856 ----------------------------------------------------------------------------
3857 -- Call massive update only if there is any valid entry
3858 -- Bug 5065965. Modified the following sql for performance.
3859 ----------------------------------------------------------------------------
3860 SELECT COUNT(1) INTO l_acct_batch_entries FROM DUAL
3861 WHERE EXISTS
3862 (SELECT 'Y'
3863 FROM xla_events
3864 WHERE application_id = g_application_id
3865 AND request_id = g_report_request_id
3866 AND process_status_code IN ('P')
3867 );
3868
3869 IF (l_acct_batch_entries > 0) THEN
3870 IF fnd_profile.value('XLA_BAL_PARALLEL_MODE') IS NULL THEN
3871 IF (C_LEVEL_EVENT >= g_log_level) THEN
3872 trace
3873 (p_msg => 'Calling function XLA_BALANCES_PKG.MASSIVE_UPDATE'
3874 ,p_level => C_LEVEL_EVENT
3875 ,p_module => l_log_module);
3876 END IF;
3877
3878 l_ret_flag_bal_update :=
3879 xla_balances_pkg.massive_update
3880 (p_application_id => g_application_id --NULL
3881 ,p_ledger_id => NULL
3882 ,p_entity_id => NULL
3883 ,p_event_id => NULL
3884 ,p_request_id => NULL
3885 ,p_accounting_batch_id => g_accounting_batch_id
3886 ,p_update_mode => 'A'
3887 ,p_execution_mode => 'C');
3888
3889 IF (C_LEVEL_EVENT >= g_log_level) THEN
3890 trace
3891 (p_msg => 'Fucntion XLA_BALANCES_PKG.MASSIVE_UPDATE executed'
3892 ,p_level => C_LEVEL_EVENT
3893 ,p_module => l_log_module);
3894 END IF;
3895 ELSE
3896 IF (C_LEVEL_EVENT >= g_log_level) THEN
3897 trace
3898 (p_msg => 'Calling function xla_balances_calc_pkg.MASSIVE_UPDATE'
3899 ,p_level => C_LEVEL_EVENT
3900 ,p_module => l_log_module);
3901 END IF;
3902
3903 l_ret_flag_bal_update :=
3904 xla_balances_calc_pkg.massive_update
3905 (p_application_id => g_application_id --NULL
3906 ,p_ledger_id => g_ledger_id
3907 ,p_entity_id => NULL
3908 ,p_event_id => NULL
3909 ,p_request_id => NULL
3910 ,p_accounting_batch_id => g_accounting_batch_id
3911 ,p_update_mode => 'A'
3912 ,p_execution_mode => 'C');
3913
3914 IF (C_LEVEL_EVENT >= g_log_level) THEN
3915 trace
3916 (p_msg => 'Fucntion xla_balances_calc_pkg.MASSIVE_UPDATE executed'
3917 ,p_level => C_LEVEL_EVENT
3918 ,p_module => l_log_module);
3919 END IF;
3920 END IF;
3921
3922
3923 IF NOT l_ret_flag_bal_update THEN
3924 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3925 trace
3926 (p_msg => 'l_ret_flag_bal_update = FALSE'
3927 ,p_level => C_LEVEL_STATEMENT
3928 ,p_module => l_log_module);
3929 END IF;
3930
3931 xla_accounting_err_pkg.build_message
3932 (p_appli_s_name => 'XLA'
3933 ,p_msg_name => 'XLA_AP_BAL_UPDATE_FAILED'
3934 ,p_entity_id => NULL
3935 ,p_event_id => NULL);
3936
3937 print_logfile('Technical problem : Problem in submitting request for balance update');
3938
3939 xla_exceptions_pkg.raise_message
3940 (p_appli_s_name => 'XLA'
3941 ,p_msg_name => 'XLA_AP_BAL_UPDATE_FAILED');
3942 ELSE
3943 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3944 trace
3945 (p_msg => 'l_ret_flag_bal_update = TRUE'
3946 ,p_level => C_LEVEL_STATEMENT
3947 ,p_module => l_log_module);
3948 END IF;
3949 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - request for balance calulation submitted');
3950 END IF;
3951 END IF;
3952
3953 --
3954 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Accounting Program completed successfully');
3955
3956 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3957 trace
3958 (p_msg => 'END of procedure BATCH_ACCOUNTING'
3959 ,p_level => C_LEVEL_PROCEDURE
3960 ,p_module => l_log_module);
3961 END IF;
3962 EXCEPTION
3963 WHEN normal_termination THEN
3964 RAISE;
3965 WHEN xla_exceptions_pkg.application_exception THEN
3966 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3967 trace
3968 (p_msg => 'xla_exceptions_pkg.application_exception: BATCH_ACCOUNTING'
3969 ,p_level => C_LEVEL_EXCEPTION
3970 ,p_module => l_log_module);
3971 END IF;
3972
3973 ROLLBACK;
3974 ----------------------------------------------------------------------------
3975 -- calling post-accounting
3976 ----------------------------------------------------------------------------
3977 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Post Accounting Started');
3978 -- Bug 8282549 modified the call to pass g_queue_started_flag and g_queue_created_flag
3979 post_accounting
3980 (p_queue_started_flag => g_queue_started_flag
3981 ,p_queue_created_flag => g_queue_created_flag
3982 ,p_seq_api_called_flag => l_seq_api_called_flag);
3983
3984 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Post Accounting Ended');
3985 --
3986
3987 RAISE;
3988 WHEN OTHERS THEN
3989 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3990 trace
3991 (p_msg => 'Exception: BATCH_ACCOUNTING'
3992 ,p_level => C_LEVEL_EXCEPTION
3993 ,p_module => l_log_module);
3994 END IF;
3995
3996 ROLLBACK;
3997 ----------------------------------------------------------------------------
3998 -- calling post-accounting
3999 ----------------------------------------------------------------------------
4000 -- Bug 8282549 modified the call to pass g_queue_started_flag and g_queue_created_flag
4001 post_accounting
4002 (p_queue_started_flag => g_queue_started_flag
4003 ,p_queue_created_flag => g_queue_created_flag
4004 ,p_seq_api_called_flag => l_seq_api_called_flag);
4005
4006 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Executed post-accounting routine');
4007
4008 xla_accounting_err_pkg.build_message
4009 (p_appli_s_name => 'XLA'
4010 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
4011 ,p_token_1 => 'APPLICATION_NAME'
4012 ,p_value_1 => 'SLA'
4013 ,p_entity_id => NULL
4014 ,p_event_id => NULL);
4015 xla_exceptions_pkg.raise_message
4016 (p_location => 'xla_accounting_pkg.batch_accounting');
4017 END batch_accounting; -- end of procedure
4018
4019
4020 --=============================================================================
4021 --
4022 --
4023 --
4024 --=============================================================================
4025 PROCEDURE pre_accounting IS
4026 l_str_lock_entities VARCHAR2(2000);
4027 l_str_update_events VARCHAR2(2000);
4028 l_pre_processing_str VARCHAR2(2000);
4029 l_ret_flag_bal_reversal BOOLEAN;
4030 l_events_count NUMBER;
4031 l_sqlerrm VARCHAR2(2000);
4032 l_log_module VARCHAR2(240);
4033 l_draft_exists_flag VARCHAR2(1);
4034 BEGIN
4035 IF g_log_enabled THEN
4036 l_log_module := C_DEFAULT_MODULE||'.pre_accounting';
4037 END IF;
4038 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4039 trace
4040 (p_msg => 'BEGIN of procedure PRE_ACCOUNTING'
4041 ,p_level => C_LEVEL_PROCEDURE
4042 ,p_module => l_log_module);
4043 END IF;
4044
4045 ----------------------------------------------------------------------------
4046 -- Handle preaccounting hook
4047 ----------------------------------------------------------------------------
4048 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - executing preaccounting hook');
4049 handle_accounting_hook
4050 (p_application_id => g_application_id
4051 ,p_ledger_id => g_ledger_id
4052 ,p_process_category => g_process_category
4053 ,p_end_date => g_end_date
4054 ,p_accounting_mode => g_accounting_mode
4055 ,p_budgetary_control_mode => g_budgetary_control_mode
4056 ,p_valuation_method => g_valuation_method
4057 ,p_security_id_int_1 => g_security_id_int_1
4058 ,p_security_id_int_2 => g_security_id_int_2
4059 ,p_security_id_int_3 => g_security_id_int_3
4060 ,p_security_id_char_1 => g_security_id_char_1
4061 ,p_security_id_char_2 => g_security_id_char_2
4062 ,p_security_id_char_3 => g_security_id_char_3
4063 ,p_report_request_id => NULL
4064 ,p_event_name => 'preaccounting'
4065 ,p_event_key => to_char(g_accounting_batch_id)||'-'
4066 ||to_char(g_parent_request_id));
4067 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - preaccounting hook executed successfully');
4068
4069
4070 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4071 trace
4072 (p_msg => 'END of procedure PRE_ACCOUNTING'
4073 ,p_level => C_LEVEL_PROCEDURE
4074 ,p_module => l_log_module);
4075 END IF;
4076 EXCEPTION
4077 WHEN normal_termination THEN
4078 RAISE;
4079 WHEN xla_exceptions_pkg.application_exception THEN
4080 RAISE;
4081 WHEN OTHERS THEN
4082 xla_accounting_err_pkg.build_message
4083 (p_appli_s_name => 'XLA'
4084 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
4085 ,p_token_1 => 'APPLICATION_NAME'
4086 ,p_value_1 => 'SLA'
4087 ,p_entity_id => NULL
4088 ,p_event_id => NULL);
4089 xla_exceptions_pkg.raise_message
4090 (p_location => 'xla_accounting_pkg.pre_accounting');
4091 END pre_accounting; -- end of procedure
4092
4093
4094 --=============================================================================
4095 --
4096 --
4097 --
4098 --=============================================================================
4099
4100 PROCEDURE delete_request_je IS
4101 l_log_module VARCHAR2(240);
4102 l_delete_count NUMBER;
4103
4104 BEGIN
4105 IF g_log_enabled THEN
4106 l_log_module := C_DEFAULT_MODULE||'.delete_request_je';
4107 END IF;
4108 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4109 trace
4110 (p_msg => 'BEGIN of procedure DELETE_REQUEST_JE'
4111 ,p_level => C_LEVEL_PROCEDURE
4112 ,p_module => l_log_module);
4113 END IF;
4114
4115 --
4116 -- Delete from xla_accounting_errors
4117 --
4118 DELETE FROM xla_accounting_errors
4119 WHERE event_id IN
4120 (SELECT event_id FROM xla_events_gt);
4121
4122 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4123 trace
4124 (p_msg => 'Number of errors deleted = '||SQL%ROWCOUNT
4125 ,p_level => C_LEVEL_STATEMENT
4126 ,p_module => l_log_module);
4127 END IF;
4128
4129 --
4130 -- Delete from xla_distribution_links
4131 --
4132 DELETE /*+ index(xdl,XLA_DISTRIBUTION_LINKS_N3) */ FROM xla_distribution_links xdl
4133 WHERE ae_header_id IN
4134 (SELECT /*+ cardinality(XE,10) leading(XE) use_nl(XH) unnest */ xh.ae_header_id
4135 FROM xla_events_gt xe,
4136 xla_ae_headers xh
4137 WHERE xe.process_status_code in ('D','E','R','I')
4138 AND xh.application_id = xe.application_id
4139 AND xh.event_id = xe.event_id
4140 )
4141 AND application_id = g_application_id;
4142
4143 l_delete_count := SQL%ROWCOUNT;
4144
4145 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4146 trace
4147 (p_msg => 'Number of distribution links deleted = '||l_delete_count
4148 ,p_level => C_LEVEL_STATEMENT
4149 ,p_module => l_log_module);
4150 END IF;
4151
4152 IF l_delete_count > 0 THEN
4153 --
4154 -- Delete from xla_ae_segment_values
4155 --
4156 DELETE /*+ index(XLA_AE_SEGMENT_VALUES, XLA_AE_SEGMENT_VALUES_U1) */
4157 FROM xla_ae_segment_values
4158 WHERE ae_header_id IN
4159 (SELECT xh.ae_header_id
4160 FROM xla_events_gt xe,
4161 xla_ae_headers xh
4162 WHERE xe.process_status_code in ('D','E','R', 'I')
4163 AND xh.application_id = xe.application_id
4164 AND xh.event_id = xe.event_id
4165 );
4166
4167 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4168 trace
4169 (p_msg => 'Number of segment values deleted = '||SQL%ROWCOUNT
4170 ,p_level => C_LEVEL_STATEMENT
4171 ,p_module => l_log_module);
4172 END IF;
4173
4174 --
4175 -- Delete from xla_ae_line_acs
4176 --
4177 DELETE /*+ use_nl_with_index(XLA_AE_LINE_ACS,XLA_AE_LINE_ACS_U1) leading(VW_NSO_1) */
4178 FROM xla_ae_line_acs
4179
4180 WHERE ae_header_id IN
4181 (SELECT/*+ cardinality(evt,10) unnest */ aeh.ae_header_id
4182 FROM xla_events_gt evt
4183 ,xla_ae_headers aeh
4184 WHERE evt.process_status_code in ('D','E','R','I')
4185 AND aeh.application_id = evt.application_id
4186 AND aeh.event_id = evt.event_id);
4187
4188 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4189 trace
4190 (p_msg => 'Number of line acs deleted = '||SQL%ROWCOUNT
4191 ,p_level => C_LEVEL_STATEMENT
4192 ,p_module => l_log_module);
4193 END IF;
4194
4195 --
4196 -- Delete from xla_ae_header_acs
4197 --
4198 DELETE FROM xla_ae_header_acs
4199 WHERE ae_header_id IN
4200 (SELECT aeh.ae_header_id
4201 FROM xla_events_gt evt
4202 ,xla_ae_headers aeh
4203 WHERE evt.process_status_code in ('D','E','R','I')
4204 AND aeh.application_id = evt.application_id
4205 AND aeh.event_id = evt.event_id);
4206
4207 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4208 trace
4209 (p_msg => 'Number of header acs deleted = '||SQL%ROWCOUNT
4210 ,p_level => C_LEVEL_STATEMENT
4211 ,p_module => l_log_module);
4212 END IF;
4213
4214 --
4215 -- Delete from xla_ae_lines
4216 --
4217 DELETE FROM xla_ae_lines
4218 WHERE application_id = g_application_id
4219 AND ae_header_id IN
4220 (SELECT xh.ae_header_id
4221 FROM xla_events_gt xe,
4222 xla_ae_headers xh
4223 WHERE xe.process_status_code in ('D','E','R','I')
4224 AND xh.application_id = xe.application_id
4225 AND xh.event_id = xe.event_id
4226 );
4227
4228 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4229 trace
4230 (p_msg => 'Number of ae lines deleted = '||SQL%ROWCOUNT
4231 ,p_level => C_LEVEL_STATEMENT
4232 ,p_module => l_log_module);
4233 END IF;
4234
4235 --
4236 -- Delete from xla_ae_headers
4237 --
4238 DELETE /*+ index(aeh, xla_ae_headers_n2) */
4239 FROM xla_ae_headers aeh
4240 WHERE application_id = g_application_id
4241 AND event_id IN (SELECT event_id
4242 FROM xla_events_gt
4243 WHERE process_status_code IN ('D','E','R','I'));
4244
4245 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4246 trace
4247 (p_msg => 'Number of ae headers deleted = '||SQL%ROWCOUNT
4248 ,p_level => C_LEVEL_STATEMENT
4249 ,p_module => l_log_module);
4250 END IF;
4251
4252 END IF;
4253
4254 ----------------------------------------------------------------------------
4255 --
4256 -- Used by the Accounting Event Extract Diagnostics process
4257 --
4258 ----------------------------------------------------------------------------
4259 ----------------------------------------------------------------------------
4260 -- following deletes the Accounting Event Extract Diagnostics data
4261 -- for the events that are being accounted in this run.
4262 ----------------------------------------------------------------------------
4263
4264 IF ( nvl(fnd_profile.value('XLA_DIAGNOSTIC_MODE'),'N') = 'Y') THEN
4265
4266 DELETE FROM xla_diag_sources
4267 WHERE event_id IN
4268 (SELECT event_id FROM xla_events_gt);
4269
4270 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4271 trace
4272 (p_msg => 'Number of Extract sources rows deleted = '||SQL%ROWCOUNT
4273 ,p_level => C_LEVEL_STATEMENT
4274 ,p_module => l_log_module);
4275 END IF;
4276
4277 DELETE FROM xla_diag_events
4278 WHERE event_id IN
4279 (SELECT event_id FROM xla_events_gt);
4280
4281 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4282 trace
4283 (p_msg => 'Number of Extract events deleted = '||SQL%ROWCOUNT
4284 ,p_level => C_LEVEL_STATEMENT
4285 ,p_module => l_log_module);
4286 END IF;
4287 --bug6369888
4288 DELETE FROM xla_diag_ledgers d
4289 WHERE d.application_id = g_application_id
4290 AND NOT EXISTS
4291 (SELECT ledger_id, request_id
4292 FROM xla_diag_events
4293 WHERE application_id = d.application_id
4294 AND request_id = d.accounting_request_id
4295 AND ledger_id = d.primary_ledger_id
4296 );
4297
4298 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4299 trace
4300 (p_msg => 'Number of Extract ledgers deleted = '||SQL%ROWCOUNT
4301 ,p_level => C_LEVEL_STATEMENT
4302 ,p_module => l_log_module);
4303 END IF;
4304
4305 END IF;
4306
4307 ----------------------------------------------------------------------------
4308 --
4309 -- End of code used by the Accounting Event Extract Diagnostics process
4310 --
4311 ----------------------------------------------------------------------------
4312
4313
4314 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4315 trace
4316 (p_msg => 'END of procedure DELETE_REQUEST_JE'
4317 ,p_level => C_LEVEL_PROCEDURE
4318 ,p_module => l_log_module);
4319 END IF;
4320 EXCEPTION
4321 WHEN xla_exceptions_pkg.application_exception THEN
4322 RAISE;
4323 WHEN OTHERS THEN
4324 xla_exceptions_pkg.raise_message
4325 (p_location => 'xla_accounting_pkg.delete_request_je');
4326 END delete_request_je;
4327
4328
4329 --=============================================================================
4330 --
4331 --
4332 --
4333 --=============================================================================
4334 PROCEDURE post_accounting
4335 (p_queue_started_flag IN OUT NOCOPY VARCHAR2
4336 ,p_queue_created_flag IN OUT NOCOPY VARCHAR2
4337 ,p_seq_api_called_flag IN OUT NOCOPY VARCHAR2) IS
4338 l_seq_status VARCHAR2(30);
4339 l_log_module VARCHAR2(240);
4340 BEGIN
4341 IF g_log_enabled THEN
4342 l_log_module := C_DEFAULT_MODULE||'.post_accounting';
4343 END IF;
4344 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4345 trace
4346 (p_msg => 'BEGIN of procedure POST_ACCOUNTING'
4347 ,p_level => C_LEVEL_PROCEDURE
4348 ,p_module => l_log_module);
4349 END IF;
4350 dbms_session.set_identifier(client_id => g_parent_request_id); -- added for bug11903966
4351 ----------------------------------------------------------------------------
4352 -- Total error error counts are read into a local variable before the
4353 -- global context is cleared. This is later used to set the 'p_retcode'.
4354 -- bug # 2709397.
4355 ----------------------------------------------------------------------------
4356 g_total_error_count := xla_accounting_err_pkg.get_total_error_count;
4357
4358
4359 --
4360 -- 4865292
4361 -- Compare event count with header extract count
4362 -- Display messages when the counts are different
4363 --
4364 IF xla_context_pkg.get_event_nohdr_context = 'Y' THEN
4365
4366 xla_accounting_err_pkg.build_message
4367 (p_appli_s_name => 'XLA'
4368 ,p_msg_name => 'XLA_AP_NO_HDR_EXTRACT'
4369 ,p_entity_id => NULL
4370 ,p_event_id => NULL
4371 ,p_ledger_id => g_ledger_id);
4372
4373 END IF;
4374
4375 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4376 trace
4377 (p_msg => 'g_total_error_count = '||g_total_error_count
4378 ,p_level => C_LEVEL_STATEMENT
4379 ,p_module => l_log_module);
4380 END IF;
4381
4382 ----------------------------------------------------------------------------
4383 -- clean up the global application context
4384 ----------------------------------------------------------------------------
4385 xla_context_pkg.clear_acct_err_context
4386 (p_client_id => g_parent_request_id);
4387
4388 xla_context_pkg.clear_event_context
4389 (p_client_id => g_parent_request_id);
4390
4391 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4392 trace
4393 (p_msg => 'Global Context cleared'
4394 ,p_level => C_LEVEL_STATEMENT
4395 ,p_module => l_log_module);
4396 END IF;
4397
4398 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Global Context cleared');
4399
4400 ----------------------------------------------------------------------------
4401 -- clean up queues for each event application
4402 ----------------------------------------------------------------------------
4403 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4404 trace
4405 (p_msg => 'p_queue_started_flag = '||p_queue_started_flag
4406 ,p_level => C_LEVEL_STATEMENT
4407 ,p_module => l_log_module);
4408 trace
4409 (p_msg => 'p_queue_created_flag = '||p_queue_created_flag
4410 ,p_level => C_LEVEL_STATEMENT
4411 ,p_module => l_log_module);
4412 END IF;
4413
4414 IF p_queue_started_flag = 'Y' THEN
4415 IF (C_LEVEL_EVENT >= g_log_level) THEN
4416 trace
4417 (p_msg => 'Ready to stop the message queue'
4418 ,p_level => C_LEVEL_EVENT
4419 ,p_module => l_log_module);
4420 END IF;
4421
4422 dbms_aqadm.stop_queue(queue_name => g_queue_name
4423 ,wait => TRUE); --5056507
4424 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue stopped = '||g_queue_name);
4425 dbms_aqadm.stop_queue(queue_name => g_comp_queue_name
4426 ,wait => TRUE); --5056507
4427 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue stopped = '||g_comp_queue_name);
4428 p_queue_started_flag := 'N';
4429
4430 IF (C_LEVEL_EVENT >= g_log_level) THEN
4431 trace
4432 (p_msg => 'Message queue stopped'
4433 ,p_level => C_LEVEL_EVENT
4434 ,p_module => l_log_module);
4435 END IF;
4436 END IF;
4437
4438 IF p_queue_created_flag = 'Y' THEN
4439 IF (C_LEVEL_EVENT >= g_log_level) THEN
4440 trace
4441 (p_msg => 'Ready to drop the message queue'
4442 ,p_level => C_LEVEL_EVENT
4443 ,p_module => l_log_module);
4444 END IF;
4445
4446 dbms_aqadm.drop_queue(queue_name => g_queue_name);
4447 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue dropped = '||g_queue_name);
4448 dbms_aqadm.drop_queue(queue_name => g_comp_queue_name);
4449 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Queue dropped = '||g_comp_queue_name);
4450 p_queue_created_flag := 'N';
4451
4452 IF (C_LEVEL_EVENT >= g_log_level) THEN
4453 trace
4454 (p_msg => 'Message queue dropped'
4455 ,p_level => C_LEVEL_EVENT
4456 ,p_module => l_log_module);
4457 END IF;
4458 END IF;
4459
4460 ----------------------------------------------------------------------------
4461 -- Call sequencing batch_exit
4462 ----------------------------------------------------------------------------
4463 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4464 trace
4465 (p_msg => 'p_seq_api_called_flag = '||p_seq_api_called_flag
4466 ,p_level => C_LEVEL_STATEMENT
4467 ,p_module => l_log_module);
4468 END IF;
4469
4470 IF p_seq_api_called_flag = 'Y' THEN
4471 BEGIN
4472 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Calling sequencing batch_exit');
4473
4474 IF (C_LEVEL_EVENT >= g_log_level) THEN
4475 trace
4476 (p_msg => 'Calling the procedure FUN_SEQ_BATCH.BATCH_EXIT'
4477 ,p_level => C_LEVEL_EVENT
4478 ,p_module => l_log_module);
4479 END IF;
4480
4481 fun_seq_batch.batch_exit
4482 (p_request_id => g_parent_request_id
4483 ,x_status => l_seq_status);
4484 p_seq_api_called_flag := 'N';
4485 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Returned from sequencing batch_exit');
4486
4487 IF (C_LEVEL_EVENT >= g_log_level) THEN
4488 trace
4489 (p_msg => 'Procedure FUN_SEQ_BATCH.BATCH_EXIT executed'
4490 ,p_level => C_LEVEL_EVENT
4491 ,p_module => l_log_module);
4492 END IF;
4493
4494 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4495 trace
4496 (p_msg => 'l_seq_status = '||l_seq_status
4497 ,p_level => C_LEVEL_STATEMENT
4498 ,p_module => l_log_module);
4499 END IF;
4500
4501 IF l_seq_status <> 'SUCCESS' THEN
4502 xla_accounting_err_pkg.build_message
4503 (p_appli_s_name => 'XLA'
4504 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
4505 ,p_token_1 => 'APPLICATION_NAME'
4506 ,p_value_1 => 'SLA'
4507 ,p_entity_id => NULL
4508 ,p_event_id => NULL);
4509
4510 print_logfile('Technical problem : Problem encountered in sequencing BATCH_EXIT. '||
4511 'Please submit the concurrent program to compelte this process');
4512 END IF;
4513 EXCEPTION
4514 WHEN OTHERS THEN
4515 xla_accounting_err_pkg.build_message
4516 (p_appli_s_name => 'XLA'
4517 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
4518 ,p_token_1 => 'APPLICATION_NAME'
4519 ,p_value_1 => 'SLA'
4520 ,p_entity_id => NULL
4521 ,p_event_id => NULL);
4522
4523 print_logfile('Technical problem : Problem encountered in sequencing BATCH_EXIT. '||
4524 'Please submit the concurrent program to compelte this process');
4525 END;
4526 END IF;
4527
4528 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4529 trace
4530 (p_msg => 'END of procedure POST_ACCOUNTING'
4531 ,p_level => C_LEVEL_PROCEDURE
4532 ,p_module => l_log_module);
4533 END IF;
4534 EXCEPTION
4535 WHEN xla_exceptions_pkg.application_exception THEN
4536 RAISE;
4537 WHEN OTHERS THEN
4538 xla_accounting_err_pkg.build_message
4539 (p_appli_s_name => 'XLA'
4540 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
4541 ,p_token_1 => 'APPLICATION_NAME'
4542 ,p_value_1 => 'SLA'
4543 ,p_entity_id => NULL
4544 ,p_event_id => NULL);
4545 xla_exceptions_pkg.raise_message
4546 (p_location => 'xla_accounting_pkg.post_accounting');
4547 END post_accounting;
4548
4549
4550 --=============================================================================
4551 --
4552 --
4553 --
4554 --=============================================================================
4555
4556 PROCEDURE enqueue_messages
4557 (p_processing_order INTEGER
4558 ,p_max_processing_order INTEGER
4559 ,p_children_spawned IN OUT NOCOPY BOOLEAN
4560 ,p_msg_count IN OUT NOCOPY INTEGER)
4561 IS
4562 TYPE ref_cur_type IS REF CURSOR;
4563 csr_event_class ref_cur_type;
4564 csr_entity ref_cur_type;
4565
4566 l_cur_event_stmt VARCHAR2(8000);
4567 l_cur_entity_stmt VARCHAR2(8000);
4568
4569 l_entity_id xla_array_number_type; -- xla_number_array_type;
4570 l_entity_found BOOLEAN := FALSE;
4571 l_children_spawned BOOLEAN := FALSE;
4572 l_unit_count NUMBER := 0;
4573 l_enq_options dbms_aq.enqueue_options_t;
4574 l_msg_prop dbms_aq.message_properties_t;
4575 l_message xla_queue_msg_type; --SYSTEM.xla_queue_msg_type;
4576 l_msgid RAW(16);
4577
4578 l_event_class_code VARCHAR2(30);
4579 l_unit_size NUMBER := 0;
4580
4581 l_log_module VARCHAR2(240);
4582 l_combine_event_classes VARCHAR2(10000);
4583 l_anytime_class VARCHAR2(5000);
4584 l_current_class VARCHAR2(5000);
4585
4586 BEGIN
4587 IF g_log_enabled THEN
4588 l_log_module := C_DEFAULT_MODULE||'.enqueue_messages';
4589 END IF;
4590 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4591 trace
4592 (p_msg => 'BEGIN of procedure ENQUEUE_MESSAGES'
4593 ,p_level => C_LEVEL_PROCEDURE
4594 ,p_module => l_log_module);
4595
4596 trace
4597 (p_msg => 'p_processing_order = '||p_processing_order
4598 ,p_level => C_LEVEL_PROCEDURE
4599 ,p_module => l_log_module);
4600 END IF;
4601
4602 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Ready to Enqueue documents in the queue');
4603 -------------------------------------------------------------------------------
4604 -- Retrieve Processing Unit Size at Event Class Level
4605 -------------------------------------------------------------------------------
4606 --bug6369888 changed cursor to merge into single query.
4607 l_cur_event_stmt :=
4608 'SELECT /*+ index(evt,XLA_EVENTS_N3) */ MIN(nvl(xjc.processing_unit_size, :1))
4609 FROM xla_events evt,
4610 xla_transaction_entities ent,
4611 xla_event_types_b xet,
4612 xla_event_class_attrs eca,
4613 xla_evt_class_orders_gt xpo,
4614 xla_je_categories xjc
4615 WHERE ent.application_id = :3
4616 AND ent.ledger_id = :4
4617 AND evt.application_id = :5
4618 AND evt.entity_id = ent.entity_id
4619 AND xet.application_id = evt.application_id
4620 AND xet.event_type_code = evt.event_type_code
4621 AND eca.application_id = xet.application_id
4622 AND eca.entity_code = xet.entity_code
4623 AND eca.event_class_code = xet.event_class_code
4624 AND eca.event_class_group_code = nvl(:6, eca.event_class_group_code)
4625 AND evt.event_type_code NOT IN(''FULL_MERGE'', ''PARTIAL_MERGE'')
4626 AND evt.process_status_code IN(''I'', ''E'', ''R'', decode(:7, ''N'', ''D'', ''E''), decode(:8, ''N'', ''U'', ''E''))
4627 AND evt.event_status_code IN(''U'', decode(:9, ''F'', ''N'', ''U''))
4628 AND evt.on_hold_flag = ''N''
4629 AND evt.event_date <= :10
4630 AND ent.entity_code <> :11
4631 AND nvl(evt.budgetary_control_flag, ''N'') = ''N''
4632 AND xet.event_class_code = xpo.event_class_code
4633 AND xpo.processing_order = :2
4634 AND xjc.application_id = :12
4635 AND xjc.ledger_id = :13
4636 AND xjc.event_class_code = xpo.event_class_code '
4637 ||g_security_condition;
4638
4639 l_cur_entity_stmt :=
4640 'SELECT /*+ leading(evt) use_nl(ent) index(evt,XLA_EVENTS_N3) */ -- Bug 5529420 reverted bug6369888 modified hint bug9192859
4641 DISTINCT evt.entity_id
4642 FROM xla_events evt
4643 ,xla_transaction_entities ent
4644 ,xla_event_types_b xet
4645 ,xla_event_class_attrs eca
4646 ,xla_evt_class_orders_gt xpo
4647 WHERE ent.application_id = :1
4648 AND ent.ledger_id = :2
4649 AND evt.application_id = :3
4650 AND evt.entity_id = ent.entity_id
4651 AND xet.application_id = evt.application_id
4652 AND xet.event_type_code = evt.event_type_code
4653 AND eca.application_id = xet.application_id
4654 AND eca.entity_code = xet.entity_code
4655 AND eca.event_class_code = xet.event_class_code
4656 AND eca.event_class_group_code = NVL(:4, eca.event_class_group_code)
4657 AND evt.event_type_code NOT IN (''FULL_MERGE'', ''PARTIAL_MERGE'')
4658 AND evt.process_status_code IN (''I'',''E'', ''R'',DECODE(:5,''N'',''D'',''E'')
4659 ,DECODE(:6,''N'',''U'',''E'')
4660 )
4661 AND evt.event_status_code IN (''U'',DECODE(:7,''F'',''N'',''U''))
4662 AND evt.on_hold_flag = ''N''
4663 AND evt.event_date <= :8
4664 AND ent.entity_code <> :9
4665 AND NVL(evt.budgetary_control_flag,''N'') = ''N''
4666 AND xet.event_class_code = xpo.event_class_code
4667 AND xpo.processing_order = :10 '
4668 ||g_security_condition;
4669
4670 ----------------------------------------------------------------------------
4671 -- initiating queue/message related variables
4672 ----------------------------------------------------------------------------
4673 l_enq_options.visibility := dbms_aq.IMMEDIATE;
4674 l_enq_options.relative_msgid := NULL;
4675 l_enq_options.sequence_deviation := NULL;
4676
4677 IF (p_processing_order = -1) THEN
4678 l_msg_prop.priority := p_max_processing_order+1;
4679 ELSE
4680 l_msg_prop.priority := p_processing_order;
4681 END IF;
4682 l_msg_prop.DELAY := dbms_aq.NO_DELAY;
4683 l_msg_prop.expiration := dbms_aq.NEVER;
4684 l_msg_prop.correlation := NULL;
4685 l_msg_prop.exception_queue := NULL;
4686 l_msg_prop.sender_id := NULL;
4687
4688 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4689 trace
4690 (p_msg => 'l_cur_event_stmt '||l_cur_event_stmt
4691 ,p_level => C_LEVEL_STATEMENT
4692 ,p_module => l_log_module);
4693 END IF;
4694 --bug6369888 removed loop
4695 SELECT MAX(xjc.processing_unit_size)
4696 INTO l_unit_size
4697 FROM xla_je_categories xjc,
4698 (
4699 SELECT
4700 xpo.event_class_code
4701 FROM xla_evt_class_orders_gt xpo
4702 WHERE xpo.processing_order = p_processing_order
4703 ) tab1
4704 WHERE xjc.application_id = g_application_id
4705 AND xjc.ledger_id = g_ledger_id
4706 AND xjc.event_class_code = tab1.event_class_code;
4707
4708 IF l_unit_size <> NULL THEN
4709 OPEN csr_event_class FOR l_cur_event_stmt USING g_unit_size
4710 ,p_processing_order
4711 ,g_application_id
4712 ,g_ledger_id
4713 ,g_application_id
4714 ,g_process_category
4715 ,g_error_only_flag
4716 ,g_error_only_flag
4717 ,g_accounting_mode
4718 ,g_end_date
4719 ,C_MANUAL
4720 ,g_application_id
4721 ,g_ledger_id ;
4722 FETCH csr_event_class INTO l_unit_size;
4723 CLOSE csr_event_class;
4724 END IF;
4725
4726 -------------------------------------------------------------------------------------------------
4727 -- 4597150 Find all event class for process order of -1
4728 -------------------------------------------------------------------------------------------------
4729 l_anytime_class := concat_event_classes(-1);
4730
4731 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4732 trace
4733 (p_msg => 'Event class for processing order of -1 = '||l_anytime_class
4734 ,p_level => C_LEVEL_STATEMENT
4735 ,p_module => l_log_module);
4736 END IF;
4737
4738 ----------------------------------------------------------
4739 -- 4597150 Find all event class for current process order
4740 ----------------------------------------------------------
4741 IF p_processing_order <> -1 THEN
4742 l_current_class := concat_event_classes(p_processing_order);
4743 ELSE
4744 l_current_class := l_anytime_class;
4745 l_anytime_class := ''; -- 14105024
4746 END IF;
4747
4748 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4749 trace
4750 (p_msg => 'Event class for processing order of '
4751 ||p_processing_order||' = '||l_current_class
4752 ,p_level => C_LEVEL_STATEMENT
4753 ,p_module => l_log_module);
4754 END IF;
4755
4756 -------------------------------------------------------------------------
4757 -- 4597150 : combine Current and Anytime event classes
4758 -- e.g. 'EC1','EC2'#-#-#-#-#-#-#-#'EC3','EC4'
4759 -- When Current Process Order is -1, l_current_class = l_anytime_class
4760 -------------------------------------------------------------------------
4761 l_combine_event_classes := l_current_class||C_DELIMITER||l_anytime_class;
4762 l_msg_prop.user_property :=
4763 SYS.AnyData.ConvertVarchar2(l_combine_event_classes);
4764
4765 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4766 trace
4767 (p_msg => 'l_cur_entity_stmt '||l_cur_entity_stmt
4768 ,p_level => C_LEVEL_STATEMENT
4769 ,p_module => l_log_module);
4770 END IF;
4771
4772 OPEN csr_entity FOR l_cur_entity_stmt USING g_application_id
4773 ,g_ledger_id
4774 ,g_application_id
4775 ,g_process_category
4776 ,g_error_only_flag
4777 ,g_error_only_flag
4778 ,g_accounting_mode
4779 ,g_end_date
4780 ,C_MANUAL
4781 ,p_processing_order;
4782
4783 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4784 trace
4785 (p_msg => 'g_unit_size '||g_unit_size
4786 ,p_level => C_LEVEL_STATEMENT
4787 ,p_module => l_log_module);
4788 END IF;
4789
4790 ----------------------------------------------------------------------------
4791 -- loop for each data fetched from the cursor. This will enqueue the data
4792 -- in the queue
4793 ----------------------------------------------------------------------------
4794 LOOP
4795 FETCH csr_entity BULK COLLECT INTO l_entity_id LIMIT NVL(l_unit_size,g_unit_size);
4796
4797 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4798 trace
4799 (p_msg => ' l_entity_id.COUNT ='||l_entity_id.COUNT
4800 ,p_level => C_LEVEL_STATEMENT
4801 ,p_module => l_log_module);
4802 FOR i in 1..l_entity_id.COUNT LOOP
4803 trace
4804 (p_msg => 'entity_id ='||l_entity_id(i)
4805 ,p_level => C_LEVEL_STATEMENT
4806 ,p_module => l_log_module);
4807 END LOOP;
4808 END IF;
4809
4810 -------------------------------------------------------------------------
4811 -- following is the only way to exit the indefinite loop. It exits when
4812 -- no documents are fetched into the array variable 'l_entity_id'
4813 -------------------------------------------------------------------------
4814 EXIT WHEN l_entity_id.COUNT = 0;
4815
4816 IF NOT p_children_spawned THEN
4817 ----------------------------------------------------------------------------
4818 -- spawn parallel processes, "event processors" for processing documents.
4819 -- number of paralle process spawned depends on the ledger setup
4820 ----------------------------------------------------------------------------
4821 --
4822 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Spawning unit processors');
4823
4824 spawn_child_processes;
4825 p_children_spawned := TRUE;
4826 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Unit processors spawned');
4827
4828 END IF;
4829
4830 -------------------------------------------------------------------------
4831 -- l_entity_found is set to TRUE to indicate that there are events that
4832 -- that are eligible to be processed
4833 -------------------------------------------------------------------------
4834 l_entity_found := TRUE;
4835 l_unit_count := l_unit_count + 1;
4836 p_msg_count := p_msg_count + 1;
4837
4838 -------------------------------------------------------------------------
4839 -- create a message from the fetched entity ids.
4840 -------------------------------------------------------------------------
4841 l_message := xla_queue_msg_type(l_entity_id); --SYSTEM.xla_queue_msg_type(l_entity_id);
4842
4843 -------------------------------------------------------------------------
4844 -- enqueue the message in the queue
4845 -------------------------------------------------------------------------
4846 dbms_aq.enqueue
4847 (g_queue_name
4848 ,l_enq_options
4849 ,l_msg_prop
4850 ,l_message
4851 ,l_msgid);
4852
4853 g_parent_data.total_entity_count := g_parent_data.total_entity_count +
4854 csr_entity%ROWCOUNT;
4855 END LOOP;
4856
4857 CLOSE csr_entity;
4858
4859 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4860 trace
4861 (p_msg => 'END of procedure ENQUEUE_MESSAGES'
4862 ,p_level => C_LEVEL_PROCEDURE
4863 ,p_module => l_log_module);
4864 END IF;
4865 EXCEPTION
4866 WHEN NO_DATA_FOUND THEN
4867 IF csr_event_class%NOTFOUND THEN
4868 xla_exceptions_pkg.raise_message
4869 (p_appli_s_name => 'XLA'
4870 ,p_msg_name => 'XLA_COMMON_ERROR'
4871 ,p_token_1 => 'ERROR'
4872 ,p_value_1 => 'Journal categories does not have data for this ledger and application.
4873 Please run Update Subledger Accounting Options program for your
4874 application '||'ledger_id = '||g_ledger_id||
4875 ' application_id = '|| g_application_id
4876 ,p_token_2 => 'LOCATION'
4877 ,p_value_2 => 'xla_accounting_pkg.enqueue_messages');
4878 END IF;
4879 WHEN normal_termination THEN
4880 IF csr_entity%ISOPEN THEN
4881 CLOSE csr_entity;
4882 END IF;
4883 RAISE;
4884 WHEN xla_exceptions_pkg.application_exception THEN
4885 IF csr_entity%ISOPEN THEN
4886 CLOSE csr_entity;
4887 END IF;
4888 RAISE;
4889 WHEN OTHERS THEN
4890 IF csr_entity%ISOPEN THEN
4891 CLOSE csr_entity;
4892 END IF;
4893 xla_exceptions_pkg.raise_message
4894 (p_location => 'xla_accounting_pkg.enqueue_messages');
4895 END enqueue_messages; -- end of procedure
4896
4897 --=============================================================================
4898 --
4899 --
4900 --
4901 --=============================================================================
4902 PROCEDURE dequeue_completion_messages
4903 (p_msg_count INTEGER)
4904 IS
4905 l_msgid RAW(16);
4906 l_conf_msg_prop dbms_aq.message_properties_t;
4907 l_conf_message xla_queue_msg_type; -- SYSTEM.xla_queue_msg_type;
4908 l_deq_options dbms_aq.dequeue_options_t;
4909 l_msg_count INTEGER;
4910
4911 l_log_module VARCHAR2(240);
4912 BEGIN
4913 IF g_log_enabled THEN
4914 l_log_module := C_DEFAULT_MODULE||'.dequeue_completion_messages';
4915 END IF;
4916
4917 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4918 trace
4919 (p_msg => 'BEGIN of procedure dequeue_completion_messages'
4920 ,p_level => C_LEVEL_PROCEDURE
4921 ,p_module => l_log_module);
4922 END IF;
4923
4924 IF (C_LEVEL_EVENT >= g_log_level) THEN
4925 trace
4926 (p_msg => 'BEGIN LOOP : dequeue completion messges - p_msg_count = '||p_msg_count
4927 ,p_level => C_LEVEL_EVENT
4928 ,p_module => l_log_module);
4929 END IF;
4930
4931 l_deq_options.consumer_name := NULL;
4932 l_deq_options.dequeue_mode := dbms_aq.REMOVE;
4933 l_deq_options.navigation := dbms_aq.FIRST_MESSAGE;
4934 l_deq_options.visibility := dbms_aq.IMMEDIATE;
4935 l_deq_options.wait := 60;
4936 l_deq_options.msgid := NULL;
4937 l_deq_options.correlation := NULL;
4938
4939 l_msg_count := p_msg_count;
4940
4941 --
4942 -- Get completion messages for all document messages before proceeding
4943 --
4944 WHILE (l_msg_count > 0) LOOP
4945 IF (C_LEVEL_EVENT >= g_log_level) THEN
4946 trace
4947 (p_msg => 'LOOP : dequeue completion messges : '||p_msg_count
4948 ,p_level => C_LEVEL_EVENT
4949 ,p_module => l_log_module);
4950 END IF;
4951
4952 l_msgid := NULL;
4953 BEGIN
4954
4955 IF (C_LEVEL_EVENT >= g_log_level) THEN
4956 trace
4957 (p_msg => 'Begin LOOP : dequeue completion messges : '||p_msg_count
4958 ,p_level => C_LEVEL_EVENT
4959 ,p_module => l_log_module);
4960 END IF;
4961
4962 dbms_aq.dequeue
4963 (g_comp_queue_name
4964 ,l_deq_options
4965 ,l_conf_msg_prop
4966 ,l_conf_message
4967 ,l_msgid);
4968
4969 IF (C_LEVEL_EVENT >= g_log_level) THEN
4970 trace
4971 (p_msg => 'Dequeue one completion message'
4972 ,p_level => C_LEVEL_EVENT
4973 ,p_module => l_log_module);
4974 END IF;
4975
4976 l_msg_count := l_msg_count - 1;
4977
4978 EXCEPTION
4979 WHEN OTHERS THEN
4980 IF (C_LEVEL_EVENT >= g_log_level) THEN
4981 trace
4982 (p_msg => 'No completion message to dequeue'
4983 ,p_level => C_LEVEL_EVENT
4984 ,p_module => l_log_module);
4985 END IF;
4986
4987 IF (NOT is_any_child_running) THEN
4988 IF (C_LEVEL_EVENT >= g_log_level) THEN
4989 trace
4990 (p_msg => 'No children process running : EXIT dequeue completion message'
4991 ,p_level => C_LEVEL_EVENT
4992 ,p_module => l_log_module);
4993 END IF;
4994
4995 EXIT;
4996 END IF;
4997
4998 END;
4999 END LOOP;
5000
5001 IF (C_LEVEL_EVENT >= g_log_level) THEN
5002 trace
5003 (p_msg => 'END LOOP : dequeue completion messges'
5004 ,p_level => C_LEVEL_EVENT
5005 ,p_module => l_log_module);
5006 END IF;
5007
5008 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5009 trace
5010 (p_msg => 'END of procedure dequeue_completion_messages'
5011 ,p_level => C_LEVEL_PROCEDURE
5012 ,p_module => l_log_module);
5013 END IF;
5014 EXCEPTION
5015 WHEN normal_termination THEN
5016 RAISE;
5017 WHEN xla_exceptions_pkg.application_exception THEN
5018 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
5019 trace
5020 (p_msg => 'xla_exceptions_pkg.application_exception: dequeue_completion_messages'
5021 ,p_level => C_LEVEL_EXCEPTION
5022 ,p_module => l_log_module);
5023 END IF;
5024 RAISE;
5025 WHEN OTHERS THEN
5026 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
5027 trace
5028 (p_msg => 'EXCEPTION: dequeue_completion_messages'
5029 ,p_level => C_LEVEL_EXCEPTION
5030 ,p_module => l_log_module);
5031 END IF;
5032 xla_exceptions_pkg.raise_message
5033 (p_location => 'xla_accounting_pkg.dequeue_completion_messages');
5034 END dequeue_completion_messages; -- end of procedure
5035
5036
5037
5038
5039 --=============================================================================
5040 --
5041 --
5042 --
5043 --=============================================================================
5044 PROCEDURE process_events IS
5045 l_children_spawned BOOLEAN;
5046 l_msg_count INTEGER;
5047 l_msg_count2 INTEGER;
5048 l_total_msg_count INTEGER;
5049 l_enq_options dbms_aq.enqueue_options_t;
5050 l_msg_prop dbms_aq.message_properties_t;
5051 l_message xla_queue_msg_type; -- SYSTEM.xla_queue_msg_type;
5052 l_msgid RAW(16);
5053 l_max_processing_order INTEGER;
5054 l_num_level INTEGER;
5055
5056 l_log_module VARCHAR2(240);
5057 BEGIN
5058 IF g_log_enabled THEN
5059 l_log_module := C_DEFAULT_MODULE||'.process_events';
5060 END IF;
5061
5062 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5063 trace
5064 (p_msg => 'BEGIN of procedure process_events'
5065 ,p_level => C_LEVEL_PROCEDURE
5066 ,p_module => l_log_module);
5067 END IF;
5068
5069 INSERT INTO xla_evt_class_orders_gt
5070 (event_class_code
5071 ,processing_order
5072 )
5073 SELECT xec.event_class_code
5074 , NVL(t.max_level, -1)
5075 FROM xla_event_classes_b xec
5076 , (SELECT application_id, event_class_code, max(LEVEL) AS max_level
5077 FROM (SELECT application_id, event_class_code, prior_event_class_code
5078 FROM xla_event_class_predecs
5079 WHERE application_id = g_application_id
5080 UNION
5081 SELECT application_id, prior_event_class_code, NULL
5082 FROM xla_event_class_predecs
5083 WHERE application_id = g_application_id) xep
5084 CONNECT BY application_id = PRIOR application_id
5085 AND prior_event_class_code = PRIOR event_class_code
5086 GROUP BY application_id, event_class_code) t
5087 WHERE xec.event_class_code = t.event_class_code(+)
5088 AND xec.application_id = t.application_id(+)
5089 AND xec.application_id = g_application_id
5090 AND xec.event_class_code <> 'MANUAL';
5091
5092 SELECT max(processing_order)
5093 INTO l_max_processing_order
5094 FROM xla_evt_class_orders_gt;
5095
5096 IF (l_max_processing_order = -1) THEN
5097 l_num_level := 1;
5098 ELSE
5099 l_num_level := l_max_processing_order + 1; -- 5113664 to loop one more to handle -1 process order
5100 END IF;
5101
5102 IF (C_LEVEL_EVENT >= g_log_level) THEN
5103 trace
5104 (p_msg => 'Max processing order = '||l_max_processing_order
5105 ,p_level => C_LEVEL_EVENT
5106 ,p_module => l_log_module);
5107 END IF;
5108
5109 g_parent_data.total_entity_count := 0;
5110
5111 l_total_msg_count := 0;
5112 l_msg_count := 0;
5113 l_children_spawned := FALSE;
5114
5115 l_enq_options.visibility := dbms_aq.IMMEDIATE;
5116 l_enq_options.relative_msgid := NULL;
5117 l_enq_options.sequence_deviation := NULL;
5118
5119 l_msg_prop.priority := l_max_processing_order + 2;
5120 l_msg_prop.DELAY := dbms_aq.NO_DELAY;
5121 l_msg_prop.expiration := dbms_aq.NEVER;
5122 l_msg_prop.correlation := NULL;
5123 l_msg_prop.exception_queue := NULL;
5124 l_msg_prop.sender_id := NULL;
5125
5126 l_message := xla_queue_msg_type(NULL); -- SYSTEM.xla_queue_msg_type(NULL);
5127
5128 IF (C_LEVEL_EVENT >= g_log_level) THEN
5129 trace
5130 (p_msg => 'BEGIN LOOP : enqueue document messges'
5131 ,p_level => C_LEVEL_EVENT
5132 ,p_module => l_log_module);
5133 END IF;
5134
5135 --
5136 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Begin enqueue');
5137 --
5138 -- Porcess document starting from the event with lowest processing event
5139 --
5140 FOR i IN 1..l_num_level LOOP
5141 IF (C_LEVEL_EVENT >= g_log_level) THEN
5142 trace
5143 (p_msg => 'LOOP : enqueue document messges : '||i
5144 ,p_level => C_LEVEL_EVENT
5145 ,p_module => l_log_module);
5146 END IF;
5147
5148 IF (l_max_processing_order > 0) THEN
5149
5150 l_msg_count := 0;
5151
5152 --------------------------------------------------------------------------------------------------------------------
5153 -- 5113664
5154 -- To handle case when only processing order -1 events exist, and there are no events for other processing order.
5155 -- When enqueue_message cannot find events of processing order 'i' in csr_entity, it also cannot process -1 order events.
5156 -- Therefore -1 events will not be processed.
5157 -- Increase l_num_level by 1 more than l_max_processing_order to act as a dummy to loop for any remaining -1 events.
5158 -- This is like a 'catch all'.
5159 --------------------------------------------------------------------------------------------------------------------
5160 IF i <= l_max_processing_order THEN
5161 enqueue_messages(p_processing_order => i
5162 ,p_children_spawned => l_children_spawned
5163 ,p_max_processing_order => l_max_processing_order
5164 ,p_msg_count => l_msg_count);
5165 ELSE
5166 enqueue_messages(p_processing_order => -1
5167 ,p_children_spawned => l_children_spawned
5168 ,p_max_processing_order => l_max_processing_order
5169 ,p_msg_count => l_msg_count);
5170 END IF;
5171
5172 l_total_msg_count := l_total_msg_count + l_msg_count;
5173
5174 --------------------------------------------------------------------------------------------------------
5175 -- 4597150 l_max_processing_order < 0 implies only process order -1 exists, and no other process orders.
5176 -- Only call enqueue_messages with -1 if there are no other process orders.
5177 --------------------------------------------------------------------------------------------------------
5178 ELSE
5179 l_msg_count := 0;
5180 enqueue_messages(p_processing_order => -1
5181 ,p_children_spawned => l_children_spawned
5182 ,p_max_processing_order => l_max_processing_order
5183 ,p_msg_count => l_msg_count);
5184 l_total_msg_count := l_total_msg_count + l_msg_count;
5185 END IF;
5186
5187 --
5188 -- After queueing the highest priority events, queue the events that can
5189 -- be processed anytime
5190 --
5191 /* 4597150
5192 IF (i = 1) THEN
5193 l_msg_count2 := 0;
5194 enqueue_messages(p_processing_order => -1
5195 ,p_children_spawned => l_children_spawned
5196 ,p_max_processing_order => l_max_processing_order
5197 ,p_msg_count => l_msg_count2);
5198 l_total_msg_count := l_total_msg_count + l_msg_count2;
5199 END IF;
5200 */
5201
5202 IF (l_children_spawned) THEN
5203 --
5204 -- If after processing the last processing order message and
5205 -- child processes are created, enqueue NULL messages to the
5206 -- document queue to signal the child processes that there is
5207 -- no more documents to be processed
5208 --
5209 -- 5113664 increase l_max_processing_order by 1 since l_num_level is increased also
5210 -- IF (i = l_max_processing_order OR l_max_processing_order = -1) THEN
5211 IF (i = (l_max_processing_order+1) OR l_max_processing_order = -1) THEN
5212
5213 IF (C_LEVEL_EVENT >= g_log_level) THEN
5214 trace
5215 (p_msg => 'BEGIN LOOP : enqueue dummy messges'
5216 ,p_level => C_LEVEL_EVENT
5217 ,p_module => l_log_module);
5218 END IF;
5219
5220 FOR j IN 1..g_process_count LOOP
5221 IF (C_LEVEL_EVENT >= g_log_level) THEN
5222 trace
5223 (p_msg => 'LOOP : enqueue dummy messges : '||j
5224 ,p_level => C_LEVEL_EVENT
5225 ,p_module => l_log_module);
5226 END IF;
5227
5228 dbms_aq.enqueue
5229 (g_queue_name
5230 ,l_enq_options
5231 ,l_msg_prop
5232 ,l_message
5233 ,l_msgid);
5234 END LOOP;
5235
5236 IF (C_LEVEL_EVENT >= g_log_level) THEN
5237 trace
5238 (p_msg => 'END LOOP: enqueue dummy messges'
5239 ,p_level => C_LEVEL_EVENT
5240 ,p_module => l_log_module);
5241 END IF;
5242
5243 END IF;
5244
5245 IF (l_msg_count > 0) THEN
5246 dequeue_completion_messages(p_msg_count => l_msg_count);
5247 END IF;
5248
5249 IF (NOT is_any_child_running) THEN
5250
5251 IF (C_LEVEL_EVENT >= g_log_level) THEN
5252 trace
5253 (p_msg => 'No children process running : EXIT processing events'
5254 ,p_level => C_LEVEL_EVENT
5255 ,p_module => l_log_module);
5256 END IF;
5257
5258 EXIT;
5259 END IF;
5260
5261 END IF; -- if l_children_spawned
5262
5263 END LOOP;
5264
5265 IF (C_LEVEL_EVENT >= g_log_level) THEN
5266 trace
5267 (p_msg => 'END LOOP : enqueue document messges'
5268 ,p_level => C_LEVEL_EVENT
5269 ,p_module => l_log_module);
5270 END IF;
5271
5272 IF (NOT l_children_spawned) THEN
5273 xla_accounting_err_pkg.build_message
5274 (p_appli_s_name => 'XLA'
5275 ,p_msg_name => 'XLA_AP_NO_EVENT_TO_PROCESS'
5276 ,p_entity_id => NULL
5277 ,p_event_id => NULL);
5278
5279 print_logfile('Technical warning : There are no events to process.');
5280
5281 RAISE normal_termination;
5282
5283 ELSE
5284 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Enqueueing completed');
5285
5286 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5287 trace
5288 (p_msg => 'Number of processing units = '||l_total_msg_count
5289 ,p_level => C_LEVEL_STATEMENT
5290 ,p_module => l_log_module);
5291 trace
5292 (p_msg => 'Number of entities = '|| g_parent_data.total_entity_count
5293 ,p_level => C_LEVEL_STATEMENT
5294 ,p_module => l_log_module);
5295 END IF;
5296 END IF;
5297
5298 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5299 trace
5300 (p_msg => 'END of procedure process_events'
5301 ,p_level => C_LEVEL_PROCEDURE
5302 ,p_module => l_log_module);
5303 END IF;
5304 EXCEPTION
5305 WHEN normal_termination THEN
5306 RAISE;
5307 WHEN xla_exceptions_pkg.application_exception THEN
5308 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
5309 trace
5310 (p_msg => 'xla_exceptions_pkg.application_exception: process_events'
5311 ,p_level => C_LEVEL_EXCEPTION
5312 ,p_module => l_log_module);
5313 END IF;
5314 RAISE;
5315 WHEN OTHERS THEN
5316 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
5317 trace
5318 (p_msg => 'EXCEPTION: process_events'
5319 ,p_level => C_LEVEL_EXCEPTION
5320 ,p_module => l_log_module);
5321 END IF;
5322 xla_exceptions_pkg.raise_message
5323 (p_location => 'xla_accounting_pkg.process_events');
5324 END process_events; -- end of procedure
5325
5326
5327
5328 --=============================================================================
5329 --
5330 --
5331 --
5332 --=============================================================================
5333 PROCEDURE spawn_child_processes IS
5334 PRAGMA AUTONOMOUS_TRANSACTION;
5335 l_ep_request_ids xla_accounting_pkg.t_array_number;
5336 l_log_module VARCHAR2(240);
5337 BEGIN
5338 IF g_log_enabled THEN
5339 l_log_module := C_DEFAULT_MODULE||'.spawn_child_processes';
5340 END IF;
5341 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5342 trace
5343 (p_msg => 'BEGIN of procedure SPAWN_CHILD_PROCESSES'
5344 ,p_level => C_LEVEL_PROCEDURE
5345 ,p_module => l_log_module);
5346 END IF;
5347
5348 FOR i IN 1..(g_process_count) LOOP
5349 l_ep_request_ids(i) :=
5350 fnd_request.submit_request
5351 (application => 'XLA'
5352 ,program => 'XLAACCUP'
5353 ,description => NULL
5354 ,start_time => NULL
5355 ,sub_request => FALSE
5356 ,argument1 => g_application_id
5357 ,argument2 => g_ledger_id
5358 ,argument3 => to_char(g_end_date,'YYYY/MM/DD')
5359 ,argument4 => g_accounting_mode
5360 ,argument5 => g_error_only_flag
5361 ,argument6 => g_accounting_batch_id
5362 ,argument7 => g_parent_request_id
5363 ,argument8 => g_report_request_id
5364 ,argument9 => g_queue_name
5365 ,argument10 => g_comp_queue_name
5366 ,argument11 => g_error_limit
5367 ,argument12 => g_seq_enabled_flag
5368 ,argument13 => g_transfer_flag
5369 ,argument14 => g_gl_posting_flag
5370 ,argument15 => g_gl_batch_name); -- Bug 5257343
5371
5372 IF l_ep_request_ids(i) = 0 THEN
5373 IF (C_LEVEL_EXCEPTION>= g_log_level) THEN
5374 trace
5375 (p_msg => 'Technical Error : Unable to submit child requests.'
5376 ,p_level => C_LEVEL_EXCEPTION
5377 ,p_module => l_log_module);
5378 END IF;
5379
5380 xla_accounting_err_pkg.build_message
5381 (p_appli_s_name => 'XLA'
5382 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
5383 ,p_token_1 => 'APPLICATION_NAME'
5384 ,p_value_1 => 'SLA'
5385 ,p_entity_id => NULL
5386 ,p_event_id => NULL);
5387
5388 print_logfile('Technical Error : Unable to submit child requests');
5389
5390 xla_exceptions_pkg.raise_message
5391 (p_appli_s_name => 'XLA'
5392 ,p_msg_name => 'XLA_COMMON_ERROR'
5393 ,p_token_1 => 'LOCATION'
5394 ,p_value_1 => 'xla_accounting_pkg.spawn_child_processes'
5395 ,p_token_2 => 'ERROR'
5396 ,p_value_2 => 'Technical Error : Unable to submit child requests.');
5397
5398 END IF;
5399 END LOOP;
5400
5401 g_ep_request_ids := l_ep_request_ids;
5402
5403
5404 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5405 FOR i IN 1 .. l_ep_request_ids.count LOOP
5406 trace
5407 (p_msg => 'Submitted unit processor request = '||l_ep_request_ids(i)
5408 ,p_level => C_LEVEL_STATEMENT
5409 ,p_module => l_log_module);
5410 END LOOP;
5411 END IF;
5412
5413 COMMIT;
5414
5415 IF (C_LEVEL_EVENT >= g_log_level) THEN
5416 trace
5417 (p_msg => 'COMMIT issued in AUTONOMOUS_TRANSACTION procedure SPAWN_CHILD_PROCESSES'
5418 ,p_level => C_LEVEL_EVENT
5419 ,p_module => l_log_module);
5420 END IF;
5421
5422 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5423 trace
5424 (p_msg => 'END of procedure SPAWN_CHILD_PROCESSES'
5425 ,p_level => C_LEVEL_PROCEDURE
5426 ,p_module => l_log_module);
5427 END IF;
5428 EXCEPTION
5429 WHEN xla_exceptions_pkg.application_exception THEN
5430 RAISE;
5431 WHEN OTHERS THEN
5432 xla_exceptions_pkg.raise_message
5433 (p_location => 'xla_accounting_pkg.spawn_child_processes');
5434 END spawn_child_processes; -- end of procedure
5435
5436
5437 --=============================================================================
5438 --
5439 --
5440 --
5441 --=============================================================================
5442 PROCEDURE wait_for_requests
5443 (p_array_request_id IN t_array_number
5444 ,p_error_status OUT NOCOPY VARCHAR2
5445 ,p_warning_status OUT NOCOPY VARCHAR2) IS
5446 l_phase VARCHAR2(30);
5447 l_status VARCHAR2(30);
5448 l_dphase VARCHAR2(30);
5449 l_dstatus VARCHAR2(30);
5450 l_message VARCHAR2(240);
5451 l_btemp BOOLEAN;
5452 l_log_module VARCHAR2(240);
5453 BEGIN
5454 IF g_log_enabled THEN
5455 l_log_module := C_DEFAULT_MODULE||'.wait_for_requests';
5456 END IF;
5457 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5458 trace
5459 (p_msg => 'BEGIN of procedure WAIT_FOR_REQUESTS'
5460 ,p_level => C_LEVEL_PROCEDURE
5461 ,p_module => l_log_module);
5462 END IF;
5463
5464 ----------------------------------------------------------------------------
5465 -- Waiting for active/pending requests to complete
5466 ----------------------------------------------------------------------------
5467 IF p_array_request_id.count > 0 THEN
5468 FOR i IN 1..p_array_request_id.count LOOP
5469
5470 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5471 trace
5472 (p_msg => 'waiting for request id = '||p_array_request_id(i)
5473 ,p_level => C_LEVEL_STATEMENT
5474 ,p_module => l_log_module);
5475 END IF;
5476
5477 l_btemp := fnd_concurrent.wait_for_request
5478 (request_id => p_array_request_id(i)
5479 ,interval => 30
5480 ,phase => l_phase
5481 ,status => l_status
5482 ,dev_phase => l_dphase
5483 ,dev_status => l_dstatus
5484 ,message => l_message);
5485 IF NOT l_btemp THEN
5486 xla_accounting_err_pkg.build_message
5487 (p_appli_s_name => 'XLA'
5488 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
5489 ,p_token_1 => 'APPLICATION_NAME'
5490 ,p_value_1 => 'SLA'
5491 ,p_entity_id => NULL
5492 ,p_event_id => NULL);
5493
5494 print_logfile('Technical problem : FND_CONCURRENT.WAIT_FOR_REQUEST returned FALSE '||
5495 'while executing for request id '||p_array_request_id(i));
5496 ELSE
5497 IF (C_LEVEL_EVENT >= g_log_level) THEN
5498 trace
5499 (p_msg => 'request completed with status = '||l_status
5500 ,p_level => C_LEVEL_EVENT
5501 ,p_module => l_log_module);
5502 END IF;
5503
5504 IF l_dstatus = 'WARNING' THEN
5505 p_warning_status := 'Y';
5506 ELSIF l_dstatus = 'ERROR' THEN
5507 p_error_status := 'Y';
5508 END IF;
5509 END IF;
5510 END LOOP;
5511 END IF;
5512
5513 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5514 trace
5515 (p_msg => 'END of procedure WAIT_FOR_REQUESTS'
5516 ,p_level => C_LEVEL_PROCEDURE
5517 ,p_module => l_log_module);
5518 END IF;
5519 EXCEPTION
5520 WHEN xla_exceptions_pkg.application_exception THEN
5521 RAISE;
5522 WHEN OTHERS THEN
5523 xla_exceptions_pkg.raise_message
5524 (p_location => 'xla_accounting_pkg.wait_for_requests');
5525 END wait_for_requests; -- end of procedure
5526
5527 --FSAH-PSFT FP
5528 --=============================================================================
5529 --
5530 --
5531 --
5532 --=============================================================================
5533 PROCEDURE wait_for_combo_edit_req
5534 (p_request_id IN NUMBER
5535 ,p_error_status OUT NOCOPY VARCHAR2
5536 ,p_warning_status OUT NOCOPY VARCHAR2) IS
5537 l_phase VARCHAR2(30);
5538 l_status VARCHAR2(30);
5539 l_dphase VARCHAR2(30);
5540 l_dstatus VARCHAR2(30);
5541 l_message VARCHAR2(240);
5542 l_btemp BOOLEAN;
5543 l_log_module VARCHAR2(240);
5544 BEGIN
5545 IF g_log_enabled THEN
5546 l_log_module := C_DEFAULT_MODULE||'.wait_for_combo_edit_req';
5547 END IF;
5548 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5549 trace
5550 (p_msg => 'BEGIN of procedure WAIT_FOR_COMBO_EDIT_REQ'
5551 ,p_level => C_LEVEL_PROCEDURE
5552 ,p_module => l_log_module);
5553 END IF;
5554
5555 ----------------------------------------------------------------------------
5556 -- Waiting for active/pending requests to complete
5557 ----------------------------------------------------------------------------
5558 IF p_request_id <> 0 THEN
5559 l_btemp := fnd_concurrent.wait_for_request
5560 (request_id => p_request_id
5561 ,interval => 30
5562 ,phase => l_phase
5563 ,status => l_status
5564 ,dev_phase => l_dphase
5565 ,dev_status => l_dstatus
5566 ,message => l_message);
5567 IF NOT l_btemp THEN
5568 xla_accounting_err_pkg.build_message
5569 (p_appli_s_name => 'XLA'
5570 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
5571 ,p_token_1 => 'APPLICATION_NAME'
5572 ,p_value_1 => 'SLA'
5573 ,p_entity_id => NULL
5574 ,p_event_id => NULL);
5575
5576 print_logfile('Technical problem : FND_CONCURRENT.WAIT_FOR_REQUEST returned FALSE '||
5577 'while executing for request id '||p_request_id);
5578 ELSE
5579 IF (C_LEVEL_EVENT >= g_log_level) THEN
5580 trace
5581 (p_msg => 'request completed with status = '||l_status
5582 ,p_level => C_LEVEL_EVENT
5583 ,p_module => l_log_module);
5584 END IF;
5585
5586 IF l_dstatus = 'WARNING' THEN
5587 p_warning_status := 'Y';
5588 ELSIF l_dstatus = 'ERROR' THEN
5589 p_error_status := 'Y';
5590 END IF;
5591 END IF;
5592 END IF;
5593
5594 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5595 trace
5596 (p_msg => 'END of procedure WAIT_FOR_REQUESTS'
5597 ,p_level => C_LEVEL_PROCEDURE
5598 ,p_module => l_log_module);
5599 END IF;
5600 EXCEPTION
5601 WHEN xla_exceptions_pkg.application_exception THEN
5602 RAISE;
5603 WHEN OTHERS THEN
5604 xla_exceptions_pkg.raise_message
5605 (p_location => 'xla_accounting_pkg.wait_for_combo_edit_req');
5606 END wait_for_combo_edit_req; -- end of procedure
5607 --FSAH-PSFT FP
5608
5609
5610
5611 --=============================================================================
5612 -- 5054831 - To validate that the AAD is valid in the database.
5613 --
5614 --
5615 --=============================================================================
5616 FUNCTION AAD_dbase_invalid(p_pad_name IN VARCHAR2,p_ledger_category_code IN VARCHAR2,p_enable_bc_flag IN VARCHAR2 ) return BOOLEAN
5617 IS
5618
5619 CURSOR c_aad_status(c_pad_name VARCHAR2) IS
5620 SELECT status
5621 FROM all_objects
5622 WHERE object_name = c_pad_name
5623 and owner = user
5624 ORDER BY STATUS asc;
5625
5626 /*
5627 select decode(o.status, 0, 'N/A', 1, 'VALID', 'INVALID')
5628 from sys.obj$ o, sys.user$ u
5629 where o.owner# = u.user#
5630 and o.linkname is null
5631 and (o.type# not in (1 ,
5632 10 )
5633 or
5634 (o.type# = 1 and 1 = (select 1
5635 from sys.ind$ i
5636 where i.obj# = o.obj#
5637 and i.type# in (1, 2, 3, 4, 6, 7, 9))))
5638 and o.name <> '_NEXT_OBJECT'
5639 and o.name <> '_default_auditing_options_'
5640 and o.name = p_pad_name
5641 and u.name ='APPS'
5642 order by 1 asc;
5643 */
5644
5645 l_log_module VARCHAR2(240);
5646 l_status VARCHAR2(10);
5647 l_pad_name VARCHAR2(30); -- 5531502
5648
5649 BEGIN
5650 IF g_log_enabled THEN
5651 l_log_module := C_DEFAULT_MODULE||'.AAD_dbase_invalid';
5652 END IF;
5653
5654 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5655 trace
5656 (p_msg => 'BEGIN of procedure AAD_dbase_invalid'
5657 ,p_level => C_LEVEL_PROCEDURE
5658 ,p_module => l_log_module);
5659 trace
5660 (p_msg => 'AAD p_pad_name= '||p_pad_name
5661 ,p_level => C_LEVEL_PROCEDURE
5662 ,p_module => l_log_module);
5663
5664 trace
5665 (p_msg => 'p_ledger_category_code= '||p_ledger_category_code
5666 ,p_level => C_LEVEL_PROCEDURE
5667 ,p_module => l_log_module);
5668
5669 trace
5670 (p_msg => 'p_enable_bc_flag= '||p_enable_bc_flag
5671 ,p_level => C_LEVEL_PROCEDURE
5672 ,p_module => l_log_module);
5673 END IF; -- 8238617 Added debug statements
5674
5675
5676 -- 5531502 Need to check for BC package
5677 IF NVL(g_budgetary_control_mode,'NONE') = 'NONE' THEN
5678 l_pad_name := p_pad_name;
5679 ELSE
5680 -- 6509160 Process non bc AAd package for Secondary non bc enabled ledger
5681 IF p_ledger_category_code='SECONDARY' AND p_enable_bc_flag='N' THEN
5682 /* commented for bug-9245677 */
5683 /* l_pad_name := p_pad_name; */
5684 NULL; /* added for bug-9245677 */
5685 ELSE
5686 l_pad_name := REPLACE(p_pad_name,'_PKG','_BC_PKG');
5687 END IF;
5688 END IF;
5689 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5690 trace
5691 (p_msg => 'g_budgetary_control_mode = '||g_budgetary_control_mode
5692 ,p_level => C_LEVEL_STATEMENT
5693 ,p_module => l_log_module);
5694 trace
5695 (p_msg => 'l_pad_name = '||l_pad_name
5696 ,p_level => C_LEVEL_STATEMENT
5697 ,p_module => l_log_module);
5698 END IF;
5699
5700 /* added for bug-9245677 */
5701 IF ( NVL(g_budgetary_control_mode,'NONE') = 'NONE'
5702 OR
5703 NOT( p_ledger_category_code='SECONDARY' and p_enable_bc_flag='N')
5704 )
5705 THEN
5706
5707 OPEN c_aad_status (l_pad_name);
5708 FETCH c_aad_status INTO l_status;
5709 IF c_aad_status%NOTFOUND or l_status = 'INVALID' THEN
5710 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5711 trace
5712 (p_msg => l_pad_name||' is invalid.'
5713 ,p_level => C_LEVEL_STATEMENT
5714 ,p_module => l_log_module);
5715 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - AAD Package '||l_pad_name||' is invalid.'|| ' Ledger Category is '||p_ledger_category_code||'.'); --Bug 11063454
5716 END IF;
5717 CLOSE c_aad_status;
5718 return TRUE;
5719 END IF;
5720 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - AAD Package '||l_pad_name||' is valid.'|| ' Ledger Category is '||p_ledger_category_code||'.'); --Bug 11063454
5721 CLOSE c_aad_status;
5722 END IF;
5723
5724 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5725 trace
5726 (p_msg => 'END of procedure AAD_dbase_invalid'
5727 ,p_level => C_LEVEL_PROCEDURE
5728 ,p_module => l_log_module);
5729 trace
5730 (p_msg => l_pad_name||' is valid.'
5731 ,p_level => C_LEVEL_PROCEDURE
5732 ,p_module => l_log_module);
5733 END IF;
5734
5735 return FALSE;
5736
5737 EXCEPTION
5738 WHEN normal_termination THEN
5739 if c_aad_status%ISOPEN THEN
5740 close c_aad_status;
5741 end if;
5742 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
5743 trace
5744 (p_msg => 'normal_termination: AAD_dbase_invalid'
5745 ,p_level => C_LEVEL_EXCEPTION
5746 ,p_module => l_log_module);
5747 END IF;
5748 RAISE;
5749 WHEN xla_exceptions_pkg.application_exception THEN
5750 if c_aad_status%ISOPEN THEN
5751 close c_aad_status;
5752 end if;
5753 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
5754 trace
5755 (p_msg => 'xla_exceptions_pkg.application_exception: AAD_dbase_invalid'
5756 ,p_level => C_LEVEL_EXCEPTION
5757 ,p_module => l_log_module);
5758 END IF;
5759 RAISE;
5760 WHEN OTHERS THEN
5761 if c_aad_status%ISOPEN THEN
5762 close c_aad_status;
5763 end if;
5764 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
5765 trace
5766 (p_msg => 'EXCEPTION: AAD_dbase_invalid'
5767 ,p_level => C_LEVEL_EXCEPTION
5768 ,p_module => l_log_module);
5769 END IF;
5770 xla_exceptions_pkg.raise_message
5771 (p_location => 'xla_accounting_pkg.AAD_dbase_invalid');
5772
5773 END AAD_dbase_invalid;
5774
5775 --=============================================================================
5776 -- 5054831 TO validate that the AAD is valid and there are events in the
5777 -- date range of the AAD
5778 --
5779 --=============================================================================
5780 PROCEDURE ValidateAAD (p_array_event_dates IN t_array_date)
5781 IS
5782
5783 l_log_module VARCHAR2(240);
5784 l_array_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
5785 l_array_ledger_pad xla_accounting_cache_pkg.t_array_pad;
5786 l_max_event_date date;
5787 l_min_event_date date;
5788 l_count NUMBER :=0;
5789 l_encoded_msg VARCHAR2(2000) := null;
5790 l_ledger_category_code VARCHAR2(50);
5791 l_enable_bc_flag VARCHAR2(1):=null;
5792
5793 BEGIN
5794 IF g_log_enabled THEN
5795 l_log_module := C_DEFAULT_MODULE||'.ValidateAAD';
5796 END IF;
5797
5798 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5799 trace
5800 (p_msg => 'BEGIN of procedure ValidateAAD'
5801 ,p_level => C_LEVEL_PROCEDURE
5802 ,p_module => l_log_module);
5803 END IF;
5804
5805 l_array_ledgers := xla_accounting_cache_pkg.GetLedgers;
5806
5807 if p_array_event_dates.COUNT > 0 then
5808 l_min_event_date := p_array_event_dates(1);
5809 l_max_event_date := p_array_event_dates(p_array_event_dates.COUNT);
5810 end if;
5811
5812 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5813 trace
5814 (p_msg => 'count='||p_array_event_dates.COUNT
5815 ,p_level => C_LEVEL_STATEMENT
5816 ,p_module => l_log_module);
5817 trace
5818 (p_msg => 'min event_date='||l_min_event_date
5819 ,p_level => C_LEVEL_STATEMENT
5820 ,p_module => l_log_module);
5821 trace
5822 (p_msg => 'max event_date='||l_max_event_date
5823 ,p_level => C_LEVEL_STATEMENT
5824 ,p_module => l_log_module);
5825 FOR i in 1 .. p_array_event_dates.COUNT LOOP
5826 trace
5827 (p_msg => 'event_date='||p_array_event_dates(i)
5828 ,p_level => C_LEVEL_STATEMENT
5829 ,p_module => l_log_module);
5830 END LOOP;
5831
5832 END IF;
5833
5834 FOR i in 1..l_array_ledgers.COUNT LOOP
5835
5836 -- get category code of ledger
5837 SELECT ledger_category_code,enable_budgetary_control_flag
5838 INTO l_ledger_category_code,l_enable_bc_flag
5839 FROM gl_ledgers
5840 WHERE ledger_id = l_array_ledgers(i);
5841 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5842 trace
5843 (p_msg => 'ledger category code ='||l_ledger_category_code||'bc flag='||l_enable_bc_flag
5844 ,p_level => C_LEVEL_STATEMENT
5845 ,p_module => l_log_module);
5846
5847 END IF;
5848
5849 -- get the AAD for this ledger
5850 l_array_ledger_pad := xla_accounting_cache_pkg.GetArrayPad
5851 (p_ledger_id => l_array_ledgers(i)
5852 ,p_max_event_date => l_max_event_date
5853 ,p_min_event_date => l_min_event_date);
5854
5855 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5856 trace
5857 (p_msg => 'ledger='||l_array_ledgers(i)
5858 ,p_level => C_LEVEL_STATEMENT
5859 ,p_module => l_log_module);
5860 FOR j in 1..l_array_ledger_pad.COUNT LOOP
5861 trace
5862 (p_msg => 'pad ='||l_array_ledger_pad(j).pad_package_name||
5863 ' status='||l_array_ledger_pad(j).compile_status_code||
5864 ' start='||l_array_ledger_pad(j).start_date_active||
5865 ' end='||l_array_ledger_pad(j).end_date_active
5866 ,p_level => C_LEVEL_STATEMENT
5867 ,p_module => l_log_module);
5868 END LOOP;
5869 END IF;
5870
5871 -- Verify if any AAD is invalid and there are event dates within the AAD date range.
5872 FOR k in 1..l_array_ledger_pad.COUNT LOOP
5873 -- Bug 8323089 : Changed from compile_status_code = 'N' to compile_status_code <> 'Y'
5874 IF l_array_ledger_pad(k).compile_status_code <> 'Y' or
5875 (l_array_ledger_pad(k).compile_status_code = 'Y' and AAD_dbase_invalid(l_array_ledger_pad(k).pad_package_name,l_ledger_category_code,l_enable_bc_flag)) THEN
5876
5877 FOR l in 1..p_array_event_dates.COUNT LOOP
5878 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5879 trace
5880 (p_msg => 'event date = '||p_array_event_dates(l)||
5881 ' pad='||l_array_ledger_pad(k).pad_package_name||
5882 ' start='||l_array_ledger_pad(k).start_date_active||
5883 ' end='||l_array_ledger_pad(k).end_date_active
5884 ,p_level => C_LEVEL_STATEMENT
5885 ,p_module => l_log_module);
5886 END IF;
5887
5888 IF p_array_event_dates(l) >= l_array_ledger_pad(k).start_date_active AND
5889 p_array_event_dates(l) <= NVL(l_array_ledger_pad(k).end_date_active,p_array_event_dates(l)) THEN
5890
5891 l_count := l_count + 1;
5892 /*--------------------------------------------------------------------------------------------------
5893 -- problem; error is not deleted on rerun during online accounting. for batch, error is not created.
5894 xla_accounting_err_pkg.build_message
5895 (p_appli_s_name => 'XLA'
5896 ,p_msg_name => 'XLA_AP_PAD_INACTIVE'
5897 ,p_token_1 => 'PAD_NAME'
5898 ,p_value_1 => l_array_ledger_pad(k).ledger_product_rule_name
5899 ,p_token_2 => 'OWNER'
5900 ,p_value_2 => xla_lookups_pkg.get_meaning(
5901 'XLA_OWNER_TYPE'
5902 ,l_array_ledger_pad(k).product_rule_owner)
5903 ,p_token_3 => 'SUBLEDGER_ACCTG_METHOD'
5904 ,p_value_3 => xla_accounting_cache_pkg.GetSessionValueChar
5905 (p_source_code => 'XLA_ACCOUNTING_METHOD_NAME'
5906 ,p_target_ledger_id => l_array_ledgers(i))
5907 ,p_entity_id => null
5908 ,p_event_id => null
5909 ,p_ledger_id => l_array_ledgers(i)
5910 ,p_accounting_batch_id => g_accounting_batch_id);
5911 --------------------------------------------------------------------------------------------------*/
5912 xla_messages_pkg.build_message
5913 (p_appli_s_name => 'XLA'
5914 ,p_msg_name => 'XLA_AP_PAD_INACTIVE'
5915 ,p_token_1 => 'PAD_NAME'
5916 ,p_value_1 => l_array_ledger_pad(k).ledger_product_rule_name
5917 ,p_token_2 => 'OWNER'
5918 ,p_value_2 => xla_lookups_pkg.get_meaning(
5919 'XLA_OWNER_TYPE'
5920 ,l_array_ledger_pad(k).product_rule_owner)
5921 ,p_token_3 => 'SUBLEDGER_ACCTG_METHOD'
5922 ,p_value_3 => xla_accounting_cache_pkg.GetSessionValueChar
5923 (p_source_code => 'XLA_ACCOUNTING_METHOD_NAME'
5924 ,p_target_ledger_id => l_array_ledgers(i)));
5925
5926 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5927 trace
5928 (p_msg => 'Invalid AAD = '||l_array_ledger_pad(k).pad_package_name
5929 ,p_level => C_LEVEL_STATEMENT
5930 ,p_module => l_log_module);
5931 END IF;
5932 exit;
5933
5934 END IF;
5935
5936 END LOOP; -- p_array_event_dates
5937
5938 END IF; -- l_array_ledger_pad(k).compile_status_code = 'N'
5939
5940 END LOOP; -- l_array_ledger_pad
5941
5942 END LOOP; -- l_array_ledgers
5943
5944 IF l_count> 0 THEN
5945 l_encoded_msg := fnd_message.get();
5946 raise xla_exceptions_pkg.application_exception;
5947 END IF;
5948
5949 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5950 trace
5951 (p_msg => 'END of procedure ValidateAAD'
5952 ,p_level => C_LEVEL_PROCEDURE
5953 ,p_module => l_log_module);
5954 END IF;
5955
5956 EXCEPTION
5957 WHEN xla_exceptions_pkg.application_exception THEN
5958 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
5959 trace
5960 (p_msg => 'xla_exceptions_pkg.application_exception: ValidateAAD'
5961 ,p_level => C_LEVEL_EXCEPTION
5962 ,p_module => l_log_module);
5963 END IF;
5964 IF l_count>0 THEN
5965 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - '||l_encoded_msg);
5966 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN -- log
5967 trace
5968 (p_msg => l_encoded_msg
5969 ,p_level => C_LEVEL_EXCEPTION
5970 ,p_module => l_log_module);
5971 END IF;
5972 END IF;
5973 RAISE;
5974 WHEN OTHERS THEN
5975 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
5976 trace
5977 (p_msg => 'EXCEPTION: ValidateAAD'
5978 ,p_level => C_LEVEL_EXCEPTION
5979 ,p_module => l_log_module);
5980 END IF;
5981 xla_exceptions_pkg.raise_message
5982 (p_location => 'xla_accounting_pkg.ValidateAAD');
5983 END ValidateAAD;
5984
5985
5986 --=============================================================================
5987 --
5988 -- The following ValidateAAD is called from unit_processor in batch accounting.
5989 -- It checks validity of AAD in the AMB and in database. If any AAD is invalid
5990 -- in AMB or in database, the procedure terminates 'Accoutning Program'.
5991 --
5992 --=============================================================================
5993
5994 PROCEDURE ValidateAAD
5995 (p_max_event_date IN DATE)
5996 IS
5997
5998 C_MIN_EVENT_DATE CONSTANT DATE := TO_DATE('01/01/1900','DD/MM/YYYY');
5999
6000 l_log_module VARCHAR2(240);
6001 l_array_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
6002 l_array_ledger_pad xla_accounting_cache_pkg.t_array_pad;
6003 l_count NUMBER :=0;
6004 l_message VARCHAR2(2000);
6005
6006 l_pad_name VARCHAR2(240);
6007 l_pad_owner VARCHAR2(240);
6008 l_slam VARCHAR2(240);
6009 l_ledger_category_code VARCHAR2(50);
6010 l_enable_bc_flag VARCHAR2(1):=null;
6011
6012
6013 BEGIN
6014 IF g_log_enabled THEN
6015 l_log_module := C_DEFAULT_MODULE||'.ValidateAAD';
6016 END IF;
6017
6018 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6019 trace
6020 (p_msg => 'BEGIN of procedure ValidateAAD'
6021 ,p_level => C_LEVEL_PROCEDURE
6022 ,p_module => l_log_module);
6023 trace
6024 (p_msg => 'p_max_event_date = '||p_max_event_date
6025 ,p_level => C_LEVEL_PROCEDURE
6026 ,p_module => l_log_module);
6027 END IF;
6028
6029 l_array_ledgers := xla_accounting_cache_pkg.GetLedgers;
6030
6031 FOR i in 1..l_array_ledgers.COUNT LOOP
6032
6033 -- get category code of ledger
6034 SELECT ledger_category_code,enable_budgetary_control_flag
6035 INTO l_ledger_category_code,l_enable_bc_flag
6036 FROM gl_ledgers
6037 WHERE ledger_id = l_array_ledgers(i);
6038
6039 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6040 trace
6041 (p_msg => 'ledger category code ='||l_ledger_category_code||' bc flag='||l_enable_bc_flag
6042 ,p_level => C_LEVEL_STATEMENT
6043 ,p_module => l_log_module);
6044
6045 END IF;
6046
6047 -- get the AAD for this ledger
6048 l_array_ledger_pad :=
6049 xla_accounting_cache_pkg.GetArrayPad
6050 (p_ledger_id => l_array_ledgers(i)
6051 ,p_max_event_date => p_max_event_date
6052 ,p_min_event_date => C_MIN_EVENT_DATE);
6053
6054
6055 -- Verify if any AAD is invalid and there are event dates within the AAD date range.
6056 FOR k in 1..l_array_ledger_pad.COUNT LOOP
6057 -- Bug 8323089 : Changed from compile_status_code = 'N' to compile_status_code <> 'Y'
6058 IF (l_array_ledger_pad(k).compile_status_code <> 'Y' OR
6059 (l_array_ledger_pad(k).compile_status_code = 'Y' AND
6060 AAD_dbase_invalid(l_array_ledger_pad(k).pad_package_name,l_ledger_category_code,l_enable_bc_flag)
6061 )
6062 )
6063 THEN
6064 l_pad_name := l_array_ledger_pad(k).ledger_product_rule_name;
6065 l_pad_owner := xla_lookups_pkg.get_meaning
6066 ('XLA_OWNER_TYPE'
6067 ,l_array_ledger_pad(k).product_rule_owner);
6068 l_slam := xla_accounting_cache_pkg.GetSessionValueChar
6069 (p_source_code => 'XLA_ACCOUNTING_METHOD_NAME'
6070 ,p_target_ledger_id => l_array_ledgers(i));
6071
6072 l_count := l_count + 1;
6073
6074 xla_messages_pkg.build_message
6075 (p_appli_s_name => 'XLA'
6076 ,p_msg_name => 'XLA_AP_PAD_INACTIVE'
6077 ,p_token_1 => 'PAD_NAME'
6078 ,p_value_1 => l_pad_name
6079 ,p_token_2 => 'OWNER'
6080 ,p_value_2 => l_pad_owner
6081 ,p_token_3 => 'SUBLEDGER_ACCTG_METHOD'
6082 ,p_value_3 => l_slam);
6083
6084 l_message := fnd_message.get();
6085
6086 print_logfile(l_message);
6087
6088 END IF; -- l_array_ledger_pad(k).compile_status_code = 'N'
6089 END LOOP; -- l_array_ledger_pad
6090 END LOOP; -- l_array_ledgers
6091
6092 IF l_count > 0 THEN
6093 xla_exceptions_pkg.raise_message
6094 (p_location => 'xla_accounting_pkg.ValidateAAD');
6095 END IF;
6096
6097 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6098 trace
6099 (p_msg => 'END of procedure ValidateAAD'
6100 ,p_level => C_LEVEL_PROCEDURE
6101 ,p_module => l_log_module);
6102 END IF;
6103
6104 EXCEPTION
6105 WHEN xla_exceptions_pkg.application_exception THEN
6106 RAISE;
6107 WHEN OTHERS THEN
6108 xla_exceptions_pkg.raise_message
6109 (p_location => 'xla_accounting_pkg.ValidateAAD');
6110 END ValidateAAD;
6111
6112 --=============================================================================
6113 --
6114 --
6115 --
6116 --=============================================================================
6117
6118 PROCEDURE unit_processor IS
6119 TYPE t_lock_events_cur IS REF CURSOR;
6120 lock_events_cur t_lock_events_cur;
6121
6122 l_deq_options dbms_aq.dequeue_options_t;
6123 l_enq_options dbms_aq.enqueue_options_t;
6124 l_msg_prop dbms_aq.message_properties_t;
6125 l_msgid RAW(16);
6126 --l_message xla_queue_msg_type; --SYSTEM.xla_queue_msg_type;
6127 l_entity_count NUMBER := 0;
6128 l_event_count NUMBER := 0;
6129 l_dequeue_flag BOOLEAN;
6130
6131 l_ret_val_acctg_engine NUMBER;
6132 l_sqlerrm VARCHAR2(2000);
6133 l_log_module VARCHAR2(240);
6134 l_transfer_mode VARCHAR2(30);
6135
6136 l_array_events xla_accounting_pkg.t_array_number;
6137
6138 -------------------------------------------------------
6139 -- 4597150
6140 -------------------------------------------------------
6141 l_all_event_classes VARCHAR2(10000);
6142 l_class_current_order VARCHAR2(5000);
6143 l_class_anytime_order VARCHAR2(5000);
6144 l_str1_insert_events VARCHAR2(32000);
6145 l_str2_insert_events VARCHAR2(32000);
6146 l_evt_num_subqry VARCHAR2(32000);
6147 -------------------------------------------------------
6148 l_lock_events_str VARCHAR2(32000); --14105024
6149 -------------------------------------------------------
6150 -- Bug 5056632
6151 -------------------------------------------------------
6152 l_array_base_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
6153 l_array_alc_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
6154 l_primary_ledger_group_id NUMBER;
6155 l_temp NUMBER;
6156
6157 l_event_insert_count number;
6158
6159 BEGIN
6160 IF g_log_enabled THEN
6161 l_log_module := C_DEFAULT_MODULE||'.unit_processor';
6162 END IF;
6163 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6164 trace
6165 (p_msg => 'BEGIN of procedure UNIT_PROCESSOR'
6166 ,p_level => C_LEVEL_PROCEDURE
6167 ,p_module => l_log_module);
6168 END IF;
6169
6170 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Ready to cache the Application and Ledger Level Sources ...');
6171
6172 xla_accounting_cache_pkg.load_application_ledgers
6173 (p_application_id => g_application_id
6174 ,p_event_ledger_id => g_ledger_id
6175 ,p_max_event_date => g_end_date);
6176
6177 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Cached the Application and Ledger Level Sources');
6178
6179 -- validate AADs
6180 ValidateAAD(g_end_date);
6181
6182 --
6183 -- Bug 5056632
6184 -- The following fetches group_id and stores them in an array for Transfer
6185 -- to GL. There is a distinct groupid for each base ledger. ALCs share
6186 -- their group_id with Primary ledger..
6187 --
6188 IF g_accounting_mode = 'F' AND g_transfer_flag = 'Y' THEN
6189 l_array_base_ledgers := xla_accounting_cache_pkg.GetLedgers;
6190 l_array_alc_ledgers := xla_accounting_cache_pkg.GetAlcLedgers(g_ledger_id);
6191 --For bug fix 7677948
6192 FOR i IN l_array_base_ledgers.FIRST..l_array_base_ledgers.LAST LOOP
6193 SELECT gl_interface_control_s.NEXTVAL, l_array_base_ledgers(i)
6194 INTO g_array_group_id(i), g_array_ledger_id(i)
6195 FROM DUAL;
6196
6197 IF l_array_alc_ledgers.COUNT > 0 AND
6198 l_array_base_ledgers(i) = g_ledger_id
6199 THEN
6200 l_primary_ledger_group_id := g_array_group_id(i);
6201 END IF;
6202 END LOOP;
6203
6204 IF l_array_alc_ledgers.COUNT > 0 THEN
6205 l_temp := g_array_group_id.COUNT;
6206 FOR i IN (l_array_alc_ledgers.FIRST)..(l_array_alc_ledgers.LAST) LOOP
6207 g_array_group_id(i+l_temp) := l_primary_ledger_group_id;
6208 g_array_ledger_id(i+l_temp) := l_array_alc_ledgers(i);
6209 END LOOP;
6210 END IF;
6211 END IF;
6212
6213 ----------------------------------------------------------------------------
6214 -- Following initiates queue/message related variables
6215 ----------------------------------------------------------------------------
6216 l_deq_options.consumer_name := NULL;
6217 l_deq_options.dequeue_mode := dbms_aq.REMOVE;
6218 l_deq_options.navigation := dbms_aq.FIRST_MESSAGE;
6219 l_deq_options.visibility := dbms_aq.IMMEDIATE;
6220 l_deq_options.wait := 60;
6221 l_deq_options.msgid := NULL;
6222 l_deq_options.correlation := NULL;
6223
6224 l_enq_options.visibility := dbms_aq.IMMEDIATE;
6225 l_enq_options.relative_msgid := NULL;
6226 l_enq_options.sequence_deviation := NULL;
6227
6228 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Entering the loop to read document units from the queue ...');
6229
6230 LOOP -- (reading messages from the queue)
6231 -------------------------------------------------------------------------
6232 -- Initializing variables for a loop
6233 -------------------------------------------------------------------------
6234 l_event_count := 0;
6235
6236 -------------------------------------------------------------------------
6237 -- Following checks to make sure the error count for the accounting
6238 -- program has not reached the error limit.
6239 -------------------------------------------------------------------------
6240 IF ((xla_accounting_err_pkg.g_error_limit IS NOT NULL) AND
6241 (xla_accounting_err_pkg.get_total_error_count >=
6242 xla_accounting_err_pkg.g_error_limit
6243 )
6244 )
6245 THEN
6246 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - This child process is exiting the loop due to the error limit defined in the setups');
6247
6248 IF (C_LEVEL_EVENT >= g_log_level) THEN
6249 trace
6250 (p_msg => 'Message : This child process is exiting the loop due to the error limit defined in the setups'
6251 ,p_level => C_LEVEL_EVENT
6252 ,p_module => l_log_module);
6253 END IF;
6254 EXIT;
6255 END IF;
6256
6257 -------------------------------------------------------------------------
6258 -- Following checks whether the parent accounting program is active
6259 -- or not.
6260 -------------------------------------------------------------------------
6261 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Checking status of the parent Accounting Program');
6262 IF NOT is_parent_running THEN
6263
6264 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6265 trace
6266 (p_msg => 'Technical Error : The parent request for this request is not running'
6267 ,p_level => C_LEVEL_EXCEPTION
6268 ,p_module => l_log_module);
6269 END IF;
6270
6271 xla_exceptions_pkg.raise_message
6272 (p_appli_s_name => 'XLA'
6273 ,p_msg_name => 'XLA_COMMON_ERROR'
6274 ,p_token_1 => 'LOCATION'
6275 ,p_value_1 => 'xla_accounting_pkg.unit_processor'
6276 ,p_token_2 => 'ERROR'
6277 ,p_value_2 => 'Technical Error : The parent request for this request is not running.');
6278 END IF;
6279
6280 -------------------------------------------------------------------------
6281 -- read message from the queue.
6282 -------------------------------------------------------------------------
6283
6284 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Dequeuing the unit from the queue');
6285
6286 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6287 trace
6288 (p_msg => 'Ready to dequeue message from message queue'
6289 ,p_level => C_LEVEL_STATEMENT
6290 ,p_module => l_log_module);
6291 END IF;
6292
6293 l_dequeue_flag := TRUE;
6294 WHILE (l_dequeue_flag) LOOP
6295 BEGIN
6296 dbms_aq.dequeue
6297 (g_queue_name
6298 ,l_deq_options
6299 ,l_msg_prop
6300 ,g_message
6301 ,l_msgid);
6302 l_dequeue_flag := FALSE;
6303 EXCEPTION
6304 WHEN OTHERS THEN
6305
6306 IF g_conc_hold = 'Y' AND SQLCODE = -25228 /* Timeout; queue is likely empty... */
6307 THEN
6308 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
6309 ||' - Dequeue of ' ||
6310 g_queue_name ||' Timed out');
6311 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
6312 ||' - Please run Transfer to GL explicitly.');
6313 trace(p_msg => 'Queue is empty.'
6314 ,p_level => C_LEVEL_EXCEPTION
6315 ,p_module => l_log_module);
6316
6317 RAISE;
6318 END IF;
6319
6320 IF NOT is_parent_running THEN
6321
6322 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6323 trace
6324 (p_msg => 'Technical Error : The parent request for this request is not running'
6325 ,p_level => C_LEVEL_EXCEPTION
6326 ,p_module => l_log_module);
6327 END IF;
6328
6329 xla_exceptions_pkg.raise_message
6330 (p_appli_s_name => 'XLA'
6331 ,p_msg_name => 'XLA_COMMON_ERROR'
6332 ,p_token_1 => 'LOCATION'
6333 ,p_value_1 => 'xla_accounting_pkg.unit_processor'
6334 ,p_token_2 => 'ERROR'
6335 ,p_value_2 => 'Technical Error : The parent request for this request is not running.');
6336 END IF;
6337 END;
6338 END LOOP;
6339
6340 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6341 trace
6342 (p_msg => 'Message from message queue is dequeued'
6343 ,p_level => C_LEVEL_STATEMENT
6344 ,p_module => l_log_module);
6345 END IF;
6346
6347 g_child_data.dequeued_msg_count := g_child_data.dequeued_msg_count + 1;
6348
6349 -------------------------------------------------------------------------
6350 -- Following code transfer control out of the loop when the message
6351 -- fetched from the queue has no documents in it (ie NULL).
6352 -- It is a very important step because this is the only exit point of
6353 -- the loop.
6354 -------------------------------------------------------------------------
6355 IF g_message.entity_ids IS NULL THEN
6356 IF (C_LEVEL_EVENT >= g_log_level) THEN
6357 trace
6358 (p_msg => 'Exiting the LOOP because this is end of messages in the message queue'
6359 ,p_level => C_LEVEL_EVENT
6360 ,p_module => l_log_module);
6361 END IF;
6362 EXIT;
6363 END IF;
6364
6365 g_child_data.selected_entity_count :=
6366 g_child_data.selected_entity_count + g_message.entity_ids.COUNT;
6367
6368 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Fetching event information for the documents in the unit');
6369
6370 -------------------------------------------------------------------------
6371 -- Following statement inserts event information into the temporary table
6372 -- for product teams to perform extract.
6373 -------------------------------------------------------------------------
6374 ----------------------------------------------------------------------------------------
6375 -- 4597150 Additional debug
6376 ----------------------------------------------------------------------------------------
6377 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6378 FOR i IN 1..g_message.entity_ids.COUNT LOOP
6379
6380 trace
6381 (p_msg => 'Entity_id = '||i||' = '||g_message.entity_ids(i)
6382 ,p_level => C_LEVEL_STATEMENT
6383 ,p_module => l_log_module);
6384
6385 END LOOP;
6386 END IF;
6387 ----------------------------------------------------------------------------------------
6388
6389 -------------------------------------------------------------------------------------------------
6390 -- 4597150 - divide Current Event Class and Anytime Event Class
6391 -- - list of EVENT_CLASSES is the same for each entity in this Child Process
6392 -------------------------------------------------------------------------------------------------
6393 -- if l_msg_prop.user_property = 'EC1','EC2'#-#-#-#-#-#-#-#'EC3','EC4' then
6394 -- l_class_current_order = 'EC1','EC2'
6395 -- l_class_anytime_order = 'EC3','EC4'
6396 -------------------------------------------------------------------------------------------------
6397 IF g_message.entity_ids IS NOT NULL THEN
6398
6399 ---------------------------------------------------------------------------
6400 -- extract combined event_classes from queue
6401 ---------------------------------------------------------------------------
6402 l_all_event_classes := SYS.AnyData.AccessVarchar2(l_msg_prop.user_property);
6403
6404 l_class_current_order :=
6405 SUBSTRB(l_all_event_classes
6406 ,1
6407 ,INSTRB(l_all_event_classes,C_DELIMITER)-1);
6408
6409 l_class_anytime_order :=
6410 SUBSTRB(l_all_event_classes
6411 ,LENGTH(C_DELIMITER)
6412 + INSTRB(l_all_event_classes,C_DELIMITER));
6413
6414 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6415 trace
6416 (p_msg => 'Event_Class : all = '||l_all_event_classes
6417 ,p_level => C_LEVEL_STATEMENT
6418 ,p_module => l_log_module);
6419 trace
6420 (p_msg => 'Event_Class : current = '||l_class_current_order
6421 ,p_level => C_LEVEL_STATEMENT
6422 ,p_module => l_log_module);
6423 trace
6424 (p_msg => 'Event_Class : anytime = '||l_class_anytime_order
6425 ,p_level => C_LEVEL_STATEMENT
6426 ,p_module => l_log_module);
6427 END IF;
6428
6429 END IF;
6430
6431 -------------------------------------------------------------------------
6432 -- Following is added to lock events. Bug 5534133
6433 -------------------------------------------------------------------------
6434 IF l_class_anytime_order is NULL THEN
6435 l_lock_events_str := REPLACE(C_LOCK_EVENTS_STR
6436 ,'$event_classes$'
6437 ,l_class_current_order);
6438 ELSE
6439 l_lock_events_str := REPLACE(C_LOCK_EVENTS_STR
6440 ,'$event_classes$'
6441 ,l_class_current_order||','||l_class_anytime_order);
6442 END IF;
6443
6444 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6445 trace
6446 (p_msg => 'l_lock_events_str = '|| l_lock_events_str
6447 ,p_level => C_LEVEL_STATEMENT
6448 ,p_module => l_log_module);
6449 END IF;
6450
6451 l_str1_insert_events := C_CURR_INS_EVENTS;
6452
6453 l_str1_insert_events := REPLACE(l_str1_insert_events
6454 ,'$event_classes$'
6455 ,l_class_current_order);
6456
6457 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6458 trace
6459 (p_msg => 'First l_str1_insert_events = '|| l_str1_insert_events
6460 ,p_level => C_LEVEL_STATEMENT
6461 ,p_module => l_log_module);
6462 END IF;
6463
6464 IF l_class_anytime_order IS NOT NULL
6465 AND NVL(l_class_current_order,-1) <> NVL(l_class_anytime_order,-1)
6466 THEN
6467 -- if only Processing Order -1 exist, then they are the same
6468
6469 l_str2_insert_events := C_ANYTIME_INS_EVENTS;
6470
6471 l_str2_insert_events := REPLACE(l_str2_insert_events
6472 ,'$event_classes$'
6473 ,l_class_anytime_order);
6474
6475 l_str2_insert_events := REPLACE(l_str2_insert_events
6476 ,'$event_class_current_order$'
6477 ,l_class_current_order);
6478
6479 l_str2_insert_events := REPLACE(l_str2_insert_events
6480 ,'$event_class_anytime_order$'
6481 ,l_class_anytime_order); -- 4860037
6482
6483 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6484 trace
6485 (p_msg => 'Second l_str2_insert_events = '|| l_str2_insert_events
6486 ,p_level => C_LEVEL_STATEMENT
6487 ,p_module => l_log_module);
6488 END IF;
6489 END IF;
6490
6491 OPEN lock_events_cur for l_lock_events_str
6492 USING xla_accounting_pkg.g_message.entity_ids
6493 ,g_application_id
6494 ,g_end_date
6495 ,g_accounting_mode;
6496 LOOP
6497 fetch lock_events_cur bulk collect into l_array_events limit 5000;
6498 EXIT WHEN l_array_events.COUNT = 0;
6499
6500 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6501 trace
6502 (p_msg => 'l_array_events.COUNT = '|| l_array_events.COUNT
6503 ,p_level => C_LEVEL_STATEMENT
6504 ,p_module => l_log_module);
6505 END IF;
6506
6507
6508 FORALL i IN 1..l_array_events.COUNT
6509 EXECUTE IMMEDIATE l_str1_insert_events
6510 USING g_application_id
6511 ,g_end_date
6512 ,l_array_events(i)
6513 ,g_accounting_mode;
6514
6515 l_event_insert_count := SQL%ROWCOUNT;
6516
6517 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6518 trace
6519 (p_msg => 'l_event_insert_count = '||l_event_insert_count
6520 ,p_level => C_LEVEL_STATEMENT
6521 ,p_module => l_log_module);
6522 END IF;
6523
6524 --
6525 -- 4865292
6526 -- Compare event count with header extract count
6527 --
6528 l_event_count := l_event_count + l_event_insert_count;
6529
6530 --- End of First Insert ----------------------------------------------------------------------------
6531
6532 ----------------------------------------------------------------------------------------------------
6533 -- 4597150
6534 -- Second insert into xla_events_gt is for process order -1
6535 -- When all process orders are -1, events are inserted in
6536 -- the previous insert statement. In this case, l_class_anytime_order
6537 -- becomes null.
6538 ----------------------------------------------------------------------------------------------------
6539
6540 IF l_class_anytime_order IS NOT NULL
6541 AND NVL(l_class_current_order,-1) <> NVL(l_class_anytime_order,-1)
6542 THEN
6543
6544 FORALL i IN 1..l_array_events.COUNT
6545 EXECUTE IMMEDIATE l_str2_insert_events
6546 USING g_application_id
6547 ,g_end_date
6548 ,l_array_events(i)
6549 ,g_accounting_mode
6550 ,g_end_date
6551 ,g_accounting_mode;
6552
6553 l_event_insert_count := SQL%ROWCOUNT;
6554
6555 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6556 trace
6557 (p_msg => 'l_event_insert_count = '||l_event_insert_count
6558 ,p_level => C_LEVEL_STATEMENT
6559 ,p_module => l_log_module);
6560 END IF;
6561
6562 --
6563 -- 4865292
6564 -- Compare event count with header extract count
6565 --
6566 l_event_count := l_event_count + l_event_insert_count;
6567
6568 END IF;
6569 END LOOP;
6570 CLOSE lock_events_cur;
6571
6572 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6573 trace
6574 (p_msg => 'Number of events in XLA_EVENTS_GT = '||l_event_count
6575 ,p_level => C_LEVEL_STATEMENT
6576 ,p_module => l_log_module);
6577 END IF;
6578
6579 IF l_event_count = 0 THEN
6580 GOTO enqueue_completion_msg;
6581 END IF;
6582
6583 delete_request_je;
6584
6585 --
6586 -- 4865292
6587 -- Compare event count with header extract count
6588 --
6589 xla_context_pkg.set_event_count_context
6590 (p_event_count => l_event_count
6591 ,p_client_id => g_parent_request_id);
6592 --------------------------------------------------------------------------
6593 -- Handle extract hook
6594 --------------------------------------------------------------------------
6595 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - executing extract hook');
6596 handle_accounting_hook
6597 (p_application_id => g_application_id
6598 ,p_ledger_id => NULL
6599 ,p_process_category => NULL
6600 ,p_end_date => NULL
6601 ,p_accounting_mode => g_accounting_mode
6602 ,p_budgetary_control_mode => g_budgetary_control_mode
6603 ,p_valuation_method => NULL
6604 ,p_security_id_int_1 => NULL
6605 ,p_security_id_int_2 => NULL
6606 ,p_security_id_int_3 => NULL
6607 ,p_security_id_char_1 => NULL
6608 ,p_security_id_char_2 => NULL
6609 ,p_security_id_char_3 => NULL
6610 ,p_report_request_id => NULL
6611 ,p_event_name => 'extract'
6612 ,p_event_key => to_char(g_accounting_batch_id)||'-'
6613 ||to_char(g_parent_request_id)||'-'
6614 ||rawtohex(l_msgid));
6615 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - extract hook executed successfully');
6616
6617 dbms_session.set_identifier(client_id => g_parent_request_id); -- added for bug11903966
6618 ----------------------------------------------------------------------
6619 -- Call accounting engine
6620 ----------------------------------------------------------------------
6621 IF (C_LEVEL_EVENT >= g_log_level) THEN
6622 trace
6623 (p_msg => 'Calling the function XLA_ACCOUNTING_ENGINE_PKG.ACCOUNTINGENGINE'
6624 ,p_level => C_LEVEL_EVENT
6625 ,p_module => l_log_module);
6626 END IF;
6627
6628 l_ret_val_acctg_engine :=
6629 xla_accounting_engine_pkg.AccountingEngine
6630 (p_application_id => g_application_id
6631 ,p_ledger_id => g_ledger_id
6632 ,p_end_date => g_end_date -- 4262811
6633 ,p_accounting_mode => g_accounting_mode
6634 ,p_accounting_batch_id => g_accounting_batch_id
6635 ,p_budgetary_control_mode => 'NONE');
6636
6637 IF (C_LEVEL_EVENT >= g_log_level) THEN
6638 trace
6639 (p_msg => 'Function XLA_ACCOUNTING_ENGINE_PKG.ACCOUNTINGENGINE executed'
6640 ,p_level => C_LEVEL_EVENT
6641 ,p_module => l_log_module);
6642 END IF;
6643
6644 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6645 trace
6646 (p_msg => 'l_ret_val_acctg_engine = '||l_ret_val_acctg_engine
6647 ,p_level => C_LEVEL_STATEMENT
6648 ,p_module => l_log_module);
6649 trace
6650 (p_msg => 'g_accounting_mode = '||g_accounting_mode
6651 ,p_level => C_LEVEL_STATEMENT
6652 ,p_module => l_log_module);
6653 END IF;
6654
6655 ----------------------------------------------------------------------------
6656 -- Handle postprocessing hook
6657 ----------------------------------------------------------------------------
6658 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - executing postprocessing hook');
6659 handle_accounting_hook
6660 (p_application_id => g_application_id
6661 ,p_ledger_id => NULL
6662 ,p_process_category => NULL
6663 ,p_end_date => NULL
6664 ,p_accounting_mode => g_accounting_mode
6665 ,p_budgetary_control_mode => g_budgetary_control_mode
6666 ,p_valuation_method => NULL
6667 ,p_security_id_int_1 => NULL
6668 ,p_security_id_int_2 => NULL
6669 ,p_security_id_int_3 => NULL
6670 ,p_security_id_char_1 => NULL
6671 ,p_security_id_char_2 => NULL
6672 ,p_security_id_char_3 => NULL
6673 ,p_report_request_id => NULL
6674 ,p_event_name => 'postprocessing'
6675 ,p_event_key => to_char(g_accounting_batch_id)||'-'
6676 ||to_char(g_parent_request_id)||'-'
6677 ||rawtohex(l_msgid));
6678 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - postprocessing hook executed successfully');
6679
6680 dbms_session.set_identifier(client_id => g_parent_request_id); -- added for bug11903966
6681 -------------------------------------------------------------------------
6682 -- After processing each unit (fetched from the queue), accounting
6683 -- entries are sequenced (in FINAL mode) and commited in base tables and
6684 -- errors are moved from array to error table,
6685 -------------------------------------------------------------------------
6686 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Completing Journal Entries');
6687
6688 complete_entries;
6689 xla_accounting_err_pkg.insert_errors;
6690
6691 -------------------------------------------------------------------------
6692 -- Following checks whether the parent accounting program is active
6693 -- or not before commiting the transaction
6694 -------------------------------------------------------------------------
6695 IF is_parent_running THEN
6696 COMMIT;
6697
6698 IF (C_LEVEL_EVENT >= g_log_level) THEN
6699 trace
6700 (p_msg => 'COMMIT issued in UNIT_PROCESSOR'
6701 ,p_level => C_LEVEL_EVENT
6702 ,p_module => l_log_module);
6703 END IF;
6704
6705 ELSE
6706 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6707 trace
6708 (p_msg => 'Technical Error : The parent request for this request is not running'
6709 ,p_level => C_LEVEL_EXCEPTION
6710 ,p_module => l_log_module);
6711 END IF;
6712
6713 xla_exceptions_pkg.raise_message
6714 (p_appli_s_name => 'XLA'
6715 ,p_msg_name => 'XLA_COMMON_ERROR'
6716 ,p_token_1 => 'LOCATION'
6717 ,p_value_1 => 'xla_accounting_pkg.pre_accounting'
6718 ,p_token_2 => 'ERROR'
6719 ,p_value_2 => 'Technical Error : The parent request for this request is not running.');
6720 END IF;
6721
6722 <<enqueue_completion_msg>>
6723 --
6724 -- After processing one document message, enqueue a completion message
6725 --
6726 IF (C_LEVEL_EVENT >= g_log_level) THEN
6727 trace
6728 (p_msg => 'Enqueue completion message'
6729 ,p_level => C_LEVEL_EVENT
6730 ,p_module => l_log_module);
6731 END IF;
6732
6733 g_message := xla_queue_msg_type(NULL);
6734 dbms_aq.enqueue
6735 (g_comp_queue_name
6736 ,l_enq_options
6737 ,l_msg_prop
6738 ,g_message
6739 ,l_msgid);
6740
6741 IF (C_LEVEL_EVENT >= g_log_level) THEN
6742 trace
6743 (p_msg => 'Done Enqueue completion message'
6744 ,p_level => C_LEVEL_EVENT
6745 ,p_module => l_log_module);
6746 END IF;
6747
6748 END LOOP; -- (reading messages from the queue)
6749
6750 ----------------------------------------------------------------------------
6751 -- call routines to perform 'Transfer to GL'
6752 ----------------------------------------------------------------------------
6753 IF ((g_transfer_flag = 'Y') AND (g_accounting_mode = 'F' )) THEN
6754
6755 IF (C_LEVEL_EVENT >= g_log_level) THEN
6756 trace
6757 (p_msg => 'Transfer to GL process being called'
6758 ,p_level => C_LEVEL_EVENT
6759 ,p_module => l_log_module);
6760 END IF;
6761
6762 xla_accounting_err_pkg.set_options
6763 (p_error_source => xla_accounting_err_pkg.C_TRANSFER_TO_GL);
6764
6765 l_transfer_mode := 'COMBINED';
6766
6767 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6768 trace
6769 (p_msg => 'l_transfer_mode = '||l_transfer_mode
6770 ,p_level => C_LEVEL_STATEMENT
6771 ,p_module => l_log_module);
6772 END IF;
6773
6774 IF (C_LEVEL_EVENT >= g_log_level) THEN
6775 trace
6776 (p_msg => 'Calling transfer routine XLA_TRANSFER_PKG.GL_TRANSFER_MAIN'
6777 ,p_level => C_LEVEL_EVENT
6778 ,p_module => l_log_module);
6779 END IF;
6780
6781 --
6782 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Submitting the transfer to GL');
6783 xla_transfer_pkg.gl_transfer_main
6784 (p_application_id => g_application_id
6785 ,p_transfer_mode => l_transfer_mode
6786 ,p_ledger_id => g_ledger_id
6787 ,p_securiy_id_int_1 => g_security_id_int_1
6788 ,p_securiy_id_int_2 => g_security_id_int_2
6789 ,p_securiy_id_int_3 => g_security_id_int_3
6790 ,p_securiy_id_char_1 => g_security_id_char_1
6791 ,p_securiy_id_char_2 => g_security_id_char_2
6792 ,p_securiy_id_char_3 => g_security_id_char_3
6793 ,p_valuation_method => g_valuation_method
6794 ,p_process_category => g_process_category
6795 ,p_accounting_batch_id => NULL
6796 ,p_entity_id => NULL
6797 ,p_batch_name => g_gl_batch_name
6798 ,p_end_date => g_end_date
6799 ,p_submit_gl_post => g_gl_posting_flag
6800 ,p_caller => xla_transfer_pkg.C_ACCTPROG_BATCH); -- Bug 5056632
6801
6802 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - End of the transfer to GL');
6803
6804 IF (C_LEVEL_EVENT >= g_log_level) THEN
6805 trace
6806 (p_msg => 'Transfer routine XLA_TRANSFER_PKG.GL_TRANSFER_MAIN executed'
6807 ,p_level => C_LEVEL_EVENT
6808 ,p_module => l_log_module);
6809 END IF;
6810
6811 xla_accounting_err_pkg.set_options
6812 (p_error_source => xla_accounting_err_pkg.C_ACCT_PROGRAM);
6813
6814 END IF;
6815
6816 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6817 trace
6818 (p_msg => 'END of procedure UNIT_PROCESSOR'
6819 ,p_level => C_LEVEL_PROCEDURE
6820 ,p_module => l_log_module);
6821 END IF;
6822 EXCEPTION
6823 WHEN xla_exceptions_pkg.application_exception THEN
6824 g_message := xla_queue_msg_type(NULL);
6825 dbms_aq.enqueue
6826 (g_comp_queue_name
6827 ,l_enq_options
6828 ,l_msg_prop
6829 ,g_message
6830 ,l_msgid);
6831 RAISE;
6832 WHEN OTHERS THEN
6833 IF SQLCODE = -25228 AND g_conc_hold = 'Y' /* Timeout; queue is likely empty... */
6834 THEN
6835 RAISE;
6836 END IF;
6837 g_message := xla_queue_msg_type(NULL);
6838 dbms_aq.enqueue
6839 (g_comp_queue_name
6840 ,l_enq_options
6841 ,l_msg_prop
6842 ,g_message
6843 ,l_msgid);
6844 xla_exceptions_pkg.raise_message
6845 (p_location => 'xla_accounting_pkg.unit_processor');
6846 END unit_processor; -- end of function
6847
6848
6849
6850 --=============================================================================
6851 --
6852 --
6853 --
6854 --=============================================================================
6855 FUNCTION is_parent_running
6856 RETURN BOOLEAN IS
6857 l_phase VARCHAR2(30);
6858 l_status VARCHAR2(30);
6859 l_dphase VARCHAR2(30);
6860 l_dstatus VARCHAR2(30);
6861 l_message VARCHAR2(240);
6862 l_btemp BOOLEAN;
6863 l_result BOOLEAN;
6864 l_log_module VARCHAR2(240);
6865 BEGIN
6866 IF g_log_enabled THEN
6867 l_log_module := C_DEFAULT_MODULE||'.is_parent_running';
6868 END IF;
6869 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6870 trace
6871 (p_msg => 'BEGIN of function IS_PARENT_RUNNING'
6872 ,p_level => C_LEVEL_PROCEDURE
6873 ,p_module => l_log_module);
6874 END IF;
6875
6876 ----------------------------------------------------------------------------
6877 -- Waiting for active/pending requests to complete
6878 ----------------------------------------------------------------------------
6879 l_btemp := fnd_concurrent.get_request_status
6880 (request_id => g_parent_request_id
6881 ,phase => l_phase
6882 ,status => l_status
6883 ,dev_phase => l_dphase
6884 ,dev_status => l_dstatus
6885 ,message => l_message);
6886
6887 IF NOT l_btemp THEN
6888 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6889 trace
6890 (p_msg => 'Technical problem : FND_CONCURRENT.GET_REQUEST_STATUS returned FALSE '||
6891 'while executing for request id '||g_parent_request_id
6892 ,p_level => C_LEVEL_EXCEPTION
6893 ,p_module => l_log_module);
6894 END IF;
6895
6896 xla_exceptions_pkg.raise_message
6897 (p_appli_s_name => 'XLA'
6898 ,p_msg_name => 'XLA_COMMON_ERROR'
6899 ,p_token_1 => 'LOCATION'
6900 ,p_value_1 => 'xla_accounting_pkg.is_parent_running'
6901 ,p_token_2 => 'ERROR'
6902 ,p_value_2 => 'Technical problem : FND_CONCURRENT.GET_REQUEST_STATUS returned FALSE '||
6903 'while executing for request id '||g_parent_request_id);
6904 END IF;
6905
6906 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6907 trace
6908 (p_msg => 'l_dphase = '||l_dphase
6909 ,p_level => C_LEVEL_STATEMENT
6910 ,p_module => l_log_module);
6911 END IF;
6912
6913 IF l_dphase = 'RUNNING' THEN
6914 l_result := TRUE;
6915 ELSE
6916 l_result := FALSE;
6917 END IF;
6918
6919 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6920 trace
6921 (p_msg => 'END of function IS_PARENT_RUNNING'
6922 ,p_level => C_LEVEL_PROCEDURE
6923 ,p_module => l_log_module);
6924 END IF;
6925
6926 RETURN l_result;
6927 EXCEPTION
6928 WHEN xla_exceptions_pkg.application_exception THEN
6929 RAISE;
6930 WHEN OTHERS THEN
6931 xla_exceptions_pkg.raise_message
6932 (p_location => 'xla_accounting_pkg.is_parent_running');
6933 END is_parent_running; -- end of procedure
6934
6935 --=============================================================================
6936 --
6937 --
6938 --
6939 --=============================================================================
6940 FUNCTION is_any_child_running
6941 RETURN BOOLEAN IS
6942 l_phase VARCHAR2(30);
6943 l_status VARCHAR2(30);
6944 l_dphase VARCHAR2(30);
6945 l_dstatus VARCHAR2(30);
6946 l_message VARCHAR2(240);
6947 l_btemp BOOLEAN;
6948 l_result BOOLEAN;
6949 l_log_module VARCHAR2(240);
6950 BEGIN
6951 IF g_log_enabled THEN
6952 l_log_module := C_DEFAULT_MODULE||'.is_any_child_running';
6953 END IF;
6954 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6955 trace
6956 (p_msg => 'BEGIN of function is_any_child_running'
6957 ,p_level => C_LEVEL_PROCEDURE
6958 ,p_module => l_log_module);
6959 END IF;
6960
6961 l_result := FALSE;
6962 IF g_ep_request_ids.count > 0 THEN
6963
6964 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6965 trace
6966 (p_msg => 'BEGIN LOOP: get child process status'
6967 ,p_level => C_LEVEL_PROCEDURE
6968 ,p_module => l_log_module);
6969 END IF;
6970
6971 FOR i IN 1..g_ep_request_ids.count LOOP
6972 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6973 trace
6974 (p_msg => 'LOO: get child process status : '||g_ep_request_ids(i)
6975 ,p_level => C_LEVEL_PROCEDURE
6976 ,p_module => l_log_module);
6977 END IF;
6978
6979 ----------------------------------------------------------------------------
6980 -- Check the child process status
6981 ----------------------------------------------------------------------------
6982 l_btemp := fnd_concurrent.get_request_status
6983 (request_id => g_ep_request_ids(i)
6984 ,phase => l_phase
6985 ,status => l_status
6986 ,dev_phase => l_dphase
6987 ,dev_status => l_dstatus
6988 ,message => l_message);
6989
6990 IF NOT l_btemp THEN
6991 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6992 trace
6993 (p_msg => 'Technical problem : FND_CONCURRENT.GET_REQUEST_STATUS '||
6994 'returned FALSE '||
6995 'while executing for request id '||g_ep_request_ids(i)
6996 ,p_level => C_LEVEL_EXCEPTION
6997 ,p_module => l_log_module);
6998 END IF;
6999
7000 xla_exceptions_pkg.raise_message
7001 (p_appli_s_name => 'XLA'
7002 ,p_msg_name => 'XLA_COMMON_ERROR'
7003 ,p_token_1 => 'LOCATION'
7004 ,p_value_1 => 'xla_accounting_pkg.is_any_child_running'
7005 ,p_token_2 => 'ERROR'
7006 ,p_value_2 => 'Technical problem : FND_CONCURRENT.GET_REQUEST_STATUS returned FALSE '||
7007 'while executing for request id '||g_ep_request_ids(i));
7008 END IF;
7009
7010 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7011 trace
7012 (p_msg => 'l_dphase = '||l_dphase
7013 ,p_level => C_LEVEL_STATEMENT
7014 ,p_module => l_log_module);
7015 END IF;
7016
7017 IF l_dphase IN ('PENDING', 'RUNNING') THEN
7018
7019 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7020 trace
7021 (p_msg => 'Child '||g_ep_request_ids(i)||' is running'
7022 ,p_level => C_LEVEL_PROCEDURE
7023 ,p_module => l_log_module);
7024 END IF;
7025
7026 l_result := TRUE;
7027 EXIT;
7028 END IF;
7029 END LOOP;
7030
7031 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7032 trace
7033 (p_msg => 'END LOOP: get child process status'
7034 ,p_level => C_LEVEL_PROCEDURE
7035 ,p_module => l_log_module);
7036 END IF;
7037
7038 END IF;
7039
7040 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7041 trace
7042 (p_msg => 'END of function is_any_child_running'
7043 ,p_level => C_LEVEL_PROCEDURE
7044 ,p_module => l_log_module);
7045 END IF;
7046
7047 RETURN l_result;
7048 EXCEPTION
7049 WHEN xla_exceptions_pkg.application_exception THEN
7050 RAISE;
7051 WHEN OTHERS THEN
7052 xla_exceptions_pkg.raise_message
7053 (p_location => 'xla_accounting_pkg.is_any_child_running');
7054 END is_any_child_running; -- end of procedure
7055
7056
7057
7058 --=============================================================================
7059 --
7060 --
7061 --
7062 --=============================================================================
7063 PROCEDURE sequencing_batch_init
7064 (p_seq_enabled_flag IN OUT NOCOPY VARCHAR2) IS
7065 l_xla_application_id NUMBER := 602;
7066 l_xla_seq_entity VARCHAR2(30) := 'XLA_AE_HEADERS';
7067 l_seq_event_code VARCHAR2(30) := 'COMPLETION';
7068 l_seq_context_value fun_seq_batch.context_value_tbl_type;
7069
7070 l_seq_status VARCHAR2(30);
7071 l_seq_context_id NUMBER;
7072 l_sqlerrm VARCHAR2(2000);
7073 l_log_module VARCHAR2(240);
7074 BEGIN
7075 IF g_log_enabled THEN
7076 l_log_module := C_DEFAULT_MODULE||'.sequencing_batch_init';
7077 END IF;
7078 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7079 trace
7080 (p_msg => 'BEGIN of procedure SEQUENCING_BATCH_INIT'
7081 ,p_level => C_LEVEL_PROCEDURE
7082 ,p_module => l_log_module);
7083 trace
7084 (p_msg => 'p_seq_enabled_flag = '||p_seq_enabled_flag
7085 ,p_level => C_LEVEL_PROCEDURE
7086 ,p_module => l_log_module);
7087 END IF;
7088
7089 ----------------------------------------------------------------------------
7090 -- Getting ledger ids that will be used/cached in this run of accounting
7091 -- program (Actually this should come from cache but as cache is not
7092 -- activated in parent, the SQL is repeated here. This may change in
7093 -- future).
7094 ----------------------------------------------------------------------------
7095 SELECT xlr.ledger_id BULK COLLECT
7096 INTO l_seq_context_value
7097 FROM xla_ledger_relationships_v xlr
7098 ,xla_subledger_options_v xso
7099 WHERE xlr.relationship_enabled_flag = 'Y'
7100 AND xlr.ledger_category_code IN ('ALC','PRIMARY','SECONDARY')
7101 AND DECODE(xso.valuation_method_flag
7102 ,'N',xlr.primary_ledger_id
7103 ,DECODE(xlr.ledger_category_code
7104 ,'ALC',xlr.primary_ledger_id
7105 ,xlr.ledger_id)
7106 ) = g_ledger_id
7107 AND xso.application_id = g_application_id
7108 AND xso.ledger_id = DECODE(xlr.ledger_category_code
7109 ,'ALC',xlr.primary_ledger_id
7110 ,xlr.ledger_id)
7111 AND xso.enabled_flag = 'Y';
7112
7113 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7114 trace
7115 (p_msg => 'Number of ledgers being passed to the sequencing api = '||
7116 l_seq_context_value.COUNT
7117 ,p_level => C_LEVEL_STATEMENT
7118 ,p_module => l_log_module);
7119 END IF;
7120
7121 ----------------------------------------------------------------------------
7122 -- Calling sequencing's batch init
7123 ----------------------------------------------------------------------------
7124 BEGIN
7125 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Calling sequencing batch_init');
7126 IF (C_LEVEL_EVENT >= g_log_level) THEN
7127 trace
7128 (p_msg => 'Calling procedure FUN_SEQ_BATCH.BATCH_INIT'
7129 ,p_level => C_LEVEL_EVENT
7130 ,p_module => l_log_module);
7131 END IF;
7132
7133 fun_seq_batch.batch_init
7134 (p_application_id => l_xla_application_id
7135 ,p_table_name => l_xla_seq_entity
7136 ,p_event_code => l_seq_event_code
7137 ,p_context_type => 'LEDGER_AND_CURRENCY'
7138 ,p_context_value_tbl => l_seq_context_value
7139 ,p_request_id => g_parent_request_id
7140 ,x_status => l_seq_status
7141 ,x_seq_context_id => l_seq_context_id);
7142
7143 IF (C_LEVEL_EVENT >= g_log_level) THEN
7144 trace
7145 (p_msg => 'Procedure FUN_SEQ_BATCH.BATCH_INIT executed'
7146 ,p_level => C_LEVEL_EVENT
7147 ,p_module => l_log_module);
7148 END IF;
7149 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Returned from sequencing batch_init');
7150
7151 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7152 trace
7153 (p_msg => 'l_seq_status = '||l_seq_status
7154 ,p_level => C_LEVEL_STATEMENT
7155 ,p_module => l_log_module);
7156 trace
7157 (p_msg => 'l_seq_context_id = '||l_seq_context_id
7158 ,p_level => C_LEVEL_STATEMENT
7159 ,p_module => l_log_module);
7160 END IF;
7161
7162 IF l_seq_status = 'NO_SEQUENCING' THEN
7163 p_seq_enabled_flag := 'N';
7164 ELSE
7165 p_seq_enabled_flag := 'Y';
7166 END IF;
7167
7168 EXCEPTION
7169 WHEN OTHERS THEN
7170 l_sqlerrm := sqlerrm;
7171
7172 IF (C_LEVEL_EXCEPTION>= g_log_level) THEN
7173 trace
7174 (p_msg => 'Technical problem : Problem encountered in sequencing BATCH_INIT.'||
7175 xla_environment_pkg.g_chr_newline||
7176 l_sqlerrm
7177 ,p_level => C_LEVEL_EXCEPTION
7178 ,p_module => l_log_module);
7179 END IF;
7180
7181 xla_accounting_err_pkg.build_message
7182 (p_appli_s_name => 'XLA'
7183 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
7184 ,p_token_1 => 'APPLICATION_NAME'
7185 ,p_value_1 => 'SLA'
7186 ,p_entity_id => NULL
7187 ,p_event_id => NULL);
7188
7189 print_logfile('Technical problem : Problem encountered in sequencing BATCH_INIT.');
7190
7191 xla_exceptions_pkg.raise_message
7192 (p_appli_s_name => 'XLA'
7193 ,p_msg_name => 'XLA_COMMON_ERROR'
7194 ,p_token_1 => 'LOCATION'
7195 ,p_value_1 => 'xla_accounting_pkg.sequencing_batch_init'
7196 ,p_token_2 => 'ERROR'
7197 ,p_value_2 => 'Technical problem : Problem encountered in sequencing BATCH_INIT.'||
7198 xla_environment_pkg.g_chr_newline||
7199 l_sqlerrm);
7200 END;
7201
7202 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7203 trace
7204 (p_msg => 'p_seq_enabled_flag = '||p_seq_enabled_flag
7205 ,p_level => C_LEVEL_PROCEDURE
7206 ,p_module => l_log_module);
7207 trace
7208 (p_msg => 'END of procedure SEQUENCING_BATCH_INIT'
7209 ,p_level => C_LEVEL_PROCEDURE
7210 ,p_module => l_log_module);
7211 END IF;
7212 EXCEPTION
7213 WHEN xla_exceptions_pkg.application_exception THEN
7214 RAISE;
7215 WHEN OTHERS THEN
7216 xla_exceptions_pkg.raise_message
7217 (p_location => 'xla_accounting_pkg.sequencing_batch_init');
7218 END sequencing_batch_init; -- end of procedure
7219
7220
7221 --=============================================================================
7222 --
7223 --
7224 --
7225 --
7226 --
7227 --
7228 --
7229 --
7230 --
7231 --
7232 -- Following routines are used while accounting for batch of events
7233 --
7234 -- 1. events_processor
7235 -- 2. delete_batch_je
7236 --
7237 --
7238 --
7239 --
7240 --
7241 --
7242 --
7243 --
7244 --
7245 --
7246 --=============================================================================
7247
7248 --=============================================================================
7249 --
7250 --
7251 --
7252 --=============================================================================
7253 PROCEDURE events_processor(l_processing_order IN NUMBER) -- bug 7193986
7254 IS
7255 l_ret_val_acctg_engine NUMBER;
7256 l_seq_status VARCHAR2(30);
7257 l_max_event_date DATE;
7258 l_log_module VARCHAR2(240);
7259
7260 -- 5054831 -----------------------------------
7261 l_array_event_dates t_array_date;
7262 CURSOR c_events IS
7263 SELECT distinct event_date
7264 FROM xla_events a
7265 ,xla_acct_prog_events_gt b
7266 WHERE a.application_id = g_application_id
7267 AND a.event_id = b.event_id
7268 AND a.process_status_code = 'U'
7269 AND a.event_status_code IN ('U',DECODE(g_accounting_mode,'F','N','U'))
7270 AND a.on_hold_flag = 'N'
7271 AND a.event_type_code not in ('FULL_MERGE', 'PARTIAL_MERGE')
7272 AND b.ledger_id = g_ledger_id
7273 ORDER BY event_date asc;
7274 ----------------------------------------------
7275
7276 BEGIN
7277 IF g_log_enabled THEN
7278 l_log_module := C_DEFAULT_MODULE||'.events_processor';
7279 END IF;
7280 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7281 trace
7282 (p_msg => 'BEGIN of procedure events_processor'
7283 ,p_level => C_LEVEL_PROCEDURE
7284 ,p_module => l_log_module);
7285 END IF;
7286
7287 xla_accounting_cache_pkg.load_application_ledgers
7288 (p_application_id => g_application_id
7289 ,p_event_ledger_id => g_ledger_id);
7290
7291 -- 5054831 -----------------------------
7292 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7293 FOR i in (select a.* from xla_acct_prog_events_gt b, xla_events a WHERE a.application_id = g_application_id
7294 AND a.event_id = b.event_id
7295 AND a.process_status_code = 'U'
7296 AND a.event_status_code IN ('U',DECODE(g_accounting_mode,'F','N','U'))
7297 AND a.on_hold_flag = 'N'
7298 AND a.event_type_code not in ('FULL_MERGE', 'PARTIAL_MERGE')
7299 AND b.ledger_id = g_ledger_id) LOOP
7300 trace
7301 (p_msg => 'event_id='||i.event_id||' event_date='||i.event_date||' status='||i.process_status_code
7302 ,p_level => C_LEVEL_STATEMENT
7303 ,p_module => l_log_module);
7304 END LOOP;
7305 END IF;
7306
7307 OPEN c_events;
7308 FETCH c_events BULK COLLECT INTO l_array_event_dates;
7309 CLOSE c_events;
7310
7311 ValidateAAD(l_array_event_dates);
7312 ----------------------------------------
7313 -- bug 7193986 start
7314 --
7315 -- Delete the events inserted from the previous run
7316 --
7317 DELETE FROM XLA_EVENTS_GT;
7318 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7319 trace
7320 (p_msg => '# rows deleted XLA_EVENTS_GT = '||SQL%ROWCOUNT
7321 ,p_level => C_LEVEL_PROCEDURE
7322 ,p_module => l_log_module);
7323 END IF;
7324 DELETE FROM XLA_AE_LINES_GT;
7325 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7326 trace
7327 (p_msg => '# rows deleted XLA_AE_LINES_GT = '||SQL%ROWCOUNT
7328 ,p_level => C_LEVEL_PROCEDURE
7329 ,p_module => l_log_module);
7330 END IF;
7331 DELETE FROM XLA_AE_HEADERS_GT;
7332 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7333 trace
7334 (p_msg => '# rows deleted XLA_AE_HEADERS_GT = '||SQL%ROWCOUNT
7335 ,p_level => C_LEVEL_PROCEDURE
7336 ,p_module => l_log_module);
7337 END IF;
7338 DELETE FROM XLA_VALIDATION_LINES_GT;
7339 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7340 trace
7341 (p_msg => '# rows deleted XLA_VALIDATION_LINES_GT = '||SQL%ROWCOUNT
7342 ,p_level => C_LEVEL_PROCEDURE
7343 ,p_module => l_log_module);
7344 END IF;
7345
7346
7347 --
7348 -- Insert into xla_events_gt for the entity in xla_acct_prog_events_gt
7349 -- for the p_application_id and p_ledger_id.
7350 --
7351 INSERT INTO xla_events_gt
7352 (entity_id
7353 ,application_id
7354 ,ledger_id
7355 ,legal_entity_id
7356 ,entity_code
7357 ,transaction_number
7358 ,source_id_int_1
7359 ,source_id_int_2
7360 ,source_id_int_3
7361 ,source_id_int_4
7362 ,source_id_char_1
7363 ,source_id_char_2
7364 ,source_id_char_3
7365 ,source_id_char_4
7366 ,event_id
7367 ,event_class_code
7368 ,event_type_code
7369 ,event_number
7370 ,event_date
7371 ,transaction_date
7372 ,event_status_code
7373 ,process_status_code
7374 ,valuation_method
7375 ,budgetary_control_flag
7376 ,reference_num_1
7377 ,reference_num_2
7378 ,reference_num_3
7379 ,reference_num_4
7380 ,reference_char_1
7381 ,reference_char_2
7382 ,reference_char_3
7383 ,reference_char_4
7384 ,reference_date_1
7385 ,reference_date_2
7386 ,reference_date_3
7387 ,reference_date_4)
7388 SELECT xev.entity_id
7389 ,xev.application_id
7390 ,xev.ledger_id
7391 ,xev.legal_entity_id
7392 ,xev.entity_code
7393 ,xev.transaction_number
7394 ,xev.source_id_int_1
7395 ,xev.source_id_int_2
7396 ,xev.source_id_int_3
7397 ,xev.source_id_int_4
7398 ,xev.source_id_char_1
7399 ,xev.source_id_char_2
7400 ,xev.source_id_char_3
7401 ,xev.source_id_char_4
7402 ,xev.event_id
7403 ,xev.event_class_code
7404 ,xev.event_type_code
7405 ,xev.event_number
7406 ,xev.event_date
7407 ,xev.transaction_date
7408 ,xev.event_status_code
7409 ,xev.process_status_code
7410 ,xev.valuation_method
7411 ,NVL(xev.budgetary_control_flag,'N')
7412 ,xev.reference_num_1
7413 ,xev.reference_num_2
7414 ,xev.reference_num_3
7415 ,xev.reference_num_4
7416 ,xev.reference_char_1
7417 ,xev.reference_char_2
7418 ,xev.reference_char_3
7419 ,xev.reference_char_4
7420 ,xev.reference_date_1
7421 ,xev.reference_date_2
7422 ,xev.reference_date_3
7423 ,xev.reference_date_4
7424 FROM xla_entity_events_v xev
7425 , xla_acct_prog_events_gt xap
7426 WHERE xev.application_id = g_application_id
7427 AND xev.event_id = xap.event_id
7428 AND xev.process_status_code = 'U'
7429 AND xev.event_status_code IN ('U',DECODE(g_accounting_mode,'F','N','U'))
7430 AND xev.on_hold_flag = 'N'
7431 AND xev.event_type_code not in ('FULL_MERGE', 'PARTIAL_MERGE')
7432 AND xap.ledger_id = g_ledger_id
7433 AND xap.event_id IN (
7434 SELECT xla_events.event_id
7435 FROM xla_acct_prog_events_gt ,
7436 xla_events ,
7437 xla_event_types_b ,
7438 xla_transaction_entities,
7439 xla_evt_class_orders_gt
7440 WHERE xla_events.event_id = xla_acct_prog_events_gt.event_id
7441 AND xla_events.application_id = g_application_id
7442 AND xla_transaction_entities.application_id = g_application_id
7443 AND xla_events.entity_id = xla_transaction_entities.entity_id
7444 AND xla_event_types_b.application_id = g_application_id
7445 AND xla_transaction_entities.entity_code = xla_event_types_b.entity_code
7446 AND xla_events.event_type_code = xla_event_types_b.event_type_code
7447 AND xla_event_types_b.event_class_code = xla_evt_class_orders_gt.event_class_code
7448 AND xla_events.process_status_code <> 'P' --condition added, bug8680284
7449 AND xla_evt_class_orders_gt.processing_order = l_processing_order
7450 )
7451 ORDER BY xev.entity_id, xev.event_number;
7452
7453
7454 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7455 trace
7456 (p_msg => '# rows inserted into xla_events_gt = '||SQL%ROWCOUNT
7457 ,p_level => C_LEVEL_PROCEDURE
7458 ,p_module => l_log_module);
7459 END IF;
7460
7461
7462 -- bug 7193986 end
7463
7464
7465 SELECT max(event_date)
7466 INTO l_max_event_date
7467 FROM xla_events_gt;
7468 --
7469 -- Call subledger extract API
7470 --
7471 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - executing extract hook');
7472 handle_accounting_hook
7473 (p_application_id => g_application_id
7474 ,p_ledger_id => NULL
7475 ,p_process_category => NULL
7476 ,p_end_date => NULL
7477 ,p_accounting_mode => g_accounting_mode
7478 ,p_budgetary_control_mode => g_budgetary_control_mode
7479 ,p_valuation_method => NULL
7480 ,p_security_id_int_1 => NULL
7481 ,p_security_id_int_2 => NULL
7482 ,p_security_id_int_3 => NULL
7483 ,p_security_id_char_1 => NULL
7484 ,p_security_id_char_2 => NULL
7485 ,p_security_id_char_3 => NULL
7486 ,p_report_request_id => NULL
7487 ,p_event_name => 'extract'
7488 ,p_event_key => to_char(g_accounting_batch_id));
7489 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - extract hook executed successfully');
7490
7491 xla_accounting_err_pkg.set_options
7492 (p_error_source => xla_accounting_err_pkg.C_ACCT_ENGINE);
7493
7494 l_ret_val_acctg_engine :=
7495 xla_accounting_engine_pkg.AccountingEngine
7496 (p_application_id => g_application_id
7497 ,p_ledger_id => g_ledger_id
7498 ,p_end_date => l_max_event_date
7499 ,p_accounting_mode => g_accounting_mode
7500 ,p_accounting_batch_id => g_accounting_batch_id
7501 ,p_budgetary_control_mode => g_budgetary_control_mode
7502 );
7503
7504 xla_accounting_err_pkg.set_options
7505 (p_error_source => xla_accounting_err_pkg.C_ACCT_PROGRAM);
7506
7507 --
7508 -- Call subledger post-processing API
7509 --
7510 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - executing postprocessing hook');
7511 handle_accounting_hook
7512 (p_application_id => g_application_id
7513 ,p_ledger_id => NULL
7514 ,p_process_category => NULL
7515 ,p_end_date => NULL
7516 ,p_accounting_mode => g_accounting_mode
7517 ,p_budgetary_control_mode => g_budgetary_control_mode
7518 ,p_valuation_method => NULL
7519 ,p_security_id_int_1 => NULL
7520 ,p_security_id_int_2 => NULL
7521 ,p_security_id_int_3 => NULL
7522 ,p_security_id_char_1 => NULL
7523 ,p_security_id_char_2 => NULL
7524 ,p_security_id_char_3 => NULL
7525 ,p_report_request_id => NULL
7526 ,p_event_name => 'postprocessing'
7527 ,p_event_key => to_char(g_accounting_batch_id));
7528 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - postprocessing hook executed successfully');
7529
7530 complete_entries;
7531
7532 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7533 trace
7534 (p_msg => 'END of procedure events_processor'
7535 ,p_level => C_LEVEL_PROCEDURE
7536 ,p_module => l_log_module);
7537 END IF;
7538 EXCEPTION
7539 WHEN xla_exceptions_pkg.application_exception THEN
7540 RAISE;
7541 WHEN OTHERS THEN
7542 xla_exceptions_pkg.raise_message
7543 (p_location => 'xla_accounting_pkg.events_processor');
7544 END events_processor; -- end of procedure
7545
7546 --=============================================================================
7547 --
7548 --
7549 --
7550 --=============================================================================
7551 PROCEDURE delete_batch_je
7552 IS
7553
7554 CURSOR c_headers IS
7555 SELECT /*+ LEADING (XAP) USE_NL (XAP XE XAH) */
7556 xah.ae_header_id
7557 FROM xla_ae_headers xah
7558 , xla_events xe
7559 , xla_acct_prog_events_gt xap
7560 WHERE xah.application_id = xe.application_id
7561 AND xah.event_id = xe.event_id
7562 AND xah.accounting_entry_status_code <> 'F'
7563 AND xe.application_id = g_application_id
7564 AND xe.process_status_code <> 'P'
7565 AND xe.event_id = xap.event_id;
7566
7567 l_array_event_id t_array_integer;
7568 l_array_header_id t_array_integer;
7569 l_array_packet_id t_array_integer;
7570 l_log_module VARCHAR2(240);
7571 BEGIN
7572 IF g_log_enabled THEN
7573 l_log_module := C_DEFAULT_MODULE||'.delete_batch_je';
7574 END IF;
7575 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7576 trace(p_msg => 'BEGIN of procedure delete_batch_je'
7577 ,p_level => C_LEVEL_PROCEDURE
7578 ,p_module => l_log_module);
7579 END IF;
7580
7581 SELECT /*+ leading(xap,xe) use_nl(xe) index(xe,XLA_EVENTS_U1) */
7582 xe.event_id
7583 BULK COLLECT INTO l_array_event_id
7584 FROM xla_events xe
7585 , xla_acct_prog_events_gt xap
7586 WHERE xe.application_id = g_application_id
7587 AND xe.process_status_code <> 'P'
7588 AND xe.event_id = xap.event_id;
7589
7590 IF (l_array_event_id.COUNT > 0) THEN
7591
7592 FORALL i IN 1..l_array_event_id.COUNT
7593 DELETE FROM xla_accounting_errors
7594 WHERE application_id = g_application_id
7595 AND event_id = l_array_event_id(i);
7596
7597 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7598 trace
7599 (p_msg => '# xla_accounting_errors deleted = '||SQL%ROWCOUNT
7600 ,p_level => C_LEVEL_STATEMENT
7601 ,p_module => l_log_module);
7602 END IF;
7603
7604 FORALL i IN 1..l_array_event_id.COUNT
7605 DELETE FROM xla_diag_sources
7606 WHERE event_id = l_array_event_id(i);
7607
7608 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7609 trace(p_msg => '# xla_diag_sources deleted = '||SQL%ROWCOUNT
7610 ,p_level => C_LEVEL_STATEMENT
7611 ,p_module => l_log_module);
7612 END IF;
7613
7614 FORALL i IN 1..l_array_event_id.COUNT
7615 DELETE FROM xla_diag_events
7616 WHERE application_id = g_application_id
7617 AND event_id = l_array_event_id(i);
7618
7619 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7620 trace(p_msg => '# xla_diag_events deleted = '||SQL%ROWCOUNT
7621 ,p_level => C_LEVEL_STATEMENT
7622 ,p_module => l_log_module);
7623 END IF;
7624 --bug6369888
7625 DELETE FROM xla_diag_ledgers d
7626 WHERE d.application_id = g_application_id
7627 AND NOT EXISTS
7628 (SELECT ledger_id, request_id
7629 FROM xla_diag_events
7630 WHERE application_id = d.application_id
7631 AND request_id = d.accounting_request_id
7632 AND ledger_id = d.primary_ledger_id
7633 );
7634
7635 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7636 trace
7637 (p_msg => '# xla_diag_ledgers deleted = '||SQL%ROWCOUNT
7638 ,p_level => C_LEVEL_STATEMENT
7639 ,p_module => l_log_module);
7640 END IF;
7641
7642 FORALL i IN 1..l_array_event_id.COUNT
7643 DELETE FROM gl_bc_packets
7644 WHERE application_id = g_application_id
7645 AND event_id = l_array_event_id(i)
7646 RETURNING packet_id BULK COLLECT INTO l_array_packet_id;
7647
7648 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7649 trace(p_msg => '# gl_bc_packets deleted = '||SQL%ROWCOUNT
7650 ,p_level => C_LEVEL_STATEMENT
7651 ,p_module => l_log_module);
7652 END IF;
7653
7654 IF (l_array_packet_id.COUNT > 0) THEN
7655 FORALL i IN 1..l_array_packet_id.COUNT
7656 DELETE FROM gl_bc_packet_arrival_order
7657 WHERE packet_id = l_array_packet_id(i);
7658
7659 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7660 trace(p_msg => '# gl_bc_packet_arrival_order deleted = '||SQL%ROWCOUNT
7661 ,p_level => C_LEVEL_STATEMENT
7662 ,p_module => l_log_module);
7663 END IF;
7664 END IF;
7665
7666 OPEN c_headers;
7667 FETCH c_headers BULK COLLECT INTO l_array_header_id;
7668 CLOSE c_headers;
7669
7670 IF (l_array_header_id.COUNT > 0) THEN
7671 FORALL i IN 1..l_array_header_id.COUNT
7672 DELETE FROM xla_distribution_links
7673 WHERE application_id = g_application_id
7674 AND ae_header_id = l_array_header_id(i);
7675
7676 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7677 trace(p_msg => '# xla_distribution_links deleted = '||SQL%ROWCOUNT
7678 ,p_level => C_LEVEL_STATEMENT
7679 ,p_module => l_log_module);
7680 END IF;
7681
7682 FORALL i IN 1..l_array_header_id.COUNT
7683 DELETE FROM xla_ae_segment_values
7684 WHERE ae_header_id = l_array_header_id(i);
7685
7686 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7687 trace (p_msg => '# xla_ae_segment_values deleted = '||SQL%ROWCOUNT
7688 ,p_level => C_LEVEL_STATEMENT
7689 ,p_module => l_log_module);
7690 END IF;
7691
7692 FORALL i IN 1..l_array_header_id.COUNT
7693 DELETE FROM xla_ae_line_acs
7694 WHERE ae_header_id = l_array_header_id(i);
7695
7696 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7697 trace (p_msg => '# xla_ae_line_acs deleted = '||SQL%ROWCOUNT
7698 ,p_level => C_LEVEL_STATEMENT
7699 ,p_module => l_log_module);
7700 END IF;
7701
7702 FORALL i IN 1..l_array_header_id.COUNT
7703 DELETE FROM xla_ae_header_acs
7704 WHERE ae_header_id = l_array_header_id(i);
7705
7706 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7707 trace (p_msg => '# xla_ae_header_acs deleted = '||SQL%ROWCOUNT
7708 ,p_level => C_LEVEL_STATEMENT
7709 ,p_module => l_log_module);
7710 END IF;
7711
7712 FORALL i IN 1..l_array_header_id.COUNT
7713 DELETE FROM xla_ae_lines
7714 WHERE application_id = g_application_id
7715 AND ae_header_id = l_array_header_id(i);
7716
7717 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7718 trace(p_msg => '# xla_ae_lines deleted = '||SQL%ROWCOUNT
7719 ,p_level => C_LEVEL_STATEMENT
7720 ,p_module => l_log_module);
7721 END IF;
7722
7723 FORALL i IN 1..l_array_header_id.COUNT
7724 DELETE FROM xla_ae_headers
7725 WHERE application_id = g_application_id
7726 AND ae_header_id = l_array_header_id(i);
7727
7728 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7729 trace(p_msg => '# xla_ae_headers deleted = '||SQL%ROWCOUNT
7730 ,p_level => C_LEVEL_STATEMENT
7731 ,p_module => l_log_module);
7732 END IF;
7733 END IF;
7734 END IF;
7735
7736 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7737 trace(p_msg => 'END of procedure delete_batch_je'
7738 ,p_level => C_LEVEL_PROCEDURE
7739 ,p_module => l_log_module);
7740 END IF;
7741 EXCEPTION
7742 WHEN xla_exceptions_pkg.application_exception THEN
7743 RAISE;
7744 WHEN OTHERS THEN
7745 xla_exceptions_pkg.raise_message
7746 (p_location => 'xla_accounting_pkg.delete_batch_je');
7747 END delete_batch_je;
7748
7749
7750 --=============================================================================
7751 --
7752 --
7753 --
7754 --
7755 --
7756 --
7757 --
7758 --
7759 --
7760 --
7761 -- Following routines are used while accounting for batch of documents as well
7762 -- as for a single document
7763 --
7764 -- 2. complete_entries
7765 --
7766 --
7767 --
7768 --
7769 --
7770 --
7771 --
7772 --
7773 --
7774 --
7775 --
7776 --=============================================================================
7777
7778 --=============================================================================
7779 --
7780 --
7781 --
7782 --=============================================================================
7783
7784 PROCEDURE complete_entries IS
7785 l_index NUMBER := 0;
7786 l_array_ae_header_id t_array_number;
7787 l_array_completion_date t_array_date;
7788 l_array_seq_version_id t_array_number;
7789 l_array_sequence_number t_array_number;
7790 l_array_assignment_id t_array_number;
7791 l_array_error_code t_array_char;
7792
7793 l_xla_application_id NUMBER := 602;
7794 l_xla_seq_entity VARCHAR2(30) := 'XLA_AE_HEADERS';
7795 l_seq_event_code VARCHAR2(30) := 'COMPLETION';
7796 l_control_attribute_rec fun_seq.control_attribute_rec_type;
7797 l_control_date_tbl fun_seq.control_date_tbl_type;
7798
7799 l_sqlerrm VARCHAR2(2000);
7800 l_log_module VARCHAR2(240);
7801 BEGIN
7802 IF g_log_enabled THEN
7803 l_log_module := C_DEFAULT_MODULE||'.complete_entries';
7804 END IF;
7805 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7806 trace
7807 (p_msg => 'BEGIN of procedure COMPLETE_ENTRIES'
7808 ,p_level => C_LEVEL_PROCEDURE
7809 ,p_module => l_log_module);
7810 END IF;
7811
7812 ----------------------------------------------------------------------------
7813 -- If "accounting mode = F", perform sequencing for the subledger journal
7814 -- entries
7815 ----------------------------------------------------------------------------
7816 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7817 trace
7818 (p_msg => 'g_accounting_mode = '||g_accounting_mode
7819 ,p_level => C_LEVEL_STATEMENT
7820 ,p_module => l_log_module);
7821 END IF;
7822
7823 IF g_accounting_mode = 'F' THEN
7824 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
7825 trace
7826 (p_msg => 'g_processing_mode = '||g_processing_mode
7827 ,p_level => C_LEVEL_STATEMENT
7828 ,p_module => l_log_module);
7829 trace
7830 (p_msg => 'g_seq_enabled_flag = '||g_seq_enabled_flag
7831 ,p_level => C_LEVEL_STATEMENT
7832 ,p_module => l_log_module);
7833 END IF;
7834
7835 IF g_processing_mode = 'BATCH' AND g_seq_enabled_flag = 'Y' THEN
7836 BEGIN
7837 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Calling sequencing populate_acct_seq_info');
7838
7839 IF (C_LEVEL_EVENT >= g_log_level) THEN
7840 trace
7841 (p_msg => 'Calling procedure FUN_SEQ_BATCH.POPULATE_ACCT_SEQ_INFO'
7842 ,p_level => C_LEVEL_EVENT
7843 ,p_module => l_log_module);
7844 END IF;
7845
7846 fun_seq_batch.populate_acct_seq_info
7847 (p_calling_program => 'ACCOUNTING'
7848 ,p_request_id => g_parent_request_id);
7849
7850 IF (C_LEVEL_EVENT >= g_log_level) THEN
7851 trace
7852 (p_msg => 'Procedure FUN_SEQ_BATCH.POPULATE_ACCT_SEQ_INFO executed'
7853 ,p_level => C_LEVEL_EVENT
7854 ,p_module => l_log_module);
7855 END IF;
7856
7857 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Returned from sequencing populate_acct_seq_info');
7858 EXCEPTION
7859 WHEN OTHERS THEN
7860 l_sqlerrm := sqlerrm;
7861
7862 IF (C_LEVEL_EXCEPTION>= g_log_level) THEN
7863 trace
7864 (p_msg => 'Technical problem : Problem encountered in sequencing POPULATE_ACCT_SEQ_INFO.'||
7865 xla_environment_pkg.g_chr_newline||
7866 l_sqlerrm
7867 ,p_level => C_LEVEL_EXCEPTION
7868 ,p_module => l_log_module);
7869 END IF;
7870
7871 xla_accounting_err_pkg.build_message
7872 (p_appli_s_name => 'XLA'
7873 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
7874 ,p_token_1 => 'APPLICATION_NAME'
7875 ,p_value_1 => 'SLA'
7876 ,p_entity_id => NULL
7877 ,p_event_id => NULL);
7878
7879 print_logfile('Technical problem : Problem encountered in sequencing POPULATE_ACCT_SEQ_INFO.');
7880
7881 xla_exceptions_pkg.raise_message
7882 (p_appli_s_name => 'XLA'
7883 ,p_msg_name => 'XLA_COMMON_ERROR'
7884 ,p_token_1 => 'LOCATION'
7885 ,p_value_1 => 'xla_accounting_pkg.complete_entries'
7886 ,p_token_2 => 'ERROR'
7887 ,p_value_2 => 'Technical problem : Problem encountered in sequencing POPULATE_ACCT_SEQ_INFO.'||
7888 xla_environment_pkg.g_chr_newline||
7889 l_sqlerrm);
7890 END;
7891 ELSIF g_processing_mode = 'DOCUMENT' THEN
7892 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Calling sequencing get_sequence_number');
7893
7894 FOR c1 IN (SELECT /*+ leading(xsl,xeg,aeh) use_nl(aeh) index(xla_ae_headers_n2) */
7895 aeh.ae_header_id ae_header_id
7896 ,aeh.ledger_id ledger_id
7897 ,aeh.balance_type_code balance_type_code
7898 ,xsl.je_source_name je_source_name
7899 ,aeh.je_category_name je_category_name
7900 ,aeh.doc_category_code doc_category_code
7901 ,aeh.event_type_code accounting_event_type_code
7902 ,aeh.accounting_entry_type_code accounting_entry_type_code
7903 ,aeh.accounting_date gl_date
7904 ,aeh.completed_date completion_date
7905 FROM xla_ae_headers aeh
7906 ,xla_events_gt xeg
7907 ,xla_subledgers xsl
7908 WHERE aeh.application_id = xeg.application_id
7909 AND aeh.event_id = xeg.event_id
7910 AND xsl.application_id = xeg.application_id
7911 AND xsl.application_id = g_application_id
7912 AND nvl(aeh.zero_amount_flag, 'N') = 'N')
7913 LOOP
7914 l_index := l_index + 1;
7915
7916 l_control_attribute_rec.balance_type := c1.balance_type_code;
7917 l_control_attribute_rec.journal_source := c1.je_source_name;
7918 l_control_attribute_rec.journal_category := c1.je_category_name;
7919 l_control_attribute_rec.document_category := c1.doc_category_code;
7920 l_control_attribute_rec.accounting_event_type := g_application_id||'.'||c1.accounting_event_type_code;
7921 l_control_attribute_rec.accounting_entry_type := c1.accounting_entry_type_code;
7922
7923 l_control_date_tbl := fun_seq.control_date_tbl_type();
7924 l_control_date_tbl.EXTEND(2);
7925 l_control_date_tbl(1).date_type :='GL_DATE';
7926 l_control_date_tbl(1).date_value := c1.gl_date;
7927 l_control_date_tbl(2).date_type :='COMPLETION_DATE';
7928 l_control_date_tbl(2).date_value := c1.completion_date;
7929
7930 BEGIN
7931 IF (C_LEVEL_EVENT >= g_log_level) THEN
7932 trace
7933 (p_msg => 'Calling procedure FUN_SEQ.GET_SEQUENCE_NUMBER'
7934 ,p_level => C_LEVEL_EVENT
7935 ,p_module => l_log_module);
7936 END IF;
7937
7938 fun_seq.get_sequence_number
7939 (p_context_type => 'LEDGER_AND_CURRENCY'
7940 ,p_context_value => c1.ledger_id
7941 ,p_application_id => l_xla_application_id
7942 ,p_table_name => l_xla_seq_entity
7943 ,p_event_code => l_seq_event_code
7944 ,p_control_attribute_rec => l_control_attribute_rec
7945 ,p_control_date_tbl => l_control_date_tbl
7946 ,p_suppress_error => 'N'
7947 ,x_seq_version_id => l_array_seq_version_id(l_index)
7948 ,x_sequence_number => l_array_sequence_number(l_index)
7949 ,x_assignment_id => l_array_assignment_id(l_index)
7950 ,x_error_code => l_array_error_code(l_index));
7951
7952 IF (C_LEVEL_EVENT >= g_log_level) THEN
7953 trace
7954 (p_msg => 'Procedure FUN_SEQ.GET_SEQUENCE_NUMBER executed'
7955 ,p_level => C_LEVEL_EVENT
7956 ,p_module => l_log_module);
7957 END IF;
7958
7959 l_array_ae_header_id(l_index) := c1.ae_header_id;
7960 l_array_completion_date(l_index) := sysdate;
7961
7962 EXCEPTION
7963 WHEN OTHERS THEN
7964 l_sqlerrm := sqlerrm;
7965
7966 IF (C_LEVEL_EXCEPTION>= g_log_level) THEN
7967 trace
7968 (p_msg => 'Technical problem : Problem encountered in sequencing GET_SEQUENCE_NUMBER.'||
7969 xla_environment_pkg.g_chr_newline||
7970 l_sqlerrm
7971 ,p_level => C_LEVEL_EXCEPTION
7972 ,p_module => l_log_module);
7973 END IF;
7974
7975 xla_accounting_err_pkg.build_message
7976 (p_appli_s_name => 'XLA'
7977 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
7978 ,p_token_1 => 'APPLICATION_NAME'
7979 ,p_value_1 => 'SLA'
7980 ,p_entity_id => NULL
7981 ,p_event_id => NULL);
7982
7983 print_logfile('Technical problem : Problem encountered in sequencing GET_SEQUENCE_NUMBER.');
7984
7985 xla_exceptions_pkg.raise_message
7986 (p_appli_s_name => 'XLA'
7987 ,p_msg_name => 'XLA_COMMON_ERROR'
7988 ,p_token_1 => 'LOCATION'
7989 ,p_value_1 => 'xla_accounting_pkg.complete_entries'
7990 ,p_token_2 => 'ERROR'
7991 ,p_value_2 => 'Technical problem : Problem encountered in sequencing GET_SEQUENCE_NUMBER.'||
7992 xla_environment_pkg.g_chr_newline||
7993 l_sqlerrm);
7994 END;
7995 END LOOP;
7996
7997 FORALL i IN 1..l_array_ae_header_id.COUNT
7998 UPDATE xla_ae_headers aeh
7999 SET aeh.completed_date = l_array_completion_date(i)
8000 ,aeh.completion_acct_seq_assign_id = l_array_assignment_id(i)
8001 ,aeh.completion_acct_seq_version_id = l_array_seq_version_id(i)
8002 ,aeh.completion_acct_seq_value = l_array_sequence_number(i)
8003 WHERE aeh.ae_header_id = l_array_ae_header_id(i);
8004
8005 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8006 trace
8007 (p_msg => 'Number of headers sequenced = '||SQL%ROWCOUNT
8008 ,p_level => C_LEVEL_STATEMENT
8009 ,p_module => l_log_module);
8010 END IF;
8011 print_logfile(to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')||' - Returned from sequencing get_sequence_number');
8012 END IF;
8013 END IF;
8014
8015 ----------------------------------------------------------------------------
8016 -- Following updates event status in xla_events.
8017 -- Statement updated to fix Bug # 3051978
8018 -- Statement updated to fix Bug # 4961401
8019 ----------------------------------------------------------------------------
8020 UPDATE (SELECT /*+ leading(tmp) index(evt, XLA_EVENTS_U1) use_nl(evt)*/ --4769388
8021 evt.event_status_code
8022 ,evt.process_status_code
8023 ,evt.last_update_date
8024 ,evt.last_updated_by
8025 ,evt.last_update_login
8026 ,evt.program_update_date
8027 ,evt.program_application_id
8028 ,evt.program_id
8029 ,evt.request_id
8030 ,evt.reference_char_4 --bug 13811614
8031 --,DECODE(tmp.process_status_code,'P','P','U') new_event_status_code -- bug 4961401
8032 ,CASE WHEN evt.event_status_code = 'N' OR tmp.event_status_code = 'N' THEN 'N' --bug 13811614
8033 WHEN tmp.process_status_code = 'P' THEN 'P'
8034 ELSE 'U' END new_event_status_code
8035 --,tmp.process_status_code new_process_status_code -- bug 4961401
8036 ,DECODE(evt.event_status_code,'N','P',tmp.process_status_code) new_process_status_code
8037 ,tmp.reference_char_4 new_reference_char_4 --bug 13811614
8038 FROM xla_events evt
8039 ,xla_events_gt tmp
8040 WHERE evt.event_id = tmp.event_id
8041 AND evt.application_id = g_application_id
8042 )
8043 SET event_status_code = new_event_status_code
8044 ,process_status_code = new_process_status_code
8045 ,reference_char_4 = new_reference_char_4
8046 ,last_update_date = sysdate
8047 ,last_updated_by = xla_environment_pkg.g_usr_id
8048 ,last_update_login = xla_environment_pkg.g_login_id
8049 ,request_id = g_report_request_id;
8050
8051
8052 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8053 trace
8054 (p_msg => 'Number of events updated = '||SQL%ROWCOUNT
8055 ,p_level => C_LEVEL_STATEMENT
8056 ,p_module => l_log_module);
8057 END IF;
8058
8059 -- Start of 12411043
8060 /*
8061 -- Start of 8411568
8062
8063 UPDATE xla_events xe
8064 SET xe.event_status_code = 'P'
8065 ,xe.process_status_code = 'P'
8066 ,xe.last_update_date = sysdate
8067 ,xe.last_updated_by = xla_environment_pkg.g_usr_id
8068 ,xe.last_update_login = xla_environment_pkg.g_login_id
8069 ,xe.request_id = g_report_request_id
8070 WHERE xe.event_id IN (SELECT xle.event_id
8071 FROM gl_ledgers glg
8072 ,xla_acctg_methods_b xam
8073 ,xla_acctg_method_rules xamr
8074 ,xla_prod_acct_headers xpah
8075 ,xla_event_types_b xetb
8076 ,xla_aad_line_defn_assgns xald
8077 ,xla_line_definitions_b xldb
8078 ,xla_ledger_relationships_v xlr
8079 ,xla_ledger_options xlo
8080 ,xla_events_gt xle
8081 WHERE glg.sla_accounting_method_code = xam.accounting_method_code
8082 AND glg.sla_accounting_method_type = xam.accounting_method_type_code
8083 AND xam.accounting_method_code = xamr.accounting_method_code
8084 AND xam.accounting_method_type_code = xamr.accounting_method_type_code
8085 AND xamr.application_id = xle.application_id
8086 AND xetb.application_id = xpah.application_id
8087 AND xetb.entity_code = xpah.entity_code
8088 AND xetb.event_class_code = xpah.event_class_code
8089 AND (Substr(xpah.event_type_code,-4) = '_ALL'
8090 OR xetb.event_type_code = xpah.event_type_code)
8091 AND xpah.application_id = xamr.application_id
8092 AND xpah.product_rule_type_code = xamr.product_rule_type_code
8093 AND xpah.product_rule_code = xamr.product_rule_code
8094 AND xpah.amb_context_code = xamr.amb_context_code
8095 AND xpah.amb_context_code = Nvl(xla_profiles_pkg.Get_value('XLA_AMB_CONTEXT'),
8096 'DEFAULT')
8097 AND xetb.event_type_code = xle.event_type_code
8098 AND xle.event_status_code = 'U'
8099 AND xle.process_status_code = 'U'
8100 AND glg.ledger_id = xlr.ledger_id
8101 AND xlr.primary_ledger_id = xle.ledger_id
8102 AND xlr.relationship_enabled_flag = 'Y'
8103 AND xlr.ledger_id = xlo.ledger_id
8104 AND xlo.application_id = xle.application_id
8105 AND xlo.enabled_flag = 'Y'
8106 AND xald.application_id(+) = xpah.application_id
8107 AND xald.amb_context_code(+) = xpah.amb_context_code
8108 AND xald.product_rule_type_code(+) = xpah.product_rule_type_code
8109 AND xald.product_rule_code(+) = xpah.product_rule_code
8110 AND xald.event_class_code(+) = xpah.event_class_code
8111 AND xald.event_type_code(+) = xpah.event_type_code
8112 AND xald.application_id = xldb.application_id(+)
8113 AND xald.amb_context_code = xldb.amb_context_code(+)
8114 AND xald.event_class_code = xldb.event_class_code (+)
8115 AND xald.event_type_code = xldb.event_type_code(+)
8116 AND xald.line_definition_owner_code = xldb.line_definition_owner_code(+)
8117 AND xald.line_definition_code = xldb.line_definition_code(+)
8118 AND xldb.enabled_flag(+) = 'Y'
8119 GROUP BY xle.event_id
8120 HAVING Sum(CASE
8121 WHEN xle.event_date BETWEEN Nvl(xamr.start_date_active,xle.event_date)
8122 AND Nvl(xamr.end_date_active,xle.event_date)
8123 THEN Decode(Nvl(xpah.accounting_required_flag,'N'),'Y'
8124 ,Decode(Nvl(xldb.budgetary_control_flag,'X'),xle.budgetary_control_flag,1,0)
8125 ,0)
8126 ELSE 0
8127 END) = 0)
8128 AND xe.event_status_code = 'U'
8129 AND xe.process_status_code = 'U'
8130 AND xe.application_id = g_application_id;
8131
8132 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8133 trace
8134 (p_msg => 'Number of events updated (accounting not needed): = '||SQL%ROWCOUNT
8135 ,p_level => C_LEVEL_STATEMENT
8136 ,p_module => l_log_module);
8137 END IF;
8138
8139 -- End of 8411568
8140 */
8141 -- End of 12411043
8142 ----------------------------------------------------------------------------
8143 -- Following call inserts errors into error table
8144 ----------------------------------------------------------------------------
8145 --xla_accounting_err_pkg.insert_errors; -- bug 5206382
8146
8147 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8148 trace
8149 (p_msg => 'END of procedure COMPLETE_ENTRIES'
8150 ,p_level => C_LEVEL_PROCEDURE
8151 ,p_module => l_log_module);
8152 END IF;
8153 EXCEPTION
8154 WHEN xla_exceptions_pkg.application_exception THEN
8155 RAISE;
8156 WHEN OTHERS THEN
8157 xla_exceptions_pkg.raise_message
8158 (p_location => 'xla_accounting_pkg.complete_entries');
8159 END complete_entries; -- end of procedure
8160
8161
8162 --------------------------------------------------------------------------------
8163 -- This procedure is used to raise preaccounting event or postaccounting event
8164 -- p_event_name will be 'preaccounting' or 'postaccounting'
8165 --------------------------------------------------------------------------------
8166 PROCEDURE raise_accounting_event( p_application_id IN NUMBER
8167 ,p_ledger_id IN NUMBER
8168 ,p_process_category IN VARCHAR2
8169 ,p_end_date IN DATE
8170 ,p_accounting_mode IN VARCHAR2
8171 ,p_valuation_method IN VARCHAR2
8172 ,p_security_id_int_1 IN NUMBER
8173 ,p_security_id_int_2 IN NUMBER
8174 ,p_security_id_int_3 IN NUMBER
8175 ,p_security_id_char_1 IN VARCHAR2
8176 ,p_security_id_char_2 IN VARCHAR2
8177 ,p_security_id_char_3 IN VARCHAR2
8178 ,p_report_request_id IN NUMBER
8179 ,p_event_name IN VARCHAR2
8180 ,p_event_key IN VARCHAR2)
8181 IS
8182
8183 x_progress VARCHAR2(100) := '000';
8184 l_parameter_list wf_parameter_list_t := wf_parameter_list_t();
8185 l_event_name VARCHAR2(50):='oracle.apps.xla.accounting.'||p_event_name;
8186 l_log_module VARCHAR2(240);
8187 BEGIN
8188 IF g_log_enabled THEN
8189 l_log_module := C_DEFAULT_MODULE||'.raise_accounting_event';
8190 END IF;
8191 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8192 trace
8193 (p_msg => 'BEGIN of procedure RAISE_ACCOUNTING_EVENT'
8194 ,p_level => C_LEVEL_PROCEDURE
8195 ,p_module => l_log_module);
8196 trace
8197 (p_msg => 'p_application_id = '||p_application_id
8198 ,p_level => C_LEVEL_PROCEDURE
8199 ,p_module => l_log_module);
8200 trace
8201 (p_msg => 'p_ledger_id = '||p_ledger_id
8202 ,p_level => C_LEVEL_PROCEDURE
8203 ,p_module => l_log_module);
8204 trace
8205 (p_msg => 'p_process_category = '||p_process_category
8206 ,p_level => C_LEVEL_PROCEDURE
8207 ,p_module => l_log_module);
8208 trace
8209 (p_msg => 'p_end_date = '||p_end_date
8210 ,p_level => C_LEVEL_PROCEDURE
8211 ,p_module => l_log_module);
8212 trace
8213 (p_msg => 'p_accounting_mode = '||p_accounting_mode
8214 ,p_level => C_LEVEL_PROCEDURE
8215 ,p_module => l_log_module);
8216 trace
8217 (p_msg => 'p_valuation_method = '||p_valuation_method
8218 ,p_level => C_LEVEL_PROCEDURE
8219 ,p_module => l_log_module);
8220 trace
8221 (p_msg => 'p_security_id_int_1 = '||p_security_id_int_1
8222 ,p_level => C_LEVEL_PROCEDURE
8223 ,p_module => l_log_module);
8224 trace
8225 (p_msg => 'p_security_id_int_2 = '||p_security_id_int_2
8226 ,p_level => C_LEVEL_PROCEDURE
8227 ,p_module => l_log_module);
8228 trace
8229 (p_msg => 'p_security_id_int_3 = '||p_security_id_int_3
8230 ,p_level => C_LEVEL_PROCEDURE
8231 ,p_module => l_log_module);
8232 trace
8233 (p_msg => 'p_security_id_char_1 = '||p_security_id_char_1
8234 ,p_level => C_LEVEL_PROCEDURE
8235 ,p_module => l_log_module);
8236 trace
8237 (p_msg => 'p_security_id_char_2 = '||p_security_id_char_2
8238 ,p_level => C_LEVEL_PROCEDURE
8239 ,p_module => l_log_module);
8240 trace
8241 (p_msg => 'p_security_id_char_3 = '||p_security_id_char_3
8242 ,p_level => C_LEVEL_PROCEDURE
8243 ,p_module => l_log_module);
8244 trace
8245 (p_msg => 'p_report_request_id = '||p_report_request_id
8246 ,p_level => C_LEVEL_PROCEDURE
8247 ,p_module => l_log_module);
8248 trace
8249 (p_msg => 'p_event_name = '||p_event_name
8250 ,p_level => C_LEVEL_PROCEDURE
8251 ,p_module => l_log_module);
8252 trace
8253 (p_msg => 'p_event_key = '||p_event_key
8254 ,p_level => C_LEVEL_PROCEDURE
8255 ,p_module => l_log_module);
8256 END IF;
8257
8258 print_logfile('event key = '||p_event_key);
8259
8260 x_progress := '001';
8261
8262 -- Add Parameters
8263 wf_event.AddParameterToList(p_name =>'APPLICATION_ID',
8264 p_value => p_application_id,
8265 p_parameterlist => l_parameter_list);
8266 wf_event.AddParameterToList(p_name =>'LEDGER_ID',
8267 p_value => p_ledger_id,
8268 p_parameterlist => l_parameter_list);
8269 wf_event.AddParameterToList(p_name =>'PROCESS_CATEGORY',
8270 p_value => p_process_category,
8271 p_parameterlist => l_parameter_list);
8272 wf_event.AddParameterToList(p_name =>'END_DATE',
8273 p_value => p_end_date,
8274 p_parameterlist => l_parameter_list);
8275 wf_event.AddParameterToList(p_name =>'ACCOUNTING_MODE',
8276 p_value => p_accounting_mode,
8277 p_parameterlist => l_parameter_list);
8278 wf_event.AddParameterToList(p_name =>'VALUATION_METHOD',
8279 p_value => p_valuation_method,
8280 p_parameterlist => l_parameter_list);
8281 wf_event.AddParameterToList(p_name =>'SECURITY_ID_INT_1',
8282 p_value => p_security_id_int_1,
8283 p_parameterlist => l_parameter_list);
8284 wf_event.AddParameterToList(p_name =>'SECURITY_ID_INT_2',
8285 p_value => p_security_id_int_2,
8286 p_parameterlist => l_parameter_list);
8287 wf_event.AddParameterToList(p_name =>'SECURITY_ID_INT_3',
8288 p_value => p_security_id_int_3,
8289 p_parameterlist => l_parameter_list);
8290 wf_event.AddParameterToList(p_name =>'SECURITY_ID_CHAR_1',
8291 p_value => p_security_id_char_1,
8292 p_parameterlist => l_parameter_list);
8293 wf_event.AddParameterToList(p_name =>'SECURITY_ID_CHAR_2',
8294 p_value => p_security_id_char_2,
8295 p_parameterlist => l_parameter_list);
8296 wf_event.AddParameterToList(p_name =>'SECURITY_ID_CHAR_3',
8297 p_value => p_security_id_char_3,
8298 p_parameterlist => l_parameter_list);
8299 wf_event.AddParameterToList(p_name =>'REQUEST_ID',
8300 p_value => p_report_request_id,
8301 p_parameterlist => l_parameter_list);
8302
8303 -- FSAH-PSFT FP
8304 if(fnd_profile.value('XLA_FSAH_EXT_CCID_VAL') IS NOT NULL) THEN
8305 wf_event.AddParameterToList(p_name =>'ACCOUNTING_BATCH_ID',
8306 p_value => g_accounting_batch_id,
8307 p_parameterlist =>l_parameter_list);
8308 END IF; -- FSAH-PSFT FP
8309
8310 x_progress := '002';
8311
8312 wf_event.RAISE( p_event_name => l_event_name,
8313 p_event_key => p_event_key,
8314 p_parameters => l_parameter_list);
8315
8316
8317 l_parameter_list.DELETE;
8318
8319 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8320 trace
8321 (p_msg => 'END of procedure RAISE_ACCOUNTING_EVENT'
8322 ,p_level => C_LEVEL_PROCEDURE
8323 ,p_module => l_log_module);
8324 END IF;
8325
8326 EXCEPTION
8327 WHEN others THEN
8328 wf_core.CONTEXT('xla_accounting_pkg','raise_accounting_event',x_progress);
8329 RAISE;
8330
8331 END raise_accounting_event;
8332
8333
8334 --------------------------------------------------------------------------------
8335 -- This procedure is used to raise postprocessing event or extract event
8336 -- p_event_name will be 'postprocessing' or 'extract'
8337 --------------------------------------------------------------------------------
8338 PROCEDURE raise_unit_event( p_application_id IN NUMBER
8339 ,p_accounting_mode IN VARCHAR2
8340 ,p_event_name IN VARCHAR2
8341 ,p_event_key IN VARCHAR2)
8342 IS
8343
8344 x_progress VARCHAR2(100) := '000';
8345 l_parameter_list wf_parameter_list_t := wf_parameter_list_t();
8346 l_event_name VARCHAR2(50):='oracle.apps.xla.accounting.'||p_event_name;
8347 l_log_module VARCHAR2(240);
8348 BEGIN
8349 IF g_log_enabled THEN
8350 l_log_module := C_DEFAULT_MODULE||'.raise_unit_event';
8351 END IF;
8352 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8353 trace
8354 (p_msg => 'BEGIN of procedure RAISE_UNIT_EVENT'
8355 ,p_level => C_LEVEL_PROCEDURE
8356 ,p_module => l_log_module);
8357 trace
8358 (p_msg => 'p_application_id = '||p_application_id
8359 ,p_level => C_LEVEL_PROCEDURE
8360 ,p_module => l_log_module);
8361 trace
8362 (p_msg => 'p_accounting_mode = '||p_accounting_mode
8363 ,p_level => C_LEVEL_PROCEDURE
8364 ,p_module => l_log_module);
8365 trace
8366 (p_msg => 'p_event_name = '||p_event_name
8367 ,p_level => C_LEVEL_PROCEDURE
8368 ,p_module => l_log_module);
8369 trace
8370 (p_msg => 'p_event_key = '||p_event_key
8371 ,p_level => C_LEVEL_PROCEDURE
8372 ,p_module => l_log_module);
8373 END IF;
8374
8375 print_logfile('event key = '||p_event_key);
8376
8377 x_progress := '001';
8378
8379 -- Add Parameters
8380 wf_event.AddParameterToList(p_name =>'APPLICATION_ID',
8381 p_value => p_application_id,
8382 p_parameterlist => l_parameter_list);
8383 wf_event.AddParameterToList(p_name =>'ACCOUNTING_MODE',
8384 p_value => p_accounting_mode,
8385 p_parameterlist => l_parameter_list);
8386 x_progress := '002';
8387
8388 wf_event.RAISE( p_event_name => l_event_name,
8389 p_event_key => p_event_key,
8390 p_parameters => l_parameter_list);
8391
8392 l_parameter_list.DELETE;
8393
8394 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8395 trace
8396 (p_msg => 'END of procedure RAISE_UNIT_EVENT'
8397 ,p_level => C_LEVEL_PROCEDURE
8398 ,p_module => l_log_module);
8399 END IF;
8400
8401 EXCEPTION
8402 WHEN others THEN
8403 wf_core.CONTEXT('xla_accounting_pkg','raise_unit_event',x_progress);
8404 RAISE;
8405
8406 END raise_unit_event;
8407
8408 --------------------------------------------------------------------------------
8409 -- This procedure is used to handle accounting hooks for preaccounting, extract,
8410 -- postprocessing and postaccounting.
8411 -- p_event_name will be 'postprocessing' or 'extract' or 'preaccounting' or
8412 -- 'postaccounting'
8413 --------------------------------------------------------------------------------
8414 PROCEDURE handle_accounting_hook
8415 (p_application_id IN NUMBER
8416 ,p_ledger_id IN NUMBER
8417 ,p_process_category IN VARCHAR2
8418 ,p_end_date IN DATE
8419 ,p_accounting_mode IN VARCHAR2
8420 ,p_budgetary_control_mode IN VARCHAR2
8421 ,p_valuation_method IN VARCHAR2
8422 ,p_security_id_int_1 IN NUMBER
8423 ,p_security_id_int_2 IN NUMBER
8424 ,p_security_id_int_3 IN NUMBER
8425 ,p_security_id_char_1 IN VARCHAR2
8426 ,p_security_id_char_2 IN VARCHAR2
8427 ,p_security_id_char_3 IN VARCHAR2
8428 ,p_report_request_id IN NUMBER
8429 ,p_event_name IN VARCHAR2
8430 ,p_event_key IN VARCHAR2)
8431 IS
8432 l_log_module VARCHAR2(240);
8433 l_sqlerrm VARCHAR2(2000);
8434 BEGIN
8435 IF g_log_enabled THEN
8436 l_log_module := C_DEFAULT_MODULE||'.handle_accounting_hook';
8437 END IF;
8438
8439 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8440 trace
8441 (p_msg => 'BEGIN of procedure handle_accounting_hook'
8442 ,p_level => C_LEVEL_PROCEDURE
8443 ,p_module => l_log_module);
8444 END IF;
8445
8446 --------------------------------------------------------------------------
8447 -- Calling different API's depending on Application ID
8448 --------------------------------------------------------------------------
8449 CASE
8450 --
8451 -- For Account Payables
8452 --
8453 WHEN p_application_id = 200 THEN
8454 xla_ap_acct_hooks_pkg.main
8455 ( p_application_id => p_application_id
8456 ,p_ledger_id => p_ledger_id
8457 ,p_process_category => p_process_category
8458 ,p_end_date => p_end_date
8459 ,p_accounting_mode => CASE WHEN NVL(p_budgetary_control_mode,'NONE') = 'NONE'
8460 THEN p_accounting_mode
8461 ELSE p_budgetary_control_mode
8462 END -- 4606566
8463 ,p_valuation_method => p_valuation_method
8464 ,p_security_id_int_1 => p_security_id_int_1
8465 ,p_security_id_int_2 => p_security_id_int_2
8466 ,p_security_id_int_3 => p_security_id_int_3
8467 ,p_security_id_char_1 => p_security_id_char_1
8468 ,p_security_id_char_2 => p_security_id_char_2
8469 ,p_security_id_char_3 => p_security_id_char_3
8470 ,p_report_request_id => p_report_request_id
8471 ,p_event_name => p_event_name);
8472
8473 --
8474 -- For Account Recievables
8475 --
8476 WHEN p_application_id = 222 THEN
8477 xla_ar_acct_hooks_pkg.main
8478 ( p_application_id => p_application_id
8479 ,p_ledger_id => p_ledger_id
8480 ,p_process_category => p_process_category
8481 ,p_end_date => p_end_date
8482 ,p_accounting_mode => p_accounting_mode
8483 ,p_valuation_method => p_valuation_method
8484 ,p_security_id_int_1 => p_security_id_int_1
8485 ,p_security_id_int_2 => p_security_id_int_2
8486 ,p_security_id_int_3 => p_security_id_int_3
8487 ,p_security_id_char_1 => p_security_id_char_1
8488 ,p_security_id_char_2 => p_security_id_char_2
8489 ,p_security_id_char_3 => p_security_id_char_3
8490 ,p_report_request_id => p_report_request_id
8491 ,p_event_name => p_event_name);
8492
8493 --
8494 -- For Fixed Assets
8495 --
8496 WHEN p_application_id = 140 THEN
8497 xla_fa_acct_hooks_pkg.main
8498 ( p_application_id => p_application_id
8499 ,p_ledger_id => p_ledger_id
8500 ,p_process_category => p_process_category
8501 ,p_end_date => p_end_date
8502 ,p_accounting_mode => p_accounting_mode
8503 ,p_valuation_method => p_valuation_method
8504 ,p_security_id_int_1 => p_security_id_int_1
8505 ,p_security_id_int_2 => p_security_id_int_2
8506 ,p_security_id_int_3 => p_security_id_int_3
8507 ,p_security_id_char_1 => p_security_id_char_1
8508 ,p_security_id_char_2 => p_security_id_char_2
8509 ,p_security_id_char_3 => p_security_id_char_3
8510 ,p_report_request_id => p_report_request_id
8511 ,p_event_name => p_event_name);
8512
8513 --
8514 -- For Cash Managment
8515 --
8516 WHEN p_application_id = 260 THEN
8517 xla_ce_acct_hooks_pkg.main
8518 ( p_application_id => p_application_id
8519 ,p_ledger_id => p_ledger_id
8520 ,p_process_category => p_process_category
8521 ,p_end_date => p_end_date
8522 ,p_accounting_mode => p_accounting_mode
8523 ,p_valuation_method => p_valuation_method
8524 ,p_security_id_int_1 => p_security_id_int_1
8525 ,p_security_id_int_2 => p_security_id_int_2
8526 ,p_security_id_int_3 => p_security_id_int_3
8527 ,p_security_id_char_1 => p_security_id_char_1
8528 ,p_security_id_char_2 => p_security_id_char_2
8529 ,p_security_id_char_3 => p_security_id_char_3
8530 ,p_report_request_id => p_report_request_id
8531 ,p_event_name => p_event_name);
8532
8533
8534
8535 --
8536 -- For Process Manufacturing Financials
8537 --
8538
8539 WHEN p_application_id = 555 THEN
8540 xla_gmf_acct_hooks_pkg.main
8541 ( p_application_id => p_application_id
8542 ,p_ledger_id => p_ledger_id
8543 ,p_process_category => p_process_category
8544 ,p_end_date => p_end_date
8545 ,p_accounting_mode => p_accounting_mode
8546 ,p_valuation_method => p_valuation_method
8547 ,p_security_id_int_1 => p_security_id_int_1
8548 ,p_security_id_int_2 => p_security_id_int_2
8549 ,p_security_id_int_3 => p_security_id_int_3
8550 ,p_security_id_char_1 => p_security_id_char_1
8551 ,p_security_id_char_2 => p_security_id_char_2
8552 ,p_security_id_char_3 => p_security_id_char_3
8553 ,p_report_request_id => p_report_request_id
8554 ,p_event_name => p_event_name);
8555
8556 --
8557 -- For Payroll
8558 --
8559
8560 WHEN p_application_id = 801 THEN
8561 xla_pay_acct_hooks_pkg.main
8562 ( p_application_id => p_application_id
8563 ,p_ledger_id => p_ledger_id
8564 ,p_process_category => p_process_category
8565 ,p_end_date => p_end_date
8566 ,p_accounting_mode => p_accounting_mode
8567 ,p_valuation_method => p_valuation_method
8568 ,p_security_id_int_1 => p_security_id_int_1
8569 ,p_security_id_int_2 => p_security_id_int_2
8570 ,p_security_id_int_3 => p_security_id_int_3
8571 ,p_security_id_char_1 => p_security_id_char_1
8572 ,p_security_id_char_2 => p_security_id_char_2
8573 ,p_security_id_char_3 => p_security_id_char_3
8574 ,p_report_request_id => p_report_request_id
8575 ,p_event_name => p_event_name);
8576
8577 -- Bug 12725312
8578 -- Added a call to OKL API.
8579 --
8580 -- For Lease Management
8581 --
8582
8583 WHEN p_application_id = 540 THEN
8584 xla_okl_acct_hooks_pkg.main
8585 ( p_application_id => p_application_id
8586 ,p_ledger_id => p_ledger_id
8587 ,p_process_category => p_process_category
8588 ,p_end_date => p_end_date
8589 ,p_accounting_mode => p_accounting_mode
8590 ,p_valuation_method => p_valuation_method
8591 ,p_security_id_int_1 => p_security_id_int_1
8592 ,p_security_id_int_2 => p_security_id_int_2
8593 ,p_security_id_int_3 => p_security_id_int_3
8594 ,p_security_id_char_1 => p_security_id_char_1
8595 ,p_security_id_char_2 => p_security_id_char_2
8596 ,p_security_id_char_3 => p_security_id_char_3
8597 ,p_report_request_id => p_report_request_id
8598 ,p_event_name => p_event_name);
8599
8600 --
8601 -- For all other products
8602 --
8603 ELSE
8604 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8605 trace
8606 (p_msg => 'Warning: Product is not integrated using APIs'
8607 ,p_level => C_LEVEL_PROCEDURE
8608 ,p_module => l_log_module);
8609 END IF;
8610 END CASE;
8611
8612 --
8613 -- raising business event for all the subledgers
8614 --
8615
8616 IF p_event_name IN ('extract','postprocessing') THEN
8617 raise_unit_event
8618 (p_application_id => p_application_id
8619 ,p_accounting_mode => p_accounting_mode
8620 ,p_event_name => p_event_name
8621 ,p_event_key => p_event_key);
8622 ELSE
8623 raise_accounting_event
8624 (p_application_id => p_application_id
8625 ,p_ledger_id => p_ledger_id
8626 ,p_process_category => p_process_category
8627 ,p_end_date => p_end_date
8628 ,p_accounting_mode => p_accounting_mode
8629 ,p_valuation_method => p_valuation_method
8630 ,p_security_id_int_1 => p_security_id_int_1
8631 ,p_security_id_int_2 => p_security_id_int_2
8632 ,p_security_id_int_3 => p_security_id_int_3
8633 ,p_security_id_char_1 => p_security_id_char_1
8634 ,p_security_id_char_2 => p_security_id_char_2
8635 ,p_security_id_char_3 => p_security_id_char_3
8636 ,p_report_request_id => p_report_request_id
8637 ,p_event_name => p_event_name
8638 ,p_event_key => p_event_key);
8639 END IF;
8640
8641 -- Call to PSA accounting hook
8642 xla_psa_acct_hooks_pkg.main
8643 ( p_application_id => p_application_id
8644 ,p_ledger_id => p_ledger_id
8645 ,p_process_category => p_process_category
8646 ,p_end_date => p_end_date
8647 ,p_accounting_mode => p_accounting_mode
8648 ,p_valuation_method => p_valuation_method
8649 ,p_security_id_int_1 => p_security_id_int_1
8650 ,p_security_id_int_2 => p_security_id_int_2
8651 ,p_security_id_int_3 => p_security_id_int_3
8652 ,p_security_id_char_1 => p_security_id_char_1
8653 ,p_security_id_char_2 => p_security_id_char_2
8654 ,p_security_id_char_3 => p_security_id_char_3
8655 ,p_report_request_id => p_report_request_id
8656 ,p_event_name => p_event_name);
8657
8658 -- Call to Federal accounting hook
8659 xla_fv_acct_hooks_pkg.main
8660 ( p_application_id => p_application_id
8661 ,p_ledger_id => p_ledger_id
8662 ,p_process_category => p_process_category
8663 ,p_end_date => p_end_date
8664 ,p_accounting_mode => p_accounting_mode
8665 ,p_valuation_method => p_valuation_method
8666 ,p_security_id_int_1 => p_security_id_int_1
8667 ,p_security_id_int_2 => p_security_id_int_2
8668 ,p_security_id_int_3 => p_security_id_int_3
8669 ,p_security_id_char_1 => p_security_id_char_1
8670 ,p_security_id_char_2 => p_security_id_char_2
8671 ,p_security_id_char_3 => p_security_id_char_3
8672 ,p_report_request_id => p_report_request_id
8673 ,p_event_name => p_event_name);
8674
8675
8676 -- Call to IGI accounting hook bug6359422
8677
8678 xla_igi_acct_hooks_pkg.main
8679 ( p_application_id => p_application_id
8680 ,p_ledger_id => p_ledger_id
8681 ,p_process_category => p_process_category
8682 ,p_end_date => p_end_date
8683 ,p_accounting_mode => p_accounting_mode
8684 ,p_valuation_method => p_valuation_method
8685 ,p_security_id_int_1 => p_security_id_int_1
8686 ,p_security_id_int_2 => p_security_id_int_2
8687 ,p_security_id_int_3 => p_security_id_int_3
8688 ,p_security_id_char_1 => p_security_id_char_1
8689 ,p_security_id_char_2 => p_security_id_char_2
8690 ,p_security_id_char_3 => p_security_id_char_3
8691 ,p_report_request_id => p_report_request_id
8692 ,p_event_name => p_event_name);
8693
8694 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8695 trace
8696 (p_msg => 'END of procedure handle_accounting_hooks'
8697 ,p_level => C_LEVEL_PROCEDURE
8698 ,p_module => l_log_module);
8699 END IF;
8700
8701 EXCEPTION
8702 WHEN xla_exceptions_pkg.application_exception THEN
8703 RAISE;
8704 WHEN others THEN
8705 l_sqlerrm := sqlerrm;
8706
8707 IF (C_LEVEL_EXCEPTION>= g_log_level) THEN
8708 trace
8709 (p_msg => 'Technical problem : Exception encounterd while raising '||
8710 'business event for '||p_event_name||
8711 xla_environment_pkg.g_chr_newline||l_sqlerrm
8712 ,p_level => C_LEVEL_EXCEPTION
8713 ,p_module => l_log_module);
8714 END IF;
8715
8716 xla_accounting_err_pkg.build_message
8717 (p_appli_s_name => 'XLA'
8718 ,p_msg_name => 'XLA_AP_TECHNICAL_ERROR'
8719 ,p_token_1 => 'APPLICATION_NAME'
8720 ,p_value_1 => 'SLA'
8721 ,p_entity_id => NULL
8722 ,p_event_id => NULL);
8723
8724 print_logfile('Technical problem : Exception encounterd while raising busniess event for '||p_event_name);
8725
8726 xla_exceptions_pkg.raise_message
8727 (p_appli_s_name => 'XLA'
8728 ,p_msg_name => 'XLA_COMMON_ERROR'
8729 ,p_token_1 => 'LOCATION'
8730 ,p_value_1 => 'xla_accounting_pkg.handle_accounting_hook'
8731 ,p_token_2 => 'ERROR'
8732 ,p_value_2 => 'Technical problem : Exception encounterd while raising '||
8733 'busniess event for '||p_event_name||
8734 xla_environment_pkg.g_chr_newline||l_sqlerrm);
8735 END handle_accounting_hook;
8736
8737 FUNCTION concat_event_classes
8738 (p_processing_order IN NUMBER)
8739 RETURN VARCHAR2
8740 IS
8741 l_concat_classes VARCHAR2(5000);
8742 BEGIN
8743 l_concat_classes := NULL;
8744 --
8745 -- changes done for bug 5673550 to put filter based on process category
8746 --
8747 IF g_process_category IS NULL THEN
8748 FOR c IN (SELECT event_class_code FROM xla_evt_class_orders_gt WHERE processing_order = p_processing_order) LOOP
8749 IF l_concat_classes IS NULL THEN
8750 l_concat_classes := C_QUOTE;
8751 ELSE
8752 l_concat_classes := l_concat_classes || C_COMMA;
8753 END IF;
8754 l_concat_classes := l_concat_classes || c.event_class_code;
8755 END LOOP;
8756 ELSE
8757 FOR c IN (SELECT xec.event_class_code
8758 FROM xla_evt_class_orders_gt xec
8759 ,xla_event_class_attrs xea
8760 WHERE xea.application_id = g_application_id
8761 AND xea.event_class_code = xec.event_class_code
8762 AND xea.event_class_group_code = g_process_category
8763 AND xec.processing_order = p_processing_order) LOOP
8764 IF l_concat_classes IS NULL THEN
8765 l_concat_classes := C_QUOTE;
8766 ELSE
8767 l_concat_classes := l_concat_classes || C_COMMA;
8768 END IF;
8769 l_concat_classes := l_concat_classes || c.event_class_code;
8770 END LOOP;
8771 END IF;
8772
8773 IF l_concat_classes IS NOT NULL THEN
8774 l_concat_classes := l_concat_classes || C_QUOTE;
8775 END IF;
8776
8777 RETURN l_concat_classes;
8778
8779 END concat_event_classes;
8780
8781 --=============================================================================
8782 -- *********** Initialization routine **********
8783 --=============================================================================
8784
8785 --=============================================================================
8786 --
8787 --
8788 --
8789 --
8790 --
8791 --
8792 --
8793 --
8794 --
8795 --
8796 -- Following code is executed when the package body is referenced for the first
8797 -- time
8798 --
8799 --
8800 --
8801 --
8802 --
8803 --
8804 --
8805 --
8806 --
8807 --
8808 --
8809 --
8810 --=============================================================================
8811
8812 BEGIN
8813 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
8814 g_log_enabled := fnd_log.test
8815 (log_level => g_log_level
8816 ,MODULE => C_DEFAULT_MODULE);
8817
8818 IF NOT g_log_enabled THEN
8819 g_log_level := C_LEVEL_LOG_DISABLED;
8820 END IF;
8821
8822 g_conc_hold := fnd_profile.value('CONC_HOLD');
8823
8824 END xla_accounting_pkg;