DBA Data[Home] [Help]

PACKAGE BODY: APPS.XLA_EVENTS_PUB_PKG

Source


1 PACKAGE BODY xla_events_pub_pkg AS
2 -- $Header: xlaevevp.pkb 120.37 2011/05/05 13:51:56 sgullape ship $
3 /*===========================================================================+
4 |             Copyright (c) 2001-2002 Oracle Corporation                     |
5 |                       Redwood Shores, CA, USA                              |
6 |                         All rights reserved.                               |
7 +============================================================================+
8 | FILENAME                                                                   |
9 |    xlaevevp.pkb                                                            |
10 |                                                                            |
11 | PACKAGE NAME                                                               |
12 |    xla_events_pub_pkg                                                      |
13 |                                                                            |
14 | DESCRIPTION                                                                |
15 |    This is a public package for product teams, which contains all the      |
16 |    APIs required for processing accounting events.                         |
17 |                                                                            |
18 |    Note: the APIs do not excute COMMIT or ROLLBACK.                        |
19 |                                                                            |
20 |    These public APIs are wrapper over public routines of xla_event_pkg     |
21 |                                                                            |
22 | HISTORY                                                                    |
23 |    08-Feb-01 G. Gu           Created                                       |
24 |    10-Mar-01 P. Labrevois    Reviewed                                      |
25 |    17-Jul-01 P. Labrevois    Added array create_event                      |
26 |    13-Sep-01 P. Labrevois    Added 2nd array create_event                  |
27 |    08-Feb-02 S. Singhania    Reviewed and performed major changes          |
28 |    10-Feb-02 S. Singhania    Made changes in APIs to handle 'Transaction   |
29 |                               Number' (new column added in xla_entities)   |
30 |    13-Feb-02 S. Singhania    Made changes in APIs to handle 'Event Number' |
31 |    17-Feb-02 S. Singhania    Added 'Org_id' parameter to all the APIs as a |
32 |                               'security context'                           |
33 |    04-Apr-02 S. Singhania    Replaced 'Org_id' parameter with the generic  |
34 |                                paramenter 'p_security_context'. Removed the|
35 |                                not required, redundant APIs                |
36 |    17-Apr-02 S. Singhania    Removed shadow procedures. Added seperate APIs|
37 |                                to update transaction number, Event Number  |
38 |                                and Reference Information                   |
39 |    06-May-02 S. Singhania    Added "valuation_method" and "ledger_id".     |
40 |                                Bug # 2351677.                              |
41 |    31-May-02 S. Singhania    Removed one of the 'create_entity_event' API  |
42 |                              Renamed 'create_entity_event' API to          |
43 |                                'create_bulk_events'                        |
44 |    23-Jul-02 S. Singhania    commented 'get_document_status' API.          |
45 |                                Bug # 2464825                               |
46 |    09-Sep-02 S. Singhania    modified 'create_bulk_events' API. Bug 2530796|
47 |    21-Feb-03 S. Singhania    Added 'Trace' procedure.                      |
48 |    04-Sep-03 S. Singhania    Made changes to satisfy enhanced requirement  |
49 |                                for 'Source Application'.                   |
50 |                                - Added parameter to CREATE_BULK_EVENTS     |
51 |    12-Dec-03 S. Singhania    Removed the API UPDATE_TRANSACTION_NUMBER.    |
52 |                                Bug # 3268790                               |
53 |    25-Jun-04 W. Shen         add a new function delete_entity(bug 3316535) |
54 |    23-OCT-04 W. Shen         New API to delete/update/create event in bulk |
55 |    1- APR-05 W. Shen         Add transaction_date to create_event api      |
56 |                                add transaction_date to update_event API    |
57 |    20-Apr-05 S. Singhania    Bug 4312353. Modified the calls to routines in|
58 |                                xla_events_pkg to reflect the change in the |
59 |                                way we handle valuation method different    |
60 |                                from other security columns                 |
61 |    02-May-05 V. Kumar        Removed function create_bulk_events,          |
62 |                              Bug # 4323140                                 |
63 |    30-SEP-10 VDAMERLA        Bug:9077926  Created overloaded procedures    |
64 |                                for create_bulk_events and                  |
65 |                                update_bulk_event_statuses to pass          |
66 |                                bulk limit value                            |
67 |    13-Oct-10 nksurana        Bug 10152910 Created new function/API         |
68 |                              allow_third_party_update to check if the party|
69 |                              site can be updated, based on Control Account.|
70 +===========================================================================*/
71 
72 --=============================================================================
73 --               *********** Local Trace Routine **********
74 --=============================================================================
75 C_LEVEL_STATEMENT     CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
76 C_LEVEL_PROCEDURE     CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
77 C_LEVEL_EVENT         CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
78 C_LEVEL_EXCEPTION     CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
79 C_LEVEL_ERROR         CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
80 C_LEVEL_UNEXPECTED    CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
81 
82 C_LEVEL_LOG_DISABLED  CONSTANT NUMBER := 99;
83 
84 C_DEFAULT_MODULE      CONSTANT VARCHAR2(240) := 'xla.plsql.xla_events_pub_pkg';
85 
86 g_debug_flag      VARCHAR2(1) := NVL(fnd_profile.value('XLA_DEBUG_TRACE'),'N');
87 
88 --l_log_module          VARCHAR2(240);
89 g_log_level           NUMBER;
90 g_log_enabled         BOOLEAN;
91 
92 
93 
94 PROCEDURE trace
95        (p_msg                        IN VARCHAR2
96        ,p_level                      IN NUMBER
97        ,p_module                     IN VARCHAR2 DEFAULT C_DEFAULT_MODULE) IS
98 BEGIN
99    IF (p_msg IS NULL AND p_level >= g_log_level) THEN
100       fnd_log.message(p_level, p_module);
101    ELSIF p_level >= g_log_level THEN
102       fnd_log.string(p_level, p_module, p_msg);
103    END IF;
104 EXCEPTION
105    WHEN xla_exceptions_pkg.application_exception THEN
106       RAISE;
107    WHEN OTHERS THEN
108       xla_exceptions_pkg.raise_message
109          (p_location   => 'xla_acct_setup_pub_pkg.trace');
110 END trace;
111 
112 
113 --=============================================================================
114 --          *********** Event creation routines **********
115 --=============================================================================
116 --=============================================================================
117 --
118 --
119 --
120 --
121 --
122 --
123 --
124 --
125 --
126 --
127 -- 1.    create_event
128 --
129 --
130 --
131 --
132 --
133 --
134 --
135 --
136 --
137 --
138 --
139 --
140 --
141 --
142 --=============================================================================
143 
144 --============================================================================
145 --
146 -- This procedure is used to create an event and returns event id.
147 -- It will also
148 --    - validate input parameters(except reference columns)
149 --    - create a new event
150 --
151 --============================================================================
152 
153 FUNCTION create_event
154    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
155    ,p_event_type_code              IN  VARCHAR2
156    ,p_event_date                   IN  DATE
157    ,p_event_status_code            IN  VARCHAR2
158    ,p_event_number                 IN  INTEGER        DEFAULT NULL
159    ,p_transaction_date             IN  DATE        DEFAULT NULL
160    ,p_reference_info               IN  xla_events_pub_pkg.t_event_reference_info DEFAULT NULL
161    ,p_valuation_method             IN  VARCHAR2
162    ,p_security_context             IN  xla_events_pub_pkg.t_security)
163 RETURN INTEGER IS
164 BEGIN
165    trace('@ xla_events_pub_pkg.create_event (fn)'             , 20);
166 
167    xla_events_pub_pkg.g_security := p_security_context;
168 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
169 
170    RETURN xla_events_pkg.create_event
171             (p_event_source_info        => p_event_source_info
172             ,p_valuation_method         => p_valuation_method
173             ,p_event_type_code          => p_event_type_code
174             ,p_event_date               => p_event_date
175             ,p_event_status_code        => p_event_status_code
176             ,p_event_number             => p_event_number
177             ,p_transaction_date         => p_transaction_date
178             ,p_reference_info           => p_reference_info
179             ,p_budgetary_control_flag   => 'N');
180 EXCEPTION
181 WHEN xla_exceptions_pkg.application_exception THEN
182    RAISE;
183 WHEN OTHERS                                   THEN
184    xla_exceptions_pkg.raise_message
185       (p_location => 'xla_events_pub_pkg.create_event (fn)');
186 END create_event;
187 
188 --============================================================================
189 --
190 -- This procedure is used to create an event and returns event id.
191 -- It will also
192 --    - validate input parameters(except reference columns)
193 --    - create a new event
194 --
195 --============================================================================
196 FUNCTION create_event
197    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
198    ,p_event_type_code              IN  VARCHAR2
199    ,p_event_date                   IN  DATE
200    ,p_event_status_code            IN  VARCHAR2
201    ,p_event_number                 IN  INTEGER        DEFAULT NULL
202    ,p_transaction_date             IN  DATE        DEFAULT NULL
203    ,p_reference_info               IN  xla_events_pub_pkg.t_event_reference_info DEFAULT NULL
204    ,p_valuation_method             IN  VARCHAR2
205    ,p_security_context             IN  xla_events_pub_pkg.t_security
206    ,p_budgetary_control_flag       IN  VARCHAR2)
207 RETURN INTEGER IS
208 BEGIN
209    trace('@ xla_events_pub_pkg.create_event (fn)'             , 20);
210 
211    xla_events_pub_pkg.g_security := p_security_context;
212 
213    RETURN xla_events_pkg.create_event
214             (p_event_source_info        => p_event_source_info
215             ,p_valuation_method         => p_valuation_method
216             ,p_event_type_code          => p_event_type_code
217             ,p_event_date               => p_event_date
218             ,p_event_status_code        => p_event_status_code
219             ,p_event_number             => p_event_number
220             ,p_transaction_date         => p_transaction_date
221             ,p_reference_info           => p_reference_info
222             ,p_budgetary_control_flag   => p_budgetary_control_flag);
223 EXCEPTION
224 WHEN xla_exceptions_pkg.application_exception THEN
225    RAISE;
226 WHEN OTHERS                                   THEN
227    xla_exceptions_pkg.raise_message
228       (p_location => 'xla_events_pub_pkg.create_event (fn)');
229 END create_event;
230 
231 
232 -------------------------------------------------------------------------------
233 -- Event updation routines
234 -------------------------------------------------------------------------------
235 
236 --============================================================================
237 --
238 -- This procedure is used to manipulate the status of an event. It will
239 --    - validate input parameters
240 --    - lock the document
241 --    - ensure all selected events status are not 'Processed'
242 --    - update event
243 --
244 --============================================================================
245 
246 PROCEDURE update_event_status
247    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
248    ,p_event_class_code             IN  VARCHAR2   DEFAULT NULL
249    ,p_event_type_code              IN  VARCHAR2   DEFAULT NULL
250    ,p_event_date                   IN  DATE       DEFAULT NULL
251    ,p_event_status_code            IN  VARCHAR2
252    ,p_valuation_method             IN  VARCHAR2
253    ,p_security_context             IN  xla_events_pub_pkg.t_security) IS
254 BEGIN
255    trace('> xla_events_pub_pkg.update_event_status'           , 20);
256 
257    xla_events_pub_pkg.g_security := p_security_context;
258 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
259 
260    xla_events_pkg.update_event_status
261       (p_event_source_info       => p_event_source_info
262       ,p_valuation_method        => p_valuation_method
263       ,p_event_class_code        => p_event_class_code
264       ,p_event_type_code         => p_event_type_code
265       ,p_event_date              => p_event_date
266       ,p_event_status_code       => p_event_status_code);
267 
268    trace('< xla_events_pub_pkg.update_event_status'           , 20);
269 EXCEPTION
270 WHEN xla_exceptions_pkg.application_exception THEN
271    RAISE;
272 WHEN OTHERS                                   THEN
273    xla_exceptions_pkg.raise_message
274       (p_location => 'xla_events_pub_pkg.update_event_status');
275 END update_event_status;
276 
277 
278 --============================================================================
279 --
280 -- This procedure is used to manipulate the type, status, and/or date for a
281 -- specific event.
282 --    - validate input parameters
283 --    - lock the document
284 --    - ensure all selected events status are not 'Processed'
285 --    - update event
286 --
287 --============================================================================
288 
289 PROCEDURE update_event
290    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
291    ,p_event_id                     IN  INTEGER
292    ,p_event_type_code              IN  VARCHAR2   DEFAULT NULL
293    ,p_event_date                   IN  DATE       DEFAULT NULL
294    ,p_event_status_code            IN  VARCHAR2   DEFAULT NULL
295    ,p_valuation_method             IN  VARCHAR2
296    ,p_security_context             IN  xla_events_pub_pkg.t_security
297    ,p_transaction_date             IN  DATE       DEFAULT NULL) IS
298 BEGIN
299    trace('> xla_events_pub_pkg.update_event'                  , 20);
300 
301    xla_events_pub_pkg.g_security := p_security_context;
302 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
303 
304    xla_events_pkg.update_event
305       (p_event_source_info        => p_event_source_info
306       ,p_valuation_method         => p_valuation_method
307       ,p_event_id                 => p_event_id
308       ,p_event_type_code          => p_event_type_code
309       ,p_event_date               => p_event_date
310       ,p_event_status_code        => p_event_status_code
311       ,p_transaction_date         => p_transaction_date);
312 
313    trace('< xla_events_pub_pkg.update_event'                  , 20);
314 EXCEPTION
315 WHEN xla_exceptions_pkg.application_exception THEN
316    RAISE;
317 WHEN OTHERS                                   THEN
318    xla_exceptions_pkg.raise_message
319       (p_location => 'xla_events_pub_pkg.update_event');
320 END update_event;
321 
322 
323 --============================================================================
324 --
325 -- This procedure is used to manipulate the type, status, date and/or
326 -- event numberany for a specific event.
327 --    - validate input parameters
328 --    - lock the document
329 --    - ensure all selected events status are not 'Processed'
330 --    - update event
331 --
332 --============================================================================
333 
334 PROCEDURE update_event
335    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
336    ,p_event_id                     IN  INTEGER
337    ,p_event_type_code              IN  VARCHAR2   DEFAULT NULL
338    ,p_event_date                   IN  DATE       DEFAULT NULL
339    ,p_event_status_code            IN  VARCHAR2   DEFAULT NULL
340    ,p_event_number                 IN  INTEGER
341    ,p_valuation_method             IN  VARCHAR2
342    ,p_security_context             IN  xla_events_pub_pkg.t_security
343    ,p_transaction_date             IN  DATE       DEFAULT NULL) IS
344 BEGIN
345    trace('> xla_events_pub_pkg.update_event'                  , 20);
346 
347    xla_events_pub_pkg.g_security := p_security_context;
348 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
349 
350    xla_events_pkg.update_event
351       (p_event_source_info        => p_event_source_info
352       ,p_valuation_method         => p_valuation_method
353       ,p_event_id                 => p_event_id
354       ,p_event_type_code          => p_event_type_code
355       ,p_event_date               => p_event_date
356       ,p_event_status_code        => p_event_status_code
357       ,p_transaction_date         => p_transaction_date
358       ,p_event_number             => p_event_number
359       ,p_overwrite_event_num      => 'Y');
360 
361    trace('< xla_events_pub_pkg.update_event'                  , 20);
362 EXCEPTION
363 WHEN xla_exceptions_pkg.application_exception THEN
364    RAISE;
365 WHEN OTHERS                                   THEN
366    xla_exceptions_pkg.raise_message
367       (p_location => 'xla_events_pub_pkg.update_event');
368 END update_event;
369 
370 
371 --============================================================================
372 --
373 -- This procedure is used to manipulate the type, status, date or any
374 -- reference information for a specific event.
375 --    - validate input parameters
376 --    - lock the document
377 --    - ensure all selected events status are not 'Processed'
378 --    - update event
379 --
380 --============================================================================
381 
382 PROCEDURE update_event
383    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
384    ,p_event_id                     IN  INTEGER
385    ,p_event_type_code              IN  VARCHAR2   DEFAULT NULL
386    ,p_event_date                   IN  DATE       DEFAULT NULL
387    ,p_event_status_code            IN  VARCHAR2   DEFAULT NULL
388    ,p_reference_info               IN  xla_events_pub_pkg.t_event_reference_info
389    ,p_valuation_method             IN  VARCHAR2
390    ,p_security_context             IN  xla_events_pub_pkg.t_security
391    ,p_transaction_date             IN  DATE       DEFAULT NULL) IS
392 BEGIN
393    trace('> xla_events_pub_pkg.update_event'                  , 20);
394 
395    xla_events_pub_pkg.g_security := p_security_context;
396 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
397 
398    xla_events_pkg.update_event
399       (p_event_source_info        => p_event_source_info
400       ,p_valuation_method         => p_valuation_method
401       ,p_event_id                 => p_event_id
402       ,p_event_type_code          => p_event_type_code
403       ,p_event_date               => p_event_date
407       ,p_overwrite_ref_info       => 'Y' );
404       ,p_event_status_code        => p_event_status_code
405       ,p_transaction_date         => p_transaction_date
406       ,p_reference_info           => p_reference_info
408 
409    trace('< xla_events_pub_pkg.update_event'                  , 20);
410 EXCEPTION
411 WHEN xla_exceptions_pkg.application_exception THEN
412    RAISE;
413 WHEN OTHERS                                   THEN
414    xla_exceptions_pkg.raise_message
415       (p_location => 'xla_events_pub_pkg.update_event');
416 END update_event;
417 
418 
419 --============================================================================
420 --
421 -- This procedure is used to manipulate the type, status, date, event number
422 -- and/or any reference information for a specific event.
423 --    - validate input parameters
424 --    - lock the document
425 --    - ensure all selected events status are not 'Processed'
426 --    - update event
427 --
428 --============================================================================
429 
430 PROCEDURE update_event
431    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
432    ,p_event_id                     IN  INTEGER
433    ,p_event_type_code              IN  VARCHAR2   DEFAULT NULL
434    ,p_event_date                   IN  DATE       DEFAULT NULL
435    ,p_event_status_code            IN  VARCHAR2   DEFAULT NULL
436    ,p_event_number                 IN  INTEGER
437    ,p_reference_info               IN  xla_events_pub_pkg.t_event_reference_info
438    ,p_valuation_method             IN  VARCHAR2
439    ,p_security_context             IN  xla_events_pub_pkg.t_security
440    ,p_transaction_date             IN  DATE       DEFAULT NULL) IS
441 BEGIN
442    trace('> xla_events_pub_pkg.update_event'                  , 20);
443 
444    xla_events_pub_pkg.g_security := p_security_context;
445 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
446 
447    xla_events_pkg.update_event
448       (p_event_source_info        => p_event_source_info
449       ,p_valuation_method         => p_valuation_method
450       ,p_event_id                 => p_event_id
451       ,p_event_type_code          => p_event_type_code
452       ,p_event_date               => p_event_date
453       ,p_event_status_code        => p_event_status_code
454       ,p_transaction_date         => p_transaction_date
455       ,p_event_number             => p_event_number
456       ,p_reference_info           => p_reference_info
457       ,p_overwrite_event_num      => 'Y'
458       ,p_overwrite_ref_info       => 'Y');
459 
460    trace('< xla_events_pub_pkg.update_event'                  , 20);
461 EXCEPTION
462 WHEN xla_exceptions_pkg.application_exception THEN
463    RAISE;
464 WHEN OTHERS                                   THEN
465    xla_exceptions_pkg.raise_message
466       (p_location => 'xla_events_pub_pkg.update_event');
467 END update_event;
468 
469 
470 -------------------------------------------------------------------------------
471 -- Event deletion routines
472 -------------------------------------------------------------------------------
473 
474 --============================================================================
475 --
476 -- This procedure is used to delete one event. It will:
477 --    - validate input parameters
478 --    - lock the document
479 --    - ensure all selected events status are not 'Processed'
480 --    - delete event
481 --
482 --============================================================================
483 
484 PROCEDURE delete_event
485    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
486    ,p_event_id                     IN  INTEGER
487    ,p_valuation_method             IN  VARCHAR2
488    ,p_security_context             IN  xla_events_pub_pkg.t_security) IS
489 BEGIN
490    trace('> xla_events_pub_pkg.delete_event'                  , 20);
491 
492    xla_events_pub_pkg.g_security := p_security_context;
493    --xla_events_pub_pkg.g_valuation_method := p_valuation_method;
494 
495    xla_events_pkg.delete_event
496       (p_event_source_info     => p_event_source_info
497       ,p_valuation_method         => p_valuation_method
498       ,p_event_id              => p_event_id );
499 
500    trace('< xla_events_pub_pkg.delete_event'                  , 20);
501 EXCEPTION
502 WHEN xla_exceptions_pkg.application_exception THEN
503    RAISE;
504 WHEN OTHERS                                   THEN
505    xla_exceptions_pkg.raise_message
506       (p_location => 'xla_events_pub_pkg.delete_event');
507 END delete_event;
508 
509 
510 --============================================================================
511 --
512 -- This procedure is used to delete one to many event for a document and
513 -- return the number or record deleted. It will:
514 --    - validate input parameters
515 --    - lock the document
516 --    - ensure all selected events status are not 'Processed'
517 --    - delete unprocessed event(s)
518 --
519 --============================================================================
520 
521 FUNCTION delete_events
522    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
523    ,p_event_class_code             IN  VARCHAR2   DEFAULT NULL
524    ,p_event_type_code              IN  VARCHAR2   DEFAULT NULL
525    ,p_event_date                   IN  DATE       DEFAULT NULL
526    ,p_valuation_method             IN  VARCHAR2
527    ,p_security_context             IN  xla_events_pub_pkg.t_security)
528 RETURN INTEGER IS
529 BEGIN
530    trace('@ xla_events_pub_pkg.delete_events (fn)'             , 20);
531 
532    xla_events_pub_pkg.g_security := p_security_context;
533 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
534 
538             ,p_valuation_method         => p_valuation_method
535    RETURN xla_events_pkg.delete_events
536             (p_event_source_info      => p_event_source_info
537             ,p_event_class_code       => p_event_class_code
539             ,p_event_type_code        => p_event_type_code
540             ,p_event_date             => p_event_date);
541 EXCEPTION
542 WHEN xla_exceptions_pkg.application_exception THEN
543    RAISE;
544 WHEN OTHERS                                   THEN
545    xla_exceptions_pkg.raise_message
546       (p_location => 'xla_events_pub_pkg.delete_events(fn)');
547 END delete_events;
548 
549 
550 --============================================================================
551 --
552 -- This function is used to delete one entity. It will:
553 --    - validate input parameters
554 --    - check if there is still event associated with the entity
555 --    - if yes, return 1 without deletion
556 --    - else delete entity, return 0
557 --
558 --============================================================================
559 FUNCTION delete_entity
560    (p_source_info            IN  xla_events_pub_pkg.t_event_source_info
561    ,p_valuation_method             IN  VARCHAR2
562    ,p_security_context             IN  xla_events_pub_pkg.t_security)
563 RETURN INTEGER IS
564 l_result INTEGER;
565 BEGIN
566    trace('> xla_events_pub_pkg.delete_entty'                  , 20);
567 
568    xla_events_pub_pkg.g_security := p_security_context;
569 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
570 
571    l_result := xla_events_pkg.delete_entity
572       (p_source_info         => p_source_info
573       ,p_valuation_method    => p_valuation_method);
574 
575    trace('< xla_events_pub_pkg.delete_entity'                  , 20);
576    return l_result;
577 EXCEPTION
578 WHEN xla_exceptions_pkg.application_exception THEN
579    RAISE;
580 WHEN OTHERS                                   THEN
581    xla_exceptions_pkg.raise_message
582       (p_location => 'xla_events_pub_pkg.delete_entity');
583 END delete_entity;
584 
585 -------------------------------------------------------------------------------
586 -- Event information routines
587 -------------------------------------------------------------------------------
588 
589 --============================================================================
590 --
591 -- This procedure is used to get information for a specific event. It
592 -- will:
593 --    - lock the document
594 --    - get the information
595 --
596 --============================================================================
597 
598 FUNCTION get_event_info
599    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
600    ,p_event_id                     IN  INTEGER
601    ,p_valuation_method             IN  VARCHAR2
602    ,p_security_context             IN  xla_events_pub_pkg.t_security)
603 RETURN xla_events_pub_pkg.t_event_info IS
604 BEGIN
605    trace('@ xla_events_pub_pkg.get_event_info'                , 20);
606 
607    xla_events_pub_pkg.g_security := p_security_context;
608 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
609 
610    RETURN xla_events_pkg.get_event_info
611             (p_event_source_info        => p_event_source_info
612             ,p_valuation_method         => p_valuation_method
613             ,p_event_id                 => p_event_id);
614 EXCEPTION
615 WHEN xla_exceptions_pkg.application_exception THEN
616    RAISE;
617 WHEN OTHERS                                   THEN
618    xla_exceptions_pkg.raise_message
619       (p_location => 'xla_events_pub_pkg.get_event_info');
620 END get_event_info;
621 
622 
623 --============================================================================
624 --
625 -- This procedure is used to get status for a specific event. It will:
626 --    - lock the document
627 --    - get the information
628 --
629 --============================================================================
630 
631 FUNCTION get_event_status
632    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
633    ,p_event_id                     IN  INTEGER
634    ,p_valuation_method             IN  VARCHAR2
635    ,p_security_context             IN  xla_events_pub_pkg.t_security)
636 RETURN VARCHAR2 IS
637 BEGIN
638    trace('@ xla_events_pub_pkg.get_event_status'         , 20);
639 
640    xla_events_pub_pkg.g_security := p_security_context;
641 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
642 
643    RETURN xla_events_pkg.get_event_status
644             (p_event_source_info        => p_event_source_info
645             ,p_valuation_method         => p_valuation_method
646             ,p_event_id                 => p_event_id);
647 EXCEPTION
648 WHEN xla_exceptions_pkg.application_exception THEN
649    RAISE;
650 WHEN OTHERS                                   THEN
651    xla_exceptions_pkg.raise_message
652       (p_location => 'xla_events_pub_pkg.get_event_status');
653 END get_event_status;
654 
655 
656 --============================================================================
657 --
658 -- This procedure is used to detect the existency of a particular event.
659 --
660 --============================================================================
661 
662 FUNCTION event_exists
663    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
664    ,p_event_class_code             IN  VARCHAR2   DEFAULT NULL
665    ,p_event_type_code              IN  VARCHAR2   DEFAULT NULL
666    ,p_event_date                   IN  DATE       DEFAULT NULL
667    ,p_event_status_code            IN  VARCHAR2   DEFAULT NULL
668    ,p_event_number                 IN  INTEGER    DEFAULT NULL
672 BEGIN
669    ,p_valuation_method             IN  VARCHAR2
670    ,p_security_context             IN  xla_events_pub_pkg.t_security)
671 RETURN BOOLEAN IS
673    trace('@ xla_events_pub_pkg.event_exists'                  , 20);
674 
675    xla_events_pub_pkg.g_security := p_security_context;
676 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
677 
678    RETURN xla_events_pkg.event_exists
679             (p_event_source_info       => p_event_source_info
680             ,p_valuation_method        => p_valuation_method
681             ,p_event_class_code        => p_event_class_code
682             ,p_event_type_code         => p_event_type_code
683             ,p_event_date              => p_event_date
684             ,p_event_status_code       => p_event_status_code
685             ,p_event_number            => p_event_number);
686 EXCEPTION
687 WHEN xla_exceptions_pkg.application_exception THEN
688    RAISE;
689 WHEN OTHERS                                   THEN
690    xla_exceptions_pkg.raise_message
691       (p_location => 'xla_events_pub_pkg.event_exists');
692 END event_exists;
693 
694 
695 --============================================================================
696 --
697 -- This procedure is used to get information for all events associated
698 -- to a document. It will
699 --    - lock the document
700 --    - get the information
701 --    - return the information
702 --
703 --============================================================================
704 
705 FUNCTION get_array_event_info
706    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
707    ,p_event_class_code             IN  VARCHAR2   DEFAULT NULL
708    ,p_event_type_code              IN  VARCHAR2   DEFAULT NULL
709    ,p_event_date                   IN  DATE       DEFAULT NULL
710    ,p_event_status_code            IN  VARCHAR2   DEFAULT NULL
711    ,p_valuation_method             IN  VARCHAR2
712    ,p_security_context             IN  xla_events_pub_pkg.t_security)
713 RETURN xla_events_pub_pkg.t_array_event_info IS
714 BEGIN
715    trace('@ xla_events_pub_pkg.get_array_event_info'          , 20);
716 
717    xla_events_pub_pkg.g_security := p_security_context;
718 --   xla_events_pub_pkg.g_valuation_method := p_valuation_method;
719 
720    RETURN xla_events_pkg.get_array_event_info
721             (p_event_source_info       => p_event_source_info
722             ,p_valuation_method        => p_valuation_method
723             ,p_event_class_code        => p_event_class_code
724             ,p_event_type_code         => p_event_type_code
725             ,p_event_date              => p_event_date
726             ,p_event_status_code       => p_event_status_code);
727 EXCEPTION
728 WHEN xla_exceptions_pkg.application_exception THEN
729    RAISE;
730 WHEN OTHERS                                   THEN
731    xla_exceptions_pkg.raise_message
732       (p_location => 'xla_events_pub_pkg.get_array_event_info');
733 END get_array_event_info;
734 
735 PROCEDURE create_bulk_events
736        (p_source_application_id        IN  INTEGER     DEFAULT NULL
737        ,p_application_id               IN  INTEGER
738        ,p_legal_entity_id              IN  INTEGER     DEFAULT NULL
739        ,p_ledger_id                    IN  INTEGER
740        ,p_entity_type_code             IN  VARCHAR2) IS
741 BEGIN
742   trace('>BEGIN of procedure xla_events_pub_pkg.create_bulk_events'                  , 20);
743   xla_events_pkg.create_bulk_events(
744        p_source_application_id    => p_source_application_id
745        , p_application_id           => p_application_id
746        , p_legal_entity_id          => p_legal_entity_id
747        , p_ledger_id                => p_ledger_id
748        , p_entity_type_code         => p_entity_type_code);
749   trace('>END of procedure xla_events_pub_pkg.create_bulk_events'                  , 20);
750 
751 EXCEPTION
752 WHEN xla_exceptions_pkg.application_exception THEN
753    RAISE;
754 WHEN OTHERS                                   THEN
755    xla_exceptions_pkg.raise_message
756       (p_location => 'xla_events_pub_pkg.create_bulk_events');
757 END create_bulk_events;
758 
759 
760 PROCEDURE create_bulk_events
761        (p_source_application_id        IN  INTEGER     DEFAULT NULL
762        ,p_application_id               IN  INTEGER
763        ,p_legal_entity_id              IN  INTEGER     DEFAULT NULL
764        ,p_ledger_id                    IN  INTEGER
765        ,p_entity_type_code             IN  VARCHAR2
766        ,p_limit_size                   IN  INTEGER) IS
767 BEGIN
768   trace('>BEGIN of procedure xla_events_pub_pkg.create_bulk_events'                  , 20);
769   xla_events_pkg.create_bulk_events(
770        p_source_application_id    => p_source_application_id
771        , p_application_id           => p_application_id
772        , p_legal_entity_id          => p_legal_entity_id
773        , p_ledger_id                => p_ledger_id
774        , p_entity_type_code         => p_entity_type_code
775        , p_limit_size               => p_limit_size);
776   trace('>END of procedure xla_events_pub_pkg.create_bulk_events'                  , 20);
777 EXCEPTION
778 WHEN xla_exceptions_pkg.application_exception THEN
779    RAISE;
780 WHEN OTHERS                                   THEN
781    xla_exceptions_pkg.raise_message
782       (p_location => 'xla_events_pub_pkg.create_bulk_events');
783 END create_bulk_events;
784 
785 PROCEDURE update_bulk_event_statuses(p_application_id INTEGER) IS
786 BEGIN
787   trace('>BEGIN of procedure xla_events_pub_pkg.update_bulk_event_statuses'                  , 20);
788   xla_events_pkg.update_bulk_event_statuses(
789        p_application_id           => p_application_id);
790   trace('>END of procedure xla_events_pub_pkg.update_bulk_event_statuses'                  , 20);
791 
792 EXCEPTION
796    xla_exceptions_pkg.raise_message
793 WHEN xla_exceptions_pkg.application_exception THEN
794    RAISE;
795 WHEN OTHERS                                   THEN
797       (p_location => 'xla_events_pub_pkg.update_bulk_event_statuses');
798 END update_bulk_event_statuses;
799 
800 
801 PROCEDURE update_bulk_event_statuses(p_application_id                IN  INTEGER
802                                      ,p_limit_size                   IN  INTEGER)  IS
803 BEGIN
804   trace('>BEGIN of procedure xla_events_pub_pkg.update_bulk_event_statuses'                  , 20);
805   xla_events_pkg.update_bulk_event_statuses(
806        p_application_id           => p_application_id
807        ,p_limit_size               => p_limit_size);
808   trace('>END of procedure xla_events_pub_pkg.update_bulk_event_statuses'                  , 20);
809 EXCEPTION
810 WHEN xla_exceptions_pkg.application_exception THEN
811    RAISE;
812 WHEN OTHERS                                   THEN
813    xla_exceptions_pkg.raise_message
814       (p_location => 'xla_events_pub_pkg.update_bulk_event_statuses');
815 END update_bulk_event_statuses;
816 
817 
818 
819 PROCEDURE delete_bulk_events(p_application_id INTEGER) IS
820 BEGIN
821   xla_events_pkg.delete_bulk_events(
822        p_application_id           => p_application_id);
823 
824 EXCEPTION
825 WHEN xla_exceptions_pkg.application_exception THEN
826    RAISE;
827 WHEN OTHERS  THEN
828    xla_exceptions_pkg.raise_message
829       (p_location => 'xla_events_pub_pkg.delete_bulk_events');
830 END delete_bulk_events;
831 
832 -- For subledger teams uptake of Period Close validation.
833 PROCEDURE period_close  (p_api_version    IN NUMBER
834                         ,x_return_status  IN OUT NOCOPY VARCHAR2
835                         ,p_application_id IN NUMBER
836                         ,p_ledger_id      IN NUMBER
837                         ,p_period_name    IN VARCHAR2) IS
838 
839 l_log_module       VARCHAR2(240);
840 l_return_status    VARCHAR2(16);
841 l_api_name         CONSTANT VARCHAR2(30) := 'period_close';
842 l_api_version      CONSTANT NUMBER       := 1.0;
843 l_adjustment_flag  VARCHAR2(10);
844 BEGIN
845 
846    IF g_log_enabled THEN
847      l_log_module := C_DEFAULT_MODULE||'.period_close';
848    END IF;
849 
850    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
851         trace
852            ( p_msg      => 'BEGIN of Period Close Function for Subledger check'
853             ,p_level    => C_LEVEL_PROCEDURE
854             ,p_module   => l_log_module);
855    END IF;
856 
857    IF (NOT fnd_api.compatible_api_call
858                  (p_current_version_number => p_api_version
859                  ,p_caller_version_number  => l_api_version
860                  ,p_api_name               => l_api_name
861                  ,p_pkg_name               => C_DEFAULT_MODULE)) THEN
862       RAISE  FND_API.G_EXC_UNEXPECTED_ERROR;
863    ELSE
864 
865       /******************************/
866      /*** Added for bug 9286886 ****/
867      /******************************/
868 
869      BEGIN
870 
871       SELECT adjustment_period_flag
872       INTO   l_adjustment_flag
873       FROM   gl_period_statuses
874       WHERE  application_id = p_application_id
875       AND    ledger_id      = p_ledger_id
876       AND    period_name    = p_period_name;
877 
878      EXCEPTION
879      --BUG 12312395
880      -- Changed from WHEN NO DATA FOUND to OTHERS
881       WHEN OTHERS THEN
882         RAISE;
883      END;
884 
885       /*** Added for bug 9286886 ***/
886 
887       IF NVL(l_adjustment_flag, 'N') <> 'Y'
888       THEN
889          l_return_status :=  xla_events_pkg.period_close
890                            (p_application_id    => p_application_id
891                            ,p_ledger_id         => p_ledger_id
892                            ,p_period_name       => p_period_name);
893 
894          IF l_return_status = 'TRUE' THEN
895             x_return_status := FND_API.G_RET_STS_SUCCESS;
896          ELSIF l_return_status = 'FALSE' THEN
897             x_return_status := FND_API.G_RET_STS_ERROR;
898          ELSIF l_return_status = 'ERROR' THEN
899            x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
900          END IF;
901 
902       ELSE                /*   Else if of l_adjustment_flag */
903          x_return_status := FND_API.G_RET_STS_SUCCESS;
904 
905       END IF;             /* End if of l_adjustment_flag */
906 
907 
908    END IF;
909 
910    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
911        trace
912            ( p_msg      => 'End of Period Close Function for Subledger check'
913             ,p_level    => C_LEVEL_PROCEDURE
914             ,p_module   => l_log_module);
915    END IF;
916 
917 EXCEPTION
918   WHEN  FND_API.G_EXC_UNEXPECTED_ERROR THEN
919        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
920   WHEN OTHERS THEN
921      IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
922          trace
923            ( p_msg      => 'End of Period Close function for Subledger
924 	                    check with error'
925             ,p_level    => C_LEVEL_PROCEDURE
926             ,p_module   => l_log_module);
927      END IF;
928      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
929 END period_close;
930 
931 FUNCTION period_close(p_subscription_guid   IN raw
932                      ,p_event               IN OUT NOCOPY WF_EVENT_T)
933 RETURN VARCHAR2 is
934 
935 l_parameter_list        WF_PARAMETER_LIST_T;
936 l_ledger_id             NUMBER;
937 l_period_name           VARCHAR2(100);
938 l_log_module            VARCHAR2(240);
939 return_status           VARCHAR2(10);
943   -- get the parameter of the event
940 l_adjustment_flag       VARCHAR2(10); -- Bug 12312395
941 BEGIN
942 
944   l_parameter_list := p_event.getParameterList;
945   l_period_name := wf_event.getValueForParameter('PERIOD_NAME',
946 						 l_parameter_list);
947   l_ledger_id := to_number(wf_event.getValueForParameter('LEDGER_ID',
948 	                   l_parameter_list));
949 
950     /******************************/
951      /*** Added for bug 12312395 ****/
952      /******************************/
953 
954      BEGIN
955 
956       SELECT adjustment_period_flag
957       INTO   l_adjustment_flag
958       FROM   gl_period_statuses
959       WHERE  application_id = 101
960       AND    ledger_id      = l_ledger_id
961       AND    period_name    = l_period_name;
962 
963      EXCEPTION
964       WHEN OTHERS THEN
965         RAISE;
966      END;
967 
968       /*** Added for bug 12312395 ***/
969 
970       IF NVL(l_adjustment_flag, 'N') <> 'Y'
971       THEN
972 
973   	return_status :=  xla_events_pkg.period_close
974                (p_period_name    => l_period_name
975                ,p_ledger_id      => l_ledger_id
976                ,p_mode           => 'W');
977       ELSE                /*   Else if of l_adjustment_flag(bug 12312395) */
978          return_status := 'SUCCESS';
979 
980       END IF;             /* End if of l_adjustment_flag(bug 12312395) */
981 
982 
983   RETURN return_status;
984 
985 EXCEPTION
986 
987 WHEN xla_exceptions_pkg.application_exception THEN
988 
989   WF_CORE.CONTEXT( 'xla_events_pub_pkg', 'period_close',
990                     p_event.getEventName( ), p_subscription_guid);
991   WF_EVENT.setErrorInfo(p_event, 'ERROR');
992   RETURN 'ERROR';
993  -- Added for Bug 12312395
994  WHEN OTHERS THEN
995   RETURN 'ERROR';
996 
997 END period_close;
998 
999 --added bug6737299 update transaction number procedure
1000 
1001 -------------------------------------------------------------------------------
1002 -- Entity update routines
1003 -------------------------------------------------------------------------------
1004 
1005 --============================================================================
1006 --
1007 -- This procedure updates transaction number on the document.
1008 --
1009 --============================================================================
1010 
1011 PROCEDURE update_transaction_number
1012    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
1013    ,p_transaction_number           IN  VARCHAR2
1014    ,p_valuation_method             IN  VARCHAR2
1015    ,p_security_context             IN  xla_events_pub_pkg.t_security
1016    ,p_event_id                     IN  NUMBER  DEFAULT NULL) IS -- 8761772
1017 BEGIN
1018    trace('> xla_events_pub_pkg.update_transaction_number'             , 20);
1019 
1020    xla_events_pub_pkg.g_security := p_security_context;
1021    xla_events_pub_pkg.g_valuation_method := p_valuation_method;
1022 
1023    xla_events_pkg.update_transaction_number
1024       (p_event_source_info     => p_event_source_info
1025       ,p_transaction_number    => p_transaction_number
1026       ,p_valuation_method      => p_valuation_method
1027       ,p_event_id              => p_event_id
1028       );
1029 
1030    trace('< xla_events_pub_pkg.update_transaction_number'             , 20);
1031 EXCEPTION
1032 WHEN xla_exceptions_pkg.application_exception THEN
1033    RAISE;
1034 WHEN OTHERS                                   THEN
1035    xla_exceptions_pkg.raise_message
1036       (p_location => 'xla_events_pub_pkg.update_transaction_number');
1037 END update_transaction_number;
1038 
1039 
1040 -------------------------------------------------------------------------------
1041 -- Control Account Information routines
1042 -------------------------------------------------------------------------------
1043 
1044 --============================================================================
1045 --
1046 -- This function returns TRUE if the party site for the transaction can be updated
1047 -- based on whether it has any accounted information for a Control Account.
1048 --============================================================================
1049 
1050 FUNCTION allow_third_party_update
1051    (p_event_source_info            IN  xla_events_pub_pkg.t_event_source_info
1052    ,p_valuation_method             IN  VARCHAR2
1053    ,p_security_context             IN  xla_events_pub_pkg.t_security)
1054 RETURN BOOLEAN IS
1055 BEGIN
1056    trace('> xla_events_pub_pkg.allow_third_party_update'             , 20);
1057 
1058    xla_events_pub_pkg.g_security := p_security_context;
1059    xla_events_pub_pkg.g_valuation_method := p_valuation_method;
1060 
1061    RETURN xla_events_pkg.allow_third_party_update
1062            (p_event_source_info     => p_event_source_info
1063            ,p_valuation_method      => p_valuation_method);
1064 
1065    trace('< xla_events_pub_pkg.allow_third_party_update'             , 20);
1066 EXCEPTION
1067 WHEN xla_exceptions_pkg.application_exception THEN
1068    RAISE;
1069 WHEN OTHERS                                   THEN
1070    xla_exceptions_pkg.raise_message
1071       (p_location => 'xla_events_pub_pkg.allow_third_party_update');
1072 END allow_third_party_update;
1073 
1074 
1075 BEGIN
1076   g_log_level      := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
1077   g_log_enabled    := fnd_log.test
1078                           (log_level  => g_log_level
1079                           ,MODULE     => C_DEFAULT_MODULE);
1080 
1081   IF NOT g_log_enabled  THEN
1082     g_log_level := C_LEVEL_LOG_DISABLED;
1083   END IF;
1084 
1085 END xla_events_pub_pkg;