DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_CDT_INS

Source


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