DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_AGL_INS

Source


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