[Home] [Help]
PACKAGE BODY: APPS.BEN_XFI_INS
Source
1 Package Body ben_xfi_ins as
2 /* $Header: bexfirhi.pkb 120.0 2005/05/28 12:33:36 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_xfi_ins.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |-----------------------< create_app_ownerships >--------------------------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description:
15 -- This procedure inserts a row into the HR_APPLICATION_OWNERSHIPS table
16 -- when the row handler is called in the appropriate mode.
17 --
18 -- ----------------------------------------------------------------------------
19 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
20 ,p_pk_value IN varchar2) IS
21 --
22 CURSOR csr_definition (p_session_id NUMBER) IS
23 SELECT product_short_name
24 FROM hr_owner_definitions
25 WHERE session_id = p_session_id;
26 --
27 l_session_id NUMBER;
28 --
29 BEGIN
30 --
31 IF (hr_startup_data_api_support.return_startup_mode IN
32 ('STARTUP','GENERIC')) THEN
33 --
34 l_session_id := nvl(hr_startup_data_api_support.g_startup_session_id
35 ,hr_startup_data_api_support.g_session_id);
36 --
37 FOR c1 IN csr_definition(l_session_id) LOOP
38 --
39 INSERT INTO hr_application_ownerships
40 (key_name
41 ,key_value
42 ,product_name
43 )
44 VALUES
45 (p_pk_column
46 ,fnd_number.number_to_canonical(p_pk_value)
47 ,c1.product_short_name
48 );
49 END LOOP;
50 END IF;
51 END create_app_ownerships;
52 --
53 -- ----------------------------------------------------------------------------
54 -- |-----------------------< create_app_ownerships >--------------------------|
55 -- ----------------------------------------------------------------------------
56 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
57 ,p_pk_value IN number) IS
58 --
59 BEGIN
60 create_app_ownerships(p_pk_column, to_char(p_pk_value));
61 END create_app_ownerships;
62 --
63 --
64 -- ----------------------------------------------------------------------------
65 -- |------------------------------< insert_dml >------------------------------|
66 -- ----------------------------------------------------------------------------
67 -- {Start Of Comments}
68 --
69 -- Description:
70 -- This procedure controls the actual dml insert logic. The processing of
71 -- this procedure are as follows:
72 -- 1) Initialise the object_version_number to 1 if the object_version_number
73 -- is defined as an attribute for this entity.
74 -- 2) To set and unset the g_api_dml status as required (as we are about to
75 -- perform dml).
76 -- 3) To insert the row into the schema.
77 -- 4) To trap any constraint violations that may have occurred.
78 -- 5) To raise any other errors.
79 --
80 -- Prerequisites:
81 -- This is an internal private procedure which must be called from the ins
82 -- procedure and must have all mandatory attributes set (except the
83 -- object_version_number which is initialised within this procedure).
84 --
85 -- In Parameters:
86 -- A Pl/Sql record structre.
87 --
88 -- Post Success:
89 -- The specified row will be inserted into the schema.
90 --
91 -- Post Failure:
92 -- On the insert dml failure it is important to note that we always reset the
93 -- g_api_dml status to false.
94 -- If a check, unique or parent integrity constraint violation is raised the
95 -- constraint_error procedure will be called.
96 -- If any other error is reported, the error will be raised after the
97 -- g_api_dml status is reset.
98 --
99 -- Developer Implementation Notes:
100 -- None.
101 --
102 -- Access Status:
103 -- Internal Row Handler Use Only.
104 --
105 -- {End Of Comments}
106 -- ----------------------------------------------------------------------------
107 Procedure insert_dml(p_rec in out nocopy ben_xfi_shd.g_rec_type) is
108 --
109 l_proc varchar2(72) := g_package||'insert_dml';
110 --
111 Begin
112 hr_utility.set_location('Entering:'||l_proc, 5);
113 p_rec.object_version_number := 1; -- Initialise the object version
114 --
115 ben_xfi_shd.g_api_dml := true; -- Set the api dml status
116 --
117 -- Insert the row into: ben_ext_file
118 --
119 insert into ben_ext_file
120 ( ext_file_id,
121 name,
122 xml_tag_name,
123 business_group_id,
124 legislation_code,
125 xfi_attribute_category,
126 xfi_attribute1,
127 xfi_attribute2,
128 xfi_attribute3,
129 xfi_attribute4,
130 xfi_attribute5,
131 xfi_attribute6,
132 xfi_attribute7,
133 xfi_attribute8,
134 xfi_attribute9,
135 xfi_attribute10,
136 xfi_attribute11,
137 xfi_attribute12,
138 xfi_attribute13,
139 xfi_attribute14,
140 xfi_attribute15,
141 xfi_attribute16,
142 xfi_attribute17,
143 xfi_attribute18,
144 xfi_attribute19,
145 xfi_attribute20,
146 xfi_attribute21,
147 xfi_attribute22,
148 xfi_attribute23,
149 xfi_attribute24,
150 xfi_attribute25,
151 xfi_attribute26,
152 xfi_attribute27,
153 xfi_attribute28,
154 xfi_attribute29,
155 xfi_attribute30,
156 ext_rcd_in_file_id ,
157 ext_data_elmt_in_rcd_id1 ,
158 ext_data_elmt_in_rcd_id2 ,
159 last_update_date,
160 creation_date,
161 last_updated_by,
162 last_update_login,
163 created_by,
164 object_version_number
165 )
166 Values
167 ( p_rec.ext_file_id,
168 p_rec.name,
169 p_rec.xml_tag_name,
170 p_rec.business_group_id,
171 p_rec.legislation_code,
172 p_rec.xfi_attribute_category,
173 p_rec.xfi_attribute1,
174 p_rec.xfi_attribute2,
175 p_rec.xfi_attribute3,
176 p_rec.xfi_attribute4,
177 p_rec.xfi_attribute5,
178 p_rec.xfi_attribute6,
179 p_rec.xfi_attribute7,
180 p_rec.xfi_attribute8,
181 p_rec.xfi_attribute9,
182 p_rec.xfi_attribute10,
183 p_rec.xfi_attribute11,
184 p_rec.xfi_attribute12,
185 p_rec.xfi_attribute13,
186 p_rec.xfi_attribute14,
187 p_rec.xfi_attribute15,
188 p_rec.xfi_attribute16,
189 p_rec.xfi_attribute17,
190 p_rec.xfi_attribute18,
191 p_rec.xfi_attribute19,
192 p_rec.xfi_attribute20,
193 p_rec.xfi_attribute21,
194 p_rec.xfi_attribute22,
195 p_rec.xfi_attribute23,
196 p_rec.xfi_attribute24,
197 p_rec.xfi_attribute25,
198 p_rec.xfi_attribute26,
199 p_rec.xfi_attribute27,
200 p_rec.xfi_attribute28,
201 p_rec.xfi_attribute29,
202 p_rec.xfi_attribute30,
203 p_rec.ext_rcd_in_file_id ,
204 p_rec.ext_data_elmt_in_rcd_id1 ,
205 p_rec.ext_data_elmt_in_rcd_id2 ,
206 p_rec.last_update_date,
207 p_rec.creation_date,
208 p_rec.last_updated_by,
209 p_rec.last_update_login,
210 p_rec.created_by,
211 p_rec.object_version_number
212 );
213 --
214 ben_xfi_shd.g_api_dml := false; -- Unset the api dml status
215 --
216 hr_utility.set_location(' Leaving:'||l_proc, 10);
217 Exception
218 When hr_api.check_integrity_violated Then
219 -- A check constraint has been violated
220 ben_xfi_shd.g_api_dml := false; -- Unset the api dml status
221 ben_xfi_shd.constraint_error
222 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
223 When hr_api.parent_integrity_violated Then
224 -- Parent integrity has been violated
225 ben_xfi_shd.g_api_dml := false; -- Unset the api dml status
226 ben_xfi_shd.constraint_error
227 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
228 When hr_api.unique_integrity_violated Then
229 -- Unique integrity has been violated
230 ben_xfi_shd.g_api_dml := false; -- Unset the api dml status
231 ben_xfi_shd.constraint_error
232 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
233 When Others Then
234 ben_xfi_shd.g_api_dml := false; -- Unset the api dml status
235 Raise;
236 End insert_dml;
237 --
238 -- ----------------------------------------------------------------------------
239 -- |------------------------------< pre_insert >------------------------------|
240 -- ----------------------------------------------------------------------------
241 -- {Start Of Comments}
242 --
243 -- Description:
244 -- This private procedure contains any processing which is required before
245 -- the insert dml. Presently, if the entity has a corresponding primary
246 -- key which is maintained by an associating sequence, the primary key for
247 -- the entity will be populated with the next sequence value in
248 -- preparation for the insert dml.
249 --
250 -- Prerequisites:
251 -- This is an internal procedure which is called from the ins procedure.
252 --
253 -- In Parameters:
254 -- A Pl/Sql record structre.
255 --
256 -- Post Success:
257 -- Processing continues.
258 --
259 -- Post Failure:
260 -- If an error has occurred, an error message and exception will be raised
261 -- but not handled.
262 --
263 -- Developer Implementation Notes:
264 -- Any pre-processing required before the insert dml is issued should be
265 -- coded within this procedure. As stated above, a good example is the
266 -- generation of a primary key number via a corresponding sequence.
267 -- It is important to note that any 3rd party maintenance should be reviewed
268 -- before placing in this procedure.
269 --
270 -- Access Status:
271 -- Internal Row Handler Use Only.
272 --
273 -- {End Of Comments}
274 -- ----------------------------------------------------------------------------
275 Procedure pre_insert(p_rec in out nocopy ben_xfi_shd.g_rec_type) is
276 --
277 l_proc varchar2(72) := g_package||'pre_insert';
278 --
279 Cursor C_Sel1 is select ben_ext_file_s.nextval from sys.dual;
280 --
281 Begin
282 hr_utility.set_location('Entering:'||l_proc, 5);
283 --
284 --
285 -- Select the next sequence number
286 --
287 Open C_Sel1;
288 Fetch C_Sel1 Into p_rec.ext_file_id;
289 Close C_Sel1;
290 --
291 hr_utility.set_location(' Leaving:'||l_proc, 10);
292 End pre_insert;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |-----------------------------< post_insert >------------------------------|
296 -- ----------------------------------------------------------------------------
297 -- {Start Of Comments}
298 --
299 -- Description:
300 -- This private procedure contains any processing which is required after the
301 -- insert dml.
302 --
303 -- Prerequisites:
304 -- This is an internal procedure which is called from the ins procedure.
305 --
306 -- In Parameters:
307 -- A Pl/Sql record structre.
308 --
309 -- Post Success:
310 -- Processing continues.
311 --
312 -- Post Failure:
313 -- If an error has occurred, an error message and exception will be raised
314 -- but not handled.
315 --
316 -- Developer Implementation Notes:
317 -- Any post-processing required after the insert dml is issued should be
318 -- coded within this procedure. It is important to note that any 3rd party
319 -- maintenance should be reviewed before placing in this procedure.
320 --
321 -- Access Status:
322 -- Internal Row Handler Use Only.
323 --
324 -- {End Of Comments}
325 -- ----------------------------------------------------------------------------
326 Procedure post_insert(p_rec in ben_xfi_shd.g_rec_type) is
327 --
328 l_proc varchar2(72) := g_package||'post_insert';
329 --
330 Begin
331 hr_utility.set_location('Entering:'||l_proc, 5);
332 --
333 --
334 -- Start of API User Hook for post_insert.
335 --
336 begin
337 --
338 -- insert ownerships if applicable
339 --
340 create_app_ownerships('EXT_FILE_ID', p_rec.ext_file_id);
341 --
342 --
343 ben_xfi_rki.after_insert
344 (
345 p_ext_file_id =>p_rec.ext_file_id
346 ,p_name =>p_rec.name
347 ,p_xml_tag_name =>p_rec.xml_tag_name
348 ,p_business_group_id =>p_rec.business_group_id
349 ,p_legislation_code =>p_rec.legislation_code
350 ,p_xfi_attribute_category =>p_rec.xfi_attribute_category
351 ,p_xfi_attribute1 =>p_rec.xfi_attribute1
352 ,p_xfi_attribute2 =>p_rec.xfi_attribute2
353 ,p_xfi_attribute3 =>p_rec.xfi_attribute3
354 ,p_xfi_attribute4 =>p_rec.xfi_attribute4
355 ,p_xfi_attribute5 =>p_rec.xfi_attribute5
356 ,p_xfi_attribute6 =>p_rec.xfi_attribute6
357 ,p_xfi_attribute7 =>p_rec.xfi_attribute7
358 ,p_xfi_attribute8 =>p_rec.xfi_attribute8
359 ,p_xfi_attribute9 =>p_rec.xfi_attribute9
360 ,p_xfi_attribute10 =>p_rec.xfi_attribute10
361 ,p_xfi_attribute11 =>p_rec.xfi_attribute11
362 ,p_xfi_attribute12 =>p_rec.xfi_attribute12
363 ,p_xfi_attribute13 =>p_rec.xfi_attribute13
364 ,p_xfi_attribute14 =>p_rec.xfi_attribute14
365 ,p_xfi_attribute15 =>p_rec.xfi_attribute15
366 ,p_xfi_attribute16 =>p_rec.xfi_attribute16
367 ,p_xfi_attribute17 =>p_rec.xfi_attribute17
368 ,p_xfi_attribute18 =>p_rec.xfi_attribute18
369 ,p_xfi_attribute19 =>p_rec.xfi_attribute19
370 ,p_xfi_attribute20 =>p_rec.xfi_attribute20
371 ,p_xfi_attribute21 =>p_rec.xfi_attribute21
372 ,p_xfi_attribute22 =>p_rec.xfi_attribute22
373 ,p_xfi_attribute23 =>p_rec.xfi_attribute23
374 ,p_xfi_attribute24 =>p_rec.xfi_attribute24
375 ,p_xfi_attribute25 =>p_rec.xfi_attribute25
376 ,p_xfi_attribute26 =>p_rec.xfi_attribute26
377 ,p_xfi_attribute27 =>p_rec.xfi_attribute27
378 ,p_xfi_attribute28 =>p_rec.xfi_attribute28
379 ,p_xfi_attribute29 =>p_rec.xfi_attribute29
380 ,p_xfi_attribute30 =>p_rec.xfi_attribute30
381 ,p_ext_rcd_in_file_id =>p_rec.ext_rcd_in_file_id
382 ,p_ext_data_elmt_in_rcd_id1 =>p_rec.ext_data_elmt_in_rcd_id1
383 ,p_ext_data_elmt_in_rcd_id2 =>p_rec.ext_data_elmt_in_rcd_id2
384 ,p_object_version_number =>p_rec.object_version_number
385 );
386 --
387 exception
388 --
389 when hr_api.cannot_find_prog_unit then
390 --
391 hr_api.cannot_find_prog_unit_error
392 (p_module_name => 'ben_ext_file'
393 ,p_hook_type => 'AI');
394 --
395 end;
396 --
397 -- End of API User Hook for post_insert.
398 --
399 --
400 hr_utility.set_location(' Leaving:'||l_proc, 10);
401 End post_insert;
402 --
403 -- ----------------------------------------------------------------------------
404 -- |---------------------------------< ins >----------------------------------|
405 -- ----------------------------------------------------------------------------
406 Procedure ins
407 (
408 p_rec in out nocopy ben_xfi_shd.g_rec_type
409 ) is
410 --
411 l_proc varchar2(72) := g_package||'ins';
412 --
413 Begin
414 hr_utility.set_location('Entering:'||l_proc, 5);
415 --
416 -- Call the supporting insert validate operations
417 --
418 ben_xfi_bus.insert_validate(p_rec);
419 --
420 ben_xel_bus.chk_xml_name_format
421 ( p_xml_tag_name => p_rec.xml_tag_name
422 ) ;
423
424 -- Call the supporting pre-insert operation
425 --
426 pre_insert(p_rec);
427 --
428 -- Insert the row
429 --
430 insert_dml(p_rec);
431 --
432 -- Call the supporting post-insert operation
433 --
434 post_insert(p_rec);
435 end ins;
436 --
437 -- ----------------------------------------------------------------------------
438 -- |---------------------------------< ins >----------------------------------|
439 -- ----------------------------------------------------------------------------
440 Procedure ins
441 (
442 p_ext_file_id out nocopy number,
443 p_name in varchar2 default null,
444 p_xml_tag_name in varchar2 default null,
445 p_business_group_id in number,
446 p_legislation_code in varchar2 default null,
447 p_xfi_attribute_category in varchar2 default null,
448 p_xfi_attribute1 in varchar2 default null,
449 p_xfi_attribute2 in varchar2 default null,
450 p_xfi_attribute3 in varchar2 default null,
451 p_xfi_attribute4 in varchar2 default null,
452 p_xfi_attribute5 in varchar2 default null,
453 p_xfi_attribute6 in varchar2 default null,
454 p_xfi_attribute7 in varchar2 default null,
455 p_xfi_attribute8 in varchar2 default null,
456 p_xfi_attribute9 in varchar2 default null,
457 p_xfi_attribute10 in varchar2 default null,
458 p_xfi_attribute11 in varchar2 default null,
459 p_xfi_attribute12 in varchar2 default null,
460 p_xfi_attribute13 in varchar2 default null,
461 p_xfi_attribute14 in varchar2 default null,
462 p_xfi_attribute15 in varchar2 default null,
463 p_xfi_attribute16 in varchar2 default null,
464 p_xfi_attribute17 in varchar2 default null,
465 p_xfi_attribute18 in varchar2 default null,
466 p_xfi_attribute19 in varchar2 default null,
467 p_xfi_attribute20 in varchar2 default null,
468 p_xfi_attribute21 in varchar2 default null,
469 p_xfi_attribute22 in varchar2 default null,
470 p_xfi_attribute23 in varchar2 default null,
471 p_xfi_attribute24 in varchar2 default null,
472 p_xfi_attribute25 in varchar2 default null,
473 p_xfi_attribute26 in varchar2 default null,
474 p_xfi_attribute27 in varchar2 default null,
475 p_xfi_attribute28 in varchar2 default null,
476 p_xfi_attribute29 in varchar2 default null,
477 p_xfi_attribute30 in varchar2 default null,
478 p_ext_rcd_in_file_id in number default null,
479 p_ext_data_elmt_in_rcd_id1 in number default null ,
480 p_ext_data_elmt_in_rcd_id2 in number default null ,
481 p_last_update_date in date default null,
482 p_creation_date in date default null,
483 p_last_updated_by in number default null,
484 p_last_update_login in number default null,
485 p_created_by in number default null,
486 p_object_version_number out nocopy number
487 ) is
488 --
489 l_rec ben_xfi_shd.g_rec_type;
490 l_proc varchar2(72) := g_package||'ins';
491 --
492 Begin
493 hr_utility.set_location('Entering:'||l_proc, 5);
494 --
495 -- Call conversion function to turn arguments into the
496 -- p_rec structure.
497 --
498 l_rec :=
499 ben_xfi_shd.convert_args
500 (
501 null,
502 p_name,
503 p_xml_tag_name,
504 p_business_group_id,
505 p_legislation_code,
506 p_xfi_attribute_category,
507 p_xfi_attribute1,
508 p_xfi_attribute2,
509 p_xfi_attribute3,
510 p_xfi_attribute4,
511 p_xfi_attribute5,
512 p_xfi_attribute6,
513 p_xfi_attribute7,
514 p_xfi_attribute8,
515 p_xfi_attribute9,
516 p_xfi_attribute10,
517 p_xfi_attribute11,
518 p_xfi_attribute12,
519 p_xfi_attribute13,
520 p_xfi_attribute14,
521 p_xfi_attribute15,
522 p_xfi_attribute16,
523 p_xfi_attribute17,
524 p_xfi_attribute18,
525 p_xfi_attribute19,
526 p_xfi_attribute20,
527 p_xfi_attribute21,
528 p_xfi_attribute22,
529 p_xfi_attribute23,
530 p_xfi_attribute24,
531 p_xfi_attribute25,
532 p_xfi_attribute26,
533 p_xfi_attribute27,
534 p_xfi_attribute28,
535 p_xfi_attribute29,
536 p_xfi_attribute30,
537 p_ext_rcd_in_file_id ,
538 p_ext_data_elmt_in_rcd_id1,
539 p_ext_data_elmt_in_rcd_id2,
540 p_last_update_date,
541 p_creation_date ,
542 p_last_updated_by ,
543 p_last_update_login,
544 p_created_by ,
545 null
546 );
547 --
548 -- Having converted the arguments into the ben_xfi_rec
549 -- plsql record structure we call the corresponding record business process.
550 --
551 ins(l_rec);
552 --
553 -- As the primary key argument(s)
554 -- are specified as an OUT's we must set these values.
555 --
556 p_ext_file_id := l_rec.ext_file_id;
557 p_object_version_number := l_rec.object_version_number;
558 --
559 hr_utility.set_location(' Leaving:'||l_proc, 10);
560 End ins;
561 --
562 end ben_xfi_ins;