DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_EGU_INS

Source


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