DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_SUPERVISORY_HANDLER

Source


1 package body ame_supervisory_handler as
2 /* $Header: ameesuha.pkb 120.7 2011/05/17 11:43:19 nchinnam ship $ */
3  /* package variables */
4   approverCategories ame_util.charList;
5   parametersCount integer;
6   parameterNumbers ame_util.idList;
7   parameters ame_util.stringList;
8   parameterSigns ame_util.charList;
9   ruleIds ame_util.idList;
10   ruleSatisfiedYN ame_util.charList;
11   topDogPersonId integer;
12   currentSupervisoryLevel integer;
13   /* forward declarations */
14   /*
15     getCatSourceAndAuthority does not account for the ALLOW_REQUESTOR_APPROVAL attribute.
16     The handler procedure does that.
17   */
18   procedure getCatSourceAndAuthority(personIdIn in integer,
19                                      categoryOut out nocopy varchar2,
20                                      sourceOut out nocopy varchar2,
21                                      hasFinalAuthorityYNOut out nocopy varchar2);
22    /*
23     parseAndSortRules populates the parameterNumbers and parameterSigns tables in
24     ascending lexicographic order, first by numerical order, then with '+' dominating '-'.
25     Note that it does not sort the parameters proper.
26   */
27   procedure parseAndSortRules;
28    /*  Functions */
29   function getSupervisor(personIdIn in integer) return integer as
30     errorCode integer;
31     errorMessage ame_util.longestStringType;
32     nullIdException exception;
33     personDisplayName ame_util.longStringType;
34     supervisorPersonId integer;
35     begin
36       select supervisor_id
37       into supervisorPersonId
38       from
39         per_all_assignments_f
40       where
41         person_id = personIdIn and
42         per_all_assignments_f.primary_flag = 'Y' and
43         per_all_assignments_f.assignment_type in ('E','C') and
44         per_all_assignments_f.assignment_status_type_id not in
45           (select assignment_status_type_id
46              from per_assignment_status_types
47              where per_system_status = 'TERM_ASSIGN') and
48         trunc(sysdate) between
49           per_all_assignments_f.effective_start_date and
50           per_all_assignments_f.effective_end_date;
51       if(supervisorPersonId is null) then
52         raise nullIdException;
53       end if;
54       return(supervisorPersonId);
55       exception
56         when nullIdException then
57           personDisplayName := ame_approver_type_pkg.getApproverDisplayName2(
58                                       origSystemIn => ame_util.perOrigSystem,
59                                       origSystemIdIn => personIdIn );
60           errorCode := -20210;
61           errorMessage := ame_util.getMessage(applicationShortNameIn => 'PER',
62             messageNameIn     => 'AME_400297_HAN_LACK_SPVR',
63             tokenNameOneIn    => 'FIRST_NAME',
64             tokenValueOneIn   => personDisplayName,
65             tokenNameTwoIn    => 'LAST_NAME',
66             tokenValueTwoIn   => null ,
67             tokenNameThreeIn  => 'OTHER_NAME',
68             tokenValueThreeIn =>  null );
69           ame_util.runtimeException(packageNameIn => 'ame_supervisory_handler',
70                                     routineNameIn => 'getSupervisor',
71                                     exceptionNumberIn => errorCode,
72                                     exceptionStringIn => errorMessage);
73           raise_application_error(errorCode,
74                                   errorMessage);
75           return(null);
76         when no_data_found then
77           personDisplayName := ame_approver_type_pkg.getApproverDisplayName2(
78                                       origSystemIn => ame_util.perOrigSystem,
79                                       origSystemIdIn => personIdIn );
80           errorCode := -20210;
81           errorMessage := ame_util.getMessage(applicationShortNameIn => 'PER',
82             messageNameIn     => 'AME_400297_HAN_LACK_SPVR',
83             tokenNameOneIn    => 'FIRST_NAME',
84             tokenValueOneIn   => personDisplayName,
85             tokenNameTwoIn    => 'LAST_NAME',
86             tokenValueTwoIn   => null ,
87             tokenNameThreeIn  => 'OTHER_NAME',
88             tokenValueThreeIn =>  null );
89           ame_util.runtimeException(packageNameIn => 'ame_supervisory_handler',
90                                     routineNameIn => 'getSupervisor',
91                                     exceptionNumberIn => errorCode,
92                                     exceptionStringIn => errorMessage);
93           raise_application_error(errorCode,
94                                   errorMessage);
95         when others then
96           ame_util.runtimeException(packageNameIn => 'ame_supervisory_handler',
97                                     routineNameIn => 'getSupervisor',
98                                     exceptionNumberIn => sqlcode,
99                                     exceptionStringIn => sqlerrm);
100           raise;
101           return(null);
102     end getSupervisor;
103    /*  Procedures */
104   procedure getCatSourceAndAuthority(personIdIn in integer,
105                                      categoryOut out nocopy varchar2,
106                                      sourceOut out nocopy varchar2,
107                                      hasFinalAuthorityYNOut out nocopy varchar2) as
108     category ame_util.charType;
109     hasFinalAuthorityYN ame_util.charType;
110     source ame_util.longStringType;
111     supervisorJobLevel integer;
112     tempRuleRequiresApprover boolean;
113     tempRuleSatisfied boolean;
114     begin
115       /*
116         1.  An approver satisfies a rule in any of three cases:
117             A.  The rule's parameter number does not exceed the currentSupervisoryLevel.
118             B.  The rule's parameter sign is '-', and the supervisor level of the approver's
119                 supervisor exceeds the rule's parameter number.
120             C.  The approver is the top dog and the parameter sign is '-' and parameter number
121                 does exceed the currentSupervisoryLevel
122         2.  An approver has final authority if the approver satisfies all the rules.
123         3.  The source value is an ame_util.fieldDelimiter-delimited list of the IDs of the
124             rules that require an approver.  This procedure builds up the source value
125             according to the following logic:
126             A.  If a rule has not yet been satisfied, the rule requires the input
127                 approver.
128         4.  An approver's category is ame_util.approvalApproverCategory if any of the
129             rule usages requiring the approver is of that category; otherwise the
130             approver's category is ame_util.fyiApproverCategory.
131       */
132       if currentSupervisoryLevel is null then
133         currentSupervisoryLevel := 1;
134       else
135         currentSupervisoryLevel := currentSupervisoryLevel + 1;
136       end if;
137       category := ame_util.fyiApproverCategory;
138       hasFinalAuthorityYN := ame_util.booleanTrue;
139       for i in 1 .. parametersCount loop
140         /* Determine whether the approver satisfies the current rule. */
141         if(personIdIn = topDogPersonId) then
142           if(currentSupervisoryLevel < parameterNumbers(i) and
143              parameterSigns(i) = '+')  then
144             tempRuleSatisfied := false;
145           else
146             tempRuleSatisfied := true;
147           end if;
148         else
149           tempRuleSatisfied := false;
150           if(currentSupervisoryLevel >= parameterNumbers(i)) then
151             tempRuleSatisfied := true;
152           elsif(parameterSigns(i) = '-') then
153             if(currentSupervisoryLevel > parameterNumbers(i)) then
154               tempRuleSatisfied := true;
155             end if;
156           end if;
157         end if;
158         /* Update hasFinalAuthorityYN as needed. */
159         if(not tempRuleSatisfied and
160            hasFinalAuthorityYN = ame_util.booleanTrue) then
161           hasFinalAuthorityYN := ame_util.booleanFalse;
162         end if;
163         /* Determine whether the current rule requires the approver. */
164         tempRuleRequiresApprover := false;
165         if(ruleSatisfiedYN(i) = ame_util.booleanTrue) then
166           if(not tempRuleSatisfied) then
167             tempRuleRequiresApprover := true;
168           end if;
169         else
170           tempRuleRequiresApprover := true;
171           if(tempRuleSatisfied) then
172             ruleSatisfiedYN(i) := ame_util.booleanTrue;
173           end if;
174         end if;
175         if(tempRuleRequiresApprover) then
176           /* Update source. */
177           ame_util.appendRuleIdToSource(ruleIdIn => ruleIds(i),
178                                         sourceInOut => source);
179           /* Update category as needed. */
180           if(category = ame_util.fyiApproverCategory and
181              approverCategories(i) = ame_util.approvalApproverCategory) then
182             category := ame_util.approvalApproverCategory;
183           end if;
184         end if;
185       end loop;
186       categoryOut := category;
187       hasFinalAuthorityYNOut := hasFinalAuthorityYN;
188       sourceOut := source;
189       exception
190         when others then
191           categoryOut := null;
192           hasFinalAuthorityYNOut := null;
193           sourceOut := null;
194           ame_util.runtimeException(packageNameIn => 'ame_supervisory_handler',
195                                     routineNameIn => 'getCatSourceAndAuthority',
196                                     exceptionNumberIn => sqlcode,
197                                     exceptionStringIn => sqlerrm);
198           raise;
199     end getCatSourceAndAuthority;
200   procedure handler as
201     COAInsertee ame_util.approverRecord2;
202     errorCode integer;
203     errorMessage ame_util.longestStringType;
204     finalAuthorityFound boolean;
205     firstApproverSource ame_util.longStringType;
206     nullFirstIdException exception;
207     requestorId integer;
208     startingPointId integer;
209     tempApprover ame_util.approverRecord2;
210     tempHasFinalAuthorityYN ame_util.charType;
211     tempMemberOrderNumber integer;
212     tempSupervisorId integer;
213     topDogRequestorException exception;
214     votingRegimeType ame_util.stringType;
215     currentApproverPersonId integer;
216     firstAuthInsExists boolean := false;
217     coaInsAuthForward boolean := false;
218     l_error_code number;
219     begin
220       /* Reset package variables */
221       errorCode := -20226;
222       currentSupervisoryLevel := 0;
223       /*
224         The engine only calls a handler if a rule requiring it exists, so we can assume that
225         the package variables that ame_engine.getHandlerRules2 initializes are nonempty.
226         Fetch the rules and sort them in increasing parameter order.  (Duplicate parameters
227         are harmless here.)
228       */
229       ame_engine.getHandlerRules2(ruleIdsOut => ruleIds,
230                                   approverCategoriesOut => approverCategories,
231                                   parametersOut => parameters);
232       /* Populate some of the package variables. */
233       topDogPersonId := to_number(ame_engine.getHeaderAttValue2(attributeNameIn => ame_util.topSupPersonIdAttribute));
234       parametersCount := parameters.count;
235       parseAndSortRules;
236       for i in 1 .. ruleIds.count loop
237         ruleSatisfiedYN(i) := ame_util.booleanFalse;
238       end loop;
239       /* Set the fields in tempApprover that are constant for the entire handler cycle. */
240       tempApprover.orig_system := ame_util.perOrigSystem;
241       tempApprover.authority := ame_util.authorityApprover;
242       tempApprover.action_type_id := ame_engine.getHandlerActionTypeId;
243       tempApprover.item_class := ame_engine.getHandlerItemClassName;
244       tempApprover.item_id := ame_engine.getHandlerItemId;
245       tempApprover.item_class_order_number := ame_engine.getHandlerItemClassOrderNumber;
246       tempApprover.item_order_number := ame_engine.getHandlerItemOrderNumber;
247       tempApprover.sub_list_order_number := ame_engine.getHandlerSublistOrderNum;
248       tempApprover.action_type_order_number := ame_engine.getHandlerActionTypeOrderNum;
249       tempApprover.group_or_chain_order_number := 1;
250       tempApprover.group_or_chain_id := 1;
251       votingRegimeType := ame_engine.getActionTypeVotingRegime(actionTypeIdIn => tempApprover.action_type_id);
252       /* In a supervisory hierarchy, self approval can not be done. Hence no check needed for it.  */
253       /* Check for COA Insertions */
254       ame_engine.getHandlerCOAFirstApprover(itemClassIn => tempApprover.item_class,
255                                             itemIdIn => tempApprover.item_id,
256                                             actionTypeIdIn => tempApprover.action_type_id,
257                                             groupOrChainIdIn => tempApprover.group_or_chain_id,
258                                             nameOut => COAInsertee.name,
259                                             origSystemOut => COAInsertee.orig_system,
260                                             origSystemIdOut => COAInsertee.orig_system_id,
261                                             displayNameOut => COAInsertee.display_name,
262                                             sourceOut => COAInsertee.source);
263       /*
264         Start building the chain from the COA Insertee if defined otherwise from the non-default
265         starting point or the requestor's supervisor.
266       */
267       if COAInsertee.name is  null then
268         /* Fetch some of the required attributes. */
269         startingPointId :=
270           to_number(ame_engine.getHeaderAttValue2(attributeNameIn => ame_util.supStartingPointAttribute));
271         if(startingPointId is null) then
272           requestorId :=
273              to_number(ame_engine.getHeaderAttValue2(attributeNameIn => ame_util.transactionRequestorAttribute));
274           if (requestorId is null) then
275             raise nullFirstIdException;
276           end if;
277           /* check if requestor is the top supervisor person id */
278           if topDogPersonId = requestorId then
279             tempApprover.orig_system_id := requestorId;
280             /* check if requestor can self approve transaction  */
281             if(ame_engine.getHeaderAttValue2(attributeNameIn => ame_util.allowAutoApprovalAttribute)
282                  = ame_util.booleanAttributeTrue) then
283               getCatSourceAndAuthority(personIdIn => tempApprover.orig_system_id,
284                                        categoryOut => tempApprover.approver_category,
285                                        sourceOut => tempApprover.source,
286                                        hasFinalAuthorityYNOut => tempHasFinalAuthorityYN);
287               tempApprover.occurrence := ame_engine.getHandlerOccurrence(nameIn =>  tempApprover.name,
288                                                 itemClassIn => tempApprover.item_class,
289                                                 itemIdIn => tempApprover.item_id,
290                                                 actionTypeIdIn => tempApprover.action_type_id,
291                                                 groupOrChainIdIn => tempApprover.group_or_chain_id);
292               tempApprover.member_order_number := 1;
293               tempApprover.api_insertion := ame_util.oamGenerated;
294               tempApprover.approval_status := ame_util.approvedStatus;
295               ame_approver_type_pkg.getWfRolesNameAndDisplayName(origSystemIn => ame_util.perOrigSystem,
296                                                            origSystemIdIn => tempApprover.orig_system_id,
297                                                            nameOut => tempApprover.name,
298                                                            displayNameOut => tempApprover.display_name);
299               ame_engine.addApprover(approverIn => tempApprover);
300               return;
301             else
302               /*  raise appropriate exception */
303               raise topDogRequestorException;
304             end if;
305           else
306             tempApprover.orig_system_id := getSupervisor(personIdIn => requestorId);
307           end if;
308         else
309           tempApprover.orig_system_id := startingPointId;
310         end if;
311         tempApprover.api_insertion := ame_util.oamGenerated;
312         ame_approver_type_pkg.getWfRolesNameAndDisplayName(origSystemIn => ame_util.perOrigSystem,
313                                                            origSystemIdIn=> tempApprover.orig_system_id,
314                                                            nameOut => tempApprover.name,
315                                                            displayNameOut => tempApprover.display_name);
316       else
317         tempApprover.name := COAInsertee.name;
318         tempApprover.orig_system := COAInsertee.orig_system;
319         tempApprover.orig_system_id := COAInsertee.orig_system_id;
320         tempApprover.display_name :=  COAInsertee.display_name;
321         firstApproverSource := COAInsertee.source;
322         tempApprover.api_insertion := ame_util.apiAuthorityInsertion;
323         firstAuthInsExists := true;
324       end if;
325       /* Build the chain. */
326       errorCode := -20227;
327       tempMemberOrderNumber := 0; /* pre-increment */
328       loop
329         getCatSourceAndAuthority(personIdIn => tempApprover.orig_system_id,
330                                  categoryOut => tempApprover.approver_category,
331                                  sourceOut => tempApprover.source,
332                                  hasFinalAuthorityYNOut => tempHasFinalAuthorityYN);
333         /* reassign the value of source in case approver was a firstAuthority insertee */
334         if firstApproverSource is not null then
335           tempApprover.source := firstApproverSource;
336           firstApproverSource := null;
337         end if;
338         tempMemberOrderNumber := tempMemberOrderNumber + 1;
339         if(votingRegimeType = ame_util.serializedVoting) then
340           tempApprover.member_order_number := tempMemberOrderNumber;
341         else /* votingRegimeType in (ame_util.consensusVoting, ame_util.firstApproverVoting) */
342           tempApprover.member_order_number := 1;
343         end if;
344         if tempApprover.name is null then
345           ame_approver_type_pkg.getWfRolesNameAndDisplayName(origSystemIn => ame_util.perOrigSystem,
346                                                            origSystemIdIn=> tempApprover.orig_system_id,
347                                                            nameOut => tempApprover.name,
348                                                            displayNameOut => tempApprover.display_name);
349         end if;
350         tempApprover.occurrence := ame_engine.getHandlerOccurrence(nameIn =>  tempApprover.name,
351                                               itemClassIn => tempApprover.item_class,
352                                               itemIdIn => tempApprover.item_id,
353                                               actionTypeIdIn => tempApprover.action_type_id,
354                                               groupOrChainIdIn => tempApprover.group_or_chain_id);
355         tempApprover.approval_status := ame_engine.getHandlerApprovalStatus(approverIn => tempApprover);
356         /* The engine will set tempApprover.approver_order_number; leave it null here. */
357         ame_engine.addApprover(approverIn => tempApprover);
358         /* check to see if there is a COA insertion after this approver. If a COA insertion is
359            found, keep checking till no more COA insertions.
360         */
361         currentApproverPersonId := tempApprover.orig_system_id;
362         loop
363           /* Initialize COAInsertee approver record 2 */
364           COAInsertee := ame_util.emptyApproverRecord2;
365           /* Check if there are any chain of authority insertions */
366           ame_engine.getHandlerCOAInsertion(nameIn => tempApprover.name,
367                                             itemClassIn => tempApprover.item_class,
368                                             itemIdIn => tempApprover.item_id,
369                                             actionTypeIdIn => tempApprover.action_type_id,
370                                             groupOrChainIdIn => tempApprover.group_or_chain_id,
371                                             occurrenceIn => tempApprover.occurrence,
372                                             approvalStatusIn => tempApprover.approval_status,
373                                             nameOut => COAInsertee.name,
374                                             origSystemOut => COAInsertee.orig_system,
375                                             origSystemIdOut => COAInsertee.orig_system_id,
376                                             displayNameOut => COAInsertee.display_name,
377                                             sourceOut => COAInsertee.source);
378           if COAInsertee.name is  null then
379             exit;
380           else
381             if COAInsertee.source <> ame_util.specialForwardInsertion then
382               coaInsAuthForward := true;
383               currentApproverPersonId := COAInsertee.orig_system_id;
384             end if;
385             tempApprover.name := COAInsertee.name;
386             tempApprover.orig_system := COAInsertee.orig_system;
387             tempApprover.orig_system_id := COAInsertee.orig_system_id;
388             tempApprover.display_name :=  COAInsertee.display_name;
389             tempApprover.source := COAInsertee.source;
390             tempApprover.approver_category := ame_util.approvalApproverCategory;
391             tempApprover.api_insertion := ame_util.apiAuthorityInsertion;
392             tempMemberOrderNumber := tempMemberOrderNumber + 1;
393             if(votingRegimeType = ame_util.serializedVoting) then
394               tempApprover.member_order_number := tempMemberOrderNumber;
395             else /* votingRegimeType in (ame_util.consensusVoting, ame_util.firstApproverVoting) */
396               tempApprover.member_order_number := 1;
397             end if;
398             tempApprover.occurrence := ame_engine.getHandlerOccurrence(nameIn =>  tempApprover.name,
399                                               itemClassIn => tempApprover.item_class,
400                                               itemIdIn => tempApprover.item_id,
401                                               actionTypeIdIn => tempApprover.action_type_id,
402                                               groupOrChainIdIn => tempApprover.group_or_chain_id);
403             tempApprover.approval_status := ame_engine.getHandlerApprovalStatus(approverIn => tempApprover);
404             /* If approver has a status of ame_util.approve or ame_util.approveAndForwardStatus or
405                ame_util.nullStatus check to see if approver could have final authority */
406             ame_engine.addApprover(approverIn => tempApprover);
407           end if;
408         end loop;
409         /* Decide whether to end the chain. */
410         if(tempHasFinalAuthorityYN  = ame_util.booleanTrue ) then
411           exit;
412         end if;
413         /* Final authority not found. Need to go up one level. */
414         tempApprover.orig_system_id := getSupervisor(personIdIn => currentApproverPersonId);
415         ame_approver_type_pkg.getWfRolesNameAndDisplayName(origSystemIn => ame_util.perOrigSystem,
416                                                            origSystemIdIn=> tempApprover.orig_system_id,
417                                                            nameOut => tempApprover.name,
418                                                            displayNameOut => tempApprover.display_name);
419         /*if the next approver because of first auth insertion the populate the date and reason*/
420         if firstAuthInsExists then
421           ame_engine.setDeviationReasonDate(ame_approver_deviation_pkg.firstauthHandlerInsReason,null);
422         end if;
423         if coaInsAuthForward then
424           ame_engine.setDeviationReasonDate(ame_approver_deviation_pkg.forwarHandlerAuthInsReason,null);
425         end if;
426         tempApprover.api_insertion := ame_util.oamGenerated;
427       end loop;
428       exception
429         when nullFirstIdException then
430           errorCode := -20106;
431           errorMessage :=
432           ame_util.getMessage(applicationShortNameIn => 'PER',
433                               messageNameIn => 'AME_400233_HAN_NO_TRANS_PER_ID');
434           ame_util.runtimeException(packageNameIn => 'ame_supervisory_handler',
435                                     routineNameIn => 'handler',
436                                     exceptionNumberIn => errorCode,
437                                     exceptionStringIn => errorMessage);
438           raise_application_error(errorCode,
439                                   errorMessage);
440         when topDogRequestorException then
441           errorCode := -20111;
442           errorMessage := ame_util.getMessage(applicationShortNameIn => 'PER',
443                                     messageNameIn => 'AME_400421_REQ_CANNOT_APPROVE');
444           ame_util.runtimeException(packageNameIn => 'ame_supervisory_handler',
445                                     routineNameIn => 'handler',
446                                     exceptionNumberIn => errorCode,
447                                     exceptionStringIn => errorMessage);
448           raise_application_error(errorCode,
449                                   errorMessage);
450         when others then
451           ame_util.runtimeException(packageNameIn => 'ame_supervisory_handler',
452                                     routineNameIn => 'handler',
453                                     exceptionNumberIn => sqlcode,
454                                     exceptionStringIn => sqlerrm);
455           l_error_code := sqlcode;
456           if l_error_code = -20213 then
457             errorMessage := ame_util.getMessage(applicationShortNameIn =>'PER',
458                                               messageNameIn => 'AME_400834_INV_HANDLR_APR',
459                                               tokenNameOneIn  => 'ACTION_TYPE_NAME',
460                                               tokenValueOneIn => ame_engine.getActionTypeName(tempApprover.action_type_id),
461                                               tokenNameTwoIn => 'ORIG_SYSTEM',
462                                               tokenValueTwoIn => ame_util.perOrigSystem,
463                                               tokenNameThreeIn => 'ORIG_SYSEM_ID',
464                                               tokenValueThreeIn => tempApprover.orig_system_id);
465            raise_application_error(errorCode,errorMessage);
466           end if;
467           raise;
468     end handler;
469   procedure parseAndSortRules as
470     badParameterException exception;
471     errorCode integer;
472     errorMessage ame_util.longestStringType;
473     signPosition integer;
474     tempCategory ame_util.charType;
475     tempLength integer;
476     tempNumber integer;
477     tempRuleId integer;
478     tempSign ame_util.charType;
479     upperLimit integer;
480     begin
481       /* Parse. */
482       for i in 1 .. parametersCount loop
483         signPosition := instrb(parameters(i), '-');
484         tempLength := lengthb(parameters(i));
485         if signPosition = 0 then
486           signPosition := instrb(parameters(i), '+');
487           if signPosition = 0 then
488             parameterSigns(i) := '+';
489             parameterNumbers(i) := to_number(parameters(i));
490           else
491             parameterSigns(i) := substrb(parameters(i), tempLength, tempLength);
492             parameterNumbers(i) := to_number(substrb(parameters(i), 1, tempLength - 1));
493           end if;
494         else
495           parameterSigns(i) := substrb(parameters(i), tempLength, tempLength);
496           parameterNumbers(i) := to_number(substrb(parameters(i), 1, tempLength - 1));
497         end if;
498         if(parameterSigns(i) <> '+' and
499            parameterSigns(i) <> '-') then
500           raise badParameterException;
501         end if;
502       end loop;
503       /* Sort. */
504       for i in 2 .. parametersCount loop
505         upperLimit := i - 1;
506         for j in 1 .. upperLimit loop
507           if(parameterNumbers(i) < parameterNumbers(j) or
508              (parameterNumbers(i) = parameterNumbers(j) and
509               parameterSigns(i) = '-' and parameterSigns(j) = '+')) then
510             tempRuleId := ruleIds(j);
511             tempCategory := approverCategories(j);
512             tempNumber := parameterNumbers(j);
513             tempSign := parameterSigns(j);
514             ruleIds(j) := ruleIds(i);
515             approverCategories(j) := approverCategories(i);
516             parameterNumbers(j) := parameterNumbers(i);
517             parameterSigns(j) := parameterSigns(i);
518             ruleIds(i) := tempRuleId;
519             approverCategories(i) := tempCategory;
520             parameterNumbers(i) := tempNumber;
521             parameterSigns(i) := tempSign;
522           end if;
523         end loop;
524       end loop;
525       exception
526         when badParameterException then
527           errorCode := -20001;
528           errorMessage := ame_util.getMessage(applicationShortNameIn => 'PER',
529                                               messageNameIn => 'AME_400234_HAN_ACT_PAR_SIGN');
530           ame_util.runtimeException(packageNameIn => 'ame_supervisory_handler',
531                                     routineNameIn => 'parseAndSortRules',
532                                     exceptionNumberIn => errorCode,
533                                     exceptionStringIn => errorMessage);
534           raise_application_error(errorCode,
535                                   errorMessage);
536         when others then
537           ame_util.runtimeException(packageNameIn => 'ame_supervisory_handler',
538                                     routineNameIn => 'parseAndSortRules',
539                                     exceptionNumberIn => sqlcode,
540                                     exceptionStringIn => sqlerrm);
541           raise;
542     end parseAndSortRules;
543  end ame_supervisory_handler;