DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XCT_INS

Source


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