DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQP_EXR_INS

Source


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