DBA Data[Home] [Help]

APPS.AME_ENGINE SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 18

    set engIsTestTransaction to false (via a call to updateTransactionState), and it should
    set engIsLocalTransaction to true.  The API should set both engIsTestTransaction and
    engIsLocalTransaction to false.  The ame_util.runtimeException checks engIsLocalTransaction
    to determine whether to log an exception to the Workflow context stack.
  */
  engIsLocalTransaction boolean := true;
Line: 28

    a value of true in the absence of a call to updateTransactionState, before the
    call to ame_util.runtimeException.  That is, unless a call to updateTransactionState
    sets this variable's value, we assume the transaction is a test transaction, to
    avoid writing spurious exceptions to the Workflow context stack.
   */
  engIsTestTransaction boolean := true;
Line: 35

    updateTransactionState sets the following variables.  They indicate which parts of its
    cycle the engine should or should not execute.
  */
  engPrepareItemData boolean;
Line: 46

  engUpdateCurrentApproverList boolean;
Line: 47

  engUpdateOldApproverList boolean;
Line: 79

  engDeletedApproverList ame_util.approversTable2; /* kept compact */
Line: 80

  engInsertedApproverList ame_util.approversTable2; /* kept compact */
Line: 82

  /* lists related to approver insertion and deletion */
  engInsertionOrderTypeList ame_util.stringList; /* corresponds in order to engInsertedApproverList */
Line: 84

  engInsertionParameterList ame_util.longestStringList; /* corresponds in order to engInsertedApproverList */
Line: 85

  engInsertionIsSpecialForwardee ame_util.charList; /* ame_util.booleanTrue if insertee is a special forwardee */
Line: 86

  engInsApproverIndex ame_util.idList; /*maintain the approver index for the insertion*/
Line: 267

      1.  deletes a row in the compact engApp lists if the rule represented by the row
          is of insufficient relative priority.
      2.  re-compacts the same lists (preserving the above lexicographic ordering).
    At this point, a rule with several actions still appears just once in the engApp
    lists.  The procedure fetchApplicableActions
      1.  populates engAppActionTypeIds, engAppParameters, and engAppParameterTwos.
      2.  splits out the actions in a rule so that the rule has one row in the engApp
          lists for each of the rule's actions.
      3.  converts each combination rule's rule type to the rule type that corresponds
          with the rule's action type.
      4.  re-sorts the lists lexicographically by these values:
            rule's item-class order number
            rule's item-class ID
            item ID of the item to which the rule applies
            rule type
            action-type order number
            action-type ID.
    fetchApplicableActions deletes engAppPriorities because priorities have already been
    processed; so engAppPriorities should not be referenced after fetchApplicableActions
Line: 287

      1.  deletes from the engApp variables any list-creation (authority) rules
          suppressed by the exception rules.
      2.  re-compacts the lists (preserving the above lexicographic ordering).
      3.  converts the exception rules to list-creation rules.
    processExceptions occurs in the engine algorithm after applicable actions have been
    fetched, so that the actions of any list-creation rules suppressed by exception
    rules will have been fetched unnecessarily.  The assumption here is that exception
    rules are deprecated, so if performance becomes an issue, exception rules should be
    converted to list-creation rules with appropriate priorities.
  */
  engAppActionTypeIds ame_util.idList;
Line: 328

     needs to be called a second time after adhoc insertions and surrogate processing */
  engRepeatSubstitutions    boolean;
Line: 399

  engStInsertionIndexes ame_util.idList;
Line: 400

  engInsertionOrderList ame_util.idList;
Line: 403

  engInsertionReasonList ame_util.stringList;
Line: 404

  engInsertionDateList ame_util.dateList;
Line: 462

  procedure fetchDeletedApprovers;
Line: 466

  procedure fetchInsertedApprovers;
Line: 477

  procedure insertIntoTransApprovalHistory
              (transactionIdIn  ame_trans_approval_history.transaction_id%type
              ,applicationIdIn  ame_trans_approval_history.application_id%type
              ,orderNumberIn    ame_trans_approval_history.order_number%type
              ,nameIn           ame_trans_approval_history.name%type
              ,appCategoryIn    ame_trans_approval_history.approver_category%type
              ,itemClassIn      ame_trans_approval_history.item_class%type
              ,itemIdIn         ame_trans_approval_history.item_id%type
              ,actionTypeIdIn   ame_trans_approval_history.action_type_id%type
              ,authorityIn      ame_trans_approval_history.authority%type
              ,statusIn         ame_trans_approval_history.status%type
              ,grpOrChainIdIn   ame_trans_approval_history.group_or_chain_id%type
              ,occurrenceIn     ame_trans_approval_history.occurrence%type
              ,apiInsertionIn   ame_trans_approval_history.api_insertion%type
              ,memberOrderNumberIn ame_trans_approval_history.member_order_number%type
              ,notificationIdIn ame_trans_approval_history.notification_id%type
              ,userCommentsIn   ame_trans_approval_history.user_comments%type
              ,dateClearedIn    ame_trans_approval_history.date_cleared%type
              ,historyTypeIn    varchar2);
Line: 513

  procedure processAdHocInsertions;
Line: 519

  procedure populateInsertionIndexes(indexIn in integer
                                    ,insertionOrderIn in integer);
Line: 526

                       fetchInsertionsIn in boolean,
                       fetchDeletionsIn in boolean,
                       fetchAttributeValuesIn in boolean,
                       fetchInactiveAttValuesIn in boolean,
                       processProductionActionsIn in boolean,
                       processProductionRulesIn in boolean,
                       updateCurrentApproverListIn in boolean,
                       updateOldApproverListIn in boolean,
                       processPrioritiesIn in boolean,
                       prepareItemDataIn in boolean,
                       prepareRuleIdsIn in boolean,
                       prepareRuleDescsIn in boolean,
                       prepareApproverTreeIn in boolean default false,
                       transactionIdIn in varchar2,
                       ameApplicationIdIn in integer default null,
                       fndApplicationIdIn in integer default null,
                       transactionTypeIdIn in varchar2 default null);
Line: 543

  procedure setInsertedApprovalStatus(currentApproverIndexIn in integer
                                      ,approvalStatusIn in varchar2);
Line: 547

  procedure updateOldApproverList;
Line: 912

  function insertionExists(orderTypeIn in varchar2,
                           parameterIn in varchar2) return boolean as
    begin
      for i in 1 .. engInsertionOrderTypeList.count loop
        if(engInsertionOrderTypeList(i) = orderTypeIn and
           engInsertionParameterList(i) = parameterIn) then
          return(true);
Line: 925

                                    routineNameIn => 'insertionExists',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 930

    end insertionExists;
Line: 1030

      select application_id
        into ameApplicationId
        from ame_calling_apps
        where
          fnd_application_id = fndApplicationIdIn and
          ((transactionTypeIdIn is null and transaction_type_id is null) or
           (transaction_type_id = transactionTypeIdIn)) and
          /* Don't use engEffectiveRuleDate here. */
          sysdate between
            start_date and
            nvl(end_date - ame_util.oneSecond, sysdate) and
          rownum < 2; /* Avoids second fetch otherwise required by ANSI standard to check for too many rows. */
Line: 1087

      if(actionTypeIdIn = ame_util.nullInsertionActionTypeId or actionTypeIdIn = -2 ) then
        return(null);
Line: 1138

      if(actionTypeIdIn = ame_util.nullInsertionActionTypeId or actionTypeIdIn = -2 ) then
        return(null);
Line: 1375

                                    isInsertionapprover in boolean default false) return varchar2 as
    l_approvalStatus varchar2(50);
Line: 1387

       if l_approvalStatus is null and (approverIn.action_type_id <> ame_util.nullInsertionActionTypeId and
                          approverIn.action_type_id is not null) and
                          not isInsertionapprover then
        l_action_type_id := approverIn.action_type_id;
Line: 1404

                engOldApproverList(i).api_insertion <> ame_util.apiInsertion and
                engOldApproverList(i).approval_status in (ame_util.approvedStatus
                                                      ,ame_util.beatByFirstResponderStatus
                                                      ,ame_util.rejectStatus  ) then
                 return(ame_util.beatByFirstResponderStatus);
Line: 1551

          If we're not trying to match an inserted approver with nullInsertionActionTypeId and
          nullInsertionGroupOrChainId, and one of the input arguments is null, match the most
          recently added group or chain.
        */
        for i in reverse 1 .. engStApproversCount loop
          if(engStApprovers(i).action_type_id <> ame_util.nullInsertionActionTypeId and
             engStApprovers(i).group_or_chain_id <> ame_util.nullInsertionGroupOrChainId and
             engStApprovers(i).item_class is not null and
             engStApprovers(i).item_id is not null and
             engStApprovers(i).action_type_id is not null and
             engStApprovers(i).group_or_chain_id is not null) then
            itemClass := engStApprovers(i).item_class;
Line: 1577

          One of the input arguments is null, and all approvers in the list have nullInsertionActionTypeId and
          nullInsertionGroupOrChainId.  So these are the only action-type ID and group-or-chain ID we can match.
          In this case, match the item class and item ID of the most recent insertion.
        */
        itemClass := engStApprovers(engStApproversCount).item_class;
Line: 1631

      select state
        into tempState
        from ame_temp_handler_states
        where
          handler_name = handlerName and
          ((application_id is null and engAmeApplicationId is null) or
           (application_id = engAmeApplicationId)) and
          ((parameter is null and parameterIn is null) or
           (parameter = parameterIn)) and
          rownum < 2; /* Avoids second fetch otherwise required by ANSI standard to check for too many rows. */
Line: 1708

      select attribute_value_1 into tempValue from ame_test_trans_att_values
        where application_id = engAmeApplicationId
          and transaction_id = engTransactionId
          and attribute_id = attributeIdIn
          and item_class_id = itemClassIdIn
          and item_id    = itemIdIn;
Line: 1718

            select attribute_value_1
              into tempValue
              from ame_test_trans_att_values
             where application_id = engAmeApplicationId
               and transaction_id = engTransactionId
               and attribute_id = attributeIdIn
               and item_class_id = getItemClassId(ame_util.headerItemClassName)
               and item_id    = engTransactionId;
Line: 1963

  function getNextInsertionOrder return integer as
    maxInsertionOrderNumber number;
Line: 1966

      select max(insertion_order)
        into maxInsertionOrderNumber
        from ame_temp_insertions
       where transaction_id = engTransactionId
         and application_id = engAmeApplicationId;
Line: 1971

      if maxinsertionOrderNumber is null
      then
        return 1;
Line: 1975

        return (maxInsertionOrderNumber + 1);
Line: 1980

                                    routineNameIn => 'getNextInsertionOrder',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 1985

    end getNextInsertionOrder;
Line: 2206

         approverIn.api_insertion is null or
         approverIn.authority is null or
         approverIn.action_type_id is null or
         approverIn.group_or_chain_id is null or
         approverIn.occurrence is null or
         approverIn.source is null or
         approverIn.item_class is null or
         approverIn.item_id is null or
         approverIn.item_class_order_number is null or
         approverIn.item_order_number is null or
         approverIn.sub_list_order_number is null or
         approverIn.action_type_order_number is null or
         approverIn.group_or_chain_order_number is null or
         approverIn.member_order_number is null) then
        raise nullFieldException;
Line: 2336

    /* insert the approver into the tree.In the way if any of other nodes  */
    /* are missing create them.                                            */
    previousTreeNodeIndex := 1;
Line: 2545

        select count(*)
          into tempApproverTypeCount
          from ame_approver_types
         where orig_system = approverIn.orig_system
           and sysdate between start_date and end_date;
Line: 2595

      delete
        from ame_temp_handler_states
        where
          handler_name = handlerName and
          application_id = engAmeApplicationId and
          ((parameter is null and parameterIn is null) or
           (parameter = parameterIn));
Line: 2651

      engAppItemClassIds.delete(tempFirstIndex, tempLastIndex);
Line: 2652

      engAppItemIds.delete(tempFirstIndex, tempLastIndex);
Line: 2653

      engAppApproverCategories.delete(tempFirstIndex, tempLastIndex);
Line: 2654

      engAppRuleIds.delete(tempFirstIndex, tempLastIndex);
Line: 2655

      engRuleAppliedYN.delete(tempFirstIndex, tempLastIndex);
Line: 2656

      engAppRuleTypes.delete(tempFirstIndex, tempLastIndex);
Line: 2657

      engAppRuleItemClassIds.delete(tempFirstIndex, tempLastIndex);
Line: 2658

      engAppAppItemIds.delete(tempFirstIndex, tempLastIndex);
Line: 2660

        engAppPriorities.delete(tempFirstIndex, tempLastIndex);
Line: 2663

        engAppActionTypeIds.delete(tempFirstIndex, tempLastIndex);
Line: 2666

        engAppParameters.delete(tempFirstIndex, tempLastIndex);
Line: 2667

        engAppParameterTwos.delete(tempFirstIndex, tempLastIndex);
Line: 2699

        deletes them in an unpredictable order, and does not re-compact the lists; so the
Line: 2742

        tempPendingRuleIds.delete;
Line: 2757

        /* Delete this condition from currentConditionRuleCounts. */
        currentConditionRuleCounts.delete(tempConditionId);
Line: 2771

            tempIndex2 indexes the current currentAC variables, which may be deleted.  tempIndex3
            indexes tempPendingRuleIds.
          */
          tempIndex := currentACUsageConditionIds.first;
Line: 2782

              currentACUsageConditionIds.delete(tempIndex2);
Line: 2783

              currentACUsageRuleIds.delete(tempIndex2);
Line: 2832

            indexes the current currentAC variable, which may be deleted; and tempIndex3
Line: 2845

                currentACUsageConditionIds.delete(tempIndex2);
Line: 2846

                currentACUsageRuleIds.delete(tempIndex2);
Line: 3044

        deletes them in an unpredictable order, and does not re-compact the lists; so the
Line: 3089

        tempPendingRuleIds.delete;
Line: 3104

        /* Delete this condition from currentConditionRuleCounts. */
        currentConditionRuleCounts.delete(tempConditionId);
Line: 3135

            tempIndex2 indexes the current currentAC variables, which may be deleted.  tempIndex3
            indexes tempPendingRuleIds.
          */
          tempIndex := currentACUsageConditionIds.first;
Line: 3146

              currentACUsageConditionIds.delete(tempIndex2);
Line: 3147

              currentACUsageRuleIds.delete(tempIndex2);
Line: 3191

            indexes the current currentAC variable (which may be deleted).
          */
          for pendingRuleIndex in 1 .. tempPendingRuleIds.count loop
            tempIndex := currentACUsageConditionIds.first;
Line: 3203

                currentACUsageConditionIds.delete(tempIndex2);
Line: 3204

                currentACUsageRuleIds.delete(tempIndex2);
