DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_APP_INS

Source


1 Package Body pay_app_ins as
2 /* $Header: pyapprhi.pkb 120.0.12000000.1 2007/01/17 15:36:55 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_process_parameter_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_process_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_app_ins.g_process_parameter_id_i := p_process_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
81   l_proc  varchar2(72);
78   (p_rec in out nocopy pay_app_shd.g_rec_type
79   ) is
80 --
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_app_shd.g_api_dml := true;  -- Set the api dml status
90   --
91   -- Insert the row into: pay_au_process_parameters
92   --
93   insert into pay_au_process_parameters
94       (process_parameter_id
95       ,process_id
96       ,internal_name
97       ,data_type
98       ,enabled_flag
99       ,object_version_number
100       )
101   Values
102     (p_rec.process_parameter_id
103     ,p_rec.process_id
104     ,p_rec.internal_name
105     ,p_rec.data_type
106     ,p_rec.enabled_flag
107     ,p_rec.object_version_number
108     );
109   --
110   pay_app_shd.g_api_dml := false;   -- Unset the api dml status
111   --
112   hr_utility.set_location(' Leaving:'||l_proc, 10);
113 Exception
114   When hr_api.check_integrity_violated Then
115     -- A check constraint has been violated
116     pay_app_shd.g_api_dml := false;   -- Unset the api dml status
117     pay_app_shd.constraint_error
118       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
119   When hr_api.parent_integrity_violated Then
120     -- Parent integrity has been violated
121     pay_app_shd.g_api_dml := false;   -- Unset the api dml status
122     pay_app_shd.constraint_error
123       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
124   When hr_api.unique_integrity_violated Then
125     -- Unique integrity has been violated
126     pay_app_shd.g_api_dml := false;   -- Unset the api dml status
127     pay_app_shd.constraint_error
128       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
129   When Others Then
130     pay_app_shd.g_api_dml := false;   -- Unset the api dml status
131     Raise;
132 End insert_dml;
133 --
134 -- ----------------------------------------------------------------------------
135 -- |------------------------------< pre_insert >------------------------------|
136 -- ----------------------------------------------------------------------------
137 -- {Start Of Comments}
138 --
139 -- Description:
140 --   This private procedure contains any processing which is required before
141 --   the insert dml. Presently, if the entity has a corresponding primary
142 --   key which is maintained by an associating sequence, the primary key for
143 --   the entity will be populated with the next sequence value in
144 --   preparation for the insert dml.
145 --
146 -- Prerequisites:
147 --   This is an internal procedure which is called from the ins procedure.
148 --
149 -- In Parameters:
150 --   A Pl/Sql record structure.
151 --
152 -- Post Success:
153 --   Processing continues.
154 --
155 -- Post Failure:
156 --   If an error has occurred, an error message and exception will be raised
157 --   but not handled.
158 --
159 -- Developer Implementation Notes:
160 --   Any pre-processing required before the insert dml is issued should be
161 --   coded within this procedure. As stated above, a good example is the
162 --   generation of a primary key number via a corresponding sequence.
163 --   It is important to note that any 3rd party maintenance should be reviewed
164 --   before placing in this procedure.
165 --
166 -- Access Status:
167 --   Internal Row Handler Use Only.
168 --
169 -- {End Of Comments}
170 -- ----------------------------------------------------------------------------
171 Procedure pre_insert
172   (p_rec  in out nocopy pay_app_shd.g_rec_type
173   ) is
174 --
175   Cursor C_Sel1 is select pay_au_process_parameters_s.nextval from sys.dual;
176 --
177   Cursor C_Sel2 is
178     Select null
179       from pay_au_process_parameters
180      where process_parameter_id =
181              pay_app_ins.g_process_parameter_id_i;
182 --
183   l_proc   varchar2(72);
184   l_exists varchar2(1);
185 --
186 Begin
187   l_proc := g_package||'pre_insert';
188   --
189   hr_utility.set_location('Entering:'||l_proc, 5);
190   --
191   If (pay_app_ins.g_process_parameter_id_i is not null) Then
192     --
193     -- Verify registered primary key values not already in use
194     --
195     Open C_Sel2;
196     Fetch C_Sel2 into l_exists;
197     If C_Sel2%found Then
198        Close C_Sel2;
199        --
200        -- The primary key values are already in use.
201        --
202        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
203        fnd_message.set_token('TABLE_NAME','pay_au_process_parameters');
204        fnd_message.raise_error;
205     End If;
206     Close C_Sel2;
207     --
208     -- Use registered key values and clear globals
209     --
210     p_rec.process_parameter_id :=
211       pay_app_ins.g_process_parameter_id_i;
212     pay_app_ins.g_process_parameter_id_i := null;
213   Else
214     --
215     -- No registerd key values, so select the next sequence number
216     --
217     --
218     -- Select the next sequence number
219     --
220     Open C_Sel1;
221     Fetch C_Sel1 Into p_rec.process_parameter_id;
222     Close C_Sel1;
223   End If;
224   --
225   hr_utility.set_location(' Leaving:'||l_proc, 10);
226 End pre_insert;
227 --
228 -- ----------------------------------------------------------------------------
232 --
229 -- |-----------------------------< post_insert >------------------------------|
230 -- ----------------------------------------------------------------------------
231 -- {Start Of Comments}
233 -- Description:
234 --   This private procedure contains any processing which is required after
235 --   the insert dml.
236 --
237 -- Prerequisites:
238 --   This is an internal procedure which is called from the ins procedure.
239 --
240 -- In Parameters:
241 --   A Pl/Sql record structre.
242 --
243 -- Post Success:
244 --   Processing continues.
245 --
246 -- Post Failure:
247 --   If an error has occurred, an error message and exception will be raised
248 --   but not handled.
249 --
250 -- Developer Implementation Notes:
251 --   Any post-processing required after the insert dml is issued should be
252 --   coded within this procedure. It is important to note that any 3rd party
253 --   maintenance should be reviewed before placing in this procedure.
254 --
255 -- Access Status:
256 --   Internal Row Handler Use Only.
257 --
258 -- {End Of Comments}
259 -- ----------------------------------------------------------------------------
260 Procedure post_insert
261   (p_rec                          in pay_app_shd.g_rec_type
262   ) is
263 --
264   l_proc  varchar2(72);
265 --
266 Begin
267   l_proc := g_package||'post_insert';
268   --
269   hr_utility.set_location('Entering:'||l_proc, 5);
270   --
271   hr_utility.set_location(' Leaving:'||l_proc, 10);
272 End post_insert;
273 --
274 -- ----------------------------------------------------------------------------
275 -- |---------------------------------< ins >----------------------------------|
276 -- ----------------------------------------------------------------------------
277 Procedure ins
278   (p_rec                          in out nocopy pay_app_shd.g_rec_type
279   ) is
280 --
281   l_proc  varchar2(72);
282 --
283 Begin
284   l_proc := g_package||'ins';
285   --
286   hr_utility.set_location('Entering:'||l_proc, 5);
287   --
288   -- Call the supporting insert validate operations
289   --
290   pay_app_bus.insert_validate
291      (p_rec
292      );
293   --
294   -- Call to raise any errors on multi-message list
295   hr_multi_message.end_validation_set;
296   --
297   -- Call the supporting pre-insert operation
298   --
299   pay_app_ins.pre_insert(p_rec);
300   --
301   -- Insert the row
302   --
303   pay_app_ins.insert_dml(p_rec);
304   --
305   -- Call the supporting post-insert operation
306   --
307   pay_app_ins.post_insert
308      (p_rec
309      );
310   --
311   -- Call to raise any errors on multi-message list
312   hr_multi_message.end_validation_set;
313   --
314   hr_utility.set_location('Leaving:'||l_proc, 20);
315 end ins;
316 --
317 -- ----------------------------------------------------------------------------
318 -- |---------------------------------< ins >----------------------------------|
319 -- ----------------------------------------------------------------------------
320 Procedure ins
321   (p_process_id                     in     number
322   ,p_internal_name                  in     varchar2
323   ,p_data_type                      in     varchar2
324   ,p_enabled_flag                   in     varchar2
325   ,p_process_parameter_id              out nocopy number
326   ,p_object_version_number             out nocopy number
327   ) is
328 --
329   l_rec   pay_app_shd.g_rec_type;
330   l_proc  varchar2(72);
331 --
332 Begin
333   l_proc := g_package||'ins';
334   --
335   hr_utility.set_location('Entering:'||l_proc, 5);
336   --
337   -- Call conversion function to turn arguments into the
338   -- p_rec structure.
339   --
340   l_rec :=
341   pay_app_shd.convert_args
342     (null
343     ,p_process_id
344     ,p_internal_name
345     ,p_data_type
346     ,p_enabled_flag
347     ,null
348     );
349   --
350   -- Having converted the arguments into the pay_app_rec
351   -- plsql record structure we call the corresponding record business process.
352   --
353   pay_app_ins.ins
354      (l_rec
355      );
356   --
357   -- As the primary key argument(s)
358   -- are specified as an OUT's we must set these values.
359   --
360   p_process_parameter_id := l_rec.process_parameter_id;
361   p_object_version_number := l_rec.object_version_number;
362   --
363   hr_utility.set_location(' Leaving:'||l_proc, 10);
364 End ins;
365 --
366 begin
367   g_package  := '  pay_app_ins.';  -- Global package name
368 end pay_app_ins;