1 Package Body ben_xrf_ins as
2 /* $Header: bexrfrhi.pkb 120.3 2006/04/06 17:46:56 tjesumic noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_xrf_ins.'; -- Global package name
9
10 --
11 -- ----------------------------------------------------------------------------
12 -- |-----------------------< create_app_ownerships >--------------------------|
13 -- ----------------------------------------------------------------------------
14 --
15 -- Description:
16 -- This procedure inserts a row into the HR_APPLICATION_OWNERSHIPS table
17 -- when the row handler is called in the appropriate mode.
18 --
19 -- ----------------------------------------------------------------------------
20 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
21 ,p_pk_value IN varchar2) IS
22 --
23 CURSOR csr_definition (p_session_id NUMBER) IS
24 SELECT product_short_name
25 FROM hr_owner_definitions
26 WHERE session_id = p_session_id;
27 --
28 l_session_id NUMBER;
29 --
30 BEGIN
31 --
32 IF (hr_startup_data_api_support.return_startup_mode IN
33 ('STARTUP','GENERIC')) THEN
34 --
35 l_session_id := nvl(hr_startup_data_api_support.g_startup_session_id
36 ,hr_startup_data_api_support.g_session_id);
37 --
38 FOR c1 IN csr_definition(l_session_id) LOOP
39 --
40 INSERT INTO hr_application_ownerships
41 (key_name
42 ,key_value
43 ,product_name
44 )
45 VALUES
46 (p_pk_column
47 ,fnd_number.number_to_canonical(p_pk_value)
48 ,c1.product_short_name
49 );
50 END LOOP;
51 END IF;
52 END create_app_ownerships;
53 --
54 -- ----------------------------------------------------------------------------
55 -- |-----------------------< create_app_ownerships >--------------------------|
56 -- ----------------------------------------------------------------------------
57 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
58 ,p_pk_value IN number) IS
59 --
60 BEGIN
61 create_app_ownerships(p_pk_column, to_char(p_pk_value));
62 END create_app_ownerships;
63
64 --
65 -- ----------------------------------------------------------------------------
66 -- |------------------------------< insert_dml >------------------------------|
67 -- ----------------------------------------------------------------------------
68 -- {Start Of Comments}
69 --
70 -- Description:
71 -- This procedure controls the actual dml insert logic. The processing of
72 -- this procedure are as follows:
73 -- 1) Initialise the object_version_number to 1 if the object_version_number
74 -- is defined as an attribute for this entity.
75 -- 2) To set and unset the g_api_dml status as required (as we are about to
76 -- perform dml).
77 -- 3) To insert the row into the schema.
78 -- 4) To trap any constraint violations that may have occurred.
79 -- 5) To raise any other errors.
80 --
81 -- Prerequisites:
82 -- This is an internal private procedure which must be called from the ins
83 -- procedure and must have all mandatory attributes set (except the
84 -- object_version_number which is initialised within this procedure).
85 --
86 -- In Parameters:
87 -- A Pl/Sql record structre.
88 --
89 -- Post Success:
90 -- The specified row will be inserted into the schema.
91 --
92 -- Post Failure:
93 -- On the insert dml failure it is important to note that we always reset the
94 -- g_api_dml status to false.
95 -- If a check, unique or parent integrity constraint violation is raised the
96 -- constraint_error procedure will be called.
97 -- If any other error is reported, the error will be raised after the
98 -- g_api_dml status is reset.
99 --
100 -- Developer Implementation Notes:
101 -- None.
102 --
103 -- Access Status:
104 -- Internal Row Handler Use Only.
105 --
106 -- {End Of Comments}
107 -- ----------------------------------------------------------------------------
108 Procedure insert_dml(p_rec in out nocopy ben_xrf_shd.g_rec_type) is
109 --
110 l_proc varchar2(72) := g_package||'insert_dml';
111 --
112 Begin
113 hr_utility.set_location('Entering:'||l_proc, 5);
114 p_rec.object_version_number := 1; -- Initialise the object version
115 --
116 ben_xrf_shd.g_api_dml := true; -- Set the api dml status
117 --
118 -- Insert the row into: ben_ext_rcd_in_file
119 --
120 insert into ben_ext_rcd_in_file
121 ( ext_rcd_in_file_id,
122 seq_num,
123 sprs_cd,
124 sort1_data_elmt_in_rcd_id,
125 sort2_data_elmt_in_rcd_id,
126 sort3_data_elmt_in_rcd_id,
127 sort4_data_elmt_in_rcd_id,
128 ext_rcd_id,
129 ext_file_id,
130 business_group_id,
131 legislation_code,
132 last_update_date,
133 creation_date,
134 last_updated_by,
135 last_update_login,
136 created_by,
137 object_version_number,
138 any_or_all_cd,
139 hide_flag,
140 rqd_flag ,
141 chg_rcd_upd_flag
142 )
143 Values
144 ( p_rec.ext_rcd_in_file_id,
145 p_rec.seq_num,
146 p_rec.sprs_cd,
147 p_rec.sort1_data_elmt_in_rcd_id,
148 p_rec.sort2_data_elmt_in_rcd_id,
149 p_rec.sort3_data_elmt_in_rcd_id,
150 p_rec.sort4_data_elmt_in_rcd_id,
151 p_rec.ext_rcd_id,
152 p_rec.ext_file_id,
153 p_rec.business_group_id,
154 p_rec.legislation_code,
155 p_rec.last_update_date,
156 p_rec.creation_date,
157 p_rec.last_updated_by,
158 p_rec.last_update_login,
159 p_rec.created_by,
160 p_rec.object_version_number,
161 p_rec.any_or_all_cd,
162 p_rec.hide_flag,
163 p_rec.rqd_flag ,
164 p_rec.chg_rcd_upd_flag
165 );
166 --
167 ben_xrf_shd.g_api_dml := false; -- Unset the api dml status
168 --
169 hr_utility.set_location(' Leaving:'||l_proc, 10);
170 Exception
171 When hr_api.check_integrity_violated Then
172 -- A check constraint has been violated
173 ben_xrf_shd.g_api_dml := false; -- Unset the api dml status
174 ben_xrf_shd.constraint_error
175 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
176 When hr_api.parent_integrity_violated Then
177 -- Parent integrity has been violated
178 ben_xrf_shd.g_api_dml := false; -- Unset the api dml status
179 ben_xrf_shd.constraint_error
180 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
181 When hr_api.unique_integrity_violated Then
182 -- Unique integrity has been violated
186 When Others Then
183 ben_xrf_shd.g_api_dml := false; -- Unset the api dml status
184 ben_xrf_shd.constraint_error
185 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
187 ben_xrf_shd.g_api_dml := false; -- Unset the api dml status
188 Raise;
189 End insert_dml;
190 --
191 -- ----------------------------------------------------------------------------
192 -- |------------------------------< pre_insert >------------------------------|
193 -- ----------------------------------------------------------------------------
194 -- {Start Of Comments}
195 --
196 -- Description:
197 -- This private procedure contains any processing which is required before
198 -- the insert dml. Presently, if the entity has a corresponding primary
199 -- key which is maintained by an associating sequence, the primary key for
200 -- the entity will be populated with the next sequence value in
201 -- preparation for the insert dml.
202 --
203 -- Prerequisites:
204 -- This is an internal procedure which is called from the ins procedure.
205 --
206 -- In Parameters:
207 -- A Pl/Sql record structre.
208 --
209 -- Post Success:
210 -- Processing continues.
211 --
212 -- Post Failure:
213 -- If an error has occurred, an error message and exception will be raised
214 -- but not handled.
215 --
216 -- Developer Implementation Notes:
217 -- Any pre-processing required before the insert dml is issued should be
218 -- coded within this procedure. As stated above, a good example is the
219 -- generation of a primary key number via a corresponding sequence.
220 -- It is important to note that any 3rd party maintenance should be reviewed
221 -- before placing in this procedure.
222 --
223 -- Access Status:
224 -- Internal Row Handler Use Only.
225 --
226 -- {End Of Comments}
227 -- ----------------------------------------------------------------------------
228 Procedure pre_insert(p_rec in out nocopy ben_xrf_shd.g_rec_type) is
229 --
230 l_proc varchar2(72) := g_package||'pre_insert';
231 --
232 Cursor C_Sel1 is select ben_ext_rcd_in_file_s.nextval from sys.dual;
233 --
234 Begin
235 hr_utility.set_location('Entering:'||l_proc, 5);
236 --
237 --
238 -- Select the next sequence number
239 --
240 Open C_Sel1;
241 Fetch C_Sel1 Into p_rec.ext_rcd_in_file_id;
242 Close C_Sel1;
243 --
244 hr_utility.set_location(' Leaving:'||l_proc, 10);
245 End pre_insert;
246 --
247 -- ----------------------------------------------------------------------------
248 -- |-----------------------------< post_insert >------------------------------|
249 -- ----------------------------------------------------------------------------
250 -- {Start Of Comments}
251 --
252 -- Description:
253 -- This private procedure contains any processing which is required after the
254 -- insert dml.
255 --
256 -- Prerequisites:
257 -- This is an internal procedure which is called from the ins procedure.
258 --
259 -- In Parameters:
260 -- A Pl/Sql record structre.
261 --
262 -- Post Success:
263 -- Processing continues.
264 --
265 -- Post Failure:
266 -- If an error has occurred, an error message and exception will be raised
267 -- but not handled.
268 --
269 -- Developer Implementation Notes:
270 -- Any post-processing required after the insert dml is issued should be
271 -- coded within this procedure. It is important to note that any 3rd party
272 -- maintenance should be reviewed before placing in this procedure.
273 --
274 -- Access Status:
275 -- Internal Row Handler Use Only.
276 --
277 -- {End Of Comments}
278 -- ----------------------------------------------------------------------------
279 Procedure post_insert(
280 p_effective_date in date,p_rec in ben_xrf_shd.g_rec_type) is
281 --
282 l_proc varchar2(72) := g_package||'post_insert';
283 --
284 Begin
285 hr_utility.set_location('Entering:'||l_proc, 5);
286 --
287 --
288 -- insert ownerships if applicable
289 --
290 create_app_ownerships('EXT_RCD_IN_FILE_ID', p_rec.ext_rcd_in_file_id);
291
292 --
293 -- Start of API User Hook for post_insert.
294 --
295 begin
296 --
297 ben_xrf_rki.after_insert
298 (
299 p_ext_rcd_in_file_id =>p_rec.ext_rcd_in_file_id
300 ,p_seq_num =>p_rec.seq_num
301 ,p_sprs_cd =>p_rec.sprs_cd
302 ,p_sort1_data_elmt_in_rcd_id =>p_rec.sort1_data_elmt_in_rcd_id
303 ,p_sort2_data_elmt_in_rcd_id =>p_rec.sort2_data_elmt_in_rcd_id
304 ,p_sort3_data_elmt_in_rcd_id =>p_rec.sort3_data_elmt_in_rcd_id
305 ,p_sort4_data_elmt_in_rcd_id =>p_rec.sort4_data_elmt_in_rcd_id
306 ,p_ext_rcd_id =>p_rec.ext_rcd_id
307 ,p_ext_file_id =>p_rec.ext_file_id
308 ,p_business_group_id =>p_rec.business_group_id
309 ,p_legislation_code =>p_rec.legislation_code
310 ,p_object_version_number =>p_rec.object_version_number
311 ,p_any_or_all_cd =>p_rec.any_or_all_cd
312 ,p_hide_flag =>p_rec.hide_flag
313 ,p_rqd_flag =>p_rec.rqd_flag
314 ,p_chg_rcd_upd_flag =>p_rec.chg_rcd_upd_flag
315 ,p_effective_date =>p_effective_date
316 );
317 --
318 exception
319 --
320 when hr_api.cannot_find_prog_unit then
321 --
322 hr_api.cannot_find_prog_unit_error
323 (p_module_name => 'ben_ext_rcd_in_file'
324 ,p_hook_type => 'AI');
325 --
326 end;
327 --
328 -- End of API User Hook for post_insert.
329 --
330 --
331 hr_utility.set_location(' Leaving:'||l_proc, 10);
332 End post_insert;
333 --
334 -- ----------------------------------------------------------------------------
335 -- |---------------------------------< ins >----------------------------------|
336 -- ----------------------------------------------------------------------------
337 Procedure ins
338 (
339 p_effective_date in date,
340 p_rec in out nocopy ben_xrf_shd.g_rec_type
341 ) is
342 --
343 l_proc varchar2(72) := g_package||'ins';
344 --
345 Begin
346 hr_utility.set_location('Entering:'||l_proc, 5);
347 --
348 -- Call the supporting insert validate operations
349 --
350 ben_xrf_bus.insert_validate(p_rec
351 ,p_effective_date);
352 --
353 -- Call the supporting pre-insert operation
354 --
355 pre_insert(p_rec);
356 --
357 -- Insert the row
358 --
359 insert_dml(p_rec);
360 --
361 -- Call the supporting post-insert operation
362 --
363 post_insert(
364 p_effective_date,p_rec);
365 end ins;
366 --
367 -- ----------------------------------------------------------------------------
368 -- |---------------------------------< ins >----------------------------------|
369 -- ----------------------------------------------------------------------------
370 Procedure ins
371 (
372 p_effective_date in date,
373 p_ext_rcd_in_file_id out nocopy number,
374 p_seq_num in number default null,
375 p_sprs_cd in varchar2 default null,
376 p_sort1_data_elmt_in_rcd_id in number default null,
377 p_sort2_data_elmt_in_rcd_id in number default null,
378 p_sort3_data_elmt_in_rcd_id in number default null,
379 p_sort4_data_elmt_in_rcd_id in number default null,
380 p_ext_rcd_id in number,
381 p_ext_file_id in number,
382 p_business_group_id in number,
383 p_legislation_code in varchar2 default null,
384 p_last_update_date in date default null,
385 p_creation_date in date default null,
386 p_last_updated_by in number default null,
387 p_last_update_login in number default null,
388 p_created_by in number default null,
389 p_object_version_number out nocopy number,
390 p_any_or_all_cd in varchar2 default null,
391 p_hide_flag in varchar2,
392 p_rqd_flag in varchar2 ,
393 p_chg_rcd_upd_flag in varchar2 default 'N'
394 ) is
395 --
396 l_rec ben_xrf_shd.g_rec_type;
397 l_proc varchar2(72) := g_package||'ins';
398 --
399 Begin
400 hr_utility.set_location('Entering:'||l_proc, 5);
401 --
402 -- Call conversion function to turn arguments into the
403 -- p_rec structure.
404 --
405 l_rec :=
406 ben_xrf_shd.convert_args
407 (
408 null,
409 p_seq_num,
410 p_sprs_cd,
411 p_sort1_data_elmt_in_rcd_id,
412 p_sort2_data_elmt_in_rcd_id,
413 p_sort3_data_elmt_in_rcd_id,
414 p_sort4_data_elmt_in_rcd_id,
415 p_ext_rcd_id,
416 p_ext_file_id,
417 p_business_group_id,
418 p_legislation_code,
419 p_last_update_date,
420 p_creation_date ,
421 p_last_updated_by ,
422 p_last_update_login,
423 p_created_by ,
424 null,
425 p_any_or_all_cd,
426 p_hide_flag,
427 p_rqd_flag ,
428 p_chg_rcd_upd_flag
429 );
430 --
431 -- Having converted the arguments into the ben_xrf_rec
432 -- plsql record structure we call the corresponding record business process.
433 --
434 ins(
435 p_effective_date,l_rec);
436 --
437 -- As the primary key argument(s)
438 -- are specified as an OUT's we must set these values.
439 --
440 p_ext_rcd_in_file_id := l_rec.ext_rcd_in_file_id;
441 p_object_version_number := l_rec.object_version_number;
442 --
443 hr_utility.set_location(' Leaving:'||l_proc, 10);
444 End ins;
445 --
446 end ben_xrf_ins;