Line: 3242

      select
        ame_rules.rule_id rule_id,
        nvl(ame_rules.item_class_id,
            headerItemClassIdIn) item_class_id,
        ame_rules.rule_type rule_type,
        ame_rule_usages.priority priority,
        ame_rule_usages.approver_category approver_category
      from
        ame_rules,
        ame_rule_usages,
        ame_item_class_usages
      where
        ame_rules.rule_id = ame_rule_usages.rule_id and
        ame_rule_usages.item_id = engAmeApplicationId and
        nvl(ame_rules.item_class_id, headerItemClassIdIn) = ame_item_class_usages.item_class_id and
        ame_item_class_usages.application_id = engAmeApplicationId and
        (processPrioritiesIn = ame_util.booleanFalse or
         (ame_rules.rule_type = ame_util.combinationRuleType and
          (combinationRulePriorityModeIn <> ame_util.absoluteRulePriority or
           combinationRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.authorityRuleType and
          (authorityRulePriorityModeIn <> ame_util.absoluteRulePriority or
           authorityRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.exceptionRuleType and
          (exceptionRulePriorityModeIn <> ame_util.absoluteRulePriority or
           exceptionRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.listModRuleType and
          (listModRulePriorityModeIn <> ame_util.absoluteRulePriority or
           listModRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.substitutionRuleType and
          (substRulePriorityModeIn <> ame_util.absoluteRulePriority or
           substRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.preListGroupRuleType and
          (preRulePriorityModeIn <> ame_util.absoluteRulePriority or
           preRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.postListGroupRuleType and
          (postRulePriorityModeIn <> ame_util.absoluteRulePriority or
           postRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.productionRuleType and
          (productionRulePriorityModeIn <> ame_util.absoluteRulePriority or
           productionRuleThresholdIn >= ame_rule_usages.priority))) and
        (processProductionRulesIn = ame_util.booleanTrue or
         ame_rules.rule_type <> ame_util.productionRuleType) and
        not exists (select *
                      from
                        ame_conditions,
                        ame_condition_usages
                      where
                        ame_conditions.condition_type <> ame_util.listModConditionType and
                        ame_conditions.condition_id = ame_condition_usages.condition_id and
                        ame_condition_usages.rule_id = ame_rules.rule_id and
                        engEffectiveRuleDate between
                          ame_conditions.start_date and
                          nvl(ame_conditions.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
                        engEffectiveRuleDate between
                          ame_condition_usages.start_date and
                          nvl(ame_condition_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
                        /* Avoids second fetch otherwise required by ANSI standard to check for too many rows. */
                        rownum < 2) and
        engEffectiveRuleDate between
          ame_rules.start_date and
          nvl(ame_rules.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
        engEffectiveRuleDate between
          ame_rule_usages.start_date and
          nvl(ame_rule_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
        engEffectiveRuleDate between
          ame_item_class_usages.start_date and
          nvl(ame_item_class_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate)
      order by
        ame_item_class_usages.item_class_order_number,
        item_class_id,
        ame_rules.rule_type,
        ame_rules.rule_id;
Line: 3518

      select
        condition_id,
        string_value
      from ame_string_values
      where
        condition_id in
          (select ame_condition_usages.condition_id
            from
              ame_attributes,
              ame_conditions,
              ame_condition_usages,
              ame_rule_usages
            where
              ame_attributes.attribute_type = ame_util.stringAttributeType and
              ame_attributes.attribute_id = ame_conditions.attribute_id and
              ame_conditions.condition_id = ame_condition_usages.condition_id and
              ame_condition_usages.rule_id = ame_rule_usages.rule_id and
              ame_rule_usages.item_id = engAmeApplicationId and
              engEffectiveRuleDate between
                ame_attributes.start_date and
                nvl(ame_attributes.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
              engEffectiveRuleDate between
                ame_conditions.start_date and
                nvl(ame_conditions.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
              engEffectiveRuleDate between
                ame_condition_usages.start_date and
                nvl(ame_condition_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
              engEffectiveRuleDate between
                ame_rule_usages.start_date and
                nvl(ame_rule_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate)) and
        engEffectiveRuleDate between
          ame_string_values.start_date and
          nvl(ame_string_values.end_date - ame_util.oneSecond, engEffectiveRuleDate)
      order by condition_id;
Line: 3571

      select
        ame_conditions.condition_id condition_id,
        ame_conditions.condition_type condition_type,
        ame_conditions.attribute_id attribute_id,
        ame_conditions.parameter_one parameter_one,
        ame_conditions.parameter_two parameter_two,
        ame_conditions.parameter_three parameter_three,
        ame_conditions.include_lower_limit,
        ame_conditions.include_upper_limit,
        ame_condition_usages.rule_id rule_id,
        ame_rules.rule_type rule_type,
        nvl(ame_rules.item_class_id,
            headerItemClassIdIn) rule_item_class,
        ame_rule_usages.priority priority,
        ame_rule_usages.approver_category
      from
        ame_attributes,
        ame_conditions,
        ame_condition_usages,
        ame_rules,
        ame_rule_usages
      where
        ame_attributes.attribute_id = ame_conditions.attribute_id and
        ame_conditions.condition_type <> ame_util.listModConditionType and
        ame_conditions.condition_id = ame_condition_usages.condition_id and
        ame_condition_usages.rule_id = ame_rules.rule_id and
        ame_rules.rule_id = ame_rule_usages.rule_id and
        ame_rule_usages.item_id = engAmeApplicationId and
        (processPrioritiesIn = ame_util.booleanFalse or
         (ame_rules.rule_type = ame_util.combinationRuleType and
          (combinationRulePriorityModeIn <> ame_util.absoluteRulePriority or
           combinationRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.authorityRuleType and
          (authorityRulePriorityModeIn <> ame_util.absoluteRulePriority or
           authorityRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.exceptionRuleType and
          (exceptionRulePriorityModeIn <> ame_util.absoluteRulePriority or
           exceptionRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.listModRuleType and
          (listModRulePriorityModeIn <> ame_util.absoluteRulePriority or
           listModRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.substitutionRuleType and
          (substRulePriorityModeIn <> ame_util.absoluteRulePriority or
           substRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.preListGroupRuleType and
          (preRulePriorityModeIn <> ame_util.absoluteRulePriority or
           preRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.postListGroupRuleType and
          (postRulePriorityModeIn <> ame_util.absoluteRulePriority or
           postRuleThresholdIn >= ame_rule_usages.priority)) or
         (ame_rules.rule_type = ame_util.productionRuleType and
          (productionRulePriorityModeIn <> ame_util.absoluteRulePriority or
           productionRuleThresholdIn >= ame_rule_usages.priority))) and
        (processProductionRulesIn = ame_util.booleanTrue or
         ame_rules.rule_type <> ame_util.productionRuleType) and
        engEffectiveRuleDate between
          ame_attributes.start_date and
          nvl(ame_attributes.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
        engEffectiveRuleDate between
          ame_conditions.start_date and
          nvl(ame_conditions.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
        engEffectiveRuleDate between
          ame_condition_usages.start_date and
          nvl(ame_condition_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
        engEffectiveRuleDate between
          ame_rules.start_date and
          nvl(ame_rules.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
        engEffectiveRuleDate between
          ame_rule_usages.start_date and
          nvl(ame_rule_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate)
      order by
        rule_item_class,
        ame_rules.rule_type,
        ame_rules.rule_id,
        ame_attributes.item_class_id;
Line: 3814

      select
        ame_actions.action_type_id,
        ame_actions.parameter,
        ame_actions.parameter_two
        from
          ame_actions,
          ame_action_usages
        where
          ame_actions.action_id = ame_action_usages.action_id and
          ame_action_usages.rule_id = ruleIdIn and
          engEffectiveRuleDate between
            ame_actions.start_date and
            nvl(ame_actions.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
          engEffectiveRuleDate between
            ame_action_usages.start_date and
            nvl(ame_action_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate);
Line: 3843

      /* Delete priorities, to make sure they don't get used from here on. */
      engAppPriorities.delete;
Line: 3849

        tempActionTypeIds.delete;
Line: 3850

        tempParameters.delete;
Line: 3851

        tempParameterTwos.delete;
Line: 3939

      engAppLMSubItemClassIds.delete;
Line: 3940

      engAppLMSubItemIds.delete;
Line: 3955

      select
        ame_attributes.attribute_id attribute_id,
        ame_attributes.name attribute_name,
        ame_attributes.attribute_type attribute_type,
        ame_attributes.item_class_id item_class_id,
        ame_attribute_usages.query_string,
        ame_attribute_usages.is_static
        from
          ame_attributes,
          ame_attribute_usages,
          ame_item_class_usages
        where
          ame_attributes.name not in (ame_util.workflowItemKeyAttribute, ame_util.workflowItemTypeAttribute) and
          ame_attributes.attribute_id = ame_attribute_usages.attribute_id and
          ame_attribute_usages.application_id = applicationIdIn and
          ame_item_class_usages.application_id = applicationIdIn and
          ame_attributes.item_class_id = ame_item_class_usages.item_class_id and
          (fetchInactivesIn = ame_util.booleanTrue or
           ame_attribute_usages.use_count > 0 or
           ame_attributes.attribute_id in
            (select ame_attributes2.attribute_id
              from
                ame_attributes ame_attributes2,
                ame_mandatory_attributes
              where
                ame_attributes2.attribute_id = ame_mandatory_attributes.attribute_id and
                ame_mandatory_attributes.action_type_id = -1 and
                engEffectiveRuleDate between
                  ame_attributes2.start_date and
                  nvl(ame_attributes2.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
                engEffectiveRuleDate between
                  ame_mandatory_attributes.start_date and
                  nvl(ame_mandatory_attributes.end_date - ame_util.oneSecond, engEffectiveRuleDate))) and
          engEffectiveRuleDate between
            ame_attributes.start_date and
            nvl(ame_attributes.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
          engEffectiveRuleDate between
            ame_attribute_usages.start_date and
            nvl(ame_attribute_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
          engEffectiveRuleDate between
            ame_item_class_usages.start_date and
            nvl(ame_item_class_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate)
        /*
          The order-by conditions are all necessary.  The second is to break
          item_class_order_number ties in a determinate order.  The third is
          to display attribute names in alphabetical order on the test tab.
          Compare the itemClassUsageCursor cursor in the procedure updateTransactionState.
        */
        order by
          ame_item_class_usages.item_class_order_number,
          ame_item_class_usages.item_class_id,
          ame_attributes.name;
Line: 4008

      select
        attribute_value_1,
        attribute_value_2,
        attribute_value_3
      from ame_test_trans_att_values
      where
        application_id = engAmeApplicationId and
        transaction_id = engTransactionId and
        attribute_id = attributeIdIn
      order by item_id;
Line: 4019

      select attribute_value_1
      from ame_test_trans_att_values
      where
        application_id = engAmeApplicationId and
        transaction_id = engTransactionId and
        attribute_id = attributeIdIn
      order by item_id;
Line: 4027

      select attribute_value_1
      from ame_test_trans_att_values
      where
        application_id = engAmeApplicationId and
        transaction_id = engTransactionId and
        attribute_id = attributeIdIn and
        item_class_id = getItemClassId(ame_util.headerItemClassName) and
        item_id = engTransactionId;
Line: 4063

        in a select statement.
      */
      if(fetchInactivesIn) then
        fetchInactives := ame_util.booleanTrue;
Line: 4128

              tempAttributeValues1.delete;
Line: 4129

              tempAttributeValues2.delete;
Line: 4130

              tempAttributeValues3.delete;
Line: 4221

              tempAttributeValues1.delete;
Line: 4222

              tempAttributeValues2.delete;
Line: 4223

              tempAttributeValues3.delete;
Line: 4380

      select
        ame_attributes.attribute_id attribute_id,
        ame_attributes.name attribute_name,
        ame_attributes.attribute_type attribute_type,
        ame_attributes.item_class_id item_class_id,
        ame_attribute_usages.query_string,
        ame_attribute_usages.is_static
        from
          ame_attributes,
          ame_attribute_usages,
          ame_item_class_usages
        where
          ame_attributes.name not in (ame_util.workflowItemKeyAttribute, ame_util.workflowItemTypeAttribute) and
          ame_attributes.attribute_id = ame_attribute_usages.attribute_id and
          ame_attribute_usages.application_id = applicationIdIn and
          ame_item_class_usages.application_id = applicationIdIn and
          ame_attributes.item_class_id = ame_item_class_usages.item_class_id and
          (ame_attribute_usages.use_count = 0 and
           ame_attributes.attribute_id not in
            (select ame_attributes2.attribute_id
              from
                ame_attributes ame_attributes2,
                ame_mandatory_attributes
              where
                ame_attributes2.attribute_id = ame_mandatory_attributes.attribute_id and
                ame_mandatory_attributes.action_type_id = -1 and
                sysdate between
                  ame_attributes2.start_date and
                  nvl(ame_attributes2.end_date - ame_util.oneSecond, sysdate) and
                sysdate between
                  ame_mandatory_attributes.start_date and
                  nvl(ame_mandatory_attributes.end_date - ame_util.oneSecond, sysdate))) and
          sysdate between
            ame_attributes.start_date and
            nvl(ame_attributes.end_date - ame_util.oneSecond, sysdate) and
          sysdate between
            ame_attribute_usages.start_date and
            nvl(ame_attribute_usages.end_date - ame_util.oneSecond, sysdate) and
          sysdate between
            ame_item_class_usages.start_date and
            nvl(ame_item_class_usages.end_date - ame_util.oneSecond, sysdate) and
            -- Condition to check whether the attribute is used in the rule
            exists
            (
              select 1
               from ame_conditions,
                    ame_condition_usages,
                    ame_rules,
                    ame_rule_usages
              where ame_conditions.attribute_id = ame_attributes.attribute_id
                and ame_conditions.condition_id = ame_condition_usages.condition_id
                and ame_condition_usages.rule_id = ame_rules.rule_id
                and ame_rules.rule_id = ame_rule_usages.rule_id
                and ame_rule_usages.item_id = applicationIdIn
                and ((engEffectiveRuleDate between ame_rules.start_date
                        and nvl(ame_rules.end_date - (1/86400), engEffectiveRuleDate)))
                and ((engEffectiveRuleDate between ame_rule_usages.start_date
                        and nvl(ame_rule_usages.end_date - (1/86400), engEffectiveRuleDate)))
                and engEffectiveRuleDate between ame_conditions.start_date
                      and nvl(ame_conditions.end_date - (1/86400), engEffectiveRuleDate)
                and ((engEffectiveRuleDate between ame_condition_usages.start_date
                      and nvl(ame_condition_usages.end_date - (1/86400), engEffectiveRuleDate)))
              union
              select 1
                from ame_mandatory_attributes,
                     ame_actions,
                     ame_action_usages,
                     ame_rules,
                     ame_rule_usages
               where ame_mandatory_attributes.attribute_id = ame_attributes.attribute_id
                 and ame_mandatory_attributes.action_type_id =
                        ame_actions.action_type_id
                 and ame_actions.action_id = ame_action_usages.action_id
                 and ame_action_usages.rule_id = ame_rules.rule_id
                 and ame_rules.rule_id = ame_rule_usages.rule_id
                 and ame_rule_usages.item_id = applicationIdIn
                 and ((engEffectiveRuleDate between ame_rules.start_date
                 and nvl(ame_rules.end_date - (1/86400), engEffectiveRuleDate)))
                 and ((engEffectiveRuleDate between ame_rule_usages.start_date
                 and nvl(ame_rule_usages.end_date - (1/86400), engEffectiveRuleDate)))
                 and engEffectiveRuleDate between ame_mandatory_attributes.start_date
                 and nvl(ame_mandatory_attributes.end_date - (1/86400), engEffectiveRuleDate)
                 and engEffectiveRuleDate between ame_actions.start_date
                 and nvl(ame_actions.end_date - (1/86400), engEffectiveRuleDate)
                 and ((engEffectiveRuleDate between ame_action_usages.start_date
                 and nvl(ame_action_usages.end_date - (1/86400), engEffectiveRuleDate)))
            )
        /*
          The order-by conditions are all necessary.  The second is to break
          item_class_order_number ties in a determinate order.  The third is
          to display attribute names in alphabetical order on the test tab.
          Compare the itemClassUsageCursor cursor in the procedure updateTransactionState.
        */
        order by
          ame_item_class_usages.item_class_order_number,
          ame_item_class_usages.item_class_id,
          ame_attributes.name;
Line: 4478

      select
        attribute_value_1,
        attribute_value_2,
        attribute_value_3
      from ame_test_trans_att_values
      where
        application_id = engAmeApplicationId and
        transaction_id = engTransactionId and
        attribute_id = attributeIdIn
      order by item_id;
Line: 4489

      select attribute_value_1
      from ame_test_trans_att_values
      where
        application_id = engAmeApplicationId and
        transaction_id = engTransactionId and
        attribute_id = attributeIdIn
      order by item_id;
Line: 4497

      select attribute_value_1
      from ame_test_trans_att_values
      where
        application_id = engAmeApplicationId and
        transaction_id = engTransactionId and
        attribute_id = attributeIdIn and
        item_class_id = getItemClassId(ame_util.headerItemClassName) and
        item_id = engTransactionId;
Line: 4588

              tempAttributeValues1.delete;
Line: 4589

              tempAttributeValues2.delete;
Line: 4590

              tempAttributeValues3.delete;
Line: 4681

              tempAttributeValues1.delete;
Line: 4682

              tempAttributeValues2.delete;
Line: 4683

              tempAttributeValues3.delete;
Line: 4822

      select
        ame_action_type_config.action_type_id,
        ame_action_type_config.voting_regime,
        ame_action_type_config.order_number,
        ame_action_type_config.chain_ordering_mode,
        ame_action_types.name,
        ame_action_types.procedure_name,
        ame_action_type_usages.rule_type
        from
          ame_action_type_config,
          ame_action_types,
          ame_action_type_usages
        where
          ame_action_type_config.application_id = engAmeApplicationId and
          ame_action_types.action_type_id = ame_action_type_config.action_type_id and
          ame_action_type_usages.action_type_id = ame_action_types.action_type_id and
          /*
            Only action types for list-creation and exception rules have two action-type usages;
Line: 4854

      select
        decode(nvl(application_id,0),0,0,-1) application_id,
        /* modified from
           application_id to
           decode(nvl(application_id,0),0,0,-1) application_id
           for the bug 5614208 */
        variable_name,
        variable_value
        from ame_config_vars
        where
          (application_id = 0 or application_id is null or application_id = engAmeApplicationId) and
          /* Config vars can impact the approver list, so use engEffectiveRuleDate here. */
          engEffectiveRuleDate between
            start_date and
            nvl(end_date - ame_util.oneSecond, engEffectiveRuleDate)
        order by
          variable_name,
          application_id;
Line: 4954

  procedure fetchDeletedApprovers as
    cursor deletedApproversCursor(applicationIdIn in integer,
                                  transactionIdIn in varchar2) is
      select
        name,
        item_class,
        item_id,
        approver_category,
        action_type_id,
        group_or_chain_id,
        occurrence,
        effective_date,
        reason
        from ame_temp_deletions
        where
          application_id = applicationIdIn and
          transaction_id = transactionIdIn;
Line: 4982

      open deletedApproversCursor(applicationIdIn => engAmeApplicationId,
                                   transactionIdIn => engTransactionId);
Line: 4984

      fetch deletedApproversCursor bulk collect
        into
          approverNames,
          itemClasses,
          itemIds,
          approverCategories,
          actionTypeIds,
          groupOrChainIds,
          occurrences,
          engSuppressionDateList,
          engSupperssionReasonList;
Line: 4995

      close deletedApproversCursor;
Line: 4998

        engDeletedApproverList(i).name := approverNames(i);
Line: 4999

        engDeletedApproverList(i).item_class := itemClasses(i);
Line: 5000

        engDeletedApproverList(i).item_id := itemIds(i);
Line: 5001

        engDeletedApproverList(i).approver_category := approverCategories(i);
Line: 5002

        engDeletedApproverList(i).action_type_id := actionTypeIds(i);
Line: 5003

        engDeletedApproverList(i).group_or_chain_id := groupOrChainIds(i);
Line: 5004

        engDeletedApproverList(i).occurrence := occurrences(i);
Line: 5008

          if(deletedApproversCursor%isopen) then
            close deletedApproversCursor;
Line: 5012

                                    routineNameIn => 'fetchDeletedApprovers',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 5016

    end fetchDeletedApprovers;
Line: 5017

  procedure fetchInsertedApprovers as
    cursor insertedApproversCursor(applicationIdIn in integer,
                                   transactionIdIn in varchar2) is
      select
        name,
        item_class,
        item_id,
        nvl(approver_category,ame_util.approvalApproverCategory) approver_category,
        api_insertion,
        authority,
        order_type,
        parameter,
        special_forwardee,
        insertion_order,
        effective_date,
        reason,
        approval_status
        from ame_temp_insertions
        where
          application_id = applicationIdIn and
          transaction_id = transactionIdIn
          order by insertion_order;
Line: 5039

    approverApiInsertions ame_util.charList;
Line: 5051

      open insertedApproversCursor(applicationIdIn => engAmeApplicationId,
                                   transactionIdIn => engTransactionId);
Line: 5053

      fetch insertedApproversCursor bulk collect
        into
          approverNames,
          approverItemClasses,
          approverItemIds,
          approverCategories,
          approverApiInsertions,
          approverAuthorities,
          engInsertionOrderTypeList,
          engInsertionParameterList,
          engInsertionIsSpecialForwardee,
          engInsertionOrderList,
          engInsertionDateList,
          engInsertionReasonList,
          approvalStatuses;
Line: 5068

      close insertedApproversCursor;
Line: 5071

        engInsertedApproverList(i).name := approverNames(i);
Line: 5072

        engInsertedApproverList(i).item_class := approverItemClasses(i);
Line: 5073

        engInsertedApproverList(i).item_id := approverItemIds(i);
Line: 5074

        engInsertedApproverList(i).approver_category := approverCategories(i);
Line: 5075

        engInsertedApproverList(i).api_insertion := approverApiInsertions(i);
Line: 5076

        engInsertedApproverList(i).authority := approverAuthorities(i);
Line: 5077

        engInsertedApproverList(i).approval_status := approvalStatuses(i);
Line: 5081

          if(insertedApproversCursor%isopen) then
            close insertedApproversCursor;
Line: 5085

                                    routineNameIn => 'fetchInsertedApprovers',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 5089

    end fetchInsertedApprovers;
Line: 5092

      select
        ame_item_classes.item_class_id,
        ame_item_classes.name,
        ame_item_class_usages.item_id_query,
        ame_item_class_usages.item_class_order_number,
        ame_item_class_usages.item_class_par_mode,
        ame_item_class_usages.item_class_sublist_mode
        from
          ame_item_classes,
          ame_item_class_usages
        where
          ame_item_classes.item_class_id = ame_item_class_usages.item_class_id and
          ame_item_class_usages.application_id = applicationIdIn and
          engEffectiveRuleDate between
            ame_item_classes.start_date and
            nvl(ame_item_classes.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
          engEffectiveRuleDate between
            ame_item_class_usages.start_date and
            nvl(ame_item_class_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate)
        /*
          The order-by conditions are both critical.  The second is to break
          item_class_order_number ties in a determinate order.  Compare the
          attributeCursor cursor in the procedure fetchAttributeValues.
        */
        order by
          ame_item_class_usages.item_class_order_number,
          ame_item_class_usages.item_class_id;
Line: 5120

      select distinct item_id
      from ame_test_trans_att_values
      where
        application_id = engAmeApplicationId and
        transaction_id = engTransactionId and
        item_class_id = itemClassIdIn
      order by item_id;
Line: 5150

        itemIds.delete;
Line: 5264

      select
        fnd_application_id,
        transaction_type_id
        into
          fndApplicationIdOut,
          transactionTypeIdOut
        from ame_calling_apps
        where
          application_id = applicationIdIn and
          /* Don't use engEffectiveRuleDate here. */
          sysdate between
            start_date and
            nvl(end_date - ame_util.oneSecond, sysdate) and
          rownum < 2; /* Avoids second fetch otherwise required by ANSI standard to check for too many rows. */
Line: 5291

      select
        name,
        item_class,
        item_id,
        approver_category,
        api_insertion,
        authority,
        approval_status,
        action_type_id,
        group_or_chain_id,
        occurrence
        from ame_temp_old_approver_lists
        where
          application_id = applicationIdIn and
          transaction_id = transactionIdIn
          order by order_number;
Line: 5308

    approverApiInsertions ame_util.charList;
Line: 5327

          approverApiInsertions,
          approverAuthorities,
          approverStatuses,
          actionTypeIds,
          groupOrChainIds,
          occurrences;
Line: 5340

        engOldApproverList(i).api_insertion := approverApiInsertions(i);
Line: 5370

        select name
          from wf_local_roles
         where orig_system_id = origSystemIdIn
           and orig_system = origSystemIn
           and rownum <2;
Line: 5376

        select 1
         from dual
         where exists
           (select null
             from ame_trans_approval_history a
             where application_id = engAmeApplicationId
               and transaction_id = engTransactionId
               and group_or_chain_id = groupIdIn
               and name = c_nameIn
               and status is not null
               and status in (ame_util.approvedStatus
                                       ,ame_util.beatByFirstResponderStatus
                                       ,ame_util.forwardStatus
                                       ,ame_util.rejectStatus
                                       ,ame_util.approvedByRepeatedStatus
                                       ,ame_util.rejectedByRepeatedStatus
                                       ,ame_util.noResponseStatus
                                       ,ame_util2.noResponseByRepeatedStatus
                                       ,ame_util2.reassignStatus
                                       ,ame_util2.forwardByRepeatedStatus)
               and name = c_nameIn
               and row_timestamp in
               (select max(row_timestamp)
                 from ame_trans_approval_history
                 where application_id = engAmeApplicationId
                   and transaction_id = engTransactionId
                   and group_or_chain_id = groupIdIn
                   and  name = c_nameIn
                  group by name
               ));
Line: 5432

      select
        orig_system,
        orig_system_id,
        parameter,
        upper(parameter_name),
        query_string,
        order_number
        from ame_approval_group_members
        where
          approval_group_id = groupIdIn
        order by order_number;
Line: 5490

        /* This is not the first time this query is being executed, so find and delete all old approvers in this group. */
        for n in 1 .. engGroupMemberGroupIds.count loop
          if( engGroupMemberGroupIds(n) = groupIdIn ) then
            -- delete all occurrences of this
             engGroupMemberGroupIds(n) := null;
Line: 5515

        engGroupMemberGroupIds.delete(outputIndex, engGroupMemberGroupIds.count);
Line: 5519

        tempGroupMembers.delete; -- for bug 4616570
Line: 5956

      select
        order_number,
        voting_regime
        from ame_approval_group_config
        where
          application_id = engAmeApplicationId and
          approval_group_id = groupIdIn and
        engEffectiveRuleDate between
          start_date and
          nvl(end_date - ame_util.oneSecond, engEffectiveRuleDate);
Line: 6044

        approversOut(i).api_insertion := engStApprovers(i).api_insertion;
Line: 6080

        approversOut(i).api_insertion := engStApprovers(i).api_insertion;
Line: 6133

    parameter ame_temp_insertions.parameter%type;
Line: 6148

      for i in 1 .. engInsertedApproverList.count loop
        if(engInsertionParameterList(i) = parameter) then
          nameOut := engInsertedApproverList(i).name;
Line: 6152

            ame_approver_type_pkg.getOrigSystemIdAndDisplayName(nameIn => engInsertedApproverList(i).name,
                                                              origSystemOut => origSystemOut,
                                                              origSystemIdOut => origSystemIdOut,
                                                              displayNameOut => displayNameOut);
Line: 6167

                                              tokenValueTwoIn => engInsertedApproverList(i).name
                                              );
Line: 6173

          sourceOut := ame_util.otherInsertion;
Line: 6174

          setDeviationReasonDate(engInsertionReasonList(i),engInsertionDateList(i));
Line: 6186

  procedure getHandlerCOAInsertion(nameIn in varchar2,
                                   itemClassIn in varchar2,
                                   itemIdIn in varchar2,
                                   actionTypeIdIn in integer,
                                   groupOrChainIdIn in integer,
                                   occurrenceIn in integer,
                                   approvalStatusIn in varchar2,
                                   nameOut out nocopy varchar2,
                                   origSystemOut out nocopy varchar2,
                                   origSystemIdOut out nocopy integer,
                                   displayNameOut out nocopy varchar2,
                                   sourceOut out nocopy varchar2) as
    parameter ame_temp_insertions.parameter%type;
Line: 6215

      for i in 1 .. engInsertedApproverList.count loop
        if(engInsertedApproverList(i).api_insertion = ame_util.apiAuthorityInsertion and
           engInsertionOrderTypeList(i) = ame_util.afterApprover and
           engInsertionParameterList(i) = parameter) then
           nameOut := engInsertedApproverList(i).name;
Line: 6221

            ame_approver_type_pkg.getOrigSystemIdAndDisplayName(nameIn => engInsertedApproverList(i).name,
                                                              origSystemOut => origSystemOut,
                                                              origSystemIdOut => origSystemIdOut,
                                                              displayNameOut => displayNameOut);
Line: 6236

                                              tokenValueTwoIn => engInsertedApproverList(i).name
                                              );
Line: 6242

          if(engInsertionIsSpecialForwardee(i) = ame_util.booleanTrue) then
            sourceOut := ame_util.specialForwardInsertion;
Line: 6245

            sourceOut := ame_util.forwardInsertion;
Line: 6247

            sourceOut := ame_util.approveAndForwardInsertion;
Line: 6249

            sourceOut := ame_util.otherInsertion;
Line: 6251

          setDeviationReasonDate(engInsertionReasonList(i),engInsertionDateList(i));
Line: 6258

                                    routineNameIn => 'getHandlerCOAInsertion',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 6262

    end getHandlerCOAInsertion;
Line: 6659

          itemIdsOut.delete;
Line: 6752

  procedure getInsertions
    (positionIn             in            number
    ,orderTypeIn            in            varchar2 default null
    ,coaInsertionsYNIn      in            varchar2 default ame_util.booleanTrue
    ,availableInsertionsOut    out nocopy ame_util.insertionsTable2
    ) as

    engStApproversCount         integer;
Line: 6760

    availableInsertionsIndex    integer; /* pre-increment */
Line: 6764

    nextApproverDescription     ame_temp_insertions.description%type;
Line: 6765

    prevApproverDescription     ame_temp_insertions.description%type;
Line: 6769

    tempInsertionDoesNotExist   boolean;
Line: 6770

    tempParameter               ame_temp_insertions.parameter%type;
Line: 6782

    availableInsertionsIndex := 0;
Line: 6791

        if (not ame_engine.insertionExists
                  (orderTypeIn   => ame_util.absoluteOrder
                  ,parameterIn   => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 6796

          availableInsertionsOut(availableInsertionsIndex).item_class := ame_util.headerItemClassName;
Line: 6797

          availableInsertionsOut(availableInsertionsIndex).item_id := engTransactionId;
Line: 6798

          availableInsertionsOut(availableInsertionsIndex).action_type_id := null;
Line: 6799

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := null;
Line: 6800

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.absoluteOrder;
Line: 6801

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 6802

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 6803

          availableInsertionsOut(availableInsertionsIndex).authority := ame_util.preApprover;
Line: 6804

          availableInsertionsOut(availableInsertionsIndex).description :=
                                        ame_util.absoluteOrderDescription || positionIn || '.  ';
Line: 6809

        if (not ame_engine.insertionExists
                  (orderTypeIn   => ame_util.absoluteOrder
                  ,parameterIn   => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 6814

          availableInsertionsOut(availableInsertionsIndex).item_class := ame_util.headerItemClassName;
Line: 6815

          availableInsertionsOut(availableInsertionsIndex).item_id := engTransactionId;
Line: 6816

          availableInsertionsOut(availableInsertionsIndex).action_type_id := null;
Line: 6817

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := null;
Line: 6818

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.absoluteOrder;
Line: 6819

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 6820

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 6821

          availableInsertionsOut(availableInsertionsIndex).authority := ame_util.authorityApprover;
Line: 6822

          availableInsertionsOut(availableInsertionsIndex).description :=
                                         ame_util.absoluteOrderDescription || positionIn || '.  ';
Line: 6827

        if (not ame_engine.insertionExists
                  (orderTypeIn   => ame_util.absoluteOrder
                  ,parameterIn   => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 6832

          availableInsertionsOut(availableInsertionsIndex).item_class := ame_util.headerItemClassName;
Line: 6833

          availableInsertionsOut(availableInsertionsIndex).item_id := engTransactionId;
Line: 6834

          availableInsertionsOut(availableInsertionsIndex).action_type_id := null;
Line: 6835

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := null;
Line: 6836

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.absoluteOrder;
Line: 6837

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 6838

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 6839

          availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 6840

          availableInsertionsOut(availableInsertionsIndex).description :=
                                         ame_util.absoluteOrderDescription || positionIn || '.  ';
Line: 6848

          /* Attribute to the insertee the relevant properties of the approver at positionIn. */
          if (not ame_engine.insertionExists
                    (orderTypeIn   => ame_util.absoluteOrder
                    ,parameterIn   => tempParameter
                    )) then
            availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 6854

            availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn).item_class;
Line: 6855

            availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn).item_id;
Line: 6856

            availableInsertionsOut(availableInsertionsIndex).action_type_id := engStApprovers(positionIn).action_type_id;
Line: 6857

            availableInsertionsOut(availableInsertionsIndex).group_or_chain_id :=
                                                                       engStApprovers(positionIn).group_or_chain_id;
Line: 6859

            availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.absoluteOrder;
Line: 6860

            availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 6861

            availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 6862

            availableInsertionsOut(availableInsertionsIndex).authority := engStApprovers(positionIn).authority;
Line: 6863

            availableInsertionsOut(availableInsertionsIndex).description :=
                                         ame_util.absoluteOrderDescription || positionIn || '.  ';
Line: 6871

          those of the approver at positionIn (if any), add a second available insertion, attributing
          to the insertee the relevant properties of engStApprovers(positionIn - 1).
        */
        if (positionIn = engStApproversCount + 1 or
            (positionIn > 1 and
             (engStApprovers(positionIn).group_or_chain_id <> engStApprovers(positionIn - 1).group_or_chain_id or
              engStApprovers(positionIn).action_type_id <> engStApprovers(positionIn - 1).action_type_id or
              engStApprovers(positionIn).item_id <> engStApprovers(positionIn - 1).item_id or
              engStApprovers(positionIn).item_class <> engStApprovers(positionIn - 1).item_class
             ))) then

          /* Attribute to the insertee the relevant properties of the approver at positionIn - 1. */
          if (not ame_engine.insertionExists
                    (orderTypeIn   => ame_util.absoluteOrder
                    ,parameterIn   => tempParameter
                    )) then
            availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 6888

            availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn - 1).item_class;
Line: 6889

            availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn - 1).item_id;
Line: 6890

            availableInsertionsOut(availableInsertionsIndex).action_type_id :=
                                                                   engStApprovers(positionIn - 1).action_type_id;
Line: 6892

            availableInsertionsOut(availableInsertionsIndex).group_or_chain_id :=
                                                                 engStApprovers(positionIn - 1).group_or_chain_id;
Line: 6894

            availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.absoluteOrder;
Line: 6895

            availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 6896

            availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 6897

            availableInsertionsOut(availableInsertionsIndex).authority := engStApprovers(positionIn - 1).authority;
Line: 6898

            availableInsertionsOut(availableInsertionsIndex).description :=
                                                    ame_util.absoluteOrderDescription || positionIn || '.  ';
Line: 6930

                                              tokenValueOneIn => 'ame_engine.getInsertions',
                                              tokenNameTwoIn => 'NAME',
                                              tokenValueTwoIn => engStApprovers(positionIn - 1).name);
Line: 6953

        if (not ame_engine.insertionExists
                  (orderTypeIn   => ame_util.afterApprover
                  ,parameterIn   => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 6958

          availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn - 1).item_class;
Line: 6959

          availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn - 1).item_id;
Line: 6960

          availableInsertionsOut(availableInsertionsIndex).action_type_id :=
                                                                engStApprovers(positionIn - 1).action_type_id;
Line: 6962

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id :=
                                                             engStApprovers(positionIn - 1).group_or_chain_id;
Line: 6964

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.afterApprover;
Line: 6965

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 6966

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 6967

          availableInsertionsOut(availableInsertionsIndex).authority := engStApprovers(positionIn - 1).authority;
Line: 6968

          availableInsertionsOut(availableInsertionsIndex).description :=
                                           ame_util.afterApproverDescription || prevApproverDescription;
Line: 6975

              engStApprovers(positionIn).api_insertion <> ame_util.apiInsertion and
              engStApprovers(positionIn).approver_category = ame_util.approvalApproverCategory and
              coaInsertionsYNIn = ame_util.booleanTrue and
              (not ame_engine.insertionExists
                   (orderTypeIn   => ame_util.afterApprover
                   ,parameterIn   => tempParameter
                   ))) then /* COA */
            availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 6983

            availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn - 1).item_class;
Line: 6984

            availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn - 1).item_id;
Line: 6985

            availableInsertionsOut(availableInsertionsIndex).action_type_id :=
                                                             engStApprovers(positionIn - 1).action_type_id;
Line: 6987

            availableInsertionsOut(availableInsertionsIndex).group_or_chain_id :=
                                                                 engStApprovers(positionIn - 1).group_or_chain_id;
Line: 6989

            availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.afterApprover;
Line: 6991

            availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 6992

            availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiAuthorityInsertion;
Line: 6993

            availableInsertionsOut(availableInsertionsIndex).authority := engStApprovers(positionIn - 1).authority;
Line: 6994

            availableInsertionsOut(availableInsertionsIndex).description :=
                                         ame_util.afterApproverDescription || prevApproverDescription;
Line: 7023

                                              tokenValueOneIn => 'ame_engine.getInsertions',
                                              tokenNameTwoIn => 'NAME',
                                              tokenValueTwoIn =>  engStApprovers(positionIn).name);
Line: 7047

        if (not ame_engine.insertionExists
                  (orderTypeIn   => ame_util.beforeApprover
                  ,parameterIn   => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7052

          availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn).item_class;
Line: 7053

          availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn).item_id;
Line: 7054

          availableInsertionsOut(availableInsertionsIndex).action_type_id := engStApprovers(positionIn).action_type_id;
Line: 7055

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id :=
                                                                    engStApprovers(positionIn).group_or_chain_id;
Line: 7057

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.beforeApprover;
Line: 7058

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7059

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7060

          availableInsertionsOut(availableInsertionsIndex).authority := engStApprovers(positionIn).authority;
Line: 7061

          availableInsertionsOut(availableInsertionsIndex).description :=
                                             ame_util.beforeApproverDescription || nextApproverDescription;
Line: 7071

    if (coaInsertionsYNIn = ame_util.booleanTrue and
        (orderTypeIn is null or
        orderTypeIn = ame_util.firstAuthority)) then

      if (positionIn < engStApproversCount + 1 and
          engStApprovers(positionIn).authority = ame_util.authorityApprover and
          engStApprovers(positionIn).api_insertion <> ame_util.apiInsertion) then
        tempBoolean := true; /* tempBoolean remains true if no previous authority is found. */
Line: 7088

              engStApprovers(i).api_insertion <> ame_util.apiInsertion) then
            tempBoolean := false;
Line: 7105

          if (not ame_engine.insertionExists
                    (orderTypeIn   => ame_util.firstAuthority
                    ,parameterIn   => tempParameter
                    )) then
            availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7110

            availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn).item_class;
Line: 7111

            availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn).item_id;
Line: 7112

            availableInsertionsOut(availableInsertionsIndex).action_type_id :=
                                                                   engStApprovers(positionIn).action_type_id;
Line: 7114

            availableInsertionsOut(availableInsertionsIndex).group_or_chain_id :=
                                                                 engStApprovers(positionIn).group_or_chain_id;
Line: 7116

            availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstAuthority;
Line: 7117

            availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7118

            availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiAuthorityInsertion;
Line: 7119

            availableInsertionsOut(availableInsertionsIndex).authority := ame_util.authorityApprover;
Line: 7120

            availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstAuthorityDescription;
Line: 7128

      Assume that in the case of an entirely empty approver list, we allow insertion of a first
      post-approver into the header item's list only.  Otherwise, we only allow insertion of a
      first post-approver into a non-empty item list.  Here is the case analysis:
          if(the approver list is empty) then
            allow a first-post-approver insertion for the header
          elsif(positionIn is after the end of the approver list) then
            if(the last approver in the list is not a post-approver) then
              allow a first-post-approver insertion for the last approver's item
            end if
          elsif(positionIn = 1) then
            if(the first approver in the list is a post-approver_ then
              allow a first-post-approver insertion for the first approver's item
            end if
          else
            if(the engStApprovers at positionIn - 1 and positionIn are for the same item) then
              if(the first approver is not a post-approver and
                 the second approver is a post-approver) then
                allow a first-post-approver insertion for the engStApprovers' item
              end if
            else
              if(the second approver is a post-approver) then
                allow a first-post-approver insertion for the second approver's item
              end if
              if(the first approver is not a post-approver) then
                allow a first-post-approver insertion for the first approver's item
              end if
            end if
          end if
    */
    if (orderTypeIn is null or
        orderTypeIn = ame_util.firstPostApprover) then

      if (engStApproversCount = 0) then
        tempParameter := ame_util.firstPostParameter ||
                         ame_util.fieldDelimiter ||
                         ame_util.headerItemClassName ||
                         ame_util.fieldDelimiter ||
                         engTransactionId;
Line: 7167

        if (not ame_engine.insertionExists
                  (orderTypeIn => ame_util.firstPostApprover
                  ,parameterIn => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7172

          availableInsertionsOut(availableInsertionsIndex).item_class := ame_util.headerItemClassName;
Line: 7173

          availableInsertionsOut(availableInsertionsIndex).item_id := engTransactionId;
Line: 7174

          availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7175

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7176

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstPostApprover;
Line: 7177

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7178

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7179

          availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 7180

          availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstPostApproverDescription;
Line: 7189

          if (not ame_engine.insertionExists
                    (orderTypeIn   => ame_util.firstPostApprover
                    ,parameterIn   => tempParameter
                    )) then
            availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7194

            availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(engStApproversCount).item_class;
Line: 7195

            availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(engStApproversCount).item_id;
Line: 7196

            availableInsertionsOut(availableInsertionsIndex).action_type_id :=
                                                                        ame_util.nullInsertionActionTypeId;
Line: 7198

            availableInsertionsOut(availableInsertionsIndex).group_or_chain_id :=
                                                                      ame_util.nullInsertionGroupOrChainId;
Line: 7200

            availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstPostApprover;
Line: 7201

            availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7202

            availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7203

            availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 7204

            availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstPostApproverDescription;
Line: 7214

          if (not ame_engine.insertionExists
                    (orderTypeIn   => ame_util.firstPostApprover
                    ,parameterIn   => tempParameter
                    )) then
            availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7219

            availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(1).item_class;
Line: 7220

            availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(1).item_id;
Line: 7221

            availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7222

            availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7223

            availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstPostApprover;
Line: 7224

            availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7225

            availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7226

            availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 7227

            availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstPostApproverDescription;
Line: 7240

            if (not ame_engine.insertionExists
                      (orderTypeIn => ame_util.firstPostApprover
                      ,parameterIn => tempParameter
                      )) then
              availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7245

              availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn).item_class;
Line: 7246

              availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn).item_id;
Line: 7247

              availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7248

              availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7249

              availableInsertionsOut(availableInsertionsIndex).group_or_chain_id :=
                                                            engStApprovers(positionIn).group_or_chain_id;
Line: 7251

              availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstPostApprover;
Line: 7252

              availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7253

              availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7254

              availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 7255

              availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstPostApproverDescription;
Line: 7265

            if (not ame_engine.insertionExists
                      (orderTypeIn   => ame_util.firstPostApprover
                      ,parameterIn   => tempParameter
                      )) then
              availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7270

              availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn).item_class;
Line: 7271

              availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn).item_id;
Line: 7272

              availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7273

              availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7274

              availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstPostApprover;
Line: 7275

              availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7276

              availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7277

              availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 7278

              availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstPostApproverDescription;
Line: 7288

            if (not ame_engine.insertionExists
                      (orderTypeIn   => ame_util.firstPostApprover
                      ,parameterIn   => tempParameter
                      )) then
              availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7293

              availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn - 1).item_class;
Line: 7294

              availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn - 1).item_id;
Line: 7295

              availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7296

              availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7297

              availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstPostApprover;
Line: 7298

              availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7299

              availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7300

              availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 7301

              availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstPostApproverDescription;
Line: 7310

      Assume that in the case of an entirely empty approver list, we allow insertion of a first
      pre-approver into the header item's list only.  Otherwise, we only allow insertion of a
      first pre-approver into a non-empty item list.  Here is the case analysis:
        if(the approver list is empty) then
          allow a first-pre-approver insertion for the header item
        elsif(positionIn = 1) then
          allow a first-pre-approver insertion for the first approver's item
        elsif(positionIn < engStApproversCount + 1) then
          if(the engStApprovers at positionIn - 1 and positionIn are for different items) then
            allow a first-pre-approver insertion for the second approver's item
          end if
        end if
    */
    if (orderTypeIn is null or
        orderTypeIn = ame_util.firstPreApprover) then

      if (engStApproversCount = 0) then
        tempParameter := ame_util.firstPreApprover ||
                         ame_util.fieldDelimiter ||
                         ame_util.headerItemClassName ||
                         ame_util.fieldDelimiter ||
                         engTransactionId;
Line: 7332

        if (not ame_engine.insertionExists
                  (orderTypeIn => ame_util.firstPreApprover
                  ,parameterIn => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7337

          availableInsertionsOut(availableInsertionsIndex).item_class := ame_util.headerItemClassName;
Line: 7338

          availableInsertionsOut(availableInsertionsIndex).item_id := engTransactionId;
Line: 7339

          availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7340

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7341

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstPreApprover;
Line: 7342

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7343

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7344

          availableInsertionsOut(availableInsertionsIndex).authority := ame_util.preApprover;
Line: 7345

          availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstPreApproverDescription;
Line: 7353

        if (not ame_engine.insertionExists
                  (orderTypeIn   => ame_util.firstPreApprover
                  ,parameterIn   => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7358

          availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(1).item_class;
Line: 7359

          availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(1).item_id;
Line: 7360

          availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7361

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7362

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstPreApprover;
Line: 7363

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7364

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7365

          availableInsertionsOut(availableInsertionsIndex).authority := ame_util.preApprover;
Line: 7366

          availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstPreApproverDescription;
Line: 7376

          if (not ame_engine.insertionExists
                    (orderTypeIn   => ame_util.firstPreApprover
                    ,parameterIn   => tempParameter
                    )) then
            availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7381

            availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn).item_class;
Line: 7382

            availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn).item_id;
Line: 7383

            availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7384

            availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7385

            availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.firstPreApprover;
Line: 7386

            availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7387

            availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7388

            availableInsertionsOut(availableInsertionsIndex).authority := ame_util.preApprover;
Line: 7389

            availableInsertionsOut(availableInsertionsIndex).description := ame_util.firstPreApproverDescription;
Line: 7397

      Assume that in the case of an entirely empty approver list, we allow insertion of a last
      post-approver into the header item's list only.  Otherwise, we only allow insertion of a
      last post-approver into a non-empty item list.  Here is the case analysis:
        if(the approver list is empty) then
          allow last-post-approver insertion for the header item
        elsif(positionIn = engStApproversCount + 1) then
          allow last-post-approver insertion for the last approver's item
        elsif(positionIn > 1) then
          if(the engStApprovers at positionIn - 1 and positionIn are for different items) then
            allow last-post-approver insertion for the former approver's item
          end if
        end if
    */
    if (orderTypeIn is null or
        orderTypeIn = ame_util.lastPostApprover) then
      if (engStApproversCount = 0) then
        tempParameter := ame_util.lastPostApprover ||
                         ame_util.fieldDelimiter ||
                         ame_util.headerItemClassName ||
                         ame_util.fieldDelimiter ||
                         engTransactionId;
Line: 7418

        if (not ame_engine.insertionExists
                  (orderTypeIn   => ame_util.lastPostApprover
                  ,parameterIn   => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7423

          availableInsertionsOut(availableInsertionsIndex).item_class := ame_util.headerItemClassName;
Line: 7424

          availableInsertionsOut(availableInsertionsIndex).item_id := engTransactionId;
Line: 7425

          availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7426

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7427

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.lastPostApprover;
Line: 7428

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7429

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7430

          availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 7431

          availableInsertionsOut(availableInsertionsIndex).description := ame_util.lastPostApproverDescription;
Line: 7439

        if (not ame_engine.insertionExists
                  (orderTypeIn => ame_util.lastPostApprover
                  ,parameterIn => tempParameter
                  )) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7444

          availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(engStApproversCount).item_class;
Line: 7445

          availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(engStApproversCount).item_id;
Line: 7446

          availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7447

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7448

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.lastPostApprover;
Line: 7449

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7450

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7451

          availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 7452

          availableInsertionsOut(availableInsertionsIndex).description := ame_util.lastPostApproverDescription;
Line: 7462

          if (not ame_engine.insertionExists
                    (orderTypeIn   => ame_util.lastPostApprover
                    ,parameterIn   => tempParameter
                    )) then
            availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7467

            availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn - 1).item_class;
Line: 7468

            availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn - 1).item_id;
Line: 7469

            availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7470

            availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7471

            availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.lastPostApprover;
Line: 7472

            availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7473

            availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7474

            availableInsertionsOut(availableInsertionsIndex).authority := ame_util.postApprover;
Line: 7475

            availableInsertionsOut(availableInsertionsIndex).description := ame_util.lastPostApproverDescription;
Line: 7483

      Assume that in the case of an entirely empty approver list, we allow insertion of a last
      pre-approver into the header item's list only.  Otherwise, we only allow insertion of a
      last pre-approver into a non-empty item list.  Here is the case analysis:
        if(the approver list is empty) then
          allow last-pre-approver insertion for the header item
        elsif(positionIn = 1) then
          if(the approver at position 1 is not a pre-approver) then
            allow last-pre-approver insertion for the item of the first approver
          end if
        elsif(positionIn <= engStApproversCount) then
          if(the engStApprovers at positionIn - 1 and positionIn are for the same item) then
            if(the approver at positionIn - 1 is a pre-approver and
               the approver at positionIn is not a pre-approver) then
              allow last-pre-approver insertion for the engStApprovers' item
            end if
          else
            if(the approver at positionIn is not a pre-approver) then
              allow last-pre-approver insertion for the item of the approver at positionIn
            end if
          end if
        end if
    */
    if (orderTypeIn is null or
        orderTypeIn = ame_util.lastPreApprover) then
      if (engStApproversCount = 0) then
        tempParameter := ame_util.lastPreApprover ||
                         ame_util.fieldDelimiter ||
                         ame_util.headerItemClassName ||
                         ame_util.fieldDelimiter ||
                         engTransactionId;
Line: 7513

        if (not ame_engine.insertionExists
                  (orderTypeIn => ame_util.lastPreApprover
                  ,parameterIn => tempParameter)) then
          availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7517

          availableInsertionsOut(availableInsertionsIndex).item_class := ame_util.headerItemClassName;
Line: 7518

          availableInsertionsOut(availableInsertionsIndex).item_id := engTransactionId;
Line: 7519

          availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7520

          availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7521

          availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.lastPreApprover;
Line: 7522

          availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7523

          availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7524

          availableInsertionsOut(availableInsertionsIndex).authority := ame_util.preApprover;
Line: 7525

          availableInsertionsOut(availableInsertionsIndex).description := ame_util.lastPreApproverDescription;
Line: 7534

          if (not ame_engine.insertionExists
                    (orderTypeIn   => ame_util.lastPreApprover
                    ,parameterIn   => tempParameter
                    )) then
            availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7539

            availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(1).item_class;
Line: 7540

            availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(1).item_id;
Line: 7541

            availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7542

            availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7543

            availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.lastPreApprover;
Line: 7544

            availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7545

            availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7546

            availableInsertionsOut(availableInsertionsIndex).authority := ame_util.preApprover;
Line: 7547

            availableInsertionsOut(availableInsertionsIndex).description := ame_util.lastPreApproverDescription;
Line: 7560

            if (not ame_engine.insertionExists
                      (orderTypeIn  => ame_util.lastPreApprover
                      ,parameterIn  => tempParameter
                      )) then
              availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7565

              availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn).item_class;
Line: 7566

              availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn).item_id;
Line: 7567

              availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7568

              availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7569

              availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.lastPreApprover;
Line: 7570

              availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7571

              availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7572

              availableInsertionsOut(availableInsertionsIndex).authority := ame_util.preApprover;
Line: 7573

              availableInsertionsOut(availableInsertionsIndex).description := ame_util.lastPreApproverDescription;
Line: 7583

            if (not ame_engine.insertionExists
                      (orderTypeIn   => ame_util.lastPreApprover
                      ,parameterIn   => tempParameter
                      )) then
              availableInsertionsIndex := availableInsertionsIndex + 1;
Line: 7588

              availableInsertionsOut(availableInsertionsIndex).item_class := engStApprovers(positionIn).item_class;
Line: 7589

              availableInsertionsOut(availableInsertionsIndex).item_id := engStApprovers(positionIn).item_id;
Line: 7590

              availableInsertionsOut(availableInsertionsIndex).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 7591

              availableInsertionsOut(availableInsertionsIndex).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 7592

              availableInsertionsOut(availableInsertionsIndex).order_type := ame_util.lastPreApprover;
Line: 7593

              availableInsertionsOut(availableInsertionsIndex).parameter := tempParameter;
Line: 7594

              availableInsertionsOut(availableInsertionsIndex).api_insertion := ame_util.apiInsertion;
Line: 7595

              availableInsertionsOut(availableInsertionsIndex).authority := ame_util.preApprover;
Line: 7596

              availableInsertionsOut(availableInsertionsIndex).description := ame_util.lastPreApproverDescription;
Line: 7608

        ,messageNameIn            => 'AME_400418_INVALID_INSERTION'
        );
Line: 7612

        ,routineNameIn     => 'getInsertions'
        ,exceptionNumberIn => errorCode
        ,exceptionStringIn => errorMessage
        );
Line: 7621

        ,routineNameIn     => 'getInsertions'
        ,exceptionNumberIn => sqlcode
        ,exceptionStringIn => sqlerrm
        );
Line: 7626

  end getInsertions;
Line: 7639

        /* Select the values, as they were not cached. */
        select
          ame_conditions.parameter_one,
          ame_conditions.parameter_two
          into
            parameterOne,
            parameterTwo
          from
            ame_conditions,
            ame_condition_usages
          where
            ame_condition_usages.rule_id = ruleIdIn and
            ame_condition_usages.condition_id = ame_conditions.condition_id and
            ame_conditions.condition_type = ame_util.listModConditionType and
            engEffectiveRuleDate between
              ame_conditions.start_date and
              nvl(ame_conditions.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
            engEffectiveRuleDate between
              ame_condition_usages.start_date and
              nvl(ame_condition_usages.end_date - ame_util.oneSecond, engEffectiveRuleDate) and
            rownum < 2; /* Avoids second fetch otherwise required by ANSI standard to check for too many rows. */
Line: 7759

      ame_engine.updateTransactionState(isTestTransactionIn  => false
                                       ,isLocalTransactionIn => false
                                       ,fetchConfigVarsIn    => true
                                       ,fetchOldApproversIn  => true
                                       ,fetchInsertionsIn    => true
                                       ,fetchDeletionsIn     => true
                                       ,fetchAttributeValuesIn      => true
                                       ,fetchInactiveAttValuesIn    => false
                                       ,processProductionActionsIn  => tempProcessProductionActions
                                       ,processProductionRulesIn    => tempProcessProductionRules
                                       ,updateCurrentApproverListIn => true
                                       ,updateOldApproverListIn     => true
                                       ,processPrioritiesIn   => true
                                       ,prepareItemDataIn     => tempPrepareItemData
                                       ,prepareRuleIdsIn      => false
                                       ,prepareRuleDescsIn    => false
                                       ,prepareApproverTreeIn => true
                                       ,transactionIdIn       => transactionIdIn
                                       ,ameApplicationIdIn    => null
                                       ,fndApplicationIdIn    => applicationIdIn
                                       ,transactionTypeIdIn   => transactionTypeIn);
Line: 7835

                setInsertedApprovalStatus(currentApproverIndexIn => currentTreeNode.approver_index
                                           ,approvalStatusIn => ame_util.notifiedStatus );
Line: 7852

                  update ame_temp_old_approver_lists
                     set approval_status = ame_util.notifiedByRepeatedStatus
                   where application_id = ameApplicationId
                     and transaction_id = transactionIdIn
                     and name           = engStApprovers(engStRepeatedAppIndexes(x)).name --nextApproversOut(i).name
                     and item_class        = engStApprovers(engStRepeatedAppIndexes(x)).item_class
                     and item_id           = engStApprovers(engStRepeatedAppIndexes(x)).item_id
                     and action_type_id    = engStApprovers(engStRepeatedAppIndexes(x)).action_type_id
                     and group_or_chain_id = engStApprovers(engStRepeatedAppIndexes(x)).group_or_chain_id
                     and occurrence        = engStApprovers(engStRepeatedAppIndexes(x)).occurrence
                     and (approval_status is null or approval_status = ame_util.repeatedStatus);
Line: 7864

                     setInsertedApprovalStatus(currentApproverIndexIn => engStRepeatedAppIndexes(x)
                                    ,approvalStatusIn => ame_util.notifiedByRepeatedStatus);
Line: 7903

                  setInsertedApprovalStatus(currentApproverIndexIn => engStApproversTree(currentTreeNode.sibling_index).approver_index
                                           ,approvalStatusIn =>ame_util.notifiedStatus );
Line: 7921

                    update ame_temp_old_approver_lists
                       set approval_status = ame_util.notifiedByRepeatedStatus
                     where application_id = ameApplicationId
                       and transaction_id = transactionIdIn
                       and name           = engStApprovers(engStRepeatedAppIndexes(x)).name --nextApproversOut(i).name
                       and item_class        = engStApprovers(engStRepeatedAppIndexes(x)).item_class
                       and item_id           = engStApprovers(engStRepeatedAppIndexes(x)).item_id
                       and action_type_id    = engStApprovers(engStRepeatedAppIndexes(x)).action_type_id
                       and group_or_chain_id = engStApprovers(engStRepeatedAppIndexes(x)).group_or_chain_id
                       and occurrence        = engStApprovers(engStRepeatedAppIndexes(x)).occurrence
                       and (approval_status is null or approval_status = ame_util.repeatedStatus);
Line: 7933

                       setInsertedApprovalStatus(currentApproverIndexIn => engStRepeatedAppIndexes(x)
                                                ,approvalStatusIn => ame_util.notifiedByRepeatedStatus);
Line: 8063

            update ame_temp_old_approver_lists
               set approval_status = ame_util.notifiedStatus
             where item_class = nextApproversOut(i).item_class
               and item_id = nextApproversOut(i).item_id
               and name = nextApproversOut(i).name
               and action_type_id = nextApproversOut(i).action_type_id
               and group_or_chain_id = nextApproversOut(i).group_or_chain_id
               and occurrence = nextApproversOut(i).occurrence
               and transaction_id = transactionIdIn
               and application_id = ameApplicationId;
Line: 8073

           /* Insert into Approval Notification History Table */
          insertIntoTransApprovalHistory
            (transactionIdIn         => transactionIdIn
            ,applicationIdIn         => ameApplicationId
            ,orderNumberIn           => nextApproversOut(i).approver_order_number
            ,nameIn                  => nextApproversOut(i).name
            ,appCategoryIn           => nextApproversOut(i).approver_category
            ,itemClassIn             => nextApproversOut(i).item_class
            ,itemIdIn                => nextApproversOut(i).item_id
            ,actionTypeIdIn          => nextApproversOut(i).action_type_id
            ,authorityIn             => nextApproversOut(i).authority
            ,statusIn                => ame_util.notifiedStatus
            ,grpOrChainIdIn          => nextApproversOut(i).group_or_chain_id
            ,occurrenceIn            => nextApproversOut(i).occurrence
            ,apiInsertionIn          => nextApproversOut(i).api_insertion
            ,memberOrderNumberIn     => nextApproversOut(i).member_order_number
            ,notificationIdIn        => null
            ,userCommentsIn          => null
            ,dateClearedIn           => null
            ,historyTypeIn           => 'APPROVERPRESENT');
Line: 8122

        nextApproversOut.delete;
Line: 8211

            tempRuleIdList.delete;
Line: 8243

        itemIndexesOut.delete;
Line: 8244

        itemItemClassesOut.delete;
Line: 8245

        itemIdsOut.delete;
Line: 8246

        itemSourcesOut.delete;
Line: 8284

        tempRuleIdList.delete;
Line: 8330

          tempRuleIdList.delete;
Line: 8370

        prodIndexesOut.delete;
Line: 8371

        productionNamesOut.delete;
Line: 8372

        productionValuesOut.delete;
Line: 8394

        tempRuleIdList.delete;
Line: 8417

          tempRuleIdList.delete;
Line: 8460

        engStRuleDescriptions.delete;
Line: 8461

        engStRuleIds.delete;
Line: 8462

        engStRuleIndexes.delete;
Line: 8743

        select count(*)
          into tempCount
          from ame_temp_transactions
          where
            application_id = ameApplicationIdIn and
            transaction_id = transactionIdIn and
            rownum < 2; /* Avoids second fetch otherwise required by ANSI standard to check for too many rows. */
Line: 8751

          insert into ame_temp_transactions(
            application_id,
            transaction_id,
            temp_transactions_id,
            row_timestamp) values(
              ameApplicationIdIn,
              transactionIdIn,
              -1,
              sysdate); /* Don't use engEffectiveRuleDate here. */
Line: 8760

          updateTransactionState(isTestTransactionIn => false,
                                 isLocalTransactionIn => true,
                                 fetchConfigVarsIn => true,
                                 fetchOldApproversIn => true,
                                 fetchInsertionsIn => true,
                                 fetchDeletionsIn => true,
                                 fetchAttributeValuesIn => true,
                                 fetchInactiveAttValuesIn => false,
                                 processProductionActionsIn => false,
                                 processProductionRulesIn => false,
                                 updateCurrentApproverListIn => true,
                                 updateOldApproverListIn => true,
                                 processPrioritiesIn => true,
                                 prepareItemDataIn => true,
                                 prepareRuleIdsIn => true,
                                 prepareRuleDescsIn => false,
                                 prepareApproverTreeIn => true,
                                 transactionIdIn => transactionIdIn,
                                 ameApplicationIdIn => ameApplicationIdIn);
Line: 8785

                 fetchInsertionsIn => approverListStageIn > 1,
                 fetchDeletionsIn => approverListStageIn > 2,
                 fetchAttributeValuesIn => true,
                 fetchInactiveAttValuesIn => false,
                 processProductionActionsIn => true,
                 processProductionRulesIn => true,
                 updateCurrentApproverListIn => true,
                 updateOldApproverListIn => true,
                 processPrioritiesIn => true,
                 prepareItemDataIn => true,
                 prepareRuleIdsIn => true,
                 prepareRuleDescsIn => false,
                 prepareApproverTreeIn => true,
                 transactionIdIn => transactionIdIn,
                 ameApplicationIdIn => ameApplicationIdIn);
Line: 8805

        processAdHocInsertions;
Line: 8907

                                   fetchInsertionsIn in boolean default true,
                                   fetchDeletionsIn in boolean default true,
                                   fetchAttributeValuesIn in boolean default true,
                                   fetchInactiveAttValuesIn in boolean default false) as
    begin
      setContext(isTestTransactionIn => false,
                 isLocalTransactionIn => true,
                 fetchConfigVarsIn => true,
                 fetchOldApproversIn => true,
                 fetchInsertionsIn => true,
                 fetchDeletionsIn => true,
                 fetchAttributeValuesIn => true,
                 fetchInactiveAttValuesIn => false,
                 processProductionActionsIn => false,
                 processProductionRulesIn => false,
                 updateCurrentApproverListIn => true,
                 updateOldApproverListIn => true,
                 processPrioritiesIn => true,
                 prepareItemDataIn => false,
                 prepareRuleIdsIn => false,
                 prepareRuleDescsIn => false,
                 prepareApproverTreeIn => false,
                 transactionIdIn => transactionIdIn,
                 ameApplicationIdIn => ameApplicationIdIn,
                 fndApplicationIdIn => null,
                 transactionTypeIdIn => transactionTypeIdIn);
Line: 8941

  procedure updateDeviationList( sourceIndexIn in number
                              ,targetIndexIn in number) as
  begin
   if engDeviationResultList.exists(sourceIndexIn) then
     engDeviationResultList(targetIndexIn) := engDeviationResultList(sourceIndexIn);
Line: 8946

     engDeviationResultList.delete(sourceIndexIn);
Line: 8953

                                routineNameIn => 'updateDeviationList',
                                exceptionNumberIn => sqlcode,
                                exceptionStringIn => sqlerrm);
Line: 8956

  end updateDeviationList;
Line: 8957

  procedure insertApprover(indexIn in integer,
                           approverIn in ame_util.approverRecord2,
                           adjustMemberOrderNumbersIn in boolean default false,
                           approverLocationIn in boolean default ame_util.lastAmongEquals,
                           inserteeIndexIn in number default null,
                           currentInsIndex in integer default null) as
    engStApproversCount integer;
Line: 9018

       If the status is not available in ame_temp_insertions get it from
       ame_temp_old_approver_lists
      */
      if engStApprovers(indexIn).approval_status is null then
         engStApprovers(indexIn).approval_status :=  getHandlerApprovalStatus(approverIn => engStApprovers(indexIn)
                                                     ,isInsertionapprover => true);
Line: 9070

                select voting_regime
                  into tempVotingRegime
                  from ame_approval_group_config
                 where approval_group_id = engStApprovers(previousIndex).group_or_chain_id
                   and application_id = engAmeApplicationId
                   and sysdate between start_date and nvl(end_Date - (1/86400), sysdate);
Line: 9159

          if inserteeIndexIn is not null then
            engTempReason := engInsertionReasonList(inserteeIndexIn);
Line: 9161

            engTempDate := engInsertionDateList(inserteeIndexIn);
Line: 9172

        /* is true update the member order number in the tree                       */
        /* Add the approver to tree                                                 */
          if adjustMemberOrderNumbersIn then
            approverTreeIndex := engStApproversTree.first;
Line: 9193

          if inserteeIndexIn is not null then
            engTempReason := engInsertionReasonList(inserteeIndexIn);
Line: 9195

            engTempDate := engInsertionDateList(inserteeIndexIn);
Line: 9212

                                    routineNameIn => 'insertApprover',
                                    exceptionNumberIn => errorCode,
                                    exceptionStringIn => errorMessage);
Line: 9219

                                    routineNameIn => 'insertApprover',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 9223

    end insertApprover;
Line: 9224

  procedure insertApprovers(firstIndexIn in integer,
                            approversIn in ame_util.approversTable2) as
    approversInCount integer;
Line: 9260

      /* Insert the new approvers to the tree */
      if engPrepareApproverTree then
        /* Approvers Tree is sparse */
        loopIndex := engStApproversTree.last;
Line: 9295

                                    routineNameIn => 'insertApprovers',
                                    exceptionNumberIn => errorCode,
                                    exceptionStringIn => errorMessage);
Line: 9302

                                    routineNameIn => 'insertApprovers',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 9306

    end insertApprovers;
Line: 9307

  procedure insertIntoTransApprovalHistory
              (transactionIdIn  ame_trans_approval_history.transaction_id%type
              ,applicationIdIn  ame_trans_approval_history.application_id%type
              ,orderNumberIn    ame_trans_approval_history.order_number%type
              ,nameIn           ame_trans_approval_history.name%type
              ,appCategoryIn    ame_trans_approval_history.approver_category%type
              ,itemClassIn      ame_trans_approval_history.item_class%type
              ,itemIdIn         ame_trans_approval_history.item_id%type
              ,actionTypeIdIn   ame_trans_approval_history.action_type_id%type
              ,authorityIn      ame_trans_approval_history.authority%type
              ,statusIn         ame_trans_approval_history.status%type
              ,grpOrChainIdIn   ame_trans_approval_history.group_or_chain_id%type
              ,occurrenceIn     ame_trans_approval_history.occurrence%type
              ,apiInsertionIn   ame_trans_approval_history.api_insertion%type
              ,memberorderNumberIn ame_trans_approval_history.member_order_number%type
              ,notificationIdIn ame_trans_approval_history.notification_id%type
              ,userCommentsIn   ame_trans_approval_history.user_comments%type
              ,dateClearedIn    ame_trans_approval_history.date_cleared%type
              ,historyTypeIn    varchar2) as
    tempTransHistoryId ame_trans_approval_history.trans_history_id%type;
Line: 9334

    tempApiInsertion   ame_trans_approval_history.api_insertion%type;
Line: 9351

            select ame_trans_approval_history_s.nextval
              into tempTransHistoryId
              from dual;
Line: 9354

            insert into AME_TRANS_APPROVAL_HISTORY
                (TRANS_HISTORY_ID
                ,TRANSACTION_ID
                ,APPLICATION_ID
                ,ROW_TIMESTAMP
                ,ORDER_NUMBER
                ,NAME
                ,APPROVER_CATEGORY
                ,ITEM_CLASS
                ,ITEM_ID
                ,ACTION_TYPE_ID
                ,AUTHORITY
                ,STATUS
                ,GROUP_OR_CHAIN_ID
                ,OCCURRENCE
                ,API_INSERTION
                ,MEMBER_ORDER_NUMBER
                ,NOTIFICATION_ID
                ,USER_COMMENTS
                ,DATE_CLEARED
                )select tempTransHistoryId
                       ,transactionIdIn
                       ,applicationIdIn
                       ,sysdate
                       ,approvers(i).approver_order_number
                       ,approvers(i).name
                       ,approvers(i).approver_category
                       ,approvers(i).item_class
                       ,approvers(i).item_id
                       ,approvers(i).action_type_id
                       ,approvers(i).authority
                       ,ame_util.beatByFirstResponderStatus
                       ,approvers(i).group_or_chain_id
                       ,approvers(i).occurrence
                       ,approvers(i).api_insertion
                       ,approvers(i).member_order_number
                       ,notificationIdIn
                       ,null
                       ,null
                   from dual;
Line: 9409

            select ame_trans_approval_history_s.nextval
              into tempTransHistoryId
              from dual;
Line: 9412

            insert into AME_TRANS_APPROVAL_HISTORY
                (TRANS_HISTORY_ID
                ,TRANSACTION_ID
                ,APPLICATION_ID
                ,ROW_TIMESTAMP
                ,ORDER_NUMBER
                ,NAME
                ,APPROVER_CATEGORY
                ,ITEM_CLASS
                ,ITEM_ID
                ,ACTION_TYPE_ID
                ,AUTHORITY
                ,STATUS
                ,GROUP_OR_CHAIN_ID
                ,OCCURRENCE
                ,API_INSERTION
                ,MEMBER_ORDER_NUMBER
                ,NOTIFICATION_ID
                ,USER_COMMENTS
                ,DATE_CLEARED
                )select tempTransHistoryId
                       ,transactionIdIn
                       ,applicationIdIn
                       ,sysdate
                       ,approvers(i).approver_order_number
                       ,approvers(i).name
                       ,approvers(i).approver_category
                       ,approvers(i).item_class
                       ,approvers(i).item_id
                       ,approvers(i).action_type_id
                       ,approvers(i).authority
                       ,ame_util.beatByFirstResponderStatus
                       ,approvers(i).group_or_chain_id
                       ,approvers(i).occurrence
                       ,approvers(i).api_insertion
                       ,approvers(i).member_order_number
                       ,notificationIdIn
                       ,null
                       ,null
                   from dual;
Line: 9456

      select ame_trans_approval_history_s.nextval
        into tempTransHistoryId
        from dual;
Line: 9460

        insert into AME_TRANS_APPROVAL_HISTORY
                (TRANS_HISTORY_ID
                ,TRANSACTION_ID
                ,APPLICATION_ID
                ,ROW_TIMESTAMP
                ,ORDER_NUMBER
                ,NAME
                ,APPROVER_CATEGORY
                ,ITEM_CLASS
                ,ITEM_ID
                ,ACTION_TYPE_ID
                ,AUTHORITY
                ,STATUS
                ,GROUP_OR_CHAIN_ID
                ,OCCURRENCE
                ,API_INSERTION
                ,MEMBER_ORDER_NUMBER
                ,NOTIFICATION_ID
                ,USER_COMMENTS
                ,DATE_CLEARED
                )values
                (tempTransHistoryId
                ,transactionIdIn
                ,applicationIdIn
                ,sysdate
                ,orderNumberIn
                ,nameIn
                ,appCategoryIn
                ,itemClassIn
                ,itemIdIn
                ,actionTypeIdIn
                ,authorityIn
                ,statusIn
                ,grpOrChainIdIn
                ,occurrenceIn
                ,apiInsertionIn
                ,memberorderNumberIn
                ,notificationIdIn
                ,userCommentsIn
                ,dateClearedIn);
Line: 9502

          select atah.item_class item_class
                ,atah.item_id item_id
                ,atah.order_number order_number
                ,atah.authority authority
                ,atah.action_type_id action_type_id
                ,atah.group_or_chain_id group_or_chain_id
                ,atah.occurrence occurrence
                ,atah.api_insertion api_insertion
                ,atah.member_order_number member_order_number
            into tempItemClass
                ,tempItemId
                ,tempOrderNumber
                ,tempAuthority
                ,tempActionTypeId
                ,tempGroupOrChainId
                ,tempOccurrence
                ,tempApiInsertion
                ,tempMemberOrderNumber
            from ame_trans_approval_history atah
                ,fnd_lookups lookup
                ,fnd_lookups lookup2
                ,ame_approval_groups apg
           where atah.date_cleared is null
             and atah.transaction_id = transactionIdIn
             and atah.application_id = applicationIdIn
             and atah.name = tempName
             and atah.trans_history_id =
                   (select max(b.trans_history_id)
                      from ame_trans_approval_history b
                     where atah.transaction_id = b.transaction_id
                       and atah.application_id = b.application_id
                       and atah.name = b.name
                       and atah.approver_category = b.approver_category
                       and atah.item_class = b.item_class
                       and atah.item_id = b.item_id
                       and atah.action_type_id = b.action_type_id
                       and atah.authority = b.authority
                       and atah.group_or_chain_id = b.group_or_chain_id
                       and atah.occurrence = b.occurrence
                       and b.date_cleared is null )
             and lookup.lookup_type = 'AME_SUBLIST_TYPES'
             and lookup.lookup_code = atah.authority
             and lookup2.lookup_type = 'AME_APPROVAL_STATUS'
             and lookup2.lookup_code = atah.status
             and apg.approval_group_id(+) = atah.group_or_chain_id
             and sysdate between nvl(apg.start_date,sysdate) and nvl(apg.end_date,sysdate);
Line: 9557

            tempApiInsertion   := null;
Line: 9581

        if apiInsertionIn is not null then
          tempApiInsertion := apiInsertionIn;
Line: 9587

        insert into AME_TRANS_APPROVAL_HISTORY
                (TRANS_HISTORY_ID
                ,TRANSACTION_ID
                ,APPLICATION_ID
                ,ROW_TIMESTAMP
                ,ORDER_NUMBER
                ,NAME
                ,APPROVER_CATEGORY
                ,ITEM_CLASS
                ,ITEM_ID
                ,ACTION_TYPE_ID
                ,AUTHORITY
                ,STATUS
                ,GROUP_OR_CHAIN_ID
                ,OCCURRENCE
                ,API_INSERTION
                ,MEMBER_ORDER_NUMBER
                ,NOTIFICATION_ID
                ,USER_COMMENTS
                ,DATE_CLEARED
               ) values
               (tempTransHistoryId
               ,transactionIdIn
               ,applicationIdIn
               ,sysdate
               ,tempOrderNumber
               ,nameIn
               ,appCategoryIn
               ,tempItemClass
               ,tempItemId
               ,tempActionTypeId
               ,tempAuthority
               ,statusIn
               ,tempGroupOrChainId
               ,tempOccurrence
               ,tempApiInsertion
               ,tempMemberOrderNumber
               ,notificationIdIn
               ,userCommentsIn
               ,dateClearedIn
               );
Line: 9632

                                    routineNameIn => 'insertIntoTransApprovalHistory',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 9636

    end insertIntoTransApprovalHistory;
Line: 9642

      select 'Y'
        from ame_temp_trans_locks
       where fnd_application_id = fndApplicationIdIn
         and transaction_id = transactionIdIn
         and transaction_type_id = transactionTypeIdIn;
Line: 9649

        The ame_temp_trans_locks_pk unique index will prevent the following insert from occurring
        if another row has already been inserted into ame_temp_trans_locks with the same
        fnd_application_id, transaction_type_id, and transaction_id values (even though the other
        insert is not committed).
      */
      tempTransIsLocked := null;
Line: 9664

      insert into ame_temp_trans_locks(fnd_application_id,
                                       transaction_type_id,
                                       transaction_id,
                                       row_timestamp) values(
                                       fndApplicationIdIn,
                                       transactionTypeIdIn,
                                       transactionIdIn,
                                       sysdate);
Line: 9686

      select count(*)
        into tempCount
        from ame_temp_transactions
        where
          application_id = engAmeApplicationId and
          transaction_id = engTransactionId and
          rownum < 2; /* Avoids second fetch otherwise required by ANSI standard to check for too many rows. */
Line: 9694

        select ame_temp_transactions_s.nextval into tempTransSeqId from dual;
Line: 9695

        insert into ame_temp_transactions(
          application_id,
          transaction_id,
          row_timestamp,
          temp_transactions_id
          ) values(
            engAmeApplicationId,
            engTransactionId,
            sysdate,
            tempTransSeqId); /* Don't use engEffectiveRuleDate here. */
Line: 9858

        /* Update the temp variables when the item changes. */
        if(engStApprovers(i).item_id <> tempItemId or
           engStApprovers(i).item_class <> tempItemClass) then
          tempItemId := engStApprovers(i).item_id;
Line: 9875

        /* Update the process-complete engSt variables as appropriate. */
        -- check for pending/yet to be notified approvers
        if(engStItemAppProcessCompleteYN(tempItemIndex) <> ame_util2.completeFullyRejected and
           ((engStApprovers(i).approver_category = ame_util.approvalApproverCategory and
             (engStApprovers(i).approval_status is null or
              engStApprovers(i).approval_status in (ame_util.nullStatus
                                                   ,ame_util.notifiedStatus
                                                   ,ame_util.repeatedStatus
                                                   ,ame_util.notifiedByRepeatedStatus))) or
            (engStApprovers(i).approver_category = ame_util.fyiApproverCategory and
             (engStApprovers(i).approval_status is null or
             engStApprovers(i).approval_status = ame_util.nullStatus)))) then
          if engStItemAppProcessCompleteYN(tempItemIndex) in (ame_util2.completeNoApprovers
                                                             ,ame_util2.completeFullyApproved) then
            engStItemAppProcessCompleteYN(tempItemIndex) := ame_util2.notCompleted;
Line: 9981

  procedure processAdHocInsertions as
    displacedInserteeIndexes ame_util.idList;
Line: 9989

    tempItemClass ame_temp_insertions.item_class%type;
Line: 9990

    tempItemId ame_temp_insertions.item_id%type;
Line: 9991

    tempOrderType ame_temp_insertions.order_type%type;
Line: 9998

        for each inserted approver:
          orig_system
          orig_system_id
          display_name
          action_type_id
          group_or_chain_id
          occurrence
          source
          approval_status
          item_class_order_number
          item_order_number
          sub_list_order_number
          action_type_order_number
          group_or_chain_order_number
          member_order_number
        The first three of these fields get populated at the beginning of the outermost loop below.
        The other fields get populated just before the actual insertion occurs.  This procedure must
        therefore decide how to set the order-number fields.  The procedure attempts to set the
        order numbers consistent with the order relation of the insertion, where the order relation
        anchors the insertion to the approver preceeding or following the insertion in engStApprovers.
        See the comments near specific insertApprover calls below.
      */
      engStApproversCount := engStApprovers.count;
Line: 10021

      for i in 1 .. engInsertedApproverList.count loop
        if(engInsertedApproverList(i).authority <> ame_util.authorityApprover or
           engInsertedApproverList(i).api_insertion = ame_util.apiInsertion) then
          begin
           ame_approver_type_pkg.getOrigSystemIdAndDisplayName(nameIn => engInsertedApproverList(i).name,
                                                              origSystemOut => engInsertedApproverList(i).orig_system,
                                                              origSystemIdOut => engInsertedApproverList(i).orig_system_id,
                                                              displayNameOut => engInsertedApproverList(i).display_name);
Line: 10033

                if engInsertedApproverList(i).approval_status is null then
                  errorCode := -20219;
Line: 10038

                                              tokenValueOneIn => 'ame_engine.processAdHocInsertions',
                                              tokenNameTwoIn => 'NAME',
                                              tokenValueTwoIn => engInsertedApproverList(i).name);
Line: 10044

                engInsertedApproverList(i).orig_system := 'AME_INS_ORIG_SYSTEM';
Line: 10047

          parameterFields.delete;
Line: 10048

          parseFields(stringIn => engInsertionParameterList(i),
                      fieldsOut => parameterFields);
Line: 10051

          if(engInsertionOrderTypeList(i) = ame_util.absoluteOrder) then
            tempIndex := engInsertionParameterList(i);
Line: 10056

            engInsertedApproverList(i).source := ame_util.otherInsertion;
Line: 10058

               engStApprovers(tempIndex - 1).authority = engInsertedApproverList(i).authority and
               engStApprovers(tempIndex - 1).item_class = engInsertedApproverList(i).item_class and
               engStApprovers(tempIndex - 1).item_id = engInsertedApproverList(i).item_id
               ) then
              /* Group the insertion with the preceeding approver in engStApprovers. */
              engInsertedApproverList(i).action_type_id := engStApprovers(tempIndex - 1).action_type_id;
Line: 10064

              engInsertedApproverList(i).group_or_chain_id := engStApprovers(tempIndex - 1).group_or_chain_id;
Line: 10065

              engInsertedApproverList(i).occurrence :=
                getHandlerOccurrence(nameIn => engInsertedApproverList(i).name,
                                     itemClassIn => engInsertedApproverList(i).item_class,
                                     itemIdIn => engInsertedApproverList(i).item_id,
                                     actionTypeIdIn => engInsertedApproverList(i).action_type_id,
                                     groupOrChainIdIn => engInsertedApproverList(i).group_or_chain_id);
Line: 10071

              engInsertedApproverList(i).item_class_order_number :=
                engStApprovers(tempIndex - 1).item_class_order_number;
Line: 10073

              engInsertedApproverList(i).item_order_number := engStApprovers(tempIndex - 1).item_order_number;
Line: 10074

              engInsertedApproverList(i).sub_list_order_number := engStApprovers(tempIndex - 1).sub_list_order_number;
Line: 10075

              engInsertedApproverList(i).action_type_order_number :=
                engStApprovers(tempIndex - 1).action_type_order_number;
Line: 10077

              engInsertedApproverList(i).group_or_chain_order_number :=
                engStApprovers(tempIndex - 1).group_or_chain_order_number;
Line: 10080

              /* Group the insertion with the following approver in engStApprovers. */
              engInsertedApproverList(i).authority := engStApprovers(tempIndex).authority;
Line: 10082

              engInsertedApproverList(i).action_type_id := engStApprovers(tempIndex).action_type_id;
Line: 10083

              engInsertedApproverList(i).group_or_chain_id := engStApprovers(tempIndex).group_or_chain_id;
Line: 10084

              engInsertedApproverList(i).occurrence :=
                getHandlerOccurrence(nameIn => engInsertedApproverList(i).name,
                                     itemClassIn => engInsertedApproverList(i).item_class,
                                     itemIdIn => engInsertedApproverList(i).item_id,
                                     actionTypeIdIn => engInsertedApproverList(i).action_type_id,
                                     groupOrChainIdIn => engInsertedApproverList(i).group_or_chain_id);
Line: 10090

              engInsertedApproverList(i).item_class_order_number := engStApprovers(tempIndex).item_class_order_number;
Line: 10091

              engInsertedApproverList(i).item_order_number := engStApprovers(tempIndex).item_order_number;
Line: 10092

              engInsertedApproverList(i).sub_list_order_number := engStApprovers(tempIndex).sub_list_order_number;
Line: 10093

              engInsertedApproverList(i).action_type_order_number := engStApprovers(tempIndex).action_type_order_number;
Line: 10094

              engInsertedApproverList(i).group_or_chain_order_number :=
                engStApprovers(tempIndex).group_or_chain_order_number;
Line: 10098

              engInsertedApproverList(i).action_type_id := ame_util.nullInsertionActionTypeId;
Line: 10099

              engInsertedApproverList(i).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 10100

              engInsertedApproverList(i).occurrence := 1;
Line: 10101

              engInsertedApproverList(i).item_class_order_number :=
                getItemClassOrderNumber(itemClassIdIn =>
                  getItemClassId(itemClassNameIn => engInsertedApproverList(i).item_class));
Line: 10104

              engInsertedApproverList(i).item_order_number :=
                getItemOrderNumber(itemClassNameIn => engInsertedApproverList(i).item_class,
                                   itemIdIn => engInsertedApproverList(i).item_id);
Line: 10107

              engInsertedApproverList(i).sub_list_order_number :=
                getSublistOrderNum(itemClassNameIn => ame_util.headerItemClassName,
                                   authorityIn => ame_util.postApprover);
Line: 10110

              engInsertedApproverList(i).action_type_order_number := getNullActionTypeOrderNumber;
Line: 10111

              engInsertedApproverList(i).group_or_chain_order_number := 1;
Line: 10116

                ,'ame_engine.processAdhocInsertions'
                ,'Adhoc Insertion approver(absolute order) ::: ' || engInsertedApproverList(i).name
                );
Line: 10120

            insertApprover(indexIn => tempIndex,
                           approverIn => engInsertedApproverList(i),
                           adjustMemberOrderNumbersIn => true,
                           inserteeIndexIn => i,
                           currentInsIndex => i);
Line: 10125

            populateInsertionIndexes(indexIn => tempIndex
                                    ,insertionOrderIn => engInsertionOrderList(i));
Line: 10129

          elsif(engInsertionOrderTypeList(i) in (ame_util.afterApprover,
                                                 ame_util.beforeApprover)) then
            tempIndex := 1; /* post-increment */
Line: 10136

                the insertion parameter.
              */
              if(engStApprovers(tempIndex).name = parameterFields(1) and
                 engStApprovers(tempIndex).occurrence = parameterFields(6) and
                 engStApprovers(tempIndex).group_or_chain_id = parameterFields(5) and
                 engStApprovers(tempIndex).action_type_id = parameterFields(4) and
                 engStApprovers(tempIndex).item_id = parameterFields(3) and
                 engStApprovers(tempIndex).item_class = parameterFields(2)) then
                tempBoolean := true;
Line: 10145

                if(engInsertionOrderTypeList(i) = ame_util.afterApprover) then
                  tempIndex2 := tempIndex + 1;
Line: 10150

                engInsertedApproverList(i).action_type_id := engStApprovers(tempIndex).action_type_id;
Line: 10151

                engInsertedApproverList(i).group_or_chain_id := engStApprovers(tempIndex).group_or_chain_id;
Line: 10152

                engInsertedApproverList(i).occurrence :=
                  getHandlerOccurrence(nameIn => engInsertedApproverList(i).name,
                                       itemClassIn => engInsertedApproverList(i).item_class,
                                       itemIdIn => engInsertedApproverList(i).item_id,
                                       actionTypeIdIn => engInsertedApproverList(i).action_type_id,
                                       groupOrChainIdIn => engInsertedApproverList(i).group_or_chain_id);
Line: 10158

                if(engInsertionIsSpecialForwardee(i) = ame_util.booleanTrue) then
                  engInsertedApproverList(i).source := ame_util.specialForwardInsertion;
Line: 10161

                  if(engInsertionOrderTypeList(i) = ame_util.afterApprover and
                     engStApprovers(tempIndex).approval_status = ame_util.forwardStatus) then
                    engInsertedApproverList(i).source := ame_util.forwardInsertion;
Line: 10164

                  elsif(engInsertionOrderTypeList(i) = ame_util.afterApprover and
                        engStApprovers(tempIndex).approval_status = ame_util.approveAndForwardStatus) then
                    engInsertedApproverList(i).source := ame_util.approveAndForwardInsertion;
Line: 10168

                    engInsertedApproverList(i).source := ame_util.otherInsertion;
Line: 10171

                engInsertedApproverList(i).item_class_order_number := engStApprovers(tempIndex).item_class_order_number;
Line: 10172

                engInsertedApproverList(i).item_order_number := engStApprovers(tempIndex).item_order_number;
Line: 10173

                engInsertedApproverList(i).sub_list_order_number := engStApprovers(tempIndex).sub_list_order_number;
Line: 10174

                engInsertedApproverList(i).action_type_order_number := engStApprovers(tempIndex).action_type_order_number;
Line: 10175

                engInsertedApproverList(i).group_or_chain_order_number :=
                  engStApprovers(tempIndex).group_or_chain_order_number;
Line: 10180

                    ,'ame_engine.processAdhocInsertions'
                    ,'Adhoc Insertion approver(after/before approver) ::: ' || engInsertedApproverList(i).name
                    );
Line: 10184

                insertApprover(indexIn => tempIndex2,
                               approverIn => engInsertedApproverList(i),
                               adjustMemberOrderNumbersIn => true,
                               inserteeIndexIn => i,
                               currentInsIndex => i);
Line: 10189

                populateInsertionIndexes(indexIn => tempIndex2
                                        ,insertionOrderIn => engInsertionOrderList(i));
Line: 10202

              ame_api3.getAvailableInsertions for these order types.
            */
            if(engStApproversCount = 0) then
              /*
                The four first/last pre/post order types can only occur in an empty list if the insertion
                is for the header item.  Treat any other case of these order types as displaced, here.
                In the code blocks below for these four order types, require that engStApproversCount > 0.
              */
              if(parameterFields(3) = ame_util.headerItemClassName and
                 parameterFields(2) = engTransactionId) then
                engInsertedApproverList(i).occurrence := 1;
Line: 10213

                engInsertedApproverList(i).item_class_order_number :=
                  getItemClassOrderNumber(itemClassIdIn =>
                    getItemClassId(itemClassNameIn => ame_util.headerItemClassName));
Line: 10216

                engInsertedApproverList(i).item_order_number := 1;
Line: 10217

                engInsertedApproverList(i).sub_list_order_number :=
                  getSublistOrderNum(itemClassNameIn => ame_util.headerItemClassName,
                                     authorityIn => engInsertedApproverList(i).authority);
Line: 10220

                engInsertedApproverList(i).action_type_order_number := getNullActionTypeOrderNumber;
Line: 10221

                engInsertedApproverList(i).group_or_chain_order_number := 1;
Line: 10222

                engInsertedApproverList(i).member_order_number := 1;
Line: 10223

                insertApprover(indexIn => 1,
                               approverIn => engInsertedApproverList(i),
                               adjustMemberOrderNumbersIn => false,
                               inserteeIndexIn => i,
                               currentInsIndex => i);
Line: 10228

                populateInsertionIndexes(indexIn => 1
                                        ,insertionOrderIn => engInsertionOrderList(i));
Line: 10232

                engInsertedApproverList(i).occurrence := 1;
Line: 10233

                engInsertedApproverList(i).item_class_order_number :=
                  getItemClassOrderNumber(itemClassIdIn =>
                    getItemClassId(itemClassNameIn => engInsertedApproverList(i).item_class));
Line: 10236

                engInsertedApproverList(i).item_order_number := 1;
Line: 10237

                engInsertedApproverList(i).sub_list_order_number :=
                  getSublistOrderNum(itemClassNameIn => engInsertedApproverList(i).item_class,
                                     authorityIn => engInsertedApproverList(i).authority);
Line: 10240

                engInsertedApproverList(i).action_type_order_number := getNullActionTypeOrderNumber;
Line: 10241

                engInsertedApproverList(i).group_or_chain_order_number := 1;
Line: 10242

                engInsertedApproverList(i).member_order_number := 1;
Line: 10243

                displacedInserteeIndexes(displacedInserteeIndexes.count + 1) := i;
Line: 10249

              if(engInsertionOrderTypeList(i) = ame_util.firstPostApprover) then
                /*
                  Insert at tempIndex if it's non-null, after checking the possible cases.
                  Recall that the case where engStApproversCount = 0 is handled at the
                  start of the procedure, that the item id is in parameterFields(3), and
                  that the item-class ID is in parameterFields(2).  Here are the cases
                  requiring insertion (always at j + 1).
                  1.  j = 0,
                      post-approver for the right item at j + 1 = 1
                  2.  j > 0,
                      j < engStApproversCount,
                      non-post-approver for the right item at j,
                      post-approver for the right item at j + 1
                  3.  j > 0,
                      j < engStApproversCount,
                      non-post-approver for the right item at j,
                      any approver for the wrong item at j + 1
                  4.  j > 0,
                      j = engStApproversCount,
                      non-post-approver for the right item at j
                  5.  j > 0,
                      j < engStApproversCount,
                      any approver for the wrong item at j,
                      post-approver for the right item at j + 1
                  Finally, note that the way the code is written, case 4 must be checked
                  before cases 2, 3, and 5, to ensure that for these cases,
                  j + 1 <= engStApproversCount.
                */
                /* The zero lower limit is intentional. */
                for j in 0 .. engStApproversCount loop
                  tempIndex2 := j + 1;
Line: 10326

              elsif(engInsertionOrderTypeList(i) = ame_util.firstPreApprover) then
                /*
                  Insert at tempIndex if it's non-null, after checking the possible cases.
                  Recall that the case where engStApproversCount = 0 is handled at the
                  start of the procedure.  Here are the cases requiring insertion (always
                  at j).
                  1.  j = 1,
                      any approver for the right item at j = 1
                  2.  j > 1,
                      any approver for the wrong item at j - 1,
                      any approver for the right item at j
                */
                for j in 1 .. engStApproversCount loop
                  if(j = 1) then
                    if(engStApprovers(1).item_id = parameterFields(3) and
                       engStApprovers(1).item_class = parameterFields(2)) then /* case 1 */
                      tempIndex := 1;
Line: 10360

              elsif(engInsertionOrderTypeList(i) = ame_util.lastPostApprover) then
                /*
                  Insert at tempIndex if it's non-null, after checking the possible cases.
                  Recall that the case where engStApproversCount = 0 is handled at the
                  start of the procedure.  Here are the cases requiring insertion (always
                  at j + 1).
                  1.  j = engStApproversCount,
                      any approver for the right item at j
                  2.  j < engStApproversCount,
                      any approver for right item at j,
                      any approver for wrong item at j + 1
                */
                for j in 1 .. engStApproversCount loop
                  if(j = engStApproversCount) then
                    if(engStApprovers(j).item_id = parameterFields(3) and
                       engStApprovers(j).item_class = parameterFields(2)) then
                      tempIndex := engStApproversCount + 1;
Line: 10396

              else /* engInsertionOrderTypeList(i) = ame_util.lastPreApprover */
                /*
                  Insert at tempIndex if it's non-null, after checking the possible cases.
                  Recall that the case where engStApproversCount = 0 is handled at the
                  start of the procedure.  Here are the cases (always inserting at j):
                  1.  j = 1,
                      non-pre-approver for the right item at 1
                  2.  j > 1,
                      j <= engStApproversCount,
                      the approver at j - 1 is for the right item,
                      the approver at j is for the right item,
                      the approver at j - 1 is a pre-approver,
                      the approver at j is not a pre-approver
                  3.  j > 1,
                      j <= engStApproversCount,
                      any approver at j - 1 for the wrong item,
                      the approver at j is for the right item,
                      the approver at j is not a pre-approver
                */
                for j in 1 .. engStApproversCount loop
                  if(j = 1) then
                    if(engStApprovers(1).item_id = parameterFields(3) and
                       engStApprovers(1).item_class = parameterFields(2) and
                       engStApprovers(1).authority <> ame_util.preApprover) then /* case 1 */
                      tempIndex := 1;
Line: 10442

              /* Set the remaining fields in the insertee's approverRecord2. */
              engInsertedApproverList(i).source := ame_util.otherInsertion;
Line: 10445

                engInsertedApproverList(i).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 10449

                /* engInsertedApproverList(i).action_type_id := ame_util.nullInsertionActionTypeId; */
Line: 10450

                engInsertedApproverList(i).occurrence :=
                  getHandlerOccurrence(nameIn => engInsertedApproverList(i).name,
                                       itemClassIn => engInsertedApproverList(i).item_class,
                                       itemIdIn => engInsertedApproverList(i).item_id,
                                       actionTypeIdIn => engInsertedApproverList(i).action_type_id,
                                       groupOrChainIdIn => engInsertedApproverList(i).group_or_chain_id);
Line: 10456

                engInsertedApproverList(i).item_class_order_number :=
                  getItemClassOrderNumber(itemClassIdIn =>
                    getItemClassId(itemClassNameIn => engInsertedApproverList(i).item_class));
Line: 10459

                engInsertedApproverList(i).item_order_number :=
                  getItemOrderNumber(itemClassNameIn => engInsertedApproverList(i).item_class,
                                                 itemIdIn => engInsertedApproverList(i).item_id);
Line: 10465

                if engInsertionOrderTypeList(i) = ame_util.firstPreApprover or
                        engInsertionOrderTypeList(i) = ame_util.lastPreApprover then
                  engInsertedApproverList(i).sub_list_order_number :=
                    getSublistOrderNum(itemClassNameIn => engInsertedApproverList(i).item_class,
                                       authorityIn => ame_util.preApprover);
Line: 10470

                elsif engInsertionOrderTypeList(i) = ame_util.firstPostApprover or
                        engInsertionOrderTypeList(i) = ame_util.lastPostApprover then
                  engInsertedApproverList(i).sub_list_order_number :=
                    getSublistOrderNum(itemClassNameIn => engInsertedApproverList(i).item_class,
                                       authorityIn => ame_util.postApprover);
Line: 10479

                /* engInsertedApproverList(i).action_type_order_number := getNullActionTypeOrderNumber; */
Line: 10480

                engInsertedApproverList(i).action_type_order_number := 1;
Line: 10481

                engInsertedApproverList(i).group_or_chain_order_number := 1;
Line: 10483

                engInsertedApproverList(i).group_or_chain_id := ame_util.nullInsertionGroupOrChainId;
Line: 10487

                /* engInsertedApproverList(i).action_type_id := ame_util.nullInsertionActionTypeId;*/
Line: 10488

                engInsertedApproverList(i).occurrence :=
                  getHandlerOccurrence(nameIn => engInsertedApproverList(i).name,
                                       itemClassIn => engInsertedApproverList(i).item_class,
                                       itemIdIn => engInsertedApproverList(i).item_id,
                                       actionTypeIdIn => engInsertedApproverList(i).action_type_id,
                                       groupOrChainIdIn => engInsertedApproverList(i).group_or_chain_id);
Line: 10494

                engInsertedApproverList(i).item_class_order_number :=
                  engStApprovers(tempAnchorIndex).item_class_order_number;
Line: 10496

                engInsertedApproverList(i).item_order_number :=
                  engStApprovers(tempAnchorIndex).item_order_number;
Line: 10498

                engInsertedApproverList(i).sub_list_order_number :=
                  engStApprovers(tempAnchorIndex).sub_list_order_number;
Line: 10503

                /*engInsertedApproverList(i).action_type_order_number :=                */
                /*  engStApprovers(tempAnchorIndex).action_type_order_number;           */
Line: 10505

                if engInsertionOrderTypeList(i) = ame_util.firstPreApprover or
                     engInsertionOrderTypeList(i) = ame_util.firstPostApprover then
                  engInsertedApproverList(i).action_type_order_number :=
                    engStApprovers(tempAnchorIndex).action_type_order_number - 1;
Line: 10509

                elsif engInsertionOrderTypeList(i) = ame_util.lastPreApprover or
                     engInsertionOrderTypeList(i) = ame_util.lastPostApprover then
                  engInsertedApproverList(i).action_type_order_number :=
                    engStApprovers(tempAnchorIndex).action_type_order_number + 1;
Line: 10514

                engInsertedApproverList(i).group_or_chain_order_number :=
                  engStApprovers(tempAnchorIndex).group_or_chain_order_number;
Line: 10517

              /* Perform the insertion if the proper position has been located. */
              if(tempIndex is null) then
                displacedInserteeIndexes(displacedInserteeIndexes.count + 1) := i;
Line: 10524

                if engInsertionOrderTypeList(i) = ame_util.firstPreApprover or
                        engInsertionOrderTypeList(i) = ame_util.firstPostApprover then
                  engInsertedApproverList(i).action_type_id := -1;
Line: 10530

                      ,'ame_engine.processAdhocInsertions'
                      ,'Adhoc Insertion approver(first pre/first post approver) ::: ' || engInsertedApproverList(i).name
                      );
Line: 10534

                  insertApprover(indexIn => tempIndex,
                                 approverIn => engInsertedApproverList(i),
                                 adjustMemberOrderNumbersIn => true,
                                 approverLocationIn => ame_util.firstAmongEquals,
                                 inserteeIndexIn => i,
                                 currentInsIndex => i);
Line: 10540

                  populateInsertionIndexes(indexIn => tempIndex
                                          ,insertionOrderIn => engInsertionOrderList(i));
Line: 10542

                elsif engInsertionOrderTypeList(i) = ame_util.lastPreApprover or
                        engInsertionOrderTypeList(i) = ame_util.lastPostApprover then
                  engInsertedApproverList(i).action_type_id := -2;
Line: 10548

                      ,'ame_engine.processAdhocInsertions'
                      ,'Adhoc Insertion approver(last pre/last post approver) ::: ' || engInsertedApproverList(i).name
                      );
Line: 10552

                  insertApprover(indexIn => tempIndex,
                                 approverIn => engInsertedApproverList(i),
                                 adjustMemberOrderNumbersIn => true,
                                 approverLocationIn => ame_util.lastAmongEquals,
                                 inserteeIndexIn => i,
                                 currentInsIndex => i);
Line: 10558

                  populateInsertionIndexes(indexIn => tempIndex
                                          ,insertionOrderIn => engInsertionOrderList(i));
Line: 10568

        Insert any displaced approvers at the end of their items' lists, if possible; and
Line: 10571

      for i in 1 .. displacedInserteeIndexes.count loop
        parameterFields.delete;
Line: 10573

        parseFields(stringIn => engInsertionParameterList(displacedInserteeIndexes(i)),
                    fieldsOut => parameterFields);
Line: 10575

        /* Set tempBoolean false if displaced approver i is inserted at the end of its item's list. */
        tempBoolean := true;
Line: 10587

                ,'ame_engine.processAdhocInsertions'
                ,'Adhoc Insertion approver(displaced) ::: ' || engInsertedApproverList(displacedInserteeIndexes(i)).name
                );
Line: 10591

            insertApprover(indexIn => j + 1,
                           approverIn => engInsertedApproverList(displacedInserteeIndexes(i)),
                           adjustMemberOrderNumbersIn => true,
                           inserteeIndexIn => i,
                           currentInsIndex => i);
Line: 10596

            populateInsertionIndexes(indexIn => j + 1
                                    ,insertionOrderIn => engInsertionOrderList(displacedInserteeIndexes(i)));
Line: 10606

              ,'ame_engine.processAdhocInsertions'
              ,'Adhoc Insertion approver(displaced) ::: ' || engInsertedApproverList(displacedInserteeIndexes(i)).name
              );
Line: 10610

          insertApprover(indexIn => engStApproversCount + 1,
                         approverIn => engInsertedApproverList(displacedInserteeIndexes(i)),
                         adjustMemberOrderNumbersIn => false,
                         inserteeIndexIn => i,
                         currentInsIndex => i);
Line: 10615

          populateInsertionIndexes(indexIn => engStApproversCount + 1
                                  ,insertionOrderIn => engInsertionOrderList(displacedInserteeIndexes(i)));
Line: 10625

          engStApprovers.delete(engStApprovers.count);
Line: 10631

                                    routineNameIn => 'processAdHocInsertions',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 10635

    end processAdHocInsertions;
Line: 10726

  procedure populateInsertionIndexes(indexIn in integer
                                    ,insertionOrderIn in integer) as
    firstIndex integer;
Line: 10732

      firstIndex := engStInsertionIndexes.first;
Line: 10733

      if(engStInsertionIndexes.exists(firstIndex)) then
        lastIndex := engStInsertionIndexes.last;
Line: 10735

        while engStInsertionIndexes.exists(lastIndex) and lastIndex >= indexIn loop
          tempValue := engStInsertionIndexes(lastIndex);
Line: 10737

          engStInsertionIndexes(lastIndex + 1) := tempValue;
Line: 10738

          engStInsertionIndexes.delete(lastIndex);
Line: 10739

          lastIndex := engStInsertionIndexes.prior(lastIndex + 1);
Line: 10741

        engStInsertionIndexes(indexIn) := insertionOrderIn;
Line: 10743

        engStInsertionIndexes(indexIn) := insertionOrderIn;
Line: 10745

    end populateInsertionIndexes;
Line: 10760

      for i in 1 .. engDeletedApproverList.count loop
        for j in 1 .. engStApprovers.count loop
          if(engStApprovers(j).name = engDeletedApproverList(i).name and
             engStApprovers(j).occurrence = engDeletedApproverList(i).occurrence and
             engStApprovers(j).group_or_chain_id = engDeletedApproverList(i).group_or_chain_id and
             engStApprovers(j).action_type_id = engDeletedApproverList(i).action_type_id and
             engStApprovers(j).item_id = engDeletedApproverList(i).item_id and
             engStApprovers(j).item_class = engDeletedApproverList(i).item_class) then
            engStApprovers(j).approval_status := ame_util.suppressedStatus;
Line: 10868

            tempExcOrdCondAttributeIds.delete;
Line: 10886

                    copy it at each iteration, so we can freely delete entries in the
                    copy.
                  */
                  tempAttributeIdsToMatch.delete;
Line: 10911

                        tempAttributeIdsToMatch.delete(tempAttributeId);
Line: 10924

                      exception's ordinary conditions' attributes were matched; so, delete the authority
Line: 10928

                    engAppItemClassIds.delete(j);
Line: 10929

                    engAppItemIds.delete(j);
Line: 10930

                    engAppRuleIds.delete(j);
Line: 10931

                    engRuleAppliedYN.delete(j);
Line: 10932

                    engAppRuleTypes.delete(j);
Line: 10933

                    engAppActionTypeIds.delete(j);
Line: 10934

                    engAppParameters.delete(j);
Line: 10935

                    engAppParameterTwos.delete(j);
Line: 10936

                    engAppRuleItemClassIds.delete(j);
Line: 10937

                    engAppAppItemIds.delete(j);
Line: 10954

      /* Re-compact the engApp lists if any authority rules got deleted. */
      if(authorityRuleSuppressed) then
        compactEngAppLists(compactPrioritiesIn => false,
                           compactActionTypeIdsIn => true,
                           compactParametersIn => true);
Line: 11079

                  per-item approver responses.  See the ame_api2.updateApprovalStatus code for details.
                  Also, don't suppress special forwardees.  See bug 3401298 for details.
                */
                if(engStApprovers(j).approval_status is null and
                   engStApprovers(j).source not like ame_util.specialForwardInsertion || '%') then
                  engStApprovers(j).approval_status := ame_util.repeatedStatus;
Line: 11117

          repeatedIndexesList.delete;
Line: 11278

                    /* Update the current action-type state variables. */
                    engAppHandlerFirstIndex := tempIndex;
Line: 11292

            /* Update the current state variables. */
            currentFirstRuleIndexes.delete;
Line: 11294

            currentLastRuleIndexes.delete;
Line: 11340

    ruleDeleted boolean;
Line: 11356

      ruleDeleted := false;
Line: 11366

          tempThresholds.delete;
Line: 11404

                engAppRuleIds.delete(i);
Line: 11405

                engRuleAppliedYN.delete(i);
Line: 11406

                engAppItemClassIds.delete(i);
Line: 11407

                engAppItemIds.delete(i);
Line: 11408

                engAppPriorities.delete(i);
Line: 11409

                engAppApproverCategories.delete(i);
Line: 11410

                engAppRuleTypes.delete(i);
Line: 11411

                engAppRuleItemClassIds.delete(i);
Line: 11412

                engAppAppItemIds.delete(i);
Line: 11413

                ruleDeleted := true;
Line: 11458

                  engAppRuleIds.delete(oldTempIndex);
Line: 11459

                  engRuleAppliedYN.delete(oldTempIndex);
Line: 11460

                  engAppItemClassIds.delete(oldTempIndex);
Line: 11461

                  engAppItemIds.delete(oldTempIndex);
Line: 11462

                  engAppPriorities.delete(oldTempIndex);
Line: 11463

                  engAppApproverCategories.delete(oldTempIndex);
Line: 11464

                  engAppRuleTypes.delete(oldTempIndex);
Line: 11465

                  engAppRuleItemClassIds.delete(oldTempIndex);
Line: 11466

                  engAppAppItemIds.delete(oldTempIndex);
Line: 11467

                  ruleDeleted := true;
Line: 11477

      /* If relative-priority processing deleted one or more rules from the engApp lists, compact them. */
      if(ruleDeleted) then
        compactEngAppLists(compactPrioritiesIn => true,
                           compactActionTypeIdsIn => false,
                           compactParametersIn => false);
Line: 11513

          tempSurrogateApprover.api_insertion := ame_util.apiInsertion;
Line: 11514

          tempSurrogateApprover.source := ame_util.surrogateInsertion;
Line: 11536

             instead of in insertApprover. This will ensure that the surrogate has the same
             order as the unresponsive approver. Also changed call to insertApprover so that
             adjustMemberOrderNumbers is false */
          tempSurrogateApprover.member_order_number := engStApprovers(tempIndex).member_order_number;
Line: 11551

          insertApprover(indexIn => tempIndex + 1,
                         approverIn => tempSurrogateApprover,
                         adjustMemberOrderNumbersIn => false);
Line: 11588

                       fetchInsertionsIn in boolean,
                       fetchDeletionsIn in boolean,
                       fetchAttributeValuesIn in boolean,
                       fetchInactiveAttValuesIn in boolean,
                       processProductionActionsIn in boolean,
                       processProductionRulesIn in boolean,
                       updateCurrentApproverListIn in boolean,
                       updateOldApproverListIn in boolean,
                       processPrioritiesIn in boolean,
                       prepareItemDataIn in boolean,
                       prepareRuleIdsIn in boolean,
                       prepareRuleDescsIn in boolean,
                       prepareApproverTreeIn in boolean default false,
                       transactionIdIn in varchar2,
                       ameApplicationIdIn in integer default null,
                       fndApplicationIdIn in integer default null,
                       transactionTypeIdIn in varchar2 default null) as
    badLocalTransException exception;
Line: 11615

      engLMParameterOnes.delete;
Line: 11616

      engLMParameterTwos.delete;
Line: 11617

      engGroupMemberGroupIds.delete;
Line: 11618

      engGroupMemberNames.delete;
Line: 11619

      engGroupMemberOrderNumbers.delete;
Line: 11620

      engGroupMemberDisplayNames.delete;
Line: 11621

      engGroupMemberOrigSystems.delete;
Line: 11622

      engGroupMemberOrigSystemIds.delete;
Line: 11623

      engGroupUseItemBind.delete;
Line: 11624

      engAppActionTypeIds.delete;
Line: 11625

      engAppApproverCategories.delete;
Line: 11626

      engAppItemClassIds.delete;
Line: 11627

      engAppItemIds.delete;
Line: 11628

      engAppLMSubItemClassIds.delete;
Line: 11629

      engAppLMSubItemIds.delete;
Line: 11630

      engAppParameters.delete;
Line: 11631

      engAppParameterTwos.delete;
Line: 11632

      engAppPriorities.delete;
Line: 11633

      engAppRuleIds.delete;
Line: 11634

      engRuleAppliedYN.delete;
Line: 11635

      engAppRuleTypes.delete;
Line: 11636

      engAppRuleItemClassIds.delete;
Line: 11637

      engAppAppItemIds.delete;
Line: 11638

      engAppPerAppProdFirstIndexes.delete;
Line: 11639

      engAppPerAppProdRuleIds.delete;
Line: 11640

      engAppPerAppProdVariableNames.delete;
Line: 11641

      engAppPerAppProdVariableValues.delete;
Line: 11642

      engStApprovers.delete;
Line: 11644

      engStApproversTree.delete;
Line: 11645

      engStItemClasses.delete;
Line: 11646

      engStItemIds.delete;
Line: 11647

      engStItemIndexes.delete;
Line: 11648

      engStItemSources.delete;
Line: 11649

      engStProductionIndexes.delete;
Line: 11651

      engStRepeatedIndexes.delete;
Line: 11652

      engStRepeatedAppIndexes.delete;
Line: 11653

      engStRuleDescriptions.delete;
Line: 11654

      engStRuleIds.delete;
Line: 11655

      engStRuleIndexes.delete;
Line: 11656

      engStSourceTypes.delete;
Line: 11658

      engStSuspendedItems.delete;
Line: 11659

      engStSuspendedItemClasses.delete;
Line: 11660

      engStProductionsTable.delete;
Line: 11661

      engStVariableNames.delete;
Line: 11662

      engStVariableValues.delete;
Line: 11663

      engStItemAppProcessCompleteYN.delete;
Line: 11664

      engConfigVarNames.delete;
Line: 11665

      engConfigVarValues.delete;
Line: 11666

      engForwardingBehaviors.delete;
Line: 11667

      engPriorityModes.delete;
Line: 11668

      engPriorityThresholds.delete;
Line: 11669

      engActionTypeChainOrderModes.delete;
Line: 11670

      engActionTypeOrderNumbers.delete;
Line: 11671

      engActionTypeVotingRegimes.delete;
Line: 11672

      engActionTypeNames.delete;
Line: 11673

      engActionTypeUsages.delete;
Line: 11674

      engActionTypePackageNames.delete;
Line: 11675

      engItemClassIds.delete;
Line: 11676

      engItemClassIndexes.delete;
Line: 11677

      engItemClassItemIdIndexes.delete;
Line: 11678

      engItemClassNames.delete;
Line: 11679

      engItemClassOrderNumbers.delete;
Line: 11680

      engItemClassParModes.delete;
Line: 11681

      engItemClassSublistModes.delete;
Line: 11682

      engItemCounts.delete;
Line: 11683

      engItemIds.delete;
Line: 11684

      engAttributeIsStatics.delete;
Line: 11685

      engAttributeItemClassIds.delete;
Line: 11686

      engAttributeNames.delete;
Line: 11687

      engAttributeTypes.delete;
Line: 11688

      engAttributeValueIndexes.delete;
Line: 11689

      engAttributeValues1.delete;
Line: 11690

      engAttributeValues2.delete;
Line: 11691

      engAttributeValues3.delete;
Line: 11692

      engAttributeQueries.delete;
Line: 11693

      engAttributeVariant.delete;
Line: 11694

      engHeaderConditionValues.delete;
Line: 11695

      engACUsageConditionIds.delete;
Line: 11696

      engACUsageFirstIndexes.delete;
Line: 11697

      engACUsageItemClassCounts.delete;
Line: 11698

      engACUsageRuleIds.delete;
Line: 11699

      engACUsageRulePriorities.delete;
Line: 11700

      engACUsageRuleTypes.delete;
Line: 11701

      engACUsageRuleApprCategories.delete;
Line: 11702

      engACAttributeIds.delete;
Line: 11703

      engACConditionTypes.delete;
Line: 11704

      engACIncludeLowerLimits.delete;
Line: 11705

      engACIncludeUpperLimits.delete;
Line: 11706

      engACParameterOnes.delete;
Line: 11707

      engACParameterThrees.delete;
Line: 11708

      engACParameterTwos.delete;
Line: 11709

      engACStringValueCounts.delete;
Line: 11710

      engACStringValueFirstIndexes.delete;
Line: 11711

      engACStringValues.delete;
Line: 11712

      engOldApproverList.delete;
Line: 11713

      engInsertedApproverList.delete;
Line: 11714

      engInsertionOrderTypeList.delete;
Line: 11715

      engInsertionParameterList.delete;
Line: 11716

      engInsertionIsSpecialForwardee.delete;
Line: 11717

      engDeletedApproverList.delete;
Line: 11718

      engStInsertionIndexes.delete;
Line: 11719

      /*delete deviation related info*/
      engDeviationResultList.delete;
Line: 11721

      engInsertionReasonList.delete;
Line: 11722

      engInsertionDateList.delete;
Line: 11723

      engSuppressionDateList.delete;
Line: 11724

      engSupperssionReasonList.delete;
Line: 11725

      engInsApproverIndex.delete;
Line: 11762

      engUpdateCurrentApproverList := updateCurrentApproverListIn;
Line: 11763

      engUpdateOldApproverList := updateOldApproverListIn;
Line: 11805

           updateCurrentApproverListIn or
           updateOldApproverListIn or
           processPrioritiesIn or
           prepareItemDataIn or
           prepareRuleIdsIn or
           prepareRuleDescsIn) then
          /* Fetch the active condition usages. */
          fetchActiveConditionUsages;
Line: 11819

      /* Optionally fetch the inserted-approvers list. */
      if(fetchInsertionsIn) then
        fetchInsertedApprovers;
Line: 11825

        fetchDeletedApprovers;
Line: 11868

      delete
        from ame_temp_handler_states
        where
          handler_name = handlerName and
          application_id = engAmeApplicationId and
          ((parameter is null and parameterIn is null) or
           (parameter = parameterIn));
Line: 11875

      insert into ame_temp_handler_states(
        handler_name,
        row_timestamp,
        application_id,
        parameter,
        state)
        values(
          handlerName,
          sysdate, /* Don't use engEffectiveRuleDate here. */
          engAmeApplicationId,
          parameterIn,
          stateIn);
Line: 11905

  procedure setInsertedApprovalStatus(currentApproverIndexIn in integer
                                      ,approvalStatusIn in varchar2) as
      insIndex Number;
Line: 11913

            engInsertedApproverList(insIndex).approval_status := approvalStatusIn;
Line: 11914

            update ame_temp_insertions
             set approval_status = approvalStatusIn
            where application_id = engAmeApplicationId
              and transaction_id = engTransactionId
              and insertion_order = engInsertionOrderList(insIndex)
              and order_type = engInsertionOrderTypeList(insIndex)
              and parameter = engInsertionParameterList(insIndex)
              and api_insertion = engInsertedApproverList(insIndex).api_insertion
              and authority = engInsertedApproverList(insIndex).authority;
Line: 11932

                                  routineNameIn => 'setInsertedApprovalStatus',
                                  exceptionNumberIn => sqlcode,
                                  exceptionStringIn => sqlerrm);
