DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_IVT_INS

Source


1 Package Body pay_ivt_ins as
2 /* $Header: pyivtrhi.pkb 120.1 2005/10/04 23:01:29 pgongada noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_ivt_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_ivt_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_input_values_f_tl
66   --
67   insert into pay_input_values_f_tl
68       (input_value_id
69       ,name
70       ,language
71       ,source_lang
72       )
73   Values
74     (p_rec.input_value_id
75     ,p_rec.name
76     ,p_rec.language
77     ,p_rec.source_lang
78     );
79   --
80   --
81   --
82   hr_utility.set_location(' Leaving:'||l_proc, 10);
83 Exception
84   When hr_api.check_integrity_violated Then
85     -- A check constraint has been violated
86     --
87     pay_ivt_shd.constraint_error
88       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
89   When hr_api.parent_integrity_violated Then
90     -- Parent integrity has been violated
91     --
92     pay_ivt_shd.constraint_error
93       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94   When hr_api.unique_integrity_violated Then
95     -- Unique integrity has been violated
96     --
97     pay_ivt_shd.constraint_error
98       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99   When Others Then
100     --
101     Raise;
102 End insert_dml;
103 --
104 -- ----------------------------------------------------------------------------
105 -- |------------------------------< pre_insert >------------------------------|
106 -- ----------------------------------------------------------------------------
107 -- {Start Of Comments}
108 --
109 -- Description:
110 --   This private procedure contains any processing which is required before
111 --   the insert dml. Presently, if the entity has a corresponding primary
112 --   key which is maintained by an associating sequence, the primary key for
113 --   the entity will be populated with the next sequence value in
114 --   preparation for the insert dml.
115 --
116 -- Prerequisites:
117 --   This is an internal procedure which is called from the ins procedure.
118 --
119 -- In Parameters:
120 --   A Pl/Sql record structre.
121 --
122 -- Post Success:
123 --   Processing continues.
124 --
125 -- Post Failure:
126 --   If an error has occurred, an error message and exception will be raised
127 --   but not handled.
128 --
129 -- Developer Implementation Notes:
130 --   Any pre-processing required before the insert dml is issued should be
131 --   coded within this procedure. As stated above, a good example is the
132 --   generation of a primary key number via a corresponding sequence.
133 --   It is important to note that any 3rd party maintenance should be reviewed
134 --   before placing in this procedure.
135 --
136 -- Access Status:
137 --   Internal Row Handler Use Only.
138 --
139 -- {End Of Comments}
140 -- ----------------------------------------------------------------------------
141 Procedure pre_insert
142   (p_rec                          in out nocopy  pay_ivt_shd.g_rec_type
143   ,p_input_value_id               in number
144   ) is
145 --
146   l_proc  varchar2(72) := g_package||'pre_insert';
147 --
148 Begin
149   hr_utility.set_location('Entering:'||l_proc, 5);
150   --
151   p_rec.input_value_id                   := p_input_value_id;
152   --
153   hr_utility.set_location(' Leaving:'||l_proc, 10);
154 End pre_insert;
155 --
156 -- ----------------------------------------------------------------------------
157 -- |-----------------------------< post_insert >------------------------------|
158 -- ----------------------------------------------------------------------------
159 -- {Start Of Comments}
160 --
161 -- Description:
162 --   This private procedure contains any processing which is required after
163 --   the insert dml.
164 --
165 -- Prerequisites:
166 --   This is an internal procedure which is called from the ins procedure.
167 --
168 -- In Parameters:
169 --   A Pl/Sql record structre.
170 --
171 -- Post Success:
172 --   Processing continues.
173 --
174 -- Post Failure:
175 --   If an error has occurred, an error message and exception will be raised
176 --   but not handled.
177 --
178 -- Developer Implementation Notes:
179 --   Any post-processing required after the insert dml is issued should be
180 --   coded within this procedure. It is important to note that any 3rd party
181 --   maintenance should be reviewed before placing in this procedure.
182 --
183 -- Access Status:
184 --   Internal Row Handler Use Only.
185 --
186 -- {End Of Comments}
187 -- ----------------------------------------------------------------------------
188 Procedure post_insert
189   (p_rec                          in pay_ivt_shd.g_rec_type
190   ) is
191 --
192   l_proc  varchar2(72) := g_package||'post_insert';
193 --
194 Begin
195   hr_utility.set_location('Entering:'||l_proc, 5);
196   begin
197     --
198     pay_ivt_rki.after_insert
199       (p_input_value_id
200       => p_rec.input_value_id
201       ,p_name
202       => p_rec.name
203       ,p_language
204       => p_rec.language
205       ,p_source_lang
206       => p_rec.source_lang
207       );
208     --
209   exception
210     --
211     when hr_api.cannot_find_prog_unit then
212       --
213       hr_api.cannot_find_prog_unit_error
214         (p_module_name => 'PAY_INPUT_VALUES_F_TL'
215         ,p_hook_type   => 'AI');
216       --
217   end;
218   --
219   hr_utility.set_location(' Leaving:'||l_proc, 10);
220 End post_insert;
221 --
222 -- ----------------------------------------------------------------------------
223 -- |---------------------------------< ins >----------------------------------|
224 -- ----------------------------------------------------------------------------
225 Procedure ins
226   (p_rec                          in out nocopy  pay_ivt_shd.g_rec_type
227   ,p_input_value_id               in number
228   ) is
229 --
230   l_proc  varchar2(72) := g_package||'ins';
231 --
232 Begin
233   hr_utility.set_location('Entering:'||l_proc, 5);
234   --
235   -- Call the supporting insert validate operations
236   --
237   pay_ivt_bus.insert_validate
238      (p_rec
239      );
240   --
241   -- Call to raise any errors on multi-message list
242   hr_multi_message.end_validation_set;
243   --
244   -- Call the supporting pre-insert operation
245   --
246   pay_ivt_ins.pre_insert
247     (p_rec                         => p_rec
248     ,p_input_value_id              => p_input_value_id
249     );
250   --
251   -- Insert the row
252   --
253   pay_ivt_ins.insert_dml(p_rec);
254   --
255   -- Call the supporting post-insert operation
256   --
257   pay_ivt_ins.post_insert
258      (p_rec
259      );
260   --
261   -- Call to raise any errors on multi-message list
262   hr_multi_message.end_validation_set;
263   --
264   hr_utility.set_location('Leaving:'||l_proc, 20);
265 end ins;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |---------------------------------< ins >----------------------------------|
269 -- ----------------------------------------------------------------------------
270 Procedure ins
271   (p_input_value_id                 in     number
272   ,p_name                           in     varchar2
273   ,p_language                       in     varchar2
274   ,p_source_lang                    in     varchar2
275   ) is
276 --
277   l_rec   pay_ivt_shd.g_rec_type;
278   l_proc  varchar2(72) := g_package||'ins';
279 --
280 Begin
281   hr_utility.set_location('Entering:'||l_proc, 5);
282   --
283   -- Call conversion function to turn arguments into the
284   -- p_rec structure.
285   --
286   l_rec :=
287   pay_ivt_shd.convert_args
288     (null
289     ,p_name
290     ,p_language
291     ,p_source_lang
292     );
293   --
294   -- Having converted the arguments into the pay_ivt_rec
295   -- plsql record structure we call the corresponding record business process.
296   --
297   pay_ivt_ins.ins
298      (p_rec                         => l_rec
299      ,p_input_value_id              => p_input_value_id
300      );
301   --
302   -- As the primary key argument(s)
303   -- are specified as an OUT's we must set these values.
304   --
305   --
306   --
307   hr_utility.set_location(' Leaving:'||l_proc, 10);
308 End ins;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |------------------------------< ins_tl >----------------------------------|
312 -- ----------------------------------------------------------------------------
313 Procedure ins_tl
314   (p_language_code               in varchar2
315   ,p_input_value_id               in number
316   ,p_name                         in varchar2
317   ) is
318   --
319   -- Cursor to obtain the list of base and installed languages
320   --
321   cursor csr_ins_langs is
322     select l.language_code
323       from fnd_languages l
324      where l.installed_flag in ('I','B')
325        and not exists (select null
326                          from pay_input_values_f_tl ivt
327                         where ivt.input_value_id = p_input_value_id
328                           and ivt.language = l.language_code);
329   --
330   l_proc  varchar2(72)  := g_package || 'ins_tl';
331   --
332   l_is_pay_value boolean := FALSE;
333   l_name  pay_input_values_f_tl.name%type := p_name;
334   --
335 Begin
336   hr_utility.set_location('Entering:'||l_proc,10);
337   --
338   -- Find out if the input value is the Pay Value
339   --
340   if (upper(p_name) = 'PAY VALUE' OR
341       p_name = hr_general.pay_value) then
342     l_is_pay_value := TRUE;
343   end if;
344   --
345   -- Insert a row for the base language and every installed language.
346   --
347   for l_lang in csr_ins_langs loop
348 
349     if l_is_pay_value then
350       begin
351         select meaning
352         into l_name
353         from fnd_lookup_values
354         where lookup_type = 'NAME_TRANSLATIONS'
355         and   lookup_code = 'PAY VALUE'
356         and   language    = l_lang.language_code;
357       exception
358         when no_data_found then
359           l_name := p_name;
360       end;
361     end if;
362 
363     pay_ivt_ins.ins
364       (p_input_value_id              => p_input_value_id
365       ,p_language                    => l_lang.language_code
366       ,p_source_lang                 => p_language_code
367       ,p_name                        => l_name
368       );
369   end loop;
370   --
371   hr_utility.set_location('Leaving:'||l_proc,20);
372 End ins_tl;
373 --
374 end pay_ivt_ins;