[Home] [Help]
PACKAGE BODY: APPS.XLA_EVENTS_PKG
Source
1 PACKAGE BODY xla_events_pkg AS
2 -- $Header: xlaevevt.pkb 120.112.12020000.2 2012/07/23 13:27:15 vgopiset ship $
3 /*===========================================================================+
4 | Copyright (c) 2001-2002 Oracle Corporation |
5 | Redwood Shores, CA, USA |
6 | All rights reserved. |
7 +============================================================================+
8 | FILENAME |
9 | xlaevevt.pkb |
10 | |
11 | PACKAGE NAME |
12 | xla_events_pkg |
13 | |
14 | DESCRIPTION |
15 | This is a XLA private package, which contains all the APIs |
16 | required for processing accounting events. |
17 | |
18 | The public wrapper called xla_event_pub_pkg, is built based on |
19 | this package. |
20 | |
21 | Note: |
22 | - the APIs do not execute any COMMIT or ROLLBACK except in |
23 | - period_close procedure.
24 | - these APIs are not supposed to return any error when being |
25 | used in production. Internal english message are hard-coded. |
26 | |
27 | HISTORY |
28 | 08-Feb-01 G. Qu Created |
29 | 10-Mar-01 P. Labrevois Reviewed |
30 | 28-Mar-01 P. Labrevois Review security columns |
31 | 27-Apr-01 P. Labrevois Review per new datamodel change |
32 | 10-Aug-01 P. Labrevois Added bulk |
33 | 13-Sep-01 P. Labrevois Reviewed |
34 | 08-Feb-02 S. Singhania Reviewed and performed major changes |
35 | 10-Feb-02 S. Singhania Made changes in APIs to handle 'Transaction |
36 | Number' (new column added in xla_entities) |
37 | 13-Feb-02 S. Singhania Made changes in APIs to handle 'Event Number' |
38 | 18-Feb-02 S. Singhania Procedure 'Initialize' is made public. Minor |
39 | changes. |
40 | 04-Mar-02 S. Singhania Changes in the function "get_id_mapping" |
41 | Added condition "entity_id = g_entity_id" in |
42 | all the update APIs. |
43 | Removed date validation calls and truncated |
44 | event date in all the APIs |
45 | 18-Mar-02 S. Singhania Modified the Bulk APIs to improve performance |
46 | by using a "Temporary table" |
47 | 08-Apr-02 S. Singhania Removed the not required, redundant APIs |
48 | 19-Apr-02 S. Singhania Added seperate API to update transaction |
49 | number. modified the APIs based on changes |
50 | in "event_source_info" & "entity_source_info |
51 | 08-May-02 S. Singhania Made changes in the routines to include: |
52 | NOT NULL ledger_id, NULL valuation_method. |
53 | legal_entity_id is made NULL in XLA_ENTITIES |
54 | Removed "legal_entity_id" from XLA_EVENTS |
55 | Bug # 2351677 |
56 | 14-May-02 S. Singhania Modified "event_exists" routine and changed |
57 | cursors in 'cache_application_setups'. |
58 | 31-May-02 S. Singhania Made changes based on Bug # 2392835. Updated |
59 | code at all the places to make sure |
60 | 'source_id_date_n' is not used. |
61 | Changes based on Bug # 2385846. Changes made |
62 | to support XLA_ENTITY_ID_MAPPINGS column |
63 | name changes. Modified APIs 'update_event' |
64 | and 'update_event_status' to update |
65 | 'process_status' with 'event_status' |
66 | Renamed 'create_entity_event' API to |
67 | 'create_bulk_events' |
68 | 14-Jun-02 S. Singhania Added the bulk API, 'update_event_status_bulk'|
69 | to update event/entity status in bulk. This |
70 | API will be called by Accounting Program |
71 | 18-Jul-02 S. Singhania Added curosr in 'cache_application_setup' to |
72 | cache application from xla_subledgers. |
73 | Commented 'validate_event_date' routine. Date |
74 | validation is not needed. |
75 | Commented 'update_entity_status' and 'evaluate|
76 | _entity_status'. Bug # 2464825. Removed |
77 | reference to g_entity_status_code. |
78 | Cleaned up Exception messages. |
79 | 23-Jul-02 S. Singhania Modified code to handle to issue of 'enabled |
80 | flags'.( see DLD closed issues). |
81 | 14-Aug-02 S. Singhania Changed XLA_ENTITES and XLA_ENTITIES_S to |
82 | XLA_TRANSACTION_ENTITIES and |
83 | XLA_TRANSACTION_ENTITIES_S |
84 | 09-Sep-02 S. Singhania Made changes to 'cache_entity_info' to handle |
85 | MANUAL events. Bug # 2529997. |
86 | 09-Sep-02 S. Singhania modified 'create_bulk_events' routine (with |
87 | single array) to handle entities belonging |
88 | to multiple security contexts. Bug # 2530796 |
89 | 08-Nov-02 S. Singhania Included and verified 'get_entity_id' API for |
90 | 'document mode' Accounting Program |
91 | 21-Feb-03 S. Singhania Added 'Trace' procedure. |
92 | 10-Apr-03 S. Singhania Made changes due to change in temporary table |
93 | name (bug # 2897261) |
94 | 12-Jun-03 S. Singhania Fixed FND Messages (bug # 3001156). |
95 | Removed commented APIs. |
96 | 10-Jul-03 S. Singhania Added new APIs for MANUAL events (2899700) |
97 | - UPDATE_MANUAL_EVENT |
98 | - CREATE_MANUAL_EVENT |
99 | - DELETE_PROCESSED_EVENT |
100 | modified other internal routines to handle the|
101 | the case of MANUAL events. |
102 | removed update_event_status_bulk API |
103 | (accounting program do not use this anymore)|
104 | 12-Aug-03 S. Singhania Fixed a typo in GET_ID_MAPPING |
105 | 21-Aug-03 S. Singhania Enhanced the following APIs to fix 2701681 |
106 | - update_event_status |
107 | - update_event |
108 | - delete_event |
109 | - delete_events |
110 | - delete_processed_event |
111 | 28-Aug-03 S. Singhania Modified UPDATE_EVENT to fix 3111204 |
112 | 04-Sep-03 S. Singhania Enhanced APIs to support 'Source Application':|
113 | - Added parameter p_source_application_id to|
114 | CREATE_BULK_EVENTS API |
115 | - Added validation for source application in|
116 | CREATE_EVENT and CREATE_BULK_EVENTS |
117 | - Modified the insert statment to insert |
118 | source application in CREATE_ENTITY_EVENT |
119 | 05-Sep-03 S. Singhania To improve performance, the structures to |
120 | store event_types, event_classes and |
121 | entity_types are modified. Following were |
122 | impacted: |
123 | - CACHE_APPLICATION_SETUP |
124 | - VALIDATE_EVENT_ENTITY_CODE |
125 | - VALIDATE_EVNENT_CLASS_CODE |
126 | - VALIDATE_EVNET_TYPE_CODE. |
127 | 12-Dec-03 S. Singhania Bug # 3268790. |
128 | - Modified cursors in CACHE_ENTITY_INFO not |
129 | to lock rows in xla_transaction_entities. |
130 | - Routines DELETE_EVENTS and DELETE_EVENT |
131 | are modified not to delete entites when |
132 | last STANDARD event is deleted for the |
133 | entity. |
134 | 04-Mar-04 W. Shen Gapless event processing project |
135 | 25-Mar-04 W. Shen add trace |
136 | 23-Jun-04 W. Shen New API delete_entity to delete entities |
137 | from xla_transaction_entities(bug 3316535) |
138 | 10-Aug-04 S. Singhania Added trace messages to help debug the code |
139 | 23-OCT-04 W. Shen New API to delete/update/create event in bulk |
140 | 09-Nov-04 S. Singhania Made chnages for valuation method enhancements|
141 | Following routines were modified: |
142 | - CACHE_APPLICATION_SETUP |
143 | - RESET_CACHE |
144 | - VALIDATE_CONTEXT |
145 | - VALIDATE_LEDGER (New routine added) |
146 | 23-OCT-04 W. Shen bulk delete API, when delete transaction |
147 | entities, make sure only delete those |
148 | affected by the batch. |
149 | 1- APR-05 W. Shen Add transaction_date to the following API: |
150 | create_event, create_manual_event |
151 | create_bulk_events(two of them) |
152 | update_event |
153 | 20-Apr-05 S. Singhania Bug 4312353. |
154 | - Modified signature of routines in to reflect|
155 | the change in the way we handle valuation |
156 | method different from other security columns|
157 | - The major impact is on the following: |
158 | - SOURCE_INFO_CHANGED |
159 | - CACHE_ENTITY_INFO |
160 | - CREATE_BULK_EVENTS |
161 | 02-May-05 V. Kumar Removed function create_bulk_events, |
162 | Bug # 4323140 |
163 | 22-Jul-05 Swapna Vellani Modified an insert statement in |
164 | create_bulk_events procedure Bug #4458604 |
165 | 2- Aug-05 W. Shen remove the validation for p_source_app_id |
166 | bug 4526089 |
167 | 30- Aug-05 W. Shen when no entity exists, event_exists will |
168 | return false instead of raising exception |
169 | bug 4529563 |
170 | 30-Aug-05 S. Singhania Bug 4519181: Added call to |
171 | XLA_SECURITY_PKG.SET_SECURITY_CONTEXT to |
172 | each public API. |
173 | 07-Oct-09 VGOPISET Bug:8967771 , few queries on XLA_EVENTS has |
174 | no join on APPLICATION_ID |
175 | 30-SEP-10 VDAMERLA Bug:9077926 Created overloaded procedures |
176 | for create_bulk_events and |
177 | update_bulk_event_statuses to pass |
178 | bulk limit value |
179 | 13-Oct-10 nksurana Bug 10152910 Created new function/API |
180 | allow_third_party_update to check if the party|
181 | site can be updated, based on Control Account.|
182 | 06-Jan-11 sgullape Bug 9775727:Modified the WHERE condition while|
183 | deleteing the data from XLA_ACCOUNTING_ERRORS |
184 | in delete_je procedure. |
185 | Bug 10162587: Modified at SAVEPOINT in |
186 | delete_bulk_events procedure. |
187 +===========================================================================*/
188
189 --=============================================================================
190 -- **************** declaraions ********************
191 --=============================================================================
192 -------------------------------------------------------------------------------
193 -- declaring private constants
194 -------------------------------------------------------------------------------
195
196 C_YES CONSTANT VARCHAR2(1) := 'Y'; -- yes flag
197 C_NO CONSTANT VARCHAR2(1) := 'N'; -- no flag
198
199 C_NUM CONSTANT NUMBER := -99;
200 C_CHAR CONSTANT VARCHAR2(30) := ' ';
201
202 C_EVENT_DELETE CONSTANT VARCHAR2(1) := 'D';
203 C_EVENT_CREATE CONSTANT VARCHAR2(1) := 'C';
204 C_EVENT_UPDATE CONSTANT VARCHAR2(1) := 'U';
205 C_EVENT_QUERY CONSTANT VARCHAR2(1) := 'Q';
206
207 C_MANUAL_ENTITY CONSTANT VARCHAR2(30) := 'MANUAL';
208 C_MANUAL_EVENT_CONTEXT CONSTANT VARCHAR2(30) := 'MANUAL';
209 C_REGULAR_EVENT_CONTEXT CONSTANT VARCHAR2(30) := 'REGULAR';
210 -------------------------------------------------------------------------------
211 -- declaring private pl/sql types
212 -------------------------------------------------------------------------------
213 TYPE t_event_type IS RECORD
214 (event_class_code VARCHAR2(30)
215 ,enabled_flag VARCHAR2(1));
216
217 TYPE t_class_type IS RECORD
218 (entity_type_code VARCHAR2(30)
219 ,enabled_flag VARCHAR2(1));
220
221 TYPE t_entity_type IS RECORD
222 (id_mapping VARCHAR2(8)
223 ,enabled_flag VARCHAR2(1));
224
225
226 TYPE t_parameter_tbl IS TABLE OF VARCHAR2(100) INDEX BY BINARY_INTEGER;
227 TYPE t_number_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
228 TYPE t_array_event_type IS TABLE OF t_event_type INDEX BY VARCHAR2(30);
229 TYPE t_array_event_class IS TABLE OF t_class_type INDEX BY VARCHAR2(30);
230 TYPE t_array_entity_type IS TABLE OF t_entity_type INDEX BY VARCHAR2(30);
231 TYPE t_event_status_tbl IS TABLE OF xla_events.event_status_code%type
232 INDEX BY BINARY_INTEGER;
233 TYPE t_on_hold_flag_tbl IS TABLE OF xla_events.on_hold_flag%type
234 INDEX BY BINARY_INTEGER;
235 TYPE t_event_number_tbl IS TABLE OF xla_events.event_number%type
236 INDEX BY BINARY_INTEGER;
237 TYPE t_ledger_status_tbl IS TABLE OF VARCHAR2(1) INDEX BY BINARY_INTEGER;
238
239
240 TYPE t_array_varchar IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER; -- Bug 13698935
241
242
243 -------------------------------------------------------------------------------
244 -- declaring private variables
245 -------------------------------------------------------------------------------
246
247 g_entity_type_code_tbl t_array_entity_type; -- for caching entity_type
248 g_event_class_code_tbl t_array_event_class; -- for caching event_class
249 g_event_type_code_tbl t_array_event_type; -- for caching event_type
250 g_event_status_code_tbl t_parameter_tbl; -- for caching event_status
251 g_process_status_code_tbl t_parameter_tbl; -- for caching internal status
252 g_id_mapping VARCHAR2(12); -- for caching entity mapping
253
254 g_ledger_status_tbl t_ledger_status_tbl;
255 -- for caching the value if event can be created
256
257 g_source_info xla_events_pub_pkg.t_event_source_info;
258 g_entity_id NUMBER; -- Entity id 8761772
259 g_entity_type_code VARCHAR2(30); -- Entity code
260 g_valuation_method VARCHAR2(80); -- valuation method
261
262 g_application_id PLS_INTEGER;
263 g_transaction_number VARCHAR2(240);
264 g_max_event_number NUMBER := 0;
265 g_context VARCHAR2(30);
266 g_action VARCHAR2(1);
267 g_gapless_flag VARCHAR2(1);
268 g_gapless_array_event_status t_event_status_tbl;
269 g_gapless_event_number t_event_number_tbl;
270
271 --=============================================================================
272 -- *********** Local Trace Routine **********
273 --=============================================================================
274 C_LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
275 C_LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
276 C_LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
277 C_LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
278 C_LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
279 C_LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
280
281 C_LEVEL_LOG_DISABLED CONSTANT NUMBER := 99;
282
283 C_DEFAULT_MODULE CONSTANT VARCHAR2(240) := 'xla.plsql.xla_events_pkg';
284
285 g_debug_flag VARCHAR2(1):= NVL(fnd_profile.value('XLA_DEBUG_TRACE'),'N');
286
287 --l_log_module VARCHAR2(240);
288 g_log_level NUMBER;
289 g_log_enabled BOOLEAN;
290
291
292 -------------------------------------------------------------------------------
293 -- forward declarion of private procedures and functions
294 -------------------------------------------------------------------------------
295
296 PROCEDURE validate_context
297 (p_application_id IN INTEGER
298 ,p_ledger_id IN INTEGER
299 ,p_entity_type_code IN VARCHAR2);
300
301 PROCEDURE validate_ids
302 (p_entity_type_code IN VARCHAR2
303 ,p_source_id_int_1 IN INTEGER
304 ,p_source_id_int_2 IN INTEGER
305 ,p_source_id_int_3 IN INTEGER
306 ,p_source_id_int_4 IN INTEGER
307 ,p_source_id_char_1 IN VARCHAR2
308 ,p_source_id_char_2 IN VARCHAR2
309 ,p_source_id_char_3 IN VARCHAR2
310 ,p_source_id_char_4 IN VARCHAR2);
311
312 PROCEDURE validate_cached_setup;
313
314 PROCEDURE cache_application_setup
315 (p_application_id IN INTEGER);
316
317 PROCEDURE validate_entity_type_code
318 (p_entity_type_code IN VARCHAR2);
319
320 PROCEDURE validate_event_class_code
321 (p_entity_type_code IN VARCHAR2
322 ,p_event_class_code IN VARCHAR2);
323
324 PROCEDURE validate_event_type_code
325 (p_entity_type_code IN VARCHAR2
326 ,p_event_class_code IN VARCHAR2
327 ,p_event_type_code IN VARCHAR2);
328
329 PROCEDURE validate_status_code
330 (p_event_status_code IN VARCHAR2
331 ,p_process_status_code IN VARCHAR2);
332
333 PROCEDURE validate_params
334 (p_source_info IN xla_events_pub_pkg.t_event_source_info
335 ,p_event_class_code IN VARCHAR2 DEFAULT NULL
336 ,p_event_type_code IN VARCHAR2 DEFAULT NULL
337 ,p_event_date IN DATE DEFAULT NULL
338 ,p_event_status_code IN VARCHAR2 DEFAULT NULL
339 ,p_process_status_code IN VARCHAR2 DEFAULT NULL);
340
341 PROCEDURE validate_ledger
342 (p_ledger_id IN NUMBER
343 ,p_application_id IN NUMBER);
344
345 PROCEDURE cache_entity_info
346 (p_source_info IN xla_events_pub_pkg.t_event_source_info
347 ,p_valuation_method IN VARCHAR2
348 ,p_event_id IN NUMBER); -- 8761772
349
350 PROCEDURE update_entity_trx_number
351 (p_transaction_number IN VARCHAR2);
352
353 PROCEDURE reset_cache;
354
355 PROCEDURE set_context
356 (p_context IN VARCHAR2);
357
358 FUNCTION source_info_changed
359 (p_event_source_info1 IN xla_events_pub_pkg.t_event_source_info
360 ,p_event_source_info2 IN xla_events_pub_pkg.t_event_source_info
361 ,p_valuation_method1 IN VARCHAR2
362 ,p_valuation_method2 IN VARCHAR2)
363 RETURN BOOLEAN;
364
365 FUNCTION get_id_mapping
366 (p_entity_type_code IN VARCHAR2
367 ,p_source_id_code_1 IN VARCHAR2
368 ,p_source_id_code_2 IN VARCHAR2
369 ,p_source_id_code_3 IN VARCHAR2
370 ,p_source_id_code_4 IN VARCHAR2)
371 RETURN VARCHAR2;
372
373 FUNCTION create_entity_event
374 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
375 ,p_valuation_method IN VARCHAR2
376 ,p_event_type_code IN VARCHAR2
377 ,p_event_date IN DATE
378 ,p_event_status_code IN VARCHAR2
379 ,p_process_status_code IN VARCHAR2
380 ,p_event_number IN NUMBER
381 ,p_transaction_date IN DATE
382 ,p_reference_info IN xla_events_pub_pkg.t_event_reference_info
383 DEFAULT NULL
384 ,p_budgetary_control_flag IN VARCHAR2)
385 RETURN INTEGER;
386
387 FUNCTION add_entity_event
388 (p_entity_id IN INTEGER
389 ,p_application_id IN INTEGER
390 ,p_ledger_id IN INTEGER
391 ,p_legal_entity_id IN INTEGER
392 ,p_event_type_code IN VARCHAR2
393 ,p_event_date IN DATE
394 ,p_event_status_code IN VARCHAR2
395 ,p_process_status_code IN VARCHAR2
396 ,p_event_number IN NUMBER
397 ,p_transaction_date IN DATE
398 ,p_reference_info IN xla_events_pub_pkg.t_event_reference_info
399 DEFAULT NULL
400 ,p_budgetary_control_flag IN VARCHAR2)
401 RETURN INTEGER;
402
403 PROCEDURE delete_je;
404
405 FUNCTION validate_id_where_clause return VARCHAR2;
406 FUNCTION join_id_where_clause return VARCHAR2;
407
408 FUNCTION get_application_name
409 (p_application_id IN NUMBER)
410 RETURN VARCHAR2;
411
412 FUNCTION get_ledger_name
413 (p_ledger_id IN NUMBER)
414 RETURN VARCHAR2;
415
416
417 --=============================================================================
418 -- *********** Local Trace Routine **********
419 --=============================================================================
420
421 PROCEDURE trace
422 (p_msg IN VARCHAR2
423 ,p_level IN NUMBER
424 ,p_module IN VARCHAR2 DEFAULT C_DEFAULT_MODULE) IS
425 BEGIN
426 IF (p_msg IS NULL AND p_level >= g_log_level) THEN
427 fnd_log.message(p_level, p_module);
428 ELSIF p_level >= g_log_level THEN
429 fnd_log.string(p_level, p_module, p_msg);
430 END IF;
431
432 EXCEPTION
433 WHEN xla_exceptions_pkg.application_exception THEN
434 RAISE;
435 WHEN OTHERS THEN
436 xla_exceptions_pkg.raise_message
437 (p_location => 'xla_events_pkg.trace');
438 END trace;
439
440 --=============================================================================
441 -- *********** public procedures and functions **********
442 --=============================================================================
443 --=============================================================================
444 --
445 --
446 --
447 --
448 --
449 --
450 --
451 --
452 --
453 --
454 -- Following are the routines on which "single event/entity" public APIs
455 -- are based.
456 --
457 -- 1. create_event
458 -- 2. create_manual_event
459 -- 3. update_event_status (for multiple events for an entity)
460 -- 4. update_event (update multiple attributes for an event)
461 -- 5. update_manual_event (update multiple attributes for an event)
462 -- 6. delete_event (for a single event)
463 -- 7. delete_events (for multiple events for an entity)
464 -- 8. purge_entity
465 -- 9. get_event_info (for an event)
466 -- 10. get_event_status (for an event)
467 -- 11. event_exists (for an entity)
468 -- 12. update_transaction_number
469 -- 13. get_entity_id
470 --
471 --
472 --
473 --
474 --
475 --
476 --
477 --
478 --
479 --
480 --
481 --
482 --=============================================================================
483
484 --=============================================================================
485 --
486 -- For MANUAL events this API cannot be called.
487 --
488 --=============================================================================
489
490 FUNCTION create_event
491 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
492 ,p_valuation_method IN VARCHAR2
493 ,p_event_type_code IN VARCHAR2
494 ,p_event_date IN DATE
495 ,p_event_status_code IN VARCHAR2
496 ,p_event_number IN INTEGER DEFAULT NULL
497 ,p_transaction_date IN DATE DEFAULT NULL
498 ,p_reference_info IN xla_events_pub_pkg.t_event_reference_info
499 DEFAULT NULL
500 ,p_budgetary_control_flag IN VARCHAR2)
501 RETURN INTEGER IS
502 l_event_date DATE;
503 L_CONSTANT CONSTANT VARCHAR2(30) := '##UNDEFINED##'; --chr(12);
504
505 /*
506 CURSOR csr_xla_applications IS
507 SELECT application_id
508 FROM xla_subledgers
509 WHERE application_id = p_event_source_info.source_application_id;
510 */
511 l_log_module VARCHAR2(240);
512 l_return_id INTEGER;
513
514 BEGIN
515 IF g_log_enabled THEN
516 l_log_module := C_DEFAULT_MODULE||'.create_event';
517 END IF;
518 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
519 trace
520 (p_msg => 'BEGIN of procedure create_event'
521 ,p_level => C_LEVEL_PROCEDURE
522 ,p_module =>l_log_module);
523 trace
524 (p_msg => 'source_application_id = '||
525 p_event_source_info.source_application_id
526 ,p_level => C_LEVEL_PROCEDURE
527 ,p_module =>l_log_module);
528 trace
529 (p_msg => 'application_id = '||p_event_source_info.application_id
530 ,p_level => C_LEVEL_PROCEDURE
531 ,p_module =>l_log_module);
532 trace
533 (p_msg => 'legal_entity_id = '||
534 p_event_source_info.legal_entity_id
535 ,p_level => C_LEVEL_PROCEDURE
536 ,p_module =>l_log_module);
537 trace
538 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
539 ,p_level => C_LEVEL_PROCEDURE
540 ,p_module =>l_log_module);
541 trace
542 (p_msg => 'entity_type_code = '||
543 p_event_source_info.entity_type_code
544 ,p_level => C_LEVEL_PROCEDURE
545 ,p_module =>l_log_module);
546 trace
547 (p_msg => 'transaction_number = '||
548 p_event_source_info.transaction_number
549 ,p_level => C_LEVEL_PROCEDURE
550 ,p_module =>l_log_module);
551 trace
552 (p_msg => 'source_id_int_1 = '||
553 p_event_source_info.source_id_int_1
554 ,p_level => C_LEVEL_PROCEDURE
555 ,p_module =>l_log_module);
556 trace
557 (p_msg => 'source_id_int_2 = '||
558 p_event_source_info.source_id_int_2
559 ,p_level => C_LEVEL_PROCEDURE
560 ,p_module =>l_log_module);
561 trace
562 (p_msg => 'source_id_int_3 = '||
563 p_event_source_info.source_id_int_3
564 ,p_level => C_LEVEL_PROCEDURE
565 ,p_module =>l_log_module);
566 trace
567 (p_msg => 'source_id_int_4 = '||
568 p_event_source_info.source_id_int_4
569 ,p_level => C_LEVEL_PROCEDURE
570 ,p_module =>l_log_module);
571 trace
572 (p_msg => 'source_id_char_1 = '||
573 p_event_source_info.source_id_char_1
574 ,p_level => C_LEVEL_PROCEDURE
575 ,p_module =>l_log_module);
576 trace
577 (p_msg => 'source_id_char_2 = '||
578 p_event_source_info.source_id_char_2
579 ,p_level => C_LEVEL_PROCEDURE
580 ,p_module =>l_log_module);
581 trace
582 (p_msg => 'source_id_char_3 = '||
583 p_event_source_info.source_id_char_3
584 ,p_level => C_LEVEL_PROCEDURE
585 ,p_module =>l_log_module);
586 trace
587 (p_msg => 'source_id_char_4 = '||
588 p_event_source_info.source_id_char_4
589 ,p_level => C_LEVEL_PROCEDURE
590 ,p_module =>l_log_module);
591 trace
592 (p_msg => 'p_event_type_code = '||p_event_type_code
593 ,p_level => C_LEVEL_PROCEDURE
594 ,p_module =>l_log_module);
595 trace
596 (p_msg => 'p_event_date = '||p_event_date
597 ,p_level => C_LEVEL_PROCEDURE
598 ,p_module =>l_log_module);
599 trace
600 (p_msg => 'p_event_status_code = '||p_event_status_code
601 ,p_level => C_LEVEL_PROCEDURE
602 ,p_module =>l_log_module);
603 trace
604 (p_msg => 'p_event_number = '||p_event_number
605 ,p_level => C_LEVEL_PROCEDURE
606 ,p_module =>l_log_module);
607 trace
608 (p_msg => 'security_id_int_1 = '||
609 xla_events_pub_pkg.g_security.security_id_int_1
610 ,p_level => C_LEVEL_PROCEDURE
611 ,p_module =>l_log_module);
612 trace
613 (p_msg => 'security_id_int_2 = '||
614 xla_events_pub_pkg.g_security.security_id_int_2
615 ,p_level => C_LEVEL_PROCEDURE
616 ,p_module =>l_log_module);
617 trace
618 (p_msg => 'security_id_int_3 = '||
619 xla_events_pub_pkg.g_security.security_id_int_3
620 ,p_level => C_LEVEL_PROCEDURE
621 ,p_module =>l_log_module);
622 trace
623 (p_msg => 'security_id_char_1 = '||
624 xla_events_pub_pkg.g_security.security_id_char_1
625 ,p_level => C_LEVEL_PROCEDURE
626 ,p_module =>l_log_module);
627 trace
628 (p_msg => 'security_id_char_2 = '||
629 xla_events_pub_pkg.g_security.security_id_char_2
630 ,p_level => C_LEVEL_PROCEDURE
631 ,p_module =>l_log_module);
632 trace
633 (p_msg => 'security_id_char_3 = '||
634 xla_events_pub_pkg.g_security.security_id_char_3
635 ,p_level => C_LEVEL_PROCEDURE
636 ,p_module =>l_log_module);
637 trace
638 (p_msg => 'valuation_method = '||p_valuation_method
639 ,p_level => C_LEVEL_PROCEDURE
640 ,p_module =>l_log_module);
641 trace
642 (p_msg => 'budgetary_control_flag = '||p_budgetary_control_flag
643 ,p_level => C_LEVEL_PROCEDURE
644 ,p_module =>l_log_module);
645 end if;
646
647 SAVEPOINT before_event_creation;
648 g_action := C_EVENT_CREATE;
649
650 ----------------------------------------------------------------------------
651 -- Following sets the Security Context for the execution. This enables the
652 -- event API to respect the transaction security.
653 ----------------------------------------------------------------------------
654 xla_security_pkg.set_security_context(p_event_source_info.application_id);
655
656 ----------------------------------------------------------------------------
657 -- check to see the API is not called for manual events
658 ----------------------------------------------------------------------------
659 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
660 xla_exceptions_pkg.raise_message
661 (p_appli_s_name => 'XLA'
662 ,p_msg_name => 'XLA_COMMON_ERROR'
663 ,p_token_1 => 'ERROR'
664 ,p_value_1 => 'For MANUAL events this API cannot be called'
665 ,p_token_2 => 'LOCATION'
666 ,p_value_2 => 'xla_events_pkg.get_array_event_info (fn)');
667 ELSE
668 g_context := C_REGULAR_EVENT_CONTEXT;
669 END IF;
670
671 IF p_event_type_code IS NULL THEN
672 xla_exceptions_pkg.raise_message
673 (p_appli_s_name => 'XLA'
674 ,p_msg_name => 'XLA_COMMON_ERROR'
675 ,p_token_1 => 'ERROR'
676 ,p_value_1 =>
677 'Event Type Code has an invalid value. It cannot have a NULL value.'
678 ,p_token_2 => 'LOCATION'
679 ,p_value_2 => 'xla_events_pkg.create_event');
680 END IF;
681 IF p_event_date IS NULL THEN
682 xla_exceptions_pkg.raise_message
683 (p_appli_s_name => 'XLA'
684 ,p_msg_name => 'XLA_COMMON_ERROR'
685 ,p_token_1 => 'ERROR'
686 ,p_value_1 =>
687 'Event Date has an invalid value. It cannot have a NULL value.'
688 ,p_token_2 => 'LOCATION'
689 ,p_value_2 => 'xla_events_pkg.create_event');
690 END IF;
691 IF p_event_status_code IS NULL THEN
692 xla_exceptions_pkg.raise_message
693 (p_appli_s_name => 'XLA'
694 ,p_msg_name => 'XLA_COMMON_ERROR'
695 ,p_token_1 => 'ERROR'
696 ,p_value_1 =>
697 'Event Status Code has an invalid value. It cannot have a NULL value.'
698 ,p_token_2 => 'LOCATION'
699 ,p_value_2 => 'xla_events_pkg.create_event');
700 END IF;
701
702 ----------------------------------------------------------------------------
703 -- truncate date
704 ----------------------------------------------------------------------------
705 l_event_date := TRUNC(p_event_date);
706
707 ----------------------------------------------------------------------------
708 -- Validate parameters
709 ----------------------------------------------------------------------------
710 validate_params
711 (p_source_info => p_event_source_info
712 ,p_event_type_code => p_event_type_code
713 ,p_event_status_code => p_event_status_code
714 ,p_process_status_code => C_INTERNAL_UNPROCESSED);
715
716 ----------------------------------------------------------------------------
717 -- Get document PK.
718 ----------------------------------------------------------------------------
719 cache_entity_info
720 (p_source_info => p_event_source_info
721 ,p_valuation_method => p_valuation_method
722 ,p_event_id => NULL);
723
724 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
725 trace
726 (p_msg => 'gapless_flag:'||g_gapless_flag
727 ,p_level => C_LEVEL_STATEMENT
728 ,p_module =>l_log_module);
729 trace
730 (p_msg => 'p_event_number:'||to_char(p_event_number)
731 ,p_level => C_LEVEL_STATEMENT
732 ,p_module =>l_log_module);
733 trace
734 (p_msg => 'g_entity_id:'||to_char(g_entity_id)
735 ,p_level => C_LEVEL_STATEMENT
736 ,p_module =>l_log_module);
737 END IF;
738
739 IF (g_gapless_flag = 'Y'
740 and (p_event_number is null or p_event_number<1)) THEN
741 xla_exceptions_pkg.raise_message
742 (p_appli_s_name => 'XLA'
743 ,p_msg_name => 'XLA_COMMON_ERROR'
744 ,p_token_1 => 'ERROR'
745 ,p_value_1 =>
746 'The developer has to give the event number greater than 0 when create new event for gapless processing.'
747 ,p_token_2 => 'LOCATION'
748 ,p_value_2 => 'xla_events_pkg.create_event');
749 END IF;
750 ----------------------------------------------------------------------------
751 -- If the PK is NULL, create an entity as well as the event. Otherwise,
752 -- add a new event to the entity.
753 ----------------------------------------------------------------------------
754 IF g_entity_id IS NULL THEN
755 l_return_id:=create_entity_event
756 (p_event_source_info => p_event_source_info
757 ,p_valuation_method => p_valuation_method
758 ,p_event_type_code => p_event_type_code
759 ,p_event_date => l_event_date
760 ,p_event_status_code => p_event_status_code
761 ,p_process_status_code => C_INTERNAL_UNPROCESSED
762 ,p_event_number => p_event_number
763 ,p_transaction_date => p_transaction_date
764 ,p_reference_info => p_reference_info
765 ,p_budgetary_control_flag => p_budgetary_control_flag);
766 ELSIF NVL(g_transaction_number,L_CONSTANT) <>
767 NVL(p_event_source_info.transaction_number,L_CONSTANT) THEN
768 update_entity_trx_number
769 (p_transaction_number => p_event_source_info.transaction_number);
770
771 l_return_id:=add_entity_event
772 (p_entity_id => g_entity_id
773 ,p_application_id => p_event_source_info.application_id
774 ,p_ledger_id => p_event_source_info.ledger_id
775 ,p_legal_entity_id => p_event_source_info.legal_entity_id
776 ,p_event_type_code => p_event_type_code
777 ,p_event_date => l_event_date
778 ,p_event_status_code => p_event_status_code
779 ,p_process_status_code => C_INTERNAL_UNPROCESSED
780 ,p_event_number => p_event_number
781 ,p_transaction_date => p_transaction_date
782 ,p_reference_info => p_reference_info
783 ,p_budgetary_control_flag => p_budgetary_control_flag);
784 ELSE
785 l_return_id:=add_entity_event
786 (p_entity_id => g_entity_id
787 ,p_application_id => p_event_source_info.application_id
788 ,p_ledger_id => p_event_source_info.ledger_id
789 ,p_legal_entity_id => p_event_source_info.legal_entity_id
790 ,p_event_type_code => p_event_type_code
791 ,p_event_date => l_event_date
792 ,p_event_status_code => p_event_status_code
793 ,p_process_status_code => C_INTERNAL_UNPROCESSED
794 ,p_event_number => p_event_number
795 ,p_transaction_date => p_transaction_date
796 ,p_reference_info => p_reference_info
797 ,p_budgetary_control_flag => p_budgetary_control_flag);
798 END IF;
799 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
800 trace
801 (p_msg => 'end of procedure create_event'
802 ,p_level => C_LEVEL_PROCEDURE
803 ,p_module =>l_log_module);
804 trace
805 (p_msg => 'return value is:'||to_char(l_return_id)
806 ,p_level => C_LEVEL_PROCEDURE
807 ,p_module =>l_log_module);
808 END IF;
809 RETURN l_return_id;
810
811 EXCEPTION
812 WHEN xla_exceptions_pkg.application_exception THEN
813 ROLLBACK to SAVEPOINT before_event_creation;
814 RAISE;
815 WHEN OTHERS THEN
816 ROLLBACK to SAVEPOINT before_event_creation;
817 xla_exceptions_pkg.raise_message
818 (p_location => 'xla_events_pkg.create_event (fn)');
819 END create_event;
820
821
822 --=============================================================================
823 --
824 -- This API is specific for MANUAL events. Bug # 2899700.
825 --
826 --=============================================================================
827
828 FUNCTION create_manual_event
829 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
830 ,p_event_type_code IN VARCHAR2
831 ,p_event_date IN DATE
832 ,p_event_status_code IN VARCHAR2
833 ,p_process_status_code IN VARCHAR2
834 ,p_event_number IN INTEGER DEFAULT NULL
835 ,p_transaction_date IN DATE DEFAULT NULL
836 ,p_reference_info IN xla_events_pub_pkg.t_event_reference_info DEFAULT NULL
837 ,p_budgetary_control_flag IN VARCHAR2)
838 RETURN INTEGER IS
839 l_event_date DATE;
840 L_CONSTANT CONSTANT VARCHAR2(30) := '##UNDEFINED##'; --chr(12);
841 l_log_module VARCHAR2(240);
842 l_return_id INTEGER;
843 BEGIN
844 IF g_log_enabled THEN
845 l_log_module := C_DEFAULT_MODULE||'.create_manual_event';
846 END IF;
847 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
848 trace
849 (p_msg => 'BEGIN of procedure create_manual_event'
850 ,p_level => C_LEVEL_PROCEDURE
851 ,p_module =>l_log_module);
852 trace
853 (p_msg => 'source_application_id = '||
854 p_event_source_info.source_application_id
855 ,p_level => C_LEVEL_PROCEDURE
856 ,p_module =>l_log_module);
857 trace
858 (p_msg => 'application_id = '||p_event_source_info.application_id
859 ,p_level => C_LEVEL_PROCEDURE
860 ,p_module =>l_log_module);
861 trace
862 (p_msg => 'legal_entity_id = '||
863 p_event_source_info.legal_entity_id
864 ,p_level => C_LEVEL_PROCEDURE
865 ,p_module =>l_log_module);
866 trace
867 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
868 ,p_level => C_LEVEL_PROCEDURE
869 ,p_module =>l_log_module);
870 trace
871 (p_msg => 'entity_type_code = '||
872 p_event_source_info.entity_type_code
873 ,p_level => C_LEVEL_PROCEDURE
874 ,p_module =>l_log_module);
875 trace
876 (p_msg => 'transaction_number = '||
877 p_event_source_info.transaction_number
878 ,p_level => C_LEVEL_PROCEDURE
879 ,p_module =>l_log_module);
880 trace
881 (p_msg => 'source_id_int_1 = '||
882 p_event_source_info.source_id_int_1
883 ,p_level => C_LEVEL_PROCEDURE
884 ,p_module =>l_log_module);
885 trace
886 (p_msg => 'source_id_int_2 = '||
887 p_event_source_info.source_id_int_2
888 ,p_level => C_LEVEL_PROCEDURE
889 ,p_module =>l_log_module);
890 trace
891 (p_msg => 'source_id_int_3 = '||
892 p_event_source_info.source_id_int_3
893 ,p_level => C_LEVEL_PROCEDURE
894 ,p_module =>l_log_module);
895 trace
896 (p_msg => 'source_id_int_4 = '||
897 p_event_source_info.source_id_int_4
898 ,p_level => C_LEVEL_PROCEDURE
899 ,p_module =>l_log_module);
900 trace
901 (p_msg => 'source_id_char_1 = '||
902 p_event_source_info.source_id_char_1
903 ,p_level => C_LEVEL_PROCEDURE
904 ,p_module =>l_log_module);
905 trace
906 (p_msg => 'source_id_char_2 = '||
907 p_event_source_info.source_id_char_2
908 ,p_level => C_LEVEL_PROCEDURE
909 ,p_module =>l_log_module);
910 trace
911 (p_msg => 'source_id_char_3 = '||
912 p_event_source_info.source_id_char_3
913 ,p_level => C_LEVEL_PROCEDURE
914 ,p_module =>l_log_module);
915 trace
916 (p_msg => 'source_id_char_4 = '||
917 p_event_source_info.source_id_char_4
918 ,p_level => C_LEVEL_PROCEDURE
919 ,p_module =>l_log_module);
920 trace
921 (p_msg => 'p_event_type_code = '||p_event_type_code
922 ,p_level => C_LEVEL_PROCEDURE
923 ,p_module =>l_log_module);
924 trace
925 (p_msg => 'p_event_date = '||p_event_date
926 ,p_level => C_LEVEL_PROCEDURE
927 ,p_module =>l_log_module);
928 trace
929 (p_msg => 'p_event_status_code = '||p_event_status_code
930 ,p_level => C_LEVEL_PROCEDURE
931 ,p_module =>l_log_module);
932 trace
933 (p_msg => 'p_process_status_code = '||p_process_status_code
934 ,p_level => C_LEVEL_PROCEDURE
935 ,p_module =>l_log_module);
936 trace
937 (p_msg => 'p_event_number = '||p_event_number
938 ,p_level => C_LEVEL_PROCEDURE
939 ,p_module =>l_log_module);
940 trace
941 (p_msg => 'p_budgetary_control_flag = '||p_budgetary_control_flag
942 ,p_level => C_LEVEL_PROCEDURE
943 ,p_module =>l_log_module);
944 trace
945 (p_msg => 'security_id_int_1 = '||
946 xla_events_pub_pkg.g_security.security_id_int_1
947 ,p_level => C_LEVEL_PROCEDURE
948 ,p_module =>l_log_module);
949 trace
950 (p_msg => 'security_id_int_2 = '||
951 xla_events_pub_pkg.g_security.security_id_int_2
952 ,p_level => C_LEVEL_PROCEDURE
953 ,p_module =>l_log_module);
954 trace
955 (p_msg => 'security_id_int_3 = '||
956 xla_events_pub_pkg.g_security.security_id_int_3
957 ,p_level => C_LEVEL_PROCEDURE
958 ,p_module =>l_log_module);
959 trace
960 (p_msg => 'security_id_char_1 = '||
961 xla_events_pub_pkg.g_security.security_id_char_1
962 ,p_level => C_LEVEL_PROCEDURE
963 ,p_module =>l_log_module);
964 trace
965 (p_msg => 'security_id_char_2 = '||
966 xla_events_pub_pkg.g_security.security_id_char_2
967 ,p_level => C_LEVEL_PROCEDURE
968 ,p_module =>l_log_module);
969 trace
970 (p_msg => 'security_id_char_3 = '||
971 xla_events_pub_pkg.g_security.security_id_char_3
972 ,p_level => C_LEVEL_PROCEDURE
973 ,p_module =>l_log_module);
974 END IF;
975
976 SAVEPOINT before_event_creation;
977 g_action := C_EVENT_CREATE;
978
979 ----------------------------------------------------------------------------
980 -- Following sets the Security Context for the execution. This enables the
981 -- event API to respect the transaction security.
982 ----------------------------------------------------------------------------
983 xla_security_pkg.set_security_context(p_event_source_info.application_id);
984
985 ----------------------------------------------------------------------------
986 -- check to see the API is not called for regular events
987 ----------------------------------------------------------------------------
988 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
989 g_context := C_MANUAL_EVENT_CONTEXT;
990 ELSE
991 xla_exceptions_pkg.raise_message
992 (p_appli_s_name => 'XLA'
993 ,p_msg_name => 'XLA_COMMON_ERROR'
994 ,p_token_1 => 'ERROR'
995 ,p_value_1 => 'For REGULAR events this API cannot be called'
996 ,p_token_2 => 'LOCATION'
997 ,p_value_2 => 'xla_events_pkg.get_array_event_info (fn)');
998 END IF;
999
1000 ----------------------------------------------------------------------------
1001 -- perform specific validations for 'creating events'
1002 ----------------------------------------------------------------------------
1003 IF p_event_type_code IS NULL THEN
1004 xla_exceptions_pkg.raise_message
1005 (p_appli_s_name => 'XLA'
1006 ,p_msg_name => 'XLA_COMMON_ERROR'
1007 ,p_token_1 => 'ERROR'
1008 ,p_value_1 =>
1009 'Event Type Code has an invalid value. It cannot have a NULL value.'
1010 ,p_token_2 => 'LOCATION'
1011 ,p_value_2 => 'xla_events_pkg.create_manual_event');
1012 END IF;
1013 IF p_event_date IS NULL THEN
1014 xla_exceptions_pkg.raise_message
1015 (p_appli_s_name => 'XLA'
1016 ,p_msg_name => 'XLA_COMMON_ERROR'
1017 ,p_token_1 => 'ERROR'
1018 ,p_value_1 => 'Event Date cannot have a NULL value.'
1019 ,p_token_2 => 'LOCATION'
1020 ,p_value_2 => 'xla_events_pkg.create_manual_event');
1021 END IF;
1022 IF p_event_status_code IS NULL THEN
1023 xla_exceptions_pkg.raise_message
1024 (p_appli_s_name => 'XLA'
1025 ,p_msg_name => 'XLA_COMMON_ERROR'
1026 ,p_token_1 => 'ERROR'
1027 ,p_value_1 => 'Event Status Code cannot have a NULL value.'
1028 ,p_token_2 => 'LOCATION'
1029 ,p_value_2 => 'xla_events_pkg.create_manual_event');
1030 END IF;
1031 IF p_process_status_code IS NULL THEN
1032 xla_exceptions_pkg.raise_message
1033 (p_appli_s_name => 'XLA'
1034 ,p_msg_name => 'XLA_COMMON_ERROR'
1035 ,p_token_1 => 'ERROR'
1036 ,p_value_1 => 'Process Status Code cannot have a NULL value.'
1037 ,p_token_2 => 'LOCATION'
1038 ,p_value_2 => 'xla_events_pkg.create_manual_event');
1039 END IF;
1040
1041 ----------------------------------------------------------------------------
1042 -- truncate date
1043 ----------------------------------------------------------------------------
1044 l_event_date := TRUNC(p_event_date);
1045
1046 ----------------------------------------------------------------------------
1047 -- Validate parameters
1048 ----------------------------------------------------------------------------
1049 validate_params
1050 (p_source_info => p_event_source_info
1051 ,p_event_type_code => p_event_type_code
1052 ,p_event_status_code => p_event_status_code
1053 ,p_process_status_code => p_process_status_code);
1054
1055 ----------------------------------------------------------------------------
1056 -- Get document PK.
1057 ----------------------------------------------------------------------------
1058 cache_entity_info
1059 (p_source_info => p_event_source_info
1060 ,p_valuation_method => NULL
1061 ,p_event_id => NULL);
1062
1063 ----------------------------------------------------------------------------
1064 -- If the PK is NULL, create an entity as well as the event. Otherwise,
1065 -- add a new event to the entity.
1066 ----------------------------------------------------------------------------
1067 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1068 trace
1069 (p_msg => 'g_entity_id = '||g_entity_id
1070 ,p_level => C_LEVEL_STATEMENT
1071 ,p_module =>l_log_module);
1072 END IF;
1073
1074 IF g_entity_id IS NULL THEN
1075 l_return_id:=create_entity_event
1076 (p_event_source_info => p_event_source_info
1077 ,p_valuation_method => NULL
1078 ,p_event_type_code => p_event_type_code
1079 ,p_event_date => l_event_date
1080 ,p_event_status_code => p_event_status_code
1081 ,p_process_status_code => p_process_status_code
1082 ,p_event_number => p_event_number
1083 ,p_transaction_date => p_transaction_date
1084 ,p_reference_info => p_reference_info
1085 ,p_budgetary_control_flag => p_budgetary_control_flag);
1086 ELSIF NVL(g_transaction_number,L_CONSTANT) <>
1087 NVL(p_event_source_info.transaction_number,L_CONSTANT) THEN
1088 update_entity_trx_number
1089 (p_transaction_number => p_event_source_info.transaction_number);
1090
1091 l_return_id:=add_entity_event
1092 (p_entity_id => g_entity_id
1093 ,p_application_id => p_event_source_info.application_id
1094 ,p_ledger_id => p_event_source_info.ledger_id
1095 ,p_legal_entity_id => p_event_source_info.legal_entity_id
1096 ,p_event_type_code => p_event_type_code
1097 ,p_event_date => l_event_date
1098 ,p_event_status_code => p_event_status_code
1099 ,p_process_status_code => p_process_status_code
1100 ,p_event_number => p_event_number
1101 ,p_transaction_date => p_transaction_date
1102 ,p_reference_info => p_reference_info
1103 ,p_budgetary_control_flag => p_budgetary_control_flag);
1104 ELSE
1105 l_return_id:=add_entity_event
1106 (p_entity_id => g_entity_id
1107 ,p_application_id => p_event_source_info.application_id
1108 ,p_ledger_id => p_event_source_info.ledger_id
1109 ,p_legal_entity_id => p_event_source_info.legal_entity_id
1110 ,p_event_type_code => p_event_type_code
1111 ,p_event_date => l_event_date
1112 ,p_event_status_code => p_event_status_code
1113 ,p_process_status_code => p_process_status_code
1114 ,p_event_number => p_event_number
1115 ,p_transaction_date => p_transaction_date
1116 ,p_reference_info => p_reference_info
1117 ,p_budgetary_control_flag => p_budgetary_control_flag);
1118 END IF;
1119 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1120 trace
1121 (p_msg => 'end of procedure create_manual_event'
1122 ,p_level => C_LEVEL_PROCEDURE
1123 ,p_module =>l_log_module);
1124 trace
1125 (p_msg => 'return value is:'||to_char(l_return_id)
1126 ,p_level => C_LEVEL_PROCEDURE
1127 ,p_module =>l_log_module);
1128 END IF;
1129 RETURN l_return_id;
1130 EXCEPTION
1131 WHEN xla_exceptions_pkg.application_exception THEN
1132 ROLLBACK to SAVEPOINT before_event_creation;
1133 RAISE;
1134 WHEN OTHERS THEN
1135 ROLLBACK to SAVEPOINT before_event_creation;
1136 xla_exceptions_pkg.raise_message
1137 (p_location => 'xla_events_pkg.create_manual_event (fn)');
1138 END create_manual_event;
1139
1140
1141
1142 --=============================================================================
1143 --
1144 -- For MANUAL events this API cannot be called.
1145 --
1146 --=============================================================================
1147
1148 PROCEDURE update_event_status
1149 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
1150 ,p_valuation_method IN VARCHAR2
1151 ,p_event_class_code IN VARCHAR2 DEFAULT NULL
1152 ,p_event_type_code IN VARCHAR2 DEFAULT NULL
1153 ,p_event_date IN DATE DEFAULT NULL
1154 ,p_event_status_code IN VARCHAR2) IS
1155 l_event_date DATE;
1156 l_array_events t_number_tbl;
1157 l_array_event_status t_event_status_tbl;
1158 l_array_on_hold_flag t_on_hold_flag_tbl;
1159 l_temp_event_number xla_events.event_number%type;
1160 l_array_event_number t_event_number_tbl;
1161 l_log_module VARCHAR2(240);
1162 BEGIN
1163 IF g_log_enabled THEN
1164 l_log_module := C_DEFAULT_MODULE||'.update_event_status';
1165 END IF;
1166 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1167 trace
1168 (p_msg => 'BEGIN of procedure update_event_status'
1169 ,p_level => C_LEVEL_PROCEDURE
1170 ,p_module =>l_log_module);
1171 trace
1172 (p_msg => 'source_application_id = '||
1173 p_event_source_info.source_application_id
1174 ,p_level => C_LEVEL_PROCEDURE
1175 ,p_module =>l_log_module);
1176 trace
1177 (p_msg => 'application_id = '||p_event_source_info.application_id
1178 ,p_level => C_LEVEL_PROCEDURE
1179 ,p_module =>l_log_module);
1180 trace
1181 (p_msg => 'legal_entity_id = '||
1182 p_event_source_info.legal_entity_id
1183 ,p_level => C_LEVEL_PROCEDURE
1184 ,p_module =>l_log_module);
1185 trace
1186 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
1187 ,p_level => C_LEVEL_PROCEDURE
1188 ,p_module =>l_log_module);
1189 trace
1190 (p_msg => 'entity_type_code = '||
1191 p_event_source_info.entity_type_code
1192 ,p_level => C_LEVEL_PROCEDURE
1193 ,p_module =>l_log_module);
1194 trace
1195 (p_msg => 'transaction_number = '||
1196 p_event_source_info.transaction_number
1197 ,p_level => C_LEVEL_PROCEDURE
1198 ,p_module =>l_log_module);
1199 trace
1200 (p_msg => 'source_id_int_1 = '||
1201 p_event_source_info.source_id_int_1
1202 ,p_level => C_LEVEL_PROCEDURE
1203 ,p_module =>l_log_module);
1204 trace
1205 (p_msg => 'source_id_int_2 = '||
1206 p_event_source_info.source_id_int_2
1207 ,p_level => C_LEVEL_PROCEDURE
1208 ,p_module =>l_log_module);
1209 trace
1210 (p_msg => 'source_id_int_3 = '||
1211 p_event_source_info.source_id_int_3
1212 ,p_level => C_LEVEL_PROCEDURE
1213 ,p_module =>l_log_module);
1214 trace
1215 (p_msg => 'source_id_int_4 = '||
1216 p_event_source_info.source_id_int_4
1217 ,p_level => C_LEVEL_PROCEDURE
1218 ,p_module =>l_log_module);
1219 trace
1220 (p_msg => 'source_id_char_1 = '||
1221 p_event_source_info.source_id_char_1
1222 ,p_level => C_LEVEL_PROCEDURE
1223 ,p_module =>l_log_module);
1224 trace
1225 (p_msg => 'source_id_char_2 = '||
1226 p_event_source_info.source_id_char_2
1227 ,p_level => C_LEVEL_PROCEDURE
1228 ,p_module =>l_log_module);
1229 trace
1230 (p_msg => 'source_id_char_3 = '||
1231 p_event_source_info.source_id_char_3
1232 ,p_level => C_LEVEL_PROCEDURE
1233 ,p_module =>l_log_module);
1234 trace
1235 (p_msg => 'source_id_char_4 = '||
1236 p_event_source_info.source_id_char_4
1237 ,p_level => C_LEVEL_PROCEDURE
1238 ,p_module =>l_log_module);
1239 trace
1240 (p_msg => 'p_event_class_code = '||p_event_class_code
1241 ,p_level => C_LEVEL_PROCEDURE
1242 ,p_module =>l_log_module);
1243 trace
1244 (p_msg => 'p_event_type_code = '||p_event_type_code
1245 ,p_level => C_LEVEL_PROCEDURE
1246 ,p_module =>l_log_module);
1247 trace
1248 (p_msg => 'p_event_date = '||p_event_date
1249 ,p_level => C_LEVEL_PROCEDURE
1250 ,p_module =>l_log_module);
1251 trace
1252 (p_msg => 'p_event_status_code = '||p_event_status_code
1253 ,p_level => C_LEVEL_PROCEDURE
1254 ,p_module =>l_log_module);
1255 trace
1256 (p_msg => 'security_id_int_1 = '||
1257 xla_events_pub_pkg.g_security.security_id_int_1
1258 ,p_level => C_LEVEL_PROCEDURE
1259 ,p_module =>l_log_module);
1260 trace
1261 (p_msg => 'security_id_int_2 = '||
1262 xla_events_pub_pkg.g_security.security_id_int_2
1263 ,p_level => C_LEVEL_PROCEDURE
1264 ,p_module =>l_log_module);
1265 trace
1266 (p_msg => 'security_id_int_3 = '||
1267 xla_events_pub_pkg.g_security.security_id_int_3
1268 ,p_level => C_LEVEL_PROCEDURE
1269 ,p_module =>l_log_module);
1270 trace
1271 (p_msg => 'security_id_char_1 = '||
1272 xla_events_pub_pkg.g_security.security_id_char_1
1273 ,p_level => C_LEVEL_PROCEDURE
1274 ,p_module =>l_log_module);
1275 trace
1276 (p_msg => 'security_id_char_2 = '||
1277 xla_events_pub_pkg.g_security.security_id_char_2
1278 ,p_level => C_LEVEL_PROCEDURE
1279 ,p_module =>l_log_module);
1280 trace
1281 (p_msg => 'security_id_char_3 = '||
1282 xla_events_pub_pkg.g_security.security_id_char_3
1283 ,p_level => C_LEVEL_PROCEDURE
1284 ,p_module =>l_log_module);
1285 trace
1286 (p_msg => 'valuation_method = '||p_valuation_method
1287 ,p_level => C_LEVEL_PROCEDURE
1288 ,p_module =>l_log_module);
1289
1290 END IF;
1291
1292 SAVEPOINT before_event_update;
1293 g_action := C_EVENT_UPDATE;
1294
1295 ----------------------------------------------------------------------------
1296 -- Following sets the Security Context for the execution. This enables the
1297 -- event API to respect the transaction security.
1298 ----------------------------------------------------------------------------
1299 xla_security_pkg.set_security_context(p_event_source_info.application_id);
1300
1301 ----------------------------------------------------------------------------
1302 -- check to see the API is not called for manual events
1303 ----------------------------------------------------------------------------
1304 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
1305 xla_exceptions_pkg.raise_message
1306 (p_appli_s_name => 'XLA'
1307 ,p_msg_name => 'XLA_COMMON_ERROR'
1308 ,p_token_1 => 'ERROR'
1309 ,p_value_1 => 'For MANUAL events this API cannot be called'
1310 ,p_token_2 => 'LOCATION'
1311 ,p_value_2 => 'xla_events_pkg.get_array_event_info (fn)');
1312 ELSE
1313 g_context := C_REGULAR_EVENT_CONTEXT;
1314 END IF;
1315
1316 ----------------------------------------------------------------------------
1317 -- perform validations specific to 'updating event's status'
1318 ----------------------------------------------------------------------------
1319 IF p_event_status_code IS NULL THEN
1320 xla_exceptions_pkg.raise_message
1321 (p_appli_s_name => 'XLA'
1322 ,p_msg_name => 'XLA_COMMON_ERROR'
1323 ,p_token_1 => 'ERROR'
1324 ,p_value_1 => 'Event Status Code cannot have a NULL value.'
1325 ,p_token_2 => 'LOCATION'
1326 ,p_value_2 => 'xla_events_pkg.update_event_status');
1327 END IF;
1328
1329 ----------------------------------------------------------------------------
1330 -- truncate date
1331 ----------------------------------------------------------------------------
1332 l_event_date := TRUNC(p_event_date);
1333
1334 ----------------------------------------------------------------------------
1335 -- Validate parameters
1336 ----------------------------------------------------------------------------
1337 validate_params
1338 (p_source_info => p_event_source_info
1339 ,p_event_class_code => p_event_class_code
1340 ,p_event_type_code => p_event_type_code
1341 ,p_event_status_code => p_event_status_code
1342 ,p_process_status_code => C_INTERNAL_UNPROCESSED);
1343
1344 ----------------------------------------------------------------------------
1345 -- Get document PK
1346 ----------------------------------------------------------------------------
1347 cache_entity_info
1348 (p_source_info => p_event_source_info
1349 ,p_valuation_method => p_valuation_method
1350 ,p_event_id => NULL);
1351
1352 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1353 trace
1354 (p_msg => 'gapless_flag = '||g_gapless_flag
1355 ,p_level => C_LEVEL_STATEMENT
1356 ,p_module =>l_log_module);
1357 trace
1358 (p_msg => 'g_entity_id = '||to_char(g_entity_id)
1359 ,p_level => C_LEVEL_STATEMENT
1360 ,p_module =>l_log_module);
1361 END IF;
1362
1363 ----------------------------------------------------------------------------
1364 -- Check entity existency
1365 ----------------------------------------------------------------------------
1366 IF g_entity_id IS NULL THEN
1367 xla_exceptions_pkg.raise_message
1368 (p_appli_s_name => 'XLA'
1369 ,p_msg_name => 'XLA_COMMON_ERROR'
1370 ,p_token_1 => 'ERROR'
1371 ,p_value_1 => 'No event exists for the document represented '||
1372 'by the given source information.'
1373 ,p_token_2 => 'LOCATION'
1374 ,p_value_2 => 'xla_events_pkg.update_event_status');
1375 END IF;
1376
1377 ----------------------------------------------------------------------------
1378 -- Fetching event ids for the events that are going to be updated
1379 ----------------------------------------------------------------------------
1380 if(g_gapless_flag='N') then
1381 SELECT event_id BULK COLLECT
1382 INTO l_array_events
1383 FROM xla_events
1384 WHERE event_status_code NOT IN (xla_events_pub_pkg.C_EVENT_PROCESSED,
1385 xla_events_pub_pkg.C_EVENT_NOACTION) -- Bug 9197871
1386 AND event_date = NVL(l_event_date, event_date)
1387 AND event_type_code = NVL(p_event_type_code, event_type_code)
1388 AND entity_id = g_entity_id
1389 AND application_id = g_application_id -- 8967771
1390 AND event_type_code IN
1391 (SELECT event_type_code
1392 FROM xla_event_types_b
1393 WHERE application_id = g_application_id
1394 AND entity_code = g_entity_type_code
1395 AND event_class_code = NVL(p_event_class_code,
1396 event_class_code));
1397 else
1398 SELECT event_id,
1399 event_status_code,
1400 on_hold_flag,
1401 event_number BULK COLLECT
1402 INTO l_array_events,
1403 l_array_event_status,
1404 l_array_on_hold_flag,
1405 l_array_event_number
1406 FROM xla_events
1407 WHERE event_status_code NOT IN (xla_events_pub_pkg.C_EVENT_PROCESSED,
1408 xla_events_pub_pkg.C_EVENT_NOACTION) -- Bug 9197871
1409 AND event_date = NVL(l_event_date, event_date)
1410 AND event_type_code = NVL(p_event_type_code, event_type_code)
1411 AND entity_id = g_entity_id
1412 AND application_id = g_application_id -- 8967771
1413 AND event_type_code IN
1414 (SELECT event_type_code
1415 FROM xla_event_types_b
1416 WHERE application_id = g_application_id
1417 AND entity_code = g_entity_type_code
1418 AND event_class_code = NVL(p_event_class_code,
1419 event_class_code))
1420 Order by event_number;
1421 end if;
1422 ----------------------------------------------------------------------------
1423 -- Call routine to delete errors/JEs related to the event bug # 2701681
1424 ----------------------------------------------------------------------------
1425
1426 FOR i IN 1..l_array_events.COUNT LOOP
1427 xla_journal_entries_pkg.delete_journal_entries
1428 (p_event_id => l_array_events(i)
1429 ,p_application_id => g_application_id);
1430 END LOOP;
1431
1432 ----------------------------------------------------------------------------
1433 -- Actual status update
1434 ----------------------------------------------------------------------------
1435 FORAll i IN 1..l_array_events.COUNT
1436 UPDATE xla_events
1437 SET event_status_code = p_event_status_code
1438 ,process_status_code = C_INTERNAL_UNPROCESSED
1439 ,last_update_date = sysdate
1440 ,last_updated_by = xla_environment_pkg.g_usr_id
1441 ,last_update_login = xla_environment_pkg.g_login_id
1442 ,program_update_date = sysdate
1443 ,program_application_id = xla_environment_pkg.g_prog_appl_id
1444 ,program_id = xla_environment_pkg.g_prog_id
1445 ,request_id = xla_environment_pkg.g_Req_Id
1446 WHERE event_id = l_array_events(i)
1447 AND application_id = g_application_id -- 8967771
1448 ;
1449 if(g_gapless_flag='Y') then
1450
1451 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1452 trace
1453 (p_msg => 'p_event_status_code:'||p_event_status_code
1454 ,p_level => C_LEVEL_STATEMENT
1455 ,p_module =>l_log_module);
1456 END IF;
1457
1458 if(p_event_status_code='I') then
1459 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1460 trace
1461 (p_msg => 'l_array_event_status(1):'||
1462 l_array_event_status(1)
1463 ,p_level => C_LEVEL_STATEMENT
1464 ,p_module =>l_log_module);
1465 trace
1466 (p_msg => ' l_array_on_hold_flag(1):'||
1467 l_array_on_hold_flag(1)
1468 ,p_level => C_LEVEL_STATEMENT
1469 ,p_module =>l_log_module);
1470 end if;
1471 if(l_array_event_status(1)<>'I' and l_array_on_hold_flag(1)='N') then
1472 update xla_events
1473 set on_hold_flag='Y'
1474 where entity_id=g_entity_id
1475 and event_number >l_array_event_number(1)
1476 and on_hold_flag='N'
1477 AND application_id = g_application_id -- 8967771
1478 ;
1479 end if;
1480 else
1481 FOR i IN 1..l_array_events.COUNT loop
1482 if(l_array_on_hold_flag(i)='Y') then
1483 exit;
1484 elsif (l_array_event_status(i)='I') then
1485 -- a gap is filled
1486 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1487 trace
1488 (p_msg => 'l_array_event_status(i) is I, i is:'||
1489 to_char(i)
1490 ,p_level => C_LEVEL_STATEMENT
1491 ,p_module =>l_log_module);
1492 trace
1493 (p_msg => ' l_array_event_number(i):'||
1494 to_char(l_array_event_number(i))
1495 ,p_level => C_LEVEL_STATEMENT
1496 ,p_module =>l_log_module);
1497 end if;
1498
1499 SELECT event_status_code, event_number BULK COLLECT
1500 INTO g_gapless_array_event_status, g_gapless_event_number
1501 FROM xla_events
1502 Where entity_id = g_entity_id
1503 and event_number>l_array_event_number(i)
1504 AND application_id = g_application_id -- 8967771
1505 Order by event_number;
1506
1507 l_temp_event_number:=l_array_event_number(i)+1;
1508 For j in 1..g_gapless_event_number.COUNT loop
1509 if(g_gapless_event_number(j)=l_temp_event_number
1510 and g_gapless_array_event_status(j)<>'I') then
1511 l_temp_event_number:=l_temp_event_number+1;
1512 else
1513 exit;
1514 end if;
1515 end loop;
1516 --l_temp_event_number is the next gap
1517 -- update the on_hold_flag of event between l_array_event_number(i)
1518 -- and --l_temp_event_number+1
1519 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1520 trace
1521 (p_msg => 'l_temp_event_number:'||
1522 to_char(l_temp_event_number)
1523 ,p_level => C_LEVEL_STATEMENT
1524 ,p_module =>l_log_module);
1525 end if;
1526
1527 update xla_events
1528 set on_hold_flag='N'
1529 where entity_id=g_entity_id
1530 and event_number >l_array_event_number(i)
1531 and event_number <l_temp_event_number+1
1532 AND application_id = g_application_id -- 8967771
1533 ;
1534 exit;
1535 end if;
1536 end loop;
1537 end if;
1538 end if;
1539
1540 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1541 trace
1542 (p_msg => 'end of procedure update_event_status'
1543 ,p_level => C_LEVEL_PROCEDURE
1544 ,p_module =>l_log_module);
1545 end if;
1546 EXCEPTION
1547 WHEN xla_exceptions_pkg.application_exception THEN
1548 ROLLBACK to SAVEPOINT before_event_update;
1549 RAISE;
1550 WHEN OTHERS THEN
1551 ROLLBACK to SAVEPOINT before_event_update;
1552 xla_exceptions_pkg.raise_message
1553 (p_location => 'xla_events_pkg.update_event_status');
1554 END update_event_status;
1555
1556
1557 --=============================================================================
1558 --
1559 -- For MANUAL events this API cannot be called.
1560 --
1561 --=============================================================================
1562
1563 PROCEDURE update_event
1564 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
1565 ,p_valuation_method IN VARCHAR2
1566 ,p_event_id IN INTEGER
1567 ,p_event_type_code IN VARCHAR2 DEFAULT NULL
1568 ,p_event_date IN DATE DEFAULT NULL
1569 ,p_event_status_code IN VARCHAR2 DEFAULT NULL
1570 ,p_transaction_date IN DATE DEFAULT NULL
1571 ,p_event_number IN INTEGER DEFAULT NULL
1572 ,p_reference_info IN xla_events_pub_pkg.t_event_reference_info
1573 DEFAULT NULL
1574 ,p_overwrite_event_num IN VARCHAR2 DEFAULT 'N'
1575 ,p_overwrite_ref_info IN VARCHAR2 DEFAULT 'N') IS
1576 l_event_date DATE;
1577 l_process_status_code VARCHAR2(1);
1578 l_old_event_status_code xla_events.event_status_code%TYPE;
1579 l_old_on_hold_flag xla_events.on_hold_flag%TYPE;
1580 l_old_event_number xla_events.event_number%TYPE;
1581 l_event_status_code xla_events.event_status_code%TYPE;
1582 l_on_hold_flag xla_events.on_hold_flag%TYPE:='Y';
1583 l_temp_event_number xla_events.event_number%type;
1584 l_log_module VARCHAR2(240);
1585 BEGIN
1586 IF g_log_enabled THEN
1587 l_log_module := C_DEFAULT_MODULE||'.update_event';
1588 END IF;
1589 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1590 trace
1591 (p_msg => 'BEGIN of procedure update_event'
1592 ,p_level => C_LEVEL_PROCEDURE
1593 ,p_module =>l_log_module);
1594 trace
1595 (p_msg => 'source_application_id = '||
1596 p_event_source_info.source_application_id
1597 ,p_level => C_LEVEL_PROCEDURE
1598 ,p_module =>l_log_module);
1599 trace
1600 (p_msg => 'application_id = '||p_event_source_info.application_id
1601 ,p_level => C_LEVEL_PROCEDURE
1602 ,p_module =>l_log_module);
1603 trace
1604 (p_msg => 'legal_entity_id = '||
1605 p_event_source_info.legal_entity_id
1606 ,p_level => C_LEVEL_PROCEDURE
1607 ,p_module =>l_log_module);
1608 trace
1609 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
1610 ,p_level => C_LEVEL_PROCEDURE
1611 ,p_module =>l_log_module);
1612 trace
1613 (p_msg => 'entity_type_code = '||
1614 p_event_source_info.entity_type_code
1615 ,p_level => C_LEVEL_PROCEDURE
1616 ,p_module =>l_log_module);
1617 trace
1618 (p_msg => 'transaction_number = '||
1619 p_event_source_info.transaction_number
1620 ,p_level => C_LEVEL_PROCEDURE
1621 ,p_module =>l_log_module);
1622 trace
1623 (p_msg => 'source_id_int_1 = '||
1624 p_event_source_info.source_id_int_1
1625 ,p_level => C_LEVEL_PROCEDURE
1626 ,p_module =>l_log_module);
1627 trace
1628 (p_msg => 'source_id_int_2 = '||
1629 p_event_source_info.source_id_int_2
1630 ,p_level => C_LEVEL_PROCEDURE
1631 ,p_module =>l_log_module);
1632 trace
1633 (p_msg => 'source_id_int_3 = '||
1634 p_event_source_info.source_id_int_3
1635 ,p_level => C_LEVEL_PROCEDURE
1636 ,p_module =>l_log_module);
1637 trace
1638 (p_msg => 'source_id_int_4 = '||
1639 p_event_source_info.source_id_int_4
1640 ,p_level => C_LEVEL_PROCEDURE
1641 ,p_module =>l_log_module);
1642 trace
1643 (p_msg => 'source_id_char_1 = '||
1644 p_event_source_info.source_id_char_1
1645 ,p_level => C_LEVEL_PROCEDURE
1646 ,p_module =>l_log_module);
1647 trace
1648 (p_msg => 'source_id_char_2 = '||
1649 p_event_source_info.source_id_char_2
1650 ,p_level => C_LEVEL_PROCEDURE
1651 ,p_module =>l_log_module);
1652 trace
1653 (p_msg => 'source_id_char_3 = '||
1654 p_event_source_info.source_id_char_3
1655 ,p_level => C_LEVEL_PROCEDURE
1656 ,p_module =>l_log_module);
1657 trace
1658 (p_msg => 'source_id_char_4 = '||
1659 p_event_source_info.source_id_char_4
1660 ,p_level => C_LEVEL_PROCEDURE
1661 ,p_module =>l_log_module);
1662 trace
1663 (p_msg => 'p_event_id = '||p_event_id
1664 ,p_level => C_LEVEL_PROCEDURE
1665 ,p_module =>l_log_module);
1666 trace
1667 (p_msg => 'p_event_type_code = '||p_event_type_code
1668 ,p_level => C_LEVEL_PROCEDURE
1669 ,p_module =>l_log_module);
1670 trace
1671 (p_msg => 'p_event_date = '||p_event_date
1672 ,p_level => C_LEVEL_PROCEDURE
1673 ,p_module =>l_log_module);
1674 trace
1675 (p_msg => 'p_event_status_code = '||p_event_status_code
1676 ,p_level => C_LEVEL_PROCEDURE
1677 ,p_module =>l_log_module);
1678 trace
1679 (p_msg => 'p_event_number = '||p_event_number
1680 ,p_level => C_LEVEL_PROCEDURE
1681 ,p_module =>l_log_module);
1682 trace
1683 (p_msg => 'p_overwrite_event_num = '||p_overwrite_event_num
1684 ,p_level => C_LEVEL_PROCEDURE
1685 ,p_module =>l_log_module);
1686 trace
1687 (p_msg => 'p_overwrite_ref_info = '||p_overwrite_ref_info
1688 ,p_level => C_LEVEL_PROCEDURE
1689 ,p_module =>l_log_module);
1690 trace
1691 (p_msg => 'security_id_int_1 = '||
1692 xla_events_pub_pkg.g_security.security_id_int_1
1693 ,p_level => C_LEVEL_PROCEDURE
1694 ,p_module =>l_log_module);
1695 trace
1696 (p_msg => 'security_id_int_2 = '||
1697 xla_events_pub_pkg.g_security.security_id_int_2
1698 ,p_level => C_LEVEL_PROCEDURE
1699 ,p_module =>l_log_module);
1700 trace
1701 (p_msg => 'security_id_int_3 = '||
1702 xla_events_pub_pkg.g_security.security_id_int_3
1703 ,p_level => C_LEVEL_PROCEDURE
1704 ,p_module =>l_log_module);
1705 trace
1706 (p_msg => 'security_id_char_1 = '||
1707 xla_events_pub_pkg.g_security.security_id_char_1
1708 ,p_level => C_LEVEL_PROCEDURE
1709 ,p_module =>l_log_module);
1710 trace
1711 (p_msg => 'security_id_char_2 = '||
1712 xla_events_pub_pkg.g_security.security_id_char_2
1713 ,p_level => C_LEVEL_PROCEDURE
1714 ,p_module =>l_log_module);
1715 trace
1716 (p_msg => 'security_id_char_3 = '||
1717 xla_events_pub_pkg.g_security.security_id_char_3
1718 ,p_level => C_LEVEL_PROCEDURE
1719 ,p_module =>l_log_module);
1720 trace
1721 (p_msg => 'valuation_method = '||p_valuation_method
1722 ,p_level => C_LEVEL_PROCEDURE
1723 ,p_module =>l_log_module);
1724 END IF;
1725
1726 SAVEPOINT before_event_update;
1727 g_action := C_EVENT_UPDATE;
1728
1729 ----------------------------------------------------------------------------
1730 -- Following sets the Security Context for the execution. This enables the
1731 -- event API to respect the transaction security.
1732 ----------------------------------------------------------------------------
1733 xla_security_pkg.set_security_context(p_event_source_info.application_id);
1734
1735 ----------------------------------------------------------------------------
1736 -- check to see the API is not called for manual events
1737 ----------------------------------------------------------------------------
1738 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
1739 xla_exceptions_pkg.raise_message
1740 (p_appli_s_name => 'XLA'
1741 ,p_msg_name => 'XLA_COMMON_ERROR'
1742 ,p_token_1 => 'ERROR'
1743 ,p_value_1 => 'For MANUAL events this API cannot be called'
1744 ,p_token_2 => 'LOCATION'
1745 ,p_value_2 => 'xla_events_pkg.update_event');
1746 ELSE
1747 g_context := C_REGULAR_EVENT_CONTEXT;
1748 END IF;
1749
1750 ----------------------------------------------------------------------------
1751 -- perfrom validations specific to 'updating event'
1752 ----------------------------------------------------------------------------
1753 IF p_event_id IS NULL THEN
1754 xla_exceptions_pkg.raise_message
1755 (p_appli_s_name => 'XLA'
1756 ,p_msg_name => 'XLA_COMMON_ERROR'
1757 ,p_token_1 => 'ERROR'
1758 ,p_value_1 => 'Event ID cannot have a NULL value.'
1759 ,p_token_2 => 'LOCATION'
1760 ,p_value_2 => 'xla_events_pkg.update_event');
1761 END IF;
1762
1763
1764 IF p_event_status_code IS NOT NULL THEN
1765 l_process_status_code := C_INTERNAL_UNPROCESSED;
1766 END IF;
1767
1768 ----------------------------------------------------------------------------
1769 -- truncate date
1770 ----------------------------------------------------------------------------
1771 l_event_date := TRUNC(p_event_date);
1772
1773 ----------------------------------------------------------------------------
1774 -- Validate parameters
1775 ----------------------------------------------------------------------------
1776 validate_params
1777 (p_source_info => p_event_source_info
1778 ,p_event_type_code => p_event_type_code
1779 ,p_event_status_code => p_event_status_code
1780 ,p_process_status_code => l_process_status_code);
1781
1782 ----------------------------------------------------------------------------
1783 -- Get document PK
1784 ----------------------------------------------------------------------------
1785 cache_entity_info
1786 (p_source_info => p_event_source_info
1787 ,p_valuation_method => p_valuation_method
1788 ,p_event_id => p_event_id);
1789
1790 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1791 trace
1792 (p_msg => 'gapless_flag = '||g_gapless_flag
1793 ,p_level => C_LEVEL_STATEMENT
1794 ,p_module =>l_log_module);
1795 trace
1796 (p_msg => 'g_entity_id = '||to_char(g_entity_id)
1797 ,p_level => C_LEVEL_STATEMENT
1798 ,p_module =>l_log_module);
1799 trace
1800 (p_msg => 'p_overwrite_event_num:'||p_overwrite_event_num
1801 ,p_level => C_LEVEL_STATEMENT
1802 ,p_module =>l_log_module);
1803 trace
1804 (p_msg => 'p_event_number:'||to_char(p_event_number)
1805 ,p_level => C_LEVEL_STATEMENT
1806 ,p_module =>l_log_module);
1807 END IF;
1808
1809 ----------------------------------------------------------------------------
1810 -- Check entity existency
1811 ----------------------------------------------------------------------------
1812 IF g_entity_id IS NULL THEN
1813 xla_exceptions_pkg.raise_message
1814 (p_appli_s_name => 'XLA'
1815 ,p_msg_name => 'XLA_COMMON_ERROR'
1816 ,p_token_1 => 'ERROR'
1817 ,p_value_1 => 'No event exists for the document represented '||
1818 'by the given source information.'
1819 ,p_token_2 => 'LOCATION'
1820 ,p_value_2 => 'xla_events_pkg.update_event');
1821 END IF;
1822
1823 if(g_gapless_flag='Y' and
1824 (p_overwrite_event_num=C_YES and
1825 (p_event_number is null or p_event_number<1))) then
1826 xla_exceptions_pkg.raise_message
1827 (p_appli_s_name => 'XLA'
1828 ,p_msg_name => 'XLA_COMMON_ERROR'
1829 ,p_token_1 => 'ERROR'
1830 ,p_value_1 =>
1831 'The developer has to give the event number when change event number for gapless processing.'
1832 ,p_token_2 => 'LOCATION'
1833 ,p_value_2 => 'xla_events_pkg.update_event');
1834
1835 end if;
1836 ----------------------------------------------------------------------------
1837 -- Following statement make sure that when event type and/or event date
1838 -- is updated, it puts the internal status back to 'Unporcessed' which is
1839 -- used (in the following statement) to call delete journal entries.
1840 -- bug # 3111204
1841 -- For this the event_status_code is left untouched becuase that status
1842 -- could have 'U/I/N' values and we do not want to change that status unless
1843 -- it comes from the input.
1844 ----------------------------------------------------------------------------
1845 IF p_event_type_code IS NOT NULL OR p_event_date IS NOT NULL THEN
1846 l_process_status_code := C_INTERNAL_UNPROCESSED;
1847 END IF;
1848
1849 ----------------------------------------------------------------------------
1850 -- Call routine to delete errors/JEs related to the event bug # 2701681
1851 ----------------------------------------------------------------------------
1852 IF l_process_status_code = C_INTERNAL_UNPROCESSED THEN
1853 xla_journal_entries_pkg.delete_journal_entries
1854 (p_event_id => p_event_id
1855 ,p_application_id => g_application_id);
1856 END IF;
1857
1858 if(g_gapless_flag='Y' and (p_overwrite_event_num=C_YES
1859 or p_event_status_code is not null)) then
1860 -- the on-hold-flag will be affected
1861 begin
1862 select event_status_code, on_hold_flag, event_number
1863 into l_old_event_status_code, l_old_on_hold_flag, l_old_event_number
1864 from xla_events
1865 WHERE event_id = p_event_id
1866 AND entity_id = g_entity_id
1867 AND event_status_code <> xla_events_pub_pkg.C_EVENT_PROCESSED
1868 AND application_id = g_application_id -- 8967771
1869 ;
1870 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1871 trace
1872 (p_msg => 'l_old_event_status_code:'||l_old_event_status_code
1873 ,p_level => C_LEVEL_STATEMENT
1874 ,p_module =>l_log_module);
1875 trace
1876 (p_msg => 'l_old_event_number:'||to_char(l_old_event_number)
1877 ,p_level => C_LEVEL_STATEMENT
1878 ,p_module =>l_log_module);
1879 END IF;
1880
1881
1882 Exception
1883 WHEN OTHERS THEN
1884 xla_exceptions_pkg.raise_message
1885 (p_appli_s_name => 'XLA'
1886 ,p_msg_name => 'XLA_COMMON_ERROR'
1887 ,p_token_1 => 'ERROR'
1888 ,p_value_1 =>
1889 'Unable to perform UPDATE on the event. The event ('||p_event_id ||
1890 ') is either invalid or has been final accounted.'
1891 ,p_token_2 => 'LOCATION'
1892 ,p_value_2 => 'xla_events_pkg.update_event');
1893 END;
1894 END IF;
1895 ----------------------------------------------------------------------------
1896 -- Actual update
1897 ----------------------------------------------------------------------------
1898 UPDATE xla_events
1899 SET event_type_code = NVL(p_event_type_code , event_type_code)
1900 ,event_date = NVL(l_event_date , event_date)
1901 ,transaction_date = NVL(p_transaction_date , transaction_date)
1902 ,event_status_code = NVL(p_event_status_code, event_status_code)
1903 ,process_status_code = NVL(l_process_status_code,process_status_code)
1904 ,event_number = DECODE(p_overwrite_event_num,C_YES,
1905 NVL(p_event_number,g_max_event_number+1),event_number)
1906 ,reference_num_1 = DECODE(p_overwrite_ref_info,C_YES,
1907 p_reference_info.reference_num_1,reference_num_1)
1908 ,reference_num_2 = DECODE(p_overwrite_ref_info,C_YES,
1909 p_reference_info.reference_num_2,reference_num_2)
1910 ,reference_num_3 = DECODE(p_overwrite_ref_info,C_YES,
1911 p_reference_info.reference_num_3,reference_num_3)
1912 ,reference_num_4 = DECODE(p_overwrite_ref_info,C_YES,
1913 p_reference_info.reference_num_4,reference_num_4)
1914 ,reference_char_1 = DECODE(p_overwrite_ref_info,C_YES,
1915 p_reference_info.reference_char_1,reference_char_1)
1916 ,reference_char_2 = DECODE(p_overwrite_ref_info,C_YES,
1917 p_reference_info.reference_char_2,reference_char_2)
1918 ,reference_char_3 = DECODE(p_overwrite_ref_info,C_YES,
1919 p_reference_info.reference_char_3,reference_char_3)
1920 ,reference_char_4 = DECODE(p_overwrite_ref_info,C_YES,
1921 p_reference_info.reference_char_4,reference_char_4)
1922 ,reference_date_1 = DECODE(p_overwrite_ref_info,C_YES,
1923 p_reference_info.reference_date_1,reference_date_1)
1924 ,reference_date_2 = DECODE(p_overwrite_ref_info,C_YES,
1925 p_reference_info.reference_date_2,reference_date_2)
1926 ,reference_date_3 = DECODE(p_overwrite_ref_info,C_YES,
1927 p_reference_info.reference_date_3,reference_date_3)
1928 ,reference_date_4 = DECODE(p_overwrite_ref_info,C_YES,
1929 p_reference_info.reference_date_4,reference_date_4)
1930 ,last_update_date = sysdate
1931 ,last_updated_by = xla_environment_pkg.g_usr_id
1932 ,last_update_login = xla_environment_pkg.g_login_id
1933 ,program_update_date = sysdate
1934 ,program_application_id= xla_environment_pkg.g_prog_appl_id
1935 ,program_id = xla_environment_pkg.g_prog_id
1936 ,request_id = xla_environment_pkg.g_Req_Id
1937 WHERE event_id = p_event_id
1938 AND entity_id = g_entity_id
1939 AND event_status_code <> xla_events_pub_pkg.C_EVENT_PROCESSED
1940 AND application_id = g_application_id -- 8967771
1941 ;
1942
1943 IF SQL%ROWCOUNT <> 1 THEN
1944 xla_exceptions_pkg.raise_message
1945 (p_appli_s_name => 'XLA'
1946 ,p_msg_name => 'XLA_COMMON_ERROR'
1947 ,p_token_1 => 'ERROR'
1948 ,p_value_1 =>
1949 'Unable to perform UPDATE on the event. The event ('||p_event_id ||
1950 ') is either invalid or has been final accounted.'
1951 ,p_token_2 => 'LOCATION'
1952 ,p_value_2 => 'xla_events_pkg.update_event');
1953 END IF;
1954
1955 if(g_gapless_flag='Y' and
1956 ((p_overwrite_event_num=C_YES
1957 and l_old_event_number <>p_event_number)
1958 or (p_event_status_code is not null
1959 and p_event_status_code<>l_old_event_status_code))) then
1960 -- there are 5 cases need to be considered:
1961 -- 1. status_code change to 'I'
1962 -- 2. status_code change from 'I' to others
1963 -- 3. event_number changed
1964 -- 4. 1 and 3
1965 -- 5. 2 and 3
1966 if(p_overwrite_event_num=C_YES and l_old_event_number <>p_event_number)then
1967 if(l_old_event_number<p_event_number) then
1968 if(l_old_on_hold_flag='N') then
1969 if(l_old_event_status_code<>'I') then
1970 update xla_events
1971 set on_hold_flag='Y'
1972 where entity_id=g_entity_id
1973 and event_status_code<> xla_events_pub_pkg.C_EVENT_PROCESSED
1974 and event_number>l_old_event_number
1975 AND application_id = g_application_id -- 8967771
1976 ;
1977 else
1978 update xla_events
1979 set on_hold_flag='Y'
1980 where entity_id=g_entity_id
1981 and event_id=p_event_id
1982 AND application_id = g_application_id -- 8967771
1983 ;
1984 end if;
1985 end if;
1986 else
1987 -- in this case, all the event > l_old_event_number must be on hold
1988 -- already and they will be still on hold event
1989 -- between l_old_event_number and p_event_number could be affected.
1990 begin
1991 select event_status_code, on_hold_flag
1992 into l_event_status_code, l_on_hold_flag
1993 from xla_events
1994 where entity_id=g_entity_id
1995 and event_number=p_event_number-1
1996 AND application_id = g_application_id -- 8967771
1997 ;
1998 exception
1999 when NO_DATA_FOUND then
2000 if(p_event_number=1) then
2001 l_on_hold_flag:='N';
2002 l_event_status_code:='U';
2003 else
2004 l_on_hold_flag:='Y';
2005 end if;
2006 end;
2007 if(l_on_hold_flag='N' and l_event_status_code<>'I') then
2008 if(nvl(p_event_status_code, l_old_event_status_code)='I') then
2009 update xla_events
2010 set on_hold_flag='N'
2011 where event_id=p_event_id
2012 AND application_id = g_application_id -- 8967771
2013 ;
2014 else
2015 -- update from this event til the next gap, set on_hold_flag to 'N'
2016 SELECT event_status_code, event_number BULK COLLECT
2017 INTO g_gapless_array_event_status, g_gapless_event_number
2018 FROM xla_events
2019 Where entity_id = g_entity_id
2020 and event_number>p_event_number
2021 and event_number<l_old_event_number
2022 AND application_id = g_application_id -- 8967771
2023 Order by event_number;
2024
2025 l_temp_event_number:=p_event_number+1;
2026 For j in 1..g_gapless_event_number.COUNT loop
2027 if(g_gapless_event_number(j)=l_temp_event_number
2028 and g_gapless_array_event_status(j)<>'I') then
2029 l_temp_event_number:=l_temp_event_number+1;
2030 else
2031 exit;
2032 end if;
2033 end loop;
2034 --l_temp_event_number is the next gap
2035 -- update the on_hold_flag of event between l_array_event_number(i)
2036 -- and --l_temp_event_number+1
2037
2038 update xla_events
2039 set on_hold_flag='N'
2040 where entity_id=g_entity_id
2041 and event_number >p_event_number-1
2042 and event_number <l_temp_event_number+1
2043 AND application_id = g_application_id -- 8967771
2044 ;
2045 end if;
2046 end if;
2047 end if;
2048 else --event number is not updated, but the status changed
2049 if(p_event_status_code='I' and l_old_on_hold_flag='N') then
2050 -- new gap
2051 update xla_events
2052 set on_hold_flag='Y'
2053 where entity_id=g_entity_id
2054 and event_number>l_old_event_number
2055 and on_hold_flag='N'
2056 AND application_id = g_application_id -- 8967771
2057 ;
2058
2059 elsif(l_old_event_status_code='I' and l_old_on_hold_flag='N') then
2060 -- old gap eliminated
2061 SELECT event_status_code, event_number BULK COLLECT
2062 INTO g_gapless_array_event_status, g_gapless_event_number
2063 FROM xla_events
2064 Where entity_id = g_entity_id
2065 and event_number>l_old_event_number
2066 AND application_id = g_application_id -- 8967771
2067 Order by event_number;
2068
2069 l_temp_event_number:=l_old_event_number+1;
2070 For j in 1..g_gapless_event_number.COUNT loop
2071 if(g_gapless_event_number(j)=l_temp_event_number
2072 and g_gapless_array_event_status(j)<>'I') then
2073 l_temp_event_number:=l_temp_event_number+1;
2074 else
2075 exit;
2076 end if;
2077 end loop;
2078 --l_temp_event_number is the next gap
2079 -- update the on_hold_flag of event between l_array_event_number(i)
2080 -- and --l_temp_event_number+1
2081
2082 update xla_events
2083 set on_hold_flag='N'
2084 where entity_id=g_entity_id
2085 and event_number >l_old_event_number
2086 and event_number <l_temp_event_number+1
2087 AND application_id = g_application_id -- 8967771
2088 ;
2089
2090 end if;
2091 end if;
2092 end if;
2093
2094 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2095 trace
2096 (p_msg => 'end of procedure update_event'
2097 ,p_level => C_LEVEL_PROCEDURE
2098 ,p_module =>l_log_module);
2099 END IF;
2100 EXCEPTION
2101 WHEN xla_exceptions_pkg.application_exception THEN
2102 ROLLBACK to SAVEPOINT before_event_update;
2103 RAISE;
2104 WHEN OTHERS THEN
2105 ROLLBACK to SAVEPOINT before_event_update;
2106 xla_exceptions_pkg.raise_message
2107 (p_location => 'xla_events_pkg.update_event');
2108 END update_event;
2109
2110
2111 --=============================================================================
2112 --
2113 -- This API is specific for MANUAL events. Bug # 2899700.
2114 --
2115 --=============================================================================
2116
2117 PROCEDURE update_manual_event
2118 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
2119 ,p_event_id IN INTEGER
2120 ,p_event_type_code IN VARCHAR2 DEFAULT NULL
2121 ,p_event_date IN DATE DEFAULT NULL
2122 ,p_event_status_code IN VARCHAR2 DEFAULT NULL
2123 ,p_process_status_code IN VARCHAR2 DEFAULT NULL
2124 ,p_event_number IN INTEGER DEFAULT NULL
2125 ,p_reference_info IN xla_events_pub_pkg.t_event_reference_info
2126 DEFAULT NULL
2127 ,p_overwrite_event_num IN VARCHAR2 DEFAULT 'N'
2128 ,p_overwrite_ref_info IN VARCHAR2 DEFAULT 'N') IS
2129 l_event_date DATE;
2130 l_log_module VARCHAR2(240);
2131 l_rowcount NUMBER;
2132 BEGIN
2133 IF g_log_enabled THEN
2134 l_log_module := C_DEFAULT_MODULE||'.update_manual_event';
2135 END IF;
2136 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2137 trace
2138 (p_msg => 'BEGIN of procedure update_manual_event'
2139 ,p_level => C_LEVEL_PROCEDURE
2140 ,p_module =>l_log_module);
2141 trace
2142 (p_msg => 'source_application_id = '||
2143 p_event_source_info.source_application_id
2144 ,p_level => C_LEVEL_PROCEDURE
2145 ,p_module =>l_log_module);
2146 trace
2147 (p_msg => 'application_id = '||p_event_source_info.application_id
2148 ,p_level => C_LEVEL_PROCEDURE
2149 ,p_module =>l_log_module);
2150 trace
2151 (p_msg => 'legal_entity_id = '||
2152 p_event_source_info.legal_entity_id
2153 ,p_level => C_LEVEL_PROCEDURE
2154 ,p_module =>l_log_module);
2155 trace
2156 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
2157 ,p_level => C_LEVEL_PROCEDURE
2158 ,p_module =>l_log_module);
2159 trace
2160 (p_msg => 'entity_type_code = '||
2161 p_event_source_info.entity_type_code
2162 ,p_level => C_LEVEL_PROCEDURE
2163 ,p_module =>l_log_module);
2164 trace
2165 (p_msg => 'transaction_number = '||
2166 p_event_source_info.transaction_number
2167 ,p_level => C_LEVEL_PROCEDURE
2168 ,p_module =>l_log_module);
2169 trace
2170 (p_msg => 'source_id_int_1 = '||
2171 p_event_source_info.source_id_int_1
2172 ,p_level => C_LEVEL_PROCEDURE
2173 ,p_module =>l_log_module);
2174 trace
2175 (p_msg => 'source_id_int_2 = '||
2176 p_event_source_info.source_id_int_2
2177 ,p_level => C_LEVEL_PROCEDURE
2178 ,p_module =>l_log_module);
2179 trace
2180 (p_msg => 'source_id_int_3 = '||
2181 p_event_source_info.source_id_int_3
2182 ,p_level => C_LEVEL_PROCEDURE
2183 ,p_module =>l_log_module);
2184 trace
2185 (p_msg => 'source_id_int_4 = '||
2186 p_event_source_info.source_id_int_4
2187 ,p_level => C_LEVEL_PROCEDURE
2188 ,p_module =>l_log_module);
2189 trace
2190 (p_msg => 'source_id_char_1 = '||
2191 p_event_source_info.source_id_char_1
2192 ,p_level => C_LEVEL_PROCEDURE
2193 ,p_module =>l_log_module);
2194 trace
2195 (p_msg => 'source_id_char_2 = '||
2196 p_event_source_info.source_id_char_2
2197 ,p_level => C_LEVEL_PROCEDURE
2198 ,p_module =>l_log_module);
2199 trace
2200 (p_msg => 'source_id_char_3 = '||
2201 p_event_source_info.source_id_char_3
2202 ,p_level => C_LEVEL_PROCEDURE
2203 ,p_module =>l_log_module);
2204 trace
2205 (p_msg => 'source_id_char_4 = '||
2206 p_event_source_info.source_id_char_4
2207 ,p_level => C_LEVEL_PROCEDURE
2208 ,p_module =>l_log_module);
2209 trace
2210 (p_msg => 'p_event_id = '||p_event_id
2211 ,p_level => C_LEVEL_PROCEDURE
2212 ,p_module =>l_log_module);
2213 trace
2214 (p_msg => 'p_event_type_code = '||p_event_type_code
2215 ,p_level => C_LEVEL_PROCEDURE
2216 ,p_module =>l_log_module);
2217 trace
2218 (p_msg => 'p_event_date = '||p_event_date
2219 ,p_level => C_LEVEL_PROCEDURE
2220 ,p_module =>l_log_module);
2221 trace
2222 (p_msg => 'p_event_status_code = '||p_event_status_code
2223 ,p_level => C_LEVEL_PROCEDURE
2224 ,p_module =>l_log_module);
2225 trace
2226 (p_msg => 'p_process_status_code = '||p_process_status_code
2227 ,p_level => C_LEVEL_PROCEDURE
2228 ,p_module =>l_log_module);
2229 trace
2230 (p_msg => 'p_event_number = '||p_event_number
2231 ,p_level => C_LEVEL_PROCEDURE
2232 ,p_module =>l_log_module);
2233 trace
2234 (p_msg => 'p_overwrite_event_num = '||p_overwrite_event_num
2235 ,p_level => C_LEVEL_PROCEDURE
2236 ,p_module =>l_log_module);
2237 trace
2238 (p_msg => 'p_overwrite_ref_info = '||p_overwrite_ref_info
2239 ,p_level => C_LEVEL_PROCEDURE
2240 ,p_module =>l_log_module);
2241 trace
2242 (p_msg => 'security_id_int_1 = '||
2243 xla_events_pub_pkg.g_security.security_id_int_1
2244 ,p_level => C_LEVEL_PROCEDURE
2245 ,p_module =>l_log_module);
2246 trace
2247 (p_msg => 'security_id_int_2 = '||
2248 xla_events_pub_pkg.g_security.security_id_int_2
2249 ,p_level => C_LEVEL_PROCEDURE
2250 ,p_module =>l_log_module);
2251 trace
2252 (p_msg => 'security_id_int_3 = '||
2253 xla_events_pub_pkg.g_security.security_id_int_3
2254 ,p_level => C_LEVEL_PROCEDURE
2255 ,p_module =>l_log_module);
2256 trace
2257 (p_msg => 'security_id_char_1 = '||
2258 xla_events_pub_pkg.g_security.security_id_char_1
2259 ,p_level => C_LEVEL_PROCEDURE
2260 ,p_module =>l_log_module);
2261 trace
2262 (p_msg => 'security_id_char_2 = '||
2263 xla_events_pub_pkg.g_security.security_id_char_2
2264 ,p_level => C_LEVEL_PROCEDURE
2265 ,p_module =>l_log_module);
2266 trace
2267 (p_msg => 'security_id_char_3 = '||
2268 xla_events_pub_pkg.g_security.security_id_char_3
2269 ,p_level => C_LEVEL_PROCEDURE
2270 ,p_module =>l_log_module);
2271 END IF;
2272
2273 SAVEPOINT before_event_update;
2274 g_action := C_EVENT_UPDATE;
2275
2276 ----------------------------------------------------------------------------
2277 -- Following sets the Security Context for the execution. This enables the
2278 -- event API to respect the transaction security.
2279 ----------------------------------------------------------------------------
2280 xla_security_pkg.set_security_context(p_event_source_info.application_id);
2281
2282 ----------------------------------------------------------------------------
2283 -- check to see the API is not called for regular events
2284 ----------------------------------------------------------------------------
2285 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
2286 g_context := C_MANUAL_EVENT_CONTEXT;
2287 ELSE
2288 xla_exceptions_pkg.raise_message
2289 (p_appli_s_name => 'XLA'
2290 ,p_msg_name => 'XLA_COMMON_ERROR'
2291 ,p_token_1 => 'ERROR'
2292 ,p_value_1 => 'For REGULAR events this API cannot be called'
2293 ,p_token_2 => 'LOCATION'
2294 ,p_value_2 => 'xla_events_pkg.update_manual_event');
2295 END IF;
2296
2297 ----------------------------------------------------------------------------
2298 -- perfrom validations specific to 'updating event'
2299 ----------------------------------------------------------------------------
2300 IF p_event_id IS NULL THEN
2301 xla_exceptions_pkg.raise_message
2302 (p_appli_s_name => 'XLA'
2303 ,p_msg_name => 'XLA_COMMON_ERROR'
2304 ,p_token_1 => 'ERROR'
2305 ,p_value_1 => 'Event ID cannot have a NULL value.'
2306 ,p_token_2 => 'LOCATION'
2307 ,p_value_2 => 'xla_events_pkg.update_manual_event');
2308 END IF;
2309
2310 ----------------------------------------------------------------------------
2311 -- validate to make sure that both p_event_status_code and
2312 -- p_process_status_code should either be NULL or NOT NULL
2313 ----------------------------------------------------------------------------
2314 IF (((p_event_status_code IS NOT NULL) AND (p_process_status_code IS NULL))OR
2315 ((p_event_status_code IS NULL) AND (p_process_status_code IS NOT NULL)))
2316 THEN
2317 xla_exceptions_pkg.raise_message
2318 (p_appli_s_name => 'XLA'
2319 ,p_msg_name => 'XLA_COMMON_ERROR'
2320 ,p_token_1 => 'ERROR'
2321 ,p_value_1 => 'Inconsistent values for event statuses: '||
2322 'p_event_status_code = '||p_event_status_code||
2323 'p_process_status_code = '||p_process_status_code
2324 ,p_token_2 => 'LOCATION'
2325 ,p_value_2 => 'xla_events_pkg.update_manual_event');
2326 END IF;
2327
2328 ----------------------------------------------------------------------------
2329 -- truncate date
2330 ----------------------------------------------------------------------------
2331 l_event_date := TRUNC(p_event_date);
2332
2333 ----------------------------------------------------------------------------
2334 -- Validate parameters
2335 ----------------------------------------------------------------------------
2336 validate_params
2337 (p_source_info => p_event_source_info
2338 ,p_event_type_code => p_event_type_code
2339 ,p_event_status_code => p_event_status_code
2340 ,p_process_status_code => p_process_status_code);
2341
2342 ----------------------------------------------------------------------------
2343 -- Get document PK
2344 ----------------------------------------------------------------------------
2345 cache_entity_info
2346 (p_source_info => p_event_source_info
2347 ,p_valuation_method => NULL
2348 ,p_event_id => p_event_id);
2349
2350 ----------------------------------------------------------------------------
2351 -- Check entity existency
2352 ----------------------------------------------------------------------------
2353 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2354 trace
2355 (p_msg => 'g_entity_id = '||g_entity_id
2356 ,p_level => C_LEVEL_STATEMENT
2357 ,p_module =>l_log_module);
2358 END IF;
2359
2360 IF g_entity_id IS NULL THEN
2361 xla_exceptions_pkg.raise_message
2362 (p_appli_s_name => 'XLA'
2363 ,p_msg_name => 'XLA_COMMON_ERROR'
2364 ,p_token_1 => 'ERROR'
2365 ,p_value_1 => 'No event exists for the document represented '||
2366 'by the given source information.'
2367 ,p_token_2 => 'LOCATION'
2368 ,p_value_2 => 'xla_events_pkg.update_manual_event');
2369 END IF;
2370
2371 ----------------------------------------------------------------------------
2372 -- Actual status update
2373 ----------------------------------------------------------------------------
2374 UPDATE xla_events
2375 SET event_type_code = NVL(p_event_type_code , event_type_code)
2376 ,event_date = NVL(l_event_date , event_date)
2377 ,event_status_code = NVL(p_event_status_code, event_status_code)
2378 ,process_status_code = NVL(p_process_status_code,process_status_code)
2379 ,event_number = DECODE(p_overwrite_event_num,C_YES,
2380 NVL(p_event_number,g_max_event_number+1),event_number)
2381 ,reference_num_1 = DECODE(p_overwrite_ref_info,C_YES,
2382 p_reference_info.reference_num_1,reference_num_1)
2383 ,reference_num_2 = DECODE(p_overwrite_ref_info,C_YES,
2384 p_reference_info.reference_num_2,reference_num_2)
2385 ,reference_num_3 = DECODE(p_overwrite_ref_info,C_YES,
2386 p_reference_info.reference_num_3,reference_num_3)
2387 ,reference_num_4 = DECODE(p_overwrite_ref_info,C_YES,
2388 p_reference_info.reference_num_4,reference_num_4)
2389 ,reference_char_1 = DECODE(p_overwrite_ref_info,C_YES,
2390 p_reference_info.reference_char_1,reference_char_1)
2391 ,reference_char_2 = DECODE(p_overwrite_ref_info,C_YES,
2392 p_reference_info.reference_char_2,reference_char_2)
2393 ,reference_char_3 = DECODE(p_overwrite_ref_info,C_YES,
2394 p_reference_info.reference_char_3,reference_char_3)
2395 ,reference_char_4 = DECODE(p_overwrite_ref_info,C_YES,
2396 p_reference_info.reference_char_4,reference_char_4)
2397 ,reference_date_1 = DECODE(p_overwrite_ref_info,C_YES,
2398 p_reference_info.reference_date_1,reference_date_1)
2399 ,reference_date_2 = DECODE(p_overwrite_ref_info,C_YES,
2400 p_reference_info.reference_date_2,reference_date_2)
2401 ,reference_date_3 = DECODE(p_overwrite_ref_info,C_YES,
2402 p_reference_info.reference_date_3,reference_date_3)
2403 ,reference_date_4 = DECODE(p_overwrite_ref_info,C_YES,
2404 p_reference_info.reference_date_4,reference_date_4)
2405 ,last_update_date = sysdate
2406 ,last_updated_by = xla_environment_pkg.g_usr_id
2407 ,last_update_login = xla_environment_pkg.g_login_id
2408 ,program_update_date = sysdate
2409 ,program_application_id= xla_environment_pkg.g_prog_appl_id
2410 ,program_id = xla_environment_pkg.g_prog_id
2411 ,request_id = xla_environment_pkg.g_Req_Id
2412 WHERE event_id = p_event_id
2413 AND entity_id = g_entity_id
2414 AND event_status_code <> xla_events_pub_pkg.C_EVENT_PROCESSED
2415 AND application_id = g_application_id -- 8967771
2416 ;
2417
2418 l_rowcount := SQL%ROWCOUNT;
2419
2420 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2421 trace
2422 (p_msg => 'Number for rows updated = '||l_rowcount
2423 ,p_level => C_LEVEL_STATEMENT
2424 ,p_module =>l_log_module);
2425 END IF;
2426
2427 IF l_rowcount <> 1 THEN
2428 xla_exceptions_pkg.raise_message
2429 (p_appli_s_name => 'XLA'
2430 ,p_msg_name => 'XLA_COMMON_ERROR'
2431 ,p_token_1 => 'ERROR'
2432 ,p_value_1 =>
2433 'Unable to perform UPDATE on the event. The event ('||p_event_id ||
2434 ') is invalid'
2435 ,p_token_2 => 'LOCATION'
2436 ,p_value_2 => 'xla_events_pkg.update_manual_event');
2437 END IF;
2438
2439 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2440 trace
2441 (p_msg => 'end of procedure update_manual_event'
2442 ,p_level => C_LEVEL_PROCEDURE
2443 ,p_module =>l_log_module);
2444 END IF;
2445
2446 EXCEPTION
2447 WHEN xla_exceptions_pkg.application_exception THEN
2448 ROLLBACK to SAVEPOINT before_event_update;
2449 RAISE;
2450 WHEN OTHERS THEN
2451 ROLLBACK to SAVEPOINT before_event_update;
2452 xla_exceptions_pkg.raise_message
2453 (p_location => 'xla_events_pkg.update_manual_event');
2454 END update_manual_event;
2455
2456
2457 --=============================================================================
2458 --
2459 -- Bug # 2899700. This API can be called for Manual and Standard events.
2460 -- Bug 3268790. commented the statements that delete rows for entites.
2461 --
2462 --=============================================================================
2463
2464 PROCEDURE delete_event
2465 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
2466 ,p_valuation_method IN VARCHAR2
2467 ,p_event_id IN INTEGER) IS
2468 l_on_hold_flag xla_events.on_hold_flag%type;
2469 l_event_status_code xla_events.event_status_code%type;
2470 l_event_number xla_events.event_number%type;
2471 l_log_module VARCHAR2(240);
2472 l_rowcount NUMBER;
2473 BEGIN
2474 IF g_log_enabled THEN
2475 l_log_module := C_DEFAULT_MODULE||'.delete_event';
2476 END IF;
2477 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2478 trace
2479 (p_msg => 'BEGIN of procedure delete_event'
2480 ,p_level => C_LEVEL_PROCEDURE
2481 ,p_module =>l_log_module);
2482 trace
2483 (p_msg => 'source_application_id = '||
2484 p_event_source_info.source_application_id
2485 ,p_level => C_LEVEL_PROCEDURE
2486 ,p_module =>l_log_module);
2487 trace
2488 (p_msg => 'application_id = '||p_event_source_info.application_id
2489 ,p_level => C_LEVEL_PROCEDURE
2490 ,p_module =>l_log_module);
2491 trace
2492 (p_msg => 'legal_entity_id = '||
2493 p_event_source_info.legal_entity_id
2494 ,p_level => C_LEVEL_PROCEDURE
2495 ,p_module =>l_log_module);
2496 trace
2497 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
2498 ,p_level => C_LEVEL_PROCEDURE
2499 ,p_module =>l_log_module);
2500 trace
2501 (p_msg => 'entity_type_code = '||
2502 p_event_source_info.entity_type_code
2503 ,p_level => C_LEVEL_PROCEDURE
2504 ,p_module =>l_log_module);
2505 trace
2506 (p_msg => 'transaction_number = '||
2507 p_event_source_info.transaction_number
2508 ,p_level => C_LEVEL_PROCEDURE
2509 ,p_module =>l_log_module);
2510 trace
2511 (p_msg => 'source_id_int_1 = '||
2512 p_event_source_info.source_id_int_1
2513 ,p_level => C_LEVEL_PROCEDURE
2514 ,p_module =>l_log_module);
2515 trace
2516 (p_msg => 'source_id_int_2 = '||
2517 p_event_source_info.source_id_int_2
2518 ,p_level => C_LEVEL_PROCEDURE
2519 ,p_module =>l_log_module);
2520 trace
2521 (p_msg => 'source_id_int_3 = '||
2522 p_event_source_info.source_id_int_3
2523 ,p_level => C_LEVEL_PROCEDURE
2524 ,p_module =>l_log_module);
2525 trace
2526 (p_msg => 'source_id_int_4 = '||
2527 p_event_source_info.source_id_int_4
2528 ,p_level => C_LEVEL_PROCEDURE
2529 ,p_module =>l_log_module);
2530 trace
2531 (p_msg => 'source_id_char_1 = '||
2532 p_event_source_info.source_id_char_1
2533 ,p_level => C_LEVEL_PROCEDURE
2534 ,p_module =>l_log_module);
2535 trace
2536 (p_msg => 'source_id_char_2 = '||
2537 p_event_source_info.source_id_char_2
2538 ,p_level => C_LEVEL_PROCEDURE
2539 ,p_module =>l_log_module);
2540 trace
2541 (p_msg => 'source_id_char_3 = '||
2542 p_event_source_info.source_id_char_3
2543 ,p_level => C_LEVEL_PROCEDURE
2544 ,p_module =>l_log_module);
2545 trace
2546 (p_msg => 'source_id_char_4 = '||
2547 p_event_source_info.source_id_char_4
2548 ,p_level => C_LEVEL_PROCEDURE
2549 ,p_module =>l_log_module);
2550 trace
2551 (p_msg => 'p_event_id = '||p_event_id
2552 ,p_level => C_LEVEL_PROCEDURE
2553 ,p_module =>l_log_module);
2554 trace
2555 (p_msg => 'security_id_int_1 = '||
2556 xla_events_pub_pkg.g_security.security_id_int_1
2557 ,p_level => C_LEVEL_PROCEDURE
2558 ,p_module =>l_log_module);
2559 trace
2560 (p_msg => 'security_id_int_2 = '||
2561 xla_events_pub_pkg.g_security.security_id_int_2
2562 ,p_level => C_LEVEL_PROCEDURE
2563 ,p_module =>l_log_module);
2564 trace
2565 (p_msg => 'security_id_int_3 = '||
2566 xla_events_pub_pkg.g_security.security_id_int_3
2567 ,p_level => C_LEVEL_PROCEDURE
2568 ,p_module =>l_log_module);
2569 trace
2570 (p_msg => 'security_id_char_1 = '||
2571 xla_events_pub_pkg.g_security.security_id_char_1
2572 ,p_level => C_LEVEL_PROCEDURE
2573 ,p_module =>l_log_module);
2574 trace
2575 (p_msg => 'security_id_char_2 = '||
2576 xla_events_pub_pkg.g_security.security_id_char_2
2577 ,p_level => C_LEVEL_PROCEDURE
2578 ,p_module =>l_log_module);
2579 trace
2580 (p_msg => 'security_id_char_3 = '||
2581 xla_events_pub_pkg.g_security.security_id_char_3
2582 ,p_level => C_LEVEL_PROCEDURE
2583 ,p_module =>l_log_module);
2584 trace
2585 (p_msg => 'valuation_method = '||p_valuation_method
2586 ,p_level => C_LEVEL_PROCEDURE
2587 ,p_module =>l_log_module);
2588 END IF;
2589
2590 SAVEPOINT before_event_delete;
2591 g_action := C_EVENT_DELETE;
2592
2593 ----------------------------------------------------------------------------
2594 -- Following sets the Security Context for the execution. This enables the
2595 -- event API to respect the transaction security.
2596 ----------------------------------------------------------------------------
2597 xla_security_pkg.set_security_context(p_event_source_info.application_id);
2598
2599 ----------------------------------------------------------------------------
2600 -- Set the right context for calling this API
2601 -- Changed to fix bug # 2899700
2602 ----------------------------------------------------------------------------
2603 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
2604 g_context := C_MANUAL_EVENT_CONTEXT;
2605 ELSE
2606 g_context := C_REGULAR_EVENT_CONTEXT;
2607 END IF;
2608
2609 ----------------------------------------------------------------------------
2610 -- perform validations specific to 'deleting event'
2611 ----------------------------------------------------------------------------
2612 IF p_event_id IS NULL THEN
2613 xla_exceptions_pkg.raise_message
2614 (p_appli_s_name => 'XLA'
2615 ,p_msg_name => 'XLA_COMMON_ERROR'
2616 ,p_token_1 => 'ERROR'
2617 ,p_value_1 => 'Event ID cannot have a NULL value.'
2618 ,p_token_2 => 'LOCATION'
2619 ,p_value_2 => 'xla_events_pkg.delete_event');
2620 END IF;
2621
2622 ----------------------------------------------------------------------------
2623 -- Validate parameters
2624 ----------------------------------------------------------------------------
2625 validate_params
2626 (p_source_info => p_event_source_info);
2627
2628 ----------------------------------------------------------------------------
2629 -- Get document PK
2630 ----------------------------------------------------------------------------
2631 cache_entity_info
2632 (p_source_info => p_event_source_info
2633 ,p_valuation_method => p_valuation_method
2634 ,p_event_id => p_event_id);
2635
2636 ----------------------------------------------------------------------------
2637 -- Check entity existency
2638 ----------------------------------------------------------------------------
2639 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2640 trace
2641 (p_msg => 'g_entity_id = '||g_entity_id
2642 ,p_level => C_LEVEL_STATEMENT
2643 ,p_module =>l_log_module);
2644 END IF;
2645
2646 IF g_entity_id IS NULL THEN
2647 xla_exceptions_pkg.raise_message
2648 (p_appli_s_name => 'XLA'
2649 ,p_msg_name => 'XLA_COMMON_ERROR'
2650 ,p_token_1 => 'ERROR'
2651 ,p_value_1 => 'No event exists for the document represented '||
2652 'by the given source information.'
2653 ,p_token_2 => 'LOCATION'
2654 ,p_value_2 => 'xla_events_pkg.delete_event');
2655 END IF;
2656
2657 ----------------------------------------------------------------------------
2658 -- Call routine to delete errors/JEs related to the event bug # 2701681
2659 ----------------------------------------------------------------------------
2660 xla_journal_entries_pkg.delete_journal_entries
2661 (p_event_id => p_event_id
2662 ,p_application_id => g_application_id);
2663
2664 if(g_gapless_flag='Y') then
2665 begin
2666 select on_hold_flag, event_status_code, event_number
2667 into l_on_hold_flag, l_event_status_code, l_event_number
2668 from xla_events
2669 WHERE event_id = p_event_id
2670 AND entity_id = g_entity_id
2671 AND event_status_code <> xla_events_pub_pkg.C_EVENT_PROCESSED
2672 AND application_id = g_application_id -- 8967771
2673 ;
2674 exception when others then
2675 xla_exceptions_pkg.raise_message
2676 (p_appli_s_name => 'XLA'
2677 ,p_msg_name => 'XLA_COMMON_ERROR'
2678 ,p_token_1 => 'ERROR'
2679 ,p_value_1 =>
2680 'Unable to perform DELETE on the event. The event ('|| p_event_id ||
2681 ') is either invalid or has been final accounted.'
2682 ,p_token_2 => 'LOCATION'
2683 ,p_value_2 => 'xla_events_pkg.delete_event');
2684 end;
2685 end if;
2686
2687 ----------------------------------------------------------------------------
2688 -- Actual Delete of the event
2689 ----------------------------------------------------------------------------
2690 DELETE xla_events
2691 WHERE event_id = p_event_id
2692 AND entity_id = g_entity_id
2693 AND event_status_code <> xla_events_pub_pkg.C_EVENT_PROCESSED
2694 AND application_id = g_application_id -- 8967771
2695 ;
2696
2697 l_rowcount := SQL%ROWCOUNT;
2698
2699 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2700 trace
2701 (p_msg => 'Number for events deleted = '||l_rowcount
2702 ,p_level => C_LEVEL_STATEMENT
2703 ,p_module =>l_log_module);
2704 END IF;
2705
2706 IF l_rowcount <> 1 THEN
2707 xla_exceptions_pkg.raise_message
2708 (p_appli_s_name => 'XLA'
2709 ,p_msg_name => 'XLA_COMMON_ERROR'
2710 ,p_token_1 => 'ERROR'
2711 ,p_value_1 =>
2712 'Unable to perform DELETE on the event. The event ('|| p_event_id ||
2713 ') is either invalid or has been final accounted.'
2714 ,p_token_2 => 'LOCATION'
2715 ,p_value_2 => 'xla_events_pkg.delete_event');
2716
2717 ELSIF g_context = C_MANUAL_EVENT_CONTEXT THEN
2718 --------------------------------------------------------------------------
2719 -- this if condition is added to make sure that the entity row is
2720 -- deleted only for Manula events and not for statndard event.Bug 3268790.
2721 --------------------------------------------------------------------------
2722 ----------------------------------------------------------------------
2723 -- following will delete the row from entities if there is no
2724 -- event exists for the entity
2725 ----------------------------------------------------------------------
2726 DELETE xla_transaction_entities xte
2727 WHERE xte.entity_id = g_entity_id
2728 AND xte.application_id = g_application_id
2729 AND NOT EXISTS
2730 (SELECT '1' FROM xla_events xe
2731 WHERE xe.entity_id = xte.entity_id
2732 AND xe.application_id = xte.application_id);
2733
2734 l_rowcount := SQL%ROWCOUNT;
2735
2736 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2737 trace
2738 (p_msg => 'Number for entities deleted = '||l_rowcount
2739 ,p_level => C_LEVEL_STATEMENT
2740 ,p_module =>l_log_module);
2741 END IF;
2742
2743 ELSIF (g_gapless_flag='Y' and l_on_hold_flag='N'
2744 and l_event_status_code<>'I') then
2745 update xla_events
2746 set on_hold_flag='Y'
2747 where entity_id=g_entity_id
2748 and event_number>l_event_number
2749 AND application_id = g_application_id -- 8967771
2750 ;
2751 END IF;
2752
2753 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2754 trace
2755 (p_msg => 'end of procedure delete_event'
2756 ,p_level => C_LEVEL_PROCEDURE
2757 ,p_module =>l_log_module);
2758 END IF;
2759
2760 EXCEPTION
2761 WHEN xla_exceptions_pkg.application_exception THEN
2762 ROLLBACK to SAVEPOINT before_event_delete;
2763 RAISE;
2764 WHEN OTHERS THEN
2765 ROLLBACK to SAVEPOINT before_event_delete;
2766 xla_exceptions_pkg.raise_message
2767 (p_location => 'xla_events_pkg.delete_event');
2768 END delete_event;
2769
2770
2771 --=============================================================================
2772 --
2773 -- This API is specific for MANUAL events. (delebrate restriction)
2774 -- Added this API to fix bug # 2899700.
2775 --
2776 --=============================================================================
2777
2778 PROCEDURE delete_processed_event
2779 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
2780 ,p_event_id IN INTEGER) IS
2781 l_log_module VARCHAR2(240);
2782 l_rowcount NUMBER;
2783 BEGIN
2784 IF g_log_enabled THEN
2785 l_log_module := C_DEFAULT_MODULE||'.delete_processed_event';
2786 END IF;
2787 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2788 trace
2789 (p_msg => 'BEGIN of procedure delete_processed_event'
2790 ,p_level => C_LEVEL_PROCEDURE
2791 ,p_module =>l_log_module);
2792 trace
2793 (p_msg => 'source_application_id = '||
2794 p_event_source_info.source_application_id
2795 ,p_level => C_LEVEL_PROCEDURE
2796 ,p_module =>l_log_module);
2797 trace
2798 (p_msg => 'application_id = '||p_event_source_info.application_id
2799 ,p_level => C_LEVEL_PROCEDURE
2800 ,p_module =>l_log_module);
2801 trace
2802 (p_msg => 'legal_entity_id = '||
2803 p_event_source_info.legal_entity_id
2804 ,p_level => C_LEVEL_PROCEDURE
2805 ,p_module =>l_log_module);
2806 trace
2807 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
2808 ,p_level => C_LEVEL_PROCEDURE
2809 ,p_module =>l_log_module);
2810 trace
2811 (p_msg => 'entity_type_code = '||
2812 p_event_source_info.entity_type_code
2813 ,p_level => C_LEVEL_PROCEDURE
2814 ,p_module =>l_log_module);
2815 trace
2816 (p_msg => 'transaction_number = '||
2817 p_event_source_info.transaction_number
2818 ,p_level => C_LEVEL_PROCEDURE
2819 ,p_module =>l_log_module);
2820 trace
2821 (p_msg => 'source_id_int_1 = '||
2822 p_event_source_info.source_id_int_1
2823 ,p_level => C_LEVEL_PROCEDURE
2824 ,p_module =>l_log_module);
2825 trace
2826 (p_msg => 'source_id_int_2 = '||
2827 p_event_source_info.source_id_int_2
2828 ,p_level => C_LEVEL_PROCEDURE
2829 ,p_module =>l_log_module);
2830 trace
2831 (p_msg => 'source_id_int_3 = '||
2832 p_event_source_info.source_id_int_3
2833 ,p_level => C_LEVEL_PROCEDURE
2834 ,p_module =>l_log_module);
2835 trace
2836 (p_msg => 'source_id_int_4 = '||
2837 p_event_source_info.source_id_int_4
2838 ,p_level => C_LEVEL_PROCEDURE
2839 ,p_module =>l_log_module);
2840 trace
2841 (p_msg => 'source_id_char_1 = '||
2842 p_event_source_info.source_id_char_1
2843 ,p_level => C_LEVEL_PROCEDURE
2844 ,p_module =>l_log_module);
2845 trace
2846 (p_msg => 'source_id_char_2 = '||
2847 p_event_source_info.source_id_char_2
2848 ,p_level => C_LEVEL_PROCEDURE
2849 ,p_module =>l_log_module);
2850 trace
2851 (p_msg => 'source_id_char_3 = '||
2852 p_event_source_info.source_id_char_3
2853 ,p_level => C_LEVEL_PROCEDURE
2854 ,p_module =>l_log_module);
2855 trace
2856 (p_msg => 'source_id_char_4 = '||
2857 p_event_source_info.source_id_char_4
2858 ,p_level => C_LEVEL_PROCEDURE
2859 ,p_module =>l_log_module);
2860 trace
2861 (p_msg => 'p_event_id = '||p_event_id
2862 ,p_level => C_LEVEL_PROCEDURE
2863 ,p_module =>l_log_module);
2864 trace
2865 (p_msg => 'security_id_int_1 = '||
2866 xla_events_pub_pkg.g_security.security_id_int_1
2867 ,p_level => C_LEVEL_PROCEDURE
2868 ,p_module =>l_log_module);
2869 trace
2870 (p_msg => 'security_id_int_2 = '||
2871 xla_events_pub_pkg.g_security.security_id_int_2
2872 ,p_level => C_LEVEL_PROCEDURE
2873 ,p_module =>l_log_module);
2874 trace
2875 (p_msg => 'security_id_int_3 = '||
2876 xla_events_pub_pkg.g_security.security_id_int_3
2877 ,p_level => C_LEVEL_PROCEDURE
2878 ,p_module =>l_log_module);
2879 trace
2880 (p_msg => 'security_id_char_1 = '||
2881 xla_events_pub_pkg.g_security.security_id_char_1
2882 ,p_level => C_LEVEL_PROCEDURE
2883 ,p_module =>l_log_module);
2884 trace
2885 (p_msg => 'security_id_char_2 = '||
2886 xla_events_pub_pkg.g_security.security_id_char_2
2887 ,p_level => C_LEVEL_PROCEDURE
2888 ,p_module =>l_log_module);
2889 trace
2890 (p_msg => 'security_id_char_3 = '||
2891 xla_events_pub_pkg.g_security.security_id_char_3
2892 ,p_level => C_LEVEL_PROCEDURE
2893 ,p_module =>l_log_module);
2894 END IF;
2895
2896 trace('> xla_events_pkg.delete_processed_event' , 20);
2897
2898 SAVEPOINT before_event_delete;
2899 g_action := C_EVENT_DELETE;
2900
2901 ----------------------------------------------------------------------------
2902 -- Following sets the Security Context for the execution. This enables the
2903 -- event API to respect the transaction security.
2904 ----------------------------------------------------------------------------
2905 xla_security_pkg.set_security_context(p_event_source_info.application_id);
2906
2907 ----------------------------------------------------------------------------
2908 -- Set the right context for calling this API
2909 ----------------------------------------------------------------------------
2910 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
2911 g_context := C_MANUAL_EVENT_CONTEXT;
2912 ELSE
2913 xla_exceptions_pkg.raise_message
2914 (p_appli_s_name => 'XLA'
2915 ,p_msg_name => 'XLA_COMMON_ERROR'
2916 ,p_token_1 => 'ERROR'
2917 ,p_value_1 => 'For REGULAR events this API cannot be called'
2918 ,p_token_2 => 'LOCATION'
2919 ,p_value_2 => 'xla_events_pkg.delete_processed_event');
2920 END IF;
2921
2922 ----------------------------------------------------------------------------
2923 -- perform validations specific to 'deleting event'
2924 ----------------------------------------------------------------------------
2925 IF p_event_id IS NULL THEN
2926 xla_exceptions_pkg.raise_message
2927 (p_appli_s_name => 'XLA'
2928 ,p_msg_name => 'XLA_COMMON_ERROR'
2929 ,p_token_1 => 'ERROR'
2930 ,p_value_1 => 'Event ID cannot have a NULL value.'
2931 ,p_token_2 => 'LOCATION'
2932 ,p_value_2 => 'xla_events_pkg.delete_processed_event');
2933 END IF;
2934
2935 ----------------------------------------------------------------------------
2936 -- Validate parameters
2937 ----------------------------------------------------------------------------
2938 validate_params
2939 (p_source_info => p_event_source_info);
2940
2941 ----------------------------------------------------------------------------
2942 -- Get document PK
2943 ----------------------------------------------------------------------------
2944 cache_entity_info
2945 (p_source_info => p_event_source_info
2946 ,p_valuation_method => NULL
2947 ,p_event_id => p_event_id);
2948
2949 ----------------------------------------------------------------------------
2950 -- Check entity existency
2951 ----------------------------------------------------------------------------
2952 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2953 trace
2954 (p_msg => 'g_entity_id = '||g_entity_id
2955 ,p_level => C_LEVEL_STATEMENT
2956 ,p_module =>l_log_module);
2957 END IF;
2958
2959 IF g_entity_id IS NULL THEN
2960 xla_exceptions_pkg.raise_message
2961 (p_appli_s_name => 'XLA'
2962 ,p_msg_name => 'XLA_COMMON_ERROR'
2963 ,p_token_1 => 'ERROR'
2964 ,p_value_1 => 'No event exists for the document represented '||
2965 'by the given source information.'
2966 ,p_token_2 => 'LOCATION'
2967 ,p_value_2 => 'xla_events_pkg.delete_processed_event');
2968 END IF;
2969
2970 ----------------------------------------------------------------------------
2971 -- Call routine to delete errors/JEs related to the event bug # 2701681
2972 ----------------------------------------------------------------------------
2973 xla_journal_entries_pkg.delete_journal_entries
2974 (p_event_id => p_event_id
2975 ,p_application_id => g_application_id);
2976
2977 ----------------------------------------------------------------------------
2978 -- Actual Delete of the event
2979 ----------------------------------------------------------------------------
2980 DELETE xla_events
2981 WHERE event_id = p_event_id
2982 AND entity_id = g_entity_id
2983 AND event_status_code = xla_events_pub_pkg.C_EVENT_PROCESSED
2984 AND application_id = g_application_id -- 8967771
2985 ;
2986
2987 l_rowcount := SQL%ROWCOUNT;
2988
2989 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2990 trace
2991 (p_msg => 'Number for events deleted = '||l_rowcount
2992 ,p_level => C_LEVEL_STATEMENT
2993 ,p_module =>l_log_module);
2994 END IF;
2995
2996 IF l_rowcount <> 1 THEN
2997 xla_exceptions_pkg.raise_message
2998 (p_appli_s_name => 'XLA'
2999 ,p_msg_name => 'XLA_COMMON_ERROR'
3000 ,p_token_1 => 'ERROR'
3001 ,p_value_1 =>
3002 'Unable to perform DELETE on the event. The event ('|| p_event_id ||
3003 ') is either invalid or has not been final accounted.'
3004 ,p_token_2 => 'LOCATION'
3005 ,p_value_2 => 'xla_events_pkg.delete_processed_event');
3006 ELSE
3007 -------------------------------------------------------------------------
3008 -- following will delete the row from entities if there is no
3009 -- event exists for the entity
3010 -------------------------------------------------------------------------
3011 DELETE xla_transaction_entities xte
3012 WHERE xte.entity_id = g_entity_id
3013 AND xte.application_id = g_application_id
3014 AND NOT EXISTS
3015 (SELECT '1' FROM xla_events xe
3016 WHERE xe.entity_id = xte.entity_id
3017 AND xe.application_id = xte.application_id);
3018
3019 l_rowcount := SQL%ROWCOUNT;
3020
3021 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3022 trace
3023 (p_msg => 'Number for entities deleted = '||l_rowcount
3024 ,p_level => C_LEVEL_STATEMENT
3025 ,p_module =>l_log_module);
3026 END IF;
3027 END IF;
3028
3029
3030 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3031 trace
3032 (p_msg => 'BEGIN of procedure delete_processed_event'
3033 ,p_level => C_LEVEL_PROCEDURE
3034 ,p_module =>l_log_module);
3035 END IF;
3036
3037 EXCEPTION
3038 WHEN xla_exceptions_pkg.application_exception THEN
3039 ROLLBACK to SAVEPOINT before_event_delete;
3040 RAISE;
3041 WHEN OTHERS THEN
3042 ROLLBACK to SAVEPOINT before_event_delete;
3043 xla_exceptions_pkg.raise_message
3044 (p_location => 'xla_events_pkg.delete_processed_event');
3045 END delete_processed_event;
3046
3047
3048 --=============================================================================
3049 --
3050 -- For MANUAL events this API cannot be called.
3051 -- Bug 3268790. commented the statements that delete rows for entites.
3052 --
3053 --=============================================================================
3054
3055 FUNCTION delete_events
3056 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
3057 ,p_valuation_method IN VARCHAR2
3058 ,p_event_class_code IN VARCHAR2 DEFAULT NULL
3059 ,p_event_type_code IN VARCHAR2 DEFAULT NULL
3060 ,p_event_date IN DATE DEFAULT NULL)
3061 RETURN INTEGER IS
3062 l_event_deleted INTEGER;
3063 l_event_date DATE;
3064 l_array_events t_number_tbl;
3065 l_log_module VARCHAR2(240);
3066 BEGIN
3067 IF g_log_enabled THEN
3068 l_log_module := C_DEFAULT_MODULE||'.delete_events';
3069 END IF;
3070 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3071 trace
3072 (p_msg => 'BEGIN of procedure delete_events'
3073 ,p_level => C_LEVEL_PROCEDURE
3074 ,p_module =>l_log_module);
3075 trace
3076 (p_msg => 'source_application_id = '||
3077 p_event_source_info.source_application_id
3078 ,p_level => C_LEVEL_PROCEDURE
3079 ,p_module =>l_log_module);
3080 trace
3081 (p_msg => 'application_id = '||p_event_source_info.application_id
3082 ,p_level => C_LEVEL_PROCEDURE
3083 ,p_module =>l_log_module);
3084 trace
3085 (p_msg => 'legal_entity_id = '||
3086 p_event_source_info.legal_entity_id
3087 ,p_level => C_LEVEL_PROCEDURE
3088 ,p_module =>l_log_module);
3089 trace
3090 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
3091 ,p_level => C_LEVEL_PROCEDURE
3092 ,p_module =>l_log_module);
3093 trace
3094 (p_msg => 'entity_type_code = '||
3095 p_event_source_info.entity_type_code
3096 ,p_level => C_LEVEL_PROCEDURE
3097 ,p_module =>l_log_module);
3098 trace
3099 (p_msg => 'transaction_number = '||
3100 p_event_source_info.transaction_number
3101 ,p_level => C_LEVEL_PROCEDURE
3102 ,p_module =>l_log_module);
3103 trace
3104 (p_msg => 'source_id_int_1 = '||
3105 p_event_source_info.source_id_int_1
3106 ,p_level => C_LEVEL_PROCEDURE
3107 ,p_module =>l_log_module);
3108 trace
3109 (p_msg => 'source_id_int_2 = '||
3110 p_event_source_info.source_id_int_2
3111 ,p_level => C_LEVEL_PROCEDURE
3112 ,p_module =>l_log_module);
3113 trace
3114 (p_msg => 'source_id_int_3 = '||
3115 p_event_source_info.source_id_int_3
3116 ,p_level => C_LEVEL_PROCEDURE
3117 ,p_module =>l_log_module);
3118 trace
3119 (p_msg => 'source_id_int_4 = '||
3120 p_event_source_info.source_id_int_4
3121 ,p_level => C_LEVEL_PROCEDURE
3122 ,p_module =>l_log_module);
3123 trace
3124 (p_msg => 'source_id_char_1 = '||
3125 p_event_source_info.source_id_char_1
3126 ,p_level => C_LEVEL_PROCEDURE
3127 ,p_module =>l_log_module);
3128 trace
3129 (p_msg => 'source_id_char_2 = '||
3130 p_event_source_info.source_id_char_2
3131 ,p_level => C_LEVEL_PROCEDURE
3132 ,p_module =>l_log_module);
3133 trace
3134 (p_msg => 'source_id_char_3 = '||
3135 p_event_source_info.source_id_char_3
3136 ,p_level => C_LEVEL_PROCEDURE
3137 ,p_module =>l_log_module);
3138 trace
3139 (p_msg => 'source_id_char_4 = '||
3140 p_event_source_info.source_id_char_4
3141 ,p_level => C_LEVEL_PROCEDURE
3142 ,p_module =>l_log_module);
3143 trace
3144 (p_msg => 'p_event_class_code = '||p_event_class_code
3145 ,p_level => C_LEVEL_PROCEDURE
3146 ,p_module =>l_log_module);
3147 trace
3148 (p_msg => 'p_event_type_code = '||p_event_type_code
3149 ,p_level => C_LEVEL_PROCEDURE
3150 ,p_module =>l_log_module);
3151 trace
3152 (p_msg => 'p_event_date = '||p_event_date
3153 ,p_level => C_LEVEL_PROCEDURE
3154 ,p_module =>l_log_module);
3155 trace
3156 (p_msg => 'security_id_int_1 = '||
3157 xla_events_pub_pkg.g_security.security_id_int_1
3158 ,p_level => C_LEVEL_PROCEDURE
3159 ,p_module =>l_log_module);
3160 trace
3161 (p_msg => 'security_id_int_2 = '||
3162 xla_events_pub_pkg.g_security.security_id_int_2
3163 ,p_level => C_LEVEL_PROCEDURE
3164 ,p_module =>l_log_module);
3165 trace
3166 (p_msg => 'security_id_int_3 = '||
3167 xla_events_pub_pkg.g_security.security_id_int_3
3168 ,p_level => C_LEVEL_PROCEDURE
3169 ,p_module =>l_log_module);
3170 trace
3171 (p_msg => 'security_id_char_1 = '||
3172 xla_events_pub_pkg.g_security.security_id_char_1
3173 ,p_level => C_LEVEL_PROCEDURE
3174 ,p_module =>l_log_module);
3175 trace
3176 (p_msg => 'security_id_char_2 = '||
3177 xla_events_pub_pkg.g_security.security_id_char_2
3178 ,p_level => C_LEVEL_PROCEDURE
3179 ,p_module =>l_log_module);
3180 trace
3181 (p_msg => 'security_id_char_3 = '||
3182 xla_events_pub_pkg.g_security.security_id_char_3
3183 ,p_level => C_LEVEL_PROCEDURE
3184 ,p_module =>l_log_module);
3185 trace
3186 (p_msg => 'valuation_method = '||p_valuation_method
3187 ,p_level => C_LEVEL_PROCEDURE
3188 ,p_module =>l_log_module);
3189 END IF;
3190
3191 SAVEPOINT before_event_delete;
3192 g_action := C_EVENT_DELETE;
3193
3194 ----------------------------------------------------------------------------
3195 -- Following sets the Security Context for the execution. This enables the
3196 -- event API to respect the transaction security.
3197 ----------------------------------------------------------------------------
3198 xla_security_pkg.set_security_context(p_event_source_info.application_id);
3199
3200 ----------------------------------------------------------------------------
3201 -- check to see the API is not called for manual events
3202 ----------------------------------------------------------------------------
3203 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
3204 xla_exceptions_pkg.raise_message
3205 (p_appli_s_name => 'XLA'
3206 ,p_msg_name => 'XLA_COMMON_ERROR'
3207 ,p_token_1 => 'ERROR'
3208 ,p_value_1 => 'For MANUAL events this API cannot be called'
3209 ,p_token_2 => 'LOCATION'
3210 ,p_value_2 => 'xla_events_pkg.delete_events');
3211 ELSE
3212 g_context := C_REGULAR_EVENT_CONTEXT;
3213 END IF;
3214
3215 ----------------------------------------------------------------------------
3216 -- truncate date
3217 ----------------------------------------------------------------------------
3218 l_event_date := TRUNC(p_event_date);
3219
3220 ----------------------------------------------------------------------------
3221 -- Validate parameters
3222 ----------------------------------------------------------------------------
3223 validate_params
3224 (p_source_info => p_event_source_info
3225 ,p_event_class_code => p_event_class_code
3226 ,p_event_type_code => p_event_type_code);
3227
3228 ----------------------------------------------------------------------------
3229 -- Get document PK
3230 ----------------------------------------------------------------------------
3231 cache_entity_info
3232 (p_source_info => p_event_source_info
3233 ,p_valuation_method => p_valuation_method
3234 ,p_event_id => NULL);
3235
3236 ----------------------------------------------------------------------------
3237 -- Check entity existency
3238 ----------------------------------------------------------------------------
3239 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3240 trace
3241 (p_msg => 'g_entity_id = '||g_entity_id
3242 ,p_level => C_LEVEL_STATEMENT
3243 ,p_module =>l_log_module);
3244 END IF;
3245
3246 IF g_entity_id IS NULL THEN
3247 xla_exceptions_pkg.raise_message
3248 (p_appli_s_name => 'XLA'
3249 ,p_msg_name => 'XLA_COMMON_ERROR'
3250 ,p_token_1 => 'ERROR'
3251 ,p_value_1 => 'No event exists for the document represented '||
3252 'by the given source information.'
3253 ,p_token_2 => 'LOCATION'
3254 ,p_value_2 => 'xla_events_pkg.delete_events (fn)');
3255 END IF;
3256
3257 ----------------------------------------------------------------------------
3258 -- Fetching event ids for the events that are going to be deleted
3259 ----------------------------------------------------------------------------
3260 begin
3261 if(g_gapless_flag='N') then
3262 SELECT event_id BULK COLLECT
3263 INTO l_array_events
3264 FROM xla_events
3265 WHERE event_date = NVL(l_event_date, event_date)
3266 AND event_status_code <> xla_events_pub_pkg.C_EVENT_PROCESSED
3267 AND event_type_code = NVL(p_event_type_code, event_type_code)
3268 AND entity_id = g_entity_id
3269 AND application_id = g_application_id -- 8967771
3270 AND event_type_code IN
3271 (SELECT event_type_code
3272 FROM xla_event_types_b
3273 WHERE application_id = g_application_id
3274 AND entity_code = g_entity_type_code
3275 AND event_class_code = NVL(p_event_class_code,
3276 event_class_code));
3277 else
3278 SELECT event_id, event_number BULK COLLECT
3279 INTO l_array_events, g_gapless_event_number
3280 FROM xla_events
3281 WHERE event_date = NVL(l_event_date, event_date)
3282 AND event_status_code <> xla_events_pub_pkg.C_EVENT_PROCESSED
3283 AND event_type_code = NVL(p_event_type_code, event_type_code)
3284 AND entity_id = g_entity_id
3285 AND application_id = g_application_id -- 8967771
3286 AND event_type_code IN
3287 (SELECT event_type_code
3288 FROM xla_event_types_b
3289 WHERE application_id = g_application_id
3290 AND entity_code = g_entity_type_code
3291 AND event_class_code = NVL(p_event_class_code,
3292 event_class_code))
3293 order by event_number;
3294 end if;
3295 exception when no_data_found then
3296 null;
3297 end;
3298
3299 ----------------------------------------------------------------------------
3300 -- Call routine to delete errors/JEs related to the event bug # 2701681
3301 ----------------------------------------------------------------------------
3302 FOR i IN 1..l_array_events.COUNT LOOP
3303 xla_journal_entries_pkg.delete_journal_entries
3304 (p_event_id => l_array_events(i)
3305 ,p_application_id => g_application_id);
3306 END LOOP;
3307
3308 ----------------------------------------------------------------------------
3309 -- Actual Delete
3310 ----------------------------------------------------------------------------
3311 FORAll i IN 1..l_array_events.COUNT
3312 DELETE xla_events
3313 WHERE event_id = l_array_events(i)
3314 AND application_id = g_application_id -- 8967771
3315 ;
3316
3317 l_event_deleted := SQL%ROWCOUNT;
3318
3319 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3320 trace
3321 (p_msg => 'Number of events deleted = '||l_event_deleted
3322 ,p_level => C_LEVEL_STATEMENT
3323 ,p_module =>l_log_module);
3324 trace
3325 (p_msg => 'g_gapless_flag = '||g_gapless_flag
3326 ,p_level => C_LEVEL_STATEMENT
3327 ,p_module =>l_log_module);
3328 END IF;
3329
3330 if(g_gapless_flag='Y' and l_event_deleted>0 ) then
3331 update xla_events
3332 set on_hold_flag='Y'
3333 where event_number>g_gapless_event_number(1)
3334 and on_hold_flag='N'
3335 and entity_id=g_entity_id
3336 AND application_id = g_application_id -- 8967771
3337 ;
3338 end if;
3339
3340
3341 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3342 trace
3343 (p_msg => 'end of procedure delete_events'
3344 ,p_level => C_LEVEL_PROCEDURE
3345 ,p_module =>l_log_module);
3346 trace
3347 (p_msg => 'return value:'||to_char(l_event_deleted)
3348 ,p_level => C_LEVEL_PROCEDURE
3349 ,p_module =>l_log_module);
3350 END IF;
3351
3352 RETURN l_event_deleted;
3353 EXCEPTION
3354 WHEN xla_exceptions_pkg.application_exception THEN
3355 ROLLBACK to SAVEPOINT before_event_delete;
3356 RAISE;
3357 WHEN OTHERS THEN
3358 ROLLBACK to SAVEPOINT before_event_delete;
3359 xla_exceptions_pkg.raise_message
3360 (p_location => 'xla_events_pkg.delete_events (fn)');
3361 END delete_events;
3362
3363
3364 --============================================================================
3365 --
3366 -- This function is used to delete one entity. It will:
3367 -- - validate input parameters
3368 -- - check if there is still event associated with the entity
3369 -- - if yes, return 1 without deletion
3370 -- - else delete entity, return 0
3371 --
3372 --============================================================================
3373
3374 FUNCTION delete_entity
3375 (p_source_info IN xla_events_pub_pkg.t_event_source_info
3376 ,p_valuation_method IN VARCHAR2)
3377 RETURN INTEGER IS
3378
3379 l_log_module VARCHAR2(240);
3380 l_temp NUMBER;
3381 l_entity_id XLA_TRANSACTION_ENTITIES.ENTITY_ID%TYPE;
3382 cursor c_existing_events is
3383 select 1
3384 from xla_events
3385 where entity_id=l_entity_id;
3386 BEGIN
3387 IF g_log_enabled THEN
3388 l_log_module := C_DEFAULT_MODULE||'.delete_entity';
3389 END IF;
3390 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3391 trace
3392 (p_msg => 'BEGIN of procedure delete_entity'
3393 ,p_level => C_LEVEL_PROCEDURE
3394 ,p_module =>l_log_module);
3395 trace
3396 (p_msg => 'source_application_id = '||
3397 p_source_info.source_application_id
3398 ,p_level => C_LEVEL_PROCEDURE
3399 ,p_module =>l_log_module);
3400 trace
3401 (p_msg => 'application_id = '||p_source_info.application_id
3402 ,p_level => C_LEVEL_PROCEDURE
3403 ,p_module =>l_log_module);
3404 trace
3405 (p_msg => 'legal_entity_id = '||p_source_info.legal_entity_id
3406 ,p_level => C_LEVEL_PROCEDURE
3407 ,p_module =>l_log_module);
3408 trace
3409 (p_msg => 'ledger_id = '||p_source_info.ledger_id
3410 ,p_level => C_LEVEL_PROCEDURE
3411 ,p_module =>l_log_module);
3412 trace
3413 (p_msg => 'entity_type_code = '||p_source_info.entity_type_code
3414 ,p_level => C_LEVEL_PROCEDURE
3415 ,p_module =>l_log_module);
3416 trace
3417 (p_msg => 'transaction_number = '||
3418 p_source_info.transaction_number
3419 ,p_level => C_LEVEL_PROCEDURE
3420 ,p_module =>l_log_module);
3421 trace
3422 (p_msg => 'source_id_int_1 = '||p_source_info.source_id_int_1
3423 ,p_level => C_LEVEL_PROCEDURE
3424 ,p_module =>l_log_module);
3425 trace
3426 (p_msg => 'source_id_int_2 = '||p_source_info.source_id_int_2
3427 ,p_level => C_LEVEL_PROCEDURE
3428 ,p_module =>l_log_module);
3429 trace
3430 (p_msg => 'source_id_int_3 = '||p_source_info.source_id_int_3
3431 ,p_level => C_LEVEL_PROCEDURE
3432 ,p_module =>l_log_module);
3433 trace
3434 (p_msg => 'source_id_int_4 = '||p_source_info.source_id_int_4
3435 ,p_level => C_LEVEL_PROCEDURE
3436 ,p_module =>l_log_module);
3437 trace
3438 (p_msg => 'source_id_char_1 = '||p_source_info.source_id_char_1
3439 ,p_level => C_LEVEL_PROCEDURE
3440 ,p_module =>l_log_module);
3441 trace
3442 (p_msg => 'source_id_char_2 = '||p_source_info.source_id_char_2
3443 ,p_level => C_LEVEL_PROCEDURE
3444 ,p_module =>l_log_module);
3445 trace
3446 (p_msg => 'source_id_char_3 = '||p_source_info.source_id_char_3
3447 ,p_level => C_LEVEL_PROCEDURE
3448 ,p_module =>l_log_module);
3449 trace
3450 (p_msg => 'source_id_char_4 = '||p_source_info.source_id_char_4
3451 ,p_level => C_LEVEL_PROCEDURE
3452 ,p_module =>l_log_module);
3453 trace
3454 (p_msg => 'security_id_int_1 = '||
3455 xla_events_pub_pkg.g_security.security_id_int_1
3456 ,p_level => C_LEVEL_PROCEDURE
3457 ,p_module =>l_log_module);
3458 trace
3459 (p_msg => 'security_id_int_2 = '||
3460 xla_events_pub_pkg.g_security.security_id_int_2
3461 ,p_level => C_LEVEL_PROCEDURE
3462 ,p_module =>l_log_module);
3463 trace
3464 (p_msg => 'security_id_int_3 = '||
3465 xla_events_pub_pkg.g_security.security_id_int_3
3466 ,p_level => C_LEVEL_PROCEDURE
3467 ,p_module =>l_log_module);
3468 trace
3469 (p_msg => 'security_id_char_1 = '||
3470 xla_events_pub_pkg.g_security.security_id_char_1
3471 ,p_level => C_LEVEL_PROCEDURE
3472 ,p_module =>l_log_module);
3473 trace
3474 (p_msg => 'security_id_char_2 = '||
3475 xla_events_pub_pkg.g_security.security_id_char_2
3476 ,p_level => C_LEVEL_PROCEDURE
3477 ,p_module =>l_log_module);
3478 trace
3479 (p_msg => 'security_id_char_3 = '||
3480 xla_events_pub_pkg.g_security.security_id_char_3
3481 ,p_level => C_LEVEL_PROCEDURE
3482 ,p_module =>l_log_module);
3483 trace
3484 (p_msg => 'valuation_method = '||p_valuation_method
3485 ,p_level => C_LEVEL_PROCEDURE
3486 ,p_module =>l_log_module);
3487 END IF;
3488
3489
3490 SAVEPOINT before_entity_delete;
3491 ----------------------------------------------------------------------------
3492 -- Following sets the Security Context for the execution. This enables the
3493 -- event API to respect the transaction security.
3494 ----------------------------------------------------------------------------
3495 xla_security_pkg.set_security_context(p_source_info.application_id);
3496
3497 ----------------------------------------------------------------------------
3498 -- Validate parameters
3499 ----------------------------------------------------------------------------
3500 validate_params
3501 (p_source_info => p_source_info);
3502
3503 BEGIN
3504 SELECT entity_id
3505 INTO l_entity_id
3506 FROM xla_transaction_entities a
3507 WHERE a.application_id = p_source_info.application_id
3508 AND a.ledger_id = p_source_info.ledger_id
3509 AND a.entity_code = p_source_info.entity_type_code
3510 AND NVL(a.source_id_int_1,-99) =
3511 NVL(p_source_info.source_id_int_1,-99) -- 8372505: Relpaced C_NUM with -99, C_CHAR with ' '.
3512 AND NVL(a.source_id_int_2,-99) =
3513 NVL(p_source_info.source_id_int_2,-99)
3514 AND NVL(a.source_id_int_3,-99) =
3515 NVL(p_source_info.source_id_int_3,-99)
3516 AND NVL(a.source_id_int_4,-99) =
3517 NVL(p_source_info.source_id_int_4,-99)
3518 AND NVL(a.source_id_char_1,' ') =
3519 NVL(p_source_info.source_id_char_1,' ')
3520 AND NVL(a.source_id_char_2,' ') =
3521 NVL(p_source_info.source_id_char_2,' ')
3522 AND NVL(a.source_id_char_3,' ') =
3523 NVL(p_source_info.source_id_char_3,' ')
3524 AND NVL(a.source_id_char_4,' ') =
3525 NVL(p_source_info.source_id_char_4,' ')
3526 AND NVL(a.valuation_method,C_CHAR) =
3527 NVL(p_valuation_method,C_CHAR)
3528 AND NVL(a.security_id_int_1,-99) =
3529 NVL(xla_events_pub_pkg.g_security.security_id_int_1,-99)
3530 AND NVL(a.security_id_int_2,-99) =
3531 NVL(xla_events_pub_pkg.g_security.security_id_int_2,-99)
3532 AND NVL(a.security_id_int_3,-99) =
3533 NVL(xla_events_pub_pkg.g_security.security_id_int_3,-99)
3534 AND NVL(a.security_id_char_1,' ') =
3535 NVL(xla_events_pub_pkg.g_security.security_id_char_1,' ')
3536 AND NVL(a.security_id_char_2,' ') =
3537 NVL(xla_events_pub_pkg.g_security.security_id_char_2,' ')
3538 AND NVL(a.security_id_char_3,' ') =
3539 NVL(xla_events_pub_pkg.g_security.security_id_char_3,' ');
3540 EXCEPTION when others then
3541 xla_exceptions_pkg.raise_message
3542 (p_appli_s_name => 'XLA'
3543 ,p_msg_name => 'XLA_COMMON_ERROR'
3544 ,p_token_1 => 'ERROR'
3545 ,p_value_1 =>
3546 'Unable to perform DELETE on the entity. The entity does not exist'
3547 ,p_token_2 => 'LOCATION'
3548 ,p_value_2 => 'xla_events_pkg.delete_entity');
3549 END;
3550
3551 OPEN c_existing_events;
3552 FETCH c_existing_events into l_temp;
3553
3554 IF c_existing_events%FOUND THEN
3555 -- there is event existing for the entity, can't delete
3556 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
3557 trace
3558 (p_msg => 'There is event existing for the entity, id:'||
3559 to_char(l_entity_id)
3560 ,p_level => C_LEVEL_STATEMENT
3561 ,p_module =>l_log_module);
3562 END IF;
3563 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3564 trace
3565 (p_msg => 'END of function delete_entity, return 1'
3566 ,p_level => C_LEVEL_PROCEDURE
3567 ,p_module =>l_log_module);
3568 END IF;
3569 CLOSE c_existing_events;
3570 RETURN 1;
3571 END IF;
3572 CLOSE c_existing_events;
3573
3574 DELETE xla_transaction_entities
3575 WHERE entity_id = l_entity_id
3576 AND application_id = p_source_info.application_id;
3577
3578 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3579 trace
3580 (p_msg => 'Number of entities deleted = '||SQL%ROWCOUNT
3581 ,p_level => C_LEVEL_STATEMENT
3582 ,p_module =>l_log_module);
3583 END IF;
3584
3585 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3586 trace
3587 (p_msg => 'END of function delete_entity, return 0'
3588 ,p_level => C_LEVEL_PROCEDURE
3589 ,p_module =>l_log_module);
3590 END IF;
3591 RETURN 0;
3592 EXCEPTION
3593 WHEN xla_exceptions_pkg.application_exception THEN
3594 ROLLBACK to SAVEPOINT before_entity_delete;
3595 RAISE;
3596 WHEN OTHERS THEN
3597 ROLLBACK to SAVEPOINT before_entity_delete;
3598 xla_exceptions_pkg.raise_message
3599 (p_location => 'xla_events_pkg.delete_entity');
3600 END delete_entity;
3601
3602 --=============================================================================
3603 --
3604 -- following is not the final code and is not tested as there is no requirement
3605 -- for purge routine, for now.
3606 --
3607 --=============================================================================
3608
3609 PROCEDURE purge_entity
3610 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info) IS
3611 BEGIN
3612 trace('> xla_events_pkg.delete_entity' , 20);
3613
3614 SAVEPOINT before_entity_delete;
3615 g_action := C_EVENT_DELETE;
3616
3617 ----------------------------------------------------------------------------
3618 -- Following sets the Security Context for the execution. This enables the
3619 -- event API to respect the transaction security.
3620 ----------------------------------------------------------------------------
3621 xla_security_pkg.set_security_context(p_event_source_info.application_id);
3622
3623 --
3624 -- Validate parameters
3625 --
3626 validate_params
3627 (p_source_info => p_event_source_info);
3628
3629 --
3630 -- Get document PK
3631 --
3632 cache_entity_info
3633 (p_source_info => p_event_source_info
3634 ,p_valuation_method => NULL
3635 ,p_event_id => NULL);
3636
3637 --
3638 -- Check entity existency
3639 --
3640 IF g_entity_id IS NULL THEN
3641 xla_exceptions_pkg.raise_message
3642 (p_appli_s_name => 'XLA'
3643 ,p_msg_name => 'XLA_COMMON_ERROR'
3644 ,p_token_1 => 'ERROR'
3645 ,p_value_1 =>
3646 'No event exists for the document represented by the given source information.'
3647 ,p_token_2 => 'LOCATION'
3648 ,p_value_2 => 'xla_events_pkg.delete_entity');
3649 END IF;
3650
3651 trace('< xla_events_pkg.delete_entity' , 20);
3652 EXCEPTION
3653 WHEN xla_exceptions_pkg.application_exception THEN
3654 ROLLBACK to SAVEPOINT before_entity_delete;
3655 RAISE;
3656 WHEN OTHERS THEN
3657 ROLLBACK to SAVEPOINT before_entity_delete;
3658 xla_exceptions_pkg.raise_message
3659 (p_location => 'xla_events_pkg.delete_entity');
3660 END purge_entity;
3661
3662
3663 --=============================================================================
3664 --
3665 --
3666 -- Changed to fix bug # 2899700.
3667 --
3668 --=============================================================================
3669
3670 FUNCTION get_event_info
3671 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
3672 ,p_valuation_method IN VARCHAR2
3673 ,p_event_id IN INTEGER)
3674 RETURN xla_events_pub_pkg.t_event_info IS
3675
3676 l_event_info xla_events_pub_pkg.t_event_info;
3677 l_log_module VARCHAR2(240);
3678
3679 BEGIN
3680 IF g_log_enabled THEN
3681 l_log_module := C_DEFAULT_MODULE||'.get_event_info';
3682 END IF;
3683 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3684 trace
3685 (p_msg => 'BEGIN of procedure get_event_info'
3686 ,p_level => C_LEVEL_PROCEDURE
3687 ,p_module =>l_log_module);
3688 trace
3689 (p_msg => 'source_application_id = '||
3690 p_event_source_info.source_application_id
3691 ,p_level => C_LEVEL_PROCEDURE
3692 ,p_module =>l_log_module);
3693 trace
3694 (p_msg => 'application_id = '||p_event_source_info.application_id
3695 ,p_level => C_LEVEL_PROCEDURE
3696 ,p_module =>l_log_module);
3697 trace
3698 (p_msg => 'legal_entity_id = '||
3699 p_event_source_info.legal_entity_id
3700 ,p_level => C_LEVEL_PROCEDURE
3701 ,p_module =>l_log_module);
3702 trace
3703 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
3704 ,p_level => C_LEVEL_PROCEDURE
3705 ,p_module =>l_log_module);
3706 trace
3707 (p_msg => 'entity_type_code = '||
3708 p_event_source_info.entity_type_code
3709 ,p_level => C_LEVEL_PROCEDURE
3710 ,p_module =>l_log_module);
3711 trace
3712 (p_msg => 'transaction_number = '||
3713 p_event_source_info.transaction_number
3714 ,p_level => C_LEVEL_PROCEDURE
3715 ,p_module =>l_log_module);
3716 trace
3717 (p_msg => 'source_id_int_1 = '||
3718 p_event_source_info.source_id_int_1
3719 ,p_level => C_LEVEL_PROCEDURE
3720 ,p_module =>l_log_module);
3721 trace
3722 (p_msg => 'source_id_int_2 = '||
3723 p_event_source_info.source_id_int_2
3724 ,p_level => C_LEVEL_PROCEDURE
3725 ,p_module =>l_log_module);
3726 trace
3727 (p_msg => 'source_id_int_3 = '||
3728 p_event_source_info.source_id_int_3
3729 ,p_level => C_LEVEL_PROCEDURE
3730 ,p_module =>l_log_module);
3731 trace
3732 (p_msg => 'source_id_int_4 = '||
3733 p_event_source_info.source_id_int_4
3734 ,p_level => C_LEVEL_PROCEDURE
3735 ,p_module =>l_log_module);
3736 trace
3737 (p_msg => 'source_id_char_1 = '||
3738 p_event_source_info.source_id_char_1
3739 ,p_level => C_LEVEL_PROCEDURE
3740 ,p_module =>l_log_module);
3741 trace
3742 (p_msg => 'source_id_char_2 = '||
3743 p_event_source_info.source_id_char_2
3744 ,p_level => C_LEVEL_PROCEDURE
3745 ,p_module =>l_log_module);
3746 trace
3747 (p_msg => 'source_id_char_3 = '||
3748 p_event_source_info.source_id_char_3
3749 ,p_level => C_LEVEL_PROCEDURE
3750 ,p_module =>l_log_module);
3751 trace
3752 (p_msg => 'source_id_char_4 = '||
3753 p_event_source_info.source_id_char_4
3754 ,p_level => C_LEVEL_PROCEDURE
3755 ,p_module =>l_log_module);
3756 trace
3757 (p_msg => 'p_event_id = '||p_event_id
3758 ,p_level => C_LEVEL_PROCEDURE
3759 ,p_module =>l_log_module);
3760 trace
3761 (p_msg => 'security_id_int_1 = '||
3762 xla_events_pub_pkg.g_security.security_id_int_1
3763 ,p_level => C_LEVEL_PROCEDURE
3764 ,p_module =>l_log_module);
3765 trace
3766 (p_msg => 'security_id_int_2 = '||
3767 xla_events_pub_pkg.g_security.security_id_int_2
3768 ,p_level => C_LEVEL_PROCEDURE
3769 ,p_module =>l_log_module);
3770 trace
3771 (p_msg => 'security_id_int_3 = '||
3772 xla_events_pub_pkg.g_security.security_id_int_3
3773 ,p_level => C_LEVEL_PROCEDURE
3774 ,p_module =>l_log_module);
3775 trace
3776 (p_msg => 'security_id_char_1 = '||
3777 xla_events_pub_pkg.g_security.security_id_char_1
3778 ,p_level => C_LEVEL_PROCEDURE
3779 ,p_module =>l_log_module);
3780 trace
3781 (p_msg => 'security_id_char_2 = '||
3782 xla_events_pub_pkg.g_security.security_id_char_2
3783 ,p_level => C_LEVEL_PROCEDURE
3784 ,p_module =>l_log_module);
3785 trace
3786 (p_msg => 'security_id_char_3 = '||
3787 xla_events_pub_pkg.g_security.security_id_char_3
3788 ,p_level => C_LEVEL_PROCEDURE
3789 ,p_module =>l_log_module);
3790 trace
3791 (p_msg => 'valuation_method = '||p_valuation_method
3792 ,p_level => C_LEVEL_PROCEDURE
3793 ,p_module =>l_log_module);
3794 END IF;
3795
3796 ----------------------------------------------------------------------------
3797 -- Following sets the Security Context for the execution. This enables the
3798 -- event API to respect the transaction security.
3799 ----------------------------------------------------------------------------
3800 xla_security_pkg.set_security_context(p_event_source_info.application_id);
3801
3802 ----------------------------------------------------------------------------
3803 -- Set the right context for calling this API
3804 -- Changed to fix bug # 2899700
3805 ----------------------------------------------------------------------------
3806 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
3807 g_context := C_MANUAL_EVENT_CONTEXT;
3808 ELSE
3809 g_context := C_REGULAR_EVENT_CONTEXT;
3810 END IF;
3811
3812 g_action := C_EVENT_QUERY;
3813
3814 ----------------------------------------------------------------------------
3815 -- perform validation specific to 'get event information'
3816 ----------------------------------------------------------------------------
3817 IF p_event_id IS NULL THEN
3818 xla_exceptions_pkg.raise_message
3819 (p_appli_s_name => 'XLA'
3820 ,p_msg_name => 'XLA_COMMON_ERROR'
3821 ,p_token_1 => 'ERROR'
3822 ,p_value_1 =>
3823 'Event ID has an invalid value. It cannot have a NULL value.'
3824 ,p_token_2 => 'LOCATION'
3825 ,p_value_2 => 'xla_events_pkg.get_event_info');
3826 END IF;
3827
3828 ----------------------------------------------------------------------------
3829 -- Validate parameters
3830 ----------------------------------------------------------------------------
3831 validate_params
3832 (p_source_info => p_event_source_info);
3833
3834 ----------------------------------------------------------------------------
3835 -- Get document PK
3836 ----------------------------------------------------------------------------
3837 cache_entity_info
3838 (p_source_info => p_event_source_info
3839 ,p_valuation_method => p_valuation_method
3840 ,p_event_id => p_event_id);
3841
3842 ----------------------------------------------------------------------------
3843 -- Check entity existency
3844 ----------------------------------------------------------------------------
3845 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3846 trace
3847 (p_msg => 'g_entity_id = '||g_entity_id
3848 ,p_level => C_LEVEL_STATEMENT
3849 ,p_module =>l_log_module);
3850 END IF;
3851
3852 IF g_entity_id IS NULL THEN
3853 xla_exceptions_pkg.raise_message
3854 (p_appli_s_name => 'XLA'
3855 ,p_msg_name => 'XLA_COMMON_ERROR'
3856 ,p_token_1 => 'ERROR'
3857 ,p_value_1 => 'No event exists for the document represented '||
3858 'by the given source information.'
3859 ,p_token_2 => 'LOCATION'
3860 ,p_value_2 => 'xla_events_pkg.get_event_info');
3861 END IF;
3862
3863 SELECT event_id
3864 ,event_number
3865 ,event_type_code
3866 ,event_date
3867 ,event_status_code
3868 ,on_hold_flag
3869 ,reference_num_1
3870 ,reference_num_2
3871 ,reference_num_3
3872 ,reference_num_4
3873 ,reference_char_1
3874 ,reference_char_2
3875 ,reference_char_3
3876 ,reference_char_4
3877 ,reference_date_1
3878 ,reference_date_2
3879 ,reference_date_3
3880 ,reference_date_4
3881 INTO l_event_info.event_id
3882 ,l_event_info.event_number
3883 ,l_event_info.event_type_code
3884 ,l_event_info.event_date
3885 ,l_event_info.event_status_code
3886 ,l_event_info.on_hold_flag
3887 ,l_event_info.reference_num_1
3888 ,l_event_info.reference_num_2
3889 ,l_event_info.reference_num_3
3890 ,l_event_info.reference_num_4
3891 ,l_event_info.reference_char_1
3892 ,l_event_info.reference_char_2
3893 ,l_event_info.reference_char_3
3894 ,l_event_info.reference_char_4
3895 ,l_event_info.reference_date_1
3896 ,l_event_info.reference_date_2
3897 ,l_event_info.reference_date_3
3898 ,l_event_info.reference_date_4
3899 FROM xla_events
3900 WHERE event_id = p_event_id
3901 AND entity_id = g_entity_id
3902 AND application_id = g_application_id -- 8967771
3903 ;
3904
3905 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3906 trace
3907 (p_msg => 'end of procedure get_event_info'
3908 ,p_level => C_LEVEL_PROCEDURE
3909 ,p_module =>l_log_module);
3910 END IF;
3911
3912 RETURN (l_event_info);
3913 EXCEPTION
3914 WHEN NO_DATA_FOUND THEN
3915 xla_exceptions_pkg.raise_message
3916 (p_appli_s_name => 'XLA'
3917 ,p_msg_name => 'XLA_COMMON_ERROR'
3918 ,p_token_1 => 'ERROR'
3919 ,p_value_1 => 'The event id '||p_event_id||' does not exist'
3920 ,p_token_2 => 'LOCATION'
3921 ,p_value_2 => 'xla_events_pkg.get_event_info');
3922 WHEN xla_exceptions_pkg.application_exception THEN
3923 RAISE;
3924 WHEN OTHERS THEN
3925 xla_exceptions_pkg.raise_message
3926 (p_location => 'xla_events_pkg.get_event_info (fn)');
3927 END get_event_info;
3928
3929
3930 --=============================================================================
3931 --
3932 --
3933 --
3934 --=============================================================================
3935
3936 FUNCTION get_event_status
3937 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
3938 ,p_valuation_method IN VARCHAR2
3939 ,p_event_id IN INTEGER)
3940 RETURN VARCHAR2 IS
3941
3942 l_event_info xla_events_pub_pkg.t_event_info;
3943 l_log_module VARCHAR2(240);
3944 BEGIN
3945 IF g_log_enabled THEN
3946 l_log_module := C_DEFAULT_MODULE||'.get_event_status';
3947 END IF;
3948 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3949 trace
3950 (p_msg => 'BEGIN of procedure get_event_status'
3951 ,p_level => C_LEVEL_PROCEDURE
3952 ,p_module =>l_log_module);
3953 trace
3954 (p_msg => 'source_application_id = '||
3955 p_event_source_info.source_application_id
3956 ,p_level => C_LEVEL_PROCEDURE
3957 ,p_module =>l_log_module);
3958 trace
3959 (p_msg => 'application_id = '||p_event_source_info.application_id
3960 ,p_level => C_LEVEL_PROCEDURE
3961 ,p_module =>l_log_module);
3962 trace
3963 (p_msg => 'legal_entity_id = '||
3964 p_event_source_info.legal_entity_id
3965 ,p_level => C_LEVEL_PROCEDURE
3966 ,p_module =>l_log_module);
3967 trace
3968 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
3969 ,p_level => C_LEVEL_PROCEDURE
3970 ,p_module =>l_log_module);
3971 trace
3972 (p_msg => 'entity_type_code = '||
3973 p_event_source_info.entity_type_code
3974 ,p_level => C_LEVEL_PROCEDURE
3975 ,p_module =>l_log_module);
3976 trace
3977 (p_msg => 'transaction_number = '||
3978 p_event_source_info.transaction_number
3979 ,p_level => C_LEVEL_PROCEDURE
3980 ,p_module =>l_log_module);
3981 trace
3982 (p_msg => 'source_id_int_1 = '||
3983 p_event_source_info.source_id_int_1
3984 ,p_level => C_LEVEL_PROCEDURE
3985 ,p_module =>l_log_module);
3986 trace
3987 (p_msg => 'source_id_int_2 = '||
3988 p_event_source_info.source_id_int_2
3989 ,p_level => C_LEVEL_PROCEDURE
3990 ,p_module =>l_log_module);
3991 trace
3992 (p_msg => 'source_id_int_3 = '||
3993 p_event_source_info.source_id_int_3
3994 ,p_level => C_LEVEL_PROCEDURE
3995 ,p_module =>l_log_module);
3996 trace
3997 (p_msg => 'source_id_int_4 = '||
3998 p_event_source_info.source_id_int_4
3999 ,p_level => C_LEVEL_PROCEDURE
4000 ,p_module =>l_log_module);
4001 trace
4002 (p_msg => 'source_id_char_1 = '||
4003 p_event_source_info.source_id_char_1
4004 ,p_level => C_LEVEL_PROCEDURE
4005 ,p_module =>l_log_module);
4006 trace
4007 (p_msg => 'source_id_char_2 = '||
4008 p_event_source_info.source_id_char_2
4009 ,p_level => C_LEVEL_PROCEDURE
4010 ,p_module =>l_log_module);
4011 trace
4012 (p_msg => 'source_id_char_3 = '||
4013 p_event_source_info.source_id_char_3
4014 ,p_level => C_LEVEL_PROCEDURE
4015 ,p_module =>l_log_module);
4016 trace
4017 (p_msg => 'source_id_char_4 = '||
4018 p_event_source_info.source_id_char_4
4019 ,p_level => C_LEVEL_PROCEDURE
4020 ,p_module =>l_log_module);
4021 trace
4022 (p_msg => 'p_event_id = '||p_event_id
4023 ,p_level => C_LEVEL_PROCEDURE
4024 ,p_module =>l_log_module);
4025 trace
4026 (p_msg => 'security_id_int_1 = '||
4027 xla_events_pub_pkg.g_security.security_id_int_1
4028 ,p_level => C_LEVEL_PROCEDURE
4029 ,p_module =>l_log_module);
4030 trace
4031 (p_msg => 'security_id_int_2 = '||
4032 xla_events_pub_pkg.g_security.security_id_int_2
4033 ,p_level => C_LEVEL_PROCEDURE
4034 ,p_module =>l_log_module);
4035 trace
4036 (p_msg => 'security_id_int_3 = '||
4037 xla_events_pub_pkg.g_security.security_id_int_3
4038 ,p_level => C_LEVEL_PROCEDURE
4039 ,p_module =>l_log_module);
4040 trace
4041 (p_msg => 'security_id_char_1 = '||
4042 xla_events_pub_pkg.g_security.security_id_char_1
4043 ,p_level => C_LEVEL_PROCEDURE
4044 ,p_module =>l_log_module);
4045 trace
4046 (p_msg => 'security_id_char_2 = '||
4047 xla_events_pub_pkg.g_security.security_id_char_2
4048 ,p_level => C_LEVEL_PROCEDURE
4049 ,p_module =>l_log_module);
4050 trace
4051 (p_msg => 'security_id_char_3 = '||
4052 xla_events_pub_pkg.g_security.security_id_char_3
4053 ,p_level => C_LEVEL_PROCEDURE
4054 ,p_module =>l_log_module);
4055 trace
4056 (p_msg => 'valuation_method = '||p_valuation_method
4057 ,p_level => C_LEVEL_PROCEDURE
4058 ,p_module =>l_log_module);
4059 END IF;
4060
4061 l_event_info := get_event_info
4062 (p_event_source_info => p_event_source_info
4063 ,p_valuation_method => p_valuation_method
4064 ,p_event_id => p_event_id);
4065
4066 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4067 trace
4068 (p_msg => 'return value = '||l_event_info.event_status_code
4069 ,p_level => C_LEVEL_PROCEDURE
4070 ,p_module =>l_log_module);
4071 trace
4072 (p_msg => 'end of procedure get_event_status'
4073 ,p_level => C_LEVEL_PROCEDURE
4074 ,p_module =>l_log_module);
4075 END IF;
4076
4077 RETURN l_event_info.event_status_code;
4078 EXCEPTION
4079 WHEN xla_exceptions_pkg.application_exception THEN
4080 RAISE;
4081 WHEN OTHERS THEN
4082 xla_exceptions_pkg.raise_message
4083 (p_location => 'xla_events_pkg.get_event_status (fn)');
4084 END get_event_status ;
4085
4086
4087 --=============================================================================
4088 --
4089 --
4090 -- Changed to fix bug # 2899700. (Added parameter p_event_id)
4091 --
4092 --=============================================================================
4093
4094 FUNCTION event_exists
4095 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
4096 ,p_valuation_method IN VARCHAR2
4097 ,p_event_class_code IN VARCHAR2 DEFAULT NULL
4098 ,p_event_type_code IN VARCHAR2 DEFAULT NULL
4099 ,p_event_date IN DATE DEFAULT NULL
4100 ,p_event_status_code IN VARCHAR2 DEFAULT NULL
4101 ,p_event_number IN INTEGER DEFAULT NULL
4102 ,p_event_id IN NUMBER DEFAULT NULL) -- 8761772
4103 RETURN BOOLEAN IS
4104
4105 type t_cursor is ref cursor;
4106
4107 event_status_cur t_cursor;
4108
4109
4110 l_event_status_code VARCHAR2(1);
4111 l_event_date DATE;
4112
4113
4114
4115 v_event_status_cur_stmt VARCHAR2(8000);
4116
4117 l_evt_status_bind_array t_array_varchar;
4118 l_evt_status_bind_count INTEGER :=1 ;
4119
4120
4121 /* commented out this cursor for performance fix 13698935
4122 CURSOR c1 IS
4123 SELECT event_status_code
4124 FROM xla_events
4125 WHERE event_date = NVL(l_event_date, event_date)
4126 AND event_type_code = NVL(p_event_type_code, event_type_code)
4127 AND event_status_code = NVL(p_event_status_code, event_status_code)
4128 AND event_number = NVL(p_event_number, event_number)
4129 AND event_id = NVL(p_event_id, event_id)
4130 AND entity_id = g_entity_id
4131 AND application_id = g_application_id -- 8967771
4132 AND event_type_code IN (SELECT event_type_code
4133 FROM xla_event_types_b
4134 WHERE application_id = g_application_id
4135 AND entity_code = g_entity_type_code
4136 AND event_class_code = NVL(p_event_class_code,
4137 event_class_code));
4138 */
4139 l_log_module VARCHAR2(240);
4140 BEGIN
4141 IF g_log_enabled THEN
4142 l_log_module := C_DEFAULT_MODULE||'.event_exists';
4143 END IF;
4144 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4145 trace
4146 (p_msg => 'BEGIN of procedure event_exists'
4147 ,p_level => C_LEVEL_PROCEDURE
4148 ,p_module =>l_log_module);
4149 trace
4150 (p_msg => 'source_application_id = '||
4151 p_event_source_info.source_application_id
4152 ,p_level => C_LEVEL_PROCEDURE
4153 ,p_module =>l_log_module);
4154 trace
4155 (p_msg => 'application_id = '||p_event_source_info.application_id
4156 ,p_level => C_LEVEL_PROCEDURE
4157 ,p_module =>l_log_module);
4158 trace
4159 (p_msg => 'legal_entity_id = '||
4160 p_event_source_info.legal_entity_id
4161 ,p_level => C_LEVEL_PROCEDURE
4162 ,p_module =>l_log_module);
4163 trace
4164 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
4165 ,p_level => C_LEVEL_PROCEDURE
4166 ,p_module =>l_log_module);
4167 trace
4168 (p_msg => 'entity_type_code = '||
4169 p_event_source_info.entity_type_code
4170 ,p_level => C_LEVEL_PROCEDURE
4171 ,p_module =>l_log_module);
4172 trace
4173 (p_msg => 'transaction_number = '||
4174 p_event_source_info.transaction_number
4175 ,p_level => C_LEVEL_PROCEDURE
4176 ,p_module =>l_log_module);
4177 trace
4178 (p_msg => 'source_id_int_1 = '||
4179 p_event_source_info.source_id_int_1
4180 ,p_level => C_LEVEL_PROCEDURE
4181 ,p_module =>l_log_module);
4182 trace
4183 (p_msg => 'source_id_int_2 = '||
4184 p_event_source_info.source_id_int_2
4185 ,p_level => C_LEVEL_PROCEDURE
4186 ,p_module =>l_log_module);
4187 trace
4188 (p_msg => 'source_id_int_3 = '||
4189 p_event_source_info.source_id_int_3
4190 ,p_level => C_LEVEL_PROCEDURE
4191 ,p_module =>l_log_module);
4192 trace
4193 (p_msg => 'source_id_int_4 = '||
4194 p_event_source_info.source_id_int_4
4195 ,p_level => C_LEVEL_PROCEDURE
4196 ,p_module =>l_log_module);
4197 trace
4198 (p_msg => 'source_id_char_1 = '||
4199 p_event_source_info.source_id_char_1
4200 ,p_level => C_LEVEL_PROCEDURE
4201 ,p_module =>l_log_module);
4202 trace
4203 (p_msg => 'source_id_char_2 = '||
4204 p_event_source_info.source_id_char_2
4205 ,p_level => C_LEVEL_PROCEDURE
4206 ,p_module =>l_log_module);
4207 trace
4208 (p_msg => 'source_id_char_3 = '||
4209 p_event_source_info.source_id_char_3
4210 ,p_level => C_LEVEL_PROCEDURE
4211 ,p_module =>l_log_module);
4212 trace
4213 (p_msg => 'source_id_char_4 = '||
4214 p_event_source_info.source_id_char_4
4215 ,p_level => C_LEVEL_PROCEDURE
4216 ,p_module =>l_log_module);
4217 trace
4218 (p_msg => 'p_event_class_code = '||p_event_class_code
4219 ,p_level => C_LEVEL_PROCEDURE
4220 ,p_module =>l_log_module);
4221 trace
4222 (p_msg => 'p_event_type_code = '||p_event_type_code
4223 ,p_level => C_LEVEL_PROCEDURE
4224 ,p_module =>l_log_module);
4225 trace
4226 (p_msg => 'p_event_date = '||p_event_date
4227 ,p_level => C_LEVEL_PROCEDURE
4228 ,p_module =>l_log_module);
4229 trace
4230 (p_msg => 'p_event_status_code = '||p_event_status_code
4231 ,p_level => C_LEVEL_PROCEDURE
4232 ,p_module =>l_log_module);
4233 trace
4234 (p_msg => 'p_event_number = '||p_event_number
4235 ,p_level => C_LEVEL_PROCEDURE
4236 ,p_module =>l_log_module);
4237 trace
4238 (p_msg => 'p_event_id = '||p_event_id
4239 ,p_level => C_LEVEL_PROCEDURE
4240 ,p_module =>l_log_module);
4241 trace
4242 (p_msg => 'security_id_int_1 = '||
4243 xla_events_pub_pkg.g_security.security_id_int_1
4244 ,p_level => C_LEVEL_PROCEDURE
4245 ,p_module =>l_log_module);
4246 trace
4247 (p_msg => 'security_id_int_2 = '||
4248 xla_events_pub_pkg.g_security.security_id_int_2
4249 ,p_level => C_LEVEL_PROCEDURE
4250 ,p_module =>l_log_module);
4251 trace
4252 (p_msg => 'security_id_int_3 = '||
4253 xla_events_pub_pkg.g_security.security_id_int_3
4254 ,p_level => C_LEVEL_PROCEDURE
4255 ,p_module =>l_log_module);
4256 trace
4257 (p_msg => 'security_id_char_1 = '||
4258 xla_events_pub_pkg.g_security.security_id_char_1
4259 ,p_level => C_LEVEL_PROCEDURE
4260 ,p_module =>l_log_module);
4261 trace
4262 (p_msg => 'security_id_char_2 = '||
4263 xla_events_pub_pkg.g_security.security_id_char_2
4264 ,p_level => C_LEVEL_PROCEDURE
4265 ,p_module =>l_log_module);
4266 trace
4267 (p_msg => 'security_id_char_3 = '||
4268 xla_events_pub_pkg.g_security.security_id_char_3
4269 ,p_level => C_LEVEL_PROCEDURE
4270 ,p_module =>l_log_module);
4271 trace
4272 (p_msg => 'valuation_method = '||p_valuation_method
4273 ,p_level => C_LEVEL_PROCEDURE
4274 ,p_module =>l_log_module);
4275 END IF;
4276
4277 ----------------------------------------------------------------------------
4278 -- Following sets the Security Context for the execution. This enables the
4279 -- event API to respect the transaction security.
4280 ----------------------------------------------------------------------------
4281 xla_security_pkg.set_security_context(p_event_source_info.application_id);
4282
4283 ----------------------------------------------------------------------------
4284 -- Set the right context for calling this API
4285 -- Changed to fix bug # 2899700
4286 ----------------------------------------------------------------------------
4287 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
4288 IF p_event_id IS NULL THEN
4289 xla_exceptions_pkg.raise_message
4290 (p_appli_s_name => 'XLA'
4291 ,p_msg_name => 'XLA_COMMON_ERROR'
4292 ,p_token_1 => 'ERROR'
4293 ,p_value_1 => 'For MANUAL events event_id cannot be NULL'
4294 ,p_token_2 => 'LOCATION'
4295 ,p_value_2 => 'xla_events_pkg.event_exists');
4296 END IF;
4297 g_context := C_MANUAL_EVENT_CONTEXT;
4298 ELSE
4299 g_context := C_REGULAR_EVENT_CONTEXT;
4300 END IF;
4301
4302 g_action := C_EVENT_QUERY;
4303
4304 ----------------------------------------------------------------------------
4305 -- truncate date
4306 ----------------------------------------------------------------------------
4307 l_event_date := TRUNC(p_event_date);
4308
4309 ----------------------------------------------------------------------------
4310 -- Validate parameters
4311 ----------------------------------------------------------------------------
4312 validate_params
4313 (p_source_info => p_event_source_info
4314 ,p_event_class_code => p_event_class_code
4315 ,p_event_type_code => p_event_type_code);
4316 -- ,p_event_status_code => p_event_status_code);
4317
4318 ----------------------------------------------------------------------------
4319 -- Get the entity info, cached in globals
4320 ----------------------------------------------------------------------------
4321 cache_entity_info
4322 (p_source_info => p_event_source_info
4323 ,p_valuation_method => p_valuation_method
4324 ,p_event_id => p_event_id);
4325
4326 ----------------------------------------------------------------------------
4327 -- Check entity existency
4328 ----------------------------------------------------------------------------
4329 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4330 trace
4331 (p_msg => 'g_entity_id = '||g_entity_id
4332 ,p_level => C_LEVEL_STATEMENT
4333 ,p_module =>l_log_module);
4334 END IF;
4335
4336 IF g_entity_id IS NULL THEN
4337
4338 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4339 trace
4340 (p_msg => 'no entity exist, return value is false'
4341 ,p_level => C_LEVEL_PROCEDURE
4342 ,p_module =>l_log_module);
4343 trace
4344 (p_msg => 'end of procedure event_exists'
4345 ,p_level => C_LEVEL_PROCEDURE
4346 ,p_module =>l_log_module);
4347 END IF;
4348 RETURN FALSE;
4349 /*
4350 xla_exceptions_pkg.raise_message
4351 (p_appli_s_name => 'XLA'
4352 ,p_msg_name => 'XLA_COMMON_ERROR'
4353 ,p_token_1 => 'ERROR'
4354 ,p_value_1 => 'No event exists for the document represented '||
4355 'by the given source information.'
4356 ,p_token_2 => 'LOCATION'
4357 ,p_value_2 => 'xla_events_pkg.event_exists (fn)');
4358 */
4359 END IF;
4360
4361
4362 -- Begin fix for bug 13698935
4363
4364 v_event_status_cur_stmt:=
4365 'SELECT event_status_code
4366 FROM xla_events
4367 WHERE entity_id = :'|| l_evt_status_bind_count;
4368 l_evt_status_bind_array(l_evt_status_bind_count):=to_char(g_entity_id);
4369 l_evt_status_bind_count := l_evt_status_bind_count + 1;
4370
4371 v_event_status_cur_stmt:=v_event_status_cur_stmt||'
4372 AND application_id =:'|| l_evt_status_bind_count;
4373 l_evt_status_bind_array(l_evt_status_bind_count):=to_char(g_application_id);
4374 l_evt_status_bind_count := l_evt_status_bind_count + 1;
4375
4376
4377 if l_event_date is not null then
4378 v_event_status_cur_stmt:=v_event_status_cur_stmt||'
4379 AND event_date = to_date(:'||l_evt_status_bind_count||')';
4380 l_evt_status_bind_array(l_evt_status_bind_count):=to_char(l_event_date);
4381 l_evt_status_bind_count := l_evt_status_bind_count + 1;
4382 end if;
4383
4384 if p_event_type_code is not null then
4385 v_event_status_cur_stmt:=v_event_status_cur_stmt||'
4386 AND event_type_code =:'||l_evt_status_bind_count;
4387 l_evt_status_bind_array(l_evt_status_bind_count):=p_event_type_code;
4388 l_evt_status_bind_count := l_evt_status_bind_count + 1;
4389 end if;
4390
4391 if p_event_status_code is not null then
4392 v_event_status_cur_stmt:=v_event_status_cur_stmt||'
4393 AND event_status_code =:'||l_evt_status_bind_count;
4394 l_evt_status_bind_array(l_evt_status_bind_count):=p_event_status_code;
4395 l_evt_status_bind_count := l_evt_status_bind_count + 1;
4396 end if;
4397
4398 if p_event_number is not null then
4399 v_event_status_cur_stmt:=v_event_status_cur_stmt||'
4400 AND event_number =:'||l_evt_status_bind_count;
4401 l_evt_status_bind_array(l_evt_status_bind_count):=to_char(p_event_number);
4402 l_evt_status_bind_count := l_evt_status_bind_count + 1;
4403 end if;
4404
4405
4406 if p_event_id is not null then
4407 v_event_status_cur_stmt:=v_event_status_cur_stmt||'
4408 AND event_id =:'||l_evt_status_bind_count;
4409 l_evt_status_bind_array(l_evt_status_bind_count):=to_char(p_event_id);
4410 l_evt_status_bind_count := l_evt_status_bind_count + 1;
4411 end if;
4412
4413
4414 v_event_status_cur_stmt:=v_event_status_cur_stmt||'
4415 AND event_type_code IN
4416 (SELECT event_type_code FROM xla_event_types_b WHERE application_id =:'||l_evt_status_bind_count;
4417 l_evt_status_bind_array(l_evt_status_bind_count):=to_char(g_application_id);
4418 l_evt_status_bind_count := l_evt_status_bind_count + 1;
4419
4420 if p_event_class_code is not null then
4421 v_event_status_cur_stmt:=v_event_status_cur_stmt||'
4422 AND event_class_code =:'||l_evt_status_bind_count;
4423 l_evt_status_bind_array(l_evt_status_bind_count):=p_event_class_code;
4424 l_evt_status_bind_count := l_evt_status_bind_count + 1;
4425 end if;
4426
4427
4428 v_event_status_cur_stmt:=v_event_status_cur_stmt||'
4429 AND entity_code =:'||l_evt_status_bind_count;
4430 l_evt_status_bind_array(l_evt_status_bind_count):=g_entity_type_code;
4431
4432 v_event_status_cur_stmt:=v_event_status_cur_stmt||' )';
4433
4434 IF (c_level_procedure >= g_log_level)
4435 THEN
4436 trace
4437 (p_msg => 'v_event_status_cur_stmt_1:'||substr(v_event_status_cur_stmt, 1, 1000)
4438 ,p_level => C_LEVEL_STATEMENT
4439 ,p_module => l_log_module);
4440 trace
4441 (p_msg => 'v_event_status_cur_stmt_2:'||substr(v_event_status_cur_stmt, 1001, 1000)
4442 ,p_level => C_LEVEL_STATEMENT
4443 ,p_module => l_log_module);
4444 trace
4445 (p_msg => 'v_event_status_cur_stmt_3:'||substr(v_event_status_cur_stmt, 2001, 1000)
4446 ,p_level => C_LEVEL_STATEMENT
4447 ,p_module => l_log_module);
4448 trace
4449 (p_msg => 'v_event_status_cur_stmt_4:'||substr(v_event_status_cur_stmt, 3001, 1000)
4450 ,p_level => C_LEVEL_STATEMENT
4451 ,p_module => l_log_module);
4452 trace
4453 (p_msg => 'v_event_status_cur_stmt_5:'||substr(v_event_status_cur_stmt, 4001, 1000)
4454 ,p_level => C_LEVEL_STATEMENT
4455 ,p_module => l_log_module);
4456 trace
4457 (p_msg => 'v_event_status_cur_stmt_6:'||substr(v_event_status_cur_stmt, 5001, 1000)
4458 ,p_level => C_LEVEL_STATEMENT
4459 ,p_module => l_log_module);
4460 trace
4461 (p_msg => 'v_event_status_cur_stmt_7:'||substr(v_event_status_cur_stmt, 6001, 999)
4462 ,p_level => C_LEVEL_STATEMENT
4463 ,p_module => l_log_module);
4464 trace
4465 (p_msg => 'l_evt_status_bind_count : '||l_evt_status_bind_count
4466 ,p_level => C_LEVEL_STATEMENT
4467 ,p_module => l_log_module);
4468 for lp_ndx in 1 .. l_evt_status_bind_count
4469 loop
4470 trace
4471 (p_msg => 'l_evt_status_bind_array('||lp_ndx||')='||l_evt_status_bind_array(lp_ndx)
4472 ,p_level => C_LEVEL_STATEMENT
4473 ,p_module => l_log_module);
4474 end loop;
4475 END IF;
4476
4477
4478 if l_evt_status_bind_count = 1 then
4479 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1);
4480
4481 elsif l_evt_status_bind_count = 2 then
4482 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1),l_evt_status_bind_array(2);
4483
4484 elsif l_evt_status_bind_count = 3 then
4485 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1),l_evt_status_bind_array(2),
4486 l_evt_status_bind_array(3);
4487
4488 elsif l_evt_status_bind_count = 4 then
4489 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1),l_evt_status_bind_array(2),
4490 l_evt_status_bind_array(3),l_evt_status_bind_array(4);
4491
4492 elsif l_evt_status_bind_count = 5 then
4493 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1),l_evt_status_bind_array(2),
4494 l_evt_status_bind_array(3),l_evt_status_bind_array(4),l_evt_status_bind_array(5);
4495
4496 elsif l_evt_status_bind_count = 6 then
4497 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1),l_evt_status_bind_array(2),
4498 l_evt_status_bind_array(3),l_evt_status_bind_array(4),l_evt_status_bind_array(5),l_evt_status_bind_array(6);
4499
4500 elsif l_evt_status_bind_count = 7 then
4501 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1),l_evt_status_bind_array(2),
4502 l_evt_status_bind_array(3),l_evt_status_bind_array(4),l_evt_status_bind_array(5),l_evt_status_bind_array(6),
4503 l_evt_status_bind_array(7);
4504
4505 elsif l_evt_status_bind_count = 8 then
4506 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1),l_evt_status_bind_array(2),
4507 l_evt_status_bind_array(3),l_evt_status_bind_array(4),l_evt_status_bind_array(5),l_evt_status_bind_array(6),
4508 l_evt_status_bind_array(7),l_evt_status_bind_array(8);
4509
4510 elsif l_evt_status_bind_count = 9 then
4511 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1),l_evt_status_bind_array(2),
4512 l_evt_status_bind_array(3),l_evt_status_bind_array(4),l_evt_status_bind_array(5),l_evt_status_bind_array(6),
4513 l_evt_status_bind_array(7),l_evt_status_bind_array(8),l_evt_status_bind_array(9);
4514
4515 elsif l_evt_status_bind_count = 10 then
4516 OPEN event_status_cur for v_event_status_cur_stmt using l_evt_status_bind_array(1),l_evt_status_bind_array(2),
4517 l_evt_status_bind_array(3),l_evt_status_bind_array(4),l_evt_status_bind_array(5),l_evt_status_bind_array(6),
4518 l_evt_status_bind_array(7),l_evt_status_bind_array(8),l_evt_status_bind_array(9),l_evt_status_bind_array(10);
4519
4520 end if;
4521
4522 FETCH event_status_cur INTO l_event_status_code;
4523
4524
4525 -- End fix for bug 13698935
4526
4527 IF event_status_cur%NOTFOUND THEN
4528 CLOSE event_status_cur; -- bug 13698935
4529
4530 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4531 trace
4532 (p_msg => 'return value is false'
4533 ,p_level => C_LEVEL_PROCEDURE
4534 ,p_module =>l_log_module);
4535 trace
4536 (p_msg => 'end of procedure event_exists'
4537 ,p_level => C_LEVEL_PROCEDURE
4538 ,p_module =>l_log_module);
4539 END IF;
4540
4541 RETURN FALSE;
4542 ELSE
4543 CLOSE event_status_cur; -- bug 13698935
4544 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4545 trace
4546 (p_msg => 'return value is true'
4547 ,p_level => C_LEVEL_PROCEDURE
4548 ,p_module =>l_log_module);
4549 trace
4550 (p_msg => 'end of procedure event_exists'
4551 ,p_level => C_LEVEL_PROCEDURE
4552 ,p_module =>l_log_module);
4553 END IF;
4554 RETURN TRUE;
4555 END IF;
4556
4557 EXCEPTION
4558 WHEN xla_exceptions_pkg.application_exception THEN
4559 IF event_status_cur%ISOPEN THEN
4560 CLOSE event_status_cur; -- bug 13698935
4561 END IF;
4562 RAISE;
4563 WHEN NO_DATA_FOUND THEN
4564 IF event_status_cur%ISOPEN THEN
4565 CLOSE event_status_cur; -- bug 13698935
4566 END IF;
4567 RETURN FALSE;
4568 WHEN OTHERS THEN
4569 IF event_status_cur%ISOPEN THEN
4570 CLOSE event_status_cur; -- bug 13698935
4571 END IF;
4572 xla_exceptions_pkg.raise_message
4573 (p_location => 'xla_events_pkg.event_exists (fn)');
4574 END event_exists;
4575
4576
4577 --=============================================================================
4578 --
4579 --
4580 -- Changed to fix bug # 2899700. (Added parameter p_event_id)
4581 --
4582 --=============================================================================
4583
4584 PROCEDURE update_transaction_number
4585 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
4586 ,p_valuation_method IN VARCHAR2
4587 ,p_transaction_number IN VARCHAR2
4588 ,p_event_id IN NUMBER DEFAULT NULL) IS -- 8761772
4589 l_log_module VARCHAR2(240);
4590 BEGIN
4591 IF g_log_enabled THEN
4592 l_log_module := C_DEFAULT_MODULE||'.update_transaction_number';
4593 END IF;
4594 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4595 trace
4596 (p_msg => 'BEGIN of procedure update_transaction_number'
4597 ,p_level => C_LEVEL_PROCEDURE
4598 ,p_module =>l_log_module);
4599 trace
4600 (p_msg => 'source_application_id = '||
4601 p_event_source_info.source_application_id
4602 ,p_level => C_LEVEL_PROCEDURE
4603 ,p_module =>l_log_module);
4604 trace
4605 (p_msg => 'application_id = '||p_event_source_info.application_id
4606 ,p_level => C_LEVEL_PROCEDURE
4607 ,p_module =>l_log_module);
4608 trace
4609 (p_msg => 'legal_entity_id = '||
4610 p_event_source_info.legal_entity_id
4611 ,p_level => C_LEVEL_PROCEDURE
4612 ,p_module =>l_log_module);
4613 trace
4614 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
4615 ,p_level => C_LEVEL_PROCEDURE
4616 ,p_module =>l_log_module);
4617 trace
4618 (p_msg => 'entity_type_code = '||
4619 p_event_source_info.entity_type_code
4620 ,p_level => C_LEVEL_PROCEDURE
4621 ,p_module =>l_log_module);
4622 trace
4623 (p_msg => 'transaction_number = '||
4624 p_event_source_info.transaction_number
4625 ,p_level => C_LEVEL_PROCEDURE
4626 ,p_module =>l_log_module);
4627 trace
4628 (p_msg => 'source_id_int_1 = '||
4629 p_event_source_info.source_id_int_1
4630 ,p_level => C_LEVEL_PROCEDURE
4631 ,p_module =>l_log_module);
4632 trace
4633 (p_msg => 'source_id_int_2 = '||
4634 p_event_source_info.source_id_int_2
4635 ,p_level => C_LEVEL_PROCEDURE
4636 ,p_module =>l_log_module);
4637 trace
4638 (p_msg => 'source_id_int_3 = '||
4639 p_event_source_info.source_id_int_3
4640 ,p_level => C_LEVEL_PROCEDURE
4641 ,p_module =>l_log_module);
4642 trace
4643 (p_msg => 'source_id_int_4 = '||
4644 p_event_source_info.source_id_int_4
4645 ,p_level => C_LEVEL_PROCEDURE
4646 ,p_module =>l_log_module);
4647 trace
4648 (p_msg => 'source_id_char_1 = '||
4649 p_event_source_info.source_id_char_1
4650 ,p_level => C_LEVEL_PROCEDURE
4651 ,p_module =>l_log_module);
4652 trace
4653 (p_msg => 'source_id_char_2 = '||
4654 p_event_source_info.source_id_char_2
4655 ,p_level => C_LEVEL_PROCEDURE
4656 ,p_module =>l_log_module);
4657 trace
4658 (p_msg => 'source_id_char_3 = '||
4659 p_event_source_info.source_id_char_3
4660 ,p_level => C_LEVEL_PROCEDURE
4661 ,p_module =>l_log_module);
4662 trace
4663 (p_msg => 'source_id_char_4 = '||
4664 p_event_source_info.source_id_char_4
4665 ,p_level => C_LEVEL_PROCEDURE
4666 ,p_module =>l_log_module);
4667 trace
4668 (p_msg => 'p_transaction_number = '||p_transaction_number
4669 ,p_level => C_LEVEL_PROCEDURE
4670 ,p_module =>l_log_module);
4671 trace
4672 (p_msg => 'p_event_id = '||p_event_id
4673 ,p_level => C_LEVEL_PROCEDURE
4674 ,p_module =>l_log_module);
4675 trace
4676 (p_msg => 'security_id_int_1 = '||
4677 xla_events_pub_pkg.g_security.security_id_int_1
4678 ,p_level => C_LEVEL_PROCEDURE
4679 ,p_module =>l_log_module);
4680 trace
4681 (p_msg => 'security_id_int_2 = '||
4682 xla_events_pub_pkg.g_security.security_id_int_2
4683 ,p_level => C_LEVEL_PROCEDURE
4684 ,p_module =>l_log_module);
4685 trace
4686 (p_msg => 'security_id_int_3 = '||
4687 xla_events_pub_pkg.g_security.security_id_int_3
4688 ,p_level => C_LEVEL_PROCEDURE
4689 ,p_module =>l_log_module);
4690 trace
4691 (p_msg => 'security_id_char_1 = '||
4692 xla_events_pub_pkg.g_security.security_id_char_1
4693 ,p_level => C_LEVEL_PROCEDURE
4694 ,p_module =>l_log_module);
4695 trace
4696 (p_msg => 'security_id_char_2 = '||
4697 xla_events_pub_pkg.g_security.security_id_char_2
4698 ,p_level => C_LEVEL_PROCEDURE
4699 ,p_module =>l_log_module);
4700 trace
4701 (p_msg => 'security_id_char_3 = '||
4702 xla_events_pub_pkg.g_security.security_id_char_3
4703 ,p_level => C_LEVEL_PROCEDURE
4704 ,p_module =>l_log_module);
4705 trace
4706 (p_msg => 'valuation_method = '||p_valuation_method
4707 ,p_level => C_LEVEL_PROCEDURE
4708 ,p_module =>l_log_module);
4709 END IF;
4710
4711 ----------------------------------------------------------------------------
4712 -- Following sets the Security Context for the execution. This enables the
4713 -- event API to respect the transaction security.
4714 ----------------------------------------------------------------------------
4715 xla_security_pkg.set_security_context(p_event_source_info.application_id);
4716
4717 ----------------------------------------------------------------------------
4718 -- Set the right context for calling this API
4719 -- Changed to fix bug # 2899700
4720 ----------------------------------------------------------------------------
4721 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
4722 IF p_event_id IS NULL THEN
4723 xla_exceptions_pkg.raise_message
4724 (p_appli_s_name => 'XLA'
4725 ,p_msg_name => 'XLA_COMMON_ERROR'
4726 ,p_token_1 => 'ERROR'
4727 ,p_value_1 => 'For MANUAL events event_id cannot be NULL'
4728 ,p_token_2 => 'LOCATION'
4729 ,p_value_2 => 'xla_events_pkg.update_transaction_number');
4730 END IF;
4731 g_context := C_MANUAL_EVENT_CONTEXT;
4732 ELSE
4733 g_context := C_REGULAR_EVENT_CONTEXT;
4734 END IF;
4735
4736 g_action := C_EVENT_UPDATE;
4737
4738 ----------------------------------------------------------------------------
4739 -- Validate parameters
4740 ----------------------------------------------------------------------------
4741 validate_params
4742 (p_source_info => p_event_source_info);
4743
4744 ----------------------------------------------------------------------------
4745 -- Get the entity info, cached in globals
4746 ----------------------------------------------------------------------------
4747 cache_entity_info
4748 (p_source_info => p_event_source_info
4749 ,p_valuation_method => p_valuation_method
4750 ,p_event_id => p_event_id);
4751
4752 ----------------------------------------------------------------------------
4753 -- Check entity existency
4754 ----------------------------------------------------------------------------
4755 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4756 trace
4757 (p_msg => 'g_entity_id = '||g_entity_id
4758 ,p_level => C_LEVEL_STATEMENT
4759 ,p_module =>l_log_module);
4760 END IF;
4761
4762 IF g_entity_id IS NULL THEN
4763 xla_exceptions_pkg.raise_message
4764 (p_appli_s_name => 'XLA'
4765 ,p_msg_name => 'XLA_COMMON_ERROR'
4766 ,p_token_1 => 'ERROR'
4767 ,p_value_1 => 'No event exists for the document represented '||
4768 'by the given source information.'
4769 ,p_token_2 => 'LOCATION'
4770 ,p_value_2 => 'xla_events_pkg.update_transaction_number');
4771 END IF;
4772
4773 update_entity_trx_number
4774 (p_transaction_number => p_transaction_number);
4775
4776 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4777 trace
4778 (p_msg => 'BEGIN of procedure update_transaction_number'
4779 ,p_level => C_LEVEL_PROCEDURE
4780 ,p_module =>l_log_module);
4781 END IF;
4782
4783 EXCEPTION
4784 WHEN xla_exceptions_pkg.application_exception THEN
4785 RAISE;
4786 WHEN OTHERS THEN
4787 xla_exceptions_pkg.raise_message
4788 (p_location => 'xla_events_pkg.update_transaction_number');
4789 END update_transaction_number;
4790
4791 --============================================================================
4792 --
4793 -- This function returns TRUE if the party site for the transaction can be updated
4794 -- based on whether it has any accounted information for a Control Account.
4795 --
4796 --============================================================================
4797
4798 FUNCTION allow_third_party_update
4799 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
4800 ,p_valuation_method IN VARCHAR2)
4801 RETURN BOOLEAN IS
4802 l_log_module VARCHAR2(240);
4803 l_count NUMBER;
4804 BEGIN
4805 IF g_log_enabled THEN
4806 l_log_module := C_DEFAULT_MODULE||'.allow_third_party_update';
4807 END IF;
4808 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4809 trace
4810 (p_msg => 'BEGIN of procedure allow_third_party_update'
4811 ,p_level => C_LEVEL_PROCEDURE
4812 ,p_module =>l_log_module);
4813 trace
4814 (p_msg => 'source_application_id = '||
4815 p_event_source_info.source_application_id
4816 ,p_level => C_LEVEL_PROCEDURE
4817 ,p_module =>l_log_module);
4818 trace
4819 (p_msg => 'application_id = '||p_event_source_info.application_id
4820 ,p_level => C_LEVEL_PROCEDURE
4821 ,p_module =>l_log_module);
4822 trace
4823 (p_msg => 'legal_entity_id = '||
4824 p_event_source_info.legal_entity_id
4825 ,p_level => C_LEVEL_PROCEDURE
4826 ,p_module =>l_log_module);
4827 trace
4828 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
4829 ,p_level => C_LEVEL_PROCEDURE
4830 ,p_module =>l_log_module);
4831 trace
4832 (p_msg => 'entity_type_code = '||
4833 p_event_source_info.entity_type_code
4834 ,p_level => C_LEVEL_PROCEDURE
4835 ,p_module =>l_log_module);
4836 trace
4837 (p_msg => 'transaction_number = '||
4838 p_event_source_info.transaction_number
4839 ,p_level => C_LEVEL_PROCEDURE
4840 ,p_module =>l_log_module);
4841 trace
4842 (p_msg => 'source_id_int_1 = '||
4843 p_event_source_info.source_id_int_1
4844 ,p_level => C_LEVEL_PROCEDURE
4845 ,p_module =>l_log_module);
4846 trace
4847 (p_msg => 'source_id_int_2 = '||
4848 p_event_source_info.source_id_int_2
4849 ,p_level => C_LEVEL_PROCEDURE
4850 ,p_module =>l_log_module);
4851 trace
4852 (p_msg => 'source_id_int_3 = '||
4853 p_event_source_info.source_id_int_3
4854 ,p_level => C_LEVEL_PROCEDURE
4855 ,p_module =>l_log_module);
4856 trace
4857 (p_msg => 'source_id_int_4 = '||
4858 p_event_source_info.source_id_int_4
4859 ,p_level => C_LEVEL_PROCEDURE
4860 ,p_module =>l_log_module);
4861 trace
4862 (p_msg => 'source_id_char_1 = '||
4863 p_event_source_info.source_id_char_1
4864 ,p_level => C_LEVEL_PROCEDURE
4865 ,p_module =>l_log_module);
4866 trace
4867 (p_msg => 'source_id_char_2 = '||
4868 p_event_source_info.source_id_char_2
4869 ,p_level => C_LEVEL_PROCEDURE
4870 ,p_module =>l_log_module);
4871 trace
4872 (p_msg => 'source_id_char_3 = '||
4873 p_event_source_info.source_id_char_3
4874 ,p_level => C_LEVEL_PROCEDURE
4875 ,p_module =>l_log_module);
4876 trace
4877 (p_msg => 'source_id_char_4 = '||
4878 p_event_source_info.source_id_char_4
4879 ,p_level => C_LEVEL_PROCEDURE
4880 ,p_module =>l_log_module);
4881 trace
4882 (p_msg => 'security_id_int_1 = '||
4883 xla_events_pub_pkg.g_security.security_id_int_1
4884 ,p_level => C_LEVEL_PROCEDURE
4885 ,p_module =>l_log_module);
4886 trace
4887 (p_msg => 'security_id_int_2 = '||
4888 xla_events_pub_pkg.g_security.security_id_int_2
4889 ,p_level => C_LEVEL_PROCEDURE
4890 ,p_module =>l_log_module);
4891 trace
4892 (p_msg => 'security_id_int_3 = '||
4893 xla_events_pub_pkg.g_security.security_id_int_3
4894 ,p_level => C_LEVEL_PROCEDURE
4895 ,p_module =>l_log_module);
4896 trace
4897 (p_msg => 'security_id_char_1 = '||
4898 xla_events_pub_pkg.g_security.security_id_char_1
4899 ,p_level => C_LEVEL_PROCEDURE
4900 ,p_module =>l_log_module);
4901 trace
4902 (p_msg => 'security_id_char_2 = '||
4903 xla_events_pub_pkg.g_security.security_id_char_2
4904 ,p_level => C_LEVEL_PROCEDURE
4905 ,p_module =>l_log_module);
4906 trace
4907 (p_msg => 'security_id_char_3 = '||
4908 xla_events_pub_pkg.g_security.security_id_char_3
4909 ,p_level => C_LEVEL_PROCEDURE
4910 ,p_module =>l_log_module);
4911 trace
4912 (p_msg => 'valuation_method = '||p_valuation_method
4913 ,p_level => C_LEVEL_PROCEDURE
4914 ,p_module =>l_log_module);
4915 END IF;
4916
4917 ----------------------------------------------------------------------------
4918 -- Following sets the Security Context for the execution. This enables the
4919 -- event API to respect the transaction security.
4920 ----------------------------------------------------------------------------
4921 xla_security_pkg.set_security_context(p_event_source_info.application_id);
4922
4923 ----------------------------------------------------------------------------
4924 -- Validate parameters
4925 ----------------------------------------------------------------------------
4926 validate_params
4927 (p_source_info => p_event_source_info);
4928
4929 ----------------------------------------------------------------------------
4930 -- Get the entity info, cached in globals
4931 ----------------------------------------------------------------------------
4932 cache_entity_info
4933 (p_source_info => p_event_source_info
4934 ,p_valuation_method => p_valuation_method
4935 ,p_event_id => null);
4936
4937 ----------------------------------------------------------------------------
4938 -- Check entity existency
4939 ----------------------------------------------------------------------------
4940 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4941 trace
4942 (p_msg => 'g_entity_id = '||g_entity_id
4943 ,p_level => C_LEVEL_STATEMENT
4944 ,p_module =>l_log_module);
4945 END IF;
4946
4947 IF g_entity_id IS NULL THEN
4948 xla_exceptions_pkg.raise_message
4949 (p_appli_s_name => 'XLA'
4950 ,p_msg_name => 'XLA_COMMON_ERROR'
4951 ,p_token_1 => 'ERROR'
4952 ,p_value_1 => 'No event exists for the document represented '||
4953 'by the given source information.'
4954 ,p_token_2 => 'LOCATION'
4955 ,p_value_2 => 'xla_events_pkg.allow_third_party_update');
4956 END IF;
4957
4958 SELECT count(1)
4959 INTO l_count
4960 FROM dual
4961 WHERE EXISTS (SELECT 1
4962 FROM xla_ae_headers xah,xla_ae_lines xal
4963 WHERE xah.application_id = g_application_id
4964 AND xah.entity_id = g_entity_id
4965 AND xah.application_id = xal.application_id
4966 AND xah.ae_header_id = xal.ae_header_id
4967 AND nvl(xal.control_balance_flag,'N') in ('P','Y'));
4968
4969 IF l_count > 0 THEN
4970
4971 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4972 trace
4973 (p_msg => 'return value is false'
4974 ,p_level => C_LEVEL_PROCEDURE
4975 ,p_module =>l_log_module);
4976 trace
4977 (p_msg => 'END of procedure allow_third_party_update'
4978 ,p_level => C_LEVEL_PROCEDURE
4979 ,p_module =>l_log_module);
4980 END IF;
4981
4982 RETURN FALSE;
4983 ELSE
4984
4985 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4986 trace
4987 (p_msg => 'return value is true'
4988 ,p_level => C_LEVEL_PROCEDURE
4989 ,p_module =>l_log_module);
4990 trace
4991 (p_msg => 'END of procedure allow_third_party_update'
4992 ,p_level => C_LEVEL_PROCEDURE
4993 ,p_module =>l_log_module);
4994 END IF;
4995
4996 RETURN TRUE;
4997 END IF;
4998
4999 EXCEPTION
5000 WHEN xla_exceptions_pkg.application_exception THEN
5001 RAISE;
5002 WHEN OTHERS THEN
5003 xla_exceptions_pkg.raise_message
5004 (p_location => 'xla_events_pkg.allow_third_party_update');
5005 END allow_third_party_update;
5006
5007
5008 --=============================================================================
5009 --
5010 --
5011 -- Changed to fix bug # 2899700. (Added parameter p_event_id)
5012 --
5013 --=============================================================================
5014
5015 FUNCTION get_entity_id
5016 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
5017 ,p_valuation_method IN VARCHAR2
5018 ,p_event_id IN NUMBER DEFAULT NULL) -- 8761772
5019 RETURN INTEGER IS
5020 l_log_module VARCHAR2(240);
5021 BEGIN
5022 IF g_log_enabled THEN
5023 l_log_module := C_DEFAULT_MODULE||'.get_entity_id';
5024 END IF;
5025 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5026 trace
5027 (p_msg => 'BEGIN of procedure get_entity_id'
5028 ,p_level => C_LEVEL_PROCEDURE
5029 ,p_module =>l_log_module);
5030 trace
5031 (p_msg => 'source_application_id = '||
5032 p_event_source_info.source_application_id
5033 ,p_level => C_LEVEL_PROCEDURE
5034 ,p_module =>l_log_module);
5035 trace
5036 (p_msg => 'application_id = '||p_event_source_info.application_id
5037 ,p_level => C_LEVEL_PROCEDURE
5038 ,p_module =>l_log_module);
5039 trace
5040 (p_msg => 'legal_entity_id = '||
5041 p_event_source_info.legal_entity_id
5042 ,p_level => C_LEVEL_PROCEDURE
5043 ,p_module =>l_log_module);
5044 trace
5045 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
5046 ,p_level => C_LEVEL_PROCEDURE
5047 ,p_module =>l_log_module);
5048 trace
5049 (p_msg => 'entity_type_code = '||
5050 p_event_source_info.entity_type_code
5051 ,p_level => C_LEVEL_PROCEDURE
5052 ,p_module =>l_log_module);
5053 trace
5054 (p_msg => 'transaction_number = '||
5055 p_event_source_info.transaction_number
5056 ,p_level => C_LEVEL_PROCEDURE
5057 ,p_module =>l_log_module);
5058 trace
5059 (p_msg => 'source_id_int_1 = '||
5060 p_event_source_info.source_id_int_1
5061 ,p_level => C_LEVEL_PROCEDURE
5062 ,p_module =>l_log_module);
5063 trace
5064 (p_msg => 'source_id_int_2 = '||
5065 p_event_source_info.source_id_int_2
5066 ,p_level => C_LEVEL_PROCEDURE
5067 ,p_module =>l_log_module);
5068 trace
5069 (p_msg => 'source_id_int_3 = '||
5070 p_event_source_info.source_id_int_3
5071 ,p_level => C_LEVEL_PROCEDURE
5072 ,p_module =>l_log_module);
5073 trace
5074 (p_msg => 'source_id_int_4 = '||
5075 p_event_source_info.source_id_int_4
5076 ,p_level => C_LEVEL_PROCEDURE
5077 ,p_module =>l_log_module);
5078 trace
5079 (p_msg => 'source_id_char_1 = '||
5080 p_event_source_info.source_id_char_1
5081 ,p_level => C_LEVEL_PROCEDURE
5082 ,p_module =>l_log_module);
5083 trace
5084 (p_msg => 'source_id_char_2 = '||
5085 p_event_source_info.source_id_char_2
5086 ,p_level => C_LEVEL_PROCEDURE
5087 ,p_module =>l_log_module);
5088 trace
5089 (p_msg => 'source_id_char_3 = '||
5090 p_event_source_info.source_id_char_3
5091 ,p_level => C_LEVEL_PROCEDURE
5092 ,p_module =>l_log_module);
5093 trace
5094 (p_msg => 'source_id_char_4 = '||
5095 p_event_source_info.source_id_char_4
5096 ,p_level => C_LEVEL_PROCEDURE
5097 ,p_module =>l_log_module);
5098 trace
5099 (p_msg => 'p_event_id = '||p_event_id
5100 ,p_level => C_LEVEL_PROCEDURE
5101 ,p_module =>l_log_module);
5102 trace
5103 (p_msg => 'security_id_int_1 = '||
5104 xla_events_pub_pkg.g_security.security_id_int_1
5105 ,p_level => C_LEVEL_PROCEDURE
5106 ,p_module =>l_log_module);
5107 trace
5108 (p_msg => 'security_id_int_2 = '||
5109 xla_events_pub_pkg.g_security.security_id_int_2
5110 ,p_level => C_LEVEL_PROCEDURE
5111 ,p_module =>l_log_module);
5112 trace
5113 (p_msg => 'security_id_int_3 = '||
5114 xla_events_pub_pkg.g_security.security_id_int_3
5115 ,p_level => C_LEVEL_PROCEDURE
5116 ,p_module =>l_log_module);
5117 trace
5118 (p_msg => 'security_id_char_1 = '||
5119 xla_events_pub_pkg.g_security.security_id_char_1
5120 ,p_level => C_LEVEL_PROCEDURE
5121 ,p_module =>l_log_module);
5122 trace
5123 (p_msg => 'security_id_char_2 = '||
5124 xla_events_pub_pkg.g_security.security_id_char_2
5125 ,p_level => C_LEVEL_PROCEDURE
5126 ,p_module =>l_log_module);
5127 trace
5128 (p_msg => 'security_id_char_3 = '||
5129 xla_events_pub_pkg.g_security.security_id_char_3
5130 ,p_level => C_LEVEL_PROCEDURE
5131 ,p_module =>l_log_module);
5132 trace
5133 (p_msg => 'valuation_method = '||p_valuation_method
5134 ,p_level => C_LEVEL_PROCEDURE
5135 ,p_module =>l_log_module);
5136 END IF;
5137
5138 ----------------------------------------------------------------------------
5139 -- Following sets the Security Context for the execution. This enables the
5140 -- event API to respect the transaction security.
5141 ----------------------------------------------------------------------------
5142 xla_security_pkg.set_security_context(p_event_source_info.application_id);
5143
5144 ----------------------------------------------------------------------------
5145 -- Set the right context for calling this API
5146 -- Changed to fix bug # 2899700
5147 ----------------------------------------------------------------------------
5148 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
5149 IF p_event_id IS NULL THEN
5150 xla_exceptions_pkg.raise_message
5151 (p_appli_s_name => 'XLA'
5152 ,p_msg_name => 'XLA_COMMON_ERROR'
5153 ,p_token_1 => 'ERROR'
5154 ,p_value_1 => 'For MANUAL events event_id cannot be NULL'
5155 ,p_token_2 => 'LOCATION'
5156 ,p_value_2 => 'xla_events_pkg.get_entity_id');
5157 END IF;
5158 g_context := C_MANUAL_EVENT_CONTEXT;
5159 ELSE
5160 g_context := C_REGULAR_EVENT_CONTEXT;
5161 END IF;
5162
5163 ----------------------------------------------------------------------------
5164 -- Validate parameters
5165 ----------------------------------------------------------------------------
5166 validate_params
5167 (p_source_info => p_event_source_info);
5168
5169 ----------------------------------------------------------------------------
5170 -- Get the entity info, cached in globals
5171 ----------------------------------------------------------------------------
5172 cache_entity_info
5173 (p_source_info => p_event_source_info
5174 ,p_valuation_method => p_valuation_method
5175 ,p_event_id => p_event_id);
5176
5177 ----------------------------------------------------------------------------
5178 -- Check entity existency
5179 ----------------------------------------------------------------------------
5180 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5181 trace
5182 (p_msg => 'g_entity_id = '||g_entity_id
5183 ,p_level => C_LEVEL_STATEMENT
5184 ,p_module =>l_log_module);
5185 END IF;
5186
5187 IF g_entity_id IS NULL THEN
5188 xla_exceptions_pkg.raise_message
5189 (p_appli_s_name => 'XLA'
5190 ,p_msg_name => 'XLA_COMMON_ERROR'
5191 ,p_token_1 => 'ERROR'
5192 ,p_value_1 => 'No event exists for the document represented '||
5193 'by the given source information.'
5194 ,p_token_2 => 'LOCATION'
5195 ,p_value_2 => 'xla_events_pkg.get_entity_id');
5196 END IF;
5197
5198 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5199 trace
5200 (p_msg => 'end of procedure get_entity_id'
5201 ,p_level => C_LEVEL_PROCEDURE
5202 ,p_module =>l_log_module);
5203 trace
5204 (p_msg => 'return value is:'||to_char(g_entity_id)
5205 ,p_level => C_LEVEL_PROCEDURE
5206 ,p_module =>l_log_module);
5207 END IF;
5208
5209 RETURN g_entity_id;
5210 EXCEPTION
5211 WHEN xla_exceptions_pkg.application_exception THEN
5212 RAISE;
5213 WHEN OTHERS THEN
5214 xla_exceptions_pkg.raise_message
5215 (p_location => 'xla_events_pkg.get_entity_id');
5216 END get_entity_id;
5217
5218
5219 --=============================================================================
5220 --
5221 --
5222 --
5223 --
5224 --
5225 --
5226 --
5227 --
5228 --
5229 --
5230 -- Following are the public routines on which bulk public APIs
5231 -- are based.
5232 --
5233 -- 1. create_bulk_events
5234 -- 2. get_array_event_info (for an entity)
5235 --
5236 --
5237 --
5238 --
5239 --
5240 --
5241 --
5242 --
5243 --
5244 --
5245 --=============================================================================
5246 --
5247 -- For MANUAL events this API cannot be called
5248 --
5249 --=============================================================================
5250
5251 PROCEDURE create_bulk_events
5252 (p_source_application_id IN INTEGER DEFAULT NULL
5253 ,p_application_id IN INTEGER
5254 ,p_legal_entity_id IN INTEGER DEFAULT NULL
5255 ,p_ledger_id IN INTEGER
5256 ,p_entity_type_code IN VARCHAR2)
5257 IS
5258
5259 TYPE t_array_number IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
5260 TYPE t_array_char IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
5261 TYPE t_array_char_ref IS TABLE OF VARCHAR2(240) INDEX BY BINARY_INTEGER;
5262
5263 l_array_source_id_int_1 t_array_number;
5264 l_array_source_id_int_2 t_array_number;
5265 l_array_source_id_int_3 t_array_number;
5266 l_array_source_id_int_4 t_array_number;
5267 l_array_source_id_char_1 t_array_char;
5268 l_array_source_id_char_2 t_array_char;
5269 l_array_source_id_char_3 t_array_char;
5270 l_array_source_id_char_4 t_array_char;
5271 l_array_valuation_method t_array_char;
5272 l_array_security_id_int_1 t_array_number;
5273 l_array_security_id_int_2 t_array_number;
5274 l_array_security_id_int_3 t_array_number;
5275 l_array_security_id_char_1 t_array_char;
5276 l_array_security_id_char_2 t_array_char;
5277 l_array_security_id_char_3 t_array_char;
5278 l_array_source_trx_number t_array_char_ref;
5279
5280 l_array_entity_id t_array_number;
5281 l_array_event_id t_array_number;
5282
5283 l_array_event_number xla_events_pub_pkg.t_array_event_number;
5284 l_array_event_date xla_events_pub_pkg.t_array_event_date;
5285 l_array_transaction_date xla_events_pub_pkg.t_array_event_date;
5286 l_array_event_status_code xla_events_pub_pkg.t_array_event_status_code;
5287 l_last PLS_INTEGER;
5288 l_entity_id NUMBER; -- 8761772
5289 l_current_entity_id NUMBER; -- 8761772
5290 l_current_event_number NUMBER;
5291
5292 l_on_hold_flag xla_events.on_hold_flag%type:='N';
5293 l_event_count number;
5294 l_array_on_hold_flag t_on_hold_flag_tbl;
5295
5296 l_rowcount NUMBER;
5297 l_rowcount_gt NUMBER;
5298
5299 /* --bug 4526089
5300 CURSOR csr_xla_applications IS
5301 SELECT application_id
5302 FROM xla_subledgers
5303 WHERE application_id = p_source_application_id;
5304 */
5305 l_log_module VARCHAR2(240);
5306
5307 CURSOR csr_xla_event_exist IS
5308 SELECT 1
5309 FROM xla_events_int_gt;
5310
5311 CURSOR csr_xla_event_number IS
5312 SELECT 1
5313 FROM xla_events_int_gt
5314 WHERE event_number is null or event_number<1;
5315
5316 CURSOR csr_processing_gapless IS
5317 SELECT entity_id, event_id, event_number, event_status_code
5318 FROM xla_events_int_gt
5319 ORDER BY entity_id, event_number;
5320
5321 CURSOR csr_status_error is
5322 SELECT 1 from xla_events_int_gt
5323 WHERE event_status_code not in ('I', 'U', 'N');
5324
5325 CURSOR csr_event_type_error(p_entity_code VARCHAR2, p_app_id NUMBER) is
5326 SELECT 1
5327 FROM xla_events_int_gt xeg, xla_event_types_b xet
5328 WHERE xet.entity_code(+) = p_entity_code
5329 AND xet.application_id(+) = p_app_id
5330 AND xeg.event_type_code = xet.event_type_code (+)
5331 AND nvl(xet.enabled_flag, 'N') = 'N';
5332
5333 CURSOR csr_parameter_mismatch(p_entity_code VARCHAR2, p_app_id NUMBER) is
5334 SELECT 1
5335 FROM xla_events_int_gt xeg
5336 WHERE xeg.entity_code <> p_entity_code
5337 OR xeg.application_id <> p_app_id;
5338
5339 l_update_gt_string varchar2(4000);
5340 l_query_string varchar2(4000);
5341
5342 CURSOR csr_get_trx_entities is
5343 SELECT xla_transaction_entities_s.nextval
5344 ,source_id_int_1
5345 ,source_id_int_2
5346 ,source_id_int_3
5347 ,source_id_int_4
5348 ,source_id_char_1
5349 ,source_id_char_2
5350 ,source_id_char_3
5351 ,source_id_char_4
5352 ,valuation_method
5353 FROM (
5354 SELECT DISTINCT
5355 source_id_int_1
5356 ,source_id_int_2
5357 ,source_id_int_3
5358 ,source_id_int_4
5359 ,source_id_char_1
5360 ,source_id_char_2
5361 ,source_id_char_3
5362 ,source_id_char_4
5363 ,valuation_method
5364 FROM xla_events_int_gt);
5365
5366 BEGIN
5367 IF g_log_enabled THEN
5368 l_log_module := C_DEFAULT_MODULE||'.create_bulk_events';
5369 END IF;
5370
5371 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5372 trace
5373 (p_msg => 'BEGIN of procedure create_bulk_events'
5374 ,p_level => C_LEVEL_PROCEDURE
5375 ,p_module =>l_log_module);
5376 trace
5377 (p_msg => 'p_source_application_id = '||p_source_application_id
5378 ,p_level => C_LEVEL_PROCEDURE
5379 ,p_module =>l_log_module);
5380 trace
5381 (p_msg => 'p_application_id = '||p_application_id
5382 ,p_level => C_LEVEL_PROCEDURE
5383 ,p_module =>l_log_module);
5384 trace
5385 (p_msg => 'p_legal_entity_id = '||p_legal_entity_id
5386 ,p_level => C_LEVEL_PROCEDURE
5387 ,p_module =>l_log_module);
5388 trace
5389 (p_msg => 'p_ledger_id = '||p_ledger_id
5390 ,p_level => C_LEVEL_PROCEDURE
5391 ,p_module =>l_log_module);
5392 trace
5393 (p_msg => 'p_entity_type_code = '||p_entity_type_code
5394 ,p_level => C_LEVEL_PROCEDURE
5395 ,p_module =>l_log_module);
5396 END IF;
5397
5398
5399 SAVEPOINT before_event_creation;
5400 g_action := C_EVENT_CREATE;
5401
5402 ----------------------------------------------------------------------------
5403 -- Following sets the Security Context for the execution. This enables the
5404 -- event API to respect the transaction security.
5405 ----------------------------------------------------------------------------
5406 xla_security_pkg.set_security_context(p_application_id);
5407
5408 ----------------------------------------------------------------------------
5409 -- This API cannot be called for manual events.
5410 ----------------------------------------------------------------------------
5411 IF p_entity_type_code = C_MANUAL_ENTITY THEN
5412 xla_exceptions_pkg.raise_message
5413 (p_appli_s_name => 'XLA'
5414 ,p_msg_name => 'XLA_COMMON_ERROR'
5415 ,p_token_1 => 'ERROR'
5416 ,p_value_1 => 'For MANUAL events this API cannot be called'
5417 ,p_token_2 => 'LOCATION'
5418 ,p_value_2 => 'xla_events_pkg.get_array_event_info (fn)');
5419 ELSE
5420 g_context := C_REGULAR_EVENT_CONTEXT;
5421 END IF;
5422
5423 ----------------------------------------------------------------------------
5424 -- Immediately exit if the table is empty
5425 -- the l_rowcount_gt is also useful to find if there is invalid data
5426 ----------------------------------------------------------------------------
5427 select count(1) into l_rowcount_gt from xla_events_int_gt;
5428 if(l_rowcount_gt = 0) then
5429 return;
5430 end if;
5431
5432 ----------------------------------------------------------------------------
5433 -- perform source application validation
5434 ----------------------------------------------------------------------------
5435
5436 validate_context
5437 (p_application_id => p_application_id
5438 ,p_ledger_id => p_ledger_id
5439 ,p_entity_type_code => p_entity_type_code);
5440
5441 IF g_application_id IS NULL OR g_application_id <> p_application_id THEN
5442 cache_application_setup
5443 (p_application_id => p_application_id);
5444 END IF;
5445
5446 -- assign g_id_mapping which will be used to create the where clause
5447 validate_entity_type_code
5448 (p_entity_type_code => p_entity_type_code);
5449
5450 select enable_gapless_events_flag
5451 into g_gapless_flag
5452 from xla_entity_types_b
5453 where entity_code=p_entity_type_code
5454 and application_id=p_application_id;
5455
5456 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
5457 trace
5458 (p_msg => 'g_gapless_flag= '||g_gapless_flag
5459 ,p_level =>C_LEVEL_STATEMENT
5460 ,p_module =>l_log_module);
5461 END IF;
5462
5463 -- can it be moved after the insertion as well?
5464 if(g_gapless_flag='Y') then
5465 open csr_xla_event_number;
5466 fetch csr_xla_event_number into l_last;
5467 if(csr_xla_event_number%FOUND) THEN
5468 close csr_xla_event_number;
5469 xla_exceptions_pkg.raise_message
5470 (p_appli_s_name => 'XLA'
5471 ,p_msg_name => 'XLA_COMMON_ERROR'
5472 ,p_token_1 => 'ERROR'
5473 ,p_value_1 =>
5474 'Event Number must be a number greater than 0 for entities that are subject to gapless processing'
5475 ,p_token_2 => 'LOCATION'
5476 ,p_value_2 => 'xla_events_pkg.create_bulk_events');
5477 return;
5478 end if;
5479 close csr_xla_event_number;
5480 end if;
5481
5482 -- validate if the data is ok
5483 BEGIN
5484 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
5485 trace
5486 (p_msg => 'before validate data '
5487 ,p_level => C_LEVEL_STATEMENT
5488 ,p_module =>l_log_module);
5489 END IF;
5490 l_query_string :=
5491 'SELECT 1
5492 FROM dual
5493 WHERE EXISTS
5494 (SELECT 1
5495 FROM xla_events_int_gt xeg
5496 WHERE xeg.entity_code <> :1
5497 OR xeg.application_id <> :2
5498 OR xeg.event_status_code not in (''I'', ''U'', ''N'')
5499 OR xeg.event_type_code not in
5500 (SELECT event_type_code
5501 FROM xla_event_types_b
5502 WHERE application_id = :3
5503 AND entity_code = :4
5504 AND enabled_flag = ''Y'') OR '
5505 || validate_id_where_clause || ')';
5506
5507 EXECUTE IMMEDIATE l_query_string INTO l_last
5508 USING p_entity_type_code
5509 ,p_application_id
5510 ,p_application_id
5511 ,p_entity_type_code;
5512
5513 -- there is error! Do the validation to find the error.
5514 open csr_parameter_mismatch(p_entity_type_code, p_application_id);
5515 fetch csr_parameter_mismatch into l_last;
5516 if(csr_parameter_mismatch%FOUND) THEN
5517 close csr_parameter_mismatch;
5518 xla_exceptions_pkg.raise_message
5519 (p_appli_s_name => 'XLA'
5520 ,p_msg_name => 'XLA_COMMON_ERROR'
5521 ,p_token_1 => 'ERROR'
5522 ,p_value_1 =>
5523 'The parameters passed to the procedure do not match with the data in the xla_events_int_gt table'
5524 ,p_token_2 => 'LOCATION'
5525 ,p_value_2 => 'xla_events_pkg.create_bulk_events');
5526 return;
5527 end if;
5528 close csr_parameter_mismatch;
5529
5530 open csr_status_error;
5531 fetch csr_status_error into l_last;
5532 if(csr_status_error%FOUND) THEN
5533 close csr_status_error;
5534 xla_exceptions_pkg.raise_message
5535 (p_appli_s_name => 'XLA'
5536 ,p_msg_name => 'XLA_COMMON_ERROR'
5537 ,p_token_1 => 'ERROR'
5538 ,p_value_1 => 'Event status must be I, U or N'
5539 ,p_token_2 => 'LOCATION'
5540 ,p_value_2 => 'xla_events_pkg.create_bulk_events');
5541 return;
5542 end if;
5543 close csr_status_error;
5544
5545 open csr_event_type_error(p_entity_type_code, p_application_id);
5546 fetch csr_event_type_error into l_last;
5547 if(csr_event_type_error%FOUND) THEN
5548 close csr_event_type_error;
5549 xla_exceptions_pkg.raise_message
5550 (p_appli_s_name => 'XLA'
5551 ,p_msg_name => 'XLA_COMMON_ERROR'
5552 ,p_token_1 => 'ERROR'
5553 ,p_value_1 => 'Event type must be a valid event type'
5554 ,p_token_2 => 'LOCATION'
5555 ,p_value_2 => 'xla_events_pkg.create_bulk_events');
5556 return;
5557 end if;
5558 close csr_event_type_error;
5559
5560 xla_exceptions_pkg.raise_message
5561 (p_appli_s_name => 'XLA'
5562 ,p_msg_name => 'XLA_COMMON_ERROR'
5563 ,p_token_1 => 'ERROR'
5564 ,p_value_1 =>
5565 'Please check transaction ids in gt table. Mapped ids must have a not-null value, while unmapped ids cannot have value'
5566 ,p_token_2 => 'LOCATION'
5567 ,p_value_2 => 'xla_events_pkg.create_bulk_events');
5568 EXCEPTION
5569 WHEN others then
5570 --exception means the data is good
5571 null;
5572 END;
5573
5574 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
5575 trace
5576 (p_msg => 'just before insert into xla_transaction entities'
5577 ,p_level => C_LEVEL_STATEMENT
5578 ,p_module =>l_log_module);
5579 END IF;
5580
5581
5582
5583 ----------------------------------------------------------------------------
5584 -- Bug 4312353. Modified the following loop to create new entities based
5585 -- on the promary key of the transaction that includes all the internal
5586 -- source identifiers and the valuation method
5587 ----------------------------------------------------------------------------
5588
5589 OPEN csr_get_trx_entities;
5590 LOOP
5591 FETCH csr_get_trx_entities BULK COLLECT INTO
5592 l_array_entity_id
5593 ,l_array_source_id_int_1
5594 ,l_array_source_id_int_2
5595 ,l_array_source_id_int_3
5596 ,l_array_source_id_int_4
5597 ,l_array_source_id_char_1
5598 ,l_array_source_id_char_2
5599 ,l_array_source_id_char_3
5600 ,l_array_source_id_char_4
5601 ,l_array_valuation_method
5602 LIMIT g_limit_event_size;
5603
5604 FORALL i in 1..l_array_entity_id.COUNT
5605 INSERT INTO xla_transaction_entities
5606 (entity_id
5607 ,application_id
5608 ,source_application_id
5609 ,ledger_id
5610 ,legal_entity_id
5611 ,entity_code
5612 ,transaction_number
5613 ,creation_date
5614 ,created_by
5615 ,last_update_date
5616 ,last_updated_by
5617 ,last_update_login
5618 ,valuation_method
5619 ,security_id_int_1
5620 ,security_id_int_2
5621 ,security_id_int_3
5622 ,security_id_char_1
5623 ,security_id_char_2
5624 ,security_id_char_3
5625 ,source_id_int_1
5626 ,source_id_int_2
5627 ,source_id_int_3
5628 ,source_id_int_4
5629 ,source_id_char_1
5630 ,source_id_char_2
5631 ,source_id_char_3
5632 ,source_id_char_4)
5633 (SELECT /*+ index (xe xla_events_int_gt_n1) no_expand */ -- 9674381: Added no_expand
5634 l_array_entity_id(i)
5635 , p_application_id
5636 , nvl(p_source_application_id, p_application_id)
5637 , p_ledger_id
5638 , xe.legal_entity_id /* Bug 4458604*/
5639 , p_entity_type_code
5640 , xe.transaction_number
5641 , sysdate
5642 , xla_environment_pkg.g_usr_id
5643 , sysdate
5644 , xla_environment_pkg.g_usr_id
5645 , xla_environment_pkg.g_login_id
5646 , xe.valuation_method
5647 , xe.security_id_int_1
5648 , xe.security_id_int_2
5649 , xe.security_id_int_3
5650 , xe.security_id_char_1
5651 , xe.security_id_char_2
5652 , xe.security_id_char_3
5653 , xe.source_id_int_1
5654 , xe.source_id_int_2
5655 , xe.source_id_int_3
5656 , xe.source_id_int_4
5657 , xe.source_id_char_1
5658 , xe.source_id_char_2
5659 , xe.source_id_char_3
5660 , xe.source_id_char_4
5661 FROM xla_events_int_gt xe
5662 WHERE NVL( xe.source_id_int_1,-99) = NVL(l_array_source_id_int_1(i),-99 ) -- 8967771: Relpaced C_NUM with -99
5663 AND NVL( xe.source_id_int_2,-99) = NVL(l_array_source_id_int_2(i),-99 )
5664 AND NVL( xe.source_id_int_3,-99) = NVL(l_array_source_id_int_3(i),-99 )
5665 AND NVL( xe.source_id_int_4,-99) = NVL(l_array_source_id_int_4(i),-99 )
5666 AND NVL( xe.source_id_char_1,' ') = NVL(l_array_source_id_char_1(i),' ' ) -- 8967771: Relpaced C_CHAR with ' '
5667 AND NVL( xe.source_id_char_2,' ') = NVL(l_array_source_id_char_2(i),' ' )
5668 AND NVL( xe.source_id_char_3,' ') = NVL(l_array_source_id_char_3(i),' ' )
5669 AND NVL( xe.source_id_char_4,' ') = NVL(l_array_source_id_char_4(i),' ' )
5670 AND NVL( xe.valuation_method,' ') = NVL(l_array_valuation_method(i),' ' )
5671 AND ROWNUM = 1
5672 );
5673
5674 FORALL i IN 1..l_array_entity_id.COUNT
5675 UPDATE /*+ index (xe xla_events_int_gt_n1) no_expand */ xla_events_int_gt xe -- 9674381: Added no_expand
5676 SET xe.entity_id = l_array_entity_id(i)
5677 , xe.event_id = xla_events_s.nextval
5678 WHERE NVL( xe.source_id_int_1,-99)= NVL(l_array_source_id_int_1(i),-99) -- 8967771: Relpaced C_NUM with -99
5679 AND NVL( xe.source_id_int_2,-99) = NVL(l_array_source_id_int_2(i),-99)
5680 AND NVL( xe.source_id_int_3,-99) = NVL(l_array_source_id_int_3(i),-99)
5681 AND NVL( xe.source_id_int_4,-99) = NVL(l_array_source_id_int_4(i),-99)
5682 AND NVL( xe.source_id_char_1,' ')= NVL(l_array_source_id_char_1(i),' ') -- 8967771: Relpaced C_CHAR with ' '
5683 AND NVL( xe.source_id_char_2,' ')= NVL(l_array_source_id_char_2(i),' ')
5684 AND NVL( xe.source_id_char_3,' ')= NVL(l_array_source_id_char_3(i),' ')
5685 AND NVL( xe.source_id_char_4,' ')= NVL(l_array_source_id_char_4(i),' ')
5686 AND NVL( xe.valuation_method,' ')=NVL(l_array_valuation_method(i),' ');
5687
5688 EXIT WHEN csr_get_trx_entities%NOTFOUND;
5689 END LOOP;
5690
5691
5692 IF(g_gapless_flag = 'Y') THEN
5693 open csr_processing_gapless;
5694
5695 l_current_entity_id := null;
5696 l_on_hold_flag := 'N';
5697 l_current_event_number := 1;
5698 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5699 trace
5700 (p_msg => 'Entering a loop to process the gapless on-hold flag'
5701 ,p_level => C_LEVEL_STATEMENT
5702 ,p_module =>l_log_module);
5703 END IF;
5704 LOOP
5705
5706 FETCH csr_processing_gapless
5707 BULK COLLECT INTO l_array_entity_id
5708 , l_array_event_id
5709 , l_array_event_number
5710 , l_array_event_status_code
5711 LIMIT g_limit_event_size;
5712
5713 -- next is to loop to set the on_hold_flag
5714
5715 FOR i in 1..l_array_event_id.COUNT LOOP
5716 IF(l_current_entity_id = l_array_entity_id (i)) THEN
5717 IF(l_on_hold_flag = 'N' ) THEN
5718 IF(l_current_event_number = l_array_event_number(i)) THEN
5719 l_array_on_hold_flag(i) := 'N';
5720 IF(l_array_event_status_code(i) = 'I') THEN
5721 l_on_hold_flag :='Y';
5722 ELSE
5723 l_current_event_number := l_current_event_number + 1;
5724 END IF;
5725 ELSE
5726 l_on_hold_flag :='Y';
5727 l_array_on_hold_flag(i) := 'Y';
5728 END IF;
5729 ELSE
5730 l_array_on_hold_flag(i) := 'Y';
5731 END IF;
5732 ELSE
5733 l_current_entity_id := l_array_entity_id (i);
5734 IF(l_array_event_number(i) = 1) THEN
5735 l_array_on_hold_flag(i) := 'N';
5736 IF(l_array_event_status_code(i) = 'I') THEN
5737 l_on_hold_flag :='Y';
5738 ELSE
5739 l_on_hold_flag :='N';
5740 l_current_event_number := l_current_event_number + 1;
5741 END IF;
5742 ELSE
5743 l_on_hold_flag :='Y';
5744 l_array_on_hold_flag(i) := 'Y';
5745 END IF;
5746 END IF;
5747 END LOOP;
5748
5749 FORALL i in 1..l_array_event_id.COUNT
5750 UPDATE xla_events_int_gt
5751 SET on_hold_flag = l_array_on_hold_flag(i)
5752 WHERE event_id=l_array_event_id(i);
5753
5754 EXIT when csr_processing_gapless%NOTFOUND;
5755 END LOOP;
5756
5757 CLOSE csr_processing_gapless;
5758
5759 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
5760 trace
5761 (p_msg => 'before insert into xla_events table'
5762 ,p_level => C_LEVEL_STATEMENT
5763 ,p_module =>l_log_module);
5764 END IF;
5765
5766 INSERT INTO xla_events
5767 (event_id
5768 ,application_id
5769 ,event_type_code
5770 ,entity_id
5771 ,event_number
5772 ,event_status_code
5773 ,process_status_code
5774 ,event_date
5775 ,transaction_date
5776 ,budgetary_control_flag
5777 ,creation_date
5778 ,created_by
5779 ,last_update_date
5780 ,last_updated_by
5781 ,last_update_login
5782 ,program_update_date
5783 ,program_application_id
5784 ,program_id
5785 ,request_id
5786 ,reference_num_1
5787 ,reference_num_2
5788 ,reference_num_3
5789 ,reference_num_4
5790 ,reference_char_1
5791 ,reference_char_2
5792 ,reference_char_3
5793 ,reference_char_4
5794 ,reference_date_1
5795 ,reference_date_2
5796 ,reference_date_3
5797 ,reference_date_4
5798 ,on_hold_flag)
5799 (SELECT event_id
5800 ,application_id
5801 ,event_type_code
5802 ,entity_id
5803 ,event_number
5804 ,event_status_code
5805 ,C_INTERNAL_UNPROCESSED
5806 ,TRUNC(event_date)
5807 ,nvl(transaction_date, TRUNC(event_date))
5808 ,nvl(xla_events_int_gt.budgetary_control_flag,'N')
5809 ,sysdate
5810 ,xla_environment_pkg.g_usr_id
5811 ,sysdate
5812 ,xla_environment_pkg.g_usr_id
5813 ,xla_environment_pkg.g_login_id
5814 ,sysdate
5815 ,xla_environment_pkg.g_prog_appl_id
5816 ,xla_environment_pkg.g_prog_id
5817 ,xla_environment_pkg.g_req_Id
5818 ,reference_num_1
5819 ,reference_num_2
5820 ,reference_num_3
5821 ,reference_num_4
5822 ,reference_char_1
5823 ,reference_char_2
5824 ,reference_char_3
5825 ,reference_char_4
5826 ,reference_date_1
5827 ,reference_date_2
5828 ,reference_date_3
5829 ,reference_date_4
5830 ,on_hold_flag
5831 FROM xla_events_int_gt);
5832 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5833 trace
5834 (p_msg => 'Number of events created(gapless) = '||
5835 to_char(SQL%ROWCOUNT)
5836 ,p_level => C_LEVEL_STATEMENT
5837 ,p_module =>l_log_module);
5838 END IF;
5839
5840 ELSE -- not gapless
5841 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
5842 trace
5843 (p_msg => 'before insert into xla_events table nongapless'
5844 ,p_level => C_LEVEL_STATEMENT
5845 ,p_module =>l_log_module);
5846 END IF;
5847
5848
5849 INSERT INTO xla_events
5850 (event_id
5851 ,application_id
5852 ,event_type_code
5853 ,entity_id
5854 ,event_number
5855 ,event_status_code
5856 ,process_status_code
5857 ,event_date
5858 ,transaction_date
5859 ,budgetary_control_flag
5860 ,creation_date
5861 ,created_by
5862 ,last_update_date
5863 ,last_updated_by
5864 ,last_update_login
5865 ,program_update_date
5866 ,program_application_id
5867 ,program_id
5868 ,request_id
5869 ,reference_num_1
5870 ,reference_num_2
5871 ,reference_num_3
5872 ,reference_num_4
5873 ,reference_char_1
5874 ,reference_char_2
5875 ,reference_char_3
5876 ,reference_char_4
5877 ,reference_date_1
5878 ,reference_date_2
5879 ,reference_date_3
5880 ,reference_date_4
5881 ,on_hold_flag)
5882 (SELECT event_id
5883 ,application_id
5884 ,event_type_code
5885 ,entity_id
5886 ,nvl(event_number, nvl(max(event_number)
5887 over (partition by entity_id), 0)+
5888 ROW_NUMBER() over (PARTITION BY entity_id order by event_id))
5889 ,event_status_code
5890 ,C_INTERNAL_UNPROCESSED
5891 ,TRUNC(event_date)
5892 ,nvl(transaction_date, TRUNC(event_date))
5893 ,nvl(xla_events_int_gt.budgetary_control_flag,'N')
5894 ,sysdate
5895 ,xla_environment_pkg.g_usr_id
5896 ,sysdate
5897 ,xla_environment_pkg.g_usr_id
5898 ,xla_environment_pkg.g_login_id
5899 ,sysdate
5900 ,xla_environment_pkg.g_prog_appl_id
5901 ,xla_environment_pkg.g_prog_id
5902 ,xla_environment_pkg.g_req_Id
5903 ,reference_num_1
5904 ,reference_num_2
5905 ,reference_num_3
5906 ,reference_num_4
5907 ,reference_char_1
5908 ,reference_char_2
5909 ,reference_char_3
5910 ,reference_char_4
5911 ,reference_date_1
5912 ,reference_date_2
5913 ,reference_date_3
5914 ,reference_date_4
5915 ,'N'
5916 FROM xla_events_int_gt);
5917 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
5918 trace
5919 (p_msg => 'Number of events created(non gapless) = '||
5920 to_char(SQL%ROWCOUNT)
5921 ,p_level => C_LEVEL_STATEMENT
5922 ,p_module =>l_log_module);
5923 END IF;
5924 END IF;
5925
5926
5927 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5928 trace
5929 (p_msg => 'end of procedure create_bulk_events'
5930 ,p_level => C_LEVEL_PROCEDURE
5931 ,p_module =>l_log_module);
5932 END IF;
5933
5934 EXCEPTION
5935 WHEN xla_exceptions_pkg.application_exception THEN
5936 ROLLBACK to SAVEPOINT before_event_creation;
5937 RAISE;
5938 WHEN OTHERS THEN
5939 ROLLBACK to SAVEPOINT before_event_creation;
5940 xla_exceptions_pkg.raise_message
5941 (p_location => 'xla_events_pkg.create_bulk_events(blk)');
5942 END create_bulk_events;
5943
5944 --==================================================================
5945 --
5946 -- create_bulk_events
5947 -- Overloaded procedure to pass additional parameter to pass the limit size
5948 --
5949 --==================================================================
5950 PROCEDURE create_bulk_events
5951 (p_source_application_id IN INTEGER DEFAULT NULL
5952 ,p_application_id IN INTEGER
5953 ,p_legal_entity_id IN INTEGER DEFAULT NULL
5954 ,p_ledger_id IN INTEGER
5955 ,p_entity_type_code IN VARCHAR2
5956 ,p_limit_size IN INTEGER )
5957 IS
5958 l_log_module VARCHAR2(240);
5959 begin
5960
5961 IF g_log_enabled THEN
5962 l_log_module := C_DEFAULT_MODULE||'.create_bulk_events';
5963 END IF;
5964
5965 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5966 trace
5967 (p_msg => 'BEGIN of procedure create_bulk_events'
5968 ,p_level => C_LEVEL_PROCEDURE
5969 ,p_module =>l_log_module);
5970 trace
5971 (p_msg => 'p_source_application_id = '||p_source_application_id
5972 ,p_level => C_LEVEL_PROCEDURE
5973 ,p_module =>l_log_module);
5974 trace
5975 (p_msg => 'p_application_id = '||p_application_id
5976 ,p_level => C_LEVEL_PROCEDURE
5977 ,p_module =>l_log_module);
5978 trace
5979 (p_msg => 'p_legal_entity_id = '||p_legal_entity_id
5980 ,p_level => C_LEVEL_PROCEDURE
5981 ,p_module =>l_log_module);
5982 trace
5983 (p_msg => 'p_ledger_id = '||p_ledger_id
5984 ,p_level => C_LEVEL_PROCEDURE
5985 ,p_module =>l_log_module);
5986 trace
5987 (p_msg => 'p_entity_type_code = '||p_entity_type_code
5988 ,p_level => C_LEVEL_PROCEDURE
5989 ,p_module =>l_log_module);
5990 trace
5991 (p_msg => 'p_limit_size = '||p_limit_size
5992 ,p_level => C_LEVEL_PROCEDURE
5993 ,p_module =>l_log_module);
5994 END IF;
5995
5996
5997 if (p_limit_size < 2000 or p_limit_size is null) then
5998 g_limit_event_size := 2000;
5999 else
6000 g_limit_event_size := p_limit_size;
6001 end if;
6002
6003 create_bulk_events
6004 (p_source_application_id=> p_source_application_id
6005 ,p_application_id => p_application_id
6006 ,p_legal_entity_id => p_legal_entity_id
6007 ,p_ledger_id => p_ledger_id
6008 ,p_entity_type_code => p_entity_type_code);
6009
6010 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6011 trace
6012 (p_msg => 'end of procedure create_bulk_events'
6013 ,p_level => C_LEVEL_PROCEDURE
6014 ,p_module =>l_log_module);
6015 END IF;
6016
6017 EXCEPTION
6018 WHEN xla_exceptions_pkg.application_exception THEN
6019 RAISE;
6020 WHEN OTHERS THEN
6021 xla_exceptions_pkg.raise_message
6022 (p_location => 'xla_events_pkg.create_bulk_events(blk)');
6023 END create_bulk_events;
6024
6025
6026
6027
6028
6029 --=============================================================================
6030 --
6031 --
6032 --
6033 --=============================================================================
6034
6035 PROCEDURE update_bulk_event_statuses(p_application_id INTEGER)
6036 IS
6037
6038 TYPE t_array_number IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
6039
6040 l_array_entity_id t_array_number;
6041 l_array_event_id t_array_number;
6042 l_array_event_number xla_events_pub_pkg.t_array_event_number;
6043 l_array_event_status_code xla_events_pub_pkg.t_array_event_status_code;
6044
6045 l_array_on_hold_flag t_on_hold_flag_tbl;
6046
6047 l_log_module VARCHAR2(240);
6048 l_rowcount_gt PLS_INTEGER;
6049 l_current_event_number xla_events.event_number%TYPE;
6050 l_current_entity_id NUMBER; -- 8761772
6051 l_application_id PLS_INTEGER;
6052 l_on_hold_flag xla_events.on_hold_flag%TYPE;
6053
6054 -- This cursor will check
6055 -- 1. the application_id, entity_code, event_id is not null
6056 -- 2. the old and new event_status_code is valid
6057 -- 3. no manual entity events are modified
6058 -- 4. application_id is populated and all equals p_application_id
6059 CURSOR csr_manual_processed_events(app_id NUMBER) is
6060 SELECT 1
6061 FROM xla_events_int_gt xeg, xla_events xe, xla_entity_types_b xet
6062 WHERE xeg.application_id = xe.application_id (+)
6063 AND xeg.event_id = xe.event_id (+)
6064 AND xeg.entity_code = xet.entity_code (+)
6065 AND xet.application_id(+) = app_id
6066 AND (xeg.entity_code = C_MANUAL_ENTITY
6067 OR xeg.event_status_code not in ('I', 'N', 'U')
6068 OR xe.event_status_code not in ('I', 'N', 'U')
6069 OR xe.application_id is null
6070 OR xe.event_id is null
6071 OR xet.entity_code is null
6072 OR xeg.application_id <> app_id);
6073
6074 CURSOR csr_invalid_app(app_id NUMBER) is
6075 SELECT 1
6076 FROM xla_events_int_gt xeg
6077 WHERE xeg.application_id <> app_id;
6078
6079 CURSOR csr_invalid_event_id(app_id NUMBER) is
6080 SELECT 1
6081 FROM xla_events_int_gt xeg, xla_events xe
6082 WHERE xeg.application_id = xe.application_id (+)
6083 AND xeg.event_id = xe.event_id (+)
6084 AND xe.event_id is null;
6085
6086 CURSOR csr_invalid_event_status(app_id NUMBER) is
6087 SELECT 1
6088 FROM xla_events_int_gt xeg, xla_events xe
6089 WHERE xeg.application_id = xe.application_id
6090 AND xeg.event_id = xe.event_id
6091 AND (xe.event_status_code not in ('I', 'N', 'U')
6092 OR xeg.event_status_code not in ('I', 'N', 'U'));
6093
6094 CURSOR csr_lock_te is
6095 SELECT xte.entity_id
6096 FROM xla_transaction_entities xte
6097 WHERE xte.application_id = p_application_id
6098 AND xte.entity_id in
6099 (SELECT entity_id
6100 FROM xla_events_int_gt xeg, xla_entity_types_b xet
6101 WHERE xeg.application_id = xet.application_id
6102 AND xeg.entity_code = xet.entity_code
6103 AND xet.enable_gapless_events_flag = 'Y')
6104 FOR UPDATE NOWAIT;
6105
6106 Cursor csr_new_gap is
6107 Select min(xe.event_number), xe.entity_id, xe.application_id
6108 From xla_events_int_gt xeg,
6109 xla_events xe,
6110 xla_entity_types_b xet
6111 Where xeg.event_id = xe.event_id
6112 And xeg.application_id = xe.application_id
6113 And xeg.entity_code = xet.entity_code
6114 And xeg.application_id = xet.application_id
6115 And xet.enable_gapless_events_flag = 'Y'
6116 And xe.event_status_code <> 'I'
6117 And xeg.event_status_code = 'I'
6118 And xe.on_hold_flag = 'N'
6119 Group by xe.entity_id, xe.application_id;
6120
6121 Cursor csr_erased_gap is
6122 Select xe.entity_id,
6123 xe.event_id,
6124 xe.event_number,
6125 nvl(xeg.event_status_code, xe.event_status_code)
6126 FROM xla_events xe, xla_events_int_gt xeg
6127 Where xe.event_id = xeg.event_id(+)
6128 And xe.entity_id in (
6129 Select xe.entity_id
6130 From xla_events_int_gt xeg,
6131 xla_events xe,
6132 xla_entity_types_b xet
6133 Where xeg.event_id = xe.event_id
6134 And xet.entity_code = xeg.entity_code
6135 And xet.application_id = xe.application_id
6136 And xet.enable_gapless_events_flag = 'Y'
6137 And xe.event_status_code = 'I'
6138 And xeg.event_status_code <> 'I'
6139 And xe.on_hold_flag = 'N')
6140 Order by entity_id, event_number;
6141
6142 l_temp number;
6143
6144 BEGIN
6145 IF g_log_enabled THEN
6146 l_log_module := C_DEFAULT_MODULE||'.update_bulk_event_statuses';
6147 END IF;
6148
6149 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6150 trace
6151 (p_msg => 'BEGIN of procedure .update_bulk_event_statuses'
6152 ,p_level => C_LEVEL_PROCEDURE
6153 ,p_module =>l_log_module);
6154 trace
6155 (p_msg => 'p_application_id = '||p_application_id
6156 ,p_level => C_LEVEL_PROCEDURE
6157 ,p_module =>l_log_module);
6158 END IF;
6159
6160 SAVEPOINT before_update_bulk_statuses;
6161 g_action := C_EVENT_UPDATE;
6162
6163 ----------------------------------------------------------------------------
6164 -- Following sets the Security Context for the execution. This enables the
6165 -- event API to respect the transaction security.
6166 ----------------------------------------------------------------------------
6167 xla_security_pkg.set_security_context(p_application_id);
6168
6169 IF g_application_id IS NULL OR g_application_id <> p_application_id THEN
6170 cache_application_setup
6171 (p_application_id => p_application_id);
6172 END IF;
6173
6174 ----------------------------------------------------------------------------
6175 -- Check if the data is valid
6176 ----------------------------------------------------------------------------
6177 open csr_manual_processed_events(p_application_id);
6178 fetch csr_manual_processed_events into l_temp;
6179 if(csr_manual_processed_events%FOUND) THEN
6180 close csr_manual_processed_events;
6181
6182 open csr_invalid_app(p_application_id);
6183 fetch csr_invalid_app into l_temp;
6184 if(csr_invalid_app%FOUND) THEN
6185 close csr_invalid_app;
6186 xla_exceptions_pkg.raise_message
6187 (p_appli_s_name => 'XLA'
6188 ,p_msg_name => 'XLA_COMMON_ERROR'
6189 ,p_token_1 => 'ERROR'
6190 ,p_value_1 =>
6191 'The parameter application_id does not match with the data in xla_events_int_gt table'
6192 ,p_token_2 => 'LOCATION'
6193 ,p_value_2 => 'xla_events_pkg.update_bulk_event_statuses(fn)');
6194 end if;
6195 close csr_invalid_app;
6196
6197 open csr_invalid_event_id(p_application_id);
6198 fetch csr_invalid_event_id into l_temp;
6199 if(csr_invalid_event_id%FOUND) THEN
6200 close csr_invalid_event_id;
6201 xla_exceptions_pkg.raise_message
6202 (p_appli_s_name => 'XLA'
6203 ,p_msg_name => 'XLA_COMMON_ERROR'
6204 ,p_token_1 => 'ERROR'
6205 ,p_value_1 => '(Application id, Event ID) is not valid'
6206 ,p_token_2 => 'LOCATION'
6207 ,p_value_2 => 'xla_events_pkg.update_bulk_event_statuses(fn)');
6208 end if;
6209 close csr_invalid_event_id;
6210
6211 open csr_invalid_event_status(p_application_id);
6212 fetch csr_invalid_event_status into l_temp;
6213 if(csr_invalid_event_status%FOUND) THEN
6214 close csr_invalid_event_status;
6215 xla_exceptions_pkg.raise_message
6216 (p_appli_s_name => 'XLA'
6217 ,p_msg_name => 'XLA_COMMON_ERROR'
6218 ,p_token_1 => 'ERROR'
6219 ,p_value_1 =>
6220 'Both the new and the old event status must be valid and cannot be P'
6221 ,p_token_2 => 'LOCATION'
6222 ,p_value_2 => 'xla_events_pkg.update_bulk_event_statuses(fn)');
6223 end if;
6224 close csr_invalid_event_status;
6225
6226 -- If reach here, must be entity code error
6227 xla_exceptions_pkg.raise_message
6228 (p_appli_s_name => 'XLA'
6229 ,p_msg_name => 'XLA_COMMON_ERROR'
6230 ,p_token_1 => 'ERROR'
6231 ,p_value_1 =>
6232 'The entity_code is not valid. Either it does not match with the event id, or it is MANUAL entity. This API cannot be called for MANUAL entity'
6233 ,p_token_2 => 'LOCATION'
6234 ,p_value_2 => 'xla_events_pkg.update_bulk_event_statuses(fn)');
6235 end if;
6236 close csr_manual_processed_events;
6237
6238
6239 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6240 trace
6241 (p_msg => 'after the validation'
6242 ,p_level => C_LEVEL_STATEMENT
6243 ,p_module =>l_log_module);
6244 END IF;
6245
6246 -- lock the entity in xla_transaction_entities table
6247 -- for the entities that require gapless processing
6248 open csr_lock_te;
6249 close csr_lock_te;
6250
6251 ----------------------------------------------------------------------------
6252 -- set the on_hold_flag to 'Y' for all the new gap generated
6253 ----------------------------------------------------------------------------
6254 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6255 trace
6256 (p_msg => 'processing the new gaps'
6257 ,p_level => C_LEVEL_STATEMENT
6258 ,p_module =>l_log_module);
6259 END IF;
6260 OPEN csr_new_gap;
6261 LOOP
6262 FETCH csr_new_gap
6263 into l_current_event_number,
6264 l_current_entity_id,
6265 l_application_id;
6266 EXIT WHEN csr_new_gap%NOTFOUND;
6267
6268 UPDATE xla_events
6269 SET on_hold_flag = 'Y'
6270 WHERE entity_id = l_current_entity_id
6271 AND event_number > l_current_event_number
6272 AND application_id = l_application_id;
6273 END LOOP;
6274 CLOSE csr_new_gap;
6275
6276
6277
6278 ----------------------------------------------------------------------------
6279 -- reset the on_hold_flag for all the existing gap elimited
6280 ----------------------------------------------------------------------------
6281 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6282 trace
6283 (p_msg => 'processing the erased gaps'
6284 ,p_level => C_LEVEL_STATEMENT
6285 ,p_module =>l_log_module);
6286 END IF;
6287 open csr_erased_gap;
6288
6289 l_current_entity_id := null;
6290 l_on_hold_flag := 'N';
6291 l_current_event_number := 1;
6292 LOOP
6293 FETCH csr_erased_gap
6294 BULK COLLECT INTO l_array_entity_id
6295 , l_array_event_id
6296 , l_array_event_number
6297 , l_array_event_status_code
6298 LIMIT g_limit_event_status_size;
6299
6300 -- next is to loop to set the on_hold_flag
6301 FOR i in 1..l_array_event_id.COUNT LOOP
6302 IF(l_current_entity_id = l_array_entity_id (i)) THEN
6303 IF(l_on_hold_flag = 'N' ) THEN
6304 IF(l_current_event_number = l_array_event_number(i)) THEN
6305 l_array_on_hold_flag(i) := 'N';
6306 IF(l_array_event_status_code(i) = 'I') THEN
6307 l_on_hold_flag :='Y';
6308 ELSE
6309 l_current_event_number := l_current_event_number + 1;
6310 END IF;
6311 ELSE
6312 l_on_hold_flag :='Y';
6313 l_array_on_hold_flag(i) := 'Y';
6314 END IF;
6315 ELSE
6316 l_array_on_hold_flag(i) := 'Y';
6317 END IF;
6318 ELSE
6319 l_current_entity_id := l_array_entity_id (i);
6320 IF(l_array_event_number(i) = 1) THEN
6321 l_array_on_hold_flag(i) := 'N';
6322 IF(l_array_event_status_code(i) = 'I') THEN
6323 l_on_hold_flag :='Y';
6324 ELSE
6325 l_on_hold_flag :='N';
6326 l_current_event_number := l_current_event_number + 1;
6327 END IF;
6328 ELSE
6329 l_on_hold_flag :='Y';
6330 l_array_on_hold_flag(i) := 'Y';
6331 END IF;
6332 END IF;
6333 END LOOP;
6334
6335 FORALL i in 1..l_array_event_id.COUNT
6336 UPDATE xla_events
6337 SET on_hold_flag = l_array_on_hold_flag(i)
6338 WHERE event_id=l_array_event_id(i)
6339 AND application_id = p_application_id -- 8967771
6340 ;
6341 EXIT when csr_erased_gap%NOTFOUND;
6342 END LOOP;
6343
6344 CLOSE csr_erased_gap;
6345
6346 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6347 trace
6348 (p_msg => 'before update the table'
6349 ,p_level => C_LEVEL_STATEMENT
6350 ,p_module =>l_log_module);
6351 END IF;
6352
6353 UPDATE xla_events xe
6354 SET xe.event_status_code = (
6355 SELECT event_status_code
6356 FROM xla_events_int_gt xeg
6357 WHERE xeg.event_id = xe.event_id),
6358 xe.process_status_code = 'U'
6359 WHERE xe.event_id in (
6360 SELECT event_id
6361 FROM xla_events_int_gt)
6362 AND xe.application_id = p_application_id -- 8967771
6363 ;
6364
6365 /* -- Maintaining the Draft balance is no more required bug 5529569
6366
6367 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6368 trace
6369 (p_msg => 'before calling massive_update'
6370 ,p_level => C_LEVEL_STATEMENT
6371 ,p_module =>l_log_module);
6372 END IF;
6373
6374 IF(NOT xla_balances_pkg.massive_update_for_events(p_application_id
6375 => p_application_id)) THEN
6376 xla_exceptions_pkg.raise_message
6377 (p_appli_s_name => 'XLA'
6378 ,p_msg_name => 'XLA_COMMON_ERROR'
6379 ,p_token_1 => 'ERROR'
6380 ,p_value_1 =>
6381 'Error in the routine that does balance reversals'
6382 ,p_token_2 => 'LOCATION'
6383 ,p_value_2 => 'xla_events_pkg.update_bulk_event_statuses');
6384 END IF;
6385 */
6386 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6387 trace
6388 (p_msg => 'before calling delete_je'
6389 ,p_level => C_LEVEL_STATEMENT
6390 ,p_module =>l_log_module);
6391 END IF;
6392 delete_je;
6393
6394 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6395 trace
6396 (p_msg => 'end of procedure update_bulk_event_statuses'
6397 ,p_level => C_LEVEL_PROCEDURE
6398 ,p_module =>l_log_module);
6399 END IF;
6400
6401 EXCEPTION
6402 WHEN xla_exceptions_pkg.application_exception THEN
6403 ROLLBACK to SAVEPOINT before_update_bulk_statuses;
6404 RAISE;
6405 WHEN OTHERS THEN
6406 ROLLBACK to SAVEPOINT before_update_bulk_statuses;
6407 xla_exceptions_pkg.raise_message
6408 (p_location => 'xla_events_pkg.update_bulk_event_statuses(blk)');
6409 END update_bulk_event_statuses;
6410
6411
6412 --==================================================================
6413 --
6414 -- update_bulk_event_statuses
6415 -- Overloaded procedure to pass additional parameter to pass the limit size
6416 --
6417 --==================================================================
6418 PROCEDURE update_bulk_event_statuses
6419 (p_application_id IN INTEGER
6420 ,p_limit_size IN INTEGER )
6421 IS
6422 BEGIN
6423 if (p_limit_size <=2000 or p_limit_size is null) then
6424 g_limit_event_status_size := 2000;
6425 else
6426 g_limit_event_status_size := p_limit_size;
6427 end if;
6428
6429
6430 update_bulk_event_statuses(p_application_id=>p_application_id);
6431
6432 EXCEPTION
6433 WHEN xla_exceptions_pkg.application_exception THEN
6434 ROLLBACK to SAVEPOINT before_update_bulk_statuses;
6435 RAISE;
6436 WHEN OTHERS THEN
6437 ROLLBACK to SAVEPOINT before_update_bulk_statuses;
6438 xla_exceptions_pkg.raise_message
6439 (p_location => 'xla_events_pkg.update_bulk_event_statuses(blk)');
6440 END update_bulk_event_statuses;
6441
6442
6443
6444 --=============================================================================
6445 --
6446 --
6447 --
6448 --=============================================================================
6449
6450 PROCEDURE delete_bulk_events(p_application_id INTEGER)
6451 IS
6452
6453 l_log_module VARCHAR2(240);
6454
6455 l_rowcount_gt PLS_INTEGER;
6456 l_event_number xla_events.event_number%TYPE;
6457 l_entity_id NUMBER; -- 8761772
6458 l_application_id PLS_INTEGER;
6459 -- This cursor will check
6460 -- 1. the application_id, entity_code, event_id is not null
6461 -- 2. the event_status_code cannot be 'P'
6462 -- 3. no manual entity events are modified
6463 -- 4. application_id is populated and all equals p_application_id
6464 CURSOR csr_manual_processed_events(app_id NUMBER) is
6465 SELECT 1
6466 FROM xla_events_int_gt xeg, xla_events xe, xla_transaction_entities xte
6467 WHERE xeg.application_id = xe.application_id (+)
6468 AND xeg.event_id = xe.event_id (+)
6469 AND xe.entity_id = xte.entity_id (+)
6470 AND xte.application_id(+) = app_id
6471 AND (xeg.entity_code = C_MANUAL_ENTITY
6472 OR xe.event_status_code not in ('I', 'N', 'U')
6473 OR xe.application_id is null
6474 OR xte.entity_code is null
6475 OR xe.event_id is null
6476 OR xeg.application_id <> app_id);
6477
6478 CURSOR csr_invalid_app(app_id NUMBER) is
6479 SELECT 1
6480 FROM xla_events_int_gt xeg
6481 WHERE xeg.application_id <> app_id;
6482
6483 CURSOR csr_invalid_event_id(app_id NUMBER) is
6484 SELECT 1
6485 FROM xla_events_int_gt xeg, xla_events xe
6486 WHERE xeg.application_id = xe.application_id (+)
6487 AND xeg.event_id = xe.event_id (+)
6488 AND xe.event_id is null;
6489
6490 CURSOR csr_invalid_event_status(app_id NUMBER) is
6491 SELECT 1
6492 FROM xla_events_int_gt xeg, xla_events xe
6493 WHERE xeg.application_id = xe.application_id
6494 AND xeg.event_id = xe.event_id
6495 AND xe.event_status_code not in ('I', 'N', 'U');
6496
6497 CURSOR csr_lock_te is
6498 SELECT xte.entity_id
6499 FROM xla_transaction_entities xte
6500 WHERE xte.application_id = p_application_id
6501 AND xte.entity_id in
6502 (SELECT entity_id
6503 FROM xla_events_int_gt xeg, xla_entity_types_b xet
6504 WHERE xeg.application_id = xet.application_id
6505 AND xeg.entity_code = xet.entity_code
6506 AND xet.enable_gapless_events_flag = 'Y')
6507 FOR UPDATE NOWAIT;
6508
6509 Cursor csr_new_gap is
6510 Select min(xe.event_number), xe.entity_id, xe.application_id
6511 From xla_events_int_gt xeg,
6512 xla_events xe,
6513 xla_entity_types_b xet
6514 Where xeg.event_id = xe.event_id
6515 And xeg.application_id = xe.application_id
6516 And xeg.entity_code = xet.entity_code
6517 And xeg.application_id = xet.application_id
6518 And xet.enable_gapless_events_flag = 'Y'
6519 And xe.event_status_code <> 'I'
6520 And xe.on_hold_flag = 'N'
6521 Group by xe.entity_id, xe.application_id;
6522
6523 l_temp number;
6524
6525 BEGIN
6526 IF g_log_enabled THEN
6527 l_log_module := C_DEFAULT_MODULE||'.delete_bulk_events';
6528 END IF;
6529
6530 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6531 trace
6532 (p_msg => 'BEGIN of procedure .update_bulk_event_statuses'
6533 ,p_level => C_LEVEL_PROCEDURE
6534 ,p_module =>l_log_module);
6535 trace
6536 (p_msg => 'p_application_id = '||p_application_id
6537 ,p_level => C_LEVEL_PROCEDURE
6538 ,p_module =>l_log_module);
6539 END IF;
6540
6541 SAVEPOINT before_delete_bulk_events;
6542 --g_action := C_EVENT_UPDATE;
6543 g_action := C_EVENT_DELETE;--Bug 10162587
6544
6545 ----------------------------------------------------------------------------
6546 -- Following sets the Security Context for the execution. This enables the
6547 -- event API to respect the transaction security.
6548 ----------------------------------------------------------------------------
6549 xla_security_pkg.set_security_context(p_application_id);
6550
6551 IF g_application_id IS NULL OR g_application_id <> p_application_id THEN
6552 cache_application_setup
6553 (p_application_id => p_application_id);
6554 END IF;
6555
6556 ----------------------------------------------------------------------------
6557 -- Check if the data is valid
6558 ----------------------------------------------------------------------------
6559 open csr_manual_processed_events(p_application_id);
6560 fetch csr_manual_processed_events into l_temp;
6561 if(csr_manual_processed_events%FOUND) THEN
6562 close csr_manual_processed_events;
6563
6564 open csr_invalid_app(p_application_id);
6565 fetch csr_invalid_app into l_temp;
6566 if(csr_invalid_app%FOUND) THEN
6567 close csr_invalid_app;
6568 xla_exceptions_pkg.raise_message
6569 (p_appli_s_name => 'XLA'
6570 ,p_msg_name => 'XLA_COMMON_ERROR'
6571 ,p_token_1 => 'ERROR'
6572 ,p_value_1 =>
6573 'The parameter application_id does not match with the data in xla_events_int_gt table'
6574 ,p_token_2 => 'LOCATION'
6575 ,p_value_2 => 'xla_events_pkg.update_bulk_event_statuses(fn)');
6576 end if;
6577 close csr_invalid_app;
6578
6579 open csr_invalid_event_id(p_application_id);
6580 fetch csr_invalid_event_id into l_temp;
6581 if(csr_invalid_event_id%FOUND) THEN
6582 close csr_invalid_event_id;
6583 xla_exceptions_pkg.raise_message
6584 (p_appli_s_name => 'XLA'
6585 ,p_msg_name => 'XLA_COMMON_ERROR'
6586 ,p_token_1 => 'ERROR'
6587 ,p_value_1 => '(Application id, Event ID) is not valid'
6588 ,p_token_2 => 'LOCATION'
6589 ,p_value_2 => 'xla_events_pkg.update_bulk_event_statuses(fn)');
6590 end if;
6591 close csr_invalid_event_id;
6592
6593 open csr_invalid_event_status(p_application_id);
6594 fetch csr_invalid_event_status into l_temp;
6595 if(csr_invalid_event_status%FOUND) THEN
6596 close csr_invalid_event_status;
6597 xla_exceptions_pkg.raise_message
6598 (p_appli_s_name => 'XLA'
6599 ,p_msg_name => 'XLA_COMMON_ERROR'
6600 ,p_token_1 => 'ERROR'
6601 ,p_value_1 =>
6602 'The events to be deleted must be in status I, N or U'
6603 ,p_token_2 => 'LOCATION'
6604 ,p_value_2 => 'xla_events_pkg.update_bulk_event_statuses(fn)');
6605 end if;
6606 close csr_invalid_event_status;
6607
6608 -- if reach here, it must be entity code problem
6609 xla_exceptions_pkg.raise_message
6610 (p_appli_s_name => 'XLA'
6611 ,p_msg_name => 'XLA_COMMON_ERROR'
6612 ,p_token_1 => 'ERROR'
6613 ,p_value_1 =>
6614 'Either the entity code does not match with the event id, or the entity code is MANUAL. This API cannot be called to delete event for MANUAL entity'
6615 ,p_token_2 => 'LOCATION'
6616 ,p_value_2 => 'xla_events_pkg.get_array_event_info (fn)');
6617 end if;
6618 close csr_manual_processed_events;
6619
6620 ----------------------------------------------------------------------------
6621 -- Immediately exit if the table is empty
6622 -- the l_rowcount_gt is also useful to find if there is invalid data
6623 ----------------------------------------------------------------------------
6624 select count(1) into l_rowcount_gt from xla_events_int_gt;
6625 if(l_rowcount_gt = 0) then
6626 return;
6627 end if;
6628
6629 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6630 trace
6631 (p_msg => 'before lock te'
6632 ,p_level => C_LEVEL_STATEMENT
6633 ,p_module =>l_log_module);
6634 END IF;
6635
6636 -- lock the entity in xla_transaction_entities table
6637 -- for the entities that require gapless processing
6638 open csr_lock_te;
6639 close csr_lock_te;
6640
6641 /* -- Maintaining the Draft balance is no more required bug 5529569
6642
6643 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6644 trace
6645 (p_msg => 'before calling massive_update'
6646 ,p_level => C_LEVEL_STATEMENT
6647 ,p_module =>l_log_module);
6648 END IF;
6649
6650 IF(NOT xla_balances_pkg.massive_update_for_events(p_application_id
6651 => p_application_id)) THEN
6652 xla_exceptions_pkg.raise_message
6653 (p_appli_s_name => 'XLA'
6654 ,p_msg_name => 'XLA_COMMON_ERROR'
6655 ,p_token_1 => 'ERROR'
6656 ,p_value_1 =>
6657 'Error in the routine that does balance reversals'
6658 ,p_token_2 => 'LOCATION'
6659 ,p_value_2 => 'xla_events_pkg.delete_bulk_events');
6660 END IF;
6661 */
6662
6663 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6664 trace
6665 (p_msg => 'before calling delete_je'
6666 ,p_level => C_LEVEL_STATEMENT
6667 ,p_module =>l_log_module);
6668 END IF;
6669
6670 delete_je;
6671
6672 ----------------------------------------------------------------------------
6673 -- set the on_hold_flag to 'Y' for all the new gap generated
6674 ----------------------------------------------------------------------------
6675 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6676 trace
6677 (p_msg => 'before process gapless'
6678 ,p_level => C_LEVEL_STATEMENT
6679 ,p_module =>l_log_module);
6680 END IF;
6681 OPEN csr_new_gap;
6682 LOOP
6683 FETCH csr_new_gap into l_event_number, l_entity_id, l_application_id;
6684 EXIT WHEN csr_new_gap%NOTFOUND;
6685
6686 UPDATE xla_events
6687 SET on_hold_flag = 'Y'
6688 WHERE entity_id = l_entity_id
6689 AND event_number > l_event_number
6690 AND application_id = l_application_id;
6691 END LOOP;
6692 CLOSE csr_new_gap;
6693
6694 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6695 trace
6696 (p_msg => 'before deleting events'
6697 ,p_level => C_LEVEL_STATEMENT
6698 ,p_module =>l_log_module);
6699 END IF;
6700
6701 UPDATE xla_events_int_gt xeg
6702 SET xeg.entity_id =
6703 (SELECT xe.entity_id
6704 FROM xla_events xe
6705 WHERE xe.event_id = xeg.event_id
6706 AND xe.application_id = p_application_id -- 8967771
6707 );
6708
6709 DELETE xla_events
6710 WHERE event_id in (
6711 SELECT event_id
6712 FROM xla_events_int_gt)
6713 AND application_id = p_application_id -- 8967771
6714 ;
6715 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6716 trace
6717 (p_msg => 'Number of events deleted:'||to_char(SQL%ROWCOUNT)
6718 ,p_level => C_LEVEL_STATEMENT
6719 ,p_module =>l_log_module);
6720 END IF;
6721
6722 DELETE xla_transaction_entities xte
6723 WHERE not exists (SELECT 1
6724 FROM xla_events xe
6725 WHERE xe.entity_id = xte.entity_id
6726 AND xe.application_id = xte.application_id)
6727 AND xte.entity_id in (SELECT entity_id
6728 FROM xla_events_int_gt)
6729 AND xte.application_id = p_application_id; -- 9701260 moved this from inner query
6730
6731 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
6732 trace
6733 (p_msg => 'Number of transaction entity deleted:'||
6734 to_char(SQL%ROWCOUNT)
6735 ,p_level => C_LEVEL_STATEMENT
6736 ,p_module =>l_log_module);
6737 END IF;
6738
6739
6740 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6741 trace
6742 (p_msg => 'end of procedure delete_bulk_events'
6743 ,p_level => C_LEVEL_PROCEDURE
6744 ,p_module =>l_log_module);
6745 END IF;
6746
6747 EXCEPTION
6748 WHEN xla_exceptions_pkg.application_exception THEN
6749 ROLLBACK to SAVEPOINT before_delete_bulk_events;--Bug 10162587
6750 RAISE;
6751 WHEN OTHERS THEN
6752 ROLLBACK to SAVEPOINT before_delete_bulk_events;--Bug 10162587
6753 xla_exceptions_pkg.raise_message
6754 (p_location => 'xla_events_pkg.delete_bulk_events(blk)');
6755 END delete_bulk_events;
6756
6757 --=============================================================================
6758 --
6759 -- For MANUAL events this API cannot be called.
6760 --
6761 --=============================================================================
6762
6763 FUNCTION get_array_event_info
6764 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
6765 ,p_valuation_method IN VARCHAR2
6766 ,p_event_class_code IN VARCHAR2 DEFAULT NULL
6767 ,p_event_type_code IN VARCHAR2 DEFAULT NULL
6768 ,p_event_date IN DATE DEFAULT NULL
6769 ,p_event_status_code IN VARCHAR2 DEFAULT NULL)
6770 RETURN xla_events_pub_pkg.t_array_event_info IS
6771
6772 l_array_event_info xla_events_pub_pkg.t_array_event_info;
6773 l_count INTEGER := 0;
6774 l_event_date DATE;
6775
6776 CURSOR c1 IS
6777 SELECT event_id
6778 ,event_number
6779 ,event_type_code
6780 ,event_date
6781 ,event_status_code
6782 ,on_hold_flag
6783 ,reference_num_1
6784 ,reference_num_2
6785 ,reference_num_3
6786 ,reference_num_4
6787 ,reference_char_1
6788 ,reference_char_2
6789 ,reference_char_3
6790 ,reference_char_4
6791 ,reference_date_1
6792 ,reference_date_2
6793 ,reference_date_3
6794 ,reference_date_4
6795 FROM xla_events
6796 WHERE event_date = NVL(l_event_date, event_date)
6797 AND event_status_code = NVL(p_event_status_code,event_status_code)
6798 AND event_type_code = NVL(p_event_type_code ,event_type_code)
6799 AND entity_id = g_entity_id
6800 AND application_id = g_application_id -- 8967771
6801 AND event_type_code IN (SELECT event_type_code
6802 FROM xla_event_types_b
6803 WHERE application_id = g_application_id
6804 AND entity_code = g_entity_type_code
6805 AND event_class_code = NVL(p_event_class_code,
6806 event_class_code));
6807 l_log_module VARCHAR2(240);
6808 BEGIN
6809 IF g_log_enabled THEN
6810 l_log_module := C_DEFAULT_MODULE||'.get_array_event_info';
6811 END IF;
6812 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6813 trace
6814 (p_msg => 'BEGIN of procedure get_array_event_info'
6815 ,p_level => C_LEVEL_PROCEDURE
6816 ,p_module =>l_log_module);
6817 trace
6818 (p_msg => 'source_application_id = '||
6819 p_event_source_info.source_application_id
6820 ,p_level => C_LEVEL_PROCEDURE
6821 ,p_module =>l_log_module);
6822 trace
6823 (p_msg => 'application_id = '||p_event_source_info.application_id
6824 ,p_level => C_LEVEL_PROCEDURE
6825 ,p_module =>l_log_module);
6826 trace
6827 (p_msg => 'legal_entity_id = '||
6828 p_event_source_info.legal_entity_id
6829 ,p_level => C_LEVEL_PROCEDURE
6830 ,p_module =>l_log_module);
6831 trace
6832 (p_msg => 'ledger_id = '||p_event_source_info.ledger_id
6833 ,p_level => C_LEVEL_PROCEDURE
6834 ,p_module =>l_log_module);
6835 trace
6836 (p_msg => 'entity_type_code = '||
6837 p_event_source_info.entity_type_code
6838 ,p_level => C_LEVEL_PROCEDURE
6839 ,p_module =>l_log_module);
6840 trace
6841 (p_msg => 'transaction_number = '||
6842 p_event_source_info.transaction_number
6843 ,p_level => C_LEVEL_PROCEDURE
6844 ,p_module =>l_log_module);
6845 trace
6846 (p_msg => 'source_id_int_1 = '||
6847 p_event_source_info.source_id_int_1
6848 ,p_level => C_LEVEL_PROCEDURE
6849 ,p_module =>l_log_module);
6850 trace
6851 (p_msg => 'source_id_int_2 = '||
6852 p_event_source_info.source_id_int_2
6853 ,p_level => C_LEVEL_PROCEDURE
6854 ,p_module =>l_log_module);
6855 trace
6856 (p_msg => 'source_id_int_3 = '||
6857 p_event_source_info.source_id_int_3
6858 ,p_level => C_LEVEL_PROCEDURE
6859 ,p_module =>l_log_module);
6860 trace
6861 (p_msg => 'source_id_int_4 = '||
6862 p_event_source_info.source_id_int_4
6863 ,p_level => C_LEVEL_PROCEDURE
6864 ,p_module =>l_log_module);
6865 trace
6866 (p_msg => 'source_id_char_1 = '||
6867 p_event_source_info.source_id_char_1
6868 ,p_level => C_LEVEL_PROCEDURE
6869 ,p_module =>l_log_module);
6870 trace
6871 (p_msg => 'source_id_char_2 = '||
6872 p_event_source_info.source_id_char_2
6873 ,p_level => C_LEVEL_PROCEDURE
6874 ,p_module =>l_log_module);
6875 trace
6876 (p_msg => 'source_id_char_3 = '||
6877 p_event_source_info.source_id_char_3
6878 ,p_level => C_LEVEL_PROCEDURE
6879 ,p_module =>l_log_module);
6880 trace
6881 (p_msg => 'source_id_char_4 = '||
6882 p_event_source_info.source_id_char_4
6883 ,p_level => C_LEVEL_PROCEDURE
6884 ,p_module =>l_log_module);
6885 trace
6886 (p_msg => 'p_event_class_code = '||p_event_class_code
6887 ,p_level => C_LEVEL_PROCEDURE
6888 ,p_module =>l_log_module);
6889 trace
6890 (p_msg => 'p_event_type_code = '||p_event_type_code
6891 ,p_level => C_LEVEL_PROCEDURE
6892 ,p_module =>l_log_module);
6893 trace
6894 (p_msg => 'p_event_date = '||p_event_date
6895 ,p_level => C_LEVEL_PROCEDURE
6896 ,p_module =>l_log_module);
6897 trace
6898 (p_msg => 'p_event_status_code = '||p_event_status_code
6899 ,p_level => C_LEVEL_PROCEDURE
6900 ,p_module =>l_log_module);
6901 trace
6902 (p_msg => 'security_id_int_1 = '||
6903 xla_events_pub_pkg.g_security.security_id_int_1
6904 ,p_level => C_LEVEL_PROCEDURE
6905 ,p_module =>l_log_module);
6906 trace
6907 (p_msg => 'security_id_int_2 = '||
6908 xla_events_pub_pkg.g_security.security_id_int_2
6909 ,p_level => C_LEVEL_PROCEDURE
6910 ,p_module =>l_log_module);
6911 trace
6912 (p_msg => 'security_id_int_3 = '||
6913 xla_events_pub_pkg.g_security.security_id_int_3
6914 ,p_level => C_LEVEL_PROCEDURE
6915 ,p_module =>l_log_module);
6916 trace
6917 (p_msg => 'security_id_char_1 = '||
6918 xla_events_pub_pkg.g_security.security_id_char_1
6919 ,p_level => C_LEVEL_PROCEDURE
6920 ,p_module =>l_log_module);
6921 trace
6922 (p_msg => 'security_id_char_2 = '||
6923 xla_events_pub_pkg.g_security.security_id_char_2
6924 ,p_level => C_LEVEL_PROCEDURE
6925 ,p_module =>l_log_module);
6926 trace
6927 (p_msg => 'security_id_char_3 = '||
6928 xla_events_pub_pkg.g_security.security_id_char_3
6929 ,p_level => C_LEVEL_PROCEDURE
6930 ,p_module =>l_log_module);
6931 trace
6932 (p_msg => 'valuation_method = '||p_valuation_method
6933 ,p_level => C_LEVEL_PROCEDURE
6934 ,p_module =>l_log_module);
6935 END IF;
6936 g_action := C_EVENT_QUERY;
6937
6938 ----------------------------------------------------------------------------
6939 -- Following sets the Security Context for the execution. This enables the
6940 -- event API to respect the transaction security.
6941 ----------------------------------------------------------------------------
6942 xla_security_pkg.set_security_context(p_event_source_info.application_id);
6943
6944 IF p_event_source_info.entity_type_code = C_MANUAL_ENTITY THEN
6945 xla_exceptions_pkg.raise_message
6946 (p_appli_s_name => 'XLA'
6947 ,p_msg_name => 'XLA_COMMON_ERROR'
6948 ,p_token_1 => 'ERROR'
6949 ,p_value_1 => 'For MANUAL events this API cannot be called'
6950 ,p_token_2 => 'LOCATION'
6951 ,p_value_2 => 'xla_events_pkg.get_array_event_info (fn)');
6952 ELSE
6953 g_context := C_REGULAR_EVENT_CONTEXT;
6954 END IF;
6955
6956 ----------------------------------------------------------------------------
6957 -- truncate date
6958 ----------------------------------------------------------------------------
6959 l_event_date := TRUNC(p_event_date);
6960
6961 ----------------------------------------------------------------------------
6962 -- Validate parameters
6963 ----------------------------------------------------------------------------
6964 validate_params
6965 (p_source_info => p_event_source_info
6966 ,p_event_class_code => p_event_class_code
6967 ,p_event_type_code => p_event_type_code);
6968 -- ,p_event_status_code => p_event_status_code);
6969
6970 ----------------------------------------------------------------------------
6971 -- Get document PK
6972 ----------------------------------------------------------------------------
6973 cache_entity_info
6974 (p_source_info => p_event_source_info
6975 ,p_valuation_method => p_valuation_method
6976 ,p_event_id => NULL);
6977
6978 ----------------------------------------------------------------------------
6979 -- raise error if the entity does not exist
6980 ----------------------------------------------------------------------------
6981 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6982 trace
6983 (p_msg => 'g_entity_id = '||g_entity_id
6984 ,p_level => C_LEVEL_STATEMENT
6985 ,p_module =>l_log_module);
6986 END IF;
6987
6988 IF g_entity_id IS NULL THEN
6989 xla_exceptions_pkg.raise_message
6990 (p_appli_s_name => 'XLA'
6991 ,p_msg_name => 'XLA_COMMON_ERROR'
6992 ,p_token_1 => 'ERROR'
6993 ,p_value_1 => 'No event exists for the document represented '||
6994 'by the given source information.'
6995 ,p_token_2 => 'LOCATION'
6996 ,p_value_2 => 'xla_events_pkg.get_array_event_info (fn)');
6997 END IF;
6998
6999 FOR lc_evt IN c1 LOOP
7000 l_count := l_count + 1;
7001
7002 l_array_event_info(l_count).event_id := lc_evt.event_id;
7003 l_array_event_info(l_count).event_number := lc_evt.event_number;
7004 l_array_event_info(l_count).event_type_code := lc_evt.event_type_code;
7005 l_array_event_info(l_count).event_date := lc_evt.event_date;
7006 l_array_event_info(l_count).event_status_code := lc_evt.event_status_code;
7007 l_array_event_info(l_count).on_hold_flag := lc_evt.on_hold_flag;
7008 l_array_event_info(l_count).reference_num_1 := lc_evt.reference_num_1;
7009 l_array_event_info(l_count).reference_num_2 := lc_evt.reference_num_2;
7010 l_array_event_info(l_count).reference_num_3 := lc_evt.reference_num_3;
7011 l_array_event_info(l_count).reference_num_4 := lc_evt.reference_num_4;
7012 l_array_event_info(l_count).reference_char_1 := lc_evt.reference_char_1;
7013 l_array_event_info(l_count).reference_char_2 := lc_evt.reference_char_2;
7014 l_array_event_info(l_count).reference_char_3 := lc_evt.reference_char_3;
7015 l_array_event_info(l_count).reference_char_4 := lc_evt.reference_char_4;
7016 l_array_event_info(l_count).reference_date_1 := lc_evt.reference_date_1;
7017 l_array_event_info(l_count).reference_date_2 := lc_evt.reference_date_2;
7018 l_array_event_info(l_count).reference_date_3 := lc_evt.reference_date_3;
7019 l_array_event_info(l_count).reference_date_4 := lc_evt.reference_date_4;
7020 END LOOP;
7021
7022 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7023 trace
7024 (p_msg => 'Number of events found = '||l_array_event_info.count
7025 ,p_level => C_LEVEL_PROCEDURE
7026 ,p_module =>l_log_module);
7027 trace
7028 (p_msg => 'end of procedure get_array_event_info'
7029 ,p_level => C_LEVEL_PROCEDURE
7030 ,p_module =>l_log_module);
7031 END IF;
7032
7033 RETURN (l_array_event_info);
7034 EXCEPTION
7035 WHEN xla_exceptions_pkg.application_exception THEN
7036 RAISE;
7037 WHEN OTHERS THEN
7038 xla_exceptions_pkg.raise_message
7039 (p_location => 'xla_events_pkg.get_array_event_info (fn)');
7040 END get_array_event_info;
7041
7042
7043 --=============================================================================
7044 --
7045 --
7046 --
7047 --
7048 --
7049 --
7050 --
7051 --
7052 --
7053 --
7054 -- Following are the public routines to set/reset/initialize the cache
7055 --
7056 -- 1. Initialize
7057 --
7058 --
7059 --
7060 --
7061 --
7062 --
7063 --
7064 --
7065 --
7066 --
7067 --
7068 --=============================================================================
7069
7070 --=============================================================================
7071 --
7072 --
7073 -- Changed to fix bug # 2899700. (Added g_process_status_code_tbl init...)
7074 --
7075 --=============================================================================
7076
7077 PROCEDURE initialize IS
7078 l_log_module VARCHAR2(240);
7079 BEGIN
7080 IF g_log_enabled THEN
7081 l_log_module := C_DEFAULT_MODULE||'.initialize';
7082 END IF;
7083 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7084 trace
7085 (p_msg => 'BEGIN of procedure initialize'
7086 ,p_level => C_LEVEL_PROCEDURE
7087 ,p_module =>l_log_module);
7088 END IF;
7089
7090 reset_cache;
7091
7092 ----------------------------------------------------------------------------
7093 -- cache event status code
7094 ----------------------------------------------------------------------------
7095 g_event_status_code_tbl(1) := xla_events_pub_pkg.C_EVENT_UNPROCESSED;
7096 g_event_status_code_tbl(2) := xla_events_pub_pkg.C_EVENT_INCOMPLETE;
7097 g_event_status_code_tbl(3) := xla_events_pub_pkg.C_EVENT_NOACTION;
7098 g_event_status_code_tbl(4) := xla_events_pub_pkg.C_EVENT_PROCESSED;
7099
7100 ----------------------------------------------------------------------------
7101 -- cache process status code
7102 ----------------------------------------------------------------------------
7103 g_process_status_code_tbl(1) := C_INTERNAL_UNPROCESSED;
7104 g_process_status_code_tbl(2) := C_INTERNAL_DRAFT;
7105 g_process_status_code_tbl(3) := C_INTERNAL_FINAL;
7106 g_process_status_code_tbl(4) := C_INTERNAL_ERROR;
7107 g_process_status_code_tbl(5) := C_INTERNAL_INVALID;
7108
7109 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7110 trace
7111 (p_msg => 'end of procedure initialize'
7112 ,p_level => C_LEVEL_PROCEDURE
7113 ,p_module =>l_log_module);
7114 END IF;
7115
7116 EXCEPTION
7117 WHEN xla_exceptions_pkg.application_exception THEN
7118 RAISE;
7119 WHEN OTHERS THEN
7120 xla_exceptions_pkg.raise_message
7121 (p_location => 'xla_events_pkg.initialize');
7122 END initialize;
7123
7124
7125 --=============================================================================
7126 -- *********** private procedures and functions **********
7127 --=============================================================================
7128 --=============================================================================
7129 --
7130 --
7131 --
7132 --
7133 --
7134 --
7135 --
7136 --
7137 --
7138 --
7139 -- Following are the routines that are private to this package and are
7140 --
7141 -- 1. source_info_changed (comparing event_source_info)
7142 -- 2. source_info_changed (comparing entity_source_info)
7143 -- No longer needed
7144 -- 3. validate_context
7145 -- 4. get_id_mapping
7146 -- 5. validate_ids
7147 -- 6. validate_cached_setup
7148 -- 7. cache_application_setup
7149 -- 8. validate_entity_type_code
7150 -- 9. validate_event_class_code
7151 -- 10. validate_event_type_code
7152 -- 11. validate_event_status_code
7153 -- 12. validate_params
7154 -- 13. validate_ledger
7155 -- 14. cache_entity_info
7156 -- 15. create_entity_event
7157 -- 16. update_entity_trx_number
7158 -- 17. add_entity_event
7159 -- 18. reset_cache
7160 -- 19. set_context
7161 --
7162 --
7163 --
7164 --
7165 --
7166 --
7167 --
7168 --
7169 --
7170 --
7171 --
7172 --=============================================================================
7173
7174 --=============================================================================
7175 --
7176 --
7177 --
7178 --=============================================================================
7179
7180 FUNCTION source_info_changed
7181 (p_event_source_info1 IN xla_events_pub_pkg.t_event_source_info
7182 ,p_event_source_info2 IN xla_events_pub_pkg.t_event_source_info
7183 ,p_valuation_method1 IN VARCHAR2
7184 ,p_valuation_method2 IN VARCHAR2)
7185 RETURN BOOLEAN IS
7186 l_log_module VARCHAR2(240);
7187 BEGIN
7188 IF g_log_enabled THEN
7189 l_log_module := C_DEFAULT_MODULE||'.source_info_changed';
7190 END IF;
7191 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7192 trace
7193 (p_msg => 'BEGIN of procedure source_info_changed'
7194 ,p_level => C_LEVEL_PROCEDURE
7195 ,p_module =>l_log_module);
7196 END IF;
7197
7198 ----------------------------------------------------------------------------
7199 -- Bug 4312353. Added the the OR condition to check the valuation method
7200 ----------------------------------------------------------------------------
7201
7202 IF NVL(p_event_source_info1.application_id,C_NUM)
7203 <> NVL(p_event_source_info2.application_id,C_NUM)
7204 OR NVL(p_event_source_info1.ledger_id,C_NUM)
7205 <> NVL(p_event_source_info2.ledger_id,C_NUM)
7206 OR NVL(p_event_source_info1.legal_entity_id,C_NUM)
7207 <> NVL(p_event_source_info2.legal_entity_id,C_NUM)
7208 OR NVL(p_event_source_info1.entity_type_code,C_NUM)
7209 <> NVL(p_event_source_info2.entity_type_code,C_NUM)
7210 OR NVL(p_event_source_info1.source_id_int_1,C_NUM)
7211 <> NVL(p_event_source_info2.source_id_int_1,C_NUM)
7212 OR NVL(p_event_source_info1.source_id_int_2,C_NUM)
7213 <> NVL(p_event_source_info2.source_id_int_2,C_NUM)
7214 OR NVL(p_event_source_info1.source_id_int_3,C_NUM)
7215 <> NVL(p_event_source_info2.source_id_int_3,C_NUM)
7216 OR NVL(p_event_source_info1.source_id_int_4,C_NUM)
7217 <> NVL(p_event_source_info2.source_id_int_4,C_NUM)
7218 OR NVL(p_event_source_info1.source_id_char_1,C_CHAR)
7219 <> NVL(p_event_source_info2.source_id_char_1,C_CHAR)
7220 OR NVL(p_event_source_info1.source_id_char_2,C_CHAR)
7221 <> NVL(p_event_source_info2.source_id_char_2,C_CHAR)
7222 OR NVL(p_event_source_info1.source_id_char_3,C_CHAR)
7223 <> NVL(p_event_source_info2.source_id_char_3,C_CHAR)
7224 OR NVL(p_event_source_info1.source_id_char_4,C_CHAR)
7225 <> NVL(p_event_source_info2.source_id_char_4,C_CHAR)
7226 OR NVL(p_valuation_method1,C_CHAR) <> NVL(p_valuation_method2,C_CHAR)
7227 THEN
7228
7229 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7230 trace
7231 (p_msg => 'end of procedure source_info_changed'
7232 ,p_level => C_LEVEL_PROCEDURE
7233 ,p_module =>l_log_module);
7234 trace
7235 (p_msg => 'return value is true'
7236 ,p_level => C_LEVEL_PROCEDURE
7237 ,p_module =>l_log_module);
7238 END IF;
7239 RETURN TRUE;
7240 ELSE
7241 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7242 trace
7243 (p_msg => 'end of procedure source_info_changed'
7244 ,p_level => C_LEVEL_PROCEDURE
7245 ,p_module =>l_log_module);
7246 trace
7247 (p_msg => 'return value is false'
7248 ,p_level => C_LEVEL_PROCEDURE
7249 ,p_module =>l_log_module);
7250 END IF;
7251 RETURN FALSE;
7252 END IF;
7253 EXCEPTION
7254 WHEN xla_exceptions_pkg.application_exception THEN
7255 RAISE;
7256 WHEN OTHERS THEN
7257 xla_exceptions_pkg.raise_message
7258 (p_location => 'xla_events_pkg.source_info_changed');
7259 END;
7260
7261
7262 --=============================================================================
7263 --
7264 --
7265 --
7266 --=============================================================================
7267
7268 PROCEDURE validate_context
7269 (p_application_id IN INTEGER
7270 ,p_ledger_id IN INTEGER
7271 ,p_entity_type_code IN VARCHAR2) IS
7272 l_log_module VARCHAR2(240);
7273 BEGIN
7274 IF g_log_enabled THEN
7275 l_log_module := C_DEFAULT_MODULE||'.validate_context';
7276 END IF;
7277 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7278 trace
7279 (p_msg => 'BEGIN of procedure validate_context'
7280 ,p_level => C_LEVEL_PROCEDURE
7281 ,p_module =>l_log_module);
7282 END IF;
7283
7284 IF p_application_id IS NULL THEN
7285 xla_exceptions_pkg.raise_message
7286 (p_appli_s_name => 'XLA'
7287 ,p_msg_name => 'XLA_COMMON_ERROR'
7288 ,p_token_1 => 'ERROR'
7289 ,p_value_1 =>
7290 'Application ID has an invalid value. It cannot have a NULL value.'
7291 ,p_token_2 => 'LOCATION'
7292 ,p_value_2 => 'xla_events_pkg.validate_context');
7293 END IF;
7294
7295 IF p_ledger_id IS NULL THEN
7296 xla_exceptions_pkg.raise_message
7297 (p_appli_s_name => 'XLA'
7298 ,p_msg_name => 'XLA_COMMON_ERROR'
7299 ,p_token_1 => 'ERROR'
7300 ,p_value_1 =>
7301 'Ledger ID has an invalid value. It cannot have a NULL value.'
7302 ,p_token_2 => 'LOCATION'
7303 ,p_value_2 => 'xla_events_pkg.validate_context');
7304 ELSE
7305 -------------------------------------------------------------------------
7306 -- Validate ledger
7307 -------------------------------------------------------------------------
7308 validate_ledger
7309 (p_ledger_id => p_ledger_id
7310 ,p_application_id => p_application_id);
7311
7312 END IF;
7313
7314 IF p_entity_type_code IS NULL THEN
7315 xla_exceptions_pkg.raise_message
7316 (p_appli_s_name => 'XLA'
7317 ,p_msg_name => 'XLA_COMMON_ERROR'
7318 ,p_token_1 => 'ERROR'
7319 ,p_value_1 =>
7320 'Entity Type Code has an invalid value. It cannot have a NULL value.'
7321 ,p_token_2 => 'LOCATION'
7322 ,p_value_2 => 'xla_events_pkg.validate_context');
7323 END IF;
7324 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7325 trace
7326 (p_msg => 'end of procedure validate_context'
7327 ,p_level => C_LEVEL_PROCEDURE
7328 ,p_module =>l_log_module);
7329 END IF;
7330
7331 EXCEPTION
7332 WHEN xla_exceptions_pkg.application_exception THEN
7333 RAISE;
7334 WHEN OTHERS THEN
7335 xla_exceptions_pkg.raise_message
7336 (p_location => 'xla_events_pkg.validate_context');
7337 END validate_context;
7338
7339
7340 --=============================================================================
7341 --
7342 --
7343 --
7344 --=============================================================================
7345
7346 FUNCTION get_id_mapping
7347 (p_entity_type_code IN VARCHAR2
7348 ,p_source_id_code_1 IN VARCHAR2
7349 ,p_source_id_code_2 IN VARCHAR2
7350 ,p_source_id_code_3 IN VARCHAR2
7351 ,p_source_id_code_4 IN VARCHAR2)
7352 RETURN VARCHAR2 IS
7353 l_mapping VARCHAR2(8);
7354 lmap1 VARCHAR2(1) := '_';
7355 lmap2 VARCHAR2(1) := '_';
7356 lmap3 VARCHAR2(1) := '_';
7357 lmap4 VARCHAR2(1) := '_';
7358 lmap5 VARCHAR2(1) := '_';
7359 lmap6 VARCHAR2(1) := '_';
7360 lmap7 VARCHAR2(1) := '_';
7361 lmap8 VARCHAR2(1) := '_';
7362 l_error BOOLEAN := FALSE;
7363 l_log_module VARCHAR2(240);
7364 BEGIN
7365 IF g_log_enabled THEN
7366 l_log_module := C_DEFAULT_MODULE||'.get_id_mapping';
7367 END IF;
7368 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7369 trace
7370 (p_msg => 'BEGIN of procedure get_id_mapping'
7371 ,p_level => C_LEVEL_PROCEDURE
7372 ,p_module =>l_log_module);
7373 END IF;
7374
7375 IF p_source_id_code_1 IS NULL THEN
7376 IF p_source_id_code_2 IS NULL THEN
7377 IF p_source_id_code_3 IS NULL THEN
7378 IF p_source_id_code_4 IS NULL THEN
7379 l_error := FALSE;
7380 ELSE
7381 l_error := TRUE;
7382 END IF;
7383 ELSE
7384 l_error := TRUE;
7385 END IF;
7386 ELSE
7387 l_error := TRUE;
7388 END IF;
7389 ELSE
7390 IF p_source_id_code_2 IS NULL THEN
7391 IF p_source_id_code_3 IS NULL THEN
7392 IF p_source_id_code_4 IS NULL THEN
7393 l_error := FALSE;
7394 ELSE
7395 l_error := TRUE;
7396 END IF;
7397 ELSE
7398 l_error := TRUE;
7399 END IF;
7400 ELSE
7401 IF p_source_id_code_3 IS NULL THEN
7402 IF p_source_id_code_4 IS NULL THEN
7403 l_error := FALSE;
7404 ELSE
7405 l_error := TRUE;
7406 END IF;
7407 ELSE
7408 l_error := FALSE;
7409 END IF;
7410 END IF;
7411 END IF;
7412
7413 IF l_error THEN
7414 xla_exceptions_pkg.raise_message
7415 (p_appli_s_name => 'XLA'
7416 ,p_msg_name => 'XLA_COMMON_ERROR'
7417 ,p_token_1 => 'ERROR'
7418 ,p_value_1 => 'The setup for Entity Type, '||
7419 p_entity_type_code ||', is incorrect. Internal Error.'
7420 ,p_token_2 => 'LOCATION'
7421 ,p_value_2 => 'xla_events_pkg.get_id_mapping');
7422 END IF;
7423
7424 IF p_source_id_code_1 = 'SOURCE_ID_INT_1'
7425 OR p_source_id_code_2 = 'SOURCE_ID_INT_1'
7426 OR p_source_id_code_3 = 'SOURCE_ID_INT_1'
7427 OR p_source_id_code_4 = 'SOURCE_ID_INT_1'
7428 THEN
7429 lmap1 := 'I';
7430 END IF;
7431
7432 IF p_source_id_code_1 = 'SOURCE_ID_INT_2'
7433 OR p_source_id_code_2 = 'SOURCE_ID_INT_2'
7434 OR p_source_id_code_3 = 'SOURCE_ID_INT_2'
7435 OR p_source_id_code_4 = 'SOURCE_ID_INT_2'
7436 THEN
7437 lmap2 := 'I';
7438 END IF;
7439
7440 IF p_source_id_code_1 = 'SOURCE_ID_INT_3'
7441 OR p_source_id_code_2 = 'SOURCE_ID_INT_3'
7442 OR p_source_id_code_3 = 'SOURCE_ID_INT_3'
7443 OR p_source_id_code_4 = 'SOURCE_ID_INT_3'
7444 THEN
7445 lmap3 := 'I';
7446 END IF;
7447
7448 IF p_source_id_code_1 = 'SOURCE_ID_INT_4'
7449 OR p_source_id_code_2 = 'SOURCE_ID_INT_4'
7450 OR p_source_id_code_3 = 'SOURCE_ID_INT_4'
7451 OR p_source_id_code_4 = 'SOURCE_ID_INT_4'
7452 THEN
7453 lmap4 := 'I';
7454 END IF;
7455
7456 IF p_source_id_code_1 = 'SOURCE_ID_CHAR_1'
7457 OR p_source_id_code_2 = 'SOURCE_ID_CHAR_1'
7458 OR p_source_id_code_3 = 'SOURCE_ID_CHAR_1'
7459 OR p_source_id_code_4 = 'SOURCE_ID_CHAR_1'
7460 THEN
7461 lmap5 := 'I';
7462 END IF;
7463
7464 IF p_source_id_code_1 = 'SOURCE_ID_CHAR_2'
7465 OR p_source_id_code_2 = 'SOURCE_ID_CHAR_2'
7466 OR p_source_id_code_3 = 'SOURCE_ID_CHAR_2'
7467 OR p_source_id_code_4 = 'SOURCE_ID_CHAR_2'
7468 THEN
7469 lmap6 := 'I';
7470 END IF;
7471
7472 IF p_source_id_code_1 = 'SOURCE_ID_CHAR_3'
7473 OR p_source_id_code_2 = 'SOURCE_ID_CHAR_3'
7474 OR p_source_id_code_3 = 'SOURCE_ID_CHAR_3'
7475 OR p_source_id_code_4 = 'SOURCE_ID_CHAR_3'
7476 THEN
7477 lmap7 := 'I';
7478 END IF;
7479
7480 IF p_source_id_code_1 = 'SOURCE_ID_CHAR_4'
7481 OR p_source_id_code_2 = 'SOURCE_ID_CHAR_4'
7482 OR p_source_id_code_3 = 'SOURCE_ID_CHAR_4'
7483 OR p_source_id_code_4 = 'SOURCE_ID_CHAR_4'
7484 THEN
7485 lmap8 := 'I';
7486 END IF;
7487
7488 l_mapping := lmap1||lmap2||lmap3||lmap4||lmap5||lmap6||lmap7||lmap8;
7489
7490 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7491 trace
7492 (p_msg => 'end of procedure get_id_mapping'
7493 ,p_level => C_LEVEL_PROCEDURE
7494 ,p_module =>l_log_module);
7495 trace
7496 (p_msg => 'return value is:'||l_mapping
7497 ,p_level => C_LEVEL_PROCEDURE
7498 ,p_module =>l_log_module);
7499 END IF;
7500
7501 RETURN l_mapping;
7502 EXCEPTION
7503 WHEN xla_exceptions_pkg.application_exception THEN
7504 RAISE;
7505 WHEN OTHERS THEN
7506 xla_exceptions_pkg.raise_message
7507 (p_location => 'xla_events_pkg.get_id_mapping');
7508 END;
7509
7510
7511 --=============================================================================
7512 --
7513 --
7514 --
7515 --=============================================================================
7516
7517 FUNCTION validate_id_where_clause return VARCHAR2 is
7518 l_string VARCHAR2(1000):=null;
7519 l_log_module VARCHAR2(240);
7520 BEGIN
7521 IF g_log_enabled THEN
7522 l_log_module := C_DEFAULT_MODULE||'.validate_ids';
7523 END IF;
7524
7525 IF substr(g_id_mapping,1,1) = 'I' THEN
7526 l_string := ' SOURCE_ID_INT_1 is null OR';
7527 ELSE
7528 l_string := ' SOURCE_ID_INT_1 is not null OR ';
7529 END IF;
7530
7531 IF substr(g_id_mapping,2,1) = 'I' THEN
7532 l_string := l_string || ' SOURCE_ID_INT_2 is null OR ';
7533 ELSE
7534 l_string := l_string || ' SOURCE_ID_INT_2 is not null OR ';
7535 END IF;
7536
7537 IF substr(g_id_mapping,3,1) = 'I' THEN
7538 l_string := l_string || ' SOURCE_ID_INT_3 is null OR';
7539 ELSE
7540 l_string := l_string || ' SOURCE_ID_INT_3 is not null OR';
7541 END IF;
7542
7543 IF substr(g_id_mapping,4,1) = 'I' THEN
7544 l_string := l_string || ' SOURCE_ID_INT_4 is null OR';
7545 ELSE
7546 l_string := l_string || ' SOURCE_ID_INT_4 is not null OR';
7547 END IF;
7548
7549 IF substr(g_id_mapping,5,1) = 'I' THEN
7550 l_string := l_string || ' SOURCE_ID_CHAR_1 is null OR';
7551 ELSE
7552 l_string := l_string || ' SOURCE_ID_CHAR_1 is not null OR';
7553 END IF;
7554
7555 IF substr(g_id_mapping,6,1) = 'I' THEN
7556 l_string := l_string || ' SOURCE_ID_CHAR_2 is null OR';
7557 ELSE
7558 l_string := l_string || ' SOURCE_ID_CHAR_2 is not null OR';
7559 END IF;
7560
7561 IF substr(g_id_mapping,7,1) = 'I' THEN
7562 l_string := l_string || ' SOURCE_ID_CHAR_3 is null OR';
7563 ELSE
7564 l_string := l_string || ' SOURCE_ID_CHAR_3 is not null OR';
7565 END IF;
7566
7567 IF substr(g_id_mapping,8,1) = 'I' THEN
7568 l_string := l_string || ' SOURCE_ID_CHAR_4 is null ';
7569 ELSE
7570 l_string := l_string || ' SOURCE_ID_CHAR_4 is not null ';
7571 END IF;
7572
7573 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7574 trace
7575 (p_msg => 'end of procedure validate_id_where_clause'
7576 ,p_level => C_LEVEL_PROCEDURE
7577 ,p_module =>l_log_module);
7578 trace
7579 (p_msg => 'return value is:'||l_string
7580 ,p_level => C_LEVEL_PROCEDURE
7581 ,p_module =>l_log_module);
7582 END IF;
7583
7584 RETURN l_string;
7585 END validate_id_where_clause;
7586
7587
7588 --=============================================================================
7589 --
7590 --
7591 --
7592 --=============================================================================
7593
7594 FUNCTION join_id_where_clause return VARCHAR2 is
7595 l_string VARCHAR2(1000):=null;
7596 l_log_module VARCHAR2(240);
7597 BEGIN
7598 IF g_log_enabled THEN
7599 l_log_module := C_DEFAULT_MODULE||'.validate_ids';
7600 END IF;
7601
7602 IF substr(g_id_mapping,1,1) = 'I' THEN
7603 l_string := ' AND xte.source_id_int_1 = xeg.source_id_int_1';
7604 END IF;
7605
7606 IF substr(g_id_mapping,2,1) = 'I' THEN
7607 l_string := l_string || ' AND xte.source_id_int_2 = xeg.source_id_int_2';
7608 END IF;
7609
7610 IF substr(g_id_mapping,3,1) = 'I' THEN
7611 l_string := l_string || ' AND xte.source_id_int_3 = xeg.source_id_int_3';
7612 END IF;
7613
7614 IF substr(g_id_mapping,4,1) = 'I' THEN
7615 l_string := l_string || ' AND xte.source_id_int_4 = xeg.source_id_int_4';
7616 END IF;
7617
7618 IF substr(g_id_mapping,5,1) = 'I' THEN
7619 l_string := l_string || ' AND xte.source_id_char_1 = xeg.source_id_char_1';
7620 END IF;
7621
7622 IF substr(g_id_mapping,6,1) = 'I' THEN
7623 l_string := l_string || ' AND xte.source_id_char_2 = xeg.source_id_char_2';
7624 END IF;
7625
7626 IF substr(g_id_mapping,7,1) = 'I' THEN
7627 l_string := l_string || ' AND xte.source_id_char_3 = xeg.source_id_char_3';
7628 END IF;
7629
7630 IF substr(g_id_mapping,8,1) = 'I' THEN
7631 l_string := l_string || ' AND xte.source_id_char_4 = xeg.source_id_char_4';
7632 END IF;
7633 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7634 trace
7635 (p_msg => 'end of procedure join_id_where_clause'
7636 ,p_level => C_LEVEL_PROCEDURE
7637 ,p_module =>l_log_module);
7638 trace
7639 (p_msg => 'return value is:'||l_string
7640 ,p_level => C_LEVEL_PROCEDURE
7641 ,p_module =>l_log_module);
7642 END IF;
7643
7644 RETURN l_string;
7645 END join_id_where_clause;
7646
7647
7648 --=============================================================================
7649 --
7650 --
7651 --
7652 --=============================================================================
7653
7654 PROCEDURE validate_ids
7655 (p_entity_type_code IN VARCHAR2
7656 ,p_source_id_int_1 IN INTEGER
7657 ,p_source_id_int_2 IN INTEGER
7658 ,p_source_id_int_3 IN INTEGER
7659 ,p_source_id_int_4 IN INTEGER
7660 ,p_source_id_char_1 IN VARCHAR2
7661 ,p_source_id_char_2 IN VARCHAR2
7662 ,p_source_id_char_3 IN VARCHAR2
7663 ,p_source_id_char_4 IN VARCHAR2) IS
7664 l_error BOOLEAN := FALSE;
7665 l_log_module VARCHAR2(240);
7666 BEGIN
7667 IF g_log_enabled THEN
7668 l_log_module := C_DEFAULT_MODULE||'.validate_ids';
7669 END IF;
7670 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7671 trace
7672 (p_msg => 'BEGIN of procedure validate_ids'
7673 ,p_level => C_LEVEL_PROCEDURE
7674 ,p_module =>l_log_module);
7675 END IF;
7676
7677 IF substr(g_id_mapping,1,1) = 'I' THEN
7678 IF p_source_id_int_1 IS NULL THEN
7679 l_error := TRUE;
7680 END IF;
7681 ELSE
7682 IF p_source_id_int_1 IS NOT NULL THEN
7683 l_error := TRUE;
7684 END IF;
7685 END IF;
7686
7687 IF substr(g_id_mapping,2,1) = 'I' THEN
7688 IF p_source_id_int_2 IS NULL THEN
7689 l_error := TRUE;
7690 END IF;
7691 ELSE
7692 IF p_source_id_int_2 IS NOT NULL THEN
7693 l_error := TRUE;
7694 END IF;
7695 END IF;
7696
7697 IF substr(g_id_mapping,3,1) = 'I' THEN
7698 IF p_source_id_int_3 IS NULL THEN
7699 l_error := TRUE;
7700 END IF;
7701 ELSE
7702 IF p_source_id_int_3 IS NOT NULL THEN
7703 l_error := TRUE;
7704 END IF;
7705 END IF;
7706
7707 IF substr(g_id_mapping,4,1) = 'I' THEN
7708 IF p_source_id_int_4 IS NULL THEN
7709 l_error := TRUE;
7710 END IF;
7711 ELSE
7712 IF p_source_id_int_4 IS NOT NULL THEN
7713 l_error := TRUE;
7714 END IF;
7715 END IF;
7716
7717 IF substr(g_id_mapping,5,1) = 'I' THEN
7718 IF p_source_id_char_1 IS NULL THEN
7719 l_error := TRUE;
7720 END IF;
7721 ELSE
7722 IF p_source_id_char_1 IS NOT NULL THEN
7723 l_error := TRUE;
7724 END IF;
7725 END IF;
7726
7727 IF substr(g_id_mapping,6,1) = 'I' THEN
7728 IF p_source_id_char_2 IS NULL THEN
7729 l_error := TRUE;
7730 END IF;
7731 ELSE
7732 IF p_source_id_char_2 IS NOT NULL THEN
7733 l_error := TRUE;
7734 END IF;
7735 END IF;
7736
7737 IF substr(g_id_mapping,7,1) = 'I' THEN
7738 IF p_source_id_char_3 IS NULL THEN
7739 l_error := TRUE;
7740 END IF;
7741 ELSE
7742 IF p_source_id_char_3 IS NOT NULL THEN
7743 l_error := TRUE;
7744 END IF;
7745 END IF;
7746
7747 IF substr(g_id_mapping,8,1) = 'I' THEN
7748 IF p_source_id_char_4 IS NULL THEN
7749 l_error := TRUE;
7750 END IF;
7751 ELSE
7752 IF p_source_id_char_4 IS NOT NULL THEN
7753 l_error := TRUE;
7754 END IF;
7755 END IF;
7756
7757 IF l_error THEN
7758 xla_exceptions_pkg.raise_message
7759 (p_appli_s_name => 'XLA'
7760 ,p_msg_name => 'XLA_COMMON_ERROR'
7761 ,p_token_1 => 'ERROR'
7762 ,p_value_1 =>
7763 'The source information passed does not map to the setups for Entity Type '
7764 || p_entity_type_code
7765 ,p_token_2 => 'LOCATION'
7766 ,p_value_2 => 'xla_events_pkg.validate_ids');
7767 END IF;
7768
7769 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7770 trace
7771 (p_msg => 'end of procedure validate_ids'
7772 ,p_level => C_LEVEL_PROCEDURE
7773 ,p_module =>l_log_module);
7774 END IF;
7775 END;
7776
7777
7778 --=============================================================================
7779 --
7780 --
7781 --
7782 --=============================================================================
7783
7784 PROCEDURE validate_cached_setup IS
7785 l_log_module VARCHAR2(240);
7786 BEGIN
7787 IF g_log_enabled THEN
7788 l_log_module := C_DEFAULT_MODULE||'.validate_cached_setup';
7789 END IF;
7790 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7791 trace
7792 (p_msg => 'BEGIN of procedure validate_cached_setup'
7793 ,p_level => C_LEVEL_PROCEDURE
7794 ,p_module =>l_log_module);
7795 END IF;
7796
7797 IF g_application_id IS NULL THEN
7798 xla_exceptions_pkg.raise_message
7799 (p_appli_s_name => 'XLA'
7800 ,p_msg_name => 'XLA_COMMON_ERROR'
7801 ,p_token_1 => 'ERROR'
7802 ,p_value_1 =>
7803 'The application is not registerd with subledger accounting architectre'
7804 ,p_token_2 => 'LOCATION'
7805 ,p_value_2 => 'xla_events_pkg.validate_cached_setup');
7806 END IF;
7807
7808 --
7809 -- Validate that the entity type code tables have been loaded
7810 --
7811 IF g_entity_type_code_tbl.FIRST IS NULL THEN
7812 xla_exceptions_pkg.raise_message
7813 (p_appli_s_name => 'XLA'
7814 ,p_msg_name => 'XLA_COMMON_ERROR'
7815 ,p_token_1 => 'ERROR'
7816 ,p_value_1 =>
7817 'There is no Entity Type Code defined for the application '
7818 ||g_application_id
7819 ,p_token_2 => 'LOCATION'
7820 ,p_value_2 => 'xla_events_pkg.validate_cached_setup');
7821 END IF;
7822
7823 --
7824 -- Validate that the event class tables have been loaded
7825 --
7826 IF g_event_class_code_tbl.FIRST IS NULL THEN
7827 xla_exceptions_pkg.raise_message
7828 (p_appli_s_name => 'XLA'
7829 ,p_msg_name => 'XLA_COMMON_ERROR'
7830 ,p_token_1 => 'ERROR'
7831 ,p_value_1 =>
7832 'There is no Event Class defined for the application '
7833 ||g_application_id
7834 ,p_token_2 => 'LOCATION'
7835 ,p_value_2 => 'xla_events_pkg.validate_cached_setup');
7836 END IF;
7837
7838 --
7839 -- Validate that the event type code tables have been loaded
7840 --
7841 IF g_event_type_code_tbl.FIRST IS NULL THEN
7842 xla_exceptions_pkg.raise_message
7843 (p_appli_s_name => 'XLA'
7844 ,p_msg_name => 'XLA_COMMON_ERROR'
7845 ,p_token_1 => 'ERROR'
7846 ,p_value_1 =>
7847 'There is no Event Type Code defined for the application '
7848 ||g_application_id
7849 ,p_token_2 => 'LOCATION'
7850 ,p_value_2 => 'xla_events_pkg.validate_cached_setup');
7851 END IF;
7852
7853 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7854 trace
7855 (p_msg => 'end of procedure validate_cached_setup'
7856 ,p_level => C_LEVEL_PROCEDURE
7857 ,p_module =>l_log_module);
7858 END IF;
7859
7860 END validate_cached_setup;
7861
7862
7863 --=============================================================================
7864 --
7865 --
7866 --
7867 --=============================================================================
7868 PROCEDURE cache_application_setup
7869 (p_application_id IN INTEGER) IS
7870 CURSOR csr_xla_application IS
7871 SELECT application_id
7872 FROM xla_subledgers
7873 WHERE application_id = p_application_id;
7874
7875 CURSOR csr_entity_types IS
7876 SELECT t.entity_code
7877 ,m.source_id_col_name_1
7878 ,m.source_id_col_name_2
7879 ,m.source_id_col_name_3
7880 ,m.source_id_col_name_4
7881 ,t.enabled_flag
7882 FROM xla_entity_types_b t
7883 ,xla_entity_id_mappings m
7884 WHERE t.application_id = g_application_id
7885 AND t.application_id = m.application_id
7886 AND t.entity_code = m.entity_code;
7887
7888 CURSOR csr_event_classes IS
7889 SELECT a.entity_code
7890 ,a.event_class_code
7891 ,a.enabled_flag
7892 FROM xla_event_classes_b a
7893 WHERE a.application_id = g_application_id;
7894
7895 CURSOR csr_event_types IS
7896 SELECT a.entity_code
7897 ,a.event_class_code
7898 ,a.event_type_code
7899 ,a.enabled_flag
7900 FROM xla_event_types_b a
7901 WHERE a.application_id = g_application_id;
7902
7903 l_count INTEGER;
7904
7905 l_log_module VARCHAR2(240);
7906 BEGIN
7907 IF g_log_enabled THEN
7908 l_log_module := C_DEFAULT_MODULE||'.cache_application_setup';
7909 END IF;
7910 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7911 trace
7912 (p_msg => 'BEGIN of procedure cache_application_setup'
7913 ,p_level => C_LEVEL_PROCEDURE
7914 ,p_module =>l_log_module);
7915 END IF;
7916
7917 trace('> xla_events_pkg.cache_application_setup' , 20);
7918
7919 g_application_id := null;
7920 g_entity_type_code_tbl.delete; --clear cache first
7921 g_event_class_code_tbl.delete; --clear cache first
7922 g_event_type_code_tbl.delete; --clear cache first
7923 g_ledger_status_tbl.delete; --clear cache first
7924
7925 --
7926 -- Cache application id
7927 --
7928 FOR c1 IN csr_xla_application LOOP
7929 g_application_id := c1.application_id;
7930 END LOOP;
7931
7932 --
7933 -- Cache entity code
7934 --
7935
7936 FOR c1 IN csr_entity_types LOOP
7937 g_entity_type_code_tbl(c1.entity_code).enabled_flag := c1.enabled_flag;
7938 g_entity_type_code_tbl(c1.entity_code).id_mapping :=
7939 get_id_mapping
7940 (p_entity_type_code => c1.entity_code
7941 ,p_source_id_code_1 => c1.source_id_col_name_1
7942 ,p_source_id_code_2 => c1.source_id_col_name_2
7943 ,p_source_id_code_3 => c1.source_id_col_name_3
7944 ,p_source_id_code_4 => c1.source_id_col_name_4);
7945 END LOOP;
7946
7947 --
7948 -- Cache event class code
7949 --
7950 FOR c1 IN csr_event_classes LOOP
7951 g_event_class_code_tbl(c1.event_class_code).enabled_flag :=
7952 c1.enabled_flag;
7953 g_event_class_code_tbl(c1.event_class_code).entity_type_code :=
7954 c1.entity_code;
7955 END LOOP;
7956
7957
7958 --
7959 -- Cache event type code
7960 --
7961 FOR c1 IN csr_event_types LOOP
7962 g_event_type_code_tbl(c1.event_type_code).enabled_flag := c1.enabled_flag;
7963 g_event_type_code_tbl(c1.event_type_code).event_class_code :=
7964 c1.event_class_code;
7965 END LOOP;
7966
7967 --
7968 -- Validate the cached information
7969 --
7970 validate_cached_setup;
7971
7972 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7973 trace
7974 (p_msg => 'end of procedure cache_application_setup'
7975 ,p_level => C_LEVEL_PROCEDURE
7976 ,p_module =>l_log_module);
7977 END IF;
7978 EXCEPTION
7979 WHEN xla_exceptions_pkg.application_exception THEN
7980 RAISE;
7981 WHEN OTHERS THEN
7982 xla_exceptions_pkg.raise_message
7983 (p_location => 'xla_events_pkg.cache_application_setup');
7984 END cache_application_setup;
7985
7986
7987 --=============================================================================
7988 -- This procedure assign variable g_id_mapping
7989 -- if the action is delete or query, or if the entity code is enabled
7990 -- else, it raise exception
7991 --=============================================================================
7992 PROCEDURE validate_entity_type_code
7993 (p_entity_type_code IN VARCHAR2) IS
7994 l_enabled_flag VARCHAR2(1);
7995 l_log_module VARCHAR2(240);
7996
7997 BEGIN
7998 IF g_log_enabled THEN
7999 l_log_module := C_DEFAULT_MODULE||'.validate_entity_type_code';
8000 END IF;
8001 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8002 trace
8003 (p_msg => 'BEGIN of procedure validate_entity_type_code'
8004 ,p_level => C_LEVEL_PROCEDURE
8005 ,p_module =>l_log_module);
8006 trace
8007 (p_msg => 'Entity Type Code = '||p_entity_type_code
8008 ,p_level => C_LEVEL_PROCEDURE
8009 ,p_module =>l_log_module);
8010 END IF;
8011
8012 l_enabled_flag := g_entity_type_code_tbl(p_entity_type_code).enabled_flag;
8013
8014 IF (g_action = C_EVENT_DELETE) OR (g_action = C_EVENT_QUERY) THEN
8015 g_id_mapping := g_entity_type_code_tbl(p_entity_type_code).id_mapping;
8016 ELSIF (l_enabled_flag = C_YES) THEN
8017 g_id_mapping := g_entity_type_code_tbl(p_entity_type_code).id_mapping;
8018 ELSIF (l_enabled_flag <> C_YES) THEN
8019 xla_exceptions_pkg.raise_message
8020 (p_appli_s_name => 'XLA'
8021 ,p_msg_name => 'XLA_COMMON_ERROR'
8022 ,p_token_1 => 'ERROR'
8023 ,p_value_1 =>
8024 'The entity Type is not enabled. Disabled entity types are not allowed for create/update APIs.'
8025 ,p_token_2 => 'LOCATION'
8026 ,p_value_2 => 'xla_events_pkg.validate_entity_type_code');
8027 END IF;
8028
8029 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8030 trace
8031 (p_msg => 'end of procedure validate_entity_type_code'
8032 ,p_level => C_LEVEL_PROCEDURE
8033 ,p_module =>l_log_module);
8034 END IF;
8035
8036 EXCEPTION
8037 WHEN NO_DATA_FOUND THEN
8038 xla_exceptions_pkg.raise_message
8039 (p_appli_s_name => 'XLA'
8040 ,p_msg_name => 'XLA_COMMON_ERROR'
8041 ,p_token_1 => 'ERROR'
8042 ,p_value_1 => p_entity_type_code||
8043 ' is not a defined entity type for the application '||g_application_id
8044 ,p_token_2 => 'LOCATION'
8045 ,p_value_2 => 'xla_events_pkg.validate_entity_type_code');
8046 WHEN xla_exceptions_pkg.application_exception THEN
8047 RAISE;
8048 WHEN OTHERS THEN
8049 xla_exceptions_pkg.raise_message
8050 (p_location => 'xla_events_pkg.validate_entity_type_code');
8051 END validate_entity_type_code;
8052
8053
8054 --=============================================================================
8055 --
8056 --
8057 --
8058 --=============================================================================
8059
8060 PROCEDURE validate_event_class_code
8061 (p_entity_type_code IN VARCHAR2
8062 ,p_event_class_code IN VARCHAR2) IS
8063 l_enabled_flag VARCHAR2(1);
8064 l_entity_code VARCHAR2(30);
8065 l_log_module VARCHAR2(240);
8066 BEGIN
8067 IF g_log_enabled THEN
8068 l_log_module := C_DEFAULT_MODULE||'.validate_event_class_code';
8069 END IF;
8070 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8071 trace
8072 (p_msg => 'BEGIN of procedure validate_event_class_code'
8073 ,p_level => C_LEVEL_PROCEDURE
8074 ,p_module =>l_log_module);
8075 END IF;
8076
8077 l_enabled_flag := g_event_class_code_tbl(p_event_class_code).enabled_flag;
8078 l_entity_code :=g_event_class_code_tbl(p_event_class_code).entity_type_code;
8079
8080
8081 IF (((g_action = C_EVENT_CREATE) OR (g_action = C_EVENT_UPDATE)) AND
8082 (l_enabled_flag <> C_YES)
8083 )
8084 THEN
8085 xla_exceptions_pkg.raise_message
8086 (p_appli_s_name => 'XLA'
8087 ,p_msg_name => 'XLA_COMMON_ERROR'
8088 ,p_token_1 => 'ERROR'
8089 ,p_value_1 =>
8090 'The Event Class is not enabled. Disabled event classes are not allowed for create/update APIs.'
8091 ,p_token_2 => 'LOCATION'
8092 ,p_value_2 => 'xla_events_pkg.validate_event_class_code');
8093 END IF;
8094
8095 IF p_entity_type_code <> l_entity_code THEN
8096 xla_exceptions_pkg.raise_message
8097 (p_appli_s_name => 'XLA'
8098 ,p_msg_name => 'XLA_COMMON_ERROR'
8099 ,p_token_1 => 'ERROR'
8100 ,p_value_1 => 'Event class '||p_event_class_code||
8101 ' is not defined for the entity type '||p_entity_type_code||
8102 ' and application '||g_application_id
8103 ,p_token_2 => 'LOCATION'
8104 ,p_value_2 => 'xla_events_pkg.validate_event_class_code');
8105 END IF;
8106
8107 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8108 trace
8109 (p_msg => 'end of procedure validate_event_class_code'
8110 ,p_level => C_LEVEL_PROCEDURE
8111 ,p_module =>l_log_module);
8112 END IF;
8113 EXCEPTION
8114 WHEN NO_DATA_FOUND THEN
8115 xla_exceptions_pkg.raise_message
8116 (p_appli_s_name => 'XLA'
8117 ,p_msg_name => 'XLA_COMMON_ERROR'
8118 ,p_token_1 => 'ERROR'
8119 ,p_value_1 => p_event_class_code||
8120 ' is not a defined event class for the application '||g_application_id
8121 ,p_token_2 => 'LOCATION'
8122 ,p_value_2 => 'xla_events_pkg.validate_event_class_code');
8123 WHEN xla_exceptions_pkg.application_exception THEN
8124 RAISE;
8125 WHEN OTHERS THEN
8126 xla_exceptions_pkg.raise_message
8127 (p_location => 'xla_events_pkg.validate_event_class_code');
8128 END validate_event_class_code;
8129
8130
8131 --=============================================================================
8132 --
8133 --
8134 --
8135 --=============================================================================
8136
8137 PROCEDURE validate_event_type_code
8138 (p_entity_type_code IN VARCHAR2
8139 ,p_event_class_code IN VARCHAR2
8140 ,p_event_type_code IN VARCHAR2) IS
8141 l_enabled_flag VARCHAR2(1);
8142 l_entity_code VARCHAR2(30);
8143 l_event_class_code VARCHAR2(30);
8144 l_log_module VARCHAR2(240);
8145 BEGIN
8146 IF g_log_enabled THEN
8147 l_log_module := C_DEFAULT_MODULE||'.validate_event_type_code';
8148 END IF;
8149 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8150 trace
8151 (p_msg => 'BEGIN of procedure validate_event_type_code'
8152 ,p_level => C_LEVEL_PROCEDURE
8153 ,p_module =>l_log_module);
8154 END IF;
8155
8156 l_enabled_flag := g_event_type_code_tbl(p_event_type_code).enabled_flag;
8157 l_event_class_code :=
8158 g_event_type_code_tbl(p_event_type_code).event_class_code;
8159 l_entity_code :=
8160 g_event_class_code_tbl(l_event_class_code).entity_type_code;
8161
8162 IF (((g_action = C_EVENT_CREATE) OR (g_action = C_EVENT_UPDATE)) AND
8163 (l_enabled_flag <> C_YES)
8164 )
8165 THEN
8166 xla_exceptions_pkg.raise_message
8167 (p_appli_s_name => 'XLA'
8168 ,p_msg_name => 'XLA_COMMON_ERROR'
8169 ,p_token_1 => 'ERROR'
8170 ,p_value_1 =>
8171 'The Event Type is not enabled. Disabled event types are not allowed for create/update APIs.'
8172 ,p_token_2 => 'LOCATION'
8173 ,p_value_2 => 'xla_events_pkg.validate_event_type_code');
8174 END IF;
8175
8176 IF ((p_entity_type_code <> l_entity_code) OR
8177 (NVL(p_event_class_code,l_event_class_code) <> l_event_class_code)
8178 )
8179 THEN
8180 xla_exceptions_pkg.raise_message
8181 (p_appli_s_name => 'XLA'
8182 ,p_msg_name => 'XLA_COMMON_ERROR'
8183 ,p_token_1 => 'ERROR'
8184 ,p_value_1 => 'Event type '||p_event_type_code||
8185 ' is not defined for the entity type '||p_entity_type_code||
8186 ', event class '||p_event_class_code||
8187 ' and application '||g_application_id
8188 ,p_token_2 => 'LOCATION'
8189 ,p_value_2 => 'xla_events_pkg.validate_event_type_code');
8190 END IF;
8191
8192 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8193 trace
8194 (p_msg => 'end of procedure validate_event_type_code'
8195 ,p_level => C_LEVEL_PROCEDURE
8196 ,p_module =>l_log_module);
8197 END IF;
8198
8199 trace('< xla_events_pkg.validate_event_type_code' , 20);
8200 EXCEPTION
8201 WHEN NO_DATA_FOUND THEN
8202 xla_exceptions_pkg.raise_message
8203 (p_appli_s_name => 'XLA'
8204 ,p_msg_name => 'XLA_COMMON_ERROR'
8205 ,p_token_1 => 'ERROR'
8206 ,p_value_1 => p_event_type_code||
8207 ' is not a defined event type for the application '||g_application_id
8208 ,p_token_2 => 'LOCATION'
8209 ,p_value_2 => 'xla_events_pkg.validate_event_type_code');
8210 WHEN xla_exceptions_pkg.application_exception THEN
8211 RAISE;
8212 WHEN OTHERS THEN
8213 xla_exceptions_pkg.raise_message
8214 (p_location => 'xla_events_pkg.validate_event_type_code');
8215 END validate_event_type_code;
8216
8217 --=============================================================================
8218 --
8219 --
8220 -- Changed to fix bug # 2899700.
8221 --
8222 --=============================================================================
8223
8224 PROCEDURE validate_status_code
8225 (p_event_status_code IN VARCHAR2
8226 ,p_process_status_code IN VARCHAR2) IS
8227 l_found BOOLEAN := FALSE;
8228 l_log_module VARCHAR2(240);
8229 BEGIN
8230 IF g_log_enabled THEN
8231 l_log_module := C_DEFAULT_MODULE||'.validate_status_code';
8232 END IF;
8233 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8234 trace
8235 (p_msg => 'BEGIN of procedure validate_status_code'
8236 ,p_level => C_LEVEL_PROCEDURE
8237 ,p_module =>l_log_module);
8238 END IF;
8239
8240 ----------------------------------------------------------------------------
8241 -- Validate event status code against the possible valid statuses
8242 ----------------------------------------------------------------------------
8243 FOR i IN g_event_status_code_tbl.FIRST .. g_event_status_code_tbl.LAST LOOP
8244 IF g_event_status_code_tbl(i) = p_event_status_code THEN
8245 l_found := TRUE;
8246 EXIT;
8247 END IF;
8248 END LOOP;
8249
8250 IF NOT l_found THEN
8251 xla_exceptions_pkg.raise_message
8252 (p_appli_s_name => 'XLA'
8253 ,p_msg_name => 'XLA_COMMON_ERROR'
8254 ,p_token_1 => 'ERROR'
8255 ,p_value_1 => 'Event Status Code cannot have a '||
8256 p_event_status_code ||
8257 ' value.'
8258 ,p_token_2 => 'LOCATION'
8259 ,p_value_2 => 'xla_events_pkg.validate_status_code');
8260 END IF;
8261
8262 ----------------------------------------------------------------------------
8263 -- Validate process status code against the possible valid statuses
8264 ----------------------------------------------------------------------------
8265 l_found := FALSE;
8266 FOR i IN g_process_status_code_tbl.FIRST .. g_process_status_code_tbl.LAST
8267 LOOP
8268 IF g_process_status_code_tbl(i) = p_process_status_code THEN
8269 l_found := TRUE;
8270 EXIT;
8271 END IF;
8272 END LOOP;
8273
8274 IF NOT l_found THEN
8275 xla_exceptions_pkg.raise_message
8276 (p_appli_s_name => 'XLA'
8277 ,p_msg_name => 'XLA_COMMON_ERROR'
8278 ,p_token_1 => 'ERROR'
8279 ,p_value_1 => 'Process Status Code cannot have a '||
8280 p_process_status_code ||
8281 ' value.'
8282 ,p_token_2 => 'LOCATION'
8283 ,p_value_2 => 'xla_events_pkg.validate_status_code');
8284 END IF;
8285
8286 ----------------------------------------------------------------------------
8287 -- following code is modified to fix bug # 2899700
8288 ----------------------------------------------------------------------------
8289 IF g_context = C_REGULAR_EVENT_CONTEXT THEN
8290
8291 -------------------------------------------------------------------------
8292 -- for regular events
8293 -------------------------------------------------------------------------
8294 IF p_process_status_code <> C_INTERNAL_UNPROCESSED THEN
8295 xla_exceptions_pkg.raise_message
8296 (p_appli_s_name => 'XLA'
8297 ,p_msg_name => 'XLA_COMMON_ERROR'
8298 ,p_token_1 => 'ERROR'
8299 ,p_value_1 => 'Process Status Code has an invalid value. '||
8300 'It should always have a ''Unprocessed'' value.'
8301 ,p_token_2 => 'LOCATION'
8302 ,p_value_2 => 'xla_events_pkg.validate_status_code');
8303 END IF;
8304
8305 IF p_event_status_code = xla_events_pub_pkg.C_EVENT_PROCESSED THEN
8306 xla_exceptions_pkg.raise_message
8307 (p_appli_s_name => 'XLA'
8308 ,p_msg_name => 'XLA_COMMON_ERROR'
8309 ,p_token_1 => 'ERROR'
8310 ,p_value_1 => 'Event Status Code has an invalid value. '||
8311 'It cannot have a ''Processed'' value.'
8312 ,p_token_2 => 'LOCATION'
8313 ,p_value_2 => 'xla_events_pkg.validate_status_code');
8314 END IF;
8315 ELSIF g_context = C_MANUAL_EVENT_CONTEXT THEN
8316
8317 -------------------------------------------------------------------------
8318 -- for manual events
8319 -------------------------------------------------------------------------
8320
8321 IF (p_process_status_code = C_INTERNAL_FINAL) THEN
8322 IF (p_event_status_code <> xla_events_pub_pkg.C_EVENT_PROCESSED) THEN
8323 xla_exceptions_pkg.raise_message
8324 (p_appli_s_name => 'XLA'
8325 ,p_msg_name => 'XLA_COMMON_ERROR'
8326 ,p_token_1 => 'ERROR'
8327 ,p_value_1 => 'The following combination is invalid: '||
8328 'Process Status Code = '|| p_process_status_code ||
8329 ', '||
8330 'Event Status Code = '|| p_event_status_code
8331 ,p_token_2 => 'LOCATION'
8332 ,p_value_2 => 'xla_events_pkg.validate_status_code');
8333 END IF;
8334 ELSIF (p_process_status_code = C_INTERNAL_DRAFT) THEN
8335 IF (p_event_status_code <> xla_events_pub_pkg.C_EVENT_UNPROCESSED) THEN
8336 xla_exceptions_pkg.raise_message
8337 (p_appli_s_name => 'XLA'
8338 ,p_msg_name => 'XLA_COMMON_ERROR'
8339 ,p_token_1 => 'ERROR'
8340 ,p_value_1 => 'The following combination is invalid: '||
8341 'Process Status Code = '|| p_process_status_code ||
8342 ', '||
8343 'Event Status Code = '|| p_event_status_code
8344 ,p_token_2 => 'LOCATION'
8345 ,p_value_2 => 'xla_events_pkg.validate_status_code');
8346 END IF;
8347 ELSIF (p_process_status_code = C_INTERNAL_UNPROCESSED) THEN
8348 IF (p_event_status_code = xla_events_pub_pkg.C_EVENT_PROCESSED) THEN
8349 xla_exceptions_pkg.raise_message
8350 (p_appli_s_name => 'XLA'
8351 ,p_msg_name => 'XLA_COMMON_ERROR'
8352 ,p_token_1 => 'ERROR'
8353 ,p_value_1 => 'The following combination is invalid: '||
8354 'Process Status Code = '|| p_process_status_code ||
8355 ', '||
8356 'Event Status Code = '|| p_event_status_code
8357 ,p_token_2 => 'LOCATION'
8358 ,p_value_2 => 'xla_events_pkg.validate_status_code');
8359 END IF;
8360 ELSE
8361 xla_exceptions_pkg.raise_message
8362 (p_appli_s_name => 'XLA'
8363 ,p_msg_name => 'XLA_COMMON_ERROR'
8364 ,p_token_1 => 'ERROR'
8365 ,p_value_1 => 'The following combination is invalid: '||
8366 'Process Status Code = '|| p_process_status_code ||
8367 ', '||
8368 'Event Status Code = '|| p_event_status_code
8369 ,p_token_2 => 'LOCATION'
8370 ,p_value_2 => 'xla_events_pkg.validate_status_code');
8371 END IF;
8372 END IF;
8373
8374 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8375 trace
8376 (p_msg => 'end of procedure validate_status_code'
8377 ,p_level => C_LEVEL_PROCEDURE
8378 ,p_module =>l_log_module);
8379 END IF;
8380 EXCEPTION
8381 WHEN xla_exceptions_pkg.application_exception THEN
8382 RAISE;
8383 WHEN OTHERS THEN
8384 xla_exceptions_pkg.raise_message
8385 (p_location => 'xla_events_pkg.validate_status_code');
8386 END validate_status_code;
8387
8388
8389 --=============================================================================
8390 --
8391 --
8392 -- Date validation is not needed as it is always truncated. (18-Jul-02)
8393 --
8394 --=============================================================================
8395
8396 PROCEDURE validate_params
8397 (p_source_info IN xla_events_pub_pkg.t_event_source_info
8398 ,p_event_class_code IN VARCHAR2 DEFAULT NULL
8399 ,p_event_type_code IN VARCHAR2 DEFAULT NULL
8400 ,p_event_date IN DATE DEFAULT NULL
8401 ,p_event_status_code IN VARCHAR2 DEFAULT NULL
8402 ,p_process_status_code IN VARCHAR2 DEFAULT NULL) IS
8403 l_log_module VARCHAR2(240);
8404 BEGIN
8405 IF g_log_enabled THEN
8406 l_log_module := C_DEFAULT_MODULE||'.validate_params';
8407 END IF;
8408 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8409 trace
8410 (p_msg => 'BEGIN of procedure validate_params'
8411 ,p_level => C_LEVEL_PROCEDURE
8412 ,p_module =>l_log_module);
8413 END IF;
8414
8415 ----------------------------------------------------------------------------
8416 -- Check all mandatory parameters are NOT NULL
8417 ----------------------------------------------------------------------------
8418 validate_context
8419 (p_application_id => p_source_info.application_id
8420 ,p_ledger_id => p_source_info.ledger_id
8421 ,p_entity_type_code => p_source_info.entity_type_code);
8422
8423 ----------------------------------------------------------------------------
8424 -- Do not check again the source_info if it has been kept the same
8425 ----------------------------------------------------------------------------
8426 IF source_info_changed(p_source_info,g_source_info,null,null) THEN
8427
8428 -------------------------------------------------------------------------
8429 -- Cache values for the application if not yet done
8430 -------------------------------------------------------------------------
8431 IF ((g_application_id IS NULL) OR
8432 (g_application_id <> p_source_info.application_id))
8433 THEN
8434 cache_application_setup
8435 (p_application_id => p_source_info.application_id);
8436 END IF;
8437
8438 validate_entity_type_code
8439 (p_entity_type_code => p_source_info.entity_type_code);
8440
8441 -------------------------------------------------------------------------
8442 -- Validate the source IDs
8443 -------------------------------------------------------------------------
8444 validate_ids
8445 (p_entity_type_code => p_source_info.entity_type_code
8446 ,p_source_id_int_1 => p_source_info.source_id_int_1
8447 ,p_source_id_int_2 => p_source_info.source_id_int_2
8448 ,p_source_id_int_3 => p_source_info.source_id_int_3
8449 ,p_source_id_int_4 => p_source_info.source_id_int_4
8450 ,p_source_id_char_1 => p_source_info.source_id_char_1
8451 ,p_source_id_char_2 => p_source_info.source_id_char_2
8452 ,p_source_id_char_3 => p_source_info.source_id_char_3
8453 ,p_source_id_char_4 => p_source_info.source_id_char_4);
8454 END IF;
8455
8456 ----------------------------------------------------------------------------
8457 -- Validate the class, if passed
8458 ----------------------------------------------------------------------------
8459 IF p_event_class_code IS NOT NULL THEN
8460 validate_event_class_code
8461 (p_entity_type_code => p_source_info.entity_type_code
8462 ,p_event_class_code => p_event_class_code);
8463 END IF;
8464
8465 ----------------------------------------------------------------------------
8466 -- Validate the event type, if passed
8467 ----------------------------------------------------------------------------
8468 IF p_event_type_code IS NOT NULL THEN
8469 validate_event_type_code
8470 (p_entity_type_code => p_source_info.entity_type_code
8471 ,p_event_class_code => p_event_class_code
8472 ,p_event_type_code => p_event_type_code);
8473 END IF;
8474
8475 ----------------------------------------------------------------------------
8476 -- Validate the event status code, if passed
8477 ----------------------------------------------------------------------------
8478 IF p_event_status_code IS NOT NULL THEN
8479 validate_status_code
8480 (p_event_status_code => p_event_status_code
8481 ,p_process_status_code => p_process_status_code);
8482 END IF;
8483 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8484 trace
8485 (p_msg => 'end of procedure validate_params'
8486 ,p_level => C_LEVEL_PROCEDURE
8487 ,p_module =>l_log_module);
8488 END IF;
8489
8490 EXCEPTION
8491 WHEN xla_exceptions_pkg.application_exception THEN
8492 RAISE;
8493 WHEN OTHERS THEN
8494 xla_exceptions_pkg.raise_message
8495 (p_location => 'xla_events_pkg.validate_params');
8496 END validate_params;
8497
8498
8499
8500 --=============================================================================
8501 --
8502 --
8503 --
8504 --=============================================================================
8505
8506 PROCEDURE validate_ledger
8507 (p_ledger_id IN NUMBER
8508 ,p_application_id IN NUMBER) IS
8509 l_enabled_flag VARCHAR2(1);
8510 l_log_module VARCHAR2(240);
8511 l_temp varchar2(1);
8512 l_application_name FND_APPLICATION_TL.application_name%TYPE;
8513 l_ledger_name VARCHAR2(30);
8514 BEGIN
8515 IF g_log_enabled THEN
8516 l_log_module := C_DEFAULT_MODULE||'.validate_ledger';
8517 END IF;
8518 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8519 trace
8520 (p_msg => 'BEGIN of procedure validate_ledger'
8521 ,p_level => C_LEVEL_PROCEDURE
8522 ,p_module =>l_log_module);
8523 trace
8524 (p_msg => 'p_ledger_id = '||p_ledger_id
8525 ,p_level => C_LEVEL_PROCEDURE
8526 ,p_module =>l_log_module);
8527 END IF;
8528
8529 l_application_name := get_application_name
8530 (p_application_id => p_application_id);
8531 l_ledger_name := get_ledger_name
8532 (p_ledger_id => p_ledger_id);
8533
8534 IF g_ledger_status_tbl.exists(p_ledger_id) THEN
8535 IF g_ledger_status_tbl(p_ledger_id) = 'Y' THEN
8536 NULL;
8537 ELSE
8538 xla_exceptions_pkg.raise_message
8539 (p_appli_s_name => 'XLA'
8540 ,p_msg_name => 'XLA_COMMON_ERROR'
8541 ,p_token_1 => 'ERROR'
8542 ,p_value_1 =>
8543 'The ledger is either not enabled or is marked as not to create events.'||
8544 'ledger_id = '||p_ledger_id||
8545 'application_id = '|| p_application_id
8546 ,p_token_2 => 'LOCATION'
8547 ,p_value_2 => 'xla_events_pkg.validate_ledger');
8548 END IF;
8549 ELSE
8550 BEGIN
8551 SELECT DECODE(enabled_flag
8552 ,'N','N'
8553 ,'Y',capture_event_flag)
8554 INTO l_temp --g_ledger_status_tbl(p_ledger_id)
8555 FROM xla_subledger_options_v
8556 WHERE ledger_id = p_ledger_id
8557 AND application_id = p_application_id;
8558 EXCEPTION
8559 WHEN NO_DATA_FOUND THEN
8560 xla_exceptions_pkg.raise_message
8561 (p_appli_s_name => 'XLA'
8562 ,p_msg_name => 'XLA_SU_MISSING_SETUP'
8563 ,p_token_1 => 'LEDGER_NAME'
8564 ,p_value_1 => l_ledger_name
8565 ,p_token_2 => 'APPLICATION_NAME'
8566 ,p_value_2 => l_application_name);
8567 END;
8568 END IF;
8569
8570 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8571 trace
8572 (p_msg => 'END of procedure validate_ledger'
8573 ,p_level => C_LEVEL_PROCEDURE
8574 ,p_module =>l_log_module);
8575 END IF;
8576
8577 EXCEPTION
8578 WHEN xla_exceptions_pkg.application_exception THEN
8579 RAISE;
8580 WHEN OTHERS THEN
8581 xla_exceptions_pkg.raise_message
8582 (p_location => 'xla_events_pkg.validate_ledger');
8583 END validate_ledger;
8584
8585
8586 --=============================================================================
8587 --
8588 --
8589 --
8590 --=============================================================================
8591
8592 PROCEDURE cache_entity_info
8593 (p_source_info IN xla_events_pub_pkg.t_event_source_info
8594 ,p_valuation_method IN VARCHAR2
8595 ,p_event_id IN NUMBER) IS -- 8761772
8596
8597 l_source_info xla_events_pub_pkg.t_event_source_info;
8598
8599 -------------------------------------------------------------------------------
8600 -- Following three cursors have been modified to remove the 'for update'.
8601 -- The cursors c1 and c2 have also been modified to include 'group by' rather
8602 -- than a subquery to get the max(event_number). Bug 3268790
8603 -------------------------------------------------------------------------------
8604 -------------------------------------------------------------------------------
8605 -- Bug 4312353. The following cursor is modifed to use the valuation method as
8606 -- part of primary key to identify transactions. Removed other security
8607 -- columns
8608 -------------------------------------------------------------------------------
8609
8610 CURSOR c1 IS
8611 SELECT xte.entity_id
8612 ,xte.entity_code
8613 ,xte.transaction_number
8614 ,max(xe.event_number)
8615 ,xet.enable_gapless_events_flag
8616 FROM xla_transaction_entities xte
8617 ,xla_events xe
8618 ,xla_entity_types_b xet
8619 WHERE xte.application_id = p_source_info.application_id
8620 AND xte.ledger_id = p_source_info.ledger_id
8621 AND xte.entity_code = p_source_info.entity_type_code
8622 AND NVL(xte.source_id_int_1,-99) = NVL(p_source_info.source_id_int_1,-99)
8623 AND NVL(xte.source_id_int_2,-99) = NVL(p_source_info.source_id_int_2,-99)
8624 AND NVL(xte.source_id_int_3,-99) = NVL(p_source_info.source_id_int_3,-99)
8625 AND NVL(xte.source_id_int_4,-99) = NVL(p_source_info.source_id_int_4,-99)
8626 AND NVL(xte.source_id_char_1,' ') = NVL(p_source_info.source_id_char_1,' ')
8627 AND NVL(xte.source_id_char_2,' ') = NVL(p_source_info.source_id_char_2,' ')
8628 AND NVL(xte.source_id_char_3,' ') = NVL(p_source_info.source_id_char_3,' ')
8629 AND NVL(xte.source_id_char_4,' ') = NVL(p_source_info.source_id_char_4,' ')
8630 AND NVL(xte.valuation_method,' ') = NVL(p_valuation_method,' ')
8631 AND xe.entity_id = xte.entity_id
8632 AND xe.application_id = xte.application_id -- 8967771
8633 AND xet.application_id = xte.application_id
8634 AND xte.entity_code = xet.entity_code
8635 GROUP BY
8636 xte.entity_id,
8637 xte.entity_code,
8638 xte.transaction_number,
8639 xet.enable_gapless_events_flag;
8640
8641
8642 CURSOR get_gapless_flag is
8643 SELECT a.enable_gapless_events_flag
8644 FROM xla_entity_types_b a
8645 WHERE a.entity_code=p_source_info.entity_type_code
8646 AND a.application_id=p_source_info.application_id;
8647
8648 CURSOR c2 IS
8649 SELECT a.entity_id
8650 ,a.entity_code
8651 ,a.transaction_number
8652 ,MAX(b.event_number)
8653 ,c.enable_gapless_events_flag
8654 FROM xla_transaction_entities a
8655 ,xla_events b
8656 ,xla_entity_types_b c
8657 WHERE a.application_id = p_source_info.application_id
8658 AND a.entity_id = g_entity_id
8659 AND b.entity_id = g_entity_id
8660 AND b.application_id = a.application_id -- 8967771
8661 and a.entity_code=c.entity_code
8662 AND a.application_id = c.application_id
8663 GROUP BY
8664 a.entity_id,
8665 a.entity_code,
8666 a.transaction_number,
8667 c.enable_gapless_events_flag;
8668
8669 -------------------------------------------------------------------------------
8670 -- following cursor is for Manual entries.
8671 -------------------------------------------------------------------------------
8672
8673 CURSOR c3 (eventid IN NUMBER) IS
8674 SELECT a.entity_id
8675 ,a.entity_code
8676 ,a.transaction_number
8677 ,b.event_number
8678 FROM xla_transaction_entities a
8679 ,xla_events b
8680 WHERE b.event_id = eventid
8681 AND b.application_id = p_source_info.application_id -- 8967771
8682 AND a.entity_id = b.entity_id
8683 AND a.application_id = p_source_info.application_id;
8684 -- FOR UPDATE NOWAIT;
8685
8686
8687
8688 CURSOR c_lock_te (entityid in number) is
8689 SELECT a.entity_id
8690 FROM xla_transaction_entities a
8691 WHERE a.entity_id=entityid
8692 AND a.application_id = p_source_info.application_id
8693 FOR UPDATE NOWAIT;
8694
8695 -- Added new cursor c4 bug 10649546
8696
8697 CURSOR c4 IS
8698 SELECT xte.entity_id
8699 ,xte.entity_code
8700 ,xte.transaction_number
8701 ,nvl(max(xe.event_number),0)
8702 ,xet.enable_gapless_events_flag
8703 FROM xla_transaction_entities xte
8704 ,xla_events xe
8705 ,xla_entity_types_b xet
8706 WHERE xte.application_id = p_source_info.application_id
8707 AND xte.ledger_id = p_source_info.ledger_id
8708 AND xte.entity_code = p_source_info.entity_type_code
8709 AND NVL(xte.source_id_int_1,-99) = NVL(p_source_info.source_id_int_1,-99)
8710 AND NVL(xte.source_id_int_2,-99) = NVL(p_source_info.source_id_int_2,-99)
8711 AND NVL(xte.source_id_int_3,-99) = NVL(p_source_info.source_id_int_3,-99)
8712 AND NVL(xte.source_id_int_4,-99) = NVL(p_source_info.source_id_int_4,-99)
8713 AND NVL(xte.source_id_char_1,' ') = NVL(p_source_info.source_id_char_1,' ')
8714 AND NVL(xte.source_id_char_2,' ') = NVL(p_source_info.source_id_char_2,' ')
8715 AND NVL(xte.source_id_char_3,' ') = NVL(p_source_info.source_id_char_3,' ')
8716 AND NVL(xte.source_id_char_4,' ') = NVL(p_source_info.source_id_char_4,' ')
8717 AND NVL(xte.valuation_method,' ') = NVL(p_valuation_method,' ')
8718 AND xe.entity_id(+) = xte.entity_id
8719 AND xe.application_id (+) = xte.application_id -- 8967771
8720 AND xet.application_id = xte.application_id
8721 AND xte.entity_code = xet.entity_code
8722 GROUP BY
8723 xte.entity_id,
8724 xte.entity_code,
8725 xte.transaction_number,
8726 xet.enable_gapless_events_flag;
8727
8728 -- end bug 10649546
8729
8730
8731 l_log_module VARCHAR2(240);
8732
8733 BEGIN
8734 IF g_log_enabled THEN
8735 l_log_module := C_DEFAULT_MODULE||'cache_entity_info';
8736 END IF;
8737 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8738 trace
8739 (p_msg => 'BEGIN of procedure cache_entity_info'
8740 ,p_level => C_LEVEL_PROCEDURE
8741 ,p_module =>l_log_module);
8742 trace
8743 (p_msg => 'p_event_id = '||p_event_id
8744 ,p_level => C_LEVEL_PROCEDURE
8745 ,p_module =>l_log_module);
8746 END IF;
8747
8748 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8749 trace
8750 (p_msg => 'g_context = '||g_context
8751 ,p_level => C_LEVEL_STATEMENT
8752 ,p_module =>l_log_module);
8753 END IF;
8754
8755 IF g_context = C_MANUAL_EVENT_CONTEXT THEN
8756 -------------------------------------------------------------------------
8757 -- for manual events
8758 -------------------------------------------------------------------------
8759 IF p_event_id IS NULL THEN
8760 g_entity_id := NULL;
8761 g_entity_type_code := NULL;
8762 g_transaction_number := NULL;
8763 g_max_event_number := 0;
8764 ELSE
8765 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8766 trace
8767 (p_msg => 'using cursor c3'
8768 ,p_level => C_LEVEL_STATEMENT
8769 ,p_module =>l_log_module);
8770 END IF;
8771
8772 OPEN c3(p_event_id);
8773 FETCH c3 INTO g_entity_id
8774 ,g_entity_type_code
8775 ,g_transaction_number
8776 ,g_max_event_number;
8777
8778 IF c3%NOTFOUND THEN
8779 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8780 trace
8781 (p_msg => 'cursor c3 did not fetch a row'
8782 ,p_level => C_LEVEL_STATEMENT
8783 ,p_module =>l_log_module);
8784 END IF;
8785
8786 g_entity_id := NULL;
8787 g_entity_type_code := NULL;
8788 g_transaction_number := NULL;
8789 g_max_event_number := 0;
8790 END IF;
8791 CLOSE c3;
8792 END IF;
8793
8794 g_source_info := p_source_info;
8795 g_valuation_method := p_valuation_method;
8796 ELSE
8797 IF source_info_changed(p_source_info,g_source_info,
8798 p_valuation_method,g_valuation_method) THEN
8799 -------------------------------------------------------------------------
8800 -- for regular events where source info has changed
8801 -------------------------------------------------------------------------
8802 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8803 trace
8804 (p_msg => 'using cursor c1'
8805 ,p_level => C_LEVEL_STATEMENT
8806 ,p_module =>l_log_module);
8807 END IF;
8808
8809 OPEN c1;
8810 FETCH c1 INTO g_entity_id
8811 ,g_entity_type_code
8812 ,g_transaction_number
8813 ,g_max_event_number
8814 ,g_gapless_flag;
8815 IF c1%NOTFOUND THEN
8816 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8817 trace
8818 (p_msg => 'cursor c1 did not fetch a row'
8819 ,p_level => C_LEVEL_STATEMENT
8820 ,p_module =>l_log_module);
8821 END IF;
8822
8823 g_entity_id := NULL;
8824 g_entity_type_code := NULL;
8825 g_transaction_number := NULL;
8826 g_max_event_number := 0;
8827
8828 open get_gapless_flag;
8829 fetch get_gapless_flag into g_gapless_flag;
8830 if(get_gapless_flag%NOTFOUND) THEN
8831 g_gapless_flag :='N';
8832 end if;
8833 close get_gapless_flag;
8834 END IF;
8835 CLOSE c1;
8836
8837 if (g_gapless_flag='Y' and
8838 (g_action = C_EVENT_DELETE or
8839 g_action = C_EVENT_UPDATE or
8840 g_action = C_EVENT_CREATE)) then
8841 -- lock xla_trancation_entity table
8842 open c_lock_te(g_entity_id);
8843 close c_lock_te;
8844 end if;
8845 g_source_info := p_source_info;
8846 g_valuation_method := p_valuation_method;
8847 ELSE
8848 -------------------------------------------------------------------------
8849 -- for regular events where source info has not changed
8850 -------------------------------------------------------------------------
8851 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8852 trace
8853 (p_msg => 'using cursor c2'
8854 ,p_level => C_LEVEL_STATEMENT
8855 ,p_module =>l_log_module);
8856 END IF;
8857
8858 OPEN c2;
8859 FETCH c2 INTO g_entity_id
8860 ,g_entity_type_code
8861 ,g_transaction_number
8862 ,g_max_event_number
8863 ,g_gapless_flag;
8864 IF c2%NOTFOUND THEN
8865 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8866 trace
8867 (p_msg => 'cursor c2 did not fetch a row'
8868 ,p_level => C_LEVEL_STATEMENT
8869 ,p_module =>l_log_module);
8870 END IF;
8871
8872 g_entity_id := NULL;
8873 g_entity_type_code := NULL;
8874 g_transaction_number := NULL;
8875 g_max_event_number := 0;
8876
8877 /* Commented bug 10649546 to do changes of bug 9235968 and bug 10649546 in one cursor C4
8878 -- added bug 9235968
8879 IF g_entity_id is NULL THEN
8880
8881 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8882 trace
8883 (p_msg => 'using cursor c1 again'
8884 ,p_level => C_LEVEL_STATEMENT
8885 ,p_module =>l_log_module);
8886 END IF;
8887
8888 OPEN c1;
8889 FETCH c1 INTO g_entity_id
8890 ,g_entity_type_code
8891 ,g_transaction_number
8892 ,g_max_event_number
8893 ,g_gapless_flag;
8894 IF c1%NOTFOUND THEN
8895 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8896 trace
8897 (p_msg => 'cursor c1 also did not fetch a row'
8898 ,p_level => C_LEVEL_STATEMENT
8899 ,p_module =>l_log_module);
8900 END IF;
8901 g_entity_id := NULL;
8902 g_entity_type_code := NULL;
8903 g_transaction_number := NULL;
8904 g_max_event_number := 0;
8905 END IF;
8906 END IF;
8907 --end bug 10649546 */
8908
8909
8910
8911
8912
8913 open get_gapless_flag;
8914 fetch get_gapless_flag into g_gapless_flag;
8915 if(get_gapless_flag%NOTFOUND) THEN
8916 g_gapless_flag :='N';
8917 end if;
8918 close get_gapless_flag;
8919 ELSIF g_entity_type_code <> p_source_info.entity_type_code THEN
8920 ----------------------------------------------------------------------
8921 -- this was added to handle some special cases ????
8922 ----------------------------------------------------------------------
8923 g_source_info := l_source_info;
8924 g_valuation_method := NULL;
8925 cache_entity_info
8926 (p_source_info => p_source_info
8927 ,p_valuation_method => p_valuation_method
8928 ,p_event_id => NULL);
8929 END IF;
8930 if (g_gapless_flag='Y' and
8931 (g_action = C_EVENT_DELETE or
8932 g_action = C_EVENT_UPDATE or
8933 g_action = C_EVENT_CREATE)) then
8934 -- lock xla_trancation_entity table
8935 open c_lock_te(g_entity_id);
8936 close c_lock_te;
8937 end if;
8938 CLOSE c2;
8939 END IF;
8940
8941 -- Added bug 10649546
8942
8943
8944 IF g_entity_id is NULL THEN
8945
8946 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8947 trace
8948 (p_msg => 'using final cursor c4'
8949 ,p_level => C_LEVEL_STATEMENT
8950 ,p_module =>l_log_module);
8951 END IF;
8952
8953 OPEN c4;
8954 FETCH c4 INTO g_entity_id
8955 ,g_entity_type_code
8956 ,g_transaction_number
8957 ,g_max_event_number
8958 ,g_gapless_flag;
8959 IF c4%NOTFOUND THEN
8960 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
8961 trace
8962 (p_msg => 'cursor c4 also did not fetch a row'
8963 ,p_level => C_LEVEL_STATEMENT
8964 ,p_module =>l_log_module);
8965 END IF;
8966 g_entity_id := NULL;
8967 g_entity_type_code := NULL;
8968 g_transaction_number := NULL;
8969 g_max_event_number := 0;
8970 open get_gapless_flag;
8971 fetch get_gapless_flag into g_gapless_flag;
8972 if(get_gapless_flag%NOTFOUND) THEN
8973 g_gapless_flag :='N';
8974 end if;
8975 close get_gapless_flag;
8976 END IF;
8977 CLOSE c4;
8978
8979 If (g_gapless_flag='Y' and
8980 (g_action = C_EVENT_DELETE or
8981 g_action = C_EVENT_UPDATE or
8982 g_action = C_EVENT_CREATE)) then
8983 -- lock xla_transaction_entity table
8984 open c_lock_te(g_entity_id);
8985 close c_lock_te;
8986 end if;
8987 g_source_info := p_source_info;
8988 g_valuation_method := p_valuation_method;
8989
8990
8991 END IF;
8992
8993 -- end bug 10649546
8994 END IF;
8995
8996 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8997 trace
8998 (p_msg => 'g_entity_id = '||g_entity_id
8999 ,p_level => C_LEVEL_PROCEDURE
9000 ,p_module =>l_log_module);
9001 trace
9002 (p_msg => 'end of procedure cache_entity_info'
9003 ,p_level => C_LEVEL_PROCEDURE
9004 ,p_module =>l_log_module);
9005 END IF;
9006
9007 EXCEPTION
9008 WHEN xla_exceptions_pkg.application_exception THEN
9009 IF c1%ISOPEN THEN
9010 CLOSE c1;
9011 END IF;
9012 IF c2%ISOPEN THEN
9013 CLOSE c2;
9014 END IF;
9015 IF c4%ISOPEN THEN -- Added bug 10649546
9016 CLOSE c4;
9017 END IF; -- end bug 10649546
9018 RAISE;
9019 WHEN OTHERS THEN
9020 IF c1%ISOPEN THEN
9021 CLOSE c1;
9022 END IF;
9023 IF c2%ISOPEN THEN
9024 CLOSE c2;
9025 END IF;
9026 IF c4%ISOPEN THEN -- Added bug 10649546
9027 CLOSE c4;
9028 END IF; -- end bug 10649546
9029 xla_exceptions_pkg.raise_message
9030 (p_location => 'xla_events_pkg.cache_entity_info');
9031 END cache_entity_info;
9032
9033
9034 --=============================================================================
9035 --
9036 --
9037 -- Changed to fix bug # 2899700. (Added parameter p_process_status_code)
9038 --
9039 --=============================================================================
9040
9041 FUNCTION create_entity_event
9042 (p_event_source_info IN xla_events_pub_pkg.t_event_source_info
9043 ,p_valuation_method IN VARCHAR2
9044 ,p_event_type_code IN VARCHAR2
9045 ,p_event_date IN DATE
9046 ,p_event_status_code IN VARCHAR2
9047 ,p_process_status_code IN VARCHAR2
9048 ,p_event_number IN NUMBER
9049 ,p_transaction_date IN DATE
9050 ,p_reference_info IN xla_events_pub_pkg.t_event_reference_info
9051 DEFAULT NULL
9052 ,p_budgetary_control_flag IN VARCHAR2)
9053 RETURN INTEGER IS
9054
9055 l_entity_id INTEGER;
9056 l_log_module VARCHAR2(240);
9057 l_return_id INTEGER;
9058 BEGIN
9059 IF g_log_enabled THEN
9060 l_log_module := C_DEFAULT_MODULE||'.create_entity_event';
9061 END IF;
9062 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9063 trace
9064 (p_msg => 'BEGIN of procedure create_entity_event'
9065 ,p_level => C_LEVEL_PROCEDURE
9066 ,p_module =>l_log_module);
9067 END IF;
9068
9069 INSERT INTO xla_transaction_entities
9070 (entity_id
9071 ,application_id
9072 ,source_application_id
9073 ,ledger_id
9074 ,legal_entity_id
9075 ,entity_code
9076 ,transaction_number
9077 ,creation_date
9078 ,created_by
9079 ,last_update_date
9080 ,last_updated_by
9081 ,last_update_login
9082 ,valuation_method
9083 ,security_id_int_1
9084 ,security_id_int_2
9085 ,security_id_int_3
9086 ,security_id_char_1
9087 ,security_id_char_2
9088 ,security_id_char_3
9089 ,source_id_int_1
9090 ,source_id_int_2
9091 ,source_id_int_3
9092 ,source_id_int_4
9093 ,source_id_char_1
9094 ,source_id_char_2
9095 ,source_id_char_3
9096 ,source_id_char_4)
9097 VALUES
9098 (xla_transaction_entities_s.nextval
9099 ,p_event_source_info.application_id
9100 ,NVL(p_event_source_info.source_application_id,
9101 p_event_source_info.application_id)
9102 ,p_event_source_info.ledger_id
9103 ,p_event_source_info.legal_entity_id
9104 ,p_event_source_info.entity_type_code
9105 ,p_event_source_info.transaction_number
9106 ,sysdate
9107 ,xla_environment_pkg.g_usr_id
9108 ,sysdate
9109 ,xla_environment_pkg.g_usr_id
9110 ,xla_environment_pkg.g_login_id
9111 ,p_valuation_method
9112 ,xla_events_pub_pkg.g_security.security_id_int_1
9113 ,xla_events_pub_pkg.g_security.security_id_int_2
9114 ,xla_events_pub_pkg.g_security.security_id_int_3
9115 ,xla_events_pub_pkg.g_security.security_id_char_1
9116 ,xla_events_pub_pkg.g_security.security_id_char_2
9117 ,xla_events_pub_pkg.g_security.security_id_char_3
9118 ,p_event_source_info.source_id_int_1
9119 ,p_event_source_info.source_id_int_2
9120 ,p_event_source_info.source_id_int_3
9121 ,p_event_source_info.source_id_int_4
9122 ,p_event_source_info.source_id_char_1
9123 ,p_event_source_info.source_id_char_2
9124 ,p_event_source_info.source_id_char_3
9125 ,p_event_source_info.source_id_char_4)
9126 RETURNING entity_id INTO l_entity_id;
9127
9128 g_entity_id := l_entity_id;
9129 g_entity_type_code := p_event_source_info.entity_type_code;
9130 g_transaction_number := p_event_source_info.transaction_number;
9131 g_max_event_number := 0;
9132
9133 l_return_id:=add_entity_event
9134 (p_entity_id => l_entity_id
9135 ,p_application_id => p_event_source_info.application_id
9136 ,p_ledger_id => p_event_source_info.ledger_id
9137 ,p_legal_entity_id => p_event_source_info.legal_entity_id
9138 ,p_event_type_code => p_event_type_code
9139 ,p_event_date => p_event_date
9140 ,p_event_status_code => p_event_status_code
9141 ,p_process_status_code => p_process_status_code
9142 ,p_event_number => p_event_number
9143 ,p_transaction_date => p_transaction_date
9144 ,p_reference_info => p_reference_info
9145 ,p_budgetary_control_flag => p_budgetary_control_flag);
9146 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9147 trace
9148 (p_msg => 'end of procedure create_entity_event'
9149 ,p_level => C_LEVEL_PROCEDURE
9150 ,p_module =>l_log_module);
9151 trace
9152 (p_msg => 'return value:'||to_char(l_return_id)
9153 ,p_level => C_LEVEL_PROCEDURE
9154 ,p_module =>l_log_module);
9155 END IF;
9156
9157 return l_return_id;
9158
9159 EXCEPTION
9160 WHEN xla_exceptions_pkg.application_exception THEN
9161 RAISE;
9162 WHEN OTHERS THEN
9163 xla_exceptions_pkg.raise_message
9164 (p_location => 'xla_events_pkg.create_entity_event');
9165 END create_entity_event;
9166
9167
9168 --=============================================================================
9169 --
9170 --
9171 --
9172 --=============================================================================
9173
9174 PROCEDURE update_entity_trx_number
9175 (p_transaction_number IN VARCHAR2) IS
9176 l_log_module VARCHAR2(240);
9177 BEGIN
9178 IF g_log_enabled THEN
9179 l_log_module := C_DEFAULT_MODULE||'.update_entity_trx_number';
9180 END IF;
9181 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9182 trace
9183 (p_msg => 'BEGIN of procedure update_entity_trx_number'
9184 ,p_level => C_LEVEL_PROCEDURE
9185 ,p_module =>l_log_module);
9186 END IF;
9187
9188 UPDATE xla_transaction_entities
9189 SET transaction_number = p_transaction_number
9190 WHERE entity_id = g_entity_id
9191 AND application_id = g_application_id;
9192
9193 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9194 trace
9195 (p_msg => 'end of procedure update_entity_trx_number'
9196 ,p_level => C_LEVEL_PROCEDURE
9197 ,p_module =>l_log_module);
9198 END IF;
9199
9200 EXCEPTION
9201 WHEN xla_exceptions_pkg.application_exception THEN
9202 RAISE;
9203 WHEN OTHERS THEN
9204 xla_exceptions_pkg.raise_message
9205 (p_location => 'xla_events_pkg.update_entity_trx_number');
9206 END update_entity_trx_number;
9207
9208 --=============================================================================
9209 --
9210 --
9211 -- Changed to fix bug # 2899700. (Added parameter p_process_status_code)
9212 --
9213 --=============================================================================
9214
9215 FUNCTION add_entity_event
9216 (p_entity_id IN INTEGER
9217 ,p_application_id IN INTEGER
9218 ,p_ledger_id IN INTEGER
9219 ,p_legal_entity_id IN INTEGER
9220 ,p_event_type_code IN VARCHAR2
9221 ,p_event_date IN DATE
9222 ,p_event_status_code IN VARCHAR2
9223 ,p_process_status_code IN VARCHAR2
9224 ,p_event_number IN NUMBER
9225 ,p_transaction_date IN DATE
9226 ,p_reference_info IN xla_events_pub_pkg.t_event_reference_info
9227 DEFAULT NULL
9228 ,p_budgetary_control_flag IN VARCHAR2)
9229 RETURN INTEGER IS
9230 l_event_id INTEGER;
9231 l_on_hold_flag XLA_EVENTS.ON_HOLD_FLAG%TYPE:='N';
9232 l_event_status_code XLA_EVENTS.EVENT_STATUS_CODE%TYPE;
9233 l_temp_event_number XLA_EVENTS.event_number%TYPE;
9234 l_log_module VARCHAR2(240);
9235 BEGIN
9236 IF g_log_enabled THEN
9237 l_log_module := C_DEFAULT_MODULE||'.add_entity_event';
9238 END IF;
9239 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9240 trace
9241 (p_msg => 'BEGIN of procedure add_entity_event'
9242 ,p_level => C_LEVEL_PROCEDURE
9243 ,p_module =>l_log_module);
9244 END IF;
9245
9246 if(g_gapless_flag='Y' and p_event_number>1) then
9247 begin
9248 select on_hold_flag, event_status_code
9249 into l_on_hold_flag, l_event_status_code
9250 from xla_events
9251 where entity_id=p_entity_id
9252 and event_number=p_event_number-1
9253 and application_id = p_application_id -- 8967771
9254 ;
9255 exception
9256 when no_data_found then
9257 l_on_hold_flag:='Y';
9258 end;
9259 if(l_on_hold_flag = 'N' and l_event_status_code = 'I' ) then
9260 l_on_hold_flag := 'Y';
9261 end if;
9262 end if;
9263
9264 INSERT INTO xla_events
9265 (event_id
9266 ,application_id
9267 ,event_type_code
9268 ,entity_id
9269 ,event_number
9270 ,transaction_date
9271 ,event_status_code
9272 ,process_status_code
9273 ,event_date
9274 ,budgetary_control_flag
9275 ,creation_date
9276 ,created_by
9277 ,last_update_date
9278 ,last_updated_by
9279 ,last_update_login
9280 ,program_update_date
9281 ,program_application_id
9282 ,program_id
9283 ,request_id
9284 ,reference_num_1
9285 ,reference_num_2
9286 ,reference_num_3
9287 ,reference_num_4
9288 ,reference_char_1
9289 ,reference_char_2
9290 ,reference_char_3
9291 ,reference_char_4
9292 ,reference_date_1
9293 ,reference_date_2
9294 ,reference_date_3
9295 ,reference_date_4
9296 ,on_hold_flag)
9297 VALUES
9298 (xla_events_s.nextval
9299 ,p_application_id
9300 ,p_event_type_code
9301 ,p_entity_id
9302 ,NVL(p_event_number,g_max_event_number + 1)
9303 ,NVL(p_transaction_date, TRUNC(p_event_date))
9304 ,p_event_status_code
9305 ,p_process_status_code
9306 ,TRUNC(p_event_date)
9307 ,p_budgetary_control_flag
9308 ,sysdate
9309 ,xla_environment_pkg.g_usr_id
9310 ,sysdate
9311 ,xla_environment_pkg.g_usr_id
9312 ,xla_environment_pkg.g_login_id
9313 ,sysdate
9314 ,xla_environment_pkg.g_prog_appl_id
9315 ,xla_environment_pkg.g_prog_id
9316 ,xla_environment_pkg.g_Req_Id
9317 ,p_reference_info.reference_num_1
9318 ,p_reference_info.reference_num_2
9319 ,p_reference_info.reference_num_3
9320 ,p_reference_info.reference_num_4
9321 ,p_reference_info.reference_char_1
9322 ,p_reference_info.reference_char_2
9323 ,p_reference_info.reference_char_3
9324 ,p_reference_info.reference_char_4
9325 ,p_reference_info.reference_date_1
9326 ,p_reference_info.reference_date_2
9327 ,p_reference_info.reference_date_3
9328 ,p_reference_info.reference_date_4
9329 ,l_on_hold_flag)
9330 RETURNING event_id INTO l_event_id;
9331
9332 if(l_on_hold_flag = 'N' and
9333 g_gapless_flag='Y' and p_event_status_code<>'I') then
9334 -- set the following event on_hold to 'N'
9335
9336 SELECT event_status_code, event_number BULK COLLECT
9337 INTO g_gapless_array_event_status, g_gapless_event_number
9338 FROM xla_events
9339 Where entity_id = g_entity_id
9340 and event_number> p_event_number
9341 and application_id = p_application_id -- 8967771
9342 Order by event_number;
9343
9344 l_temp_event_number:=p_event_number+1;
9345 For j in 1..g_gapless_event_number.COUNT loop
9346 if(g_gapless_event_number(j)=l_temp_event_number
9347 and g_gapless_array_event_status(j)<>'I') then
9348 l_temp_event_number:=l_temp_event_number+1;
9349 else
9350 exit;
9351 end if;
9352 end loop;
9353 --l_temp_event_number is the next gap
9354 -- update the on_hold_flag of event between l_array_event_number(i)
9355 -- and --l_temp_event_number+1
9356
9357 update xla_events
9358 set on_hold_flag='N'
9359 where entity_id=p_entity_id
9360 and event_number >p_event_number
9361 and event_number <l_temp_event_number+1
9362 and application_id = p_application_id -- 8967771
9363 ;
9364
9365 end if;
9366
9367
9368 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9369 trace
9370 (p_msg => 'end of procedure add_entity_event'
9371 ,p_level => C_LEVEL_PROCEDURE
9372 ,p_module =>l_log_module);
9373 trace
9374 (p_msg => 'return value:'||to_char(l_event_id)
9375 ,p_level => C_LEVEL_PROCEDURE
9376 ,p_module =>l_log_module);
9377 END IF;
9378 RETURN l_event_id;
9379 EXCEPTION
9380 WHEN xla_exceptions_pkg.application_exception THEN
9381 RAISE;
9382 WHEN OTHERS THEN
9383 xla_exceptions_pkg.raise_message
9384 (p_location => 'xla_events_pkg.add_event (fn)');
9385 END add_entity_event;
9386
9387
9388 --=============================================================================
9389 --
9390 --
9391 --
9392 --=============================================================================
9393
9394 PROCEDURE reset_cache IS
9395 l_dummy_class_tbl t_array_event_class;
9396 l_dummy_type_tbl t_array_event_type;
9397 l_dummy_entity_tbl t_array_entity_type;
9398 l_dummy_tbl t_parameter_tbl;
9399 l_source_info xla_events_pub_pkg.t_event_source_info;
9400 l_log_module VARCHAR2(240);
9401 BEGIN
9402 IF g_log_enabled THEN
9403 l_log_module := C_DEFAULT_MODULE||'.reset_cache';
9404 END IF;
9405 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9406 trace
9407 (p_msg => 'BEGIN of procedure reset_cache'
9408 ,p_level => C_LEVEL_PROCEDURE
9409 ,p_module =>l_log_module);
9410 END IF;
9411
9412
9413 g_entity_id := NULL;
9414 g_entity_type_code := NULL;
9415 g_valuation_method := NULL;
9416
9417 g_max_event_number := 0;
9418 g_application_id := NULL;
9419 g_action := NULL;
9420 g_gapless_flag :='N';
9421
9422 --
9423 -- Clear all cache but the event status which is static
9424 --
9425 g_entity_type_code_tbl := l_dummy_entity_tbl ;
9426 g_event_class_code_tbl := l_dummy_class_tbl ;
9427 g_event_type_code_tbl := l_dummy_type_tbl ;
9428 g_ledger_status_tbl.delete;
9429 g_source_info := l_source_info;
9430 -- g_context := C_CONTEXT_EVENTAPI;
9431
9432 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9433 trace
9434 (p_msg => 'end of reset_cache'
9435 ,p_level => C_LEVEL_PROCEDURE
9436 ,p_module =>l_log_module);
9437 END IF;
9438
9439 EXCEPTION
9440 WHEN xla_exceptions_pkg.application_exception THEN
9441 RAISE;
9442 WHEN OTHERS THEN
9443 xla_exceptions_pkg.raise_message
9444 (p_location => 'xla_events_pkg.reset_cache');
9445 END reset_cache;
9446
9447
9448 --=============================================================================
9449 --
9450 --
9451 --
9452 --=============================================================================
9453
9454 PROCEDURE set_context
9455 (p_context IN VARCHAR2) IS
9456 l_log_module VARCHAR2(240);
9457 BEGIN
9458 IF g_log_enabled THEN
9459 l_log_module := C_DEFAULT_MODULE||'.set_context';
9460 END IF;
9461 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9462 trace
9463 (p_msg => 'BEGIN of procedure set_context'
9464 ,p_level => C_LEVEL_PROCEDURE
9465 ,p_module =>l_log_module);
9466 END IF;
9467 g_context := p_context;
9468
9469 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9470 trace
9471 (p_msg => 'end of procedure set_context'
9472 ,p_level => C_LEVEL_PROCEDURE
9473 ,p_module =>l_log_module);
9474 END IF;
9475 EXCEPTION
9476 WHEN xla_exceptions_pkg.application_exception THEN
9477 RAISE;
9478 WHEN OTHERS THEN
9479 xla_exceptions_pkg.raise_message
9480 (p_location => 'xla_events_pkg.set_context');
9481 END set_context;
9482
9483
9484 --=============================================================================
9485 --
9486 --
9487 --
9488 --=============================================================================
9489
9490 PROCEDURE delete_je IS
9491 l_log_module VARCHAR2(240);
9492 BEGIN
9493 IF g_log_enabled THEN
9494 l_log_module := C_DEFAULT_MODULE||'.delete_je';
9495 END IF;
9496 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9497 trace
9498 (p_msg => 'BEGIN of procedure DELETE_JE'
9499 ,p_level => C_LEVEL_PROCEDURE
9500 ,p_module => l_log_module);
9501 END IF;
9502
9503 -- shall we join to xla_events to get only the event with status D or I?
9504 -- good: reduce the event_id that are selected
9505 -- bad: need to join to xla_events table
9506 DELETE FROM xla_accounting_errors
9507 WHERE event_id IN
9508 (SELECT xeg.event_id FROM xla_events_int_gt xeg, xla_events xe
9509 WHERE xeg.event_id = xe.event_id
9510 AND xe.application_id = g_application_id -- 8967771
9511 --AND xe.event_status_code in ('D', 'I')
9512 AND xe.event_status_code = 'U' -- BugNo 9775727
9513 AND xe.process_status_code in ('D', 'I') -- BugNo 9775727
9514 );
9515
9516 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9517 trace
9518 (p_msg => 'Number of errors deleted = '||SQL%ROWCOUNT
9519 ,p_level => C_LEVEL_STATEMENT
9520 ,p_module => l_log_module);
9521 END IF;
9522
9523 -- Bug 5529420
9524 DELETE FROM xla_distribution_links
9525 WHERE application_id= g_application_id and ae_header_id IN
9526 (SELECT xh.ae_header_id
9527 FROM xla_events_int_gt xeg,
9528 xla_ae_headers xh
9529 WHERE
9530 xh.event_id = xeg.event_id AND
9531 xh.application_id = g_application_id AND
9532 xh.accounting_entry_status_code IN ('D','R','RELATED_EVENT_ERROR','I','N')
9533 );
9534
9535
9536 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9537 trace
9538 (p_msg => 'Number of distribution links deleted = '||SQL%ROWCOUNT
9539 ,p_level => C_LEVEL_STATEMENT
9540 ,p_module => l_log_module);
9541 END IF;
9542
9543 --
9544 -- Delete from xla_ae_segment_values
9545 --
9546
9547 DELETE FROM xla_ae_segment_values
9548 WHERE ae_header_id IN
9549 (SELECT xah.ae_header_id
9550 FROM
9551 --xla_events xe, 9775727
9552 xla_ae_headers xah
9553 ,xla_events_int_gt xeg
9554 WHERE xah.event_id = xeg.event_id
9555 AND xah.application_id = g_application_id -- 8967771
9556 --AND xah.event_id = xe.event_id 9775727
9557 --AND xeg.event_id = xe.event_id 9775727
9558 AND xah.accounting_entry_status_code IN ('D','R','RELATED_EVENT_ERROR','I','N') -- 9775727
9559 );
9560
9561 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9562 trace
9563 (p_msg => 'Number of segment values deleted = '||SQL%ROWCOUNT
9564 ,p_level => C_LEVEL_STATEMENT
9565 ,p_module => l_log_module);
9566 END IF;
9567
9568 --
9569 -- Delete from xla_ae_line_acs
9570 --
9571
9572 DELETE FROM xla_ae_line_acs
9573 WHERE ae_header_id IN
9574 (SELECT xah.ae_header_id
9575 FROM
9576 --xla_events xe, 9775727
9577 xla_ae_headers xah
9578 ,xla_events_int_gt xeg
9579 WHERE xah.event_id = xeg.event_id
9580 AND xah.application_id = g_application_id -- 8967771
9581 --AND xah.event_id = xe.event_id 9775727
9582 --AND xeg.event_id = xe.event_id 9775727
9583 AND xah.accounting_entry_status_code IN ('D','R','RELATED_EVENT_ERROR','I','N') -- 9775727
9584 );
9585
9586 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9587 trace
9588 (p_msg => 'Number of line acs deleted = '||SQL%ROWCOUNT
9589 ,p_level => C_LEVEL_STATEMENT
9590 ,p_module => l_log_module);
9591 END IF;
9592
9593
9594 --
9595 -- Delete from xla_ae_header_acs
9596 --
9597 DELETE FROM xla_ae_header_acs
9598 WHERE ae_header_id IN
9599 (SELECT xah.ae_header_id
9600 FROM
9601 --xla_events xe, 9775727
9602 xla_ae_headers xah
9603 ,xla_events_int_gt xeg
9604 WHERE xah.event_id = xeg.event_id
9605 AND xah.application_id = g_application_id -- 8967771
9606 --AND xah.event_id = xe.event_id 9775727
9607 --AND xeg.event_id = xe.event_id 9775727
9608 AND xah.accounting_entry_status_code IN ('D','R','RELATED_EVENT_ERROR','I','N') -- 9775727
9609 );
9610
9611
9612 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9613 trace
9614 (p_msg => 'Number of header acs deleted = '||SQL%ROWCOUNT
9615 ,p_level => C_LEVEL_STATEMENT
9616 ,p_module => l_log_module);
9617 END IF;
9618
9619 --
9620 -- Delete from xla_ae_line_details
9621 --
9622
9623 DELETE FROM xla_ae_line_details
9624 WHERE ae_header_id IN
9625 (SELECT xah.ae_header_id
9626 FROM
9627 --xla_events xe, 9775727
9628 xla_ae_headers xah
9629 ,xla_events_int_gt xeg
9630 WHERE xah.event_id = xeg.event_id
9631 AND xah.application_id = g_application_id -- 8967771
9632 --AND xah.event_id = xe.event_id 9775727
9633 --AND xeg.event_id = xe.event_id 9775727
9634 AND xah.accounting_entry_status_code IN ('D','R','RELATED_EVENT_ERROR','I','N') -- 9775727
9635 );
9636
9637 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9638 trace
9639 (p_msg => 'Number of line details deleted = '||SQL%ROWCOUNT
9640 ,p_level => C_LEVEL_STATEMENT
9641 ,p_module => l_log_module);
9642 END IF;
9643
9644 --
9645 -- Delete from xla_ae_header_details
9646 --
9647
9648 DELETE FROM xla_ae_header_details
9649 WHERE ae_header_id IN
9650 (SELECT xah.ae_header_id
9651 FROM
9652 --xla_events xe, 9775727
9653 xla_ae_headers xah
9654 ,xla_events_int_gt xeg
9655 WHERE xah.event_id = xeg.event_id
9656 AND xah.application_id = g_application_id -- 8967771
9657 --AND xah.event_id = xe.event_id 9775727
9658 --AND xeg.event_id = xe.event_id 9775727
9659 AND xah.accounting_entry_status_code IN ('D','R','RELATED_EVENT_ERROR','I','N') -- 9775727
9660 );
9661
9662 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9663 trace
9664 (p_msg => 'Number of header details deleted = '||SQL%ROWCOUNT
9665 ,p_level => C_LEVEL_STATEMENT
9666 ,p_module => l_log_module);
9667 END IF;
9668
9669 --
9670 -- Delete from xla_ae_lines
9671 --
9672
9673 DELETE FROM xla_ae_lines
9674 WHERE application_id = g_application_id
9675 AND ae_header_id IN
9676 (SELECT xah.ae_header_id
9677 FROM
9678 --xla_events xe, 9775727
9679 xla_ae_headers xah
9680 ,xla_events_int_gt xeg
9681 WHERE xah.event_id = xeg.event_id
9682 AND xah.application_id = g_application_id -- 8967771
9683 --AND xah.event_id = xe.event_id 9775727
9684 --AND xeg.event_id = xe.event_id 9775727
9685 AND xah.accounting_entry_status_code IN ('D','R','RELATED_EVENT_ERROR','I','N') -- 9775727
9686 );
9687
9688 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9689 trace
9690 (p_msg => 'Number of ae lines deleted = '||SQL%ROWCOUNT
9691 ,p_level => C_LEVEL_STATEMENT
9692 ,p_module => l_log_module);
9693 END IF;
9694
9695 --
9696 -- Delete from xla_ae_headers
9697 --
9698
9699 DELETE FROM xla_ae_headers
9700 WHERE application_id = g_application_id
9701 AND ae_header_id IN
9702 (SELECT xah.ae_header_id
9703 FROM
9704 --xla_events xe, 9775727
9705 xla_ae_headers xah
9706 ,xla_events_int_gt xeg
9707 WHERE xah.event_id = xeg.event_id
9708 AND xah.application_id = g_application_id -- 8967771
9709 --AND xah.event_id = xe.event_id 9775727
9710 --AND xeg.event_id = xe.event_id 9775727
9711 AND xah.accounting_entry_status_code IN ('D','R','RELATED_EVENT_ERROR','I','N') -- 9775727
9712 );
9713
9714 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9715 trace
9716 (p_msg => 'Number of ae headers deleted = '||SQL%ROWCOUNT
9717 ,p_level => C_LEVEL_STATEMENT
9718 ,p_module => l_log_module);
9719 END IF;
9720
9721 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9722 trace
9723 (p_msg => 'END of procedure DELETE_JE'
9724 ,p_level => C_LEVEL_PROCEDURE
9725 ,p_module => l_log_module);
9726 END IF;
9727 EXCEPTION
9728 WHEN xla_exceptions_pkg.application_exception THEN
9729 RAISE;
9730 WHEN OTHERS THEN
9731 xla_exceptions_pkg.raise_message
9732 (p_location => 'xla_events_pkg.delete_je');
9733 END delete_je;
9734
9735
9736
9737
9738 --=============================================================================
9739 --
9740 --
9741 --
9742 --=============================================================================
9743
9744 FUNCTION period_close
9745 (p_period_name IN VARCHAR2
9746 ,p_ledger_id IN NUMBER
9747 ,p_mode IN VARCHAR2)
9748 RETURN VARCHAR2 IS
9749 l_period_start_date DATE;
9750 l_period_end_date DATE;
9751 l_unprocessed NUMBER(2) := 0;
9752 l_log_module VARCHAR2(240);
9753 l_request_id NUMBER(10);
9754 l_check_events NUMBER(2) := 0;
9755 l_primary_ledger_id GL_LEDGERS.ledger_id%TYPE;
9756 l_ledger_id GL_LEDGERS.ledger_id%TYPE;
9757 l_user_id NUMBER;
9758 l_resp_id NUMBER;
9759 l_resp_appl_id NUMBER;
9760 l_xml_output BOOLEAN;
9761 l_iso_language FND_LANGUAGES.iso_language%TYPE;
9762 l_iso_territory FND_LANGUAGES.iso_territory%TYPE;
9763 l_user_je_source_name XLA_LOOKUPS.meaning%TYPE;
9764 l_ledger_name GL_LEDGERS.name%TYPE;
9765 BEGIN
9766 IF g_log_enabled THEN
9767 l_log_module := C_DEFAULT_MODULE||'.period_close';
9768 END IF;
9769
9770 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9771 trace
9772 (p_msg => 'BEGIN of function period_close'
9773 ,p_level => C_LEVEL_PROCEDURE
9774 ,p_module => l_log_module);
9775 END IF;
9776
9777 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9778 trace('p_period_name = ' ||
9779 p_period_name, C_LEVEL_STATEMENT, l_log_module);
9780 trace('p_ledger_id = '||
9781 to_char(p_ledger_id), C_LEVEL_STATEMENT, l_log_module);
9782 trace('p_mode = '||
9783 p_mode, C_LEVEL_STATEMENT, l_log_module);
9784 END IF;
9785
9786
9787 ----------------------------------------------------------------------------
9788 -- Following sets the Security Context for the execution. This enables the
9789 -- event API to respect the transaction security implementation
9790 ----------------------------------------------------------------------------
9791 xla_security_pkg.set_security_context(602);
9792
9793 l_unprocessed := xla_period_close_exp_pkg.check_period_close
9794 (101
9795 ,p_period_name
9796 ,p_ledger_id);
9797
9798 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9799 trace('l_unprocessed = ' ||
9800 to_char(l_unprocessed), C_LEVEL_STATEMENT, l_log_module);
9801 END IF;
9802
9803 IF l_unprocessed > 0 THEN
9804
9805 IF p_mode = 'W' THEN
9806
9807 DELETE FROM xla_transfer_ledgers
9808 WHERE group_id IN
9809 (SELECT group_id
9810 FROM gl_je_batches
9811 WHERE status = 'P'
9812 AND default_period_name = p_period_name)
9813 AND (primary_ledger_id is null OR
9814 primary_ledger_id = p_ledger_id OR
9815 secondary_ledger_id = p_ledger_id);
9816
9817 BEGIN
9818
9819 SELECT lower(iso_language),iso_territory
9820 INTO l_iso_language,l_iso_territory
9821 FROM FND_LANGUAGES
9822 WHERE language_code = USERENV('LANG');
9823
9824 SELECT meaning
9825 INTO l_user_je_source_name
9826 FROM xla_lookups
9827 WHERE lookup_type = 'XLA_ADR_SIDE'
9828 AND lookup_code = 'ALL';
9829
9830 SELECT name
9831 INTO l_ledger_name
9832 FROM gl_ledgers
9833 WHERE ledger_id = p_ledger_id;
9834
9835 EXCEPTION
9836 WHEN NO_DATA_FOUND THEN
9837 NULL;
9838 WHEN OTHERS THEN
9839 RAISE;
9840 END;
9841
9842 l_xml_output := fnd_request.add_layout('XLA'
9843 ,'XLAPEXRPT'
9844 ,l_iso_language
9845 ,l_iso_territory
9846 ,'PDF');
9847
9848 l_request_id := fnd_request.submit_request
9849 (application => 'XLA'
9850 ,program => 'XLAPEXRPT'
9851 ,description => NULL
9852 ,start_time => NULL
9853 ,sub_request => FALSE
9854 ,argument1 => 101
9855 ,argument2 => l_user_je_source_name
9856 ,argument3 => p_ledger_id
9857 ,argument4 => l_ledger_name
9858 ,argument5 => p_period_name
9859 ,argument6 => p_period_name
9860 ,argument7 => NULL
9861 ,argument8 => NULL
9862 ,argument9 => NULL
9863 ,argument10 => NULL
9864 ,argument11 => NULL
9865 ,argument12 => NULL
9866 ,argument13 => 'W');
9867
9868 commit; -- commit is mandatory after fnd_request.submit_request
9869
9870 IF l_request_id = 0 THEN
9871 xla_exceptions_pkg.raise_message
9872 (p_appli_s_name => 'XLA'
9873 ,p_msg_name => 'XLA_REP_TECHNICAL_ERROR'
9874 ,p_token_1 => 'APPLICATION_NAME'
9875 ,p_value_1 => 'SLA');
9876 END IF;
9877
9878 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9879 trace('Concurrent request submitted'|| to_char(l_request_id),
9880 C_LEVEL_STATEMENT,l_log_module);
9881 END IF;
9882
9883 END IF;
9884
9885 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9886 trace
9887 ( p_msg => 'END of functon period_close'
9888 ,p_level => C_LEVEL_PROCEDURE
9889 ,p_module => l_log_module);
9890 END IF;
9891 -- 9038422 Even though there are unaccounted events, no Notification will be sent.
9892 -- RETURN 'WARNING'; -- Notification with Warning will be sent.
9893 END IF;
9894
9895 RETURN 'SUCCESS'; -- No Notification.
9896
9897 EXCEPTION
9898 WHEN XLA_EXCEPTIONS_PKG.application_exception THEN
9899 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9900 trace('End of function Period Close with error', C_LEVEL_STATEMENT,
9901 l_log_module);
9902 END IF;
9903 RETURN 'ERROR'; -- Notification with Error will be sent.
9904 END period_close;
9905
9906 --=============================================================================
9907 --
9908 -- Private Function to Get the application name for a given application id
9909 --
9910 --=============================================================================
9911
9912 FUNCTION get_application_name
9913 (p_application_id IN NUMBER)
9914 RETURN VARCHAR2 IS
9915 l_log_module VARCHAR2(240);
9916 l_application_name FND_APPLICATION_TL.application_name%TYPE;
9917
9918 BEGIN
9919
9920 IF g_log_enabled THEN
9921 l_log_module := C_DEFAULT_MODULE||'.get_application_name';
9922 END IF;
9923
9924 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9925 trace
9926 (p_msg => 'BEGIN of get_application_name'
9927 ,p_level => C_LEVEL_PROCEDURE
9928 ,p_module => l_log_module);
9929 END IF;
9930
9931
9932 SELECT fat.application_name
9933 INTO l_application_name
9934 FROM fnd_application_tl fat
9935 WHERE fat.application_id = p_application_id
9936 AND fat.language = nvl(USERENV('LANG'),fat.language);
9937
9938
9939 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9940 trace
9941 (p_msg => 'get_application_name'
9942 ,p_level => C_LEVEL_PROCEDURE
9943 ,p_module => l_log_module);
9944 END IF;
9945
9946 RETURN l_application_name;
9947
9948 EXCEPTION
9949 WHEN NO_DATA_FOUND THEN
9950 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
9951 trace('End of Get Application name', C_LEVEL_STATEMENT,l_log_module);
9952 END IF;
9953 RETURN l_application_name;
9954 END get_application_name;
9955
9956
9957 --=============================================================================
9958 --
9959 -- Private Function to Get the ledger associated with a ledger id
9960 --
9961 --=============================================================================
9962
9963 FUNCTION get_ledger_name
9964 (p_ledger_id IN NUMBER)
9965 RETURN VARCHAR2 IS
9966 l_log_module VARCHAR2(240);
9967 l_ledger_name VARCHAR2(30);
9968
9969 BEGIN
9970
9971 IF g_log_enabled THEN
9972 l_log_module := C_DEFAULT_MODULE||'.get_ledger_name';
9973 END IF;
9974
9975 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9976 trace
9977 (p_msg => 'BEGIN of get_ledger_name'
9978 ,p_level => C_LEVEL_PROCEDURE
9979 ,p_module => l_log_module);
9980 END IF;
9981
9982 SELECT name
9983 INTO l_ledger_name
9984 FROM gl_ledgers
9985 WHERE ledger_id = p_ledger_id;
9986
9987
9988 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9989 trace
9990 (p_msg => 'END of get_ledger_name'
9991 ,p_level => C_LEVEL_PROCEDURE
9992 ,p_module => l_log_module);
9993 END IF;
9994
9995 RETURN l_ledger_name;
9996
9997 EXCEPTION
9998 WHEN NO_DATA_FOUND THEN
9999 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
10000 trace('End of Get ledger name', C_LEVEL_STATEMENT,l_log_module);
10001 END IF;
10002 RETURN l_ledger_name;
10003 END get_ledger_name;
10004
10005 FUNCTION period_close
10006 (p_application_id IN NUMBER
10007 ,p_ledger_id IN NUMBER
10008 ,p_period_name IN VARCHAR2)
10009 RETURN VARCHAR2 IS
10010 l_period_start_date DATE;
10011 l_period_end_date DATE;
10012 l_unprocessed NUMBER(1) := 0;
10013 l_log_module VARCHAR2(240);
10014
10015 BEGIN
10016 IF g_log_enabled THEN
10017 l_log_module := C_DEFAULT_MODULE||'.period_close';
10018 END IF;
10019
10020 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10021 trace
10022 (p_msg => 'BEGIN of function period_close for Subledger Uptake'
10023 ,p_level => C_LEVEL_PROCEDURE
10024 ,p_module => l_log_module);
10025 END IF;
10026
10027 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
10028 trace('p_application_id = ' ||
10029 to_char(p_application_id), C_LEVEL_STATEMENT, l_log_module);
10030 trace('p_ledger_id = '||
10031 to_char(p_ledger_id), C_LEVEL_STATEMENT, l_log_module);
10032 trace('p_period_name = '||
10033 p_period_name, C_LEVEL_STATEMENT, l_log_module);
10034 END IF;
10035
10036 ----------------------------------------------------------------------------
10037 -- Following sets the Security Context for the execution. This enables the
10038 -- event API to respect the transaction security implementation
10039 ----------------------------------------------------------------------------
10040 xla_security_pkg.set_security_context(p_application_id);
10041 -- 4949921
10042 l_unprocessed := xla_period_close_exp_pkg.check_period_close
10043 (p_application_id
10044 ,p_period_name
10045 ,p_ledger_id);
10046
10047 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
10048 trace('l_unprocessed = ' ||
10049 to_char(l_unprocessed), C_LEVEL_STATEMENT, l_log_module);
10050 END IF;
10051
10052 IF l_unprocessed > 0 THEN
10053
10054 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10055 trace
10056 ( p_msg => 'END of function period close for Subledger Uptake'
10057 ,p_level => C_LEVEL_PROCEDURE
10058 ,p_module => l_log_module);
10059 END IF;
10060
10061 RETURN 'FALSE';
10062 ELSE
10063
10064 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10065 trace
10066 ( p_msg => 'END of function period close for Subledger Uptake'
10067 ,p_level => C_LEVEL_PROCEDURE
10068 ,p_module => l_log_module);
10069 END IF;
10070
10071 RETURN 'TRUE';
10072 END IF;
10073
10074 EXCEPTION
10075 WHEN OTHERS THEN
10076 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
10077 trace('End of function Period Close for Subledger Uptake with error'
10078 ,C_LEVEL_STATEMENT
10079 ,l_log_module);
10080 END IF;
10081 RETURN 'ERROR';
10082 END period_close;
10083
10084 --=============================================================================
10085 -- ******************* Initialization *********************
10086 --=============================================================================
10087 --=============================================================================
10088 --
10089 --
10090 --
10091 --
10092 --
10093 --
10094 --
10095 --
10096 --
10097 --
10098 -- Following .............
10099 --
10100 --
10101 --
10102 --
10103 --
10104 --
10105 --
10106 --
10107 --
10108 --
10109 --
10110 --
10111 --=============================================================================
10112
10113 BEGIN
10114 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
10115 g_log_enabled := fnd_log.test
10116 (log_level => g_log_level
10117 ,module => C_DEFAULT_MODULE);
10118
10119 IF NOT g_log_enabled THEN
10120 g_log_level := C_LEVEL_LOG_DISABLED;
10121 END IF;
10122
10123 initialize;
10124
10125 END xla_events_pkg;