DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_AU_GENERIC_CODE_CALLER

Source


1 package body pay_au_generic_code_caller as
2   --  $Header: pyaugcc.pkb 115.3 2002/12/04 06:16:15 ragovind ship $
3 
4   --  Copyright (C) 1999 Oracle Corporation
5   --  All Rights Reserved
6   --
7   --  Script to create AU HRMS generic code caller package.
8   --
9   --  Change List
10   --  ===========
11   --
12   --  Date        Author   Reference Description
13   --  -----------+--------+---------+------------------------------------------
14   --  04 Dec 2002 Ragovind 2689226   Added NOCOPY and dbdrv
15   --  28 Feb 2000 JTurner            Renamed script and objects to use country
16   --                                 identifier of "AU" instead of "NZ"
17   --  24 Feb 2000 JTurner            Now supports R11i date format
18   --  30 NOV 1999 JTURNER  N/A       Created
19 
20   -----------------------------------------------------------------------------
21   --  private global declarations
22   -----------------------------------------------------------------------------
23 
24   --  none
25 
26   -----------------------------------------------------------------------------
27   --  execute_process procedure
28   --
29   --  This is a public procedure that is called to execute a process.
30   -----------------------------------------------------------------------------
31 
32   procedure execute_process
33   (p_business_group_id              in     number
34   ,p_effective_date                 in     date
35   ,p_process_id                     in     number
36   ,p_assignment_action_id           in     number
37   ,p_input_store                    in     t_variable_store_tab) is
38 
39     l_procedure_name                varchar2(61) := 'pay_au_generic_code_caller.execute_process' ;
40     l_parameter_value               pay_au_module_parameters.constant_value%type ;
41     l_dummy                         varchar2(2) ;
42     l_legislation_code              pay_au_module_parameters.constant_value%type ;
43 
44     e_missing_process_parameter     exception ;
45     e_bad_module_type               exception ;
46     e_missing_legislation_code      exception ;
47     e_missing_session_record        exception ;
48     e_bad_process                   exception ;
49 
50     --  cursor to check process is valid for current business
51     --  group / legislation
52 
53     cursor c_process (p_process_id number
54                      ,p_business_group_id number
55                      ,p_legislation_code varchar2) is
56       select 'ok'
57       from   pay_au_processes p
58       where  p.process_id = p_process_id
59       and    ((p.business_group_id is null
60       and      p.legislation_code is null)
61       or      (p.business_group_id = p_business_group_id)
62       or      (p.legislation_code = p_legislation_code)) ;
63 
64     --  cursor to check fnd_sessions record exists
65 
66     cursor c_session is
67       select 'ok'
68       from   fnd_sessions
69       where  session_id = userenv('sessionid') ;
70 
71     --  cursor to find process parameters
72 
73     cursor c_process_parameters(p_process_id number) is
74       select pp.internal_name
75       ,      pp.data_type
76       from   pay_au_process_parameters pp
77       where  pp.process_id = p_process_id
78       and    pp.enabled_flag = 'Y' ;
79 
80     --  cursor to find the legislation code
81 
82     cursor c_legislation_code (p_business_group_id number) is
83       select legislation_code
84       from   per_business_groups
85       where  business_group_id = p_business_group_id ;
86 
87     --  cursor to find the enabled modules for a process
88 
89     cursor c_modules(p_process_id number) is
90       select m.name module_name
91       ,      mt.name module_type
92       ,      m.package_name
93       ,      m.procedure_function_name
94       ,      m.formula_name
95       ,      m.module_id
96       from   pay_au_process_modules pm
97       ,      pay_au_modules m
98       ,      pay_au_module_types mt
99       where  pm.process_id = p_process_id
100       and    pm.enabled_flag = 'Y'
101       and    m.module_id = pm.module_id
102       and    m.enabled_flag = 'Y'
103       and    mt.module_type_id = m.module_type_id
104       and    mt.enabled_flag = 'Y'
105       order by
106              pm.process_sequence ;
107 
108   begin
109 
110     hr_utility.trace('In: ' || l_procedure_name) ;
111     hr_utility.trace('  p_business_group_id: ' || to_char(p_business_group_id)) ;
112     hr_utility.trace('  p_effective_date: ' || fnd_date.date_to_canonical(p_effective_date)) ;
113     hr_utility.trace('  p_process_id: ' || to_char(p_process_id)) ;
114     hr_utility.trace('  p_assignment_action_id: ' || to_char(p_assignment_action_id)) ;
115 
116     --  check that there's a record in fnd_sessions (the Oracle
117     --  FastFormula harness crashes if no fnd_sessions record present).
118 
119     open c_session ;
120     fetch c_session
121       into l_dummy ;
122     if c_session%notfound
123     then
124       close c_session ;
125       raise e_missing_session_record ;
126     end if ;
127     close c_session ;
128 
129     --  store the business group input parameter and effective date
130 
131     store_variable('BUSINESS_GROUP_ID'
132                   ,'NUMBER'
133                   ,p_business_group_id) ;
134 
135     store_variable('ASSIGNMENT_ACTION_ID'
136                   ,'NUMBER'
137                   ,p_assignment_action_id) ;
138 
139     store_variable('EFFECTIVE_DATE'
140                   ,'DATE'
141                   ,fnd_date.date_to_canonical(p_effective_date)) ;
142 
143     --  get the legislation code we're working under and store it
144 
145     open c_legislation_code(p_business_group_id) ;
146     fetch c_legislation_code
147       into l_legislation_code ;
148     if c_legislation_code%notfound
149     then
150 
151       close c_legislation_code ;
152       raise e_missing_legislation_code ;
153 
154     end if ;
155     close c_legislation_code ;
156 
157     store_variable('LEGISLATION_CODE'
158                   ,'TEXT'
159                   ,l_legislation_code) ;
160 
161     --  check that the process to be run is valid for this
162     --  busines group/legislation
163 
164     open c_process(p_process_id, p_business_group_id, l_legislation_code) ;
165     fetch c_process
166       into l_dummy ;
167     if c_process%notfound
168     then
169       close c_process ;
170       raise e_bad_process ;
171     end if ;
172     close c_process ;
173 
174     --  initialise the variable store PL/SQL table with the values
175     --  from the input PL/SQL table
176 
177     for i in p_input_store.first..p_input_store.last
178     loop
179 
180       store_variable(p_input_store(i).name
181                     ,p_input_store(i).data_type
182                     ,p_input_store(i).value) ;
183 
184     end loop ;
185 
186     --  check that all the parameters the process requires have been
187     --  supplied.  The pay_au_process_parameters table defines the
188     --  parameters the process requires.
189 
190     for r_parameter in c_process_parameters(p_process_id)
191     loop
192 
193       l_parameter_value := null ;
194 
195       retrieve_variable
196       (r_parameter.internal_name
197       ,r_parameter.data_type
198       ,l_parameter_value) ;
199 
200       if l_parameter_value is null
201       then
202 
203         raise e_missing_process_parameter ;
204 
205       end if ;
206 
207     end loop ;  --  c_process_parameters
208 
209     --  add the assignment action ID to the variable store PL/SQL table
210 
211     store_variable('ASSIGNMENT_ACTION_ID', 'NUMBER', p_assignment_action_id) ;
212 
213     --  loop through the enabled modules for this process
214 
215     for r_module in c_modules(p_process_id)
216     loop
217 
218       --  store the module's name for future reference
219 
220       store_variable('MODULE_NAME'
221                     ,'TEXT'
222                     ,r_module.module_name) ;
223 
224       --  check the module's type and call the appropriate procedure
225 
226       if r_module.module_type = 'PROCEDURE'
227       then
228 
229         hr_utility.trace('  exec procedure: ' || r_module.package_name
230                          || '.' || r_module.procedure_function_name) ;
231 
232         execute_procedure(r_module.module_id
233                          ,r_module.package_name
234                          ,r_module.procedure_function_name) ;
235 
236       elsif r_module.module_type = 'FUNCTION'
237       then
238 
239         hr_utility.trace('  exec function: ' || r_module.package_name
240                          || '.' || r_module.procedure_function_name) ;
241 
242         execute_function(r_module.module_id
243                         ,r_module.package_name
244                         ,r_module.procedure_function_name) ;
245 
246       elsif r_module.module_type = 'FORMULA'
247       then
248 
249         hr_utility.trace('  exec formula: ' || r_module.formula_name) ;
250 
251         execute_formula(r_module.module_id
252                        ,r_module.formula_name) ;
253 
254       else
255 
256         raise e_bad_module_type ;
257 
258       end if ;
259 
260     end loop ;  --  c_modules
261 
262     hr_utility.trace('Out: ' || l_procedure_name) ;
263 
264   exception
265     when e_bad_process
266     then
267       hr_utility.set_message(801, 'HR_AU_INVALID_PROCESS') ;
268       hr_utility.raise_error ;
269 
270     when e_missing_session_record
271     then
272       hr_utility.set_message(801, 'HR_AU_MISSING_SESSION_DATE') ;
273       hr_utility.raise_error ;
274 
275     when e_missing_legislation_code
276     then
277       hr_utility.set_message(801, 'HR_AU_MISSING_LEGISLATION_CODE') ;
278       hr_utility.raise_error ;
279 
280     when e_missing_process_parameter
281     then
282       hr_utility.set_message(801, 'HR_AU_MISSING_PROC_PARAMETER') ;
283       hr_utility.raise_error ;
284 
285     when e_bad_module_type
286     then
287       hr_utility.set_message(801, 'HR_AU_INVALID_MODULE_TYPE') ;
288       hr_utility.raise_error ;
289 
290   end execute_process ;
291 
292   -----------------------------------------------------------------------------
293   --  store_variable procedure
294   --
295   --  This is a private procedure that is used to add or update a variable
296   --  in the variable PL/SQL table.
297   -----------------------------------------------------------------------------
298 
299   procedure store_variable
300   (p_name      in     varchar2
301   ,p_data_type in     varchar2
302   ,p_value     in     varchar2) is
303 
304     l_procedure_name                varchar2(61) := 'pay_au_generic_code_caller.store_variable' ;
305     l_variable_notfound_flag        boolean := true ;
306     l_counter                       number := 1 ;
307 
308     e_data_type_mismatch            exception ;
309 
310   begin
311 
312     hr_utility.trace('In: ' || l_procedure_name) ;
313 
314     --  loop through the records in the PL/SQL table.  Only start
315     --  the loop if there are some records and stop when the variable
316     --  has been found or we've reached the last record.
317 
318     while v_variable_store.count > 0
319       and l_variable_notfound_flag
320       and l_counter <= v_variable_store.last
321     loop
322 
323       --  find the element that contains the variable name we want,
324       --  or the variable name is null
325 
326       if v_variable_store(l_counter).name = p_name
327         or v_variable_store(l_counter).name is null
328       then
329 
330         --  we've found a suitable element so make sure that there
331         --  isn't a type mismatch
332 
333         if v_variable_store(l_counter).name is not null
334           and v_variable_store(l_counter).data_type <> p_data_type
335         then
336 
337           raise e_data_type_mismatch ;
338 
339         end if ;
340 
341         --  store the variable and set the variable not found flag
342 
343         hr_utility.trace('  ' || p_name || ' -> ' || nvl(p_value,'null')) ;
344         v_variable_store(l_counter).name := p_name ;
345         v_variable_store(l_counter).data_type := p_data_type ;
346         v_variable_store(l_counter).value := p_value ;
347         l_variable_notfound_flag := false ;
348 
349       end if ;
350 
351       l_counter := l_counter + 1 ;
352 
353     end loop ;
354 
355     --  either the variable store was empty or the variable was not already
356     --  in the store
357 
358     if l_variable_notfound_flag
359     then
360 
361       hr_utility.trace('  ' || p_name || ' -> ' || nvl(p_value,'null')) ;
362       v_variable_store(l_counter).name := p_name ;
363       v_variable_store(l_counter).data_type := p_data_type ;
364       v_variable_store(l_counter).value := p_value ;
365 
366     end if ;
367 
368     hr_utility.trace('Out: ' || l_procedure_name) ;
369 
370   exception
371     when e_data_type_mismatch
372     then
373       hr_utility.set_message(801, 'HR_AU_DATA_TYPE_MISMATCH') ;
374       hr_utility.set_message_token('PROCEDURE', l_procedure_name) ;
375       hr_utility.raise_error ;
376 
377   end store_variable ;
378 
379   -----------------------------------------------------------------------------
380   --  retrieve_variable procedure
381   --
382   --  This is a private procedure that is used to retrieve a variable's
383   --  value from the variable PL/SQL table.
384   -----------------------------------------------------------------------------
385 
386   procedure retrieve_variable
387   (p_name      in     varchar2
388   ,p_data_type in     varchar2
389   ,p_value     out NOCOPY varchar2) is
390 
391     l_procedure_name                varchar2(61) := 'pay_au_generic_code_caller.retrieve_variable' ;
392     l_variable_value                pay_au_module_parameters.constant_value%type := null ;
393     l_variable_notfound_flag        boolean := true ;
394     l_counter                       number := 1 ;
395 
396     e_data_type_mismatch            exception ;
397 
398   begin
399 
400     hr_utility.trace('In: ' || l_procedure_name) ;
401 
402     --  loop through the records in the PL/SQL table.  Only start
403     --  the loop if there are some records and stop when the variable
404     --  has been found or we've reached the last record.
405 
406     while v_variable_store.count > 0
407       and l_variable_notfound_flag
408       and l_counter <= v_variable_store.last
409     loop
410 
411       --  does the element contain the variable we're looking for?
412 
413       if v_variable_store(l_counter).name = p_name
414       then
415 
416         --  found the element containing the variable we're looking for
417         --  make sure that the data type is ok
418 
419         if v_variable_store(l_counter).data_type <> p_data_type
420         then
421 
422           raise e_data_type_mismatch ;
423 
424         end if ;
425 
426         --  get the value of the variable we're looking for
427 
428         l_variable_value := v_variable_store(l_counter).value ;
429         l_variable_notfound_flag := false ;
430 
431       end if ;
432 
433       l_counter := l_counter + 1 ;
434 
435     end loop ;
436 
437     --  set the output parameter
438 
439     hr_utility.trace('  ' || p_name || ' -> ' || nvl(l_variable_value,'null')) ;
440     p_value := l_variable_value ;
441 
442     hr_utility.trace('Out: ' || l_procedure_name) ;
443 
444   exception
445     when e_data_type_mismatch
446     then
447       hr_utility.set_message(801, 'HR_AU_DATA_TYPE_MISMATCH') ;
451   end retrieve_variable ;
448       hr_utility.set_message_token('PROCEDURE', l_procedure_name) ;
449       hr_utility.raise_error ;
450 
452 
453   -----------------------------------------------------------------------------
454   --  execute_procedure procedure
455   --
456   --  This is a private procedure that is used to execute a package procedure
457   --  type module.
458   -----------------------------------------------------------------------------
459 
460   procedure execute_procedure
461   (p_module_id                    in     number
462   ,p_package_name                 in     varchar2
463   ,p_procedure_name               in     varchar2) is
464 
465     l_procedure_name                varchar2(61) := 'pay_au_generic_code_caller.execute_procedure' ;
466 
467   begin
468 
469     hr_utility.trace('In: ' || l_procedure_name) ;
470 
471     execute_procedure_function
472     (p_module_id
473     ,p_package_name
474     ,p_procedure_name
475     ,'PROCEDURE') ;
476 
477     hr_utility.trace('Out: ' || l_procedure_name) ;
478 
479   end execute_procedure ;
480 
481   -----------------------------------------------------------------------------
482   --  execute_function procedure
483   --
484   --  This is a private procedure that is used to execute a package function
485   --  type module.
486   -----------------------------------------------------------------------------
487 
488   procedure execute_function
489   (p_module_id                    in     number
490   ,p_package_name                 in     varchar2
491   ,p_function_name                in     varchar2) is
492 
493     l_procedure_name                varchar2(61) := 'pay_au_generic_code_caller.execute_procedure_function' ;
494 
495   begin
496 
497     hr_utility.trace('In: ' || l_procedure_name) ;
498 
499     execute_procedure_function
500     (p_module_id
501     ,p_package_name
502     ,p_function_name
503     ,'FUNCTION') ;
504 
505     hr_utility.trace('Out: ' || l_procedure_name) ;
506 
507   end execute_function ;
508 
509   -----------------------------------------------------------------------------
510   --  execute_procedure_function procedure
511   --
512   --  This is a private procedure that is used to execute a package procedure
513   --  or package function type module.
514   -----------------------------------------------------------------------------
515 
516   procedure execute_procedure_function
517   (p_module_id                    in     number
518   ,p_package_name                 in     varchar2
519   ,p_procedure_function_name      in     varchar2
520   ,p_mode                         in     varchar2) is
521 
522     l_text_out_bind_var_init        pay_au_module_parameters.constant_value%type := ' ' ;
523     l_date_out_bind_var_init        date := to_date('31/12/4712', 'dd/mm/yyyy') ;
524     l_num_out_bind_var_init         number := 999 ;
525 
526     l_procedure_name                varchar2(61) := 'pay_au_generic_code_caller.execute_procedure_function' ;
527     l_parameter_store               t_parameter_store_tab ;
528     l_sql_stmt                      varchar2(4000) ;
529     l_cursor_id                     integer ;
530     l_variable_value                pay_au_module_parameters.constant_value%type ;
531     l_return_code                   integer ;
532     l_number_variable_value         number ;
533     l_date_variable_value           date ;
534     l_function_return_found_flag    boolean := false ;
535     l_no_parameters_flag            boolean := true ;
536     l_first_parameter_flag          boolean := true ;
537     l_module                        pay_au_module_parameters.constant_value%type ;
538     l_error                         pay_au_module_parameters.constant_value%type ;
539 
540     e_bad_mode                      exception ;
541     e_bad_data_type                 exception ;
542     e_missing_function_return       exception ;
543     e_multiple_function_return      exception ;
544     e_module_error                  exception ;
545 
546   begin
547 
548     hr_utility.trace('In: ' || l_procedure_name) ;
549 
550     if not (p_mode = 'FUNCTION' or p_mode = 'PROCEDURE')
551     then
552 
553       raise e_bad_mode ;
554 
555     end if ;
556 
557     --  call get_module_parameters to populate a PL/SQL table with the
558     --  data from the pay_au_module_parameters table for the module
559     --  beinmg executed.  This saves on database table accesses.
560 
561     get_module_parameters(p_module_id, l_parameter_store) ;
562 
563     --  build up a string that contains a PL/SQL block.  The PL/SQL block
564     --  will execute the module.  The DBMS_SQL package will be used to
565     --  execute the dynamically created PL/SQL block
566 
567     if p_mode = 'PROCEDURE'
568     then
569 
570       l_sql_stmt := 'begin ' || p_package_name || '.' || p_procedure_function_name ;
571 
572     else  --  p_mode = 'FUNCTION'
573 
574       l_sql_stmt := 'begin ' ;
575 
576       --  one of the parameters should have been flagged as the function
577       --  return - find it and add it to the string
578 
579       for i in l_parameter_store.first..l_parameter_store.last
580       loop
581 
585           if l_function_return_found_flag
582         if l_parameter_store(i).function_return_flag = 'Y'
583         then
584 
586           then
587 
588             --  this is the second parameter found that is marked as the
589             --  function return so raise an error.
590 
591             raise e_multiple_function_return ;
592 
593           else
594 
595             --  function return found so set up string:
596             --    :<function return bind value> := <package name>.<function_name>
597             --  set flag to show that function return has been found.  The flag is
598             --  tested to find if multiple function returns have been defined and
599             --  to find if no function return has been defined.
600 
601             l_sql_stmt := l_sql_stmt || ':' || l_parameter_store(i).internal_name
602                             || ' := ' || p_package_name || '.' || p_procedure_function_name ;
603 
604             l_function_return_found_flag := true ;
605 
606           end if ;
607 
608         end if ;
609 
610       end loop ;
611 
612       --  test to see if no function return was defined and raise error if
613       --  necessary
614 
615       if not l_function_return_found_flag
616       then
617 
618         raise e_missing_function_return ;
619 
620       end if ;
621 
622     end if ;
623 
624     --  loop through each parameter and add it to the string, each bit added
625     --  to the string looks like:
626     --    <parameter_name> => :<bind variable name>
627     --  the parameter name is the external name and the internal name is
628     --  used for the bind variable name.
629 
630     if l_parameter_store.count > 0
631     then
632 
633       for i in l_parameter_store.first..l_parameter_store.last
634       loop
635 
636         --  only add the parameter if it is an input or output
637 
638         if (l_parameter_store(i).input_flag = 'Y'
639           or l_parameter_store(i).output_flag = 'Y')
640           and l_parameter_store(i).function_return_flag = 'N'
641         then
642 
643           --  if this is the first parameter then an open bracket
644           --  is required, otherwise an comma is required:
645           --
646           --    <procedure/function name>(param1, param2, ...)
647           --                             ^      ^
648           --                             |      |
649           --                         first      second and
650           --                     parameter      subsequent parameters
651 
652           if l_first_parameter_flag
653           then
654 
655             l_sql_stmt := l_sql_stmt || '(' ;
656             l_first_parameter_flag := false ;
657             l_no_parameters_flag := false ;
658 
659           else
660 
661             l_sql_stmt := l_sql_stmt || ', ' ;
662 
663           end if ;
664 
665           --  if a constnt value has been supplied (for an input) then
666           --  pass that value otherwise set up a bind variable
667 
668           if l_parameter_store(i).constant_value is not null
669             and l_parameter_store(i).input_flag = 'Y'
670           then
671 
672             if l_parameter_store(i).data_type = 'NUMBER'
673             then
674 
675               l_sql_stmt := l_sql_stmt || l_parameter_store(i).external_name
676                               || ' => to_number(''' || l_parameter_store(i).constant_value || ''')' ;
677 
678             elsif l_parameter_store(i).data_type = 'TEXT'
679             then
680 
681               l_sql_stmt := l_sql_stmt || l_parameter_store(i).external_name
682                               || ' => ''' || l_parameter_store(i).constant_value || '''' ;
683 
684             elsif l_parameter_store(i).data_type = 'DATE'
685             then
686 
687               l_sql_stmt := l_sql_stmt || l_parameter_store(i).external_name
688                               || ' => fnd_date.cannonical_to_date(''' || l_parameter_store(i).constant_value || ''')' ;
689 
690             else
691 
692               raise e_bad_data_type ;
693 
694             end if ;
695 
696           else
697 
698             l_sql_stmt := l_sql_stmt || l_parameter_store(i).external_name
699                             || ' => :' || l_parameter_store(i).internal_name ;
700 
701           end if ;
702 
703         end if ;
704 
705       end loop ;
706 
707     end if ;
708 
709     --  the no_parameters_flag gets initialised to true at declaration.
710     --  It is set to false when the opening bracket is added to the
711     --  string when the first parameter is added to the string.
712     --  If there are no parameters then a closing bracket is not
713     --  required.
714 
715     if l_no_parameters_flag
716     then
717       l_sql_stmt := l_sql_stmt || '; end;' ;
718     else
719       l_sql_stmt := l_sql_stmt || '); end;' ;
720     end if ;
721 
722     hr_utility.trace('  ' || l_sql_stmt) ;
723 
724     --  open a cursor for the the dynamic pl/sql block
725 
726     l_cursor_id := dbms_sql.open_cursor ;
727 
731 
728     --  parse the dynamic pl/sql block
729 
730     dbms_sql.parse(l_cursor_id, l_sql_stmt, 1) ;
732     --  Now set values for the bind variables.  The values for in or in/out
733     --  parameters should be in the PL/SQL table variable store.  There will
734     --  be no values for the out parameters.  The DBMS_SQL package requires
735     --  that these out parameter bind variables are initialised so the
736     --  l_num_out_bind_var_init, l_text_out_bind_var_init, and
737     --  l_date_out_bind_var_init variables are used for this purpose.
738 
739     if l_parameter_store.count > 0
740     then
741 
742       for i in l_parameter_store.first..l_parameter_store.last
743       loop
744 
745         if l_parameter_store(i).input_flag = 'Y'
746           or l_parameter_store(i).output_flag = 'Y'
747         then
748 
749           --  get the value to bind
750 
751           retrieve_variable(l_parameter_store(i).internal_name
752                            ,l_parameter_store(i).data_type
753                            ,l_variable_value) ;
754 
755           --  the values are stored as characters so we have to convert them
756           --  to their real data types here before binding
757 
758           if l_parameter_store(i).data_type = 'NUMBER'
759           then
760 
761             if l_parameter_store(i).output_flag = 'Y'
762               and l_parameter_store(i).input_flag = 'N'
763             then
764 
765               --  initialise an out number bind variable
766 
767               dbms_sql.bind_variable(l_cursor_id
768                                     ,':' || l_parameter_store(i).internal_name
769                                     ,l_num_out_bind_var_init) ;
770 
771             else
772 
773               --  bind an in or in/out number bind variable
774 
775               dbms_sql.bind_variable(l_cursor_id
776                                     ,':' || l_parameter_store(i).internal_name
777                                     ,to_number(l_variable_value)) ;
778 
779             end if ;
780 
781           elsif l_parameter_store(i).data_type = 'TEXT'
782           then
783 
784             if l_parameter_store(i).output_flag = 'Y'
785               and l_parameter_store(i).input_flag = 'N'
786             then
787 
788               --  initialise an out text bind variable
789 
790               dbms_sql.bind_variable(l_cursor_id
791                                     ,':' || l_parameter_store(i).internal_name
792                                     ,l_text_out_bind_var_init) ;
793 
794             else
795 
796               --  bind an in or in/out text bind variable
797 
798               dbms_sql.bind_variable(l_cursor_id
799                                     ,':' || l_parameter_store(i).internal_name
800                                     ,l_variable_value) ;
801 
802             end if ;
803 
804           elsif l_parameter_store(i).data_type = 'DATE'
805           then
806 
807             if l_parameter_store(i).output_flag = 'Y'
808               and l_parameter_store(i).input_flag = 'N'
809             then
810 
811               --  initialise an out date bind variable
812 
813               dbms_sql.bind_variable(l_cursor_id
814                                     ,':' || l_parameter_store(i).internal_name
815                                     ,l_date_out_bind_var_init) ;
816 
817             else
818 
819               --  bind an in or in/out date bind variable
820 
821               dbms_sql.bind_variable(l_cursor_id
822                                     ,':' || l_parameter_store(i).internal_name
823                                     ,fnd_date.canonical_to_date(l_variable_value)) ;
824 
825             end if ;
826 
827           else
828 
829             raise e_bad_data_type ;
830 
831           end if ;
832 
833         end if ;
834 
835       end loop ;
836 
837     end if ;
838 
839     --  execute the dynamically created PL/SQL block.  (Note that the return
840     --  code has no meaning when executing PL/SQL blocks and it is ignored).
841 
842     l_return_code := dbms_sql.execute(l_cursor_id) ;
843 
844     --  now we need to get the values of the bind variables associated with
845     --  output parameters.  The function return appears to be a special case,
846     --  however, as long as it has been flagged as an output parameter its
847     --  bind value will be retrieved here.
848 
849     if l_parameter_store.count > 0
850     then
851 
852       for i in l_parameter_store.first..l_parameter_store.last
853       loop
854 
855         --  only get values for output parameter bind variables
856 
857         if l_parameter_store(i).output_flag = 'Y'
858         then
859 
860           --  the bind values are returned as their real data types so we have
861           --  to convert them to chars so that they can be stored in the
862           --  variable store PL/SQL table
863 
864           if l_parameter_store(i).data_type = 'NUMBER'
865           then
866 
867             l_number_variable_value := null ;
868 
872 
869             dbms_sql.variable_value(l_cursor_id
870                                   ,':' || l_parameter_store(i).internal_name
871                                   ,l_number_variable_value) ;
873             l_variable_value := to_char(l_number_variable_value) ;
874 
875           elsif l_parameter_store(i).data_type = 'TEXT'
876           then
877 
878             dbms_sql.variable_value(l_cursor_id
879                                   ,':' || l_parameter_store(i).internal_name
880                                   ,l_variable_value) ;
881 
882           elsif l_parameter_store(i).data_type = 'DATE'
883           then
884 
885             l_date_variable_value := null ;
886             dbms_sql.variable_value(l_cursor_id
887                                   ,':' || l_parameter_store(i).internal_name
888                                   ,l_date_variable_value) ;
889 
890             l_variable_value := fnd_date.date_to_canonical(l_date_variable_value) ;
891 
892           else
893 
894             raise e_bad_data_type ;
895 
896           end if ;
897 
898           --  the variable l_variable_value now holds the value of the bind
899           --  variable.
900 
901           --  if the output is flagged as an error message and is not null
902           --  then raise an error
903 
904           if l_parameter_store(i).error_message_flag = 'Y'
905             and l_variable_value is not null
906           then
907 
908             l_error := l_variable_value ;
909             retrieve_variable('MODULE_NAME'
910                              ,'TEXT'
911                              ,l_module) ;
912             raise e_module_error ;
913 
914           end if ;
915 
916           --  The variable value needs to be stored in the variable store PL/SQL
917           --  table (so that it can be used as an input to subsequent modules).
918           --  If the parameter is marked as a result it must also be written to
919           --  the database as a result.
920 
921           store_variable
922           (l_parameter_store(i).internal_name
923           ,l_parameter_store(i).data_type
924           ,l_variable_value) ;
925 
926           if l_parameter_store(i).result_flag = 'Y'
927           then
928 
929             save_result
930             (l_parameter_store(i).database_item_name
931             ,l_variable_value) ;
932 
933           end if ;
934 
935         end if ;
936 
937       end loop ;
938 
939     end if ;
940 
941     --  the cursor that contains the dynamically created PL/SQL block
942     --  is now finished with so release it
943 
944     dbms_sql.close_cursor(l_cursor_id) ;
945 
946     hr_utility.trace('Out: ' || l_procedure_name) ;
947 
948   exception
949     when e_module_error
950     then
951       hr_utility.set_message(801, 'HR_AU_MODULE_ERROR') ;
952       hr_utility.set_message_token('MODULE', l_module) ;
953       hr_utility.set_message_token('ERROR', l_error) ;
954       hr_utility.raise_error ;
955 
956     when e_bad_data_type
957     then
958       hr_utility.set_message(801, 'HR_AU_INVALID_DATA_TYPE') ;
959       hr_utility.set_message_token('PROCEDURE', l_procedure_name) ;
960       hr_utility.raise_error ;
961 
962     when e_bad_mode
963     then
964       hr_utility.set_message(801, 'HR_AU_INVALID_MODE') ;
965       hr_utility.raise_error ;
966 
967     when e_missing_function_return
968     then
969       hr_utility.set_message(801, 'HR_AU_MISSING_FN_RETURN') ;
970       hr_utility.raise_error ;
971 
972     when e_multiple_function_return
973     then
974       hr_utility.set_message(801, 'HR_AU_MULTIPLE_FN_RETURNS') ;
975       hr_utility.raise_error ;
976 
977   end execute_procedure_function ;
978 
979   -----------------------------------------------------------------------------
980   --  execute_formula procedure
981   --
982   --  This is a private procedure that is used to execute a Oracle FastFormula
983   --  formula type module.
984   -----------------------------------------------------------------------------
985 
986   procedure execute_formula
987   (p_module_id                    in     number
988   ,p_formula_name                 in     varchar2) is
989 
990     l_procedure_name                varchar2(61) := 'pay_au_generic_code_caller.execute_formula' ;
991     l_formula_id                    ff_formulas_f.formula_id%type ;
992     l_business_group_id             ff_formulas_f.business_group_id%type ;
993     l_legislation_code              ff_formulas_f.legislation_code%type ;
994     l_parameter_store               t_parameter_store_tab ;
995     l_inputs_counter                number := 1 ;
996     l_outputs_counter               number := 1 ;
997     l_ff_inputs                     ff_exec.inputs_t ;
998     l_ff_outputs                    ff_exec.outputs_t ;
999     l_parameter_value               pay_au_module_parameters.constant_value%type ;
1000     l_effective_date                pay_au_module_parameters.constant_value%type ;
1001     l_module                        pay_au_module_parameters.constant_value%type ;
1002     l_error                         pay_au_module_parameters.constant_value%type ;
1003     l_sqlerrm                       varchar2(255) ;
1004 
1005     e_bad_formula                   exception ;
1006     e_module_error                  exception ;
1007 
1008     cursor c_formula (p_formula_name varchar2
1012       from   ff_formulas_f f
1009                      ,p_business_group_id number
1010                      ,p_legislation_code varchar2) is
1011       select f.formula_id
1013       where  f.formula_name = p_formula_name
1014       and    ((f.business_group_id is null
1015       and      f.legislation_code is null)
1016       or      (f.business_group_id = p_business_group_id)
1017       or      (f.legislation_code = p_legislation_code)) ;
1018 
1019     function get_ff_output (p_name varchar2) return varchar2 is
1020 
1021       --  local function to loop through the FF inputs PL/SQL table
1022       --  looking for a output name
1023 
1024       l_procedure_name                varchar2(61) := 'get_ff_output' ;
1025       l_output_value                  pay_au_module_parameters.constant_value%type := null ;
1026 
1027     begin
1028 
1029       hr_utility.trace('  In: ' || l_procedure_name) ;
1030 
1031       for i in l_ff_outputs.first..l_ff_outputs.last
1032       loop
1033 
1034         if l_ff_outputs(i).name = p_name
1035         then
1036 
1037           l_output_value := l_ff_outputs(i).value ;
1038           exit ;  --  (from loop)
1039 
1040         end if ;
1041 
1042       end loop ;
1043 
1044       hr_utility.trace('  Out: ' || l_procedure_name) ;
1045 
1046       return l_output_value ;
1047 
1048     end get_ff_output ;
1049 
1050   begin
1051 
1052     hr_utility.trace('In: ' || l_procedure_name) ;
1053     hr_utility.trace('  p_module_id: ' || to_char(p_module_id)) ;
1054     hr_utility.trace('  p_formula_name: ' || p_formula_name) ;
1055 
1056     --  Get the business group ID and legislation code variables and then check
1057     --  that the formula is valid within this business group/legislation context.
1058 
1059     hr_utility.set_location(l_procedure_name, 10) ;
1060     retrieve_variable('BUSINESS_GROUP_ID'
1061                      ,'NUMBER'
1062                      ,l_business_group_id) ;
1063 
1064     hr_utility.set_location(l_procedure_name, 20) ;
1065     retrieve_variable('LEGISLATION_CODE'
1066                      ,'TEXT'
1067                      ,l_legislation_code) ;
1068 
1069     hr_utility.set_location(l_procedure_name, 30) ;
1070     open c_formula(p_formula_name, l_business_group_id, l_legislation_code) ;
1071     fetch c_formula
1072       into l_formula_id ;
1073     if c_formula%notfound
1074     then
1075 
1076       close c_formula ;
1077       raise e_bad_formula ;
1078 
1079     end if ;
1080     close c_formula ;
1081 
1082     --  call get_module_parameters to populate a PL/SQL table with the
1083     --  data from the pay_au_module_parameters table for the module
1084     --  beinmg executed.  This saves on database table accesses.
1085 
1086     hr_utility.set_location(l_procedure_name, 40) ;
1087     get_module_parameters(p_module_id, l_parameter_store) ;
1088 
1089     --  the Oracle FastFormula execution harness requires inputs
1090     --  to be passed in using a PL/SQL table and outputs to be passed
1091     --  out using another PL/SQL table.  Set up the FastFormula inputs
1092     --  and outputs tables.
1093 
1094     hr_utility.set_location(l_procedure_name, 50) ;
1095     for i in l_parameter_store.first..l_parameter_store.last
1096     loop
1097 
1098       --  look for inputs or contexts
1099 
1100       hr_utility.set_location(l_procedure_name, 60) ;
1101       if l_parameter_store(i).input_flag = 'Y'
1102         or l_parameter_store(i).context_flag = 'Y'
1103       then
1104 
1105         --  if there is a constant value defined for the parameter
1106         --  use it, otherwise get the value from the variable store
1107 
1108         hr_utility.set_location(l_procedure_name, 70) ;
1109         if l_parameter_store(i).constant_value is not null
1110         then
1111 
1112           hr_utility.set_location(l_procedure_name, 80) ;
1113           l_parameter_value := l_parameter_store(i).constant_value ;
1114 
1115         else
1116 
1117           hr_utility.set_location(l_procedure_name, 90) ;
1118           retrieve_variable(l_parameter_store(i).internal_name
1119                            ,l_parameter_store(i).data_type
1120                            ,l_parameter_value) ;
1121 
1122         end if ;
1123 
1124         --  set up the FF inputs table fields
1125 
1126         hr_utility.set_location(l_procedure_name, 100) ;
1127         l_ff_inputs(l_inputs_counter).name := l_parameter_store(i).external_name ;
1128         l_ff_inputs(l_inputs_counter).datatype := l_parameter_store(i).data_type ;
1129         l_ff_inputs(l_inputs_counter).value := l_parameter_value  ;
1130 
1131         hr_utility.set_location(l_procedure_name, 110) ;
1132         if l_parameter_store(i).input_flag = 'Y'
1133         then
1134 
1135           hr_utility.set_location(l_procedure_name, 120) ;
1136           l_ff_inputs(l_inputs_counter).class := 'INPUT' ;
1137 
1138         else
1139 
1140           hr_utility.set_location(l_procedure_name, 130) ;
1141           l_ff_inputs(l_inputs_counter).class := 'CONTEXT' ;
1142 
1143         end if ;
1144 
1145         hr_utility.set_location(l_procedure_name, 140) ;
1146         l_inputs_counter := l_inputs_counter + 1 ;
1147 
1148       end if ;
1149 
1150       --  look for outputs
1151 
1152       hr_utility.set_location(l_procedure_name, 150) ;
1153       if l_parameter_store(i).output_flag = 'Y'
1154       then
1155 
1159 
1156         hr_utility.set_location(l_procedure_name, 160) ;
1157         l_ff_outputs(l_outputs_counter).name := l_parameter_store(i).external_name ;
1158         l_outputs_counter := l_outputs_counter + 1 ;
1160       end if ;
1161 
1162     end loop ;
1163 
1164     --  the FF harness has an effective date parameter so get the
1165     --  effective date from the variable store
1166 
1167     hr_utility.set_location(l_procedure_name, 170) ;
1168     retrieve_variable('EFFECTIVE_DATE'
1169                      ,'DATE'
1170                      ,l_effective_date) ;
1171 
1172     --  call the FF harness
1173 
1174     hr_utility.set_location(l_procedure_name, 180) ;
1175     per_formula_functions.run_formula
1176     (p_formula_name       => p_formula_name
1177     ,p_business_group_id  => l_business_group_id
1178     ,p_calculation_date   => fnd_date.canonical_to_date(l_effective_date)
1179     ,p_inputs             => l_ff_inputs
1180     ,p_outputs            => l_ff_outputs) ;
1181 
1182     --  check the outputs
1183 
1184     hr_utility.set_location(l_procedure_name, 190) ;
1185     for i in l_parameter_store.first..l_parameter_store.last
1186     loop
1187 
1188       hr_utility.set_location(l_procedure_name, 200) ;
1189       if l_parameter_store(i).output_flag = 'Y'
1190       then
1191 
1192         --  get the parameter value from the FF outputs PL/SQL table
1193 
1194         hr_utility.set_location(l_procedure_name, 210) ;
1195         l_parameter_value := get_ff_output(l_parameter_store(i).external_name) ;
1196 
1197         --  if the output is flagged as an error message and is not null
1198         --  then raise an error
1199 
1200         hr_utility.set_location(l_procedure_name, 220) ;
1201         if l_parameter_store(i).error_message_flag = 'Y'
1202           and l_parameter_value is not null
1203         then
1204 
1205           hr_utility.set_location(l_procedure_name, 230) ;
1206           l_error := l_parameter_value ;
1207           retrieve_variable('MODULE_NAME'
1208                            ,'TEXT'
1209                            ,l_module) ;
1210           raise e_module_error ;
1211 
1212         end if ;
1213 
1214         --  The output needs to be stored in the variable store PL/SQL
1215         --  table (so that it can be used as an input to subsequent modules).
1216         --  If the parameter is marked as a result it must also be written to
1217         --  the database.
1218 
1219         hr_utility.set_location(l_procedure_name, 240) ;
1220         store_variable
1221         (l_parameter_store(i).internal_name
1222         ,l_parameter_store(i).data_type
1223         ,l_parameter_value) ;
1224 
1225         hr_utility.set_location(l_procedure_name, 250) ;
1226         if l_parameter_store(i).result_flag = 'Y'
1227         then
1228 
1229           hr_utility.set_location(l_procedure_name, 260) ;
1230           save_result
1231           (l_parameter_store(i).database_item_name
1232           ,l_parameter_value) ;
1233 
1234         end if ;
1235 
1236       end if ;
1237 
1238     end loop ;
1239 
1240     hr_utility.set_location(l_procedure_name, 260) ;
1241     hr_utility.trace('Out: ' || l_procedure_name) ;
1242 
1243   exception
1244     when e_bad_formula
1245     then
1246       hr_utility.set_message(801, 'HR_AU_INVALID_FORMULA') ;
1247       hr_utility.set_message_token('FORMULA', p_formula_name) ;
1248       hr_utility.raise_error ;
1249     when e_module_error
1250     then
1251       hr_utility.set_message(801, 'HR_AU_MODULE_ERROR') ;
1252       hr_utility.set_message_token('MODULE', l_module) ;
1253       hr_utility.set_message_token('ERROR', l_error) ;
1254       hr_utility.raise_error ;
1255 
1256   end execute_formula ;
1257 
1258   -----------------------------------------------------------------------------
1259   --  save_result procedure
1260   --
1261   --  This is a private procedure that is used to save results from executed
1262   --  modules.
1263   -----------------------------------------------------------------------------
1264 
1265   procedure save_result
1266   (p_database_item_name  in     varchar2
1267   ,p_result_value        in     varchar2) is
1268 
1269     type t_context_store_rec is record
1270     (name                           varchar2(30)
1271     ,value                          varchar2(255)) ;
1272 
1273     type t_context_store_tab
1274       is table of t_context_store_rec
1275       index by binary_integer ;
1276 
1277     l_procedure_name                varchar2(61) := 'pay_au_generic_code_caller.save_result' ;
1278     l_archive_item_id               ff_archive_items.archive_item_id%type ;
1279     l_user_entity_id                ff_user_entities.user_entity_id%type ;
1280     l_assignment_action_id          pay_assignment_actions.assignment_action_id%type ;
1281     l_legislation_code              ff_user_entities.legislation_code%type ;
1282     l_object_version_number         ff_archive_items.object_version_number%type ;
1283     l_some_warning                  boolean ;
1284     l_context_store                 t_context_store_tab ;
1285     l_variable_value                pay_au_module_parameters.constant_value%type ;
1286     l_counter                       integer := 1 ;
1287 
1288     e_bad_user_entity               exception ;
1289 
1290     cursor c_user_entity (p_database_item_name varchar2
1291                          ,p_legislation_code varchar2) is
1292       select ue.user_entity_id
1293       from   ff_database_items dbi
1294       ,      ff_user_entities ue
1298 
1295       where  dbi.user_name = p_database_item_name
1296       and    ue.user_entity_id = dbi.user_entity_id
1297       and    ue.legislation_code = p_legislation_code ;
1299     cursor c_contexts(p_database_item_name varchar2
1300                      ,p_legislation_code varchar2) is
1301       select c.context_name
1302       ,      decode(c.data_type
1303                    ,'N', 'NUMBER'
1304                    ,'T', 'TEXT'
1305                    ,null) data_type
1306       from   ff_contexts c
1307       ,      ff_route_context_usages rcu
1308       ,      ff_routes r
1309       ,      ff_user_entities ue
1310       ,      ff_database_items dbi
1311       where  dbi.user_name = p_database_item_name
1312       and    ue.user_entity_id = dbi.user_entity_id
1313       and    ue.legislation_code = p_legislation_code
1314       and    r.route_id = ue.route_id
1315       and    rcu.route_id = r.route_id
1316       and    c.context_id = rcu.context_id
1317       order by
1318              rcu.sequence_no ;
1319 
1320   begin
1321 
1322     hr_utility.trace('In: ' || l_procedure_name) ;
1323     hr_utility.trace('  p_database_item_name: ' || p_database_item_name) ;
1324     hr_utility.trace('  p_result_value: ' || p_result_value) ;
1325 
1326     --  get the legislation code and assignment action ID for later use
1327 
1328     retrieve_variable('LEGISLATION_CODE'
1329                      ,'TEXT'
1330                      ,l_legislation_code) ;
1331 
1332     retrieve_variable('ASSIGNMENT_ACTION_ID'
1333                      ,'NUMBER'
1334                      ,l_variable_value) ;
1335 
1336     l_assignment_action_id := to_number(l_variable_value) ;
1337 
1338     --  get the user entity ID for the DBI
1339 
1340     open c_user_entity(p_database_item_name, l_legislation_code) ;
1341     fetch c_user_entity
1342       into l_user_entity_id ;
1343     if c_user_entity%notfound
1344     then
1345       close c_user_entity ;
1346       raise e_bad_user_entity ;
1347     end if ;
1348     close c_user_entity ;
1349 
1350     --  now set up the contexts table
1351 
1352     --  initialisse the table to be full of null records
1353 
1354     for i in 1..31
1355     loop
1356 
1357       l_context_store(i).name := null ;
1358       l_context_store(i).value := null ;
1359 
1360     end loop ;
1361 
1362     --  get the contexts
1363 
1364     for r_context in c_contexts(p_database_item_name, l_legislation_code)
1365     loop
1366 
1367       retrieve_variable(r_context.context_name
1368                        ,r_context.data_type
1369                        ,l_variable_value) ;
1370 
1371       l_context_store(l_counter).name := r_context.context_name ;
1372       l_context_store(l_counter).value := l_variable_value ;
1373       l_counter := l_counter + 1 ;
1374 
1375     end loop ;  --  c_contexts
1376 
1377     --  call the API
1378 
1379     ff_archive_api.create_archive_item
1380     (p_validate                     => false
1381     ,p_archive_item_id              => l_archive_item_id
1382     ,p_user_entity_id               => l_user_entity_id
1383     ,p_archive_value                => p_result_value
1384     ,p_archive_type                 => 'AAP'
1385     ,p_action_id                    => l_assignment_action_id
1386     ,p_legislation_code             => l_legislation_code
1387     ,p_object_version_number        => l_object_version_number
1388     ,p_context_name1                => l_context_store(1).name
1389     ,p_context1                     => l_context_store(1).value
1390     ,p_context_name2                => l_context_store(2).name
1391     ,p_context2                     => l_context_store(2).value
1392     ,p_context_name3                => l_context_store(3).name
1393     ,p_context3                     => l_context_store(3).value
1394     ,p_context_name4                => l_context_store(4).name
1395     ,p_context4                     => l_context_store(4).value
1396     ,p_context_name5                => l_context_store(5).name
1397     ,p_context5                     => l_context_store(5).value
1398     ,p_context_name6                => l_context_store(6).name
1399     ,p_context6                     => l_context_store(6).value
1400     ,p_context_name7                => l_context_store(7).name
1401     ,p_context7                     => l_context_store(7).value
1402     ,p_context_name8                => l_context_store(8).name
1403     ,p_context8                     => l_context_store(8).value
1404     ,p_context_name9                => l_context_store(9).name
1405     ,p_context9                     => l_context_store(9).value
1406     ,p_context_name10               => l_context_store(10).name
1407     ,p_context10                    => l_context_store(10).value
1408     ,p_context_name11               => l_context_store(11).name
1409     ,p_context11                    => l_context_store(11).value
1410     ,p_context_name12               => l_context_store(12).name
1411     ,p_context12                    => l_context_store(12).value
1412     ,p_context_name13               => l_context_store(13).name
1413     ,p_context13                    => l_context_store(13).value
1414     ,p_context_name14               => l_context_store(14).name
1415     ,p_context14                    => l_context_store(14).value
1416     ,p_context_name15               => l_context_store(15).name
1420     ,p_context_name17               => l_context_store(17).name
1417     ,p_context15                    => l_context_store(15).value
1418     ,p_context_name16               => l_context_store(16).name
1419     ,p_context16                    => l_context_store(16).value
1421     ,p_context17                    => l_context_store(17).value
1422     ,p_context_name18               => l_context_store(18).name
1423     ,p_context18                    => l_context_store(18).value
1424     ,p_context_name19               => l_context_store(19).name
1425     ,p_context19                    => l_context_store(19).value
1426     ,p_context_name20               => l_context_store(20).name
1427     ,p_context20                    => l_context_store(20).value
1428     ,p_context_name21               => l_context_store(21).name
1429     ,p_context21                    => l_context_store(21).value
1430     ,p_context_name22               => l_context_store(22).name
1431     ,p_context22                    => l_context_store(22).value
1432     ,p_context_name23               => l_context_store(23).name
1433     ,p_context23                    => l_context_store(23).value
1434     ,p_context_name24               => l_context_store(24).name
1435     ,p_context24                    => l_context_store(24).value
1436     ,p_context_name25               => l_context_store(25).name
1437     ,p_context25                    => l_context_store(25).value
1438     ,p_context_name26               => l_context_store(26).name
1439     ,p_context26                    => l_context_store(26).value
1440     ,p_context_name27               => l_context_store(27).name
1441     ,p_context27                    => l_context_store(27).value
1442     ,p_context_name28               => l_context_store(28).name
1443     ,p_context28                    => l_context_store(28).value
1444     ,p_context_name29               => l_context_store(29).name
1445     ,p_context29                    => l_context_store(29).value
1446     ,p_context_name30               => l_context_store(30).name
1447     ,p_context30                    => l_context_store(30).value
1448     ,p_context_name31               => l_context_store(31).name
1449     ,p_context31                    => l_context_store(31).value
1450     ,p_some_warning                 => l_some_warning) ;
1451 
1452     hr_utility.trace('Out: ' || l_procedure_name) ;
1453 
1454   exception
1455     when e_bad_user_entity
1456     then
1457       hr_utility.set_message(801, 'HR_AU_INVALID_USER_ENTITY') ;
1458       hr_utility.set_message_token('USER_ENTITY', p_database_item_name) ;
1459       hr_utility.raise_error ;
1460 
1461   end save_result ;
1462 
1463   -----------------------------------------------------------------------------
1464   --  get_module_parameters procedure
1465   --
1466   --  This is a private procedure that is used to get module parameter details
1467   --  and store them in a PL/SQL table.  (This saves some of the repeated
1468   --  accesses of the module parameters table).
1469   -----------------------------------------------------------------------------
1470 
1471   procedure get_module_parameters
1472   (p_module_id                    in     number
1473   ,p_parameters                   out NOCOPY t_parameter_store_tab) is
1474 
1475     l_procedure_name                varchar2(61) := 'pay_au_generic_code_caller.get_module_parameters' ;
1476     l_counter                       number := 1 ;
1477 
1478     cursor c_module_parameters(p_module_id number) is
1479       select mp.internal_name
1480       ,      mp.data_type
1481       ,      mp.input_flag
1482       ,      mp.context_flag
1483       ,      mp.output_flag
1484       ,      mp.result_flag
1485       ,      mp.error_message_flag
1486       ,      mp.function_return_flag
1487       ,      mp.external_name
1488       ,      mp.database_item_name
1489       ,      mp.constant_value
1490       from   pay_au_module_parameters mp
1491       where  mp.module_id = p_module_id
1492       and    mp.enabled_flag = 'Y' ;
1493 
1494   begin
1495 
1496     hr_utility.trace('In: ' || l_procedure_name) ;
1497 
1498     for r_module_parameter in c_module_parameters(p_module_id)
1499     loop
1500 
1501       p_parameters(l_counter).internal_name := r_module_parameter.internal_name ;
1502       p_parameters(l_counter).data_type := r_module_parameter.data_type ;
1503       p_parameters(l_counter).input_flag := r_module_parameter.input_flag ;
1504       p_parameters(l_counter).context_flag := r_module_parameter.context_flag ;
1505       p_parameters(l_counter).output_flag := r_module_parameter.output_flag ;
1506       p_parameters(l_counter).result_flag := r_module_parameter.result_flag ;
1507       p_parameters(l_counter).error_message_flag := r_module_parameter.error_message_flag ;
1508       p_parameters(l_counter).function_return_flag := r_module_parameter.function_return_flag ;
1509       p_parameters(l_counter).external_name := r_module_parameter.external_name ;
1510       p_parameters(l_counter).database_item_name := r_module_parameter.database_item_name ;
1511       p_parameters(l_counter).constant_value := r_module_parameter.constant_value ;
1512 
1513       l_counter := l_counter + 1 ;
1514 
1515     end loop ;  --  c_module_parameters
1516 
1517     hr_utility.trace('Out: ' || l_procedure_name) ;
1518 
1519   end get_module_parameters ;
1520 
1521 end pay_au_generic_code_caller ;