1 Package Body pay_bld_ins as
2 /* $Header: pybldrhi.pkb 120.0 2005/05/29 03:19 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_bld_ins.'; -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_balance_dimension_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_balance_dimension_id in number) is
20 --
21 l_proc varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24 hr_utility.set_location('Entering:'||l_proc, 10);
25 --
26 pay_bld_ins.g_balance_dimension_id_i := p_balance_dimension_id;
27 --
28 hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |-----------------------< create_app_ownerships >--------------------------|
34 -- ----------------------------------------------------------------------------
35 --
36 -- Description:
37 -- This procedure inserts a row into the HR_APPLICATION_OWNERSHIPS table
38 -- when the row handler is called in the appropriate mode.
39 --
40 -- ----------------------------------------------------------------------------
41 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
42 ,p_pk_value IN varchar2) IS
43 --
44 CURSOR csr_definition IS
45 SELECT product_short_name
46 FROM hr_owner_definitions
47 WHERE session_id = hr_startup_data_api_support.g_session_id;
48 --
49 BEGIN
50 --
51 IF (hr_startup_data_api_support.return_startup_mode IN
52 ('STARTUP','GENERIC')) THEN
53 --
54 FOR c1 IN csr_definition LOOP
55 --
56 INSERT INTO hr_application_ownerships
57 (key_name
58 ,key_value
59 ,product_name
60 )
61 VALUES
62 (p_pk_column
63 ,fnd_number.number_to_canonical(p_pk_value)
64 ,c1.product_short_name
65 );
66 END LOOP;
67 END IF;
68 END create_app_ownerships;
69 --
70 -- ----------------------------------------------------------------------------
71 -- |-----------------------< create_app_ownerships >--------------------------|
72 -- ----------------------------------------------------------------------------
73 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
74 ,p_pk_value IN number) IS
75 --
76 BEGIN
77 create_app_ownerships(p_pk_column, to_char(p_pk_value));
78 END create_app_ownerships;
79 --
80 -- ----------------------------------------------------------------------------
81 -- |------------------------------< insert_dml >------------------------------|
82 -- ----------------------------------------------------------------------------
83 -- {Start Of Comments}
84 --
85 -- Description:
86 -- This procedure controls the actual dml insert logic. The processing of
87 -- this procedure are as follows:
88 -- 1) Initialise the object_version_number to 1 if the object_version_number
89 -- is defined as an attribute for this entity.
90 -- 2) To set and unset the g_api_dml status as required (as we are about to
91 -- perform dml).
92 -- 3) To insert the row into the schema.
93 -- 4) To trap any constraint violations that may have occurred.
94 -- 5) To raise any other errors.
95 --
96 -- Prerequisites:
97 -- This is an internal private procedure which must be called from the ins
98 -- procedure and must have all mandatory attributes set (except the
99 -- object_version_number which is initialised within this procedure).
100 --
101 -- In Parameters:
102 -- A Pl/Sql record structre.
103 --
104 -- Post Success:
105 -- The specified row will be inserted into the schema.
106 --
107 -- Post Failure:
108 -- On the insert dml failure it is important to note that we always reset the
109 -- g_api_dml status to false.
110 -- If a check, unique or parent integrity constraint violation is raised the
111 -- constraint_error procedure will be called.
112 -- If any other error is reported, the error will be raised after the
113 -- g_api_dml status is reset.
114 --
115 -- Developer Implementation Notes:
116 -- None.
117 --
118 -- Access Status:
119 -- Internal Row Handler Use Only.
120 --
121 -- {End Of Comments}
122 -- ----------------------------------------------------------------------------
123 Procedure insert_dml
124 (p_rec in out nocopy pay_bld_shd.g_rec_type
125 ) is
126 --
127 l_proc varchar2(72) := g_package||'insert_dml';
128 --
129 Begin
130 hr_utility.set_location('Entering:'||l_proc, 5);
131 --
132 --
133 --
134 --
135 -- Insert the row into: pay_balance_dimensions
136 --
137 insert into pay_balance_dimensions
138 (balance_dimension_id
139 ,business_group_id
140 ,legislation_code
141 ,route_id
142 ,database_item_suffix
143 ,dimension_name
144 ,dimension_type
145 ,description
146 ,feed_checking_code
147 ,legislation_subgroup
148 ,payments_flag
149 ,expiry_checking_code
150 ,expiry_checking_level
151 ,feed_checking_type
152 ,dimension_level
153 ,period_type
154 ,asg_action_balance_dim_id
155 ,database_item_function
156 ,save_run_balance_enabled
157 ,start_date_code
158 )
159 Values
160 (p_rec.balance_dimension_id
161 ,p_rec.business_group_id
162 ,p_rec.legislation_code
163 ,p_rec.route_id
164 ,p_rec.database_item_suffix
165 ,p_rec.dimension_name
166 ,p_rec.dimension_type
167 ,p_rec.description
168 ,p_rec.feed_checking_code
169 ,p_rec.legislation_subgroup
170 ,p_rec.payments_flag
171 ,p_rec.expiry_checking_code
172 ,p_rec.expiry_checking_level
173 ,p_rec.feed_checking_type
174 ,p_rec.dimension_level
175 ,p_rec.period_type
176 ,p_rec.asg_action_balance_dim_id
177 ,p_rec.database_item_function
178 ,p_rec.save_run_balance_enabled
179 ,p_rec.start_date_code
180 );
181 --
182 --
183 --
184 hr_utility.set_location(' Leaving:'||l_proc, 10);
185 Exception
186 When hr_api.check_integrity_violated Then
187 -- A check constraint has been violated
188 --
189 pay_bld_shd.constraint_error
190 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
191 When hr_api.parent_integrity_violated Then
192 -- Parent integrity has been violated
193 --
194 pay_bld_shd.constraint_error
195 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
196 When hr_api.unique_integrity_violated Then
197 -- Unique integrity has been violated
198 --
199 pay_bld_shd.constraint_error
200 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
201 When Others Then
202 --
203 Raise;
204 End insert_dml;
205 --
206 -- ----------------------------------------------------------------------------
207 -- |------------------------------< pre_insert >------------------------------|
208 -- ----------------------------------------------------------------------------
209 -- {Start Of Comments}
210 --
211 -- Description:
212 -- This private procedure contains any processing which is required before
213 -- the insert dml. Presently, if the entity has a corresponding primary
214 -- key which is maintained by an associating sequence, the primary key for
215 -- the entity will be populated with the next sequence value in
216 -- preparation for the insert dml.
217 --
218 -- Prerequisites:
219 -- This is an internal procedure which is called from the ins procedure.
220 --
221 -- In Parameters:
222 -- A Pl/Sql record structure.
223 --
224 -- Post Success:
225 -- Processing continues.
226 --
227 -- Post Failure:
228 -- If an error has occurred, an error message and exception will be raised
229 -- but not handled.
230 --
231 -- Developer Implementation Notes:
232 -- Any pre-processing required before the insert dml is issued should be
233 -- coded within this procedure. As stated above, a good example is the
234 -- generation of a primary key number via a corresponding sequence.
235 -- It is important to note that any 3rd party maintenance should be reviewed
236 -- before placing in this procedure.
237 --
238 -- Access Status:
239 -- Internal Row Handler Use Only.
240 --
241 -- {End Of Comments}
242 -- ----------------------------------------------------------------------------
243 Procedure pre_insert
244 (p_rec in out nocopy pay_bld_shd.g_rec_type
245 ) is
246 --
247 Cursor C_Sel1 is select pay_balance_dimensions_s.nextval from sys.dual;
248 --
249 Cursor C_Sel2 is
250 Select null
251 from pay_balance_dimensions
252 where balance_dimension_id =
253 pay_bld_ins.g_balance_dimension_id_i;
254 --
255 l_proc varchar2(72) := g_package||'pre_insert';
256 l_exists varchar2(1);
257 --
258 Begin
259 hr_utility.set_location('Entering:'||l_proc, 5);
260 --
261 If (pay_bld_ins.g_balance_dimension_id_i is not null) Then
262 --
263 -- Verify registered primary key values not already in use
264 --
265 Open C_Sel2;
266 Fetch C_Sel2 into l_exists;
267 If C_Sel2%found Then
268 Close C_Sel2;
269 --
270 -- The primary key values are already in use.
271 --
272 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
273 fnd_message.set_token('TABLE_NAME','pay_balance_dimensions');
274 fnd_message.raise_error;
275 End If;
276 Close C_Sel2;
277 --
278 -- Use registered key values and clear globals
279 --
280 p_rec.balance_dimension_id :=
281 pay_bld_ins.g_balance_dimension_id_i;
282 pay_bld_ins.g_balance_dimension_id_i := null;
283 Else
284 --
285 -- No registerd key values, so select the next sequence number
286 --
287 --
288 -- Select the next sequence number
289 --
290 Open C_Sel1;
291 Fetch C_Sel1 Into p_rec.balance_dimension_id;
292 Close C_Sel1;
293 End If;
294 --
295 hr_utility.set_location(' Leaving:'||l_proc, 10);
296 End pre_insert;
297 --
298 -- ----------------------------------------------------------------------------
299 -- |-----------------------------< post_insert >------------------------------|
300 -- ----------------------------------------------------------------------------
301 -- {Start Of Comments}
302 --
303 -- Description:
304 -- This private procedure contains any processing which is required after
305 -- the insert dml.
306 --
307 -- Prerequisites:
308 -- This is an internal procedure which is called from the ins procedure.
309 --
310 -- In Parameters:
311 -- A Pl/Sql record structre.
312 --
313 -- Post Success:
314 -- Processing continues.
315 --
316 -- Post Failure:
317 -- If an error has occurred, an error message and exception will be raised
318 -- but not handled.
319 --
320 -- Developer Implementation Notes:
321 -- Any post-processing required after the insert dml is issued should be
322 -- coded within this procedure. It is important to note that any 3rd party
323 -- maintenance should be reviewed before placing in this procedure.
324 --
325 -- Access Status:
326 -- Internal Row Handler Use Only.
327 --
328 -- {End Of Comments}
329 -- ----------------------------------------------------------------------------
330 Procedure post_insert
331 (p_rec in pay_bld_shd.g_rec_type
332 ) is
333 --
334 l_proc varchar2(72) := g_package||'post_insert';
335 --
336 Begin
337 hr_utility.set_location('Entering:'||l_proc, 5);
338 begin
339 --
340 -- insert ownerships if applicable
341 create_app_ownerships
342 ('BALANCE_DIMENSION_ID', p_rec.balance_dimension_id
343 );
344 --
345 --
346 pay_bld_rki.after_insert
347 (p_balance_dimension_id
348 => p_rec.balance_dimension_id
349 ,p_business_group_id
350 => p_rec.business_group_id
351 ,p_legislation_code
352 => p_rec.legislation_code
353 ,p_route_id
354 => p_rec.route_id
355 ,p_database_item_suffix
356 => p_rec.database_item_suffix
357 ,p_dimension_name
358 => p_rec.dimension_name
359 ,p_dimension_type
360 => p_rec.dimension_type
361 ,p_description
362 => p_rec.description
363 ,p_feed_checking_code
364 => p_rec.feed_checking_code
365 ,p_legislation_subgroup
366 => p_rec.legislation_subgroup
367 ,p_payments_flag
368 => p_rec.payments_flag
369 ,p_expiry_checking_code
370 => p_rec.expiry_checking_code
371 ,p_expiry_checking_level
372 => p_rec.expiry_checking_level
373 ,p_feed_checking_type
374 => p_rec.feed_checking_type
375 ,p_dimension_level
376 => p_rec.dimension_level
377 ,p_period_type
378 => p_rec.period_type
379 ,p_asg_action_balance_dim_id
380 => p_rec.asg_action_balance_dim_id
381 ,p_database_item_function
382 => p_rec.database_item_function
383 ,p_save_run_balance_enabled
384 => p_rec.save_run_balance_enabled
385 ,p_start_date_code
386 => p_rec.start_date_code
387 );
388 --
389 exception
390 --
391 when hr_api.cannot_find_prog_unit then
392 --
393 hr_api.cannot_find_prog_unit_error
394 (p_module_name => 'PAY_BALANCE_DIMENSIONS'
395 ,p_hook_type => 'AI');
396 --
397 end;
398 --
399 hr_utility.set_location(' Leaving:'||l_proc, 10);
400 End post_insert;
401 --
402 -- ----------------------------------------------------------------------------
403 -- |---------------------------------< ins >----------------------------------|
404 -- ----------------------------------------------------------------------------
405 Procedure ins
406 (p_rec in out nocopy pay_bld_shd.g_rec_type
407 ) is
408 --
409 l_proc varchar2(72) := g_package||'ins';
410 --
411 Begin
412 hr_utility.set_location('Entering:'||l_proc, 5);
413 --
414 -- Call the supporting insert validate operations
415 --
416 pay_bld_bus.insert_validate
417 (p_rec
418 );
419 --
420 -- Call to raise any errors on multi-message list
421 hr_multi_message.end_validation_set;
422 --
423 -- Call the supporting pre-insert operation
424 --
425 pay_bld_ins.pre_insert(p_rec);
426 --
427 -- Insert the row
428 --
429 pay_bld_ins.insert_dml(p_rec);
430 --
431 -- Call the supporting post-insert operation
432 --
433 pay_bld_ins.post_insert
434 (p_rec
435 );
436 --
437 -- Call to raise any errors on multi-message list
438 hr_multi_message.end_validation_set;
439 --
440 hr_utility.set_location('Leaving:'||l_proc, 20);
441 end ins;
442 --
443 -- ----------------------------------------------------------------------------
444 -- |---------------------------------< ins >----------------------------------|
445 -- ----------------------------------------------------------------------------
446 Procedure ins
447 (p_route_id in number
448 ,p_database_item_suffix in varchar2
449 ,p_dimension_name in varchar2
450 ,p_dimension_type in varchar2
451 ,p_business_group_id in number default null
452 ,p_legislation_code in varchar2 default null
453 ,p_description in varchar2 default null
454 ,p_feed_checking_code in varchar2 default null
455 ,p_legislation_subgroup in varchar2 default null
456 ,p_payments_flag in varchar2 default null
457 ,p_expiry_checking_code in varchar2 default null
458 ,p_expiry_checking_level in varchar2 default null
459 ,p_feed_checking_type in varchar2 default null
460 ,p_dimension_level in varchar2 default null
461 ,p_period_type in varchar2 default null
462 ,p_asg_action_balance_dim_id in number default null
463 ,p_database_item_function in varchar2 default null
464 ,p_save_run_balance_enabled in varchar2 default null
465 ,p_start_date_code in varchar2 default null
466 ,p_balance_dimension_id out nocopy number
467 ) is
468 --
469 l_rec pay_bld_shd.g_rec_type;
470 l_proc varchar2(72) := g_package||'ins';
471 --
472 Begin
473 hr_utility.set_location('Entering:'||l_proc, 5);
474 --
475 -- Call conversion function to turn arguments into the
476 -- p_rec structure.
477 --
478 l_rec :=
479 pay_bld_shd.convert_args
480 (null
481 ,p_business_group_id
482 ,p_legislation_code
483 ,p_route_id
484 ,p_database_item_suffix
485 ,p_dimension_name
486 ,p_dimension_type
487 ,p_description
488 ,p_feed_checking_code
489 ,p_legislation_subgroup
490 ,p_payments_flag
491 ,p_expiry_checking_code
492 ,p_expiry_checking_level
493 ,p_feed_checking_type
494 ,p_dimension_level
495 ,p_period_type
496 ,p_asg_action_balance_dim_id
497 ,p_database_item_function
498 ,p_save_run_balance_enabled
499 ,p_start_date_code
500 );
501 --
502 -- Having converted the arguments into the pay_bld_rec
503 -- plsql record structure we call the corresponding record business process.
504 --
505 pay_bld_ins.ins
506 (l_rec
507 );
508 --
509 -- As the primary key argument(s)
510 -- are specified as an OUT's we must set these values.
511 --
512 p_balance_dimension_id := l_rec.balance_dimension_id;
513 --
514 --
515 hr_utility.set_location(' Leaving:'||l_proc, 10);
516 End ins;
517 --
518 end pay_bld_ins;