DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_AMT_INS

Source


1 Package Body pay_amt_ins as
2 /* $Header: pyamtrhi.pkb 120.0.12000000.1 2007/01/17 15:30: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_type_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_module_type_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_amt_ins.g_module_type_id_i := p_module_type_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_amt_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_amt_shd.g_api_dml := true;  -- Set the api dml status
90   --
91   -- Insert the row into: pay_au_module_types
92   --
93   insert into pay_au_module_types
94       (module_type_id
95       ,name
96       ,enabled_flag
97       ,description
98       ,object_version_number
99       )
100   Values
101     (p_rec.module_type_id
102     ,p_rec.name
103     ,p_rec.enabled_flag
104     ,p_rec.description
105     ,p_rec.object_version_number
106     );
107   --
108   pay_amt_shd.g_api_dml := false;   -- Unset the api dml status
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     pay_amt_shd.g_api_dml := false;   -- Unset the api dml status
115     pay_amt_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     pay_amt_shd.g_api_dml := false;   -- Unset the api dml status
120     pay_amt_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     pay_amt_shd.g_api_dml := false;   -- Unset the api dml status
125     pay_amt_shd.constraint_error
126       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
127   When Others Then
128     pay_amt_shd.g_api_dml := false;   -- Unset the api dml status
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 structure.
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 pay_amt_shd.g_rec_type
171   ) is
172 --
173   Cursor C_Sel1 is select pay_au_module_types_s.nextval from sys.dual;
174 --
175   Cursor C_Sel2 is
176     Select null
177       from pay_au_module_types
178      where module_type_id =
179              pay_amt_ins.g_module_type_id_i;
180 --
181   l_proc   varchar2(72);
182   l_exists varchar2(1);
183 --
184 Begin
185   l_proc := g_package||'pre_insert';
186   --
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   --
189   If (pay_amt_ins.g_module_type_id_i is not null) Then
190     --
191     -- Verify registered primary key values not already in use
192     --
193     Open C_Sel2;
194     Fetch C_Sel2 into l_exists;
195     If C_Sel2%found Then
196        Close C_Sel2;
197        --
198        -- The primary key values are already in use.
199        --
200        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
201        fnd_message.set_token('TABLE_NAME','pay_au_module_types');
202        fnd_message.raise_error;
203     End If;
204     Close C_Sel2;
205     --
206     -- Use registered key values and clear globals
207     --
208     p_rec.module_type_id :=
209       pay_amt_ins.g_module_type_id_i;
210     pay_amt_ins.g_module_type_id_i := null;
211   Else
212     --
213     -- No registerd key values, so select the next sequence number
214     --
215     --
216     -- Select the next sequence number
217     --
218     Open C_Sel1;
219     Fetch C_Sel1 Into p_rec.module_type_id;
220     Close C_Sel1;
221   End If;
222   --
223   hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End pre_insert;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |-----------------------------< post_insert >------------------------------|
228 -- ----------------------------------------------------------------------------
229 -- {Start Of Comments}
230 --
231 -- Description:
232 --   This private procedure contains any processing which is required after
233 --   the insert dml.
234 --
235 -- Prerequisites:
236 --   This is an internal procedure which is called from the ins procedure.
237 --
238 -- In Parameters:
239 --   A Pl/Sql record structre.
240 --
241 -- Post Success:
242 --   Processing continues.
243 --
244 -- Post Failure:
245 --   If an error has occurred, an error message and exception will be raised
246 --   but not handled.
247 --
248 -- Developer Implementation Notes:
249 --   Any post-processing required after the insert dml is issued should be
250 --   coded within this procedure. It is important to note that any 3rd party
251 --   maintenance should be reviewed before placing in this procedure.
252 --
253 -- Access Status:
254 --   Internal Row Handler Use Only.
255 --
256 -- {End Of Comments}
257 -- ----------------------------------------------------------------------------
258 Procedure post_insert
259   (p_rec                          in pay_amt_shd.g_rec_type
260   ) is
261 --
262   l_proc  varchar2(72);
263 --
264 Begin
265   l_proc  := g_package||'post_insert';
266   --
267   hr_utility.set_location('Entering:'||l_proc, 5);
268   --
269   hr_utility.set_location(' Leaving:'||l_proc, 10);
270 End post_insert;
271 --
272 -- ----------------------------------------------------------------------------
273 -- |---------------------------------< ins >----------------------------------|
274 -- ----------------------------------------------------------------------------
275 Procedure ins
276   (p_rec                          in out nocopy pay_amt_shd.g_rec_type
277   ) is
278 --
279   l_proc  varchar2(72);
280 --
281 Begin
282   l_proc := g_package||'ins';
283   --
284   hr_utility.set_location('Entering:'||l_proc, 5);
285   --
286   -- Call the supporting insert validate operations
287   --
288   pay_amt_bus.insert_validate
289      (p_rec
290      );
291   --
292   -- Call to raise any errors on multi-message list
293   hr_multi_message.end_validation_set;
294   --
295   -- Call the supporting pre-insert operation
296   --
297   pay_amt_ins.pre_insert(p_rec);
298   --
299   -- Insert the row
300   --
301   pay_amt_ins.insert_dml(p_rec);
302   --
303   -- Call the supporting post-insert operation
304   --
305   pay_amt_ins.post_insert
306      (p_rec
307      );
308   --
309   -- Call to raise any errors on multi-message list
310   hr_multi_message.end_validation_set;
311   --
312   hr_utility.set_location('Leaving:'||l_proc, 20);
313 end ins;
314 --
315 -- ----------------------------------------------------------------------------
316 -- |---------------------------------< ins >----------------------------------|
317 -- ----------------------------------------------------------------------------
318 Procedure ins
319   (p_name                           in     varchar2
320   ,p_enabled_flag                   in     varchar2
321   ,p_description                    in     varchar2 default null
322   ,p_module_type_id                    out nocopy number
323   ,p_object_version_number             out nocopy number
324   ) is
325 --
326   l_rec   pay_amt_shd.g_rec_type;
327   l_proc  varchar2(72);
328 --
329 Begin
330   l_proc := g_package||'ins';
331   --
332   hr_utility.set_location('Entering:'||l_proc, 5);
333   --
334   -- Call conversion function to turn arguments into the
335   -- p_rec structure.
336   --
337   l_rec :=
338   pay_amt_shd.convert_args
339     (null
340     ,p_name
341     ,p_enabled_flag
342     ,p_description
343     ,null
344     );
345   --
346   -- Having converted the arguments into the pay_amt_rec
347   -- plsql record structure we call the corresponding record business process.
348   --
349   pay_amt_ins.ins
350      (l_rec
351      );
352   --
353   -- As the primary key argument(s)
354   -- are specified as an OUT's we must set these values.
355   --
356   p_module_type_id := l_rec.module_type_id;
357   p_object_version_number := l_rec.object_version_number;
358   --
359   hr_utility.set_location(' Leaving:'||l_proc, 10);
360 End ins;
361 --
362 begin
363   g_package := '  pay_amt_ins.';  -- Global package name
364 end pay_amt_ins;