[Home] [Help]
PACKAGE BODY: APPS.FF_FGL_SHD
Source
1 Package Body ff_fgl_shd as
2 /* $Header: fffglrhi.pkb 120.0.12000000.1 2007/03/20 11:52:47 ckesanap noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ff_fgl_shd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
15 Begin
16 --
17 Return (nvl(g_api_dml, false));
18 --
19 End return_api_dml_status;
20 --
21 -- ----------------------------------------------------------------------------
22 -- |---------------------------< constraint_error >---------------------------|
23 -- ----------------------------------------------------------------------------
24 Procedure constraint_error
25 (p_constraint_name in all_constraints.constraint_name%TYPE
26 ) Is
27 --
28 l_proc varchar2(72) := g_package||'constraint_error';
29 --
30 Begin
31 --
32 If (p_constraint_name = 'FF_GLB_DATA_TYPE_CHK') Then
33 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
34 fnd_message.set_token('PROCEDURE', l_proc);
35 fnd_message.set_token('STEP','5');
36 fnd_message.raise_error;
37 ElsIf (p_constraint_name = 'FF_GLOBALS_F_PK') Then
38 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
39 fnd_message.set_token('PROCEDURE', l_proc);
40 fnd_message.set_token('STEP','10');
41 fnd_message.raise_error;
42 ElsIf (p_constraint_name = 'FF_GLOBALS_F_UK2') Then
43 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
44 fnd_message.set_token('PROCEDURE', l_proc);
45 fnd_message.set_token('STEP','15');
46 fnd_message.raise_error;
47 Else
48 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
49 fnd_message.set_token('PROCEDURE', l_proc);
50 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
51 fnd_message.raise_error;
52 End If;
53 --
54 End constraint_error;
55 --
56 -- ----------------------------------------------------------------------------
57 -- |-----------------------------< api_updating >-----------------------------|
58 -- ----------------------------------------------------------------------------
59 Function api_updating
60 (p_effective_date in date
61 ,p_global_id in number
62 ,p_object_version_number in number
63 ) Return Boolean Is
64 --
65 -- Cursor selects the 'current' row from the HR Schema
66 --
67 Cursor C_Sel1 is
68 select
69 global_id
70 ,effective_start_date
71 ,effective_end_date
72 ,business_group_id
73 ,legislation_code
74 ,data_type
75 ,global_name
76 ,global_description
77 ,global_value
78 ,object_version_number
79 from ff_globals_f
80 where global_id = p_global_id
81 and p_effective_date
82 between effective_start_date and effective_end_date;
83 --
84 l_fct_ret boolean;
85 --
86 Begin
87 --
88 If (p_effective_date is null or
89 p_global_id is null or
90 p_object_version_number is null) Then
91 --
92 -- One of the primary key arguments is null therefore we must
93 -- set the returning function value to false
94 --
95 l_fct_ret := false;
96 Else
97 If (p_global_id =
98 ff_fgl_shd.g_old_rec.global_id and
99 p_object_version_number =
100 ff_fgl_shd.g_old_rec.object_version_number
101 ) Then
102 --
103 -- The g_old_rec is current therefore we must
104 -- set the returning function to true
105 --
106 l_fct_ret := true;
107 Else
108 --
109 -- Select the current row
110 --
111 Open C_Sel1;
112 Fetch C_Sel1 Into ff_fgl_shd.g_old_rec;
113 If C_Sel1%notfound Then
114 Close C_Sel1;
115 --
116 -- The primary key is invalid therefore we must error
117 --
118 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
119 fnd_message.raise_error;
120 End If;
121 Close C_Sel1;
122 If (p_object_version_number
123 <> ff_fgl_shd.g_old_rec.object_version_number) Then
124 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
125 fnd_message.raise_error;
126 End If;
127 l_fct_ret := true;
128 End If;
129 End If;
130 Return (l_fct_ret);
131 --
132 End api_updating;
133 --
134 -- ----------------------------------------------------------------------------
135 -- |---------------------------< find_dt_upd_modes >--------------------------|
136 -- ----------------------------------------------------------------------------
137 Procedure find_dt_upd_modes
138 (p_effective_date in date
139 ,p_base_key_value in number
140 ,p_correction out nocopy boolean
141 ,p_update out nocopy boolean
142 ,p_update_override out nocopy boolean
143 ,p_update_change_insert out nocopy boolean
144 ) is
145 --
146 l_proc varchar2(72) := g_package||'find_dt_upd_modes';
147 --
148 Begin
149 hr_utility.set_location('Entering:'||l_proc, 5);
150 --
151 -- Call the corresponding datetrack api
152 --
153 dt_api.find_dt_upd_modes
154 (p_effective_date => p_effective_date
155 ,p_base_table_name => 'ff_globals_f'
156 ,p_base_key_column => 'global_id'
157 ,p_base_key_value => p_base_key_value
158 ,p_correction => p_correction
159 ,p_update => p_update
160 ,p_update_override => p_update_override
161 ,p_update_change_insert => p_update_change_insert
162 );
163 --
164 hr_utility.set_location(' Leaving:'||l_proc, 10);
165 End find_dt_upd_modes;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |---------------------------< find_dt_del_modes >--------------------------|
169 -- ----------------------------------------------------------------------------
170 Procedure find_dt_del_modes
171 (p_effective_date in date
172 ,p_base_key_value in number
173 ,p_zap out nocopy boolean
174 ,p_delete out nocopy boolean
175 ,p_future_change out nocopy boolean
176 ,p_delete_next_change out nocopy boolean
177 ) is
178 --
179 l_proc varchar2(72) := g_package||'find_dt_del_modes';
180 --
181 --
182 Begin
183 hr_utility.set_location('Entering:'||l_proc, 5);
184 --
185 -- Call the corresponding datetrack api
186 --
187 dt_api.find_dt_del_modes
188 (p_effective_date => p_effective_date
189 ,p_base_table_name => 'ff_globals_f'
190 ,p_base_key_column => 'global_id'
191 ,p_base_key_value => p_base_key_value
192 ,p_zap => p_zap
193 ,p_delete => p_delete
194 ,p_future_change => p_future_change
195 ,p_delete_next_change => p_delete_next_change
196 );
197 --
198 hr_utility.set_location(' Leaving:'||l_proc, 10);
199 End find_dt_del_modes;
200 --
201 -- ----------------------------------------------------------------------------
202 -- |-----------------------< upd_effective_end_date >-------------------------|
203 -- ----------------------------------------------------------------------------
204 Procedure upd_effective_end_date
205 (p_effective_date in date
206 ,p_base_key_value in number
207 ,p_new_effective_end_date in date
208 ,p_validation_start_date in date
209 ,p_validation_end_date in date
210 ,p_object_version_number out nocopy number
211 ) is
212 --
213 l_proc varchar2(72) := g_package||'upd_effective_end_date';
214 l_object_version_number number;
215 --
216 Begin
217 hr_utility.set_location('Entering:'||l_proc, 5);
218 --
219 -- Because we are updating a row we must get the next object
220 -- version number.
221 --
222 l_object_version_number :=
223 dt_api.get_object_version_number
224 (p_base_table_name => 'ff_globals_f'
225 ,p_base_key_column => 'global_id'
226 ,p_base_key_value => p_base_key_value
227 );
228 --
229 hr_utility.set_location(l_proc, 10);
230 ff_fgl_shd.g_api_dml := true; -- Set the api dml status
231 --
232 -- Update the specified datetrack row setting the effective
233 -- end date to the specified new effective end date.
234 --
235 update ff_globals_f t
236 set t.effective_end_date = p_new_effective_end_date
237 , t.object_version_number = l_object_version_number
238 where t.global_id = p_base_key_value
239 and p_effective_date
240 between t.effective_start_date and t.effective_end_date;
241 --
242 ff_fgl_shd.g_api_dml := false; -- Unset the api dml status
243 p_object_version_number := l_object_version_number;
244 hr_utility.set_location(' Leaving:'||l_proc, 15);
245 --
246 Exception
247 When Others Then
248 ff_fgl_shd.g_api_dml := false; -- Unset the api dml status
249 Raise;
250 --
251 End upd_effective_end_date;
252 --
253 -- ----------------------------------------------------------------------------
254 -- |---------------------------------< lck >----------------------------------|
255 -- ----------------------------------------------------------------------------
256 Procedure lck
257 (p_effective_date in date
258 ,p_datetrack_mode in varchar2
259 ,p_global_id in number
260 ,p_object_version_number in number
261 ,p_validation_start_date out nocopy date
262 ,p_validation_end_date out nocopy date
263 ) is
264 --
265 l_proc varchar2(72) := g_package||'lck';
266 l_validation_start_date date;
267 l_validation_end_date date;
268 l_argument varchar2(30);
269 --
270 -- Cursor C_Sel1 selects the current locked row as of session date
271 -- ensuring that the object version numbers match.
272 --
273 Cursor C_Sel1 is
274 select
275 global_id
276 ,effective_start_date
277 ,effective_end_date
278 ,business_group_id
279 ,legislation_code
280 ,data_type
281 ,global_name
282 ,global_description
283 ,global_value
284 ,object_version_number
285 from ff_globals_f
286 where global_id = p_global_id
287 and p_effective_date
288 between effective_start_date and effective_end_date
289 for update nowait;
290 --
291 --
292 --
293 Begin
294 hr_utility.set_location('Entering:'||l_proc, 5);
295 --
296 -- Ensure that all the mandatory arguments are not null
297 --
298 hr_api.mandatory_arg_error(p_api_name => l_proc
299 ,p_argument => 'effective_date'
300 ,p_argument_value => p_effective_date
301 );
302 --
303 hr_api.mandatory_arg_error(p_api_name => l_proc
304 ,p_argument => 'datetrack_mode'
305 ,p_argument_value => p_datetrack_mode
306 );
307 --
308 hr_api.mandatory_arg_error(p_api_name => l_proc
309 ,p_argument => 'global_id'
310 ,p_argument_value => p_global_id
311 );
312 --
313 hr_api.mandatory_arg_error(p_api_name => l_proc
314 ,p_argument => 'object_version_number'
315 ,p_argument_value => p_object_version_number
316 );
317 --
318 -- Check to ensure the datetrack mode is not INSERT.
319 --
320 If (p_datetrack_mode <> hr_api.g_insert) then
321 --
322 -- We must select and lock the current row.
323 --
324 Open C_Sel1;
325 Fetch C_Sel1 Into ff_fgl_shd.g_old_rec;
326 If C_Sel1%notfound then
327 Close C_Sel1;
328 --
329 -- The primary key is invalid therefore we must error
330 --
331 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
332 fnd_message.raise_error;
333 End If;
334 Close C_Sel1;
335 If (p_object_version_number
336 <> ff_fgl_shd.g_old_rec.object_version_number) Then
337 fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
338 fnd_message.raise_error;
339 End If;
340 --
341 --
342 -- Validate the datetrack mode mode getting the validation start
343 -- and end dates for the specified datetrack operation.
344 --
345 dt_api.validate_dt_mode
346 (p_effective_date => p_effective_date
347 ,p_datetrack_mode => p_datetrack_mode
348 ,p_base_table_name => 'ff_globals_f'
349 ,p_base_key_column => 'global_id'
350 ,p_base_key_value => p_global_id
351 ,p_enforce_foreign_locking => true
352 ,p_validation_start_date => l_validation_start_date
353 ,p_validation_end_date => l_validation_end_date
354 );
355 Else
356 --
357 -- We are doing a datetrack 'INSERT' which is illegal within this
358 -- procedure therefore we must error (note: to lck on insert the
359 -- private procedure ins_lck should be called).
360 --
361 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
362 fnd_message.set_token('PROCEDURE', l_proc);
363 fnd_message.set_token('STEP','20');
364 fnd_message.raise_error;
365 End If;
366 --
367 -- Set the validation start and end date OUT arguments
368 --
369 p_validation_start_date := l_validation_start_date;
370 p_validation_end_date := l_validation_end_date;
371 --
372 hr_utility.set_location(' Leaving:'||l_proc, 30);
373 --
374 -- We need to trap the ORA LOCK exception
375 --
376 Exception
377 When HR_Api.Object_Locked then
378 --
379 -- The object is locked therefore we need to supply a meaningful
380 -- error message.
381 --
382 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
383 fnd_message.set_token('TABLE_NAME', 'ff_globals_f');
384 fnd_message.raise_error;
385 End lck;
386 --
387 -- ----------------------------------------------------------------------------
388 -- |-----------------------------< convert_args >-----------------------------|
389 -- ----------------------------------------------------------------------------
390 Function convert_args
391 (p_global_id in number
392 ,p_effective_start_date in date
393 ,p_effective_end_date in date
394 ,p_business_group_id in number
395 ,p_legislation_code in varchar2
396 ,p_data_type in varchar2
397 ,p_global_name in varchar2
398 ,p_global_description in varchar2
399 ,p_global_value in varchar2
400 ,p_object_version_number in number
401 )
402 Return g_rec_type is
403 --
404 l_rec g_rec_type;
405 --
406 Begin
407 --
408 -- Convert arguments into local l_rec structure.
409 --
410 l_rec.global_id := p_global_id;
411 l_rec.effective_start_date := p_effective_start_date;
412 l_rec.effective_end_date := p_effective_end_date;
413 l_rec.business_group_id := p_business_group_id;
414 l_rec.legislation_code := p_legislation_code;
415 l_rec.data_type := p_data_type;
416 l_rec.global_name := p_global_name;
417 l_rec.global_description := p_global_description;
418 l_rec.global_value := p_global_value;
419 l_rec.object_version_number := p_object_version_number;
420 --
421 -- Return the plsql record structure.
422 --
423 Return(l_rec);
424 --
425 End convert_args;
426 --
427 end ff_fgl_shd;