DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_CFV_BUS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ame_cfv_bus as
2 /* $Header: amcfvrhi.pkb 120.2 2005/11/22 03:15 santosin noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ame_cfv_bus.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |-------------------------< CHK_NONUPD_VARIABLE_VALUES >------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure checks whether a variable value is updateable or not.Certain variables
17 --   cannot be reverted back to their previous value, once they have been set to a particular
18 --   value(Max Value).
19 --
20 -- Pre-Requisites:
21 --   None
22 --
23 -- In Parameters:
24 --   p_application_id
25 --   p_effective_date
26 --   p_variable_name
27 --   p_variable_value
28 --
29 -- Post Success:
30 --   Processing continues if a valid operation is performed on the variable.
31 --
32 -- Post Failure:
33 --   An application error is raised if the operation is not valid for the variable.
34 --
35 -- Access Status:
36 --   Internal Row Handler Use Only.
37 --
38 -- {End Of Comments}
39 -- ----------------------------------------------------------------------------
40 procedure chk_nonupd_variable_values(p_application_id                 in   number
41 				   ,p_effective_date                  in   date
42 				   ,p_variable_name                   in   varchar2
43 				   ,p_variable_value		      in   varchar2
44 		                    ) IS
45 --
46     cursor csr_variable_value(p_csr_application_id in number,p_csr_variable_name in varchar2) is
47          select variable_value
48            from ame_config_vars
49           where application_id=p_csr_application_id
50 	    and variable_name=p_csr_variable_name
51             and p_effective_date between start_date
52                   and nvl(end_date - ame_util.oneSecond, p_effective_date);
53   l_proc     varchar2(72) := g_package || 'chk_nonupdateable_variable_values';
54   l_oldVal   ame_config_vars.variable_value%TYPE;
55 --
56   Begin
57     hr_utility.set_location('Entering:'||l_proc,10);
58     --
59     if(p_variable_name = 'allowAllApproverTypes' or p_variable_name = 'allowAllItemClassRules' or p_variable_name = 'allowFyiNotifications') then
60       open csr_variable_value(p_application_id,p_variable_name);
61       fetch csr_variable_value into l_oldVal;
62       if(csr_variable_value%notfound) then
63 	close csr_variable_value;
64 	open csr_variable_value(0,p_variable_name);
65 	fetch csr_variable_value into l_oldVal;
66       end if;
67       close csr_variable_value;
68       if(l_oldVal = 'yes' and (p_variable_value is null or p_variable_value <> 'yes')) then
69         fnd_message.set_name('PER', 'AME_400653_CFV_NONUPD_VAL_YN');
70 	fnd_message.set_token('VARNAME',p_variable_name);
71         fnd_message.raise_error;
72       end if;
73     elsif(p_variable_name = 'productionFunctionality') then
77 	close csr_variable_value;
74       open csr_variable_value(p_application_id,p_variable_name);
75       fetch csr_variable_value into l_oldVal;
76       if(csr_variable_value%notfound) then
78 	open csr_variable_value(0,p_variable_name);
79 	fetch csr_variable_value into l_oldVal;
80       end if;
81       close csr_variable_value;
82       if(l_oldVal = 'all'  and (p_variable_value is null or p_variable_value <> 'all')) then
83         fnd_message.set_name('PER', 'AME_400654_CFV_NONUPD_VAL_PF');
84 	fnd_message.set_token('VARNAME',p_variable_name);
85         fnd_message.raise_error;
86       end if;
87     end if;
88     hr_utility.set_location(' Leaving:'||l_proc,30);
89   exception
90     when app_exception.application_exception then
91       if hr_multi_message.exception_add
92                        (p_associated_column1 => 'AME_CONFIG_VARS.APPLICATION_ID'
93                        ) then
94         hr_utility.set_location(' Leaving:'||l_proc, 40);
95         raise;
96       end if;
97       hr_utility.set_location(' Leaving:'||l_proc,50);
98   End chk_nonupd_variable_values;
99   --
100 
101 --
102 -- ----------------------------------------------------------------------------
103 -- |-------------------------< CHK_APPLICATION_ID >---------------------------|
104 -- ----------------------------------------------------------------------------
105 -- {Start Of Comments}
106 --
107 -- Description:
108 --   This procedure checks whether a valid default value already exists for the
109 --   configuration variable being populated.
110 --
111 -- Pre-Requisites:
112 --   None
113 --
114 -- In Parameters:
115 --   p_application_id
116 --   p_effective_date
117 --
118 -- Post Success:
119 --   Processing continues if a valid default configuration variable is found.
120 --
121 -- Post Failure:
122 --   An application error is raised if a default value has not been defined
123 --   for the configuration variable.
124 --
125 -- Access Status:
126 --   Internal Row Handler Use Only.
127 --
128 -- {End Of Comments}
129 -- ----------------------------------------------------------------------------
130 procedure chk_application_id(p_application_id                  in   number
131                             ,p_effective_date                  in   date
132                             ) IS
133 --
134     cursor csr_application is
135          select 1
136            from ame_calling_apps
137           where application_id=p_application_id
138             and p_effective_date between start_date
139                   and nvl(end_date - ame_util.oneSecond, p_effective_date);
140   l_proc     varchar2(72) := g_package || 'CHK_APPLICATION_ID';
141   l_key      number;
142 --
143   Begin
144     hr_utility.set_location('Entering:'||l_proc,10);
145     --
146     if(p_application_id <> ame_utility_pkg.defaultAmeAppId) then
147       open csr_application;
148       fetch csr_application into l_key;
149       if(csr_application%notfound) then
150         fnd_message.set_name('PER', 'AME_400474_INV_APPLICATION_ID');
151         fnd_message.raise_error;
152       end if;
153       close csr_application;
154     end if;
155     hr_utility.set_location(' Leaving:'||l_proc,30);
156   exception
157     when app_exception.application_exception then
158       if hr_multi_message.exception_add
159                        (p_associated_column1 => 'AME_CONFIG_VARS.APPLICATION_ID'
160                        ) then
164       hr_utility.set_location(' Leaving:'||l_proc,50);
161         hr_utility.set_location(' Leaving:'||l_proc, 40);
162         raise;
163       end if;
165   End chk_application_id;
166   --
167 --
168 -- ----------------------------------------------------------------------------
169 -- |-------------------------< CHK_DEFAULT_CONFIG_VAR >----------------------|
170 -- ----------------------------------------------------------------------------
171 -- {Start Of Comments}
172 --
173 -- Description:
174 --   This procedure checks if the application_id = 0 (i.e the default value of the
175 --   configuration variable).This check is performed before the deletion of a
176 --   configuration variable value.
177 --
178 -- Pre-Requisites:
179 --   None
180 --
181 -- In Parameters:
182 --   p_application_id
183 --   p_effective_date
184 --
185 -- Post Success:
186 --   Processing continues if the application_id is not equal to zero i.e
187 --   the value is not the default value of the configuration variable.
188 --
189 -- Post Failure:
190 --   An application error is raised if an attempt is made to delete the
191 --   default value of the configuration variable.
192 --
193 -- Access Status:
194 --   Internal Row Handler Use Only.
195 --
196 -- {End Of Comments}
197 -- ----------------------------------------------------------------------------
198 procedure chk_default_config_var(p_application_id                  in   number
199                                 ,p_effective_date                  in   date
200                                  ) IS
201 --
202   l_proc     varchar2(72) := g_package || 'CHK_DEFAULT_CONFIG_VAR';
203 --
204   Begin
205     hr_utility.set_location('Entering:'||l_proc,10);
206     --
207     if p_application_id = 0 then
208       fnd_message.set_name('PER', 'AME_400773_DEF_CONFIG_DEL');
209       fnd_message.raise_error;
210     end if;
211   exception
212     when app_exception.application_exception then
213       if hr_multi_message.exception_add
214                        (p_associated_column1 => 'AME_CONFIG_VARS.APPLICATION_ID'
215                        ) then
216         hr_utility.set_location(' Leaving:'||l_proc, 40);
217         raise;
218       end if;
219       hr_utility.set_location(' Leaving:'||l_proc,50);
220   End chk_default_config_var;
221   --
222 
223 --
224 -- ----------------------------------------------------------------------------
225 -- |-------------------------< CHK_VARIABLE_NAME >----------------------------|
226 -- ----------------------------------------------------------------------------
227 -- {Start Of Comments}
228 --
229 -- Description:
230 --   This procedure checks whether the Variable Name entered is a valid one.
231 --
232 -- Pre-Requisites:
233 --   None
234 --
235 -- In Parameters:
236 --   p_variable_name
237 --
238 -- Post Success:
239 --   Processing continues if a valid Variable Name has been entered.
240 --
241 -- Post Failure:
242 --   An application error is raised if the Variable Name is undefined.
243 --
244 -- Access Status:
245 --   Internal Row Handler Use Only.
246 --
247 -- {End Of Comments}
248 -- ----------------------------------------------------------------------------
249 procedure chk_variable_name(p_variable_name                  in   varchar2) IS
250 --
251   cursor csr_var_name(p_var_name varchar2) is
252        select 'Y'
253          from ame_config_vars
254         where variable_name = p_var_name
255           and application_id = ame_utility_pkg.defaultAmeAppId;
256   l_proc     varchar2(72) := g_package || 'CHK_VARIABLE_NAME';
257   l_key      varchar2(1);
258 --
259   Begin
260     hr_utility.set_location('Entering:'||l_proc,10);
261     hr_api.mandatory_arg_error(p_api_name           => l_proc
262                               ,p_argument           => 'VARIABLE_NAME'
263                               ,p_argument_value     => p_variable_name
264                               );
265     --
266     -- Check if the varible name is one of the pre-defined name.
267     --
268     open csr_var_name(p_variable_name);
272       fnd_message.set_name('PER', 'AME_400657_CFV_INV_VAR_NAME');
269     fetch csr_var_name into l_key;
270     if(csr_var_name%notfound) then
271       close csr_var_name;
273       fnd_message.raise_error;
274     else
275       close csr_var_name;
276     end if;
277     hr_utility.set_location(' Leaving:'||l_proc,30);
278   exception
279     when app_exception.application_exception then
280       if hr_multi_message.exception_add
281                        (p_associated_column1 => 'AME_CONFIG_VARS.VARIABLE_NAME'
282                        ) then
283         hr_utility.set_location(' Leaving:'||l_proc, 40);
284         raise;
285       end if;
286       hr_utility.set_location(' Leaving:'||l_proc,50);
287   End chk_variable_name;
288   --
289 --
290 -- ----------------------------------------------------------------------------
291 -- |------------------< ISVALID_FORWARDING_BEHAVIOUR >------------------------|
292 -- ----------------------------------------------------------------------------
293 -- {Start Of Comments}
294 --
295 -- Description:
296 --   This procedure checks whether the value entered for the configuration
297 --   variable 'forwardingBehaviors' is valid and in the right format or not.
298 --
299 -- Pre-Requisites:
300 --   None
301 --
302 -- In Parameters:
303 --   p_value
304 --
305 -- Post Success:
306 --   Processing continues if a valid 'forwardingBehaviors' value has been
307 --   entered.
308 --
309 -- Post Failure:
310 --   An application error is raised if the value is not in the correct format.
311 --
312 -- Access Status:
313 --   Internal Row Handler Use Only.
314 --
315 -- {End Of Comments}
316 -- ----------------------------------------------------------------------------
317 function isValid_Forwarding_Behaviour(p_value                    in   varchar2)
318 Return Boolean IS
319 --
320   type profile_values is table of varchar2(20) index by binary_integer;
321   l_proc                  varchar2(72) := g_package || 'ISVALID_FORWARDING_BEHAVIOUR';
322   l_index                 number :=1;
323   l_location              number :=1;
324   l_count                 number :=0;
325   AME_FWD_PRV_SAME_CHAIN     profile_values;
326   AME_FWD_SUB_NOT_SAME_CHAIN profile_values;
327   AME_ADHOC_FWD              profile_values;
328   AME_BEHAVIOUR_VALUES       profile_values;
329   function isExist(p_value                     in   varchar2
330                   ,value_table                 in   profile_values
331                   ) return boolean is
332     isFound         boolean := false;
333     begin
334     for indx in 1..value_table.count
335     loop
336       if(value_table(indx) = p_value) then
337         isFound :=  true;
338       end if;
339     end loop;
340     return isFound;
341     end;
342 --
343   Begin
344     hr_utility.set_location('Entering:'||l_proc,10);
345     --
346     -- Populate the Profile Value Tables.
347     --
348     AME_FWD_PRV_SAME_CHAIN(1) := 'REMAND';
349     AME_FWD_PRV_SAME_CHAIN(2) := 'FORWARDER_FORWARDEE';
350     AME_FWD_PRV_SAME_CHAIN(3) := 'FORWARDEE_ONLY';
351     AME_FWD_PRV_SAME_CHAIN(4) := 'IGNORE';
352     AME_FWD_SUB_NOT_SAME_CHAIN(1) := 'FORWARDER_FORWARDEE';
353     AME_FWD_SUB_NOT_SAME_CHAIN(2) := 'FORWARDEE_ONLY';
354     AME_FWD_SUB_NOT_SAME_CHAIN(3) := 'REPEAT_FORWARDER';
355     AME_FWD_SUB_NOT_SAME_CHAIN(4) := 'SKIP_FORWARDER';
356     AME_FWD_SUB_NOT_SAME_CHAIN(5) := 'IGNORE';
357     AME_ADHOC_FWD(1) := 'FORWARDER_FORWARDEE';
358     AME_ADHOC_FWD(2) := 'FORWARDEE_ONLY';
359     AME_ADHOC_FWD(3) := 'IGNORE';
360     --
361     -- Split the incoming values into 8 subparts.
362     --
363     while(l_index <> 0)
364     loop
365     l_index := instrb(p_value||':',':',l_location);
366     l_count := l_count+1;
367     AME_BEHAVIOUR_VALUES(l_count) := substr(p_value,l_location,l_index-l_location);
368     l_location:=l_index+1;
369     end loop;
370     AME_BEHAVIOUR_VALUES.delete(l_count);
371     l_count := l_count -1;
372     --
373     -- If total parameter count is not 8, then error has occurred.
374     --
375     if(l_count <> 8) then
376       fnd_message.set_name('PER', 'AME_400658_CFV_INV_NUM_PRM');
377       fnd_message.raise_error;
378     end if;
379     --
380     -- Check for the values in respective profile value tables.
381     --
382     if not isExist(AME_BEHAVIOUR_VALUES(1),AME_FWD_PRV_SAME_CHAIN) then
383       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
384       fnd_message.set_token('PARAMNUM',1);
385       fnd_message.raise_error;
386     end if;
387     if not isExist(AME_BEHAVIOUR_VALUES(2),AME_FWD_PRV_SAME_CHAIN) then
388       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
389       fnd_message.set_token('PARAMNUM',2);
390       fnd_message.raise_error;
391     end if;
392     if not isExist(AME_BEHAVIOUR_VALUES(3),AME_FWD_SUB_NOT_SAME_CHAIN) then
393       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
394       fnd_message.set_token('PARAMNUM',3);
395       fnd_message.raise_error;
396     end if;
397     if not isExist(AME_BEHAVIOUR_VALUES(4),AME_FWD_SUB_NOT_SAME_CHAIN) then
398       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
399       fnd_message.set_token('PARAMNUM',4);
400       fnd_message.raise_error;
401     end if;
402     if not isExist(AME_BEHAVIOUR_VALUES(5),AME_FWD_PRV_SAME_CHAIN) then
403       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
404       fnd_message.set_token('PARAMNUM',5);
405       fnd_message.raise_error;
406     end if;
407     if not isExist(AME_BEHAVIOUR_VALUES(6),AME_FWD_PRV_SAME_CHAIN) then
408       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
409       fnd_message.set_token('PARAMNUM',6);
413       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
410       fnd_message.raise_error;
411     end if;
412     if not isExist(AME_BEHAVIOUR_VALUES(7),AME_ADHOC_FWD) then
414       fnd_message.set_token('PARAMNUM',7);
415       fnd_message.raise_error;
416     end if;
417     if not isExist(AME_BEHAVIOUR_VALUES(8),AME_ADHOC_FWD) then
418       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
419       fnd_message.set_token('PARAMNUM',8);
420       fnd_message.raise_error;
421     end if;
422     hr_utility.set_location(' Leaving:'||l_proc,30);
423     return true;
424   exception
425     when app_exception.application_exception then
426       if hr_multi_message.exception_add
427                        (p_associated_column1 => 'AME_CONFIG_VARS.FORWARDING_BEHAVIOUR'
428                        ) then
429         hr_utility.set_location(' Leaving:'||l_proc, 40);
430         raise;
431       end if;
432       hr_utility.set_location(' Leaving:'||l_proc,50);
433       return false;
434   End isValid_Forwarding_Behaviour;
435   --
436 --
437 -- ----------------------------------------------------------------------------
438 -- |------------------< ISVALID_RULE_PRIORITY_MODE >--------------------------|
439 -- ----------------------------------------------------------------------------
440 -- {Start Of Comments}
441 --
442 -- Description:
443 --   This procedure checks whether the value entered for the configuration
444 --   variable 'rulePriorityModes' is valid and in the specified format or not.
445 --
446 -- Pre-Requisites:
447 --   None
448 --
449 -- In Parameters:
450 --   p_value
451 --
452 -- Post Success:
453 --   Processing continues if a valid 'rulePriorityModes' value has been
454 --   entered.
455 --
456 -- Post Failure:
457 --   An application error is raised if the value is not in the correct format.
458 --
459 -- Access Status:
460 --   Internal Row Handler Use Only.
461 --
462 -- {End Of Comments}
463 -- ----------------------------------------------------------------------------
464 function isValid_Rule_Priority_Mode(p_value                     in   varchar2)
465 Return Boolean IS
466 --
467   l_proc                  varchar2(72) := g_package || 'ISVALID_RULE_PRIORITY_MODE';
468   l_index                 number :=1;
469   l_location              number :=1;
470   l_count                 number :=0;
471   l_priority              varchar2(20);
472 --
473   Begin
474     hr_utility.set_location('Entering:'||l_proc,10);
475     --
476     -- Split the incoming values into 8 subparts.
477     --
478     loop
479     l_index := instrb(p_value||':',':',l_location);
480     exit when (l_index = 0);
481     l_count := l_count+1;
482     l_priority := substr(p_value,l_location,l_index-l_location);
483     if (l_priority is null or l_priority = '' or (l_priority <> 'disabled' and
484          substr(l_priority,1,instr(l_priority,'_')) not in ('absolute_','relative_'))) then
485       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
486       fnd_message.set_token('PARAMNUM',l_count);
487       fnd_message.raise_error;
488     end if;
489     if not((l_priority = 'disabled')
490     or (
491        (substr(l_priority,1,instr(l_priority,'_')) in ('absolute_'
492                                                        ,'relative_'
493                                                        ))
494         and
495        (ame_util.isANonNegativeInteger(substr(l_priority,instr(l_priority,'_')+1)))
496         and
497        (substr(l_priority,instr(l_priority,'_')+1)<>'0')
498        ))then
499       fnd_message.set_name('PER', 'AME_400659_CFV_INV_PARAM');
500       fnd_message.set_token('PARAMNUM',l_count);
501       fnd_message.raise_error;
502     end if;
503     l_location:=l_index+1;
504     end loop;
505     --
506     -- If total parameter count is not 8, then error has occurred.
507     --
508     if(l_count <> 8) then
509       fnd_message.set_name('PER', 'AME_400660_CFV_INV_PRIORITY');
510       fnd_message.raise_error;
511     end if;
512     hr_utility.set_location(' Leaving:'||l_proc,30);
513     return true;
514   exception
515     when app_exception.application_exception then
516       if hr_multi_message.exception_add
517                        (p_associated_column1 => 'AME_CONFIG_VARS.PRIORITY_MODE'
518                        ) then
519         hr_utility.set_location(' Leaving:'||l_proc, 40);
520         raise;
521       end if;
522       hr_utility.set_location(' Leaving:'||l_proc,50);
523       return false;
524   End isValid_Rule_Priority_Mode;
525   --
526 --
527 -- ----------------------------------------------------------------------------
528 -- |-------------------------< CHK_VARIABLE_VALUE >---------------------------|
529 -- ----------------------------------------------------------------------------
530 -- {Start Of Comments}
531 --
532 -- Description:
533 --   This procedure checks whether the Value entered for the configuration
534 --   variable is valid and in the correct format or not.
535 --
536 -- Pre-Requisites:
537 --   chk_variable_name must have been validated.
538 --
539 -- In Parameters:
540 --   p_variable_name
541 --   p_variable_value
542 --
543 -- Post Success:
544 --   Processing continues if a valid configuration value has been entered.
545 --
546 -- Post Failure:
547 --   An application error is raised if the value entered is not defined or not
548 --   in the specified format.
549 --
550 -- Access Status:
554 -- ----------------------------------------------------------------------------
551 --   Internal Row Handler Use Only.
552 --
553 -- {End Of Comments}
555 procedure chk_variable_value(p_variable_name                  in   varchar2
556                             ,p_variable_value                 in   varchar2
557                             ) IS
558 --
559   cursor csr_role is
560       select 'Y'
561         from wf_roles
562        where name = p_variable_value
563          and status='ACTIVE';
564   l_proc     varchar2(72) := g_package || 'CHK_VARIABLE_VALUE';
565   l_key      varchar2(1);
566 --
567   Begin
568     hr_utility.set_location('Entering:'||l_proc,10);
569     hr_api.mandatory_arg_error(p_api_name           => l_proc
570                               ,p_argument           => 'VARIABLE_VALUE'
571                               ,p_argument_value     => p_variable_value
572                               );
573     --
574     -- Check if the varible value is in appropriate format.
575     --
576     if hr_multi_message.no_all_inclusive_error
577                    (p_check_column1 => 'AME_CONFIG_VARS.VARIABLE_NAME') then
578       if(p_variable_name = 'adminApprover') then
579         open csr_role;
580         fetch csr_role into l_key;
581         if(csr_role%notfound) then
582           close csr_role;
583           fnd_message.set_name('PER', 'AME_400661_CFV_INV_VAL');
584 	  fnd_message.set_token('VARNAME',p_variable_name);
585           fnd_message.raise_error;
586         else
587           close csr_role;
588         end if;
589 
590       elsif(p_variable_name = 'allowAllApproverTypes'
591          or p_variable_name = 'allowAllItemClassRules'
592          or p_variable_name = 'allowFyiNotifications'
593          or p_variable_name = 'distributedEnvironment'
594            ) then
595         if(p_variable_value) not in ('yes','no') then
596           fnd_message.set_name('PER', 'AME_400661_CFV_INV_VAL');
597 	  fnd_message.set_token('VARNAME',p_variable_name);
598           fnd_message.raise_error;
599         end if;
600 
601       elsif(p_variable_name = 'currencyConversionWindow'
602          or p_variable_name = 'purgeFrequency'
603            ) then
604         if (trim(p_variable_value)='0')
605         or not (ame_util.isANonNegativeInteger(p_variable_value))
606            then
607           fnd_message.set_name('PER', 'AME_400662_CFV_NEG_VAL');
608 	  fnd_message.set_token('VARNAME',p_variable_name);
609           fnd_message.raise_error;
610         end if;
611 
612       elsif(p_variable_name = 'forwardingBehaviors') then
613         if not isValid_Forwarding_Behaviour(p_variable_value) then
614           fnd_message.set_name('PER', 'AME_400661_CFV_INV_VAL');
615 	  fnd_message.set_token('VARNAME',p_variable_name);
616           fnd_message.raise_error;
617         end if;
618 
619       /*elsif(p_variable_name = 'helpPath'
620          or p_variable_name = 'htmlPath'
621          or p_variable_name = 'imagePath'
622          or p_variable_name = 'portalUrl'
623            ) then
624       */
625       elsif(p_variable_name = 'productionFunctionality') then
626         if p_variable_value not in ('none'
627                                    ,'approver'
628                                    ,'transaction'
629                                    ,'all'
630                                    ) then
631           fnd_message.set_name('PER', 'AME_400661_CFV_INV_VAL');
632 	  fnd_message.set_token('VARNAME',p_variable_name);
633           fnd_message.raise_error;
634         end if;
635 
636       elsif(p_variable_name = 'repeatedApprovers') then
637         if p_variable_value not in ('ONCE_PER_TRANSACTION'
638                                    ,'ONCE_PER_ITEM_CLASS'
639                                    ,'ONCE_PER_ITEM'
640                                    ,'ONCE_PER_SUBLIST'
641                                    ,'ONCE_PER_ACTION_TYPE'
642                                    ,'ONCE_PER_GROUP_OR_CHAIN'
643                                    ,'EACH_OCCURRENCE'
644                                    ) then
645           fnd_message.set_name('PER', 'AME_400661_CFV_INV_VAL');
646 	  fnd_message.set_token('VARNAME',p_variable_name);
647           fnd_message.raise_error;
648         end if;
649 
650       elsif(p_variable_name = 'rulePriorityModes') then
651         if not isValid_Rule_Priority_Mode(p_variable_value) then
652           fnd_message.set_name('PER', 'AME_400661_CFV_INV_VAL');
653 	  fnd_message.set_token('VARNAME',p_variable_name);
654           fnd_message.raise_error;
655         end if;
656       end if;
657     end if;
661       if hr_multi_message.exception_add
658     hr_utility.set_location(' Leaving:'||l_proc,30);
659   exception
660     when app_exception.application_exception then
662                        (p_associated_column1 => 'AME_CONFIG_VARS.VARIABLE_VALUE'
663                        ) then
664         hr_utility.set_location(' Leaving:'||l_proc, 40);
665         raise;
666       end if;
667       hr_utility.set_location(' Leaving:'||l_proc,50);
668   End chk_variable_value;
669   --
670 --
671 -- ----------------------------------------------------------------------------
672 -- |-------------------< CHK_APPLICATION_VARIABLE_NAME >----------------------|
673 -- ----------------------------------------------------------------------------
674 -- {Start Of Comments}
675 --
676 -- Description:
677 --   This procedure checks whether the configuration variable has already been
678 --   defined, for the given transaction type.
679 --
680 -- Pre-Requisites:
681 --   chk_application_id and chk_variable_name must have been validated.
682 --
683 -- In Parameters:
684 --   p_variable_name
685 --   p_application_id
686 --   p_effective_date
687 --
688 -- Post Success:
689 --   Processing continues if the configuration variable is not being
690 --   duplicated.
691 --
692 -- Post Failure:
693 --   An application error is raised if the configuration variable has already
694 --   been defined.
695 --
696 -- Access Status:
697 --   Internal Row Handler Use Only.
698 --
699 -- {End Of Comments}
700 -- ----------------------------------------------------------------------------
701 procedure chk_application_variable_name(p_variable_name       in   varchar2
702                                        ,p_application_id      in   number
703                                        ,p_effective_date      in   date
704                                        ) IS
705 --
706   cursor csr_var_name is
707        select 'Y'
708          from ame_config_vars
709         where variable_name = p_variable_name
710           and application_id = p_application_id
711           and p_effective_date between start_date
712                 and nvl(end_date - ame_util.oneSecond, p_effective_date);
713   l_proc     varchar2(72) := g_package || 'CHK_VARIABLE_NAME';
714   l_key      varchar2(1);
715 --
716   Begin
717     hr_utility.set_location('Entering:'||l_proc,10);
718     if (hr_multi_message.no_all_inclusive_error
719                    (p_check_column1 => 'AME_CONFIG_VARS.VARIABLE_NAME')
720     and hr_multi_message.no_all_inclusive_error
721                    (p_check_column1 => 'AME_CONFIG_VARS.APPLICATION_ID')) then
722       --
723       -- Check if the varible name is already defined for the application.
724       --
725       if(p_application_id <> ame_utility_pkg.defaultAmeAppId) then
726         --
727         -- Check if a non-overridable config variable has been overridden.
728         --
729         if p_variable_name in ('distributedEnvironment'
730                               ,'helpPath'
731                               ,'htmlPath'
732                               ,'imagePath'
733                               ,' portalUrl'
734                               ) then
735           fnd_message.set_name('PER', 'AME_400655_INV_NO_TT_VAL');
736           fnd_message.raise_error;
737         end if;
738         open csr_var_name;
739         fetch csr_var_name into l_key;
740         if(csr_var_name%found) then
741           close csr_var_name;
742           fnd_message.set_name('PER', 'AME_400656_DUP_VAR_VAL');
743 	  fnd_message.set_token('VARNAME',p_variable_name);
744           fnd_message.raise_error;
745         else
749         open csr_var_name;
746           close csr_var_name;
747         end if;
748       else
750         fetch csr_var_name into l_key;
751         if(csr_var_name%found) then
752           close csr_var_name;
753           fnd_message.set_name('PER', 'AME_400656_DUP_VAR_VAL');
754 	  fnd_message.set_token('VARNAME',p_variable_name);
755           fnd_message.raise_error;
756         else
757           close csr_var_name;
758         end if;
759       end if;
760     end if;
761     hr_utility.set_location(' Leaving:'||l_proc,30);
762   exception
763     when app_exception.application_exception then
764       if hr_multi_message.exception_add
765                        (p_associated_column1 => 'AME_CONFIG_VARS.APPLICATION_VARIABLE_NAME'
766                        ) then
767         hr_utility.set_location(' Leaving:'||l_proc, 40);
768         raise;
769       end if;
770       hr_utility.set_location(' Leaving:'||l_proc,50);
771   End chk_application_variable_name;
772 --
773 -- ----------------------------------------------------------------------------
774 -- |-----------------------< chk_non_updateable_args >------------------------|
775 -- ----------------------------------------------------------------------------
776 -- {Start Of Comments}
777 --
778 -- Description:
779 --   This procedure is used to ensure that non updateable attributes have
780 --   not been updated. If an attribute has been updated an error is generated.
781 --
782 -- Pre Conditions:
783 --   g_old_rec has been populated with details of the values currently in
784 --   the database.
785 --
786 -- In Arguments:
787 --   p_rec has been populated with the updated values the user would like the
788 --   record set to.
789 --
790 -- Post Success:
791 --   Processing continues if all the non updateable attributes have not
792 --   changed.
793 --
794 -- Post Failure:
795 --   An application error is raised if any of the non updatable attributes
796 --   have been altered.
797 --
798 -- {End Of Comments}
799 -- ----------------------------------------------------------------------------
800 Procedure chk_non_updateable_args
801   (p_effective_date  in date
802   ,p_rec             in ame_cfv_shd.g_rec_type
803   ) IS
804 --
805   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
806 --
807 Begin
808   --
809   -- Only proceed with the validation if a row exists for the current
810   -- record in the HR Schema.
811   --
812   IF NOT ame_cfv_shd.api_updating
813       (p_application_id =>  p_rec.application_id
814  ,p_variable_name =>  p_rec.variable_name
815       ,p_effective_date                   => p_effective_date
816       ,p_object_version_number            => p_rec.object_version_number
817       ) THEN
818      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
819      fnd_message.set_token('PROCEDURE ', l_proc);
820      fnd_message.set_token('STEP ', '5');
821      fnd_message.raise_error;
822   END IF;
823   --
824   -- EDIT_HERE: Add checks to ensure non-updateable args have
825   --            not been updated.
826   --
827 End chk_non_updateable_args;
828 --
829 -- ----------------------------------------------------------------------------
830 -- |--------------------------< dt_update_validate >--------------------------|
831 -- ----------------------------------------------------------------------------
832 -- {Start Of Comments}
833 --
834 -- Description:
835 --   This procedure is used for referential integrity of datetracked
836 --   parent entities when a datetrack update operation is taking place
837 --   and where there is no cascading of update defined for this entity.
838 --
839 -- Prerequisites:
840 --   This procedure is called from the update_validate.
841 --
842 -- In Parameters:
843 --
844 -- Post Success:
845 --   Processing continues.
846 --
847 -- Post Failure:
848 --
849 -- Developer Implementation Notes:
850 --   This procedure should not need maintenance unless the HR Schema model
851 --   changes.
852 --
853 -- Access Status:
854 --   Internal Row Handler Use Only.
855 --
856 -- {End Of Comments}
857 -- ----------------------------------------------------------------------------
858 Procedure dt_update_validate
859   (p_datetrack_mode                in varchar2
860   ,p_validation_start_date         in date
861   ,p_validation_end_date           in date
862   ) Is
863 --
864   l_proc  varchar2(72) := g_package||'dt_update_validate';
865 --
866 Begin
867   --
868   -- Ensure that the p_datetrack_mode argument is not null
869   --
870   hr_api.mandatory_arg_error
871     (p_api_name       => l_proc
872     ,p_argument       => 'datetrack_mode'
873     ,p_argument_value => p_datetrack_mode
874     );
875   --
876   -- Mode will be valid, as this is checked at the start of the upd.
877   --
878   -- Ensure the arguments are not null
879   --
880   hr_api.mandatory_arg_error
881     (p_api_name       => l_proc
882     ,p_argument       => 'validation_start_date'
883     ,p_argument_value => p_validation_start_date
884     );
885   --
886   /*hr_api.mandatory_arg_error
887     (p_api_name       => l_proc
888     ,p_argument       => 'validation_end_date'
889     ,p_argument_value => p_validation_end_date
890     );*/
891   --
892 Exception
893   When Others Then
894     --
895     -- An unhandled or unexpected error has occurred which
896     -- we must report
897     --
898     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
899     fnd_message.set_token('PROCEDURE', l_proc);
903 --
900     fnd_message.set_token('STEP','15');
901     fnd_message.raise_error;
902 End dt_update_validate;
904 -- ----------------------------------------------------------------------------
905 -- |--------------------------< dt_delete_validate >--------------------------|
906 -- ----------------------------------------------------------------------------
907 -- {Start Of Comments}
908 --
909 -- Description:
910 --   This procedure is used for referential integrity of datetracked
911 --   child entities when either a datetrack DELETE or ZAP is in operation
912 --   and where there is no cascading of delete defined for this entity.
913 --   For the datetrack mode of DELETE or ZAP we must ensure that no
914 --   datetracked child rows exist between the validation start and end
915 --   dates.
916 --
917 -- Prerequisites:
918 --   This procedure is called from the delete_validate.
919 --
920 -- In Parameters:
921 --
922 -- Post Success:
923 --   Processing continues.
924 --
925 -- Post Failure:
926 --   If a row exists by determining the returning Boolean value from the
927 --   generic dt_api.rows_exist function then we must supply an error via
928 --   the use of the local exception handler l_rows_exist.
929 --
930 -- Developer Implementation Notes:
931 --   This procedure should not need maintenance unless the HR Schema model
932 --   changes.
933 --
934 -- Access Status:
935 --   Internal Row Handler Use Only.
936 --
937 -- {End Of Comments}
938 -- ----------------------------------------------------------------------------
939 Procedure dt_delete_validate
940   (p_application_id                   in number
941   ,p_variable_name                    in varchar2
942   ,p_datetrack_mode                   in varchar2
943   ,p_validation_start_date            in date
944   ,p_validation_end_date              in date
945   ) Is
946 --
947   l_proc        varchar2(72)    := g_package||'dt_delete_validate';
948 --
949 Begin
950   --
951   -- Ensure that the p_datetrack_mode argument is not null
952   --
953   hr_api.mandatory_arg_error
954     (p_api_name       => l_proc
955     ,p_argument       => 'datetrack_mode'
956     ,p_argument_value => p_datetrack_mode
957     );
958   --
959   -- Only perform the validation if the datetrack mode is either
960   -- DELETE or ZAP
961   --
962   If (p_datetrack_mode = hr_api.g_delete or
963       p_datetrack_mode = hr_api.g_zap) then
964     --
965     --
966     -- Ensure the arguments are not null
967     --
968     hr_api.mandatory_arg_error
969       (p_api_name       => l_proc
970       ,p_argument       => 'validation_start_date'
971       ,p_argument_value => p_validation_start_date
972       );
973     --
974     /*hr_api.mandatory_arg_error
975       (p_api_name       => l_proc
976       ,p_argument       => 'validation_end_date'
977       ,p_argument_value => p_validation_end_date
978       );*/
979     --
980     hr_api.mandatory_arg_error
981       (p_api_name       => l_proc
982       ,p_argument       => 'application_id'
983       ,p_argument_value => p_application_id
984       );
985     --
986     --
987     --
988   End If;
989   --
990 Exception
991   When Others Then
992     --
993     -- An unhandled or unexpected error has occurred which
994     -- we must report
995     --
996     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
997     fnd_message.set_token('PROCEDURE', l_proc);
998     fnd_message.set_token('STEP','15');
999     fnd_message.raise_error;
1000   --
1001 End dt_delete_validate;
1002 --
1003 -- ----------------------------------------------------------------------------
1004 -- |---------------------------< insert_validate >----------------------------|
1005 -- ----------------------------------------------------------------------------
1006 Procedure insert_validate
1007   (p_rec                   in ame_cfv_shd.g_rec_type
1008   ,p_effective_date        in date
1009   ,p_datetrack_mode        in varchar2
1010   ,p_validation_start_date in date
1011   ,p_validation_end_date   in date
1012   ) is
1013 --
1014   l_proc        varchar2(72) := g_package||'insert_validate';
1015 --
1016 Begin
1017   hr_utility.set_location('Entering:'||l_proc, 5);
1018   --
1019   -- Validate Dependent Attributes
1020   --
1021   chk_application_id(p_application_id  => p_rec.application_id
1022                     ,p_effective_date  => p_effective_date
1023                     );
1024   chk_variable_name(p_variable_name  => p_rec.variable_name);
1025   chk_variable_value(p_variable_name   => p_rec.variable_name
1026                     ,p_variable_value  => p_rec.variable_value
1027                     );
1028   chk_application_variable_name(p_variable_name  => p_rec.variable_name
1029                                ,p_application_id => p_rec.application_id
1030                                ,p_effective_date => p_effective_date
1031                                );
1032   chk_nonupd_variable_values(p_application_id => p_rec.application_id
1033 				   ,p_effective_date => p_effective_date
1034 				   ,p_variable_name  => p_rec.variable_name
1035 				   ,p_variable_value => p_rec.variable_value
1036 	                            );
1037   --
1038   hr_utility.set_location(' Leaving:'||l_proc, 10);
1039 End insert_validate;
1040 --
1041 -- ----------------------------------------------------------------------------
1042 -- |---------------------------< update_validate >----------------------------|
1043 -- ----------------------------------------------------------------------------
1044 Procedure update_validate
1048   ,p_validation_start_date   in date
1045   (p_rec                     in ame_cfv_shd.g_rec_type
1046   ,p_effective_date          in date
1047   ,p_datetrack_mode          in varchar2
1049   ,p_validation_end_date     in date
1050   ) is
1051 --
1052   l_proc        varchar2(72) := g_package||'update_validate';
1053 --
1054 Begin
1055   hr_utility.set_location('Entering:'||l_proc, 5);
1056   --
1057   -- Validate Dependent Attributes
1058   --
1059   -- Call the datetrack update integrity operation
1060   --
1061   dt_update_validate
1062     (p_datetrack_mode                 => p_datetrack_mode
1063     ,p_validation_start_date          => p_validation_start_date
1064     ,p_validation_end_date            => p_validation_end_date
1065     );
1066   --
1067   chk_non_updateable_args
1068     (p_effective_date  => p_effective_date
1069     ,p_rec             => p_rec
1070     );
1071   --
1072   -- Additional checks added
1073   --
1074   chk_application_id(p_application_id  => p_rec.application_id
1075                     ,p_effective_date  => p_effective_date
1076                     );
1077   chk_variable_name (p_variable_name   => p_rec.variable_name);
1078   chk_variable_value(p_variable_name   => p_rec.variable_name
1079                     ,p_variable_value  => p_rec.variable_value
1080                     );
1081   chk_nonupd_variable_values(p_application_id => p_rec.application_id
1082 				   ,p_effective_date => p_effective_date
1083 				   ,p_variable_name  => p_rec.variable_name
1084 				   ,p_variable_value => p_rec.variable_value
1085 	                            );
1086   --
1087   hr_utility.set_location(' Leaving:'||l_proc, 10);
1088 End update_validate;
1089 --
1090 -- ----------------------------------------------------------------------------
1091 -- |---------------------------< delete_validate >----------------------------|
1092 -- ----------------------------------------------------------------------------
1093 Procedure delete_validate
1094   (p_rec                    in ame_cfv_shd.g_rec_type
1095   ,p_effective_date         in date
1096   ,p_datetrack_mode         in varchar2
1097   ,p_validation_start_date  in date
1098   ,p_validation_end_date    in date
1099   ) is
1100 --
1101   l_proc        varchar2(72) := g_package||'delete_validate';
1102   l_call_stack  varchar2(4096);
1103 --
1104 Begin
1105   hr_utility.set_location('Entering:'||l_proc, 5);
1106   --
1107   -- Call all supporting business operations
1108   --
1109   dt_delete_validate
1110     (p_datetrack_mode                   => p_datetrack_mode
1111     ,p_validation_start_date            => p_validation_start_date
1112     ,p_validation_end_date              => p_validation_end_date
1113     ,p_application_id =>  p_rec.application_id
1114     ,p_variable_name =>  p_rec.variable_name
1115     );
1116 
1117   l_call_stack := dbms_utility.format_call_stack;
1118   if instrb(l_call_stack,'AME_TRANS_TYPE_API') = 0 then
1119     chk_nonupd_variable_values
1120       (p_application_id => p_rec.application_id
1121       ,p_effective_date => p_effective_date
1122       ,p_variable_name  => p_rec.variable_name
1123       ,p_variable_value => p_rec.variable_value);
1124   end if;
1125   chk_default_config_var
1126     (p_application_id => p_rec.application_id
1127     ,p_effective_date => p_effective_date);
1128   --
1129   hr_utility.set_location(' Leaving:'||l_proc, 10);
1130 End delete_validate;
1131 --
1132 end ame_cfv_bus;