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