[Home] [Help]
PACKAGE BODY: APPS.XLA_EVENT_SOURCES_PKG
Source
1 PACKAGE BODY xla_event_sources_pkg AS
2 /* $Header: xlaamess.pkb 120.6 2004/06/04 18:24:54 weshen ship $ */
3 /*======================================================================+
4 | Copyright (c) 1995-2002 Oracle Corporation |
5 | Redwood Shores, CA, USA |
6 | All rights reserved. |
7 +=======================================================================+
8 | PACKAGE NAME |
9 | xla_event_sources_pkg |
10 | |
11 | DESCRIPTION |
12 | XLA Event Sources Package |
13 | |
14 | HISTORY |
15 | 01-May-01 Dimple Shah Created |
16 | 20-May-04 W. Shen Delete insert_accounting_source and |
17 | delete_accounting_source since they are no|
18 | longer used. add new function |
19 | event_source_details_exist |
20 | |
21 +======================================================================*/
22
23 /*======================================================================+
24 | |
25 | Public Procedure |
26 | |
27 | insert_accounting_source |
28 | |
29 | Inserts accounting source into line types for the event class |
30 | |
31 +======================================================================*/
32 /*
33 PROCEDURE insert_accounting_source
34 (p_application_id IN NUMBER
35 ,p_entity_code IN VARCHAR2
36 ,p_event_class_code IN VARCHAR2
37 ,p_accounting_source_code IN VARCHAR2
38 ,p_acctg_source_default_flag IN VARCHAR2
39 ,p_source_application_id IN NUMBER
40 ,p_source_code IN VARCHAR2
41 ,p_source_type_code IN VARCHAR2)
42 IS
43
44 --
45 -- Private variables
46 --
47 l_exist varchar2(1);
48 l_return BOOLEAN;
49
50 l_creation_date DATE := sysdate;
51 l_last_update_date DATE := sysdate;
52 l_created_by INTEGER := xla_environment_pkg.g_usr_id;
53 l_last_update_login INTEGER := xla_environment_pkg.g_login_id;
54 l_last_updated_by INTEGER := xla_environment_pkg.g_usr_id;
55
56 --
57 -- Cursor declarations
58 --
59
60 CURSOR c_class_line_types
61 IS
62 SELECT application_id, amb_context_code, entity_code, event_class_code,
63 accounting_line_type_code, accounting_line_code
64 FROM xla_acct_line_types_b
65 WHERE application_id = p_application_id
66 AND entity_code = p_entity_code
67 AND event_class_code = p_event_class_code;
68
69 l_class_line_type c_class_line_types%rowtype;
70
71 BEGIN
72 xla_utility_pkg.trace('> xla_event_sources_pkg.insert_accounting_source' , 10);
73
74 xla_utility_pkg.trace('application_id = '||p_application_id , 20);
75 xla_utility_pkg.trace('entity_code = '||p_entity_code , 20);
76 xla_utility_pkg.trace('entity_code = '||p_event_class_code , 20);
77
78 IF p_acctg_source_default_flag = 'Y' THEN
79
80 OPEN c_class_line_types;
81 LOOP
82 FETCH c_class_line_types
83 INTO l_class_line_type;
84 EXIT WHEN c_class_line_types%notfound;
85
86 BEGIN
87
88 INSERT INTO xla_jlt_acct_attrs
89 (application_id
90 ,amb_context_code
91 ,event_class_code
92 ,accounting_line_type_code
93 ,accounting_line_code
94 ,accounting_attribute_code
95 ,source_application_id
96 ,source_code
97 ,source_type_code
98 ,creation_date
99 ,created_by
100 ,last_update_date
101 ,last_updated_by
102 ,last_update_login)
103 VALUES
104 (l_class_line_type.application_id
105 ,l_class_line_type.amb_context_code
106 ,l_class_line_type.event_class_code
107 ,l_class_line_type.accounting_line_type_code
108 ,l_class_line_type.accounting_line_code
109 ,p_accounting_source_code
110 ,p_source_application_id
111 ,p_source_code
112 ,p_source_type_code
113 ,l_creation_date
114 ,l_created_by
115 ,l_last_update_date
116 ,l_last_updated_by
117 ,l_last_update_login);
118
119 EXCEPTION
120 when others then null;
121 END;
122
123 END LOOP;
124 CLOSE c_class_line_types;
125 ELSE
126 OPEN c_class_line_types;
127 LOOP
128 FETCH c_class_line_types
129 INTO l_class_line_type;
130 EXIT WHEN c_class_line_types%notfound;
131
132 BEGIN
133
134 INSERT INTO xla_jlt_acct_attrs
135 (application_id
136 ,amb_context_code
137 ,event_class_code
138 ,accounting_line_type_code
139 ,accounting_line_code
140 ,accounting_attribute_code
141 ,creation_date
142 ,created_by
143 ,last_update_date
144 ,last_updated_by
145 ,last_update_login)
146 VALUES
147 (l_class_line_type.application_id
148 ,l_class_line_type.amb_context_code
149 ,l_class_line_type.event_class_code
150 ,l_class_line_type.accounting_line_type_code
151 ,l_class_line_type.accounting_line_code
152 ,p_accounting_source_code
153 ,l_creation_date
154 ,l_created_by
155 ,l_last_update_date
156 ,l_last_updated_by
157 ,l_last_update_login);
158
159 EXCEPTION
160 when others then null;
161
162 END;
163
164 END LOOP;
165 CLOSE c_class_line_types;
166 END IF;
167
168 xla_utility_pkg.trace('< xla_event_sources_pkg.insert_accounting_source' , 10);
169
170 EXCEPTION
171 WHEN xla_exceptions_pkg.application_exception THEN
172 RAISE;
173 WHEN OTHERS THEN
174 xla_exceptions_pkg.raise_message
175 (p_location => 'xla_event_sources_pkg.insert_accounting_source');
176
177 END insert_accounting_source;
178
179 */
180 /*======================================================================+
181 | |
182 | Public Procedure |
183 | |
184 | delete_accounting_source |
185 | |
186 | Deletes accounting source from the line types |
187 | |
188 +======================================================================*/
189 /*
190
191 PROCEDURE delete_accounting_source
192 (p_application_id IN NUMBER
193 ,p_entity_code IN VARCHAR2)
194 IS
195
196 l_exist varchar2(30):= null;
197
198 --
199 -- Cursor declarations
200 --
201
202 CURSOR c_acct_source
203 IS
204 SELECT accounting_source_code
205 FROM xla_acctg_sources_b
206 WHERE restrict_source_lov_flag = 'Y'
207 OR restrict_source_lov_flag is null;
208
209 l_acct_source c_acct_source%rowtype;
210
211 BEGIN
212
213 xla_utility_pkg.trace('> xla_event_sources_pkg.delete_accounting_source' , 10);
214
215
216 OPEN c_acct_source;
217 LOOP
218 FETCH c_acct_source
219 INTO l_acct_source;
220 EXIT WHEN c_acct_source%notfound;
221
222 DELETE
223 FROM xla_jlt_acct_attrs a
224 WHERE a.application_id = p_application_id
225 AND a.accounting_attribute_code = l_acct_source.accounting_source_code
226 AND not exists (SELECT 'x'
227 FROM xla_event_sources e
228 WHERE e.application_id = a.application_id
229 AND e.event_class_code = a.event_class_code
230 AND e.accounting_source_code = a.accounting_source_code);
231
232 END LOOP;
233 CLOSE c_acct_source;
234
235 xla_utility_pkg.trace('< xla_event_sources_pkg.delete_accounting_source' , 10);
236
237 EXCEPTION
238 WHEN xla_exceptions_pkg.application_exception THEN
239 RAISE;
240 WHEN OTHERS THEN
241 xla_exceptions_pkg.raise_message
242 (p_location => 'xla_event_sources_pkg.delete_accounting_source');
243
244 END delete_accounting_source;
245 */
246
247 /*======================================================================+
248 p_event: UPDATE or DELETE. If it is UPDATE, which means the form is
249 calling this function for updating, no out parameter need
250 to be populated since the field will be disabled. If the
251 function is called in DELETE mode, then the out parameters
252 are needed for the error messege
253 p_assignment_level: whether the source is assigned at CLASS level or
254 JLT level or AAD level. error message will be different
255 for different level
256 p_name: the name of the AAD(if the p_assignment_level is AAD) or JLT
257 (if the p_assignment_level is JLT), used in the error msg
258 p_type: the type of the AAD(if the p_assignment_level is AAD) or JLT
259 (if the p_assignment_level is JLT), used in the error msg
260 +======================================================================*/
261
262
263 FUNCTION event_source_details_exist
264 (p_application_id IN NUMBER
265 ,p_entity_code IN VARCHAR2
266 ,p_event_class_code IN VARCHAR2
267 ,p_source_application_id IN NUMBER
268 ,p_source_code IN VARCHAR2
269 ,p_source_type_code IN VARCHAR2
270 ,p_event IN VARCHAR2
271 ,p_assignment_level OUT NOCOPY VARCHAR2
272 ,p_name OUT NOCOPY VARCHAR2
273 ,p_type OUT NOCOPY VARCHAR2)
274
275 return boolean is
276
277 --
278 -- Cursor declarations
279 --
280
281 CURSOR c_class_assignment
282 IS
283 SELECT 1
284 FROM xla_evt_class_acct_attrs
285 WHERE application_id = p_application_id
286 AND event_class_code = p_event_class_code
287 AND source_application_id = p_source_application_id
288 AND source_code = p_source_code
289 AND source_type_code = p_source_type_code;
290
291
292 CURSOR c_line_assignment
293 IS
294 SELECT amb_context_code, accounting_line_type_code, accounting_line_code
295 FROM xla_jlt_acct_attrs
296 WHERE application_id = p_application_id
297 AND event_class_code = p_event_class_code
298 AND source_application_id = p_source_application_id
299 AND source_code = p_source_code
300 AND source_type_code = p_source_type_code;
301
302 CURSOR c_aad_assignment
303 IS
304 SELECT 1
305 FROM xla_aad_hdr_acct_attrs
306 WHERE application_id = p_application_id
307 AND event_class_code = p_event_class_code
308 AND source_application_id = p_source_application_id
309 AND source_code = p_source_code
310 AND source_type_code = p_source_type_code;
311
312 l_temp NUMBER;
313 l_amb_context_code xla_jlt_acct_attrs.amb_context_code%TYPE;
314 l_accounting_line_type_code xla_jlt_acct_attrs.accounting_line_type_code%TYPE;
315 l_accounting_line_code xla_jlt_acct_attrs.accounting_line_code%TYPE;
316 l_product_rule_type_code xla_aad_hdr_acct_attrs.product_rule_type_code%TYPE;
317 l_product_rule_code xla_aad_hdr_acct_attrs.product_rule_code%TYPE;
318 l_application_name varchar2(240);
319
320 begin
321
322 OPEN c_class_assignment;
323 FETCH c_class_assignment
324 INTO l_temp;
325 IF c_class_assignment%found then
326 CLOSE c_class_assignment;
327 p_assignment_level := 'CLASS';
328 return true;
329 ELSE
330 CLOSE c_class_assignment;
331
332 OPEN c_line_assignment;
333 FETCH c_line_assignment
334 INTO l_amb_context_code, l_accounting_line_type_code, l_accounting_line_code;
335 IF c_line_assignment%found then
336 CLOSE c_line_assignment;
337 IF(p_event = 'DELETE') THEN
338 p_assignment_level := 'JLT';
339 xla_validations_pkg.get_line_type_info(
340 p_application_id => p_application_id
341 ,p_amb_context_code => l_amb_context_code
342 ,p_entity_code => p_entity_code
343 ,p_event_class_code => p_event_class_code
344 ,p_accounting_line_type_code => l_accounting_line_type_code
345 ,p_accounting_line_code => l_accounting_line_code
346 ,p_application_name => l_application_name
347 ,p_accounting_line_type_name => p_name
348 ,p_accounting_line_type => p_type);
349 END IF;
350 return true;
351 ELSE
352 CLOSE c_line_assignment;
353
354 OPEN c_aad_assignment;
355 FETCH c_aad_assignment
356 INTO l_temp;
357 IF c_aad_assignment%found then
358 CLOSE c_aad_assignment;
359 IF(p_event = 'DELETE') THEN
360 p_assignment_level := 'AAD';
361 xla_validations_pkg.get_product_rule_info(
362 p_application_id => p_application_id
363 ,p_amb_context_code => l_amb_context_code
364 ,p_product_rule_type_code => l_product_rule_type_code
365 ,p_product_rule_code => l_product_rule_code
366 ,p_application_name => l_application_name
367 ,p_product_rule_name => p_name
368 ,p_product_rule_type => p_type);
369 END IF;
370 return true;
371 ELSE
372 CLOSE c_aad_assignment;
373 return false;
374 END IF;
375 END IF;
376 END IF;
377
378 end;
379 END xla_event_sources_pkg;