DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_ETT_INS

Source


1 Package Body pay_ett_ins as
2 /* $Header: pyettrhi.pkb 120.1 2005/10/04 22:03:25 pgongada noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_ett_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_ett_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_element_types_f_tl
66   --
67   insert into pay_element_types_f_tl
68       (element_type_id
69       ,element_name
70       ,reporting_name
71       ,description
72       ,language
73       ,source_lang
74       )
75   Values
76     (p_rec.element_type_id
77     ,p_rec.element_name
78     ,p_rec.reporting_name
79     ,p_rec.description
80     ,p_rec.language
81     ,p_rec.source_lang
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_ett_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_ett_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_ett_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_ett_shd.g_rec_type
147   ,p_element_type_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.element_type_id                  := p_element_type_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_ett_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_ett_rki.after_insert
203       (p_element_type_id
204       => p_rec.element_type_id
205       ,p_element_name
206       => p_rec.element_name
207       ,p_reporting_name
208       => p_rec.reporting_name
209       ,p_description
210       => p_rec.description
211       ,p_language
212       => p_rec.language
213       ,p_source_lang
214       => p_rec.source_lang
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_ELEMENT_TYPES_F_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_ett_shd.g_rec_type
235   ,p_element_type_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_ett_bus.insert_validate
246      (p_rec
247      ,p_element_type_id
248      );
249   --
250   -- Call to raise any errors on multi-message list
251   hr_multi_message.end_validation_set;
252   --
253   -- Call the supporting pre-insert operation
254   --
255   pay_ett_ins.pre_insert
256     (p_rec                         => p_rec
257     ,p_element_type_id             => p_element_type_id
258     );
259   --
260   -- Insert the row
261   --
262   pay_ett_ins.insert_dml(p_rec);
263   --
264   -- Call the supporting post-insert operation
265   --
266   pay_ett_ins.post_insert
267      (p_rec
268      );
269   --
270   -- Call to raise any errors on multi-message list
271   hr_multi_message.end_validation_set;
272   --
273   hr_utility.set_location('Leaving:'||l_proc, 20);
274 end ins;
275 --
276 -- ----------------------------------------------------------------------------
277 -- |---------------------------------< ins >----------------------------------|
278 -- ----------------------------------------------------------------------------
279 Procedure ins
280   (p_element_type_id                in     number
281   ,p_element_name                   in     varchar2
282   ,p_language                       in     varchar2
283   ,p_source_lang                    in     varchar2
284   ,p_reporting_name                 in     varchar2
285   ,p_description                    in     varchar2
286   ) is
287 --
288   l_rec   pay_ett_shd.g_rec_type;
289   l_proc  varchar2(72) := g_package||'ins';
290 --
291 Begin
292   hr_utility.set_location('Entering:'||l_proc, 5);
293   --
294   -- Call conversion function to turn arguments into the
295   -- p_rec structure.
296   --
297   l_rec :=
298   pay_ett_shd.convert_args
299     (null
300     ,p_element_name
301     ,p_reporting_name
302     ,p_description
303     ,p_language
304     ,p_source_lang
305     );
306   --
307   -- Having converted the arguments into the pay_ett_rec
308   -- plsql record structure we call the corresponding record business process.
309   --
310   pay_ett_ins.ins
311      (p_rec                         => l_rec
312      ,p_element_type_id             => p_element_type_id
313      );
314   --
315   -- As the primary key argument(s)
316   -- are specified as an OUT's we must set these values.
317   --
318   --
319   --
320   hr_utility.set_location(' Leaving:'||l_proc, 10);
321 End ins;
322 --
323 -- ----------------------------------------------------------------------------
324 -- |------------------------------< ins_tl >----------------------------------|
325 -- ----------------------------------------------------------------------------
326 Procedure ins_tl
327   (p_language_code               in varchar2
328   ,p_element_type_id              in number
329   ,p_element_name                 in varchar2
330   ,p_reporting_name               in varchar2 default null
331   ,p_description                  in varchar2 default null
332   ) is
333   --
334   -- Cursor to obtain the list of base and installed languages
335   --
336   cursor csr_ins_langs is
337     select l.language_code
338       from fnd_languages l
339      where l.installed_flag in ('I','B')
340        and not exists (select null
341                          from pay_element_types_f_tl ett
342                         where ett.element_type_id = p_element_type_id
343                           and ett.language = l.language_code);
344   --
345   l_proc  varchar2(72)  := g_package || 'ins_tl';
346   --
347 Begin
348   hr_utility.set_location('Entering:'||l_proc,10);
349   --
350   -- Insert a row for the base language and every installed language.
351   --
352   for l_lang in csr_ins_langs loop
353     pay_ett_ins.ins
354       (p_element_type_id             => p_element_type_id
355       ,p_language                    => l_lang.language_code
356       ,p_source_lang                 => p_language_code
357       ,p_element_name                => p_element_name
358       ,p_reporting_name              => p_reporting_name
359       ,p_description                 => p_description
360       );
361   end loop;
362   --
363   hr_utility.set_location('Leaving:'||l_proc,20);
364 End ins_tl;
365 --
366 end pay_ett_ins;