Line: 11936

  end setInsertedApprovalStatus;
Line: 12088

      /* Update the occurrence values of the same approver wherever the approver occurs later in the same chain. */
      for i in approverIndexIn + 1 .. engStApprovers.count loop
        if(currentGroupOrChainId <> engStApprovers(i).group_or_chain_id or
           engStApprovers(approverIndexIn).action_type_id <> engStApprovers(i).action_type_id or
           engStApprovers(approverIndexIn).item_id <> engStApprovers(i).item_id or
           engStApprovers(approverIndexIn).item_class <> engStApprovers(i).item_class) then
          exit;
Line: 12161

         delete the rest of the chain.
      */
      truncateCount := lastIndexToTruncate - firstIndexToTruncate + 1;
Line: 12169

      /* Code to delete the approvers from the tree whenever there are approver suppressions */
      if engPrepareApproverTree then
        siblingTreeNodeIndex := ame_util.noSiblingIndex;
Line: 12182

              engStApproversTree.delete(loopIndex);
Line: 12186

              engStApproversTree.delete(loopIndex);
Line: 12200

      /* Delete the last truncateCount places. */
      engStApprovers.delete(engStApproversCount - truncateCount + 1, engStApproversCount);
Line: 12215

        delete from ame_temp_trans_locks
          where
            fnd_application_id = fndApplicationIdIn and
            ((transaction_type_id is null and transactionTypeIdIn is null) or
             transaction_type_id = transactionTypeIdIn) and
            transaction_id = transactionIdIn;
