[Home] [Help]
PACKAGE BODY: APPS.PN_XLA_EVENT_PKG
Source
1 PACKAGE BODY pn_xla_event_pkg AS
2 /* $Header: PNXLAEVB.pls 120.3.12010000.2 2009/03/16 12:08:47 rkartha ship $ */
3
4 ------------------------------ DECLARATIONS ----------------------------------+
5
6 bad_input_exception EXCEPTION;
7
8
9 ------------------------------------------------------------------------------+
10 -- PROCEDURE : create_xla_event
11 -- DESCRIPTION : given a schedule_id, create SLA events for all normalized
12 -- items under that schedule
13 -- HISTORY :
14 -- 08-JUN-05 ftanudja o Created.
15 -- 16-AUG-05 ftanudja o Added exception catching as a workaround to bug
16 -- # 4529563. Reference event id in payment items table.
17 -- o Stamp payment items table with event id.
18 -- 31-MAY-06 sdmahesh o Bug # 5219481
19 -- Added OUT parameter p_event_id to create_xla_event
20 -- Removed stamping of event id in pn_payment_items_all
21 -- Now we do this in PN_CREATE_ACC
22 ------------------------------------------------------------------------------+
23
24 PROCEDURE create_xla_event(
25 p_payment_item_id pn_payment_items.payment_item_id%TYPE
26 ,p_due_date pn_payment_items.due_date%TYPE -- Added for Bug#8303091
27 ,p_legal_entity_id pn_payment_terms.legal_entity_id%TYPE
28 ,p_ledger_id pn_payment_terms.set_of_books_id%TYPE
29 ,p_org_id pn_payment_terms.org_id%TYPE
30 ,p_bill_or_pay VARCHAR2
31 ,p_event_id OUT NOCOPY xla_events.event_id%TYPE
32 )
33 IS
34 l_source_info xla_events_pub_pkg.t_event_source_info;
35 l_chk_source_info xla_events_pub_pkg.t_event_source_info;
36 l_chk_return_info xla_events_pub_pkg.t_array_event_info;
37 l_security_info xla_events_pub_pkg.t_security;
38 l_reference_info xla_events_pub_pkg.t_event_reference_info;
39
40 l_event_type VARCHAR2(30);
41 l_info VARCHAR2(100);
42 l_desc VARCHAR2(100) := 'pn_xla_event_pkg.create_xla_event';
43 l_not_found BOOLEAN;
44 l_event_id xla_events.event_id%TYPE := NULL;
45
46 l_due_date pn_payment_items.due_date%TYPE; -- Added for Bug#8303091
47
48 BEGIN
49
50 pnp_debug_pkg.log(l_desc ||' (+)');
51 pnp_debug_pkg.log('INPUT PARAMETERS');
52 pnp_debug_pkg.log('p_payment_item_id : '||TO_CHAR(p_payment_item_id));
53 pnp_debug_pkg.log('p_legal_entity_id : '||TO_CHAR(p_legal_entity_id));
54 pnp_debug_pkg.log('p_ledger_id : '||TO_CHAR(p_ledger_id));
55 pnp_debug_pkg.log('p_org_id : '||TO_CHAR(p_org_id));
56 pnp_debug_pkg.log('p_bill_or_pay : '||p_bill_or_pay);
57
58 IF p_bill_or_pay = 'PAY' THEN
59 l_event_type := 'LEASE_EXPENSE_TRANSFER';
60 ELSIF p_bill_or_pay = 'BILL' THEN
61 l_event_type := 'LEASE_REVENUE_TRANSFER';
62 ELSE
63 raise bad_input_exception;
64 END IF;
65
66 l_info := 'initializing parameters for xla API ';
67 pnp_debug_pkg.log(l_info);
68
69 l_not_found := FALSE;
70 l_source_info := null;
71 l_chk_source_info := null;
72 l_security_info := null;
73 l_chk_return_info.delete;
74
75 l_security_info.security_id_int_1 := p_org_id;
76
77 l_source_info.application_id := 240;
78 l_source_info.entity_type_code := 'TRANSACTION';
79 l_source_info.legal_entity_id := p_legal_entity_id;
80 l_source_info.ledger_id := p_ledger_id;
81 l_source_info.source_id_int_1 := p_payment_item_id;
82
83 l_chk_source_info := l_source_info;
84
85 l_due_date := p_due_date; -- Added for Bug#8303091
86
87 l_info := 'checking existence of xla event for payment item ID: '||p_payment_item_id;
88 pnp_debug_pkg.log(l_info);
89
90 -- NOTE: this 'BEGIN' and 'END' should ideally not be there.
91 -- The SLA function throws a nasty error when no data is found
92 -- We need to gracefully handle the exception thrown
93 -- Once bug 4529563 is resolved, we can remove this
94
95 BEGIN
96
97 l_chk_return_info :=
98 xla_events_pub_pkg.get_array_event_info(
99 p_event_source_info => l_chk_source_info
100 ,p_valuation_method => null
101 ,p_security_context => l_security_info
102 );
103
104 EXCEPTION
105 WHEN OTHERS THEN
106 l_not_found := TRUE;
107 END;
108
109 l_info := 'creating xla event for payment item ID: '||p_payment_item_id;
110 pnp_debug_pkg.log(l_info);
111
112 IF l_chk_return_info.COUNT = 0 OR l_not_found THEN
113
114 l_event_id :=
115 xla_events_pub_pkg.create_event(
116 p_event_source_info => l_source_info
117 ,p_event_type_code => l_event_type
118 -- ,p_event_date => SYSDATE -- Commented for Bug#8303091
119 ,p_event_date => l_due_date -- Added for Bug#8303091
120 ,p_event_status_code => xla_events_pub_pkg.C_EVENT_UNPROCESSED
121 ,p_event_number => null
122 ,p_reference_info => null
123 ,p_valuation_method => null
124 ,p_transaction_date => null
125 ,p_security_context => l_security_info
126 );
127
128 p_event_id := NULL;
129
130 IF l_event_id IS NULL THEN
131 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
132 ELSE
133 p_event_id := l_event_id;
134 END IF;
135
136 END IF;
137
138 pnp_debug_pkg.log(l_desc ||' (-)');
139
140 EXCEPTION
141 WHEN OTHERS THEN
142 pnp_debug_pkg.log(l_desc || ': Error while ' || l_info);
143 raise;
144
145 END create_xla_event;
146
147 END pn_xla_event_pkg;