DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XID_INS

Source


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