Line: 12231

  procedure updateTransactionState(isTestTransactionIn in boolean,
                                   isLocalTransactionIn in boolean,
                                   fetchConfigVarsIn in boolean,
                                   fetchOldApproversIn in boolean,
                                   fetchInsertionsIn in boolean,
                                   fetchDeletionsIn in boolean,
                                   fetchAttributeValuesIn in boolean,
                                   fetchInactiveAttValuesIn in boolean,
                                   processProductionActionsIn in boolean,
                                   processProductionRulesIn in boolean,
                                   updateCurrentApproverListIn in boolean,
                                   updateOldApproverListIn in boolean,
                                   processPrioritiesIn in boolean,
                                   prepareItemDataIn in boolean,
                                   prepareRuleIdsIn in boolean,
                                   prepareRuleDescsIn in boolean,
                                   prepareApproverTreeIn in boolean default false,
                                   transactionIdIn in varchar2,
                                   ameApplicationIdIn in integer default null,
                                   fndApplicationIdIn in integer default null,
                                   transactionTypeIdIn in varchar2 default null) as
    configVarException exception;
Line: 12260

                 fetchInsertionsIn => fetchInsertionsIn,
                 fetchDeletionsIn => fetchDeletionsIn,
                 fetchAttributeValuesIn => fetchAttributeValuesIn,
                 fetchInactiveAttValuesIn => fetchInactiveAttValuesIn,
                 processProductionActionsIn => processProductionActionsIn,
                 processProductionRulesIn => processProductionRulesIn,
                 updateCurrentApproverListIn => updateCurrentApproverListIn,
                 updateOldApproverListIn => updateOldApproverListIn,
                 processPrioritiesIn => processPrioritiesIn,
                 prepareItemDataIn => prepareItemDataIn,
                 prepareRuleIdsIn => prepareRuleIdsIn,
                 prepareRuleDescsIn => prepareRuleDescsIn,
                 prepareApproverTreeIn => prepareApproverTreeIn,
                 transactionIdIn => transactionIdIn,
                 ameApplicationIdIn => ameApplicationIdIn,
                 fndApplicationIdIn => fndApplicationIdIn,
                 transactionTypeIdIn => transactionTypeIdIn);
