DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_AMO_INS

Source


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