DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BCM_INS

Source


1 Package Body ben_bcm_ins as
2 /* $Header: bebcmrhi.pkb 115.2 2003/03/10 14:31:07 ssrayapu noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ben_bcm_ins.';  -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_cwb_matrix_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_cwb_matrix_id  in  number) is
20 --
21   l_proc       varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24   hr_utility.set_location('Entering:'||l_proc, 10);
25   --
26   ben_bcm_ins.g_cwb_matrix_id_i := p_cwb_matrix_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |------------------------------< insert_dml >------------------------------|
34 -- ----------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 --   This procedure controls the actual dml insert logic. The processing of
39 --   this procedure are as follows:
40 --   1) Initialise the object_version_number to 1 if the object_version_number
41 --      is defined as an attribute for this entity.
42 --   2) To set and unset the g_api_dml status as required (as we are about to
43 --      perform dml).
44 --   3) To insert the row into the schema.
45 --   4) To trap any constraint violations that may have occurred.
46 --   5) To raise any other errors.
47 --
48 -- Prerequisites:
49 --   This is an internal private procedure which must be called from the ins
50 --   procedure and must have all mandatory attributes set (except the
51 --   object_version_number which is initialised within this procedure).
52 --
53 -- In Parameters:
54 --   A Pl/Sql record structre.
55 --
56 -- Post Success:
57 --   The specified row will be inserted into the schema.
58 --
59 -- Post Failure:
60 --   On the insert dml failure it is important to note that we always reset the
61 --   g_api_dml status to false.
62 --   If a check, unique or parent integrity constraint violation is raised the
63 --   constraint_error procedure will be called.
64 --   If any other error is reported, the error will be raised after the
65 --   g_api_dml status is reset.
66 --
67 -- Developer Implementation Notes:
68 --   None.
69 --
70 -- Access Status:
71 --   Internal Row Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- ----------------------------------------------------------------------------
75 Procedure insert_dml
76   (p_rec in out nocopy ben_bcm_shd.g_rec_type
77   ) is
78 --
79   l_proc  varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   p_rec.object_version_number := 1;  -- Initialise the object version
84   --
85   --
86   --
87   -- Insert the row into: ben_cwb_matrix
88   --
89   insert into ben_cwb_matrix
90       (cwb_matrix_id
91       ,name
92       ,date_saved
93       ,plan_id
94       ,matrix_typ_cd
95       ,person_id
96       ,row_crit_cd
97       ,col_crit_cd
98       ,alct_by_cd
99       ,business_group_id
100       ,object_version_number
101       )
102   Values
103     (p_rec.cwb_matrix_id
104     ,p_rec.name
105     ,p_rec.date_saved
106     ,p_rec.plan_id
107     ,p_rec.matrix_typ_cd
108     ,p_rec.person_id
109     ,p_rec.row_crit_cd
110     ,p_rec.col_crit_cd
111     ,p_rec.alct_by_cd
112     ,p_rec.business_group_id
113     ,p_rec.object_version_number
114     );
115   --
116   --
117   --
118   hr_utility.set_location(' Leaving:'||l_proc, 10);
119 Exception
120   When hr_api.check_integrity_violated Then
121     -- A check constraint has been violated
122     --
123     ben_bcm_shd.constraint_error
124       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
125   When hr_api.parent_integrity_violated Then
126     -- Parent integrity has been violated
127     --
128     ben_bcm_shd.constraint_error
129       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
130   When hr_api.unique_integrity_violated Then
131     -- Unique integrity has been violated
132     --
133     ben_bcm_shd.constraint_error
134       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
135   When Others Then
136     --
137     Raise;
138 End insert_dml;
139 --
140 -- ----------------------------------------------------------------------------
141 -- |------------------------------< pre_insert >------------------------------|
142 -- ----------------------------------------------------------------------------
143 -- {Start Of Comments}
144 --
145 -- Description:
146 --   This private procedure contains any processing which is required before
147 --   the insert dml. Presently, if the entity has a corresponding primary
148 --   key which is maintained by an associating sequence, the primary key for
149 --   the entity will be populated with the next sequence value in
150 --   preparation for the insert dml.
151 --
152 -- Prerequisites:
153 --   This is an internal procedure which is called from the ins procedure.
154 --
155 -- In Parameters:
156 --   A Pl/Sql record structure.
157 --
158 -- Post Success:
159 --   Processing continues.
160 --
161 -- Post Failure:
162 --   If an error has occurred, an error message and exception will be raised
163 --   but not handled.
164 --
165 -- Developer Implementation Notes:
166 --   Any pre-processing required before the insert dml is issued should be
167 --   coded within this procedure. As stated above, a good example is the
168 --   generation of a primary key number via a corresponding sequence.
169 --   It is important to note that any 3rd party maintenance should be reviewed
170 --   before placing in this procedure.
171 --
172 -- Access Status:
173 --   Internal Row Handler Use Only.
174 --
175 -- {End Of Comments}
176 -- ----------------------------------------------------------------------------
177 Procedure pre_insert
178   (p_rec  in out nocopy ben_bcm_shd.g_rec_type
179   ) is
180 --
181   Cursor C_Sel1 is select ben_cwb_matrix_s.nextval from sys.dual;
182 --
183   Cursor C_Sel2 is
184     Select null
185       from ben_cwb_matrix
186      where cwb_matrix_id =
187              ben_bcm_ins.g_cwb_matrix_id_i;
188 --
189   l_proc   varchar2(72) := g_package||'pre_insert';
190   l_exists varchar2(1);
191 --
192 Begin
193   hr_utility.set_location('Entering:'||l_proc, 5);
194   --
195   If (ben_bcm_ins.g_cwb_matrix_id_i is not null) Then
196     --
197     -- Verify registered primary key values not already in use
198     --
199     Open C_Sel2;
200     Fetch C_Sel2 into l_exists;
201     If C_Sel2%found Then
202        Close C_Sel2;
203        --
204        -- The primary key values are already in use.
205        --
206        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
207        fnd_message.set_token('TABLE_NAME','ben_cwb_matrix');
208        fnd_message.raise_error;
209     End If;
210     Close C_Sel2;
211     --
212     -- Use registered key values and clear globals
213     --
214     p_rec.cwb_matrix_id :=
215       ben_bcm_ins.g_cwb_matrix_id_i;
216     ben_bcm_ins.g_cwb_matrix_id_i := null;
217   Else
218     --
219     -- No registerd key values, so select the next sequence number
220     --
221     --
222     -- Select the next sequence number
223     --
224     Open C_Sel1;
225     Fetch C_Sel1 Into p_rec.cwb_matrix_id;
226     Close C_Sel1;
227   End If;
228   --
229   hr_utility.set_location(' Leaving:'||l_proc, 10);
230 End pre_insert;
231 --
232 -- ----------------------------------------------------------------------------
233 -- |-----------------------------< post_insert >------------------------------|
234 -- ----------------------------------------------------------------------------
235 -- {Start Of Comments}
236 --
237 -- Description:
238 --   This private procedure contains any processing which is required after
239 --   the insert dml.
240 --
241 -- Prerequisites:
242 --   This is an internal procedure which is called from the ins procedure.
243 --
244 -- In Parameters:
245 --   A Pl/Sql record structre.
246 --
247 -- Post Success:
248 --   Processing continues.
249 --
250 -- Post Failure:
251 --   If an error has occurred, an error message and exception will be raised
252 --   but not handled.
253 --
254 -- Developer Implementation Notes:
255 --   Any post-processing required after the insert dml is issued should be
256 --   coded within this procedure. It is important to note that any 3rd party
257 --   maintenance should be reviewed before placing in this procedure.
258 --
259 -- Access Status:
260 --   Internal Row Handler Use Only.
261 --
262 -- {End Of Comments}
263 -- ----------------------------------------------------------------------------
264 Procedure post_insert
265   (p_effective_date               in date
266   ,p_rec                          in ben_bcm_shd.g_rec_type
267   ) is
268 --
269   l_proc  varchar2(72) := g_package||'post_insert';
270 --
271 Begin
272   hr_utility.set_location('Entering:'||l_proc, 5);
273   begin
274     --
275     ben_bcm_rki.after_insert
276       (p_effective_date              => p_effective_date
277       ,p_cwb_matrix_id
278       => p_rec.cwb_matrix_id
279       ,p_name
280       => p_rec.name
281       ,p_date_saved
282       => p_rec.date_saved
283       ,p_plan_id
284       => p_rec.plan_id
285       ,p_matrix_typ_cd
286       => p_rec.matrix_typ_cd
287       ,p_person_id
288       => p_rec.person_id
289       ,p_row_crit_cd
290       => p_rec.row_crit_cd
291       ,p_col_crit_cd
292       => p_rec.col_crit_cd
293       ,p_alct_by_cd
294       => p_rec.alct_by_cd
295       ,p_business_group_id
296       => p_rec.business_group_id
297       ,p_object_version_number
298       => p_rec.object_version_number
299       );
300     --
301   exception
302     --
303     when hr_api.cannot_find_prog_unit then
304       --
305       hr_api.cannot_find_prog_unit_error
306         (p_module_name => 'BEN_CWB_MATRIX'
307         ,p_hook_type   => 'AI');
308       --
309   end;
310   --
311   hr_utility.set_location(' Leaving:'||l_proc, 10);
312 End post_insert;
313 --
314 -- ----------------------------------------------------------------------------
315 -- |---------------------------------< ins >----------------------------------|
316 -- ----------------------------------------------------------------------------
317 Procedure ins
318   (p_effective_date               in date
319   ,p_rec                          in out nocopy ben_bcm_shd.g_rec_type
320   ) is
321 --
322   l_proc  varchar2(72) := g_package||'ins';
323 --
324 Begin
325   hr_utility.set_location('Entering:'||l_proc, 5);
326   --
327   -- Call the supporting insert validate operations
328   --
329   ben_bcm_bus.insert_validate
330      (p_effective_date
331      ,p_rec
332      );
333   --
334   -- Call to raise any errors on multi-message list
335   hr_multi_message.end_validation_set;
336   --
337   -- Call the supporting pre-insert operation
338   --
339   ben_bcm_ins.pre_insert(p_rec);
340   --
341   -- Insert the row
342   --
343   ben_bcm_ins.insert_dml(p_rec);
344   --
345   -- Call the supporting post-insert operation
346   --
347   ben_bcm_ins.post_insert
348      (p_effective_date
349      ,p_rec
350      );
351   --
352   -- Call to raise any errors on multi-message list
353   hr_multi_message.end_validation_set;
354   --
355   hr_utility.set_location('Leaving:'||l_proc, 20);
356 end ins;
357 --
358 -- ----------------------------------------------------------------------------
359 -- |---------------------------------< ins >----------------------------------|
360 -- ----------------------------------------------------------------------------
361 Procedure ins
362   (p_effective_date                 in     date
363   ,p_name                           in     varchar2
364   ,p_row_crit_cd                    in     varchar2
365   ,p_business_group_id              in     number
366   ,p_date_saved                     in     date     default null
367   ,p_plan_id                        in     number   default null
368   ,p_matrix_typ_cd                  in     varchar2 default null
369   ,p_person_id                      in     number   default null
370   ,p_col_crit_cd                    in     varchar2 default null
371   ,p_alct_by_cd                     in     varchar2
372   ,p_cwb_matrix_id                  out nocopy number
373   ,p_object_version_number          out nocopy number
374   ) is
375 --
376   l_rec   ben_bcm_shd.g_rec_type;
377   l_proc  varchar2(72) := g_package||'ins';
378 --
379 Begin
380   hr_utility.set_location('Entering:'||l_proc, 5);
381   --
382   -- Call conversion function to turn arguments into the
383   -- p_rec structure.
384   --
385   l_rec :=
386   ben_bcm_shd.convert_args
387     (null
388     ,p_name
389     ,p_date_saved
390     ,p_plan_id
391     ,p_matrix_typ_cd
392     ,p_person_id
393     ,p_row_crit_cd
394     ,p_col_crit_cd
395     ,p_alct_by_cd
396     ,p_business_group_id
397     ,null
398     );
399   --
400   -- Having converted the arguments into the ben_bcm_rec
401   -- plsql record structure we call the corresponding record business process.
402   --
403   ben_bcm_ins.ins
404      (p_effective_date
405      ,l_rec
406      );
407   --
408   -- As the primary key argument(s)
409   -- are specified as an OUT's we must set these values.
410   --
411   p_cwb_matrix_id := l_rec.cwb_matrix_id;
412   p_object_version_number := l_rec.object_version_number;
413   --
414   hr_utility.set_location(' Leaving:'||l_proc, 10);
415 End ins;
416 --
417 end ben_bcm_ins;