DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_BDT_INS

Source


1 Package Body pay_bdt_ins as
2 /* $Header: pybdtrhi.pkb 120.3 2005/11/24 05:36 arashid noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_bdt_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To insert the row into the schema.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
27 --   This is an internal private procedure which must be called from the ins
28 --   procedure and must have all mandatory attributes set (except the
29 --   object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 --   On the insert dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   None.
47 --
48 -- Access Status:
49 --   Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml
54   (p_rec in out nocopy pay_bdt_shd.g_rec_type
55   ) is
56 --
57   l_proc  varchar2(72) := g_package||'insert_dml';
58 --
59 Begin
60   hr_utility.set_location('Entering:'||l_proc, 5);
61   --
62   --
63   --
64   --
65   -- Insert the row into: pay_balance_dimensions_tl
66   --
67   insert into pay_balance_dimensions_tl
68       (balance_dimension_id
69       ,language
70       ,source_lang
71       ,dimension_name
72       ,database_item_suffix
73       ,description
74       )
75   Values
76     (p_rec.balance_dimension_id
77     ,p_rec.language
78     ,p_rec.source_lang
79     ,p_rec.dimension_name
80     ,p_rec.database_item_suffix
81     ,p_rec.description
82     );
83   --
84   --
85   --
86   hr_utility.set_location(' Leaving:'||l_proc, 10);
87 Exception
88   When hr_api.check_integrity_violated Then
89     -- A check constraint has been violated
90     --
91     pay_bdt_shd.constraint_error
92       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93   When hr_api.parent_integrity_violated Then
94     -- Parent integrity has been violated
95     --
96     pay_bdt_shd.constraint_error
97       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98   When hr_api.unique_integrity_violated Then
99     -- Unique integrity has been violated
100     --
101     pay_bdt_shd.constraint_error
102       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103   When Others Then
104     --
105     Raise;
106 End insert_dml;
107 --
108 -- ----------------------------------------------------------------------------
109 -- |------------------------------< pre_insert >------------------------------|
110 -- ----------------------------------------------------------------------------
111 -- {Start Of Comments}
112 --
113 -- Description:
114 --   This private procedure contains any processing which is required before
115 --   the insert dml. Presently, if the entity has a corresponding primary
116 --   key which is maintained by an associating sequence, the primary key for
117 --   the entity will be populated with the next sequence value in
118 --   preparation for the insert dml.
119 --
120 -- Prerequisites:
121 --   This is an internal procedure which is called from the ins procedure.
122 --
123 -- In Parameters:
124 --   A Pl/Sql record structre.
125 --
126 -- Post Success:
127 --   Processing continues.
128 --
129 -- Post Failure:
130 --   If an error has occurred, an error message and exception will be raised
131 --   but not handled.
132 --
133 -- Developer Implementation Notes:
134 --   Any pre-processing required before the insert dml is issued should be
135 --   coded within this procedure. As stated above, a good example is the
136 --   generation of a primary key number via a corresponding sequence.
137 --   It is important to note that any 3rd party maintenance should be reviewed
138 --   before placing in this procedure.
139 --
140 -- Access Status:
141 --   Internal Row Handler Use Only.
142 --
143 -- {End Of Comments}
144 -- ----------------------------------------------------------------------------
145 Procedure pre_insert
146   (p_rec                          in out nocopy pay_bdt_shd.g_rec_type
147   ,p_balance_dimension_id         in number
148   ) is
149 --
150   l_proc  varchar2(72) := g_package||'pre_insert';
151 --
152 Begin
153   hr_utility.set_location('Entering:'||l_proc, 5);
154   --
155   p_rec.balance_dimension_id             := p_balance_dimension_id;
156   --
157   hr_utility.set_location(' Leaving:'||l_proc, 10);
158 End pre_insert;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------------< post_insert >------------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 --   This private procedure contains any processing which is required after
167 --   the insert dml.
168 --
169 -- Prerequisites:
170 --   This is an internal procedure which is called from the ins procedure.
171 --
172 -- In Parameters:
173 --   A Pl/Sql record structre.
174 --
175 -- Post Success:
176 --   Processing continues.
177 --
178 -- Post Failure:
179 --   If an error has occurred, an error message and exception will be raised
180 --   but not handled.
181 --
182 -- Developer Implementation Notes:
183 --   Any post-processing required after the insert dml is issued should be
184 --   coded within this procedure. It is important to note that any 3rd party
185 --   maintenance should be reviewed before placing in this procedure.
186 --
187 -- Access Status:
188 --   Internal Row Handler Use Only.
189 --
190 -- {End Of Comments}
191 -- ----------------------------------------------------------------------------
192 Procedure post_insert
193   (p_rec                          in pay_bdt_shd.g_rec_type
194   ) is
195 --
196   l_proc  varchar2(72) := g_package||'post_insert';
197 --
198 Begin
199   hr_utility.set_location('Entering:'||l_proc, 5);
200   begin
201     --
202     pay_bdt_rki.after_insert
203       (p_balance_dimension_id
204       => p_rec.balance_dimension_id
205       ,p_language
206       => p_rec.language
207       ,p_source_lang
208       => p_rec.source_lang
209       ,p_dimension_name
210       => p_rec.dimension_name
211       ,p_database_item_suffix
212       => p_rec.database_item_suffix
213       ,p_description
214       => p_rec.description
215       );
216     --
217   exception
218     --
219     when hr_api.cannot_find_prog_unit then
220       --
221       hr_api.cannot_find_prog_unit_error
222         (p_module_name => 'PAY_BALANCE_DIMENSIONS_TL'
223         ,p_hook_type   => 'AI');
224       --
225   end;
226   --
227   hr_utility.set_location(' Leaving:'||l_proc, 10);
228 End post_insert;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |---------------------------------< ins >----------------------------------|
232 -- ----------------------------------------------------------------------------
233 Procedure ins
234   (p_rec                          in out nocopy pay_bdt_shd.g_rec_type
235   ,p_balance_dimension_id         in number
236   ) is
237 --
238   l_proc  varchar2(72) := g_package||'ins';
239 --
240 Begin
241   hr_utility.set_location('Entering:'||l_proc, 5);
242   --
243   -- Call the supporting insert validate operations
244   --
245   pay_bdt_bus.insert_validate
246      (p_rec
247      );
248   --
249   -- Call to raise any errors on multi-message list
250   hr_multi_message.end_validation_set;
251   --
252   -- Call the supporting pre-insert operation
253   --
254   pay_bdt_ins.pre_insert
255     (p_rec                         => p_rec
256     ,p_balance_dimension_id        => p_balance_dimension_id
257     );
258   --
259   -- Insert the row
260   --
261   pay_bdt_ins.insert_dml(p_rec);
262   --
263   -- Call the supporting post-insert operation
264   --
265   --pay_bdt_ins.post_insert(p_rec);
266   --
267   -- Call to raise any errors on multi-message list
268   hr_multi_message.end_validation_set;
269   --
270   hr_utility.set_location('Leaving:'||l_proc, 20);
271 end ins;
272 --
273 -- ----------------------------------------------------------------------------
274 -- |---------------------------------< ins >----------------------------------|
275 -- ----------------------------------------------------------------------------
276 Procedure ins
277   (p_balance_dimension_id           in     number
278   ,p_language                       in     varchar2
279   ,p_source_lang                    in     varchar2
280   ,p_dimension_name                 in     varchar2
281   ,p_database_item_suffix           in     varchar2
282   ,p_description                    in     varchar2
283   ) is
284 --
285   l_rec   pay_bdt_shd.g_rec_type;
286   l_proc  varchar2(72) := g_package||'ins';
287 --
288 Begin
289   hr_utility.set_location('Entering:'||l_proc, 5);
290   --
291   -- Call conversion function to turn arguments into the
292   -- p_rec structure.
293   --
294   l_rec :=
295   pay_bdt_shd.convert_args
296     (null
297     ,p_language
298     ,p_source_lang
299     ,p_dimension_name
300     ,p_database_item_suffix
301     ,p_description
302     );
303   --
304   -- Having converted the arguments into the pay_bdt_rec
305   -- plsql record structure we call the corresponding record business process.
306   --
307   pay_bdt_ins.ins
308      (p_rec                         => l_rec
309      ,p_balance_dimension_id        => p_balance_dimension_id
310      );
311   --
312   -- As the primary key argument(s)
313   -- are specified as an OUT's we must set these values.
314   --
315   --
316   --
317   hr_utility.set_location(' Leaving:'||l_proc, 10);
318 End ins;
319 --
320 -- ----------------------------------------------------------------------------
321 -- |------------------------------< ins_tl >----------------------------------|
322 -- ----------------------------------------------------------------------------
323 Procedure ins_tl
324   (p_language_code               in varchar2
325   ,p_balance_dimension_id         in number
326   ,p_dimension_name               in varchar2
327   ,p_database_item_suffix         in varchar2
328   ,p_description                  in varchar2 default null
329   ) is
330   --
331   -- Cursor to obtain the list of base and installed languages
332   --
333   cursor csr_ins_langs is
334     select l.language_code
335       from fnd_languages l
336      where l.installed_flag in ('I','B')
337        and not exists (select null
338                          from pay_balance_dimensions_tl bdt
339                         where bdt.balance_dimension_id = p_balance_dimension_id
340                           and bdt.language = l.language_code);
341   --
342   l_proc  varchar2(72)  := g_package || 'ins_tl';
343   --
344 Begin
345   hr_utility.set_location('Entering:'||l_proc,10);
346   --
347   -- Insert a row for the base language and every installed language.
348   --
349   for l_lang in csr_ins_langs loop
350     pay_bdt_ins.ins
351       (p_balance_dimension_id        => p_balance_dimension_id
352       ,p_language                    => l_lang.language_code
353       ,p_source_lang                 => p_language_code
354       ,p_dimension_name              => p_dimension_name
355       ,p_database_item_suffix        => p_database_item_suffix
356       ,p_description                 => p_description
357       );
358   end loop;
359   --
360   hr_utility.set_location('Leaving:'||l_proc,20);
361 End ins_tl;
362 --
363 end pay_bdt_ins;