DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_AMP_INS

Source


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