[Home] [Help]
PACKAGE BODY: APPS.FF_FUNCTIONS_API
Source
1 Package Body FF_FUNCTIONS_API as
2 /* $Header: ffffnapi.pkb 120.0 2005/05/27 23:23:16 appldev noship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := ' FF_FUNCTIONS_API.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |--------------------------< CREATE_FUNCTION >-----------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure CREATE_FUNCTION
13 (p_validate in boolean default false
14 ,p_effective_date in date
15 ,p_name in varchar2
16 ,p_class in varchar2
17 ,p_business_group_id in number default null
18 ,p_legislation_code in varchar2 default null
19 ,p_alias_name in varchar2 default null
20 ,p_data_type in varchar2 default null
21 ,p_definition in varchar2 default null
22 ,p_description in varchar2 default null
23 ,p_function_id out nocopy number
24 ,p_object_version_number out nocopy number
25 ) is
26 --
27 -- Declare cursors and local variables
28 --
29 l_function_id ff_functions.function_id%type;
30 l_object_version_number ff_functions.object_version_number%type;
31 l_effective_date date;
32 l_proc varchar2(72) := g_package||'CREATE_FUNCTION';
33 begin
34 hr_utility.set_location('Entering:'|| l_proc, 10);
35 --
36 -- Issue a savepoint
37 --
38 savepoint CREATE_FUNCTION;
39 --
40 -- Remember IN OUT parameter IN values
41 --
42 -- Truncate the time portion from all IN date parameters
43 --
44 l_effective_date := trunc(p_effective_date);
45
46 --
47 -- Call Before Process User Hook
48 --
49 begin
50 FF_FUNCTIONS_BK1.CREATE_FUNCTION_b
51 (p_effective_date => l_effective_date
52 ,p_name => p_name
53 ,p_class => p_class
54 ,p_business_group_id => p_business_group_id
55 ,p_legislation_code => p_legislation_code
56 ,p_alias_name => p_alias_name
57 ,p_data_type => p_data_type
58 ,p_definition => p_definition
59 ,p_description => p_description
60 );
61 exception
62 when hr_api.cannot_find_prog_unit then
63 hr_api.cannot_find_prog_unit_error
64 (p_module_name => 'CREATE_FUNCTION'
65 ,p_hook_type => 'BP'
66 );
67 end;
68 --
69 -- Validation in addition to Row Handlers
70 --
71
72
73
74 --
75 -- Process Logic
76 --
77 ff_ffn_ins.ins
78 (p_effective_date => l_effective_date
79 ,p_name => p_name
80 ,p_class => p_class
81 ,p_business_group_id => p_business_group_id
82 ,p_legislation_code => p_legislation_code
83 ,p_alias_name => p_alias_name
84 ,p_data_type => p_data_type
85 ,p_definition => p_definition
86 ,p_description => p_description
87 ,p_function_id => l_function_id
88 ,p_object_version_number => l_object_version_number
89 );
90
91
92 --
93 -- Call After Process User Hook
94 --
95 begin
96 FF_FUNCTIONS_BK1.CREATE_FUNCTION_a
97 (p_effective_date => l_effective_date
98 ,p_name => p_name
99 ,p_class => p_class
100 ,p_business_group_id => p_business_group_id
101 ,p_legislation_code => p_legislation_code
102 ,p_alias_name => p_alias_name
103 ,p_data_type => p_data_type
104 ,p_definition => p_definition
105 ,p_description => p_description
106 ,p_function_id => l_function_id
107 ,p_object_version_number => l_object_version_number
108 );
109 exception
110 when hr_api.cannot_find_prog_unit then
111 hr_api.cannot_find_prog_unit_error
112 (p_module_name => 'CREATE_FUNCTION'
113 ,p_hook_type => 'AP'
114 );
115 end;
116 --
117 -- When in validation only mode raise the Validate_Enabled exception
118 --
119 if p_validate then
120 raise hr_api.validate_enabled;
121 end if;
122 --
123 -- Set all IN OUT and OUT parameters with out values
124 --
125 p_function_id := l_function_id;
126 p_object_version_number := l_object_version_number;
127 --
128 hr_utility.set_location(' Leaving:'||l_proc, 70);
129 exception
130 when hr_api.validate_enabled then
131 --
132 -- As the Validate_Enabled exception has been raised
133 -- we must rollback to the savepoint
134 --
135 rollback to CREATE_FUNCTION;
136 --
137 -- Reset IN OUT parameters and set OUT parameters
138 -- (Any key or derived arguments must be set to null
139 -- when validation only mode is being used.)
140 --
141 p_function_id := null;
142 p_object_version_number := null;
143
144 hr_utility.set_location(' Leaving:'||l_proc, 80);
145 when others then
146 --
147 -- A validation or unexpected error has occured
148 --
149 rollback to CREATE_FUNCTION;
150 --
151 -- Reset IN OUT parameters and set all
152 -- OUT parameters, including warnings, to null
153 --
154 p_function_id := null;
155 p_object_version_number := null;
156
157 hr_utility.set_location(' Leaving:'||l_proc, 90);
158 raise;
159 end CREATE_FUNCTION;
160 --
161
162 -- ----------------------------------------------------------------------------
163 -- |--------------------------< UPDATE_FUNCTION >-----------------------------|
164 -- ----------------------------------------------------------------------------
165 --
166 procedure UPDATE_FUNCTION
167 (p_validate in boolean default false
168 ,p_effective_date in date
169 ,p_function_id in number
170 ,p_object_version_number in out nocopy number
171 ,p_name in varchar2 default hr_api.g_varchar2
172 ,p_class in varchar2 default hr_api.g_varchar2
173 ,p_alias_name in varchar2 default hr_api.g_varchar2
174 ,p_data_type in varchar2 default hr_api.g_varchar2
175 ,p_definition in varchar2 default hr_api.g_varchar2
176 ,p_description in varchar2 default hr_api.g_varchar2
177 ) is
178 --
179 -- Declare cursors and local variables
180 --
181 l_object_version_number ff_functions.object_version_number%type;
182 l_effective_date date;
183 l_proc varchar2(72) := g_package||'UPDATE_FUNCTION';
184 begin
185 hr_utility.set_location('Entering:'|| l_proc, 10);
186 --
187 -- Issue a savepoint
188 --
189 savepoint UPDATE_FUNCTION;
190 --
191 -- Remember IN OUT parameter IN values
192 --
193 l_object_version_number := p_object_version_number;
194
195 --
196 -- Truncate the time portion from all IN date parameters
197 --
198 l_effective_date := trunc(p_effective_date);
199
200 --
201 -- Call Before Process User Hook
202 --
203 begin
204 FF_FUNCTIONS_BK2.UPDATE_FUNCTION_b
205 (p_effective_date => l_effective_date
206 ,p_function_id => p_function_id
207 ,p_object_version_number => l_object_version_number
208 ,p_name => p_name
209 ,p_class => p_class
210 ,p_alias_name => p_alias_name
211 ,p_data_type => p_data_type
212 ,p_definition => p_definition
213 ,p_description => p_description
214 );
215 exception
216 when hr_api.cannot_find_prog_unit then
217 hr_api.cannot_find_prog_unit_error
218 (p_module_name => 'UPDATE_FUNCTION'
219 ,p_hook_type => 'BP'
220 );
221 end;
222 --
223 -- Validation in addition to Row Handlers
224 --
225
226
227
228 --
229 -- Process Logic
230 --
231 ff_ffn_upd.upd
232 (p_effective_date => l_effective_date
233 ,p_function_id => p_function_id
234 ,p_object_version_number => l_object_version_number
235 ,p_name => p_name
236 ,p_class => p_class
237 -- ,p_business_group_id => hr_api.g_number
238 -- ,p_legislation_code => hr_api.g_varchar2
239 ,p_alias_name => p_alias_name
240 ,p_data_type => p_data_type
241 ,p_definition => p_definition
242 ,p_description => p_description
243 );
244
245
246 --
247 -- Call After Process User Hook
248 --
249 begin
250 FF_FUNCTIONS_BK2.UPDATE_FUNCTION_a
251 (p_effective_date => l_effective_date
252 ,p_function_id => p_function_id
253 ,p_object_version_number => l_object_version_number
254 ,p_name => p_name
255 ,p_class => p_class
256 ,p_alias_name => p_alias_name
257 ,p_data_type => p_data_type
258 ,p_definition => p_definition
259 ,p_description => p_description
260 );
261 exception
262 when hr_api.cannot_find_prog_unit then
263 hr_api.cannot_find_prog_unit_error
264 (p_module_name => 'UPDATE_FUNCTION'
265 ,p_hook_type => 'AP'
266 );
267 end;
268 --
269 -- When in validation only mode raise the Validate_Enabled exception
270 --
271 if p_validate then
272 raise hr_api.validate_enabled;
273 end if;
274 --
275 -- Set all IN OUT and OUT parameters with out values
276 --
277 p_object_version_number := l_object_version_number;
278 --
279 hr_utility.set_location(' Leaving:'||l_proc, 70);
280 exception
281 when hr_api.validate_enabled then
282 --
283 -- As the Validate_Enabled exception has been raised
284 -- we must rollback to the savepoint
285 --
286 rollback to UPDATE_FUNCTION;
287 --
288 -- Reset IN OUT parameters and set OUT parameters
289 -- (Any key or derived arguments must be set to null
290 -- when validation only mode is being used.)
291 --
292 p_object_version_number := null;
293
294 hr_utility.set_location(' Leaving:'||l_proc, 80);
295 when others then
296 --
297 -- A validation or unexpected error has occured
298 --
299 rollback to UPDATE_FUNCTION;
300 --
301 -- Reset IN OUT parameters and set all
302 -- OUT parameters, including warnings, to null
303 --
304 p_object_version_number := null;
305
306 hr_utility.set_location(' Leaving:'||l_proc, 90);
307 raise;
308 end UPDATE_FUNCTION;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |--------------------------< DELETE_FUNCTION >--------------------------|
312 -- ----------------------------------------------------------------------------
313 --
314 procedure DELETE_FUNCTION
315 (p_validate in boolean default false
316 ,p_function_id in number
317 ,p_object_version_number in number
318 ) is
319 --
320 -- Declare cursors and local variables
321 --
322 cursor csr_function_context is
323 select function_id
324 ,sequence_number
325 ,object_version_number
326 from ff_function_context_usages
327 where function_id = p_function_id;
328
329 cursor csr_function_parameter
330 is
331 select function_id
332 ,sequence_number
333 ,object_version_number
334 from ff_function_parameters
335 where function_id = p_function_id;
336
337 l_function_id ff_functions.function_id%type;
338 l_context_sequence_number ff_function_context_usages.sequence_number%type;
339 l_context_ovn ff_function_context_usages.object_version_number%type;
340 l_parameter_sequence_number ff_function_parameters.sequence_number%type;
341 l_parameter_ovn ff_function_parameters.object_version_number%type;
342 l_proc varchar2(72) := g_package||'DELETE_FUNCTION';
343 begin
344 hr_utility.set_location('Entering:'|| l_proc, 10);
345 --
346 -- Issue a savepoint
347 --
348 savepoint DELETE_FUNCTION;
349 --
350 -- Remember IN OUT parameter IN values
351 --
352 --
353 -- Truncate the time portion from all IN date parameters
354 --
355
356 --
357 -- Call Before Process User Hook
358 --
359 begin
360 FF_FUNCTIONS_BK3.DELETE_FUNCTION_b
361 ( p_function_id => p_function_id
362 ,p_object_version_number => p_object_version_number
363 );
364 exception
365 when hr_api.cannot_find_prog_unit then
366 hr_api.cannot_find_prog_unit_error
367 (p_module_name => 'DELETE_FUNCTION'
368 ,p_hook_type => 'BP'
369 );
370 end;
371 --
372 -- Validation in addition to Row Handlers
373 --
374 -- delete all context usages for this function before deleting function
375 --
376 open csr_function_context;
377 loop
378 fetch csr_function_context into l_function_id
379 ,l_context_sequence_number
380 ,l_context_ovn;
381 exit when csr_function_context%notfound;
382 FF_FUNCTION_CONTEXT_USG_API.DELETE_CONTEXT
383 (p_validate => p_validate
384 ,p_function_id => l_function_id
385 ,p_sequence_number => l_context_sequence_number
386 ,p_object_version_number => l_context_ovn
387 );
388 end loop;
389 close csr_function_context;
390
391 -- delete all parameter for this function before deleting function
392 --
393 open csr_function_parameter;
394 loop
395 fetch csr_function_parameter into l_function_id
396 ,l_parameter_sequence_number
397 ,l_parameter_ovn;
398 exit when csr_function_parameter%notfound;
399 FF_FUNCTION_PARAMETERS_API.DELETE_PARAMETER
400 (p_validate => p_validate
401 ,p_function_id => l_function_id
402 ,p_sequence_number => l_parameter_sequence_number
403 ,p_object_version_number => l_parameter_ovn
404 );
405 end loop;
406 close csr_function_parameter;
407
408 --
409 -- Process Logic
410 --
411
412 ff_ffn_del.del
413 ( p_function_id => p_function_id
414 ,p_object_version_number => p_object_version_number
415 );
416
417
418 --
419 -- Call After Process User Hook
420 --
421 begin
422 FF_FUNCTIONS_BK3.DELETE_FUNCTION_a
423 ( p_function_id => p_function_id
424 ,p_object_version_number => p_object_version_number
425 );
426 exception
427 when hr_api.cannot_find_prog_unit then
428 hr_api.cannot_find_prog_unit_error
429 (p_module_name => 'DELETE_FUNCTION'
430 ,p_hook_type => 'AP'
431 );
432 end;
433 --
434 -- When in validation only mode raise the Validate_Enabled exception
435 --
436 if p_validate then
437 raise hr_api.validate_enabled;
438 end if;
439 --
440 -- Set all IN OUT and OUT parameters with out values
441 --
442 --
443 hr_utility.set_location(' Leaving:'||l_proc, 70);
444 exception
445 when hr_api.validate_enabled then
446 --
447 -- As the Validate_Enabled exception has been raised
448 -- we must rollback to the savepoint
449 --
450 rollback to DELETE_FUNCTION;
451 --
452 -- Reset IN OUT parameters and set OUT parameters
453 -- (Any key or derived arguments must be set to null
454 -- when validation only mode is being used.)
455 --
456 hr_utility.set_location(' Leaving:'||l_proc, 80);
457 when others then
458 --
459 -- A validation or unexpected error has occured
460 --
461 rollback to DELETE_FUNCTION;
462 --
463 -- Reset IN OUT parameters and set all
464 -- OUT parameters, including warnings, to null
465 --
466 hr_utility.set_location(' Leaving:'||l_proc, 90);
467 raise;
468 end DELETE_FUNCTION;
469 --
470
471 end FF_FUNCTIONS_API;