DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XDD_INS

Source


1 Package Body ben_xdd_ins as
2 /* $Header: bexddrhi.pkb 120.1 2005/06/08 13:09:46 tjesumic noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_xdd_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_xdd_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_xdd_shd.g_api_dml := true;  -- Set the api dml status
116   --
117   -- Insert the row into: ben_ext_data_elmt_decd
118   --
119   insert into ben_ext_data_elmt_decd
120   (	ext_data_elmt_decd_id,
121 	val,
122 	dcd_val,
123 	chg_evt_source,
124 	ext_data_elmt_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_data_elmt_decd_id,
136 	p_rec.val,
137 	p_rec.dcd_val,
138 	p_rec.chg_evt_source,
139 	p_rec.ext_data_elmt_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_xdd_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_xdd_shd.g_api_dml := false;   -- Unset the api dml status
157     ben_xdd_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_xdd_shd.g_api_dml := false;   -- Unset the api dml status
162     ben_xdd_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_xdd_shd.g_api_dml := false;   -- Unset the api dml status
167     ben_xdd_shd.constraint_error
168       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
169   When Others Then
170     ben_xdd_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_xdd_shd.g_rec_type) is
212 --
213   l_proc  varchar2(72) := g_package||'pre_insert';
214 --
215   Cursor C_Sel1 is select ben_ext_data_elmt_decd_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_data_elmt_decd_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
255 --   maintenance should be reviewed before placing in this procedure.
256 --
257 -- Access Status:
258 --   Internal Row Handler Use Only.
259 --
260 -- {End Of Comments}
261 -- ----------------------------------------------------------------------------
262 Procedure post_insert(p_rec in ben_xdd_shd.g_rec_type) is
263 --
264   l_proc  varchar2(72) := g_package||'post_insert';
265 --
266 Begin
267   hr_utility.set_location('Entering:'||l_proc, 5);
268 --
269   --
270   -- Start of API User Hook for post_insert.
271   --
272   begin
273     --
274     --
275     -- insert ownerships if applicable
276     --
277     create_app_ownerships('EXT_DATA_ELMT_DECD_ID', p_rec.ext_data_elmt_decd_id);
278     --
279     ben_xdd_rki.after_insert
280       (
281   p_ext_data_elmt_decd_id         =>p_rec.ext_data_elmt_decd_id
282  ,p_val                           =>p_rec.val
283  ,p_dcd_val                       =>p_rec.dcd_val
284  ,p_chg_evt_source                =>p_rec.chg_evt_source
285  ,p_ext_data_elmt_id              =>p_rec.ext_data_elmt_id
286  ,p_business_group_id             =>p_rec.business_group_id
287  ,p_legislation_code              =>p_rec.legislation_code
288  ,p_object_version_number         =>p_rec.object_version_number
289       );
290     --
291   exception
292     --
293     when hr_api.cannot_find_prog_unit then
294       --
295       hr_api.cannot_find_prog_unit_error
296         (p_module_name => 'ben_ext_data_elmt_decd'
297         ,p_hook_type   => 'AI');
298       --
299   end;
300   --
301   -- End of API User Hook for post_insert.
302   --
303   --
304   hr_utility.set_location(' Leaving:'||l_proc, 10);
305 End post_insert;
306 --
307 -- ----------------------------------------------------------------------------
308 -- |---------------------------------< ins >----------------------------------|
309 -- ----------------------------------------------------------------------------
310 Procedure ins
311   (
312   p_rec        in out nocopy ben_xdd_shd.g_rec_type
313   ) is
314 --
315   l_proc  varchar2(72) := g_package||'ins';
316 --
317 Begin
318   hr_utility.set_location('Entering:'||l_proc, 5);
319   --
320   -- Call the supporting insert validate operations
321   --
322   ben_xdd_bus.insert_validate(p_rec);
323   --
324   -- Call the supporting pre-insert operation
325   --
326   pre_insert(p_rec);
327   --
328   -- Insert the row
329   --
330   insert_dml(p_rec);
331   --
332   -- Call the supporting post-insert operation
333   --
334   post_insert(p_rec);
335 end ins;
336 --
337 -- ----------------------------------------------------------------------------
338 -- |---------------------------------< ins >----------------------------------|
339 -- ----------------------------------------------------------------------------
340 Procedure ins
341   (
342   p_ext_data_elmt_decd_id        out nocopy number,
343   p_val                          in varchar2         default null,
344   p_dcd_val                      in varchar2         default null,
345   p_chg_evt_source               in varchar2         default null,
346   p_ext_data_elmt_id             in number,
347   p_business_group_id            in number,
348   p_legislation_code             in varchar2         default null,
349   p_last_update_date             in date             default null,
350   p_creation_date                in date             default null,
351   p_last_updated_by              in number           default null,
352   p_last_update_login            in number           default null,
353   p_created_by                   in number           default null,
354   p_object_version_number        out nocopy number
355   ) is
356 --
357   l_rec	  ben_xdd_shd.g_rec_type;
358   l_proc  varchar2(72) := g_package||'ins';
359 --
360 Begin
361   hr_utility.set_location('Entering:'||l_proc, 5);
362   --
363   -- Call conversion function to turn arguments into the
364   -- p_rec structure.
365   --
366   hr_utility.set_location(' value ' || p_val , 101);
367   hr_utility.set_location('d  value ' ||  p_dcd_val , 101);
368 
369   l_rec :=
370   ben_xdd_shd.convert_args
371   (
372   null,
373   p_val,
374   p_dcd_val,
375   p_chg_evt_source,
376   p_ext_data_elmt_id,
377   p_business_group_id,
378   p_legislation_code,
379   p_last_update_date,
380   p_creation_date   ,
381   p_last_updated_by ,
382   p_last_update_login,
383   p_created_by       ,
384   null
385   );
386   --
387   -- Having converted the arguments into the ben_xdd_rec
388   -- plsql record structure we call the corresponding record business process.
389   --
390   ins(l_rec);
391   --
392   -- As the primary key argument(s)
393   -- are specified as an OUT's we must set these values.
394   --
395   p_ext_data_elmt_decd_id := l_rec.ext_data_elmt_decd_id;
396   p_object_version_number := l_rec.object_version_number;
397   --
398   hr_utility.set_location(' Leaving:'||l_proc, 10);
399 End ins;
400 --
401 end ben_xdd_ins;