Line: 12280

          ,'ame_engine.updateTransactionState'
          ,'AME Application Id ::: ' || engAmeApplicationId
          );
Line: 12285

          ,'ame_engine.updateTransactionState'
          ,'AME Transaction Id ::: ' || engTransactionId
          );
Line: 12290

      if updateOldApproverListIn then
        logTransaction;
Line: 12295

         updateCurrentApproverListIn or
         updateOldApproverListIn or
         processPrioritiesIn or
         prepareItemDataIn or
         prepareRuleIdsIn or
         prepareRuleDescsIn) then
        if(not fetchConfigVarsIn) then
          raise configVarException;
Line: 12308

      if(updateCurrentApproverListIn or
         updateOldApproverListIn) then
        processRules(processOnlyProductionsIn => false);
Line: 12317

          ,'ame_engine.updateTransactionState'
          ,'Approver count after processRules ::: ' || engStApprovers.count
          );
Line: 12321

      if(updateCurrentApproverListIn or
         updateOldApproverListIn) then
        processAdHocInsertions;
Line: 12327

            ,'ame_engine.updateTransactionState'
            ,'Approver count after processAdHocInsertions ::: ' || engStApprovers.count
            );
Line: 12335

            ,'ame_engine.updateTransactionState'
            ,'Approver count after processUnresponsiveApprovers ::: ' || engStApprovers.count
            );
