1 Package Body ben_xer_ins as
2 /* $Header: bexerrhi.pkb 120.1 2006/03/22 13:57:32 tjesumic noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_xer_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_xer_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_xer_shd.g_api_dml := true; -- Set the api dml status
116 --
117 -- Insert the row into: ben_ext_data_elmt_in_rcd
118 --
119 insert into ben_ext_data_elmt_in_rcd
120 ( ext_data_elmt_in_rcd_id,
121 seq_num,
122 strt_pos,
123 dlmtr_val,
124 rqd_flag,
125 sprs_cd,
126 any_or_all_cd,
127 ext_data_elmt_id,
128 ext_rcd_id,
129 business_group_id,
130 legislation_code,
131 last_update_date,
132 creation_date,
133 last_updated_by,
134 last_update_login,
135 created_by,
136 object_version_number,
137 hide_flag
138 )
139 Values
140 ( p_rec.ext_data_elmt_in_rcd_id,
141 p_rec.seq_num,
142 p_rec.strt_pos,
143 p_rec.dlmtr_val,
144 p_rec.rqd_flag,
145 p_rec.sprs_cd,
146 p_rec.any_or_all_cd,
147 p_rec.ext_data_elmt_id,
148 p_rec.ext_rcd_id,
149 p_rec.business_group_id,
150 p_rec.legislation_code,
151 p_rec.last_update_date,
152 p_rec.creation_date,
153 p_rec.last_updated_by,
154 p_rec.last_update_login,
155 p_rec.created_by,
156 p_rec.object_version_number,
157 p_rec.hide_flag
158 );
159 --
160 ben_xer_shd.g_api_dml := false; -- Unset the api dml status
161 --
162 hr_utility.set_location(' Leaving:'||l_proc, 10);
163 Exception
164 When hr_api.check_integrity_violated Then
165 -- A check constraint has been violated
166 ben_xer_shd.g_api_dml := false; -- Unset the api dml status
167 ben_xer_shd.constraint_error
168 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
169 When hr_api.parent_integrity_violated Then
170 -- Parent integrity has been violated
171 ben_xer_shd.g_api_dml := false; -- Unset the api dml status
172 ben_xer_shd.constraint_error
173 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
174 When hr_api.unique_integrity_violated Then
175 -- Unique integrity has been violated
176 ben_xer_shd.g_api_dml := false; -- Unset the api dml status
177 ben_xer_shd.constraint_error
178 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
179 When Others Then
180 ben_xer_shd.g_api_dml := false; -- Unset the api dml status
181 Raise;
182 End insert_dml;
183 --
184 -- ----------------------------------------------------------------------------
185 -- |------------------------------< pre_insert >------------------------------|
186 -- ----------------------------------------------------------------------------
187 -- {Start Of Comments}
188 --
189 -- Description:
190 -- This private procedure contains any processing which is required before
191 -- the insert dml. Presently, if the entity has a corresponding primary
192 -- key which is maintained by an associating sequence, the primary key for
193 -- the entity will be populated with the next sequence value in
194 -- preparation for the insert dml.
195 --
196 -- Prerequisites:
197 -- This is an internal procedure which is called from the ins procedure.
198 --
199 -- In Parameters:
200 -- A Pl/Sql record structre.
201 --
202 -- Post Success:
203 -- Processing continues.
204 --
205 -- Post Failure:
206 -- If an error has occurred, an error message and exception will be raised
207 -- but not handled.
208 --
209 -- Developer Implementation Notes:
210 -- Any pre-processing required before the insert dml is issued should be
211 -- coded within this procedure. As stated above, a good example is the
212 -- generation of a primary key number via a corresponding sequence.
213 -- It is important to note that any 3rd party maintenance should be reviewed
214 -- before placing in this procedure.
215 --
216 -- Access Status:
217 -- Internal Row Handler Use Only.
218 --
219 -- {End Of Comments}
220 -- ----------------------------------------------------------------------------
221 Procedure pre_insert(p_rec in out nocopy ben_xer_shd.g_rec_type) is
222 --
223 l_proc varchar2(72) := g_package||'pre_insert';
224 --
225 Cursor C_Sel1 is select ben_ext_data_elmt_in_rcd_s.nextval from sys.dual;
226 --
227 Begin
228 hr_utility.set_location('Entering:'||l_proc, 5);
229 --
230 --
231 -- Select the next sequence number
232 --
233 Open C_Sel1;
234 Fetch C_Sel1 Into p_rec.ext_data_elmt_in_rcd_id;
235 Close C_Sel1;
236 --
237 hr_utility.set_location(' Leaving:'||l_proc, 10);
238 End pre_insert;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |-----------------------------< post_insert >------------------------------|
242 -- ----------------------------------------------------------------------------
243 -- {Start Of Comments}
244 --
245 -- Description:
246 -- This private procedure contains any processing which is required after the
247 -- insert dml.
248 --
249 -- Prerequisites:
250 -- This is an internal procedure which is called from the ins procedure.
251 --
252 -- In Parameters:
253 -- A Pl/Sql record structre.
254 --
255 -- Post Success:
256 -- Processing continues.
257 --
258 -- Post Failure:
259 -- If an error has occurred, an error message and exception will be raised
260 -- but not handled.
261 --
262 -- Developer Implementation Notes:
263 -- Any post-processing required after the insert dml is issued should be
264 -- coded within this procedure. It is important to note that any 3rd party
265 -- maintenance should be reviewed before placing in this procedure.
266 --
267 -- Access Status:
268 -- Internal Row Handler Use Only.
269 --
270 -- {End Of Comments}
271 -- ----------------------------------------------------------------------------
272 Procedure post_insert(
273 p_effective_date in date,p_rec in ben_xer_shd.g_rec_type) is
274 --
275 l_proc varchar2(72) := g_package||'post_insert';
276 --
277 Begin
278 hr_utility.set_location('Entering:'||l_proc, 5);
279 --
280 --
281 -- Start of API User Hook for post_insert.
282 --
283 begin
284 --
285 -- insert ownerships if applicable
286 --
287 create_app_ownerships('EXT_DATA_ELMT_IN_RCD_ID', p_rec.ext_data_elmt_in_rcd_id);
288 --
289 --
290 ben_xer_rki.after_insert
291 (
292 p_ext_data_elmt_in_rcd_id =>p_rec.ext_data_elmt_in_rcd_id
293 ,p_seq_num =>p_rec.seq_num
294 ,p_strt_pos =>p_rec.strt_pos
295 ,p_dlmtr_val =>p_rec.dlmtr_val
296 ,p_rqd_flag =>p_rec.rqd_flag
297 ,p_sprs_cd =>p_rec.sprs_cd
298 ,p_any_or_all_cd =>p_rec.any_or_all_cd
299 ,p_ext_data_elmt_id =>p_rec.ext_data_elmt_id
300 ,p_ext_rcd_id =>p_rec.ext_rcd_id
301 ,p_business_group_id =>p_rec.business_group_id
302 ,p_legislation_code =>p_rec.legislation_code
303 ,p_object_version_number =>p_rec.object_version_number
304 ,p_hide_flag =>p_rec.hide_flag
305 ,p_effective_date =>p_effective_date
306 );
307 --
308 exception
309 --
310 when hr_api.cannot_find_prog_unit then
311 --
312 hr_api.cannot_find_prog_unit_error
313 (p_module_name => 'ben_ext_data_elmt_in_rcd'
314 ,p_hook_type => 'AI');
315 --
316 end;
317 --
318 -- End of API User Hook for post_insert.
319 --
320 --
321 hr_utility.set_location(' Leaving:'||l_proc, 10);
322 End post_insert;
323 --
324 -- ----------------------------------------------------------------------------
325 -- |---------------------------------< ins >----------------------------------|
326 -- ----------------------------------------------------------------------------
327 Procedure ins
328 (
329 p_effective_date in date,
330 p_rec in out nocopy ben_xer_shd.g_rec_type
331 ) is
332 --
333 l_proc varchar2(72) := g_package||'ins';
334 --
335 Begin
336 hr_utility.set_location('Entering:'||l_proc, 5);
337 --
338 -- Call the supporting insert validate operations
339 --
340 ben_xer_bus.insert_validate(p_rec
341 ,p_effective_date);
342 --
343 -- Call the supporting pre-insert operation
344 --
345 pre_insert(p_rec);
346 --
347 -- Insert the row
348 --
349 insert_dml(p_rec);
350 --
351 -- Call the supporting post-insert operation
352 --
353 post_insert(
354 p_effective_date,p_rec);
355 end ins;
356 --
357 -- ----------------------------------------------------------------------------
358 -- |---------------------------------< ins >----------------------------------|
359 -- ----------------------------------------------------------------------------
360 Procedure ins
361 (
362 p_effective_date in date,
363 p_ext_data_elmt_in_rcd_id out nocopy number,
364 p_seq_num in number default null,
365 p_strt_pos in number default null,
366 p_dlmtr_val in varchar2 default null,
367 p_rqd_flag in varchar2,
368 p_sprs_cd in varchar2 default null,
369 p_any_or_all_cd in varchar2 default null,
370 p_ext_data_elmt_id in number,
371 p_ext_rcd_id in number,
372 p_business_group_id in number,
373 p_legislation_code in varchar2 default null,
374 p_last_update_date in date default null,
375 p_creation_date in date default null,
376 p_last_updated_by in number default null,
377 p_last_update_login in number default null,
378 p_created_by in number default null,
379 p_object_version_number out nocopy number,
380 p_hide_flag in varchar2
381 ) is
382 --
383 l_rec ben_xer_shd.g_rec_type;
384 l_proc varchar2(72) := g_package||'ins';
385 --
386 Begin
387 hr_utility.set_location('Entering:'||l_proc, 5);
388 --
389 -- Call conversion function to turn arguments into the
390 -- p_rec structure.
391 --
392 l_rec :=
393 ben_xer_shd.convert_args
394 (
395 null,
396 p_seq_num,
397 p_strt_pos,
398 p_dlmtr_val,
399 p_rqd_flag,
400 p_sprs_cd,
401 p_any_or_all_cd,
402 p_ext_data_elmt_id,
403 p_ext_rcd_id,
404 p_business_group_id,
405 p_legislation_code,
406 p_last_update_date,
407 p_creation_date ,
408 p_last_updated_by ,
409 p_last_update_login,
410 p_created_by ,
411 null,
412 p_hide_flag
413 );
414 --
415 -- Having converted the arguments into the ben_xer_rec
416 -- plsql record structure we call the corresponding record business process.
417 --
418 ins(
419 p_effective_date,l_rec);
420 --
421 -- As the primary key argument(s)
422 -- are specified as an OUT's we must set these values.
423 --
424 p_ext_data_elmt_in_rcd_id := l_rec.ext_data_elmt_in_rcd_id;
425 p_object_version_number := l_rec.object_version_number;
426 --
427 hr_utility.set_location(' Leaving:'||l_proc, 10);
428 End ins;
429 --
430 end ben_xer_ins;