DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ORU_INS

Source


1 Package Body hr_oru_ins as
2 /* $Header: hrorurhi.pkb 120.2.12020000.2 2012/09/24 09:57:10 swrajapa ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_oru_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_organization_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_organization_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   hr_oru_ins.g_organization_id_i := p_organization_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 -- ----------------------------------------------------------------------------
32 -- |------------------------------< insert_dml >------------------------------|
33 -- ----------------------------------------------------------------------------
34 -- {Start Of Comments}
35 --
36 -- Description:
37 --   This procedure controls the actual dml insert logic. The processing of
38 --   this procedure are as follows:
39 --   1) Initialise the object_version_number to 1 if the object_version_number
40 --      is defined as an attribute for this entity.
41 --   2) To set and unset the g_api_dml status as required (as we are about to
42 --      perform dml).
43 --   3) To insert the row into the schema.
44 --   4) To trap any constraint violations that may have occurred.
45 --   5) To raise any other errors.
46 --
47 -- Prerequisites:
48 --   This is an internal private procedure which must be called from the ins
49 --   procedure and must have all mandatory attributes set (except the
50 --   object_version_number which is initialised within this procedure).
51 --
52 -- In Parameters:
53 --   A Pl/Sql record structre.
54 --
55 -- Post Success:
56 --   The specified row will be inserted into the schema.
57 --
58 -- Post Failure:
59 --   On the insert dml failure it is important to note that we always reset the
60 --   g_api_dml status to false.
61 --   If a check, unique or parent integrity constraint violation is raised the
62 --   constraint_error procedure will be called.
63 --   If any other error is reported, the error will be raised after the
64 --   g_api_dml status is reset.
65 --
66 -- Developer Implementation Notes:
67 --   None.
68 --
69 -- Access Status:
70 --   Internal Row Handler Use Only.
71 --
72 -- {End Of Comments}
73 -- ----------------------------------------------------------------------------
74 Procedure insert_dml
75   (p_rec in out nocopy hr_oru_shd.g_rec_type
76   ) is
77 --
78   l_proc  varchar2(72) := g_package||'insert_dml';
79 --
80 Begin
81   hr_utility.set_location('Entering:'||l_proc, 5);
82   p_rec.object_version_number := 1;  -- Initialise the object version
83   --
84   hr_oru_shd.g_api_dml := true;  -- Set the api dml status
85   --
86   -- Insert the row into: hr_all_organization_units
87   --
88   insert into hr_all_organization_units
89       (organization_id
90       ,business_group_id
91       ,cost_allocation_keyflex_id
92       ,location_id
93       ,soft_coding_keyflex_id
94       ,date_from
95       ,name
96       ,comments
97       ,date_to
98       ,internal_external_flag
99       ,internal_address_line
100       ,type
101       ,attribute_category
102       ,attribute1
103       ,attribute2
104       ,attribute3
105       ,attribute4
106       ,attribute5
107       ,attribute6
108       ,attribute7
109       ,attribute8
110       ,attribute9
111       ,attribute10
112       ,attribute11
113       ,attribute12
114       ,attribute13
115       ,attribute14
116       ,attribute15
117       ,attribute16
118       ,attribute17
119       ,attribute18
120       ,attribute19
121       ,attribute20
122       --Enhancement 4040086
123       ,attribute21
124       ,attribute22
125       ,attribute23
126       ,attribute24
127       ,attribute25
128       ,attribute26
129       ,attribute27
130       ,attribute28
131       ,attribute29
132       ,attribute30
133       --End Enhancement 4040086
134       ,object_version_number
135       )
136   Values
137     (p_rec.organization_id
138     ,p_rec.business_group_id
139     ,p_rec.cost_allocation_keyflex_id
140     ,p_rec.location_id
141     ,p_rec.soft_coding_keyflex_id
142     ,p_rec.date_from
143     ,p_rec.name
144     ,p_rec.comments
145     ,p_rec.date_to
146     ,p_rec.internal_external_flag
147     ,p_rec.internal_address_line
148     ,p_rec.type
149     ,p_rec.attribute_category
150     ,p_rec.attribute1
151     ,p_rec.attribute2
152     ,p_rec.attribute3
153     ,p_rec.attribute4
154     ,p_rec.attribute5
155     ,p_rec.attribute6
156     ,p_rec.attribute7
157     ,p_rec.attribute8
158     ,p_rec.attribute9
159     ,p_rec.attribute10
160     ,p_rec.attribute11
161     ,p_rec.attribute12
162     ,p_rec.attribute13
163     ,p_rec.attribute14
164     ,p_rec.attribute15
165     ,p_rec.attribute16
166     ,p_rec.attribute17
167     ,p_rec.attribute18
168     ,p_rec.attribute19
169     ,p_rec.attribute20
170     --Enhancement 4040086
171     ,p_rec.attribute21
172     ,p_rec.attribute22
173     ,p_rec.attribute23
174     ,p_rec.attribute24
175     ,p_rec.attribute25
176     ,p_rec.attribute26
177     ,p_rec.attribute27
178     ,p_rec.attribute28
179     ,p_rec.attribute29
180     ,p_rec.attribute30
181     --End Enhancement 4040086
182     ,p_rec.object_version_number
183     );
184   --
185   hr_oru_shd.g_api_dml := false;   -- Unset the api dml status
186   --
187   hr_utility.set_location(' Leaving:'||l_proc, 10);
188 Exception
189   When hr_api.check_integrity_violated Then
190     -- A check constraint has been violated
191     hr_oru_shd.g_api_dml := false;   -- Unset the api dml status
192     hr_oru_shd.constraint_error
193       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
194   When hr_api.parent_integrity_violated Then
195     -- Parent integrity has been violated
196     hr_oru_shd.g_api_dml := false;   -- Unset the api dml status
197     hr_oru_shd.constraint_error
198       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
199   When hr_api.unique_integrity_violated Then
200     -- Unique integrity has been violated
201     hr_oru_shd.g_api_dml := false;   -- Unset the api dml status
202     hr_oru_shd.constraint_error
203       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
204   When Others Then
205     hr_oru_shd.g_api_dml := false;   -- Unset the api dml status
206     Raise;
207 End insert_dml;
208 --
209 -- ----------------------------------------------------------------------------
210 -- |------------------------------< pre_insert >------------------------------|
211 -- ----------------------------------------------------------------------------
212 -- {Start Of Comments}
213 --
214 -- Description:
215 --   This private procedure contains any processing which is required before
216 --   the insert dml. Presently, if the entity has a corresponding primary
217 --   key which is maintained by an associating sequence, the primary key for
218 --   the entity will be populated with the next sequence value in
219 --   preparation for the insert dml.
220 --
221 -- Prerequisites:
222 --   This is an internal procedure which is called from the ins procedure.
223 --
224 -- In Parameters:
225 --   A Pl/Sql record structre.
226 --
227 -- Post Success:
228 --   Processing continues.
229 --
230 -- Post Failure:
231 --   If an error has occurred, an error message and exception will be raised
232 --   but not handled.
233 --
234 -- Developer Implementation Notes:
235 --   Any pre-processing required before the insert dml is issued should be
236 --   coded within this procedure. As stated above, a good example is the
237 --   generation of a primary key number via a corresponding sequence.
238 --   It is important to note that any 3rd party maintenance should be reviewed
239 --   before placing in this procedure.
240 --
241 -- Access Status:
242 --   Internal Row Handler Use Only.
243 --
244 -- {End Of Comments}
245 -- ----------------------------------------------------------------------------
246 Procedure pre_insert
247   (p_rec  in out nocopy hr_oru_shd.g_rec_type
248   ) is
249 --
250   l_proc  varchar2(72) := g_package||'pre_insert';
251 --
252   Cursor C_Sel1 is select hr_organization_units_s.nextval from sys.dual;
253 --
254 Begin
255   hr_utility.set_location('Entering:'||l_proc, 5);
256   --
257   --
258   -- Select the next sequence number
259   --
260   Open C_Sel1;
261   Fetch C_Sel1 Into p_rec.organization_id;
262   Close C_Sel1;
263   --
264   hr_utility.set_location(' Leaving:'||l_proc, 10);
265 End pre_insert;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |-----------------------------< post_insert >------------------------------|
269 -- ----------------------------------------------------------------------------
270 -- {Start Of Comments}
271 --
272 -- Description:
273 --   This private procedure contains any processing which is required after the
274 --   insert dml.
275 --
276 -- Prerequisites:
277 --   This is an internal procedure which is called from the ins procedure.
278 --
279 -- In Parameters:
280 --   A Pl/Sql record structre.
281 --
282 -- Post Success:
283 --   Processing continues.
284 --
285 -- Post Failure:
286 --   If an error has occurred, an error message and exception will be raised
287 --   but not handled.
288 --
289 -- Developer Implementation Notes:
290 --   Any post-processing required after the insert dml is issued should be
291 --   coded within this procedure. It is important to note that any 3rd party
292 --   maintenance should be reviewed before placing in this procedure.
293 --
294 -- Access Status:
295 --   Internal Row Handler Use Only.
296 --
297 -- {End Of Comments}
298 -- ----------------------------------------------------------------------------
299 Procedure post_insert
300   (p_effective_date               in date
301   ,p_rec                          in hr_oru_shd.g_rec_type
302   ) is
303 --
304   l_proc  varchar2(72) := g_package||'post_insert';
305 --
306 Begin
307   hr_utility.set_location('Entering:'||l_proc, 5);
308   begin
309     --
310     hr_oru_rki.after_insert
311       (p_effective_date              => p_effective_date
312       ,p_organization_id
313       => p_rec.organization_id
314       ,p_business_group_id
315       => p_rec.business_group_id
316       ,p_cost_allocation_keyflex_id
317       => p_rec.cost_allocation_keyflex_id
318       ,p_location_id
319       => p_rec.location_id
320       ,p_soft_coding_keyflex_id
321       => p_rec.soft_coding_keyflex_id
322       ,p_date_from
323       => p_rec.date_from
324       ,p_name
325       => p_rec.name
326       ,p_comments
327       => p_rec.comments
328       ,p_date_to
329       => p_rec.date_to
330       ,p_internal_external_flag
331       => p_rec.internal_external_flag
332       ,p_internal_address_line
333       => p_rec.internal_address_line
334       ,p_type
335       => p_rec.type
336       ,p_attribute_category
337       => p_rec.attribute_category
338       ,p_attribute1
339       => p_rec.attribute1
340       ,p_attribute2
341       => p_rec.attribute2
342       ,p_attribute3
343       => p_rec.attribute3
344       ,p_attribute4
345       => p_rec.attribute4
346       ,p_attribute5
347       => p_rec.attribute5
348       ,p_attribute6
349       => p_rec.attribute6
350       ,p_attribute7
351       => p_rec.attribute7
352       ,p_attribute8
353       => p_rec.attribute8
354       ,p_attribute9
355       => p_rec.attribute9
356       ,p_attribute10
357       => p_rec.attribute10
358       ,p_attribute11
359       => p_rec.attribute11
360       ,p_attribute12
361       => p_rec.attribute12
362       ,p_attribute13
363       => p_rec.attribute13
364       ,p_attribute14
365       => p_rec.attribute14
366       ,p_attribute15
367       => p_rec.attribute15
368       ,p_attribute16
369       => p_rec.attribute16
370       ,p_attribute17
371       => p_rec.attribute17
372       ,p_attribute18
373       => p_rec.attribute18
374       ,p_attribute19
375       => p_rec.attribute19
376       ,p_attribute20
377       => p_rec.attribute20
378       --Enhancement 4040086
379       ,p_attribute21
380       => p_rec.attribute21
381       ,p_attribute22
382       => p_rec.attribute22
383       ,p_attribute23
384       => p_rec.attribute23
385       ,p_attribute24
386       => p_rec.attribute24
387       ,p_attribute25
388       => p_rec.attribute25
389       ,p_attribute26
390       => p_rec.attribute26
391       ,p_attribute27
392       => p_rec.attribute27
393       ,p_attribute28
394       => p_rec.attribute28
395       ,p_attribute29
396       => p_rec.attribute29
397       ,p_attribute30
398       => p_rec.attribute30
399       -- End Enhancement 4040086
400       ,p_object_version_number
401       => p_rec.object_version_number
402       );
403     --
404   exception
405     --
406     when hr_api.cannot_find_prog_unit then
407       --
408       hr_api.cannot_find_prog_unit_error
409         (p_module_name => 'HR_ALL_ORGANIZATION_UNITS'
410         ,p_hook_type   => 'AI');
411       --
412   end;
413   --
414   hr_utility.set_location(' Leaving:'||l_proc, 10);
415 End post_insert;
416 --
417 -- ----------------------------------------------------------------------------
418 -- |---------------------------------< ins >----------------------------------|
419 -- ----------------------------------------------------------------------------
420 Procedure ins
421   (p_effective_date               in date
422   ,p_rec                          in out nocopy hr_oru_shd.g_rec_type
423   ,p_duplicate_org_warning        out nocopy boolean
424   ) is
425 --
426 -- Fix 3565334
427 -- Added cursor csr_sec_profile and variables
428   cursor csr_sec_profile(p_security_profile_id in number) is
429     select view_all_organizations_flag
430     from  per_security_profiles
431     where  security_profile_id = p_security_profile_id;
432   l_security_profile_id   per_security_profiles.security_profile_id%type;
433   l_view_all_orgs         per_security_profiles.view_all_organizations_flag%type;
434 -- End Fix 3565334
435 --
436   l_proc  varchar2(72) := g_package||'ins';
437 --
438 Begin
439   hr_utility.set_location('Entering:'||l_proc, 5);
440   --
441   -- Call the supporting insert validate operations
442   --
443   hr_oru_bus.insert_validate
444      (p_effective_date
445      ,p_rec
446      ,p_duplicate_org_warning
447      );
448   --
449   -- Call the supporting pre-insert operation
450   --
451   hr_oru_ins.pre_insert(p_rec);
452   --
453   -- Insert the row
454   --
455   hr_oru_ins.insert_dml(p_rec);
456   --
457   -- Call the supporting post-insert operation
458   --
459   hr_oru_ins.post_insert
460      (p_effective_date
461      ,p_rec
462      );
463   --
464   -- Fix 3565334
465   l_security_profile_id := fnd_profile.value('PER_SECURITY_PROFILE_ID');
466   open csr_sec_profile( l_security_profile_id );
467   fetch csr_sec_profile into l_view_all_orgs;
468   close csr_sec_profile;
469   if l_view_all_orgs = 'N' then
470     insert into per_organization_list
471       (security_profile_id
472       ,organization_id)
473     values
474       (l_security_profile_id
475       ,p_rec.organization_id);
476   end if;
477   -- End Fix 3565334
478   --
479   hr_utility.set_location('Leaving:'||l_proc, 20);
480 end ins;
481 --
482 -- ----------------------------------------------------------------------------
483 -- |---------------------------------< ins >----------------------------------|
484 -- ----------------------------------------------------------------------------
485 Procedure ins
486   (p_effective_date               in     date
487   ,p_business_group_id              in     number
488   ,p_date_from                      in     date
489   ,p_name                           in     varchar2
490   ,p_cost_allocation_keyflex_id     in     number   default null
491   ,p_location_id                    in     number   default null
492   ,p_soft_coding_keyflex_id         in     number   default null
493   ,p_date_to                        in     date     default null
494   ,p_internal_external_flag         in     varchar2 default null
495   ,p_internal_address_line          in     varchar2 default null
496   ,p_type                           in     varchar2 default null
497   ,p_comments                       in     varchar2 default null
498   ,p_attribute_category             in     varchar2 default null
499   ,p_attribute1                     in     varchar2 default null
500   ,p_attribute2                     in     varchar2 default null
501   ,p_attribute3                     in     varchar2 default null
502   ,p_attribute4                     in     varchar2 default null
503   ,p_attribute5                     in     varchar2 default null
504   ,p_attribute6                     in     varchar2 default null
505   ,p_attribute7                     in     varchar2 default null
506   ,p_attribute8                     in     varchar2 default null
507   ,p_attribute9                     in     varchar2 default null
508   ,p_attribute10                    in     varchar2 default null
509   ,p_attribute11                    in     varchar2 default null
510   ,p_attribute12                    in     varchar2 default null
511   ,p_attribute13                    in     varchar2 default null
512   ,p_attribute14                    in     varchar2 default null
513   ,p_attribute15                    in     varchar2 default null
514   ,p_attribute16                    in     varchar2 default null
515   ,p_attribute17                    in     varchar2 default null
516   ,p_attribute18                    in     varchar2 default null
517   ,p_attribute19                    in     varchar2 default null
518   ,p_attribute20                    in     varchar2 default null
519   --Enhancement 4040086
520   ,p_attribute21                    in     varchar2 default null
521   ,p_attribute22                    in     varchar2 default null
522   ,p_attribute23                    in     varchar2 default null
523   ,p_attribute24                    in     varchar2 default null
524   ,p_attribute25                    in     varchar2 default null
525   ,p_attribute26                    in     varchar2 default null
526   ,p_attribute27                    in     varchar2 default null
527   ,p_attribute28                    in     varchar2 default null
528   ,p_attribute29                    in     varchar2 default null
529   ,p_attribute30                    in     varchar2 default null
530   --End Enhancement 4040086
531   ,p_organization_id                   out nocopy number
532   ,p_object_version_number             out nocopy number
533   ,p_duplicate_org_warning             out nocopy boolean
534   ) is
535 --
536   l_rec    hr_oru_shd.g_rec_type;
537   l_proc  varchar2(72) := g_package||'ins';
538 --
539 Begin
540   hr_utility.set_location('Entering:'||l_proc, 5);
541   --
542   -- Call conversion function to turn arguments into the
543   -- p_rec structure.
544   --
545   l_rec :=
546   hr_oru_shd.convert_args
547     (null
548     ,p_business_group_id
549     ,p_cost_allocation_keyflex_id
550     ,p_location_id
551     ,p_soft_coding_keyflex_id
552     ,p_date_from
553     ,p_name
554     ,p_comments
555     ,p_date_to
556     ,p_internal_external_flag
557     ,p_internal_address_line
558     ,p_type
559     ,null
560     ,null
561     ,null
562     ,null
563     ,p_attribute_category
564     ,p_attribute1
565     ,p_attribute2
566     ,p_attribute3
567     ,p_attribute4
568     ,p_attribute5
569     ,p_attribute6
570     ,p_attribute7
571     ,p_attribute8
572     ,p_attribute9
573     ,p_attribute10
574     ,p_attribute11
575     ,p_attribute12
576     ,p_attribute13
577     ,p_attribute14
578     ,p_attribute15
579     ,p_attribute16
580     ,p_attribute17
581     ,p_attribute18
582     ,p_attribute19
583     ,p_attribute20
584     --Enhancement 4040086
585     ,p_attribute21
586     ,p_attribute22
587     ,p_attribute23
588     ,p_attribute24
589     ,p_attribute25
590     ,p_attribute26
591     ,p_attribute27
592     ,p_attribute28
593     ,p_attribute29
594     ,p_attribute30
595     --End enhancement 4040086
596     ,null
597     );
598   --
599   -- Having converted the arguments into the hr_oru_rec
600   -- plsql record structure we call the corresponding record business process.
601   --
602   hr_oru_ins.ins
603      (p_effective_date
604      ,l_rec
605      ,p_duplicate_org_warning
606      );
607   --
608   -- As the primary key argument(s)
609   -- are specified as an OUT's we must set these values.
610   --
611   p_organization_id := l_rec.organization_id;
612   p_object_version_number := l_rec.object_version_number;
613   --
614   hr_utility.set_location(' Leaving:'||l_proc, 10);
615 End ins;
616 --
617 end hr_oru_ins;