Line: 12344

              ,'ame_engine.updateTransactionState'
              ,'Approver count after repeatSubstitutions ::: ' || engStApprovers.count
              );
Line: 12358

            ,'ame_engine.updateTransactionState'
            ,'Approver count after processSuppressions ::: ' || engStApprovers.count
            );
Line: 12370

            ,'ame_engine.updateTransactionState'
            ,'Approver count after processRepeatedApprovers ::: ' || engStApprovers.count
            );
Line: 12382

          if updateOldApproverListIn then
            ame_approver_deviation_pkg.updateDeviationState(
                                         engAmeApplicationId
                                        ,engTransactionId
                                        ,engDeviationResultList
                                        ,engStApprovalProcessCompleteYN
                                        ,engStApprovers);
Line: 12395

              ,'ame_engine.updateTransactionState'
              ,'**************** No Approvers ******************'
              );
Line: 12402

                ,'ame_engine.updateTransactionState'
                ,'Approver ::: ' || engStApprovers(i).name || ' Order Number ::: ' || engStApprovers(i).approver_order_number
                );
Line: 12408

        if(updateOldApproverListIn) then
          updateOldApproverList;
Line: 12418

                                    routineNameIn => 'updateTransactionState',
                                    exceptionNumberIn => errorCode,
                                    exceptionStringIn => errorMessage);
