DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_CPO_SHD

Source


1 Package Body ben_cpo_shd as
2 /* $Header: becporhi.pkb 115.11 2002/12/13 06:20:48 hmani ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_cpo_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
15   l_proc 	varchar2(72) := g_package||'return_api_dml_status';
16 --
17 Begin
18   hr_utility.set_location('Entering:'||l_proc, 5);
19   --
20   Return (nvl(g_api_dml, false));
21   --
22   hr_utility.set_location(' Leaving:'||l_proc, 10);
23 End return_api_dml_status;
24 --
25 -- ----------------------------------------------------------------------------
26 -- |---------------------------< constraint_error >---------------------------|
27 -- ----------------------------------------------------------------------------
28 Procedure constraint_error
29             (p_constraint_name in all_constraints.constraint_name%TYPE) Is
30 --
31   l_proc 	varchar2(72) := g_package||'constraint_error';
32 --
33 Begin
34   hr_utility.set_location('Entering:'||l_proc, 5);
35   --
36   If (p_constraint_name = 'BEN_POPL_ORG_FK1') Then
37     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
38     hr_utility.set_message_token('PROCEDURE', l_proc);
39     hr_utility.set_message_token('STEP','5');
40     hr_utility.raise_error;
41   ElsIf (p_constraint_name = 'BEN_POPL_ORG_FK2') Then
42     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
43     hr_utility.set_message_token('PROCEDURE', l_proc);
44     hr_utility.set_message_token('STEP','10');
45     hr_utility.raise_error;
46   ElsIf (p_constraint_name = 'BEN_POPL_ORG_PK') Then
47     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
48     hr_utility.set_message_token('PROCEDURE', l_proc);
49     hr_utility.set_message_token('STEP','15');
50     hr_utility.raise_error;
51   Else
52     hr_utility.set_message(801, 'HR_7877_API_INVALID_CONSTRAINT');
53     hr_utility.set_message_token('PROCEDURE', l_proc);
54     hr_utility.set_message_token('CONSTRAINT_NAME', p_constraint_name);
55     hr_utility.raise_error;
56   End If;
57   --
58   hr_utility.set_location(' Leaving:'||l_proc, 10);
59 End constraint_error;
60 --
61 -- ----------------------------------------------------------------------------
62 -- |-----------------------------< api_updating >-----------------------------|
63 -- ----------------------------------------------------------------------------
64 Function api_updating
65   (p_effective_date		in date,
66    p_popl_org_id		in number,
67    p_object_version_number	in number
68   ) Return Boolean Is
69 --
70   --
71   -- Cursor selects the 'current' row from the HR Schema
72   --
73   Cursor C_Sel1 is
74     select
75 	popl_org_id,
76 	effective_start_date,
77 	effective_end_date,
78 	business_group_id,
79 	cstmr_num,
80 	plcy_r_grp,
81 	pgm_id,
82 	pl_id,
83 	organization_id,
84 	person_id,
85 	cpo_attribute_category,
86 	cpo_attribute1,
87 	cpo_attribute2,
88 	cpo_attribute3,
89 	cpo_attribute4,
90 	cpo_attribute5,
91 	cpo_attribute6,
92 	cpo_attribute7,
93 	cpo_attribute8,
94 	cpo_attribute9,
95 	cpo_attribute10,
96 	cpo_attribute11,
97 	cpo_attribute12,
98 	cpo_attribute13,
99 	cpo_attribute14,
100 	cpo_attribute15,
101 	cpo_attribute16,
102 	cpo_attribute17,
103 	cpo_attribute18,
104 	cpo_attribute19,
105 	cpo_attribute20,
106 	cpo_attribute21,
107 	cpo_attribute22,
108 	cpo_attribute23,
109 	cpo_attribute24,
110 	cpo_attribute25,
111 	cpo_attribute26,
112 	cpo_attribute27,
113 	cpo_attribute28,
114 	cpo_attribute29,
115 	cpo_attribute30,
116 	object_version_number
117     from	ben_popl_org_f
118     where	popl_org_id = p_popl_org_id
119     and		p_effective_date
120     between	effective_start_date and effective_end_date;
121 --
122   l_proc	varchar2(72)	:= g_package||'api_updating';
123   l_fct_ret	boolean;
124 --
125 Begin
126   hr_utility.set_location('Entering:'||l_proc, 5);
127   --
128   If (p_effective_date is null or
129       p_popl_org_id is null or
130       p_object_version_number is null) Then
131     --
132     -- One of the primary key arguments is null therefore we must
133     -- set the returning function value to false
134     --
135     l_fct_ret := false;
136   Else
137     If (p_popl_org_id = g_old_rec.popl_org_id and
138         p_object_version_number = g_old_rec.object_version_number) Then
139       hr_utility.set_location(l_proc, 10);
140       --
141       -- The g_old_rec is current therefore we must
142       -- set the returning function to true
143       --
144       l_fct_ret := true;
145     Else
146       --
147       -- Select the current row
148       --
149       Open C_Sel1;
150       Fetch C_Sel1 Into g_old_rec;
151       If C_Sel1%notfound Then
152         Close C_Sel1;
153         --
154         -- The primary key is invalid therefore we must error
155         --
156         hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
157         hr_utility.raise_error;
158       End If;
159       Close C_Sel1;
160       If (p_object_version_number <> g_old_rec.object_version_number) Then
161         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
162         hr_utility.raise_error;
163       End If;
164       hr_utility.set_location(l_proc, 15);
165       l_fct_ret := true;
166     End If;
167   End If;
168   hr_utility.set_location(' Leaving:'||l_proc, 20);
169   Return (l_fct_ret);
170 --
171 End api_updating;
172 --
173 -- ----------------------------------------------------------------------------
174 -- |--------------------------< find_dt_del_modes >---------------------------|
175 -- ----------------------------------------------------------------------------
176 Procedure find_dt_del_modes
177 	(p_effective_date	in  date,
178 	 p_base_key_value	in  number,
179 	 p_zap		 out nocopy boolean,
180 	 p_delete	 out nocopy boolean,
181 	 p_future_change out nocopy boolean,
182 	 p_delete_next_change out nocopy boolean) is
183 --
184   l_proc 		varchar2(72) 	:= g_package||'find_dt_del_modes';
185 --
186   l_parent_key_value1	number;
187   l_parent_key_value2	number;
188   --
189   Cursor C_Sel1 Is
190     select  t.pl_id,
191 	    t.pgm_id
192     from    ben_popl_org_f t
193     where   t.popl_org_id = p_base_key_value
194     and     p_effective_date
195     between t.effective_start_date and t.effective_end_date;
196 --
197 Begin
198   hr_utility.set_location('Entering:'||l_proc, 5);
199   Open  C_Sel1;
200   Fetch C_Sel1 Into l_parent_key_value1,
201 		    l_parent_key_value2;
202   If C_Sel1%notfound then
203     Close C_Sel1;
204     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
205     hr_utility.set_message_token('PROCEDURE', l_proc);
206     hr_utility.set_message_token('STEP','10');
207     hr_utility.raise_error;
208   End If;
209   Close C_Sel1;
210   --
211   -- Call the corresponding datetrack api
212   --
213   dt_api.find_dt_del_modes
214 	(p_effective_date	=> p_effective_date,
215 	 p_base_table_name	=> 'ben_popl_org_f',
216 	 p_base_key_column	=> 'popl_org_id',
217 	 p_base_key_value	=> p_base_key_value,
218 	 p_parent_table_name1	=> 'ben_pl_f',
219 	 p_parent_key_column1	=> 'pl_id',
220 	 p_parent_key_value1	=> l_parent_key_value1,
221 	 p_parent_table_name2	=> 'ben_pgm_f',
222 	 p_parent_key_column2	=> 'pgm_id',
223 	 p_parent_key_value2	=> l_parent_key_value2,
224 	 p_zap			=> p_zap,
225 	 p_delete		=> p_delete,
226 	 p_future_change	=> p_future_change,
227 	 p_delete_next_change	=> p_delete_next_change);
228   --
229   hr_utility.set_location(' Leaving:'||l_proc, 10);
230 End find_dt_del_modes;
231 --
232 -- ----------------------------------------------------------------------------
233 -- |--------------------------< find_dt_upd_modes >---------------------------|
234 -- ----------------------------------------------------------------------------
235 Procedure find_dt_upd_modes
236 	(p_effective_date	in  date,
237 	 p_base_key_value	in  number,
238 	 p_correction	 out nocopy boolean,
239 	 p_update	 out nocopy boolean,
240 	 p_update_override out nocopy boolean,
241 	 p_update_change_insert out nocopy boolean) is
242 --
243   l_proc 	varchar2(72) := g_package||'find_dt_upd_modes';
244 --
245 Begin
246   hr_utility.set_location('Entering:'||l_proc, 5);
247   --
248   -- Call the corresponding datetrack api
249   --
250   dt_api.find_dt_upd_modes
251 	(p_effective_date	=> p_effective_date,
252 	 p_base_table_name	=> 'ben_popl_org_f',
253 	 p_base_key_column	=> 'popl_org_id',
254 	 p_base_key_value	=> p_base_key_value,
255 	 p_correction		=> p_correction,
256 	 p_update		=> p_update,
257 	 p_update_override	=> p_update_override,
258 	 p_update_change_insert	=> p_update_change_insert);
259   --
260   hr_utility.set_location(' Leaving:'||l_proc, 10);
261 End find_dt_upd_modes;
262 --
263 -- ----------------------------------------------------------------------------
264 -- |------------------------< upd_effective_end_date >------------------------|
265 -- ----------------------------------------------------------------------------
266 Procedure upd_effective_end_date
267 	(p_effective_date		in date,
268 	 p_base_key_value		in number,
269 	 p_new_effective_end_date	in date,
270 	 p_validation_start_date	in date,
271 	 p_validation_end_date		in date,
272          p_object_version_number       out nocopy number) is
273 --
274   l_proc 		  varchar2(72) := g_package||'upd_effective_end_date';
275   l_object_version_number number;
276 --
277 Begin
278   hr_utility.set_location('Entering:'||l_proc, 5);
279   --
280   -- Because we are updating a row we must get the next object
281   -- version number.
282   --
283   l_object_version_number :=
284     dt_api.get_object_version_number
285 	(p_base_table_name	=> 'ben_popl_org_f',
286 	 p_base_key_column	=> 'popl_org_id',
287 	 p_base_key_value	=> p_base_key_value);
288   --
289   hr_utility.set_location(l_proc, 10);
290   g_api_dml := true;  -- Set the api dml status
291   --
292   -- Update the specified datetrack row setting the effective
293   -- end date to the specified new effective end date.
294   --
295   update  ben_popl_org_f t
296   set	  t.effective_end_date	  = p_new_effective_end_date,
297 	  t.object_version_number = l_object_version_number
298   where	  t.popl_org_id	  = p_base_key_value
299   and	  p_effective_date
300   between t.effective_start_date and t.effective_end_date;
301   --
302   g_api_dml := false;   -- Unset the api dml status
303   p_object_version_number := l_object_version_number;
304   hr_utility.set_location(' Leaving:'||l_proc, 15);
305 --
306 Exception
307   When Others Then
308     g_api_dml := false;   -- Unset the api dml status
309     Raise;
310 End upd_effective_end_date;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------------< lck >----------------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure lck
316 	(p_effective_date	 in  date,
317 	 p_datetrack_mode	 in  varchar2,
318 	 p_popl_org_id	         in  number,
319 	 p_object_version_number in  number,
320 	 p_validation_start_date out nocopy date,
321 	 p_validation_end_date	 out nocopy date) is
322 --
323   l_proc		  varchar2(72) := g_package||'lck';
324   l_validation_start_date date;
325   l_validation_end_date	  date;
326   l_object_invalid 	  exception;
327   l_argument		  varchar2(30);
328   --
329   -- Cursor C_Sel1 selects the current locked row as of session date
330   -- ensuring that the object version numbers match.
331   --
332   Cursor C_Sel1 is
333     select
334 	popl_org_id,
335 	effective_start_date,
336 	effective_end_date,
337 	business_group_id,
338 	cstmr_num,
339 	plcy_r_grp,
340 	pgm_id,
341 	pl_id,
342 	organization_id,
343 	person_id,
344 	cpo_attribute_category,
345 	cpo_attribute1,
346 	cpo_attribute2,
347 	cpo_attribute3,
348 	cpo_attribute4,
349 	cpo_attribute5,
350 	cpo_attribute6,
351 	cpo_attribute7,
352 	cpo_attribute8,
353 	cpo_attribute9,
354 	cpo_attribute10,
355 	cpo_attribute11,
356 	cpo_attribute12,
357 	cpo_attribute13,
358 	cpo_attribute14,
359 	cpo_attribute15,
360 	cpo_attribute16,
361 	cpo_attribute17,
362 	cpo_attribute18,
363 	cpo_attribute19,
364 	cpo_attribute20,
365 	cpo_attribute21,
366 	cpo_attribute22,
367 	cpo_attribute23,
368 	cpo_attribute24,
369 	cpo_attribute25,
370 	cpo_attribute26,
371 	cpo_attribute27,
372 	cpo_attribute28,
373 	cpo_attribute29,
374 	cpo_attribute30,
375 	object_version_number
376     from    ben_popl_org_f
377     where   popl_org_id         = p_popl_org_id
378     and	    p_effective_date
379     between effective_start_date and effective_end_date
380     for update nowait;
381   --
382   --
383   --
384 Begin
385   hr_utility.set_location('Entering:'||l_proc, 5);
386   --
387   -- Ensure that all the mandatory arguments are not null
388   --
389   hr_api.mandatory_arg_error(p_api_name       => l_proc,
390                              p_argument       => 'effective_date',
391                              p_argument_value => p_effective_date);
392   --
393   hr_api.mandatory_arg_error(p_api_name       => l_proc,
394                              p_argument       => 'datetrack_mode',
395                              p_argument_value => p_datetrack_mode);
396   --
397   hr_api.mandatory_arg_error(p_api_name       => l_proc,
398                              p_argument       => 'popl_org_id',
399                              p_argument_value => p_popl_org_id);
400   --
401   hr_api.mandatory_arg_error(p_api_name       => l_proc,
402                              p_argument       => 'object_version_number',
403                              p_argument_value => p_object_version_number);
404   --
405   -- Check to ensure the datetrack mode is not INSERT.
406   --
407   If (p_datetrack_mode <> 'INSERT') then
408     --
409     -- We must select and lock the current row.
410     --
411     Open  C_Sel1;
412     Fetch C_Sel1 Into g_old_rec;
413     If C_Sel1%notfound then
414       Close C_Sel1;
415       --
416       -- The primary key is invalid therefore we must error
417       --
418       hr_utility.set_message(801, 'HR_7220_INVALID_PRIMARY_KEY');
419       hr_utility.raise_error;
420     End If;
421     Close C_Sel1;
422     If (p_object_version_number <> g_old_rec.object_version_number) Then
423         hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
424         hr_utility.raise_error;
425       End If;
426     hr_utility.set_location(l_proc, 15);
427     --
428     --
429     -- Validate the datetrack mode mode getting the validation start
430     -- and end dates for the specified datetrack operation.
431     --
432     dt_api.validate_dt_mode
433 	(p_effective_date	   => p_effective_date,
437 	 p_base_key_value 	   => p_popl_org_id,
434 	 p_datetrack_mode	   => p_datetrack_mode,
435 	 p_base_table_name	   => 'ben_popl_org_f',
436 	 p_base_key_column	   => 'popl_org_id',
438 	 p_parent_table_name1      => 'ben_pl_f',
439 	 p_parent_key_column1      => 'pl_id',
440 	 p_parent_key_value1       => g_old_rec.pl_id,
441 	 p_parent_table_name2      => 'ben_pgm_f',
442 	 p_parent_key_column2      => 'pgm_id',
443 	 p_parent_key_value2       => g_old_rec.pgm_id,
444          p_enforce_foreign_locking => true,
445 	 p_validation_start_date   => l_validation_start_date,
446  	 p_validation_end_date	   => l_validation_end_date);
447   Else
448     --
449     -- We are doing a datetrack 'INSERT' which is illegal within this
450     -- procedure therefore we must error (note: to lck on insert the
451     -- private procedure ins_lck should be called).
452     --
453     hr_utility.set_message(801, 'HR_6153_ALL_PROCEDURE_FAIL');
454     hr_utility.set_message_token('PROCEDURE', l_proc);
455     hr_utility.set_message_token('STEP','20');
456     hr_utility.raise_error;
457   End If;
458   --
459   -- Set the validation start and end date OUT arguments
460   --
461   p_validation_start_date := l_validation_start_date;
462   p_validation_end_date   := l_validation_end_date;
463   --
464   hr_utility.set_location(' Leaving:'||l_proc, 30);
465 --
466 -- We need to trap the ORA LOCK exception
467 --
468 Exception
469   When HR_Api.Object_Locked then
470     --
471     -- The object is locked therefore we need to supply a meaningful
472     -- error message.
473     --
474     hr_utility.set_message(801, 'HR_7165_OBJECT_LOCKED');
475     hr_utility.set_message_token('TABLE_NAME', 'ben_popl_org_f');
476     hr_utility.raise_error;
477   When l_object_invalid then
478     --
479     -- The object doesn't exist or is invalid
480     --
481     hr_utility.set_message(801, 'HR_7155_OBJECT_INVALID');
482     hr_utility.set_message_token('TABLE_NAME', 'ben_popl_org_f');
483     hr_utility.raise_error;
484 End lck;
485 --
486 -- ----------------------------------------------------------------------------
487 -- |-----------------------------< convert_args >-----------------------------|
488 -- ----------------------------------------------------------------------------
489 Function convert_args
490 	(
491 	p_popl_org_id                   in number,
492 	p_effective_start_date          in date,
493 	p_effective_end_date            in date,
494 	p_business_group_id             in number,
495 	p_cstmr_num                     in number,
496 	p_plcy_r_grp                    in varchar2,
497 	p_pgm_id                        in number,
498 	p_pl_id                         in number,
499 	p_organization_id               in number,
500 	p_person_id                     in number,
501 	p_cpo_attribute_category        in varchar2,
502 	p_cpo_attribute1                in varchar2,
503 	p_cpo_attribute2                in varchar2,
504 	p_cpo_attribute3                in varchar2,
505 	p_cpo_attribute4                in varchar2,
506 	p_cpo_attribute5                in varchar2,
507 	p_cpo_attribute6                in varchar2,
508 	p_cpo_attribute7                in varchar2,
509 	p_cpo_attribute8                in varchar2,
510 	p_cpo_attribute9                in varchar2,
511 	p_cpo_attribute10               in varchar2,
512 	p_cpo_attribute11               in varchar2,
513 	p_cpo_attribute12               in varchar2,
514 	p_cpo_attribute13               in varchar2,
515 	p_cpo_attribute14               in varchar2,
516 	p_cpo_attribute15               in varchar2,
517 	p_cpo_attribute16               in varchar2,
518 	p_cpo_attribute17               in varchar2,
519 	p_cpo_attribute18               in varchar2,
520 	p_cpo_attribute19               in varchar2,
521 	p_cpo_attribute20               in varchar2,
522 	p_cpo_attribute21               in varchar2,
523 	p_cpo_attribute22               in varchar2,
524 	p_cpo_attribute23               in varchar2,
525 	p_cpo_attribute24               in varchar2,
526 	p_cpo_attribute25               in varchar2,
527 	p_cpo_attribute26               in varchar2,
528 	p_cpo_attribute27               in varchar2,
529 	p_cpo_attribute28               in varchar2,
530 	p_cpo_attribute29               in varchar2,
531 	p_cpo_attribute30               in varchar2,
532 	p_object_version_number         in number
533 	)
534 	Return g_rec_type is
535 --
536   l_rec	  g_rec_type;
537   l_proc  varchar2(72) := g_package||'convert_args';
538 --
539 Begin
540   --
541   hr_utility.set_location('Entering:'||l_proc, 5);
542   --
543   -- Convert arguments into local l_rec structure.
544   --
545   l_rec.popl_org_id                      := p_popl_org_id;
546   l_rec.effective_start_date             := p_effective_start_date;
547   l_rec.effective_end_date               := p_effective_end_date;
548   l_rec.business_group_id                := p_business_group_id;
549   l_rec.cstmr_num                        := p_cstmr_num;
550   l_rec.plcy_r_grp                       := p_plcy_r_grp;
551   l_rec.pgm_id                           := p_pgm_id;
552   l_rec.pl_id                            := p_pl_id;
553   l_rec.organization_id                  := p_organization_id;
554   l_rec.person_id                        := p_person_id;
555   l_rec.cpo_attribute_category           := p_cpo_attribute_category;
556   l_rec.cpo_attribute1                   := p_cpo_attribute1;
557   l_rec.cpo_attribute2                   := p_cpo_attribute2;
558   l_rec.cpo_attribute3                   := p_cpo_attribute3;
559   l_rec.cpo_attribute4                   := p_cpo_attribute4;
560   l_rec.cpo_attribute5                   := p_cpo_attribute5;
561   l_rec.cpo_attribute6                   := p_cpo_attribute6;
562   l_rec.cpo_attribute7                   := p_cpo_attribute7;
563   l_rec.cpo_attribute8                   := p_cpo_attribute8;
564   l_rec.cpo_attribute9                   := p_cpo_attribute9;
565   l_rec.cpo_attribute10                  := p_cpo_attribute10;
566   l_rec.cpo_attribute11                  := p_cpo_attribute11;
567   l_rec.cpo_attribute12                  := p_cpo_attribute12;
568   l_rec.cpo_attribute13                  := p_cpo_attribute13;
569   l_rec.cpo_attribute14                  := p_cpo_attribute14;
570   l_rec.cpo_attribute15                  := p_cpo_attribute15;
571   l_rec.cpo_attribute16                  := p_cpo_attribute16;
572   l_rec.cpo_attribute17                  := p_cpo_attribute17;
573   l_rec.cpo_attribute18                  := p_cpo_attribute18;
574   l_rec.cpo_attribute19                  := p_cpo_attribute19;
575   l_rec.cpo_attribute20                  := p_cpo_attribute20;
576   l_rec.cpo_attribute21                  := p_cpo_attribute21;
577   l_rec.cpo_attribute22                  := p_cpo_attribute22;
578   l_rec.cpo_attribute23                  := p_cpo_attribute23;
579   l_rec.cpo_attribute24                  := p_cpo_attribute24;
580   l_rec.cpo_attribute25                  := p_cpo_attribute25;
581   l_rec.cpo_attribute26                  := p_cpo_attribute26;
582   l_rec.cpo_attribute27                  := p_cpo_attribute27;
583   l_rec.cpo_attribute28                  := p_cpo_attribute28;
584   l_rec.cpo_attribute29                  := p_cpo_attribute29;
585   l_rec.cpo_attribute30                  := p_cpo_attribute30;
586   l_rec.object_version_number            := p_object_version_number;
587   --
588   -- Return the plsql record structure.
589   --
590   hr_utility.set_location(' Leaving:'||l_proc, 10);
591   Return(l_rec);
592 --
593 End convert_args;
594 --
595 end ben_cpo_shd;