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