Line: 12425

                                    routineNameIn => 'updateTransactionState',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 12429

    end updateTransactionState;
Line: 12430

  procedure updateOldApproverList as
    tempActionTypeIds ame_util.idList;
Line: 12444

      delete from ame_temp_old_approver_lists
        where
          application_id = engAmeApplicationId and
          transaction_id = engTransactionId;
Line: 12449

        Bulk insert the transaction's current state into ame_temp_old_approver_lists.
        Take the state from engStApprovers, to account for all operations on the approver list.
      */
      ame_util.convertApproversTable2ToValues(approversTableIn => engStApprovers,
                                              namesOut => tempNames,
                                              itemClassesOut => tempItemClasses,
                                              itemIdsOut => tempItemIds,
                                              apiInsertionsOut => tempApiValues,
                                              authoritiesOut => tempAuthorityValues,
                                              actionTypeIdsOut => tempActionTypeIds,
                                              groupOrChainIdsOut => tempGroupOrChainIds,
                                              occurrencesOut => tempOccurrences,
                                              approverCategoriesOut => tempCategories,
                                              statusesOut => tempStatuses);
Line: 12472

        setInsertedApprovalStatus(currentApproverIndexIn => i
                                 ,approvalStatusIn => engStApprovers(i).approval_status);
Line: 12476

        insert into ame_temp_old_approver_lists(
          transaction_id,
          application_id,
          order_number,
          name,
          item_class,
          item_id,
          api_insertion,
          authority,
          action_type_id,
          group_or_chain_id,
          occurrence,
          approver_category,
          approval_status) values(
            engTransactionId,
            engAmeApplicationId,
            tempOrderNumbers(i),
            tempNames(i),
            tempItemClasses(i),
            tempItemIds(i),
            tempApiValues(i),
            tempAuthorityValues(i),
            tempActionTypeIds(i),
            tempGroupOrChainIds(i),
            tempOccurrences(i),
            tempCategories(i),
            tempStatuses(i));
Line: 12506

                                    routineNameIn => 'updateOldApproverList',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 12510

    end updateOldApproverList;
Line: 12525

  procedure updateApprovalStatus(applicationIdIn in number,
                                 transactionTypeIn in varchar2,
                                 transactionIdIn in varchar2,
                                 approverIn in ame_util.approverRecord2,
                                 notificationIn in ame_util2.notificationRecord
                                         default ame_util2.emptyNotificationRecord,
                                 forwardeeIn in ame_util.approverRecord2 default
                                             ame_util.emptyApproverRecord2,
                                 updateItemIn in boolean default false) as
    ameApplicationId integer;
Line: 12535

    apiInsertionException exception;
Line: 12553

    insertedApprover ame_util.approverRecord2;
Line: 12559

    tempInsertionOrder integer;
Line: 12560

    tempParameter ame_temp_insertions.parameter%type;
Line: 12580

        delete from ame_exceptions_log
          where
            transaction_id = transactionIdIn and
            application_id = ameApplicationId;
Line: 12590

      ame_engine.updateTransactionState(isTestTransactionIn => false,
                                        isLocalTransactionIn => false,
                                        fetchConfigVarsIn => true,
                                        fetchOldApproversIn => true,
                                        fetchInsertionsIn => true,
                                        fetchDeletionsIn => true,
                                        fetchAttributeValuesIn => true,
                                        fetchInactiveAttValuesIn => false,
                                        processProductionActionsIn => false,
                                        processProductionRulesIn => false,
                                        updateCurrentApproverListIn => true,
                                        updateOldApproverListIn => false,
                                        processPrioritiesIn => true,
                                        prepareItemDataIn => false,
                                        prepareRuleIdsIn => false,
                                        prepareRuleDescsIn => false,
                                        prepareApproverTreeIn => true,
                                        transactionIdIn => transactionIdIn,
                                        ameApplicationIdIn => null,
                                        fndApplicationIdIn => applicationIdIn,
                                        transactionTypeIdIn => transactionTypeIn);
Line: 12718

        if(approver.source like (ame_util.specialForwardInsertion || '%')) then
          approverInIsSpecialForwardee := true;
Line: 12726

        /* If approverInIsSpecialForwardee, silently convert api_insertion to
           ame_util.apiInsertion for forwardee */
        if approverInIsSpecialForwardee then
          forwardee.api_insertion := ame_util.apiInsertion;
Line: 12731

        /* Make sure the forwardee has the correct api_insertion value for COA forwarders. */
        if(/* Special forwardees can only do ad-hoc forwardings. */
           (approverInIsSpecialForwardee and
            forwardee.api_insertion <> ame_util.apiInsertion) or
           /* Ad-hoc approvers can only do ad-hoc forwardings. */
           ((not approverInIsSpecialForwardee and
             approver.authority <> ame_util.authorityApprover or
             approver.api_insertion = ame_util.apiInsertion) and
            forwardee.api_insertion <> ame_util.apiInsertion) or
           /* COA approvers other than special forwardees can only do COA forwardings. */
           (not approverInIsSpecialForwardee and
            approver.authority = ame_util.authorityApprover and
            approver.api_insertion <> ame_util.apiInsertion and
            forwardee.api_insertion <> ame_util.apiAuthorityInsertion)) then
          raise apiInsertionException;
Line: 12764

                                                   tokenValueOneIn => 'ame_engine.updateApprovalStatus',
                                                   tokenNameTwoIn => 'NAME',
                                                   tokenValueTwoIn => forwardee.name);
Line: 12775

          make sure the forwardee is an ad-hoc insertion.  Make this change silently,
          so calling applications don't have to be originating-system aware.
        */
        if(approver.orig_system <> forwardee.orig_system) then
          forwardee.api_insertion := ame_util.apiInsertion;
Line: 12787

      /* Log the status update to the history table. */
      if(approverInIndex is null) then
        insert into ame_approvals_history(transaction_id,
                                          application_id,
                                          approval_status,
                                          row_timestamp,
                                          item_class,
                                          item_id,
                                          name,
                                          approver_category,
                                          action_type_id,
                                          group_or_chain_id,
                                          occurrence)
          values(transactionIdIn,
                 ameApplicationId,
                 decode(approver.approval_status,
                        ame_util.nullStatus, ame_util.nullHistoryStatus,
                        null, ame_util.nullHistoryStatus,
                        approver.approval_status),
                 sysdate,
                 approver.item_class,
                 approver.item_id,
                 approver.name,
                 approver.approver_category,
                 ame_util.nullHistoryActionTypeId,
                 ame_util.nullHistoryGroupOrChainId,
                 ame_util.nullHistoryOccurrence);
Line: 12818

        update AME_TRANS_APPROVAL_HISTORY
           set date_cleared = sysdate
          where transaction_id = transactionIdIn
            and application_id = ameApplicationId
            and name = approver.name
            and (approver.item_class is null or
                 item_class = approver.item_class)
            and (approver.item_id is null or
                 item_id = approver.item_id)
            and (approver.action_type_id is null or
                 action_type_id = approver.action_type_id)
            and (approver.group_or_chain_id is null or
                 group_or_chain_id = approver.group_or_chain_id)
            and (approver.occurrence is null or
                 occurrence = approver.occurrence)
            and date_cleared is null;
Line: 12836

        insertIntoTransApprovalHistory
          (transactionIdIn         => transactionIdIn
          ,applicationIdIn         => ameApplicationId
          ,orderNumberIn           => approver.approver_order_number
          ,nameIn                  => approver.name
          ,appCategoryIn           => approver.approver_category
          ,itemClassIn             => approver.item_class
          ,itemIdIn                => approver.item_id
          ,actionTypeIdIn          => ame_util.nullHistoryActionTypeId
          ,authorityIn             => approver.authority
          ,statusIn                => approver.approval_status
          ,grpOrChainIdIn          => ame_util.nullHistoryGroupOrChainId
          ,occurrenceIn            => ame_util.nullHistoryOccurrence
          ,apiInsertionIn          => approver.api_insertion
          ,memberOrderNumberIn     => approver.member_order_number
          ,notificationIdIn        => notificationIn.notification_id
          ,userCommentsIn          => notificationIn.user_comments
          ,dateClearedIn           => sysdate
          ,historyTypeIn           => 'APPROVERNOTPRESENT');
Line: 12855

        /* Insert a warning into AME's exception log and return. */
        errorCode := -20001;
Line: 12865

                                  routineNameIn => 'updateApprovalStatus',
                                  exceptionNumberIn => errorCode,
                                  exceptionStringIn => errorMessage);
Line: 12870

      insert into ame_approvals_history(transaction_id,
                                        application_id,
                                        approval_status,
                                        row_timestamp,
                                        item_class,
                                        item_id,
                                        name,
                                        approver_category,
                                        action_type_id,
                                        group_or_chain_id,
                                        occurrence)
        values(transactionIdIn,
               ameApplicationId,
               decode(approver.approval_status,
                      ame_util.nullStatus, ame_util.nullHistoryStatus,
                      null, ame_util.nullHistoryStatus,
                      approver.approval_status),
               sysdate,
               approver.item_class,
               approver.item_id,
               approver.name,
               approver.approver_category,
               approver.action_type_id,
               approver.group_or_chain_id,
               approver.occurrence);
Line: 12902

        insertIntoTransApprovalHistory
          (transactionIdIn         => transactionIdIn
          ,applicationIdIn         => ameApplicationId
          ,orderNumberIn           => approver.approver_order_number
          ,nameIn                  => approver.name
          ,appCategoryIn           => approver.approver_category
          ,itemClassIn             => approver.item_class
          ,itemIdIn                => approver.item_id
          ,actionTypeIdIn          => approver.action_type_id
          ,authorityIn             => approver.authority
          ,statusIn                => approver.approval_status
          ,grpOrChainIdIn          => approver.group_or_chain_id
          ,occurrenceIn            => approver.occurrence
          ,apiInsertionIn          => approver.api_insertion
          ,memberOrderNumberIn     => approver.member_order_number
          ,notificationIdIn        => notificationIn.notification_id
          ,userCommentsIn          => notificationIn.user_comments
          ,dateClearedIn           => sysdate
          ,historyTypeIn           => 'APPROVERPRESENT');
Line: 12925

        insertIntoTransApprovalHistory
          (transactionIdIn         => transactionIdIn
          ,applicationIdIn         => ameApplicationId
          ,orderNumberIn           => approver.approver_order_number
          ,nameIn                  => approver.name
          ,appCategoryIn           => approver.approver_category
          ,itemClassIn             => approver.item_class
          ,itemIdIn                => approver.item_id
          ,actionTypeIdIn          => approver.action_type_id
          ,authorityIn             => approver.authority
          ,statusIn                => approver.approval_status
          ,grpOrChainIdIn          => approver.group_or_chain_id
          ,occurrenceIn            => approver.occurrence
          ,apiInsertionIn          => approver.api_insertion
          ,memberOrderNumberIn     => approver.member_order_number
          ,notificationIdIn        => notificationIn.notification_id
          ,userCommentsIn          => notificationIn.user_comments
          ,dateClearedIn           => null
          ,historyTypeIn           => 'APPROVERPRESENT');
Line: 12945

        Update the status of approverIn in ame_temp_old_approver_lists.  If updateItemIn
        is true, update also any other occurrences of the same approver for the same item
        class and item ID.
      */
      if(updateItemIn) then
        if(approver.approval_status in (ame_util.forwardStatus, ame_util.approveAndForwardStatus)) then
          /* Update the forwarder proper. */
          update ame_temp_old_approver_lists
            set approval_status = approver.approval_status
            where
              application_id = ameApplicationId and
              transaction_id = transactionIdIn and
              name = approver.name and
              item_class = approver.item_class and
              item_id = approver.item_id and
              action_type_id = approver.action_type_id and
              group_or_chain_id = approver.group_or_chain_id and
              occurrence = approver.occurrence;
Line: 12964

          update ame_temp_old_approver_lists
            set approval_status = ame_util.suppressedStatus
            where
              application_id = ameApplicationId and
              transaction_id = transactionIdIn and
              name = approver.name and
              item_class = approver.item_class and
              item_id = approver.item_id and
              (action_type_id <> approver.action_type_id or
               group_or_chain_id <> approver.group_or_chain_id or
               occurrence <> approver.occurrence);
Line: 12976

          update ame_temp_old_approver_lists
            set approval_status = approver.approval_status
            where
              application_id = ameApplicationId and
              transaction_id = transactionIdIn and
              name = approver.name and
              item_class = approver.item_class and
              item_id = approver.item_id;
Line: 12986

        update ame_temp_old_approver_lists
          set approval_status = approver.approval_status
          where
            application_id = ameApplicationId and
            transaction_id = transactionIdIn and
            name = approver.name and
            item_class = approver.item_class and
            item_id = approver.item_id and
            action_type_id = approver.action_type_id and
            group_or_chain_id = approver.group_or_chain_id and
            occurrence = approver.occurrence;
Line: 13000

        setInsertedApprovalStatus(currentApproverIndexIn => approverInIndex
                                  ,approvalStatusIn => approver.approval_status);
Line: 13010

            update ame_temp_old_approver_lists
               set approval_status = decode(approver.approval_status
                                           ,ame_util.approvedStatus
                                           ,ame_util.approvedByRepeatedStatus
                                           ,ame_util.approveAndForwardStatus
                                           ,ame_util.approvedByRepeatedStatus
                                           ,ame_util.rejectStatus
                                           ,ame_util.rejectedByRepeatedStatus
                                           ,ame_util.forwardStatus
                                           ,ame_util2.forwardByRepeatedStatus
                                           ,ame_util2.reassignStatus
                                           ,ame_util.nullStatus
                                           ,ame_util.noResponseStatus
                                           ,ame_util2.noResponseByRepeatedStatus
                                           ,ame_util.repeatedStatus)
             where application_id = ameApplicationId
               and transaction_id = transactionIdIn
               and name           = approver.name
               and item_class        = currentApprovers(repeatedAppIndexes(z)).item_class
               and item_id           = currentApprovers(repeatedAppIndexes(z)).item_id
               and action_type_id    = currentApprovers(repeatedAppIndexes(z)).action_type_id
               and group_or_chain_id = currentApprovers(repeatedAppIndexes(z)).group_or_chain_id
               and occurrence        = currentApprovers(repeatedAppIndexes(z)).occurrence
               and approval_status in ( ame_util.notifiedByRepeatedStatus
                                       ,ame_util.repeatedStatus);
Line: 13035

            select decode(approver.approval_status
                                           ,ame_util.approvedStatus
                                           ,ame_util.approvedByRepeatedStatus
                                           ,ame_util.approveAndForwardStatus
                                           ,ame_util.approvedByRepeatedStatus
                                           ,ame_util.rejectStatus
                                           ,ame_util.rejectedByRepeatedStatus
                                           ,ame_util.forwardStatus
                                           ,ame_util2.forwardByRepeatedStatus
                                           ,ame_util2.reassignStatus
                                           ,ame_util.nullStatus
                                           ,ame_util.noResponseStatus
                                           ,ame_util2.noResponseByRepeatedStatus
                                           ,ame_util.repeatedStatus) into tempStatus from dual;
Line: 13049

            setInsertedApprovalStatus(currentApproverIndexIn => repeatedAppIndexes(z)
                                     ,approvalStatusIn => tempStatus);
Line: 13062

              select count(*)
                 into tempfrwCount
                 from ame_temp_old_approver_lists
                where
                  application_id = ameApplicationId and
                  transaction_id = transactionIdIn and
                  item_class = currentApprovers(l_frw_index).item_class and
                  item_id = currentApprovers(l_frw_index).item_id and
                  action_type_id = currentApprovers(l_frw_index).action_type_id and
                  group_or_chain_id = currentApprovers(l_frw_index).group_or_chain_id and
                  approver_category = ame_util.approvalApproverCategory and
                  approval_status  in (ame_util.notifiedStatus
                                       ,ame_util.notifiedByRepeatedStatus) and
                 exists ( select null
                          from ame_temp_old_approver_lists
                          where  application_id = ameApplicationId and
                                 transaction_id = transactionIdIn and
                                 item_class = currentApprovers(l_frw_index).item_class and
                                 item_id = currentApprovers(l_frw_index).item_id and
                                 action_type_id = currentApprovers(l_frw_index).action_type_id and
                                 group_or_chain_id = currentApprovers(l_frw_index).group_or_chain_id and
                                 approver_category = ame_util.approvalApproverCategory and
                                 approval_status in (ame_util.approvedStatus
                                                    ,ame_util.approvedByRepeatedStatus
                                                    ,ame_util.rejectStatus
                                                    ,ame_util.rejectedByRepeatedStatus)
                           ) and
                not exists ( select null
                          from ame_temp_old_approver_lists
                          where  application_id = ameApplicationId and
                                 transaction_id = transactionIdIn and
                                 item_class = currentApprovers(l_frw_index).item_class and
                                 item_id = currentApprovers(l_frw_index).item_id and
                                 action_type_id = currentApprovers(l_frw_index).action_type_id and
                                 group_or_chain_id = currentApprovers(l_frw_index).group_or_chain_id and
                                 approver_category = ame_util.approvalApproverCategory and
                                 (approval_status  is null or approval_status in (
                                                     ame_util.nullStatus
                                                    ,ame_util.repeatedStatus)));
Line: 13102

                 update ame_temp_old_approver_lists
                 set approval_status = ame_util.beatByFirstResponderStatus
                 where
                  application_id = ameApplicationId and
                  transaction_id = transactionIdIn and
                  item_class = currentApprovers(l_frw_index).item_class and
                  item_id = currentApprovers(l_frw_index).item_id and
                  action_type_id = currentApprovers(l_frw_index).action_type_id and
                  group_or_chain_id = currentApprovers(l_frw_index).group_or_chain_id and
                  approver_category = ame_util.approvalApproverCategory and
                  approval_status in (ame_util.notifiedStatus,ame_util.notifiedByRepeatedStatus );
Line: 13113

                 insertIntoTransApprovalHistory
                   (transactionIdIn         => transactionIdIn
                   ,applicationIdIn         => ameApplicationId
                   ,orderNumberIn           => currentApprovers(l_frw_index).approver_order_number
                   ,nameIn                  => currentApprovers(l_frw_index).name
                   ,appCategoryIn           => null
                   ,itemClassIn             => currentApprovers(l_frw_index).item_class
                   ,itemIdIn                => currentApprovers(l_frw_index).item_id
                   ,actionTypeIdIn          => currentApprovers(l_frw_index).action_type_id
                   ,authorityIn             => null
                   ,statusIn                => null
                   ,grpOrChainIdIn          => currentApprovers(l_frw_index).group_or_chain_id
                   ,occurrenceIn            => currentApprovers(l_frw_index).occurrence
                   ,apiInsertionIn          => currentApprovers(l_frw_index).api_insertion
                   ,memberOrderNumberIn     => currentApprovers(l_frw_index).member_order_number
                   ,notificationIdIn        => notificationIn.notification_id
                   ,userCommentsIn          => null
                   ,dateClearedIn           => null
                   ,historyTypeIn           => 'BEATBYFIRSTRESPONDER');
Line: 13165

            update ame_temp_old_approver_lists
              set approval_status = ame_util.beatByFirstResponderStatus
              where
                application_id = ameApplicationId and
                transaction_id = transactionIdIn and
                (name <> approver.name or
                 occurrence <> approver.occurrence) and
                item_class = approver.item_class and
                item_id = approver.item_id and
                action_type_id = approver.action_type_id and
                group_or_chain_id = approver.group_or_chain_id and
                  approver_category = ame_util.approvalApproverCategory and
                  approval_status in (ame_util.notifiedStatus,ame_util.notifiedByRepeatedStatus);
Line: 13187

              setInsertedApprovalStatus(currentApproverIndexIn => i
                                       ,approvalStatusIn => ame_util.beatByFirstResponderStatus);
Line: 13191

            /* Insert rows in the notification approval history region for approvers
               with beat by first responder */
            insertIntoTransApprovalHistory
              (transactionIdIn         => transactionIdIn
              ,applicationIdIn         => ameApplicationId
              ,orderNumberIn           => approver.approver_order_number
              ,nameIn                  => approver.name
              ,appCategoryIn           => null
              ,itemClassIn             => approver.item_class
              ,itemIdIn                => approver.item_id
              ,actionTypeIdIn          => approver.action_type_id
              ,authorityIn             => null
              ,statusIn                => null
              ,grpOrChainIdIn          => approver.group_or_chain_id
              ,occurrenceIn            => approver.occurrence
              ,apiInsertionIn          => approver.api_insertion
              ,memberOrderNumberIn     => approver.member_order_number
              ,notificationIdIn        => notificationIn.notification_id
              ,userCommentsIn          => null
              ,dateClearedIn           => null
              ,historyTypeIn           => 'BEATBYFIRSTRESPONDER');
Line: 13217

            update ame_temp_old_approver_lists
               set approval_status = null
             where
              application_id = ameApplicationId and
              transaction_id = transactionIdIn and
              (name <> approver.name or
               occurrence <> approver.occurrence) and
              item_class = approver.item_class and
              item_id = approver.item_id and
              action_type_id = approver.action_type_id and
              group_or_chain_id = approver.group_or_chain_id and
              approver_category = ame_util.approvalApproverCategory;
Line: 13230

            insertIntoTransApprovalHistory
              (transactionIdIn         => transactionIdIn
              ,applicationIdIn         => ameApplicationId
              ,orderNumberIn           => approver.approver_order_number
              ,nameIn                  => approver.name
              ,appCategoryIn           => approver.approver_category
              ,itemClassIn             => approver.item_class
              ,itemIdIn                => approver.item_id
              ,actionTypeIdIn          => approver.action_type_id
              ,authorityIn             => approver.authority
              ,statusIn                => approver.approval_status
              ,grpOrChainIdIn          => approver.group_or_chain_id
              ,occurrenceIn            => approver.occurrence
              ,apiInsertionIn          => approver.api_insertion
              ,memberOrderNumberIn     => approver.member_order_number
              ,notificationIdIn        => notificationIn.notification_id
              ,userCommentsIn          => notificationIn.user_comments
              ,dateClearedIn           => null
              ,historyTypeIn           => 'CLEARFRWGRP');
Line: 13276

                                                  tokenValueOneIn => 'ame_engine.updateApprovalStatus',
                                                  tokenNameTwoIn => 'NAME',
                                                  tokenValueTwoIn => forwardee.name);
Line: 13284

          tempInsertionOrder := ame_engine.getNextInsertionOrder;
Line: 13296

          insert into ame_temp_insertions(
              transaction_id,
              application_id,
              insertion_order,
              order_type,
              parameter,
              description,
              name,
              item_class,
              item_id,
              approver_category,
              api_insertion,
              authority,
              effective_date,
              reason) values(
                transactionIdIn,
                ameApplicationId,
                tempInsertionOrder,
                ame_util.afterApprover,
                tempParameter,
                ame_util.afterApproverDescription || approver.display_name,
                forwardee.name,
                forwardee.item_class,
                forwardee.item_id,
                forwardee.approver_category,
                decode(forwarderType,
                       ame_util.chainOfAuthorityForwarder, ame_util.apiAuthorityInsertion,
                       ame_util.apiInsertion),
                approver.authority,
                sysdate,
                ame_approver_deviation_pkg.reassignStatus );
Line: 13335

           approver.api_insertion = ame_util.apiInsertion) then
          forwarderType := ame_util.adHocForwarder;
Line: 13370

          tempInsertionOrder := ame_engine.getNextInsertionOrder;
Line: 13382

          insert into ame_temp_insertions(
              transaction_id,
              application_id,
              insertion_order,
              order_type,
              parameter,
              description,
              name,
              item_class,
              item_id,
              approver_category,
              api_insertion,
              authority,
              effective_date,
              reason) values(
                transactionIdIn,
                ameApplicationId,
                tempInsertionOrder,
                ame_util.afterApprover,
                tempParameter,
                ame_util.afterApproverDescription || approver.display_name,
                forwardee.name,
                forwardee.item_class,
                forwardee.item_id,
                forwardee.approver_category,
                decode(forwarderType,
                       ame_util.chainOfAuthorityForwarder, ame_util.apiAuthorityInsertion,
                       ame_util.apiInsertion),
                approver.authority,
                sysdate
                ,ame_approver_deviation_pkg.forwardReason );
Line: 13415

            All of the insertees generated within this if statement should have the same
            action_type_id and group_or_chain_id as approver.  The insertees' source
            should always be ame_util.specialForwardInsertion.  The insertions' order
            types should always be ame_util.afterApprover.
          */
          forwardingBehavior := ame_engine.getForwardingBehavior(forwarderTypeIn => forwarderType,
                                                                 forwardeeTypeIn => forwardeeType,
                                                                 approvalStatusIn => approver.approval_status);
Line: 13427

              Locate the start of the chain, so we can calculate each insertee's occurrence
              value, for use in the following insertee's insertion parameter.
            */
            for i in reverse 1 .. (approverInIndex - 1) loop
              if(currentApprovers(i).group_or_chain_id <> approver.group_or_chain_id or
                 currentApprovers(i).action_type_id <> approver.action_type_id or
                 currentApprovers(i).item_id <> approver.item_id or
                 currentApprovers(i).item_class <> approver.item_class) then
                firstIndexInChain := i + 1;
Line: 13446

            /* Insert forwardee as ad-hoc or COA, according to whether approverIn is ad-hoc or COA. */
            tempInsertionOrder := ame_engine.getNextInsertionOrder;
Line: 13459

            insert into ame_temp_insertions(
              transaction_id,
              application_id,
              insertion_order,
              order_type,
              parameter,
              description,
              name,
              item_class,
              item_id,
              approver_category,
              api_insertion,
              authority,
              special_forwardee,
              effective_date,
              reason) values(
                transactionIdIn,
                ameApplicationId,
                tempInsertionOrder,
                ame_util.afterApprover,
                tempParameter,
                ame_util.afterApproverDescription || approver.display_name,
                forwardee.name,
                forwardee.item_class,
                forwardee.item_id,
                ame_util.approvalApproverCategory, /* Forwarding is not possible from an FYI approver. */
                decode(forwarderType,
                       ame_util.chainOfAuthorityForwarder, ame_util.apiAuthorityInsertion,
                       ame_util.apiInsertion),
                approver.authority,
                ame_util.booleanTrue,
                sysdate,
                ame_approver_deviation_pkg.forwardReason);
Line: 13492

            if(forwardingBehavior = ame_util.forwarderAndForwardee) then /* Insert the forwarder. */
              tempInsertionOrder := ame_engine.getNextInsertionOrder;
Line: 13505

              insert into ame_temp_insertions(
                transaction_id,
                application_id,
                insertion_order,
                order_type,
                parameter,
                description,
                name,
                item_class,
                item_id,
                approver_category,
                api_insertion,
                authority,
                special_forwardee,
                effective_date,
                reason) values(
                  transactionIdIn,
                  ameApplicationId,
                  tempInsertionOrder,
                  ame_util.afterApprover,
                  tempParameter,
                  ame_util.afterApproverDescription || forwardee.display_name,
                  approver.name,
                  approver.item_class,
                  approver.item_id,
                  ame_util.approvalApproverCategory, /* Forwarding is not possible from an FYI approver. */
                  decode(forwarderType,
                         ame_util.chainOfAuthorityForwarder, ame_util.apiAuthorityInsertion,
                         ame_util.apiInsertion),
                  approver.authority,
                  ame_util.booleanTrue,
                  sysdate,
                  ame_approver_deviation_pkg.forwardForwardeeReason);
Line: 13543

              case we insert starting at the insertee, and ascending the hierarchy up to but not
              including approver.  In the case of ame_util.repeatForwarder, we then add
              approverIn and stop.  In the case of ame_util.skipForwarder, we then add
              approverIn's superior and stop.  The insertees are all COA approvers.
            */
            /* Insert the forwardee. */
            tempInsertionOrder := ame_engine.getNextInsertionOrder;
Line: 13561

            insert into ame_temp_insertions(
              transaction_id,
              application_id,
              insertion_order,
              order_type,
              parameter,
              description,
              name,
              item_class,
              item_id,
              approver_category,
              api_insertion,
              authority,
              special_forwardee,
              effective_date,
              reason) values(
                transactionIdIn,
                ameApplicationId,
                tempInsertionOrder,
                ame_util.afterApprover,
                tempParameter,
                ame_util.afterApproverDescription || approver.display_name,
                forwardee.name,
                forwardee.item_class,
                forwardee.item_id,
                ame_util.approvalApproverCategory, /* Forwarding is not possible from an FYI approver. */
                ame_util.apiAuthorityInsertion,
                ame_util.authorityApprover,
                ame_util.booleanTrue,
                sysdate,
                ame_approver_deviation_pkg.forwardReason);
Line: 13592

            insertedApprover.name := forwardee.name;
Line: 13593

            insertedApprover.orig_system := forwardee.orig_system;
Line: 13594

            insertedApprover.orig_system_id := forwardee.orig_system_id;
Line: 13595

            insertedApprover.item_class := forwardee.item_class;
Line: 13596

            insertedApprover.item_id := forwardee.item_id;
Line: 13597

            insertedApprover.action_type_id := forwardee.action_type_id;
Line: 13598

            insertedApprover.group_or_chain_id :=forwardee.group_or_chain_id;
Line: 13599

            insertedApprover.occurrence := forwardee.occurrence;
Line: 13603

              /* Get the next superior to insert. */
              tempReason := ame_approver_deviation_pkg.forwardEngInsReason;
Line: 13605

              ame_approver_type_pkg.getSuperior(approverIn => insertedApprover,
                                                superiorOut => superiorApprover);
Line: 13618

              /* Calculate insertedApprover.occurrence. */
              insertedApprover.occurrence := 1;
Line: 13621

                if(currentApprovers(i).name = insertedApprover.name) then
                  insertedApprover.occurrence := currentApprovers(i).occurrence + 1;
Line: 13626

              /* Prepare and do the insertion. */
              tempInsertionOrder := ame_engine.getNextInsertionOrder;
Line: 13628

              tempParameter := insertedApprover.name ||
                               ame_util.fieldDelimiter ||
                               insertedApprover.item_class ||
                               ame_util.fieldDelimiter ||
                               insertedApprover.item_id ||
                               ame_util.fieldDelimiter ||
                               insertedApprover.action_type_id ||
                               ame_util.fieldDelimiter ||
                               insertedApprover.group_or_chain_id ||
                               ame_util.fieldDelimiter ||
                               insertedApprover.occurrence;
Line: 13639

              insert into ame_temp_insertions(
                transaction_id,
                application_id,
                insertion_order,
                order_type,
                parameter,
                description,
                name,
                item_class,
                item_id,
                approver_category,
                api_insertion,
                authority,
                special_forwardee,
                effective_date,
                reason) values(
                  transactionIdIn,
                  ameApplicationId,
                  tempInsertionOrder,
                  ame_util.afterApprover,
                  tempParameter,
                  ame_util.afterApproverDescription || insertedApprover.display_name,
                  superiorApprover.name,
                  approver.item_class,
                  approver.item_id,
                  ame_util.approvalApproverCategory, /* Forwarding is not possible from an FYI approver. */
                  ame_util.apiAuthorityInsertion,
                  ame_util.authorityApprover,
                  ame_util.booleanTrue,
                  sysdate,
                  tempReason);
Line: 13673

              insertedApprover.name := superiorApprover.name;
Line: 13674

              insertedApprover.orig_system_id := superiorApprover.orig_system_id;
Line: 13680

              such cases, we insert starting with forwardeeIn and continuing up to and including
              approver.  The insertees are always ad-hoc, and pertain to the same item, sublist,
              action type, and group or chain as the forwarder.
            */
            for i in forwardeeIndex .. approverInIndex loop
              if(i = forwardeeIndex) then
                prevApproverIndex := approverInIndex;
Line: 13698

              tempInsertionOrder := ame_engine.getNextInsertionOrder;
Line: 13710

              insert into ame_temp_insertions(
                transaction_id,
                application_id,
                insertion_order,
                order_type,
                parameter,
                description,
                name,
                item_class,
                item_id,
                approver_category,
                api_insertion,
                authority,
                special_forwardee,
                effective_date,
                reason) values(
                  transactionIdIn,
                  ameApplicationId,
                  tempInsertionOrder,
                  ame_util.afterApprover,
                  tempParameter,
                  ame_util.afterApproverDescription || insertedApprover.display_name,
                  currentApprovers(i).name,
                  approver.item_class,
                  approver.item_id,
                  ame_util.approvalApproverCategory, /* Forwarding is not possible from an FYI approver. */
                  ame_util.apiInsertion,
                  approver.authority,
                  ame_util.booleanTrue,
                  sysdate,
                  ame_approver_deviation_pkg.forwardRemandReason);
Line: 13747

      ame_engine.updateTransactionState(isTestTransactionIn => false,
                                          isLocalTransactionIn => false,
                                          fetchConfigVarsIn => true,
                                          fetchOldApproversIn => true,
                                          fetchInsertionsIn => true,
                                          fetchDeletionsIn => true,
                                          fetchAttributeValuesIn => true,
                                          fetchInactiveAttValuesIn => false,
                                          processProductionActionsIn => false,
                                          processProductionRulesIn => false,
                                          updateCurrentApproverListIn => true,
                                          updateOldApproverListIn => true,
                                          processPrioritiesIn => true,
                                          prepareItemDataIn => false,
                                          prepareRuleIdsIn => false,
                                          prepareRuleDescsIn => false,
                                          transactionIdIn => transactionIdIn,
                                          ameApplicationIdIn => null,
                                          fndApplicationIdIn => applicationIdIn,
                                          transactionTypeIdIn => transactionTypeIn);
Line: 13791

                                    routineNameIn => 'updateApprovalStatus',
                                    exceptionNumberIn => errorCode,
                                    exceptionStringIn => errorMessage);
Line: 13796

        when apiInsertionException then
          ame_engine.unlockTransaction(fndApplicationIdIn => applicationIdIn,
                                       transactionIdIn => transactionIdIn,
                                       transactionTypeIdIn => transactionTypeIn);
Line: 13805

                                    routineNameIn => 'updateApprovalStatus',
                                    exceptionNumberIn => errorCode,
                                    exceptionStringIn => errorMessage);
Line: 13849

                                    routineNameIn => 'updateApprovalStatus',
                                    exceptionNumberIn => errorCode,
                                    exceptionStringIn => errorMessage);
Line: 13859

                                    routineNameIn => 'updateApprovalStatus',
                                    exceptionNumberIn => sqlcode,
                                    exceptionStringIn => sqlerrm);
Line: 13863

    end updateApprovalStatus;
Line: 13864

  procedure updateInsertions(indexIn in integer) as
    tempIndex integer;
Line: 13866

    approverInsertionOrder integer;
Line: 13867

    deletionInsertionOrder integer;
Line: 13869

      if engStInsertionIndexes.exists(indexIn) then
        deletionInsertionOrder := engStInsertionIndexes(indexIn);
Line: 13871

        tempIndex := engStInsertionIndexes.next(indexIn);
Line: 13872

        while engStInsertionIndexes.exists(tempIndex) loop
          approverInsertionOrder := engStInsertionIndexes(tempIndex);
Line: 13874

          if approverInsertionOrder > deletionInsertionOrder then
            update ame_temp_insertions
               set parameter = parameter - 1
             where insertion_order = approverInsertionOrder
               and application_id = engAmeApplicationId
               and transaction_id = engTransactionId
               and order_type = ame_util.absoluteOrder;
Line: 13882

          tempIndex := engStInsertionIndexes.next(tempIndex);
Line: 13885

    end updateInsertions;