DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BNR_SHD

Source


1 Package Body ben_bnr_shd as
2 /* $Header: bebnrrhi.pkb 120.0 2005/05/28 00:46:03 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_bnr_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_RPTG_GRP_FK1') Then
37     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
38     fnd_message.set_token('PROCEDURE', l_proc);
39     fnd_message.set_token('STEP','5');
40     fnd_message.raise_error;
41   ElsIf (p_constraint_name = 'BEN_RPTG_GRP_PK') Then
42     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
43     fnd_message.set_token('PROCEDURE', l_proc);
44     fnd_message.set_token('STEP','10');
45     fnd_message.raise_error;
46   ElsIf (p_constraint_name = 'BEN_PL_REGN_FK2') Then
47     ben_utility.child_exists_error(p_table_name => 'BEN_PL_REGN_F');
48   ElsIf (p_constraint_name = 'BEN_POPL_RPTG_GRP_FK1') Then
49     ben_utility.child_exists_error(p_table_name => 'BEN_POPL_RPTG_GRP_F');
50   ElsIf (p_constraint_name = 'BEN_PL_REGY_BOD_FK1') Then
51     ben_utility.child_exists_error(p_table_name => 'BEN_PL_REGY_BOD_F');
52   Else
53     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
54     fnd_message.set_token('PROCEDURE', l_proc);
55     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
56     fnd_message.raise_error;
57   End If;
58   --
59   hr_utility.set_location(' Leaving:'||l_proc, 10);
60 End constraint_error;
61 --
62 -- ----------------------------------------------------------------------------
63 -- |-----------------------------< api_updating >-----------------------------|
64 -- ----------------------------------------------------------------------------
65 Function api_updating
66   (
67   p_rptg_grp_id                        in number,
68   p_object_version_number              in number
69   )      Return Boolean Is
70 --
71   --
72   -- Cursor selects the 'current' row from the HR Schema
73   --
74   Cursor C_Sel1 is
75     select
76 		rptg_grp_id,
77 	name,
78 	business_group_id,
79 	rptg_prps_cd,
80 	rpg_desc,
81 	bnr_attribute_category,
82 	bnr_attribute1,
83 	bnr_attribute2,
84 	bnr_attribute3,
85 	bnr_attribute4,
86 	bnr_attribute5,
87 	bnr_attribute6,
88 	bnr_attribute7,
89 	bnr_attribute8,
90 	bnr_attribute9,
91 	bnr_attribute10,
92 	bnr_attribute11,
93 	bnr_attribute12,
94 	bnr_attribute13,
95 	bnr_attribute14,
96 	bnr_attribute15,
97 	bnr_attribute16,
98 	bnr_attribute17,
99 	bnr_attribute18,
100 	bnr_attribute19,
101 	bnr_attribute20,
102 	bnr_attribute21,
103 	bnr_attribute22,
104 	bnr_attribute23,
105 	bnr_attribute24,
106 	bnr_attribute25,
107 	bnr_attribute26,
108 	bnr_attribute27,
109 	bnr_attribute28,
110 	bnr_attribute29,
111 	bnr_attribute30,
112         function_code,
113         legislation_code,
114 	object_version_number,
115 	ordr_num                            --iRec
116     from	ben_rptg_grp
117     where	rptg_grp_id = p_rptg_grp_id;
118 --
119   l_proc	varchar2(72)	:= g_package||'api_updating';
120   l_fct_ret	boolean;
121 --
122 Begin
123   hr_utility.set_location('Entering:'||l_proc, 5);
124   --
125   If (
126 	p_rptg_grp_id is null and
127 	p_object_version_number is null
128      ) Then
129     --
130     -- One of the primary key arguments is null therefore we must
131     -- set the returning function value to false
132     --
133     l_fct_ret := false;
134   Else
135     If (
136 	p_rptg_grp_id = g_old_rec.rptg_grp_id and
137 	p_object_version_number = g_old_rec.object_version_number
138        ) 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 into g_old_rec
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         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
157         fnd_message.raise_error;
158       End If;
159       Close C_Sel1;
160       If (p_object_version_number <> g_old_rec.object_version_number) Then
161         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
162         fnd_message.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 -- |---------------------------------< lck >----------------------------------|
175 -- ----------------------------------------------------------------------------
176 Procedure lck
177   (
178   p_rptg_grp_id                        in number,
179   p_object_version_number              in number
180   ) is
181 --
182 -- Cursor selects the 'current' row from the HR Schema
183 --
184   Cursor C_Sel1 is
185     select 	rptg_grp_id,
186 	name,
187 	business_group_id,
188 	rptg_prps_cd,
189 	rpg_desc,
190 	bnr_attribute_category,
191 	bnr_attribute1,
192 	bnr_attribute2,
193 	bnr_attribute3,
194 	bnr_attribute4,
195 	bnr_attribute5,
196 	bnr_attribute6,
197 	bnr_attribute7,
198 	bnr_attribute8,
199 	bnr_attribute9,
200 	bnr_attribute10,
201 	bnr_attribute11,
202 	bnr_attribute12,
203 	bnr_attribute13,
204 	bnr_attribute14,
205 	bnr_attribute15,
206 	bnr_attribute16,
207 	bnr_attribute17,
208 	bnr_attribute18,
209 	bnr_attribute19,
210 	bnr_attribute20,
211 	bnr_attribute21,
212 	bnr_attribute22,
213 	bnr_attribute23,
214 	bnr_attribute24,
215 	bnr_attribute25,
216 	bnr_attribute26,
217 	bnr_attribute27,
218 	bnr_attribute28,
219 	bnr_attribute29,
220 	bnr_attribute30,
221         function_code,
222         legislation_code,
223 	object_version_number,
224 	ordr_num                      --iRec
225     from	ben_rptg_grp
226     where	rptg_grp_id = p_rptg_grp_id
227     for	update nowait;
228 --
229   l_proc	varchar2(72) := g_package||'lck';
230 --
231 Begin
232   hr_utility.set_location('Entering:'||l_proc, 5);
233   --
234   -- Add any mandatory argument checking here:
235   -- Example:
236   -- hr_api.mandatory_arg_error
237   --   (p_api_name       => l_proc,
238   --    p_argument       => 'object_version_number',
239   --    p_argument_value => p_object_version_number);
240   --
241   Open  C_Sel1;
242   Fetch C_Sel1 Into g_old_rec;
243   If C_Sel1%notfound then
244     Close C_Sel1;
245     --
246     -- The primary key is invalid therefore we must error
247     --
248     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
249     fnd_message.raise_error;
250   End If;
251   Close C_Sel1;
252   If (p_object_version_number <> g_old_rec.object_version_number) Then
253         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
254         fnd_message.raise_error;
255       End If;
256 --
257   hr_utility.set_location(' Leaving:'||l_proc, 10);
258 --
259 -- We need to trap the ORA LOCK exception
260 --
261 Exception
262   When HR_Api.Object_Locked then
263     --
264     -- The object is locked therefore we need to supply a meaningful
265     -- error message.
266     --
267     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
268     fnd_message.set_token('TABLE_NAME', 'ben_rptg_grp');
269     fnd_message.raise_error;
270 End lck;
271 --
272 -- ----------------------------------------------------------------------------
273 -- |-----------------------------< convert_args >-----------------------------|
274 -- ----------------------------------------------------------------------------
275 Function convert_args
276 	(
277 	p_rptg_grp_id                   in number,
278 	p_name                          in varchar2,
279 	p_business_group_id             in number,
280 	p_rptg_prps_cd                  in varchar2,
281 	p_rpg_desc                      in varchar2,
282 	p_bnr_attribute_category        in varchar2,
283 	p_bnr_attribute1                in varchar2,
284 	p_bnr_attribute2                in varchar2,
285 	p_bnr_attribute3                in varchar2,
286 	p_bnr_attribute4                in varchar2,
287 	p_bnr_attribute5                in varchar2,
288 	p_bnr_attribute6                in varchar2,
289 	p_bnr_attribute7                in varchar2,
290 	p_bnr_attribute8                in varchar2,
291 	p_bnr_attribute9                in varchar2,
292 	p_bnr_attribute10               in varchar2,
293 	p_bnr_attribute11               in varchar2,
294 	p_bnr_attribute12               in varchar2,
295 	p_bnr_attribute13               in varchar2,
296 	p_bnr_attribute14               in varchar2,
297 	p_bnr_attribute15               in varchar2,
298 	p_bnr_attribute16               in varchar2,
299 	p_bnr_attribute17               in varchar2,
300 	p_bnr_attribute18               in varchar2,
301 	p_bnr_attribute19               in varchar2,
302 	p_bnr_attribute20               in varchar2,
303 	p_bnr_attribute21               in varchar2,
304 	p_bnr_attribute22               in varchar2,
305 	p_bnr_attribute23               in varchar2,
306 	p_bnr_attribute24               in varchar2,
307 	p_bnr_attribute25               in varchar2,
308 	p_bnr_attribute26               in varchar2,
309 	p_bnr_attribute27               in varchar2,
310 	p_bnr_attribute28               in varchar2,
311 	p_bnr_attribute29               in varchar2,
312 	p_bnr_attribute30               in varchar2,
313         p_function_code                 in varchar2,
314         p_legislation_code              in varchar2,
315 	p_object_version_number         in number,
316 	p_ordr_num                      in number                      --iRec
317 	)
318 	Return g_rec_type is
319 --
320   l_rec	  g_rec_type;
321   l_proc  varchar2(72) := g_package||'convert_args';
322 --
323 Begin
324   --
325   hr_utility.set_location('Entering:'||l_proc, 5);
326   --
327   -- Convert arguments into local l_rec structure.
328   --
329   l_rec.rptg_grp_id                      := p_rptg_grp_id;
330   l_rec.name                             := p_name;
331   l_rec.business_group_id                := p_business_group_id;
332   l_rec.rptg_prps_cd                     := p_rptg_prps_cd;
333   l_rec.rpg_desc                         := p_rpg_desc;
334   l_rec.bnr_attribute_category           := p_bnr_attribute_category;
335   l_rec.bnr_attribute1                   := p_bnr_attribute1;
336   l_rec.bnr_attribute2                   := p_bnr_attribute2;
337   l_rec.bnr_attribute3                   := p_bnr_attribute3;
338   l_rec.bnr_attribute4                   := p_bnr_attribute4;
339   l_rec.bnr_attribute5                   := p_bnr_attribute5;
340   l_rec.bnr_attribute6                   := p_bnr_attribute6;
341   l_rec.bnr_attribute7                   := p_bnr_attribute7;
342   l_rec.bnr_attribute8                   := p_bnr_attribute8;
343   l_rec.bnr_attribute9                   := p_bnr_attribute9;
344   l_rec.bnr_attribute10                  := p_bnr_attribute10;
345   l_rec.bnr_attribute11                  := p_bnr_attribute11;
346   l_rec.bnr_attribute12                  := p_bnr_attribute12;
347   l_rec.bnr_attribute13                  := p_bnr_attribute13;
348   l_rec.bnr_attribute14                  := p_bnr_attribute14;
349   l_rec.bnr_attribute15                  := p_bnr_attribute15;
350   l_rec.bnr_attribute16                  := p_bnr_attribute16;
351   l_rec.bnr_attribute17                  := p_bnr_attribute17;
352   l_rec.bnr_attribute18                  := p_bnr_attribute18;
353   l_rec.bnr_attribute19                  := p_bnr_attribute19;
354   l_rec.bnr_attribute20                  := p_bnr_attribute20;
355   l_rec.bnr_attribute21                  := p_bnr_attribute21;
356   l_rec.bnr_attribute22                  := p_bnr_attribute22;
357   l_rec.bnr_attribute23                  := p_bnr_attribute23;
358   l_rec.bnr_attribute24                  := p_bnr_attribute24;
359   l_rec.bnr_attribute25                  := p_bnr_attribute25;
360   l_rec.bnr_attribute26                  := p_bnr_attribute26;
361   l_rec.bnr_attribute27                  := p_bnr_attribute27;
362   l_rec.bnr_attribute28                  := p_bnr_attribute28;
363   l_rec.bnr_attribute29                  := p_bnr_attribute29;
364   l_rec.bnr_attribute30                  := p_bnr_attribute30;
365   l_rec.function_code                    := p_function_code;
366   l_rec.legislation_code                 := p_legislation_code;
367   l_rec.object_version_number            := p_object_version_number;
368   l_rec.ordr_num                         := p_ordr_num;                      --iRec
369   --
370   -- Return the plsql record structure.
371   --
372   hr_utility.set_location(' Leaving:'||l_proc, 10);
373   Return(l_rec);
374 --
375 End convert_args;
376 --
377 
378 -- ----------------------------------------------------------------------------
379 -- |--------------------------<add_language>----------------------------------|
380 -- ----------------------------------------------------------------------------
381 Procedure add_language
382 is
383 begin
384 
385   delete from BEN_RPTG_GRP_TL T
386   where not exists
387     (select NULL
388     from BEN_RPTG_GRP B
389     where B.RPTG_GRP_ID = T.RPTG_GRP_ID
390     );
391 
392   update ben_rptg_grp_tl t set (
393       function_code,
394       name
395     ) = (select
396       b.function_code,
397       b.name
398     from ben_rptg_grp_tl b
399     where b.RPTG_GRP_ID = t.RPTG_GRP_ID
400     and b.language = t.source_lang)
401   where (
402       t.RPTG_GRP_ID,
403       t.language
404   ) in (select
405       subt.RPTG_GRP_ID,
406       subt.language
407     from ben_rptg_grp_tl subb, ben_rptg_grp_tl subt
408     where subb.RPTG_GRP_ID = subt.RPTG_GRP_ID
409     and   subb.language = subt.source_lang
410     and (subb.name <> subt.name
411          or subb.function_code <> subt.function_code
412   ));
413 
414   insert into ben_rptg_grp_tl (
415     RPTG_GRP_ID,
416     function_code,
417     name,
418     language,
419     source_lang,
420     last_update_date,
421     last_updated_by,
422     last_update_login,
423     created_by,
424     creation_date
425   ) select
426     b.RPTG_GRP_ID,
427     b.function_code,
428     b.name,
429     l.language_code,
430     b.source_lang,
431     b.last_update_date,
432     b.last_updated_by,
433     b.last_update_login,
434     b.created_by,
435     b.creation_date
436   from ben_rptg_grp_tl b, fnd_languages l
437   where l.installed_flag in ('I', 'B')
438   and b.language = userenv('LANG')
439   and not exists
440     (select null
441     from ben_rptg_grp_tl t
442     where t.rptg_grp_id = b.rptg_grp_id
443     and   t.language = l.language_code);
444 end add_language;
445 --
446 end ben_bnr_shd;