1 Package Body pay_put_ins as
2 /* $Header: pyputrhi.pkb 115.0 2003/09/23 08:07 tvankayl noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_put_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_user_table_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_user_table_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_put_ins.g_user_table_id_i := p_user_table_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_put_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 p_rec.object_version_number := 1; -- Initialise the object version
132 --
133 pay_put_shd.g_api_dml := true; -- Set the api dml status
134 --
135 -- Insert the row into: pay_user_tables
136 --
137 insert into pay_user_tables
138 (user_table_id
139 ,business_group_id
140 ,legislation_code
141 ,range_or_match
142 ,user_key_units
143 ,user_table_name
144 ,user_row_title
145 ,object_version_number
146 )
147 Values
148 (p_rec.user_table_id
149 ,p_rec.business_group_id
150 ,p_rec.legislation_code
151 ,p_rec.range_or_match
152 ,p_rec.user_key_units
153 ,p_rec.user_table_name
154 ,p_rec.user_row_title
155 ,p_rec.object_version_number
156 );
157 --
158 pay_put_shd.g_api_dml := false; -- Unset the api dml status
159 --
160 hr_utility.set_location(' Leaving:'||l_proc, 10);
161 Exception
162 When hr_api.check_integrity_violated Then
163 -- A check constraint has been violated
164 pay_put_shd.g_api_dml := false; -- Unset the api dml status
165 pay_put_shd.constraint_error
166 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
167 When hr_api.parent_integrity_violated Then
168 -- Parent integrity has been violated
169 pay_put_shd.g_api_dml := false; -- Unset the api dml status
170 pay_put_shd.constraint_error
171 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
172 When hr_api.unique_integrity_violated Then
173 -- Unique integrity has been violated
174 pay_put_shd.g_api_dml := false; -- Unset the api dml status
175 pay_put_shd.constraint_error
176 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
177 When Others Then
178 pay_put_shd.g_api_dml := false; -- Unset the api dml status
179 Raise;
180 End insert_dml;
181 --
182 -- ----------------------------------------------------------------------------
183 -- |------------------------------< pre_insert >------------------------------|
184 -- ----------------------------------------------------------------------------
185 -- {Start Of Comments}
186 --
187 -- Description:
188 -- This private procedure contains any processing which is required before
189 -- the insert dml. Presently, if the entity has a corresponding primary
190 -- key which is maintained by an associating sequence, the primary key for
191 -- the entity will be populated with the next sequence value in
192 -- preparation for the insert dml.
193 --
194 -- Prerequisites:
195 -- This is an internal procedure which is called from the ins procedure.
196 --
197 -- In Parameters:
198 -- A Pl/Sql record structure.
199 --
200 -- Post Success:
201 -- Processing continues.
202 --
203 -- Post Failure:
204 -- If an error has occurred, an error message and exception will be raised
205 -- but not handled.
206 --
207 -- Developer Implementation Notes:
208 -- Any pre-processing required before the insert dml is issued should be
209 -- coded within this procedure. As stated above, a good example is the
210 -- generation of a primary key number via a corresponding sequence.
211 -- It is important to note that any 3rd party maintenance should be reviewed
212 -- before placing in this procedure.
213 --
214 -- Access Status:
215 -- Internal Row Handler Use Only.
216 --
217 -- {End Of Comments}
218 -- ----------------------------------------------------------------------------
219 Procedure pre_insert
220 (p_rec in out nocopy pay_put_shd.g_rec_type
221 ) is
222 --
223 Cursor C_Sel1 is select pay_user_tables_s.nextval from sys.dual;
224 --
225 Cursor C_Sel2 is
226 Select null
227 from pay_user_tables
228 where user_table_id =
229 pay_put_ins.g_user_table_id_i;
230 --
231 l_proc varchar2(72) := g_package||'pre_insert';
232 l_exists varchar2(1);
233 --
234 Begin
235 hr_utility.set_location('Entering:'||l_proc, 5);
236 --
237 If (pay_put_ins.g_user_table_id_i is not null) Then
238 --
239 -- Verify registered primary key values not already in use
240 --
241 Open C_Sel2;
242 Fetch C_Sel2 into l_exists;
243 If C_Sel2%found Then
244 Close C_Sel2;
245 --
246 -- The primary key values are already in use.
247 --
248 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
249 fnd_message.set_token('TABLE_NAME','pay_user_tables');
250 fnd_message.raise_error;
251 End If;
252 Close C_Sel2;
253 --
254 -- Use registered key values and clear globals
255 --
256 p_rec.user_table_id :=
257 pay_put_ins.g_user_table_id_i;
258 pay_put_ins.g_user_table_id_i := null;
259 Else
260 --
261 -- No registerd key values, so select the next sequence number
262 --
263 --
264 -- Select the next sequence number
265 --
266 Open C_Sel1;
267 Fetch C_Sel1 Into p_rec.user_table_id;
268 Close C_Sel1;
269 End If;
270 --
271 hr_utility.set_location(' Leaving:'||l_proc, 10);
272 End pre_insert;
273 --
274 -- ----------------------------------------------------------------------------
275 -- |-----------------------------< post_insert >------------------------------|
276 -- ----------------------------------------------------------------------------
277 -- {Start Of Comments}
278 --
279 -- Description:
280 -- This private procedure contains any processing which is required after
281 -- the insert dml.
282 --
283 -- Prerequisites:
284 -- This is an internal procedure which is called from the ins procedure.
285 --
286 -- In Parameters:
287 -- A Pl/Sql record structre.
288 --
289 -- Post Success:
290 -- Processing continues.
291 --
292 -- Post Failure:
293 -- If an error has occurred, an error message and exception will be raised
294 -- but not handled.
295 --
296 -- Developer Implementation Notes:
297 -- Any post-processing required after the insert dml is issued should be
298 -- coded within this procedure. It is important to note that any 3rd party
299 -- maintenance should be reviewed before placing in this procedure.
300 --
301 -- Access Status:
302 -- Internal Row Handler Use Only.
303 --
304 -- {End Of Comments}
305 -- ----------------------------------------------------------------------------
306 Procedure post_insert
307 (p_effective_date in date
308 ,p_rec in pay_put_shd.g_rec_type
309 ) is
310 --
311 l_proc varchar2(72) := g_package||'post_insert';
312 --
313 Begin
314 hr_utility.set_location('Entering:'||l_proc, 5);
315 begin
316 --
317 -- insert ownerships if applicable
318 create_app_ownerships
319 ('USER_TABLE_ID', p_rec.user_table_id
320 );
321 --
322 --
323 pay_put_rki.after_insert
324 (p_effective_date
325 => p_effective_date
326 ,p_user_table_id
327 => p_rec.user_table_id
328 ,p_business_group_id
329 => p_rec.business_group_id
330 ,p_legislation_code
331 => p_rec.legislation_code
332 ,p_range_or_match
333 => p_rec.range_or_match
334 ,p_user_key_units
335 => p_rec.user_key_units
336 ,p_user_table_name
337 => p_rec.user_table_name
338 ,p_user_row_title
339 => p_rec.user_row_title
340 ,p_object_version_number
341 => p_rec.object_version_number
342 );
343 --
344 exception
345 --
346 when hr_api.cannot_find_prog_unit then
347 --
348 hr_api.cannot_find_prog_unit_error
349 (p_module_name => 'PAY_USER_TABLES'
350 ,p_hook_type => 'AI');
351 --
352 end;
353 --
354 hr_utility.set_location(' Leaving:'||l_proc, 10);
355 End post_insert;
356 --
357 -- ----------------------------------------------------------------------------
358 -- |---------------------------------< ins >----------------------------------|
359 -- ----------------------------------------------------------------------------
360 Procedure ins
361 (p_effective_date in date
362 ,p_rec in out nocopy pay_put_shd.g_rec_type
363 ) is
364 --
365 l_proc varchar2(72) := g_package||'ins';
366 --
367 Begin
368 hr_utility.set_location('Entering:'||l_proc, 5);
369 --
370 -- Call the supporting insert validate operations
371 --
372 pay_put_bus.insert_validate
373 (p_effective_date
374 ,p_rec
375 );
376 --
377 -- Call to raise any errors on multi-message list
378 hr_multi_message.end_validation_set;
379 --
380 -- Call the supporting pre-insert operation
381 --
382 pay_put_ins.pre_insert(p_rec);
383 --
384 -- Insert the row
385 --
386 pay_put_ins.insert_dml(p_rec);
387 --
388 -- Call the supporting post-insert operation
389 --
390 pay_put_ins.post_insert
391 (p_effective_date
392 ,p_rec
393 );
394 --
395 -- Call to raise any errors on multi-message list
396 hr_multi_message.end_validation_set;
397 --
398 hr_utility.set_location('Leaving:'||l_proc, 20);
399 end ins;
400 --
401 -- ----------------------------------------------------------------------------
402 -- |---------------------------------< ins >----------------------------------|
403 -- ----------------------------------------------------------------------------
404 Procedure ins
405 (p_effective_date in date
406 ,p_range_or_match in varchar2
407 ,p_user_key_units in varchar2
408 ,p_user_table_name in varchar2
409 ,p_business_group_id in number default null
410 ,p_legislation_code in varchar2 default null
411 ,p_user_row_title in varchar2 default null
412 ,p_user_table_id out nocopy number
413 ,p_object_version_number out nocopy number
414 ) is
415 --
416 l_rec pay_put_shd.g_rec_type;
417 l_proc varchar2(72) := g_package||'ins';
418 --
419 Begin
420 hr_utility.set_location('Entering:'||l_proc, 5);
421 --
422 -- Call conversion function to turn arguments into the
423 -- p_rec structure.
424 --
425 l_rec :=
426 pay_put_shd.convert_args
427 (null
428 ,p_business_group_id
429 ,p_legislation_code
430 ,p_range_or_match
431 ,p_user_key_units
432 ,p_user_table_name
433 ,p_user_row_title
434 ,null
435 );
436 --
437 -- Having converted the arguments into the pay_put_rec
438 -- plsql record structure we call the corresponding record business process.
439 --
440 pay_put_ins.ins
441 (p_effective_date
442 ,l_rec
443 );
444 --
445 -- As the primary key argument(s)
446 -- are specified as an OUT's we must set these values.
447 --
448 p_user_table_id := l_rec.user_table_id;
449 p_object_version_number := l_rec.object_version_number;
450 --
451 hr_utility.set_location(' Leaving:'||l_proc, 10);
452 End ins;
453 --
454 end pay_put_ins;