17: into l_condition_type
18: from ame_conditions
19: where ame_conditions.condition_id = p_condition_id
20: and p_effective_date between start_date
21: and nvl(end_date - ame_util.oneSecond, p_effective_date);
22: return(l_condition_type);
23: exception
24: when others then
25: fnd_message.set_name('PER','AME_400494_INVALID_CONDITION');
45: from ame_rule_usages
46: where rule_id =p_rule_id
47: and item_id = p_application_id
48: and (p_effective_date between start_date
49: and nvl(end_date - ame_util.oneSecond, p_effective_date)
50: or
51: (p_effective_date < start_date
52: and start_date < nvl(end_date, start_date + ame_util.oneSecond)))
53: order by start_date desc;
48: and (p_effective_date between start_date
49: and nvl(end_date - ame_util.oneSecond, p_effective_date)
50: or
51: (p_effective_date < start_date
52: and start_date < nvl(end_date, start_date + ame_util.oneSecond)))
53: order by start_date desc;
54: usagestartDateList ame_util.dateList;
55: usageEndDateList ame_util.dateList;
56: usagePriorityList ame_util.idList;
50: or
51: (p_effective_date < start_date
52: and start_date < nvl(end_date, start_date + ame_util.oneSecond)))
53: order by start_date desc;
54: usagestartDateList ame_util.dateList;
55: usageEndDateList ame_util.dateList;
56: usagePriorityList ame_util.idList;
57: begin
58: for ruleUsage in ruleUsageCursor loop
51: (p_effective_date < start_date
52: and start_date < nvl(end_date, start_date + ame_util.oneSecond)))
53: order by start_date desc;
54: usagestartDateList ame_util.dateList;
55: usageEndDateList ame_util.dateList;
56: usagePriorityList ame_util.idList;
57: begin
58: for ruleUsage in ruleUsageCursor loop
59: if (p_old_start_date is null or
52: and start_date < nvl(end_date, start_date + ame_util.oneSecond)))
53: order by start_date desc;
54: usagestartDateList ame_util.dateList;
55: usageEndDateList ame_util.dateList;
56: usagePriorityList ame_util.idList;
57: begin
58: for ruleUsage in ruleUsageCursor loop
59: if (p_old_start_date is null or
60: p_old_start_date <> ruleUsage.start_date) then
66: elsif ( trunc(p_rlu_start_date) = trunc(ruleUsage.start_date) and
67: trunc(p_rlu_end_date) = trunc(ruleUsage.end_date)
68: ) then
69: return(2);
70: elsif (ruleUsage.end_date = ame_utility_pkg.endOfTime and p_rlu_end_date = ame_utility_pkg.endOfTime) then
71: return(3);
72: elsif ((p_rlu_end_date = ame_utility_pkg.endOfTime and p_rlu_start_date < ruleUsage.end_date)
73: or
74: ( ruleUsage.end_date = ame_utility_pkg.endOfTime and
68: ) then
69: return(2);
70: elsif (ruleUsage.end_date = ame_utility_pkg.endOfTime and p_rlu_end_date = ame_utility_pkg.endOfTime) then
71: return(3);
72: elsif ((p_rlu_end_date = ame_utility_pkg.endOfTime and p_rlu_start_date < ruleUsage.end_date)
73: or
74: ( ruleUsage.end_date = ame_utility_pkg.endOfTime and
75: (p_rlu_start_date >= ruleUsage.start_date
76: or p_rlu_end_date > ruleUsage.start_date))
70: elsif (ruleUsage.end_date = ame_utility_pkg.endOfTime and p_rlu_end_date = ame_utility_pkg.endOfTime) then
71: return(3);
72: elsif ((p_rlu_end_date = ame_utility_pkg.endOfTime and p_rlu_start_date < ruleUsage.end_date)
73: or
74: ( ruleUsage.end_date = ame_utility_pkg.endOfTime and
75: (p_rlu_start_date >= ruleUsage.start_date
76: or p_rlu_end_date > ruleUsage.start_date))
77: ) then
78: return(3);
76: or p_rlu_end_date > ruleUsage.start_date))
77: ) then
78: return(3);
79: elsif ( (p_rlu_start_date between ruleUsage.start_date and
80: ruleUsage.end_date - ame_util.oneSecond)
81: or
82: (p_rlu_end_date between ruleUsage.start_date and
83: ruleUsage.end_date - ame_util.oneSecond)
84: or
79: elsif ( (p_rlu_start_date between ruleUsage.start_date and
80: ruleUsage.end_date - ame_util.oneSecond)
81: or
82: (p_rlu_end_date between ruleUsage.start_date and
83: ruleUsage.end_date - ame_util.oneSecond)
84: or
85: (ruleUsage.start_date between p_rlu_start_date and
86: p_rlu_end_date - ame_util.oneSecond )
87: or
82: (p_rlu_end_date between ruleUsage.start_date and
83: ruleUsage.end_date - ame_util.oneSecond)
84: or
85: (ruleUsage.start_date between p_rlu_start_date and
86: p_rlu_end_date - ame_util.oneSecond )
87: or
88: (ruleUsage.end_date - ame_util.oneSecond between p_rlu_start_date and
89: p_rlu_end_date - ame_util.oneSecond )
90: ) then
84: or
85: (ruleUsage.start_date between p_rlu_start_date and
86: p_rlu_end_date - ame_util.oneSecond )
87: or
88: (ruleUsage.end_date - ame_util.oneSecond between p_rlu_start_date and
89: p_rlu_end_date - ame_util.oneSecond )
90: ) then
91: return(3);
92: end if;
85: (ruleUsage.start_date between p_rlu_start_date and
86: p_rlu_end_date - ame_util.oneSecond )
87: or
88: (ruleUsage.end_date - ame_util.oneSecond between p_rlu_start_date and
89: p_rlu_end_date - ame_util.oneSecond )
90: ) then
91: return(3);
92: end if;
93: end if;
112: l_allowAllApproverTypes varchar2(30);
113: l_allowProduction varchar2(30);
114: l_swi_package_name varchar2(30) := 'AME_RULE_SWI';
115: l_count number;
116: actionTypeIds ame_util.idList;
117: l_rule_type ame_rules.rule_type%type;
118: applicationName ame_calling_apps.application_name%type;
119: --+
120: cursor getApplicationName(applicationIdIn in integer)is
128: from ame_actions, ame_action_usages
129: where ame_action_usages.rule_id = p_rule_id
130: and ame_action_usages.action_id = ame_actions.action_id
131: and (p_effective_date between ame_action_usages.start_date
132: and nvl(ame_action_usages.end_date - ame_util.oneSecond, p_effective_date)
133: or
134: (p_effective_date < ame_action_usages.start_date
135: and ame_action_usages.start_date < nvl(ame_action_usages.end_date, ame_action_usages.start_date + ame_util.oneSecond)))
136: and p_effective_date between ame_actions.start_date
131: and (p_effective_date between ame_action_usages.start_date
132: and nvl(ame_action_usages.end_date - ame_util.oneSecond, p_effective_date)
133: or
134: (p_effective_date < ame_action_usages.start_date
135: and ame_action_usages.start_date < nvl(ame_action_usages.end_date, ame_action_usages.start_date + ame_util.oneSecond)))
136: and p_effective_date between ame_actions.start_date
137: and nvl(ame_actions.end_date - ame_util.oneSecond, p_effective_date) ;
138: begin
139: -- Check the value of the config variable 'allowAllApproverTypes' and 'productionFunctionality'
133: or
134: (p_effective_date < ame_action_usages.start_date
135: and ame_action_usages.start_date < nvl(ame_action_usages.end_date, ame_action_usages.start_date + ame_util.oneSecond)))
136: and p_effective_date between ame_actions.start_date
137: and nvl(ame_actions.end_date - ame_util.oneSecond, p_effective_date) ;
138: begin
139: -- Check the value of the config variable 'allowAllApproverTypes' and 'productionFunctionality'
140: -- to ensure that rules of this type type can be defined for this transaction type.
141: --
139: -- Check the value of the config variable 'allowAllApproverTypes' and 'productionFunctionality'
140: -- to ensure that rules of this type type can be defined for this transaction type.
141: --
142: l_allowAllApproverTypes :=
143: ame_util.getConfigVar
144: (variableNameIn => ame_util.allowAllApproverTypesConfigVar
145: ,applicationIdIn => p_application_id);
146: l_allowProduction :=
147: ame_util.getConfigVar(variableNameIn => ame_util.productionConfigVar
140: -- to ensure that rules of this type type can be defined for this transaction type.
141: --
142: l_allowAllApproverTypes :=
143: ame_util.getConfigVar
144: (variableNameIn => ame_util.allowAllApproverTypesConfigVar
145: ,applicationIdIn => p_application_id);
146: l_allowProduction :=
147: ame_util.getConfigVar(variableNameIn => ame_util.productionConfigVar
148: ,applicationIdIn => p_application_id);
143: ame_util.getConfigVar
144: (variableNameIn => ame_util.allowAllApproverTypesConfigVar
145: ,applicationIdIn => p_application_id);
146: l_allowProduction :=
147: ame_util.getConfigVar(variableNameIn => ame_util.productionConfigVar
148: ,applicationIdIn => p_application_id);
149: -- get that rule type
150: select rule_type
151: into l_rule_type
151: into l_rule_type
152: from ame_rules
153: where rule_id =p_rule_id
154: and (p_effective_date between start_date
155: and nvl(end_date - ame_util.oneSecond, p_effective_date )
156: or
157: (p_effective_date < start_date
158: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
159: --+
154: and (p_effective_date between start_date
155: and nvl(end_date - ame_util.oneSecond, p_effective_date )
156: or
157: (p_effective_date < start_date
158: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
159: --+
160: -- Transform the configuration-variable value into one of the
161: -- pseudo-boolean values used by configuration variables,
162: -- for ease of use in the cursor.
160: -- Transform the configuration-variable value into one of the
161: -- pseudo-boolean values used by configuration variables,
162: -- for ease of use in the cursor.
163: --+
164: if l_allowAllApproverTypes = ame_util.no or
165: l_allowProduction in (ame_util.noProductions, ame_util.perApproverProductions) then
166: --+
167: -- fetch the action_type_id's associated with this rule
168: --+
161: -- pseudo-boolean values used by configuration variables,
162: -- for ease of use in the cursor.
163: --+
164: if l_allowAllApproverTypes = ame_util.no or
165: l_allowProduction in (ame_util.noProductions, ame_util.perApproverProductions) then
166: --+
167: -- fetch the action_type_id's associated with this rule
168: --+
169: open getActionTypeCursor;
183: close getActionTypeCursor;
184: --+
185: -- Check that the action types are allowed for this transaction_type
186: --+
187: if l_rule_type not in (ame_util.productionRuleType
188: ,ame_util.preListGroupRuleType
189: ,ame_util.postListGroupRuleType) then
190: if l_allowAllApproverTypes = ame_util.no then
191: -- check if the action types defined are allowed to use approver types
184: --+
185: -- Check that the action types are allowed for this transaction_type
186: --+
187: if l_rule_type not in (ame_util.productionRuleType
188: ,ame_util.preListGroupRuleType
189: ,ame_util.postListGroupRuleType) then
190: if l_allowAllApproverTypes = ame_util.no then
191: -- check if the action types defined are allowed to use approver types
192: -- other than ame_util.perOrigSystem and ame_util.fndUserOrigSystem.
185: -- Check that the action types are allowed for this transaction_type
186: --+
187: if l_rule_type not in (ame_util.productionRuleType
188: ,ame_util.preListGroupRuleType
189: ,ame_util.postListGroupRuleType) then
190: if l_allowAllApproverTypes = ame_util.no then
191: -- check if the action types defined are allowed to use approver types
192: -- other than ame_util.perOrigSystem and ame_util.fndUserOrigSystem.
193: for i in 1..actionTypeIds.count loop
186: --+
187: if l_rule_type not in (ame_util.productionRuleType
188: ,ame_util.preListGroupRuleType
189: ,ame_util.postListGroupRuleType) then
190: if l_allowAllApproverTypes = ame_util.no then
191: -- check if the action types defined are allowed to use approver types
192: -- other than ame_util.perOrigSystem and ame_util.fndUserOrigSystem.
193: for i in 1..actionTypeIds.count loop
194: select count(*)
188: ,ame_util.preListGroupRuleType
189: ,ame_util.postListGroupRuleType) then
190: if l_allowAllApproverTypes = ame_util.no then
191: -- check if the action types defined are allowed to use approver types
192: -- other than ame_util.perOrigSystem and ame_util.fndUserOrigSystem.
193: for i in 1..actionTypeIds.count loop
194: select count(*)
195: into l_count
196: from ame_approver_type_usages
196: from ame_approver_type_usages
197: where approver_type_id not in (
198: select approver_type_id
199: from ame_approver_types
200: where orig_system in (ame_util.perOrigSystem
201: ,ame_util.fndUserOrigSystem)
202: and sysdate between start_date
203: and nvl(end_date - ame_util.oneSecond, sysdate))
204: and action_type_id = actionTypeIds(i)
197: where approver_type_id not in (
198: select approver_type_id
199: from ame_approver_types
200: where orig_system in (ame_util.perOrigSystem
201: ,ame_util.fndUserOrigSystem)
202: and sysdate between start_date
203: and nvl(end_date - ame_util.oneSecond, sysdate))
204: and action_type_id = actionTypeIds(i)
205: and sysdate between start_date
199: from ame_approver_types
200: where orig_system in (ame_util.perOrigSystem
201: ,ame_util.fndUserOrigSystem)
202: and sysdate between start_date
203: and nvl(end_date - ame_util.oneSecond, sysdate))
204: and action_type_id = actionTypeIds(i)
205: and sysdate between start_date
206: and nvl(end_date - ame_util.oneSecond, sysdate);
207: if l_count <> 0 then
202: and sysdate between start_date
203: and nvl(end_date - ame_util.oneSecond, sysdate))
204: and action_type_id = actionTypeIds(i)
205: and sysdate between start_date
206: and nvl(end_date - ame_util.oneSecond, sysdate);
207: if l_count <> 0 then
208: return(false);
209: end if;
210: end loop;
209: end if;
210: end loop;
211: end if;
212: end if;
213: if l_allowProduction in (ame_util.noProductions
214: ,ame_util.perApproverProductions) then
215: if l_rule_type = ame_util.productionRuleType then
216: return(false);
217: end if;
210: end loop;
211: end if;
212: end if;
213: if l_allowProduction in (ame_util.noProductions
214: ,ame_util.perApproverProductions) then
215: if l_rule_type = ame_util.productionRuleType then
216: return(false);
217: end if;
218: -- If no productions then check that no production
211: end if;
212: end if;
213: if l_allowProduction in (ame_util.noProductions
214: ,ame_util.perApproverProductions) then
215: if l_rule_type = ame_util.productionRuleType then
216: return(false);
217: end if;
218: -- If no productions then check that no production
219: -- actions are defined for the rule.
216: return(false);
217: end if;
218: -- If no productions then check that no production
219: -- actions are defined for the rule.
220: if l_allowProduction = ame_util.noProductions then
221: for i in 1..actionTypeIds.count loop
222: select count(*)
223: into l_count
224: from ame_action_type_usages
221: for i in 1..actionTypeIds.count loop
222: select count(*)
223: into l_count
224: from ame_action_type_usages
225: where rule_type = ame_util.productionRuleType
226: and action_type_id = actionTypeIds(i)
227: and p_effective_date between start_date
228: and nvl(end_date - ame_util.oneSecond, p_effective_date);
229: if l_count <> 0 then
224: from ame_action_type_usages
225: where rule_type = ame_util.productionRuleType
226: and action_type_id = actionTypeIds(i)
227: and p_effective_date between start_date
228: and nvl(end_date - ame_util.oneSecond, p_effective_date);
229: if l_count <> 0 then
230: open getApplicationName(applicationIdIn => p_application_id);
231: fetch getApplicationName into applicationName;
232: close getApplicationName;
252: into p_rul_start_date
253: from ame_rule_usages
254: where rule_id = p_rule_id
255: and (sysdate between start_date
256: and nvl(end_date - ame_util.oneSecond, sysdate )
257: or
258: (sysdate < start_date
259: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
260: select max(end_date)
255: and (sysdate between start_date
256: and nvl(end_date - ame_util.oneSecond, sysdate )
257: or
258: (sysdate < start_date
259: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
260: select max(end_date)
261: into p_rul_end_date
262: from ame_rule_usages
263: where rule_id = p_rule_id
261: into p_rul_end_date
262: from ame_rule_usages
263: where rule_id = p_rule_id
264: and (sysdate between start_date
265: and nvl(end_date - ame_util.oneSecond, sysdate )
266: or
267: (sysdate < start_date
268: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
269: end fetchNewRuleDates2;
264: and (sysdate between start_date
265: and nvl(end_date - ame_util.oneSecond, sysdate )
266: or
267: (sysdate < start_date
268: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
269: end fetchNewRuleDates2;
270: --+
271: -- This is a private function which checks if the Rule start date and end date need to
272: -- be changed.
297: --+
298: --+
299: --+
300: procedure getConditionIds(ruleIdIn in integer,
301: conditionIdListOut out nocopy ame_util.idList) as
302: cursor conditionCursor(ruleIdIn in integer) is
303: select ame_conditions.condition_id condition_id
304: ,ame_conditions.condition_type condition_type
305: from ame_conditions
308: and ame_condition_usages.rule_id = ruleIdIn
309: and (ame_conditions.start_date <= sysdate
310: and (ame_conditions.end_date is null or sysdate < ame_conditions.end_date))
311: and ((sysdate between ame_condition_usages.start_date
312: and nvl(ame_condition_usages.end_date - ame_util.oneSecond, sysdate))
313: or
314: (sysdate < ame_condition_usages.start_date
315: and ame_condition_usages.start_date <
316: nvl(ame_condition_usages.end_date,
313: or
314: (sysdate < ame_condition_usages.start_date
315: and ame_condition_usages.start_date <
316: nvl(ame_condition_usages.end_date,
317: ame_condition_usages.start_date + ame_util.oneSecond)))
318: order by condition_type;
319: tempIndex integer;
320: begin
321: /*
328: conditionIdListOut(tempIndex) := tempCondition.condition_id;
329: tempIndex := tempIndex + 1;
330: end loop;
331: if(tempIndex = 1) then
332: conditionIdListOut := ame_util.emptyIdList;
333: end if;
334: exception
335: when others then
336: conditionIdListOut := ame_util.emptyIdList;
332: conditionIdListOut := ame_util.emptyIdList;
333: end if;
334: exception
335: when others then
336: conditionIdListOut := ame_util.emptyIdList;
337: end getConditionIds;
338: --+
339: --+
340: --+
338: --+
339: --+
340: --+
341: procedure getActionIds(ruleIdIn in integer,
342: actionIdListOut out nocopy ame_util.idList) as
343: cursor actionCursor(ruleIdIn in integer) is
344: select ame_action_usages.action_id
345: from ame_action_usages
346: where rule_id = ruleIdIn
344: select ame_action_usages.action_id
345: from ame_action_usages
346: where rule_id = ruleIdIn
347: and ((sysdate between ame_action_usages.start_date
348: and nvl(ame_action_usages.end_date - ame_util.oneSecond, sysdate))
349: or
350: (sysdate < ame_action_usages.start_date
351: and ame_action_usages.start_date <
352: nvl(ame_action_usages.end_date, ame_action_usages.start_date + ame_util.oneSecond)));
348: and nvl(ame_action_usages.end_date - ame_util.oneSecond, sysdate))
349: or
350: (sysdate < ame_action_usages.start_date
351: and ame_action_usages.start_date <
352: nvl(ame_action_usages.end_date, ame_action_usages.start_date + ame_util.oneSecond)));
353: actionId integer;
354: tempIndex integer;
355: begin
356: tempIndex := 1;
359: tempIndex := tempIndex + 1;
360: end loop;
361: exception
362: when others then
363: actionIdListOut := ame_util.emptyIdList;
364: end getActionIds;
365: --+
366: -- This is a private function which checks if a rule already exists with the same
367: -- combination of conditions and actions.
369: Function ruleExists(p_rule_id in number
370: ,p_rule_type in varchar2
371: ,p_item_class_id in number
372: ,p_effective_date in date
373: ,p_conditions_list in ame_util.idList
374: ,p_actions_list in ame_util.idList
375: ) return boolean as
376: cursor ruleIdCursor(typeIn in varchar2
377: ,itemClassIdIn in integer default null) is
370: ,p_rule_type in varchar2
371: ,p_item_class_id in number
372: ,p_effective_date in date
373: ,p_conditions_list in ame_util.idList
374: ,p_actions_list in ame_util.idList
375: ) return boolean as
376: cursor ruleIdCursor(typeIn in varchar2
377: ,itemClassIdIn in integer default null) is
378: select rule_id
379: from ame_rules
380: where rule_type = typeIn
381: and (item_class_id is null or item_class_id = itemClassIdIn)
382: and ((sysdate between start_date
383: and nvl(end_date - ame_util.oneSecond, sysdate))
384: or
385: (sysdate < start_date
386: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
387: actionIdList1 ame_util.idList;
382: and ((sysdate between start_date
383: and nvl(end_date - ame_util.oneSecond, sysdate))
384: or
385: (sysdate < start_date
386: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
387: actionIdList1 ame_util.idList;
388: actionIdList2 ame_util.idList;
389: actionIdMatch boolean;
390: conditionIdList1 ame_util.idList;
383: and nvl(end_date - ame_util.oneSecond, sysdate))
384: or
385: (sysdate < start_date
386: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
387: actionIdList1 ame_util.idList;
388: actionIdList2 ame_util.idList;
389: actionIdMatch boolean;
390: conditionIdList1 ame_util.idList;
391: conditionIdList2 ame_util.idList;
384: or
385: (sysdate < start_date
386: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
387: actionIdList1 ame_util.idList;
388: actionIdList2 ame_util.idList;
389: actionIdMatch boolean;
390: conditionIdList1 ame_util.idList;
391: conditionIdList2 ame_util.idList;
392: conditionIdMatch boolean;
386: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
387: actionIdList1 ame_util.idList;
388: actionIdList2 ame_util.idList;
389: actionIdMatch boolean;
390: conditionIdList1 ame_util.idList;
391: conditionIdList2 ame_util.idList;
392: conditionIdMatch boolean;
393: begin
394: for i in 1..p_conditions_list.count loop
387: actionIdList1 ame_util.idList;
388: actionIdList2 ame_util.idList;
389: actionIdMatch boolean;
390: conditionIdList1 ame_util.idList;
391: conditionIdList2 ame_util.idList;
392: conditionIdMatch boolean;
393: begin
394: for i in 1..p_conditions_list.count loop
395: conditionIdList1(i) := p_conditions_list(i);
394: for i in 1..p_conditions_list.count loop
395: conditionIdList1(i) := p_conditions_list(i);
396: end loop;
397: --+
398: ame_util.sortIdListInPlace(idListInOut => conditionIdList1);
399: for i in 1..p_actions_list.count loop
400: actionIdList1(i) := p_actions_list(i);
401: end loop;
402: --+
399: for i in 1..p_actions_list.count loop
400: actionIdList1(i) := p_actions_list(i);
401: end loop;
402: --+
403: ame_util.sortIdListInPlace(idListInOut => actionIdList1);
404: conditionIdMatch := false;
405: actionIdMatch := false;
406: for tempRuleId in ruleIdCursor(typeIn => p_rule_type
407: ,itemClassIdIn => p_item_class_id) loop
406: for tempRuleId in ruleIdCursor(typeIn => p_rule_type
407: ,itemClassIdIn => p_item_class_id) loop
408: getConditionIds(ruleIdIn => tempRuleId.rule_id,
409: conditionIdListOut => conditionIdList2);
410: ame_util.sortIdListInPlace(idListInOut => conditionIdList2);
411: if(ame_util.idListsMatch(idList1InOut => conditionIdList1
412: ,idList2InOut => conditionIdList2
413: ,sortList1In => false
414: ,sortList2In => false)) then
407: ,itemClassIdIn => p_item_class_id) loop
408: getConditionIds(ruleIdIn => tempRuleId.rule_id,
409: conditionIdListOut => conditionIdList2);
410: ame_util.sortIdListInPlace(idListInOut => conditionIdList2);
411: if(ame_util.idListsMatch(idList1InOut => conditionIdList1
412: ,idList2InOut => conditionIdList2
413: ,sortList1In => false
414: ,sortList2In => false)) then
415: conditionIdMatch := true;
416: end if;
417: if conditionIdMatch then
418: getActionIds(ruleIdIn => tempRuleId.rule_id
419: ,actionIdListOut => actionIdList2);
420: ame_util.sortIdListInPlace(idListInOut => actionIdList2);
421: if(ame_util.idListsMatch(idList1InOut => actionIdList1
422: ,idList2InOut => actionIdList2
423: ,sortList1In => false
424: ,sortList2In => false)) then
417: if conditionIdMatch then
418: getActionIds(ruleIdIn => tempRuleId.rule_id
419: ,actionIdListOut => actionIdList2);
420: ame_util.sortIdListInPlace(idListInOut => actionIdList2);
421: if(ame_util.idListsMatch(idList1InOut => actionIdList1
422: ,idList2InOut => actionIdList2
423: ,sortList1In => false
424: ,sortList2In => false)) then
425: actionIdMatch := true;
509: ,attribute_id
510: from ame_conditions
511: where condition_id = p_condition_id
512: and l_effective_date between start_date
513: and nvl(end_date - ame_util.oneSecond,l_effective_date);
514:
515: begin
516: hr_utility.set_location('Entering:'|| l_proc, 10);
517: --
532: --+ condition id cannot be null for LCE and LM/SUB rule.
533: --+
534: if p_condition_id is null then
535: --+
536: if p_rule_type = ame_util.exceptionRuleType then
537: fnd_message.set_name('PER','AME_400709_NO_EXC_COND_LCE_RUL');
538: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
539: end if;
540: --+
537: fnd_message.set_name('PER','AME_400709_NO_EXC_COND_LCE_RUL');
538: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
539: end if;
540: --+
541: if p_rule_type = ame_util.listModRuleType or p_rule_type = ame_util.substitutionRuleType then
542: fnd_message.set_name('PER','AME_400710_NO_LM_CON_LMSUB_RUL');
543: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
544: end if;
545: --+
570: end if;
571: --+
572: --+ Item class id should be null for LM Conditions
573: --+
574: if p_rule_type = 0 and l_condition_type = ame_util.listModConditionType then
575: l_item_class_id := null;
576: end if;
577: --+
578: end if;
616: else
617: l_rul_start_date := p_rul_start_date;
618: end if;
619: if p_rul_end_date is null then
620: l_rul_end_date := ame_utility_pkg.endOfTime;
621: else
622: l_rul_end_date := p_rul_end_date;
623: end if;
624:
661: -- c. Check that action_id is not null.
662: --
663: --+ Verify the Rule Type and Condition Type Combination.
664: --+
665: if p_rule_type = ame_util.exceptionRuleType then
666: if (getConditionType(p_condition_id => p_condition_id
667: ,p_effective_date => l_effective_date)
668: <> ame_util.exceptionConditionType) then
669: fnd_message.set_name('PER','AME_400709_NO_EXC_COND_LCE_RUL');
664: --+
665: if p_rule_type = ame_util.exceptionRuleType then
666: if (getConditionType(p_condition_id => p_condition_id
667: ,p_effective_date => l_effective_date)
668: <> ame_util.exceptionConditionType) then
669: fnd_message.set_name('PER','AME_400709_NO_EXC_COND_LCE_RUL');
670: hr_multi_message.add (p_associated_column1 =>'CONDITION_ID');
671: end if;
672: elsif (p_rule_type = ame_util.listModRuleType or
668: <> ame_util.exceptionConditionType) then
669: fnd_message.set_name('PER','AME_400709_NO_EXC_COND_LCE_RUL');
670: hr_multi_message.add (p_associated_column1 =>'CONDITION_ID');
671: end if;
672: elsif (p_rule_type = ame_util.listModRuleType or
673: p_rule_type = ame_util.substitutionRuleType) then
674: if ( getConditionType(p_condition_id => p_condition_id
675: ,p_effective_date => l_effective_date)
676: <> ame_util.listModConditionType) then
669: fnd_message.set_name('PER','AME_400709_NO_EXC_COND_LCE_RUL');
670: hr_multi_message.add (p_associated_column1 =>'CONDITION_ID');
671: end if;
672: elsif (p_rule_type = ame_util.listModRuleType or
673: p_rule_type = ame_util.substitutionRuleType) then
674: if ( getConditionType(p_condition_id => p_condition_id
675: ,p_effective_date => l_effective_date)
676: <> ame_util.listModConditionType) then
677: fnd_message.set_name('PER','AME_400710_NO_LM_CON_LMSUB_RUL');
672: elsif (p_rule_type = ame_util.listModRuleType or
673: p_rule_type = ame_util.substitutionRuleType) then
674: if ( getConditionType(p_condition_id => p_condition_id
675: ,p_effective_date => l_effective_date)
676: <> ame_util.listModConditionType) then
677: fnd_message.set_name('PER','AME_400710_NO_LM_CON_LMSUB_RUL');
678: hr_multi_message.add (p_associated_column1 => 'CONDITION_ID');
679: end if;
680: end if;
688: ame_rule_utility_pkg.checkActionId(p_action_id);
689: --+
690: --+ Check the action and condition combination for LM Rule.
691: --+
692: if p_rule_type = ame_util.listModRuleType then
693: ame_rule_utility_pkg.chk_LM_action_Condition(p_condition_id => p_condition_id
694: ,p_action_id => p_action_id
695: ,is_first_condition => true);
696: end if;
907: from ame_conditions
908: ,ame_condition_usages
909: where ame_condition_usages.rule_id = p_rule_id
910: and (l_effective_date between ame_condition_usages.start_date
911: and nvl(ame_condition_usages.end_date - ame_util.oneSecond, l_effective_date )
912: or
913: (l_effective_date < ame_condition_usages.start_date
914: and ame_condition_usages.start_date < nvl(ame_condition_usages.end_date,
915: ame_condition_usages.start_date + ame_util.oneSecond)))
911: and nvl(ame_condition_usages.end_date - ame_util.oneSecond, l_effective_date )
912: or
913: (l_effective_date < ame_condition_usages.start_date
914: and ame_condition_usages.start_date < nvl(ame_condition_usages.end_date,
915: ame_condition_usages.start_date + ame_util.oneSecond)))
916: and ame_condition_usages.condition_id = ame_conditions.condition_id
917: and l_effective_date between ame_conditions.start_date
918: and nvl(ame_conditions.end_date - ame_util.oneSecond, l_effective_date)
919: )
914: and ame_condition_usages.start_date < nvl(ame_condition_usages.end_date,
915: ame_condition_usages.start_date + ame_util.oneSecond)))
916: and ame_condition_usages.condition_id = ame_conditions.condition_id
917: and l_effective_date between ame_conditions.start_date
918: and nvl(ame_conditions.end_date - ame_util.oneSecond, l_effective_date)
919: )
920: and application_id = p_application_id
921: and l_effective_date between ame_attribute_usages.start_date
922: and nvl(ame_attribute_usages.end_date - ame_util.oneSecond, l_effective_date);
918: and nvl(ame_conditions.end_date - ame_util.oneSecond, l_effective_date)
919: )
920: and application_id = p_application_id
921: and l_effective_date between ame_attribute_usages.start_date
922: and nvl(ame_attribute_usages.end_date - ame_util.oneSecond, l_effective_date);
923: --+
924: cursor getAttributeUsages2(p_attribute_id in number) is
925: select attribute_id, use_count, start_date, end_date, object_version_number
926: from ame_attribute_usages
926: from ame_attribute_usages
927: where attribute_id = p_attribute_id
928: and application_id = p_application_id
929: and l_effective_date between start_date and
930: nvl(end_date - ame_util.oneSecond,l_effective_date);
931: --+
932: cursor getReqAttributes is
933: select man.attribute_id
934: from ame_mandatory_attributes man
936: ,ame_actions act
937: where man.action_type_id = act.action_type_id
938: and acu.action_id = act.action_id
939: and acu.rule_id = p_rule_id
940: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
941: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
942: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
943: or
944: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
937: where man.action_type_id = act.action_type_id
938: and acu.action_id = act.action_id
939: and acu.rule_id = p_rule_id
940: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
941: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
942: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
943: or
944: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
945: );
938: and acu.action_id = act.action_id
939: and acu.rule_id = p_rule_id
940: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
941: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
942: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
943: or
944: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
945: );
946: --+
940: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
941: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
942: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
943: or
944: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
945: );
946: --+
947: cursor getActions is
948: select action_id
951: ,object_version_number
952: from ame_action_usages
953: where rule_id = p_rule_id
954: and (l_effective_date between start_date
955: and nvl(end_date - ame_util.oneSecond,l_effective_date)
956: or
957: (l_effective_date < start_date and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
958: --+
959: cursor getConditions is
953: where rule_id = p_rule_id
954: and (l_effective_date between start_date
955: and nvl(end_date - ame_util.oneSecond,l_effective_date)
956: or
957: (l_effective_date < start_date and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
958: --+
959: cursor getConditions is
960: select condition_id
961: ,start_date
963: ,object_version_number
964: from ame_condition_usages
965: where rule_id = p_rule_id
966: and (l_effective_date between start_date
967: and nvl(end_date - ame_util.oneSecond, l_effective_date)
968: or
969: (l_effective_date < start_date and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
970: --+
971: cursor itemClassUsageCursor(p_application_id in number
965: where rule_id = p_rule_id
966: and (l_effective_date between start_date
967: and nvl(end_date - ame_util.oneSecond, l_effective_date)
968: or
969: (l_effective_date < start_date and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
970: --+
971: cursor itemClassUsageCursor(p_application_id in number
972: ,p_item_class_id in number
973: ,l_effective_date in date) is
975: from ame_item_class_usages
976: where application_id =p_application_id
977: and item_class_id = p_item_class_id
978: and l_effective_date between start_date
979: and nvl(end_date - ame_util.oneSecond, l_effective_date);
980: l_rul_object_version_number number;
981: l_rule_id number;
982: l_rule_type ame_rules.rule_type%type;
983: l_item_class_id number;
1098: ,l_rul_object_version_number
1099: from ame_rules
1100: where rule_id = p_rule_id
1101: and ((l_effective_date between start_date
1102: and nvl(end_date - ame_util.oneSecond, l_effective_date))
1103: or
1104: (l_effective_date < start_date
1105: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
1106: if l_item_class_id is not null then
1101: and ((l_effective_date between start_date
1102: and nvl(end_date - ame_util.oneSecond, l_effective_date))
1103: or
1104: (l_effective_date < start_date
1105: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
1106: if l_item_class_id is not null then
1107: -- check item class is valid
1108: open itemClassUsageCursor(p_application_id => p_application_id
1109: ,p_item_class_id => l_item_class_id
1117: --
1118: -- Check the value of the config variable 'allowAllItemClassRules' to ensure that rules for this
1119: -- item class can be defined for this application id.
1120: --
1121: l_variable_value := ame_util.getConfigVar
1122: (variableNameIn => ame_util.allowAllICRulesConfigVar
1123: ,applicationIdIn => p_application_id);
1124: if l_variable_value = ame_util.no then
1125: -- check that the rule item class is header
1118: -- Check the value of the config variable 'allowAllItemClassRules' to ensure that rules for this
1119: -- item class can be defined for this application id.
1120: --
1121: l_variable_value := ame_util.getConfigVar
1122: (variableNameIn => ame_util.allowAllICRulesConfigVar
1123: ,applicationIdIn => p_application_id);
1124: if l_variable_value = ame_util.no then
1125: -- check that the rule item class is header
1126: select name
1120: --
1121: l_variable_value := ame_util.getConfigVar
1122: (variableNameIn => ame_util.allowAllICRulesConfigVar
1123: ,applicationIdIn => p_application_id);
1124: if l_variable_value = ame_util.no then
1125: -- check that the rule item class is header
1126: select name
1127: into l_item_class_name
1128: from ame_item_classes
1127: into l_item_class_name
1128: from ame_item_classes
1129: where item_class_id = l_item_class_id
1130: and l_effective_date between start_date
1131: and nvl(end_date - ame_util.oneSecond, l_effective_date);
1132: if l_item_class_name not in (ame_util.headerItemClassName
1133: ,ame_util.lineItemItemClassName) then
1134: fnd_message.set_name('PER','AME_400743_ITC_NOT_ALLOWED');
1135: hr_multi_message.add(p_associated_column1 => 'RULE_ID');
1128: from ame_item_classes
1129: where item_class_id = l_item_class_id
1130: and l_effective_date between start_date
1131: and nvl(end_date - ame_util.oneSecond, l_effective_date);
1132: if l_item_class_name not in (ame_util.headerItemClassName
1133: ,ame_util.lineItemItemClassName) then
1134: fnd_message.set_name('PER','AME_400743_ITC_NOT_ALLOWED');
1135: hr_multi_message.add(p_associated_column1 => 'RULE_ID');
1136: end if;
1129: where item_class_id = l_item_class_id
1130: and l_effective_date between start_date
1131: and nvl(end_date - ame_util.oneSecond, l_effective_date);
1132: if l_item_class_name not in (ame_util.headerItemClassName
1133: ,ame_util.lineItemItemClassName) then
1134: fnd_message.set_name('PER','AME_400743_ITC_NOT_ALLOWED');
1135: hr_multi_message.add(p_associated_column1 => 'RULE_ID');
1136: end if;
1137: end if;
1140: -- Check the value of the config variable 'allowAllApproverTypes' and 'productionFunctionality'
1141: -- to ensure that rules of this type type can be defined for this transaction type.
1142: --
1143: /*
1144: if l_rule_type not in (ame_util.substitutionRuleType) then
1145: if not checkRuleAllowed(p_application_id => p_application_id
1146: ,p_rule_id => p_rule_id
1147: ,p_effective_date => l_effective_date) then
1148: fnd_message.set_name('PER','AME_99999_RU_NOT_ALLOWED');
1154: --
1155: -- Check the value of the config variable 'allowFyiNotifications'
1156: -- to ensure that rules of this approver category are allowed.
1157: --
1158: if p_approver_category = ame_util.fyiApproverCategory then
1159: if (ame_util.getConfigVar(variableNameIn => ame_util.allowFyiNotificationsConfigVar
1160: ,applicationIdIn => p_application_id) = ame_util.no ) then
1161: fnd_message.set_name('PER','AME_400742_FYI_CAT_NO_ALLOWED');
1162: hr_multi_message.add(p_associated_column1 => 'APPROVER_CATEGORY');
1155: -- Check the value of the config variable 'allowFyiNotifications'
1156: -- to ensure that rules of this approver category are allowed.
1157: --
1158: if p_approver_category = ame_util.fyiApproverCategory then
1159: if (ame_util.getConfigVar(variableNameIn => ame_util.allowFyiNotificationsConfigVar
1160: ,applicationIdIn => p_application_id) = ame_util.no ) then
1161: fnd_message.set_name('PER','AME_400742_FYI_CAT_NO_ALLOWED');
1162: hr_multi_message.add(p_associated_column1 => 'APPROVER_CATEGORY');
1163: end if;
1156: -- to ensure that rules of this approver category are allowed.
1157: --
1158: if p_approver_category = ame_util.fyiApproverCategory then
1159: if (ame_util.getConfigVar(variableNameIn => ame_util.allowFyiNotificationsConfigVar
1160: ,applicationIdIn => p_application_id) = ame_util.no ) then
1161: fnd_message.set_name('PER','AME_400742_FYI_CAT_NO_ALLOWED');
1162: hr_multi_message.add(p_associated_column1 => 'APPROVER_CATEGORY');
1163: end if;
1164: end if;
1163: end if;
1164: end if;
1165: l_approver_category := p_approver_category;
1166: if not l_swi_call then
1167: if(l_rule_type not in (ame_util.listModRuleType
1168: ,ame_util.substitutionRuleType
1169: ,ame_util.productionRuleType
1170: ,ame_util.combinationRuleType)) then
1171: if l_approver_category is null then
1164: end if;
1165: l_approver_category := p_approver_category;
1166: if not l_swi_call then
1167: if(l_rule_type not in (ame_util.listModRuleType
1168: ,ame_util.substitutionRuleType
1169: ,ame_util.productionRuleType
1170: ,ame_util.combinationRuleType)) then
1171: if l_approver_category is null then
1172: l_approver_category := ame_util.approvalApproverCategory;
1165: l_approver_category := p_approver_category;
1166: if not l_swi_call then
1167: if(l_rule_type not in (ame_util.listModRuleType
1168: ,ame_util.substitutionRuleType
1169: ,ame_util.productionRuleType
1170: ,ame_util.combinationRuleType)) then
1171: if l_approver_category is null then
1172: l_approver_category := ame_util.approvalApproverCategory;
1173: end if;
1166: if not l_swi_call then
1167: if(l_rule_type not in (ame_util.listModRuleType
1168: ,ame_util.substitutionRuleType
1169: ,ame_util.productionRuleType
1170: ,ame_util.combinationRuleType)) then
1171: if l_approver_category is null then
1172: l_approver_category := ame_util.approvalApproverCategory;
1173: end if;
1174: elsif l_rule_type = ame_util.combinationRuleType and not ame_rule_utility_pkg.is_LM_comb_rule(p_rule_id) then
1168: ,ame_util.substitutionRuleType
1169: ,ame_util.productionRuleType
1170: ,ame_util.combinationRuleType)) then
1171: if l_approver_category is null then
1172: l_approver_category := ame_util.approvalApproverCategory;
1173: end if;
1174: elsif l_rule_type = ame_util.combinationRuleType and not ame_rule_utility_pkg.is_LM_comb_rule(p_rule_id) then
1175: if l_approver_category is null then
1176: l_approver_category := ame_util.approvalApproverCategory;
1170: ,ame_util.combinationRuleType)) then
1171: if l_approver_category is null then
1172: l_approver_category := ame_util.approvalApproverCategory;
1173: end if;
1174: elsif l_rule_type = ame_util.combinationRuleType and not ame_rule_utility_pkg.is_LM_comb_rule(p_rule_id) then
1175: if l_approver_category is null then
1176: l_approver_category := ame_util.approvalApproverCategory;
1177: end if;
1178: elsif l_approver_category is not null then
1172: l_approver_category := ame_util.approvalApproverCategory;
1173: end if;
1174: elsif l_rule_type = ame_util.combinationRuleType and not ame_rule_utility_pkg.is_LM_comb_rule(p_rule_id) then
1175: if l_approver_category is null then
1176: l_approver_category := ame_util.approvalApproverCategory;
1177: end if;
1178: elsif l_approver_category is not null then
1179: fnd_message.set_name('PER','AME_400744_APPR_CAT_NOT_NULL');
1180: hr_multi_message.add(p_associated_column1 => 'APPROVER_CATEGORY');
1183:
1184: --
1185: -- Check that priority is defined, if enabled for this rule type for this transaction type
1186: --
1187: l_variable_value := ame_util.getConfigVar(
1188: variableNameIn => ame_util.rulePriorityModesConfigVar
1189: ,applicationIdIn => p_application_id);
1190: if(l_rule_type = ame_util.combinationRuleType) then
1191: priority := substrb(l_variable_value, 1, (instr(l_variable_value,':',1,1) -1));
1184: --
1185: -- Check that priority is defined, if enabled for this rule type for this transaction type
1186: --
1187: l_variable_value := ame_util.getConfigVar(
1188: variableNameIn => ame_util.rulePriorityModesConfigVar
1189: ,applicationIdIn => p_application_id);
1190: if(l_rule_type = ame_util.combinationRuleType) then
1191: priority := substrb(l_variable_value, 1, (instr(l_variable_value,':',1,1) -1));
1192: elsif(l_rule_type = ame_util.authorityRuleType) then
1186: --
1187: l_variable_value := ame_util.getConfigVar(
1188: variableNameIn => ame_util.rulePriorityModesConfigVar
1189: ,applicationIdIn => p_application_id);
1190: if(l_rule_type = ame_util.combinationRuleType) then
1191: priority := substrb(l_variable_value, 1, (instr(l_variable_value,':',1,1) -1));
1192: elsif(l_rule_type = ame_util.authorityRuleType) then
1193: priority := substrb(l_variable_value,
1194: (instr(l_variable_value,':',1,1) +1),
1188: variableNameIn => ame_util.rulePriorityModesConfigVar
1189: ,applicationIdIn => p_application_id);
1190: if(l_rule_type = ame_util.combinationRuleType) then
1191: priority := substrb(l_variable_value, 1, (instr(l_variable_value,':',1,1) -1));
1192: elsif(l_rule_type = ame_util.authorityRuleType) then
1193: priority := substrb(l_variable_value,
1194: (instr(l_variable_value,':',1,1) +1),
1195: (instr(l_variable_value,':',1,2) -
1196: (instr(l_variable_value,':',1,1) +1)));
1193: priority := substrb(l_variable_value,
1194: (instr(l_variable_value,':',1,1) +1),
1195: (instr(l_variable_value,':',1,2) -
1196: (instr(l_variable_value,':',1,1) +1)));
1197: elsif(l_rule_type = ame_util.exceptionRuleType) then
1198: priority := substrb(l_variable_value,
1199: (instr(l_variable_value,':',1,2) +1),
1200: (instr(l_variable_value,':',1,3) -
1201: (instr(l_variable_value,':',1,2) +1)));
1198: priority := substrb(l_variable_value,
1199: (instr(l_variable_value,':',1,2) +1),
1200: (instr(l_variable_value,':',1,3) -
1201: (instr(l_variable_value,':',1,2) +1)));
1202: elsif(l_rule_type = ame_util.listModRuleType) then
1203: priority := substrb(l_variable_value,
1204: (instr(l_variable_value,':',1,3) +1),
1205: (instr(l_variable_value,':',1,4) -
1206: (instr(l_variable_value,':',1,3) +1)));
1203: priority := substrb(l_variable_value,
1204: (instr(l_variable_value,':',1,3) +1),
1205: (instr(l_variable_value,':',1,4) -
1206: (instr(l_variable_value,':',1,3) +1)));
1207: elsif(l_rule_type = ame_util.substitutionRuleType) then
1208: priority := substrb(l_variable_value,
1209: (instr(l_variable_value,':',1,4) +1),
1210: (instr(l_variable_value,':',1,5) -
1211: (instr(l_variable_value,':',1,4) +1)));
1208: priority := substrb(l_variable_value,
1209: (instr(l_variable_value,':',1,4) +1),
1210: (instr(l_variable_value,':',1,5) -
1211: (instr(l_variable_value,':',1,4) +1)));
1212: elsif(l_rule_type = ame_util.preListGroupRuleType) then
1213: priority := substrb(l_variable_value,
1214: (instr(l_variable_value,':',1,5) +1),
1215: (instr(l_variable_value,':',1,6) -
1216: (instr(l_variable_value,':',1,5) +1)));
1213: priority := substrb(l_variable_value,
1214: (instr(l_variable_value,':',1,5) +1),
1215: (instr(l_variable_value,':',1,6) -
1216: (instr(l_variable_value,':',1,5) +1)));
1217: elsif(l_rule_type = ame_util.postListGroupRuleType) then
1218: priority := substrb(l_variable_value,
1219: (instr(l_variable_value,':',1,6) +1),
1220: (instr(l_variable_value,':',1,7) -
1221: (instr(l_variable_value,':',1,6) +1)));
1218: priority := substrb(l_variable_value,
1219: (instr(l_variable_value,':',1,6) +1),
1220: (instr(l_variable_value,':',1,7) -
1221: (instr(l_variable_value,':',1,6) +1)));
1222: elsif(l_rule_type = ame_util.productionRuleType) then
1223: priority := substrb(l_variable_value,
1224: (instr(l_variable_value,':',1,7) +1));
1225: end if;
1226: if(priority <> ame_util.disabledRulePriority and p_priority is null) then
1222: elsif(l_rule_type = ame_util.productionRuleType) then
1223: priority := substrb(l_variable_value,
1224: (instr(l_variable_value,':',1,7) +1));
1225: end if;
1226: if(priority <> ame_util.disabledRulePriority and p_priority is null) then
1227: fnd_message.set_name('PER','AME_400707_INVALID_PRIORITY');
1228: hr_multi_message.add(p_associated_column1 => 'PRIORITY');
1229: end if;
1230: --
1250: if l_rlu_start_date is null then
1251: l_rlu_start_date := l_effective_date;
1252: end if;
1253: if l_rlu_end_date is null then
1254: l_rlu_end_date := ame_utility_pkg.endOfTime;
1255: else
1256: l_rlu_end_date := trunc(l_rlu_end_date);
1257: end if;
1258: ame_rlu_ins.ins(p_rule_id => p_rule_id
1437: ,attribute_id
1438: from ame_conditions
1439: where condition_id = p_condition_id
1440: and l_effective_date between start_date
1441: and nvl(end_date - ame_util.oneSecond,l_effective_date);
1442: cursor getRuleDetails is
1443: select rule_type
1444: ,start_date
1445: ,end_date
1446: ,item_class_id
1447: from ame_rules
1448: where rule_id = p_rule_id
1449: and (l_effective_date between start_date
1450: and nvl(end_date - ame_util.oneSecond,l_effective_date) or
1451: (l_effective_date < start_date
1452: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
1453: cursor getApplications is
1454: select item_id
1448: where rule_id = p_rule_id
1449: and (l_effective_date between start_date
1450: and nvl(end_date - ame_util.oneSecond,l_effective_date) or
1451: (l_effective_date < start_date
1452: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
1453: cursor getApplications is
1454: select item_id
1455: from ame_rule_usages
1456: where rule_id = p_rule_id
1454: select item_id
1455: from ame_rule_usages
1456: where rule_id = p_rule_id
1457: and (l_effective_date between start_date
1458: and nvl(end_date - ame_util.oneSecond,l_effective_date ) or
1459: (l_effective_date < start_date
1460: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
1461: cursor getAttributeUsages(p_application_id in integer) is
1462: select use_count
1456: where rule_id = p_rule_id
1457: and (l_effective_date between start_date
1458: and nvl(end_date - ame_util.oneSecond,l_effective_date ) or
1459: (l_effective_date < start_date
1460: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
1461: cursor getAttributeUsages(p_application_id in integer) is
1462: select use_count
1463: ,start_date
1464: ,end_date
1465: ,object_version_number
1466: from ame_attribute_usages
1467: where attribute_id = l_attribute_id
1468: and l_effective_date between start_date
1469: and nvl(end_date - ame_util.oneSecond,l_effective_date )
1470: and application_id = p_application_id;
1471: cursor getApplicationName(applicationIdIn in integer)is
1472: select application_name
1473: from ame_calling_apps
1498: l_cnu_object_version_number number;
1499: l_cnu_start_date date;
1500: l_cnu_end_date date;
1501: l_use_count number := 0;
1502: actionIdList ame_util.idList;
1503: conditionIdList ame_util.idList;
1504: applicationName ame_calling_apps.application_name%type;
1505: attributeName ame_attributes.name%type;
1506: appIdList ame_util.idList;
1499: l_cnu_start_date date;
1500: l_cnu_end_date date;
1501: l_use_count number := 0;
1502: actionIdList ame_util.idList;
1503: conditionIdList ame_util.idList;
1504: applicationName ame_calling_apps.application_name%type;
1505: attributeName ame_attributes.name%type;
1506: appIdList ame_util.idList;
1507: lm_count number;
1502: actionIdList ame_util.idList;
1503: conditionIdList ame_util.idList;
1504: applicationName ame_calling_apps.application_name%type;
1505: attributeName ame_attributes.name%type;
1506: appIdList ame_util.idList;
1507: lm_count number;
1508: begin
1509: hr_utility.set_location('Entering:'|| l_proc, 10);
1510: --
1594: -- List Modification Rule Y N Y
1595: -- Substitution Rule Y N Y
1596: -- Production Rule Y N N
1597: --+
1598: if l_condition_type = ame_util.exceptionConditionType then
1599: if l_rule_type <> ame_util.exceptionRuleType then
1600: fnd_message.set_name('PER','AME_400726_NO_EXC_CON_IN_RULE');
1601: hr_multi_message.add(p_associated_column1 =>'CONDITION_ID');
1602: end if;
1595: -- Substitution Rule Y N Y
1596: -- Production Rule Y N N
1597: --+
1598: if l_condition_type = ame_util.exceptionConditionType then
1599: if l_rule_type <> ame_util.exceptionRuleType then
1600: fnd_message.set_name('PER','AME_400726_NO_EXC_CON_IN_RULE');
1601: hr_multi_message.add(p_associated_column1 =>'CONDITION_ID');
1602: end if;
1603: elsif l_condition_type = ame_util.listModConditionType then
1599: if l_rule_type <> ame_util.exceptionRuleType then
1600: fnd_message.set_name('PER','AME_400726_NO_EXC_CON_IN_RULE');
1601: hr_multi_message.add(p_associated_column1 =>'CONDITION_ID');
1602: end if;
1603: elsif l_condition_type = ame_util.listModConditionType then
1604: if l_rule_type not in (ame_util.listModRuleType
1605: ,ame_util.substitutionRuleType
1606: ,ame_util.combinationRuleType) then
1607: fnd_message.set_name('PER','AME_400727_NO_LM_CON_IN_RULE');
1600: fnd_message.set_name('PER','AME_400726_NO_EXC_CON_IN_RULE');
1601: hr_multi_message.add(p_associated_column1 =>'CONDITION_ID');
1602: end if;
1603: elsif l_condition_type = ame_util.listModConditionType then
1604: if l_rule_type not in (ame_util.listModRuleType
1605: ,ame_util.substitutionRuleType
1606: ,ame_util.combinationRuleType) then
1607: fnd_message.set_name('PER','AME_400727_NO_LM_CON_IN_RULE');
1608: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
1601: hr_multi_message.add(p_associated_column1 =>'CONDITION_ID');
1602: end if;
1603: elsif l_condition_type = ame_util.listModConditionType then
1604: if l_rule_type not in (ame_util.listModRuleType
1605: ,ame_util.substitutionRuleType
1606: ,ame_util.combinationRuleType) then
1607: fnd_message.set_name('PER','AME_400727_NO_LM_CON_IN_RULE');
1608: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
1609: if ame_rule_utility_pkg.rule_conditions_count(p_rule_id => p_rule_id) > 0 then
1602: end if;
1603: elsif l_condition_type = ame_util.listModConditionType then
1604: if l_rule_type not in (ame_util.listModRuleType
1605: ,ame_util.substitutionRuleType
1606: ,ame_util.combinationRuleType) then
1607: fnd_message.set_name('PER','AME_400727_NO_LM_CON_IN_RULE');
1608: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
1609: if ame_rule_utility_pkg.rule_conditions_count(p_rule_id => p_rule_id) > 0 then
1610: fnd_message.set_name('PER','AME_400733_EXTRA_LM_CON');
1641: or
1642: (sysdate < cnu.start_date and cnu.start_date < nvl(cnu.end_date, cnu.start_date + (1/86400)))
1643: );
1644: if lm_count > 0 then
1645: if(l_rule_type in(ame_util.listModRuleType
1646: ,ame_util.substitutionRuleType
1647: ,ame_util.combinationRuleType)
1648: and l_condition_type = ame_util.listModConditionType) then
1649: fnd_message.set_name('PER','AME_400385_RULE_LM');
1642: (sysdate < cnu.start_date and cnu.start_date < nvl(cnu.end_date, cnu.start_date + (1/86400)))
1643: );
1644: if lm_count > 0 then
1645: if(l_rule_type in(ame_util.listModRuleType
1646: ,ame_util.substitutionRuleType
1647: ,ame_util.combinationRuleType)
1648: and l_condition_type = ame_util.listModConditionType) then
1649: fnd_message.set_name('PER','AME_400385_RULE_LM');
1650: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
1643: );
1644: if lm_count > 0 then
1645: if(l_rule_type in(ame_util.listModRuleType
1646: ,ame_util.substitutionRuleType
1647: ,ame_util.combinationRuleType)
1648: and l_condition_type = ame_util.listModConditionType) then
1649: fnd_message.set_name('PER','AME_400385_RULE_LM');
1650: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
1651: end if;
1644: if lm_count > 0 then
1645: if(l_rule_type in(ame_util.listModRuleType
1646: ,ame_util.substitutionRuleType
1647: ,ame_util.combinationRuleType)
1648: and l_condition_type = ame_util.listModConditionType) then
1649: fnd_message.set_name('PER','AME_400385_RULE_LM');
1650: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
1651: end if;
1652: end if;
1710: -- check that an attribute usage exists for the attribute this condition is based on
1711: -- for all the transaction type's using this rule.
1712: -- Update the attribute usage counts
1713: --+
1714: if l_condition_type <> ame_util.listModConditionType then
1715: for tempApplications in getApplications loop
1716: l_application_id := tempApplications.item_id;
1717: open getAttributeUsages(p_application_id => l_application_id) ;
1718: fetch getAttributeUsages
1829: from ame_action_type_usages aatu
1830: ,ame_actions aa
1831: where aa.action_id = p_action_id
1832: and l_effective_date between aa.start_date
1833: and nvl(aa.end_date - ame_util.oneSecond, l_effective_date)
1834: and aa.action_type_id = aatu.action_type_id
1835: and l_effective_date between aatu.start_date
1836: and nvl(aatu.end_date - ame_util.oneSecond, l_effective_date);
1837: --+
1832: and l_effective_date between aa.start_date
1833: and nvl(aa.end_date - ame_util.oneSecond, l_effective_date)
1834: and aa.action_type_id = aatu.action_type_id
1835: and l_effective_date between aatu.start_date
1836: and nvl(aatu.end_date - ame_util.oneSecond, l_effective_date);
1837: --+
1838: cursor getRuleDetails is
1839: select rule_type, start_date, end_date, item_class_id
1840: from ame_rules
1839: select rule_type, start_date, end_date, item_class_id
1840: from ame_rules
1841: where rule_id = p_rule_id
1842: and ( l_effective_date between start_date and
1843: nvl(end_date - ame_util.oneSecond,l_effective_date ) or
1844: (l_effective_date < start_date and
1845: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
1846: --+
1847: cursor getReqAttributes(p_application_id in integer
1841: where rule_id = p_rule_id
1842: and ( l_effective_date between start_date and
1843: nvl(end_date - ame_util.oneSecond,l_effective_date ) or
1844: (l_effective_date < start_date and
1845: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
1846: --+
1847: cursor getReqAttributes(p_application_id in integer
1848: ,p_action_type_id in integer) is
1849: select attribute_id
1851: where ama.attribute_id not in (select attribute_id
1852: from ame_attribute_usages
1853: where application_id = p_application_id
1854: and l_effective_date between start_date
1855: and nvl(end_date - ame_util.oneSecond, l_effective_date))
1856: and l_effective_date between ama.start_date
1857: and nvl(ama.end_date - ame_util.oneSecond, l_effective_date)
1858: and action_type_id = p_action_type_id;
1859: --+
1853: where application_id = p_application_id
1854: and l_effective_date between start_date
1855: and nvl(end_date - ame_util.oneSecond, l_effective_date))
1856: and l_effective_date between ama.start_date
1857: and nvl(ama.end_date - ame_util.oneSecond, l_effective_date)
1858: and action_type_id = p_action_type_id;
1859: --+
1860: cursor getReqAttributeIds(actionIdIn in integer
1861: ,ruleIdIn in integer) is
1866: where man.action_type_id = act.action_type_id
1867: and acu.action_id = act.action_id
1868: and acu.action_id = actionIdIn
1869: and acu.rule_id = ruleIdIn
1870: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
1871: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
1872: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
1873: or
1874: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
1867: and acu.action_id = act.action_id
1868: and acu.action_id = actionIdIn
1869: and acu.rule_id = ruleIdIn
1870: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
1871: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
1872: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
1873: or
1874: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
1875: );
1868: and acu.action_id = actionIdIn
1869: and acu.rule_id = ruleIdIn
1870: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
1871: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
1872: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
1873: or
1874: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
1875: );
1876: --+
1870: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
1871: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
1872: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
1873: or
1874: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
1875: );
1876: --+
1877: cursor getApplications(ruleIdIn in integer)is
1878: select item_id
1878: select item_id
1879: from ame_rule_usages
1880: where rule_id = ruleIdIn
1881: and (l_effective_date between start_date
1882: and nvl(end_date - ame_util.oneSecond, l_effective_date)
1883: or
1884: (l_effective_date < start_date
1885: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
1886: --+
1881: and (l_effective_date between start_date
1882: and nvl(end_date - ame_util.oneSecond, l_effective_date)
1883: or
1884: (l_effective_date < start_date
1885: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
1886: --+
1887: cursor getAttributeUsages(attributeIdIn in integer
1888: ,applicationIdIn in integer) is
1889: select application_id
1894: from ame_attribute_usages
1895: where attribute_id = attributeIdIn
1896: and application_id = applicationIdIn
1897: and l_effective_date between start_date
1898: and nvl(end_date - ame_util.oneSecond,l_effective_date);
1899: --+
1900: cursor getApplicationIds(p_rule_id in integer) is
1901: select distinct item_id
1902: from ame_rule_usages
1922: l_acu_object_version_number number;
1923: l_acu_start_date date;
1924: l_acu_end_date date;
1925: l_swi_package_name varchar2(30) := 'AME_RULE_SWI';
1926: actionIdList ame_util.idList;
1927: conditionIdList ame_util.idList;
1928: appIdList ame_util.idList;
1929: l_result number(2);
1930: l_head_item_class_id ame_item_classes.item_class_id%type;
1923: l_acu_start_date date;
1924: l_acu_end_date date;
1925: l_swi_package_name varchar2(30) := 'AME_RULE_SWI';
1926: actionIdList ame_util.idList;
1927: conditionIdList ame_util.idList;
1928: appIdList ame_util.idList;
1929: l_result number(2);
1930: l_head_item_class_id ame_item_classes.item_class_id%type;
1931: l_aty_name ame_action_types.name%type;
1924: l_acu_end_date date;
1925: l_swi_package_name varchar2(30) := 'AME_RULE_SWI';
1926: actionIdList ame_util.idList;
1927: conditionIdList ame_util.idList;
1928: appIdList ame_util.idList;
1929: l_result number(2);
1930: l_head_item_class_id ame_item_classes.item_class_id%type;
1931: l_aty_name ame_action_types.name%type;
1932: l_swi_call boolean;
2051: ,p_allow_production_action => true) then
2052: fnd_message.set_name('PER','AME_400741_RULE_TYPE_MISMATCH');
2053: hr_multi_message.add(p_associated_column1 => 'RULE_TYPE');
2054: end if;
2055: if l_rule_type = ame_util.listModRuleType then
2056: if not ame_rule_utility_pkg.chk_lm_actions(p_rule_id => p_rule_id
2057: ,p_action_id => p_action_id) then
2058: fnd_message.set_name('PER','AME_400425_RULE_LM_RULE');
2059: hr_multi_message.add(p_associated_column1 => 'ACTION_ID');
2411: ,end_date
2412: ,object_version_number
2413: from ame_rules
2414: where rule_id = p_rule_id
2415: and ((l_effective_date between start_date and nvl(end_date - ame_util.oneSecond, l_effective_date))
2416: or
2417: (l_effective_date < start_date and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2418: --+
2419: cursor getActions is
2413: from ame_rules
2414: where rule_id = p_rule_id
2415: and ((l_effective_date between start_date and nvl(end_date - ame_util.oneSecond, l_effective_date))
2416: or
2417: (l_effective_date < start_date and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2418: --+
2419: cursor getActions is
2420: select action_id
2421: ,start_date
2423: ,object_version_number
2424: from ame_action_usages
2425: where rule_id = p_rule_id
2426: and ((l_effective_date between start_date
2427: and nvl(end_date - ame_util.oneSecond, l_effective_date))
2428: or
2429: (l_effective_date < start_date
2430: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
2431: --+
2426: and ((l_effective_date between start_date
2427: and nvl(end_date - ame_util.oneSecond, l_effective_date))
2428: or
2429: (l_effective_date < start_date
2430: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
2431: --+
2432: cursor getConditions is
2433: select condition_id
2434: ,start_date
2436: ,object_version_number
2437: from ame_condition_usages
2438: where rule_id = p_rule_id
2439: and ((l_effective_date between start_date
2440: and nvl(end_date - ame_util.oneSecond, l_effective_date))
2441: or
2442: (l_effective_date < start_date
2443: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
2444: begin
2439: and ((l_effective_date between start_date
2440: and nvl(end_date - ame_util.oneSecond, l_effective_date))
2441: or
2442: (l_effective_date < start_date
2443: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
2444: begin
2445: hr_utility.set_location('Entering:'|| l_proc, 10);
2446:
2447: if(p_end_date is not null and TRUNC(p_end_date) = TRUNC(SYSDATE)) then
2719: select action_id, start_date, end_date, object_version_number
2720: from ame_action_usages
2721: where rule_id = p_rule_id
2722: and ( l_effective_date between start_date and
2723: nvl(end_date - ame_util.oneSecond,l_effective_date ) or
2724: (l_effective_date < start_date and
2725: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2726: --+
2727: --+
2721: where rule_id = p_rule_id
2722: and ( l_effective_date between start_date and
2723: nvl(end_date - ame_util.oneSecond,l_effective_date ) or
2724: (l_effective_date < start_date and
2725: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2726: --+
2727: --+
2728: cursor getRuleDetails is
2729: select start_date
2730: ,end_date
2731: ,object_version_number
2732: from ame_rules
2733: where rule_id = p_rule_id
2734: and ((l_effective_date between start_date and nvl(end_date - ame_util.oneSecond, l_effective_date))
2735: or
2736: (l_effective_date < start_date and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2737: --+
2738: cursor getConditions is
2732: from ame_rules
2733: where rule_id = p_rule_id
2734: and ((l_effective_date between start_date and nvl(end_date - ame_util.oneSecond, l_effective_date))
2735: or
2736: (l_effective_date < start_date and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2737: --+
2738: cursor getConditions is
2739: select condition_id
2740: ,start_date
2742: ,object_version_number
2743: from ame_condition_usages
2744: where rule_id = p_rule_id
2745: and ((l_effective_date between start_date
2746: and nvl(end_date - ame_util.oneSecond,l_effective_date))
2747: or
2748: (l_effective_date < start_date
2749: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2750: --+
2745: and ((l_effective_date between start_date
2746: and nvl(end_date - ame_util.oneSecond,l_effective_date))
2747: or
2748: (l_effective_date < start_date
2749: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2750: --+
2751: cursor getRuleConditions is
2752: select ame_conditions.attribute_id attribute_id
2753: from ame_conditions
2753: from ame_conditions
2754: ,ame_condition_usages
2755: where ame_condition_usages.rule_id = p_rule_id
2756: and (l_effective_date between ame_condition_usages.start_date
2757: and nvl(ame_condition_usages.end_date - ame_util.oneSecond, l_effective_date)
2758: or
2759: (l_effective_date < ame_condition_usages.start_date
2760: and ame_condition_usages.start_date <
2761: nvl(ame_condition_usages.end_date, ame_condition_usages.start_date + ame_util.oneSecond)))
2757: and nvl(ame_condition_usages.end_date - ame_util.oneSecond, l_effective_date)
2758: or
2759: (l_effective_date < ame_condition_usages.start_date
2760: and ame_condition_usages.start_date <
2761: nvl(ame_condition_usages.end_date, ame_condition_usages.start_date + ame_util.oneSecond)))
2762: and ame_condition_usages.condition_id = ame_conditions.condition_id
2763: and ame_conditions.condition_type <> ame_util.listModConditionType
2764: and l_effective_date between ame_conditions.start_date
2765: and nvl(ame_conditions.end_date - ame_util.oneSecond,l_effective_date);
2759: (l_effective_date < ame_condition_usages.start_date
2760: and ame_condition_usages.start_date <
2761: nvl(ame_condition_usages.end_date, ame_condition_usages.start_date + ame_util.oneSecond)))
2762: and ame_condition_usages.condition_id = ame_conditions.condition_id
2763: and ame_conditions.condition_type <> ame_util.listModConditionType
2764: and l_effective_date between ame_conditions.start_date
2765: and nvl(ame_conditions.end_date - ame_util.oneSecond,l_effective_date);
2766: --+
2767: cursor getReqAttributes is
2761: nvl(ame_condition_usages.end_date, ame_condition_usages.start_date + ame_util.oneSecond)))
2762: and ame_condition_usages.condition_id = ame_conditions.condition_id
2763: and ame_conditions.condition_type <> ame_util.listModConditionType
2764: and l_effective_date between ame_conditions.start_date
2765: and nvl(ame_conditions.end_date - ame_util.oneSecond,l_effective_date);
2766: --+
2767: cursor getReqAttributes is
2768: select man.attribute_id
2769: from ame_mandatory_attributes man
2771: ,ame_actions act
2772: where man.action_type_id = act.action_type_id
2773: and acu.action_id = act.action_id
2774: and acu.rule_id = p_rule_id
2775: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
2776: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
2777: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
2778: or
2779: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
2772: where man.action_type_id = act.action_type_id
2773: and acu.action_id = act.action_id
2774: and acu.rule_id = p_rule_id
2775: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
2776: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
2777: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
2778: or
2779: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
2780: );
2773: and acu.action_id = act.action_id
2774: and acu.rule_id = p_rule_id
2775: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
2776: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
2777: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
2778: or
2779: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
2780: );
2781: --+
2775: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
2776: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date)
2777: and ((l_effective_date between acu.start_date and nvl(acu.end_date - ame_util.oneSecond, l_effective_date))
2778: or
2779: (l_effective_date < acu.start_date and acu.start_date < nvl(acu.end_date, acu.start_date + ame_util.oneSecond))
2780: );
2781: --+
2782: cursor getAttributeUsages(p_attribute_id in number) is
2783: select attribute_id, use_count, start_date, end_date, object_version_number
2784: from ame_attribute_usages
2785: where attribute_id = p_attribute_id
2786: and application_id = p_application_id
2787: and l_effective_date between start_date and
2788: nvl(end_date - ame_util.oneSecond,l_effective_date);
2789: begin
2790: hr_utility.set_location('Entering:'|| l_proc, 10);
2791: --
2792: -- Issue a savepoint
2875: into l_usage_count
2876: from ame_rule_usages
2877: where rule_id = p_rule_id
2878: and ((l_effective_date between start_date
2879: and nvl(end_date - ame_util.oneSecond,l_effective_date))
2880: or
2881: (l_effective_date < start_date
2882: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2883: if l_usage_count = 0 then
2878: and ((l_effective_date between start_date
2879: and nvl(end_date - ame_util.oneSecond,l_effective_date))
2880: or
2881: (l_effective_date < start_date
2882: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
2883: if l_usage_count = 0 then
2884: -- actions usages
2885: for tempActions in getActions loop
2886: l_acu_object_version_number := tempActions.object_version_number;
3019: from ame_conditions, ame_condition_usages
3020: where ame_condition_usages.condition_id <> p_condition_id
3021: and ame_condition_usages.rule_id = p_rule_id
3022: and ( l_effective_date between ame_condition_usages.start_date and
3023: nvl(ame_condition_usages.end_date - ame_util.oneSecond,l_effective_date ) or
3024: (l_effective_date < ame_condition_usages.start_date and
3025: ame_condition_usages.start_date <
3026: nvl(ame_condition_usages.end_date,ame_condition_usages.start_date + ame_util.oneSecond)))
3027: and ame_condition_usages.condition_id = ame_conditions.condition_id
3022: and ( l_effective_date between ame_condition_usages.start_date and
3023: nvl(ame_condition_usages.end_date - ame_util.oneSecond,l_effective_date ) or
3024: (l_effective_date < ame_condition_usages.start_date and
3025: ame_condition_usages.start_date <
3026: nvl(ame_condition_usages.end_date,ame_condition_usages.start_date + ame_util.oneSecond)))
3027: and ame_condition_usages.condition_id = ame_conditions.condition_id
3028: and ame_conditions.condition_type = p_condition_type
3029: and l_effective_date between ame_conditions.start_date and
3030: nvl(ame_conditions.end_date - ame_util.oneSecond,l_effective_date );
3026: nvl(ame_condition_usages.end_date,ame_condition_usages.start_date + ame_util.oneSecond)))
3027: and ame_condition_usages.condition_id = ame_conditions.condition_id
3028: and ame_conditions.condition_type = p_condition_type
3029: and l_effective_date between ame_conditions.start_date and
3030: nvl(ame_conditions.end_date - ame_util.oneSecond,l_effective_date );
3031: --+
3032: cursor getRuleDetails is
3033: select rule_type, start_date, end_date, item_class_id
3034: from ame_rules
3033: select rule_type, start_date, end_date, item_class_id
3034: from ame_rules
3035: where rule_id = p_rule_id
3036: and ( l_effective_date between start_date and
3037: nvl(end_date - ame_util.oneSecond,l_effective_date ) or
3038: (l_effective_date < start_date and
3039: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
3040: --+
3041: cursor getApplications is
3035: where rule_id = p_rule_id
3036: and ( l_effective_date between start_date and
3037: nvl(end_date - ame_util.oneSecond,l_effective_date ) or
3038: (l_effective_date < start_date and
3039: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
3040: --+
3041: cursor getApplications is
3042: select item_id
3043: from ame_rule_usages
3042: select item_id
3043: from ame_rule_usages
3044: where rule_id = p_rule_id
3045: and ( l_effective_date between start_date and
3046: nvl(end_date - ame_util.oneSecond,l_effective_date ) or
3047: (l_effective_date < start_date and
3048: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
3049: --+
3050: cursor getConditionType(conditionIdIn in integer) is
3044: where rule_id = p_rule_id
3045: and ( l_effective_date between start_date and
3046: nvl(end_date - ame_util.oneSecond,l_effective_date ) or
3047: (l_effective_date < start_date and
3048: start_date < nvl(end_date,start_date + ame_util.oneSecond)));
3049: --+
3050: cursor getConditionType(conditionIdIn in integer) is
3051: select condition_type
3052: from ame_conditions
3051: select condition_type
3052: from ame_conditions
3053: where condition_id = conditionIdIn
3054: and l_effective_date between start_date
3055: and nvl(end_date - ame_util.oneSecond,l_effective_date);
3056: --+
3057: cursor getAttributeUsages(p_application_id in integer) is
3058: select use_count, start_date, end_date, object_version_number
3059: from ame_attribute_usages
3058: select use_count, start_date, end_date, object_version_number
3059: from ame_attribute_usages
3060: where attribute_id = l_attribute_id
3061: and l_effective_date between start_date and
3062: nvl(end_date - ame_util.oneSecond,l_effective_date )
3063: and application_id = p_application_id;
3064: --+
3065: cursor getAttributeId is
3066: select attribute_id
3066: select attribute_id
3067: from ame_conditions
3068: where condition_id = p_condition_id
3069: and l_effective_date between start_date and
3070: nvl(end_date - ame_util.oneSecond,l_effective_date ) ;
3071: --+
3072: --+ Declare local variables
3073: --+
3074: l_proc varchar2(72) := g_package||'delete_ame_rule_condition ';
3092: l_acu_object_version_number number;
3093: l_acu_start_date date;
3094: l_acu_end_date date;
3095: l_use_count number := 0;
3096: actionIdList ame_util.idList;
3097: conditionIdList ame_util.idList;
3098: applicationName ame_calling_apps.application_name%type;
3099: attributeName ame_attributes.name%type;
3100: l_swi_call boolean;
3093: l_acu_start_date date;
3094: l_acu_end_date date;
3095: l_use_count number := 0;
3096: actionIdList ame_util.idList;
3097: conditionIdList ame_util.idList;
3098: applicationName ame_calling_apps.application_name%type;
3099: attributeName ame_attributes.name%type;
3100: l_swi_call boolean;
3101: begin
3158: ,p_condition_id => p_condition_id) then
3159: fnd_message.set_name('PER','AME_400772_CON_NOT_EXIST_RULE');
3160: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
3161: end if;
3162: if l_rule_type = ame_util.exceptionRuleType then
3163: l_condition_type := ame_util.exceptionConditionType;
3164: --
3165: -- Fetch the condition details
3166: --
3159: fnd_message.set_name('PER','AME_400772_CON_NOT_EXIST_RULE');
3160: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
3161: end if;
3162: if l_rule_type = ame_util.exceptionRuleType then
3163: l_condition_type := ame_util.exceptionConditionType;
3164: --
3165: -- Fetch the condition details
3166: --
3167: open getConditionCount(p_condition_type => l_condition_type
3171: if l_count = 0 then
3172: fnd_message.set_name('PER','AME_400709_NO_EXC_COND_LCE_RUL');
3173: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
3174: end if;
3175: elsif l_rule_type in (ame_util.listModRuleType, ame_util.substitutionRuleType) then
3176: l_condition_type := ame_util.listModConditionType ;
3177: --
3178: -- Fetch the condition details
3179: --
3172: fnd_message.set_name('PER','AME_400709_NO_EXC_COND_LCE_RUL');
3173: hr_multi_message.add(p_associated_column1 => 'CONDITION_ID');
3174: end if;
3175: elsif l_rule_type in (ame_util.listModRuleType, ame_util.substitutionRuleType) then
3176: l_condition_type := ame_util.listModConditionType ;
3177: --
3178: -- Fetch the condition details
3179: --
3180: open getConditionCount(p_condition_type => l_condition_type
3244: ,p_start_date => l_cnu_start_date
3245: ,p_end_date => l_cnu_end_date
3246: );
3247: --
3248: if(l_condition_type <> ame_util.listModConditionType) then
3249: open getAttributeId;
3250: fetch getAttributeId into l_attribute_id;
3251: close getAttributeId;
3252: --+
3361: cursor getActionCount is
3362: select count(*)
3363: from ame_action_usages acu
3364: where rule_id = p_rule_id
3365: and ((l_effective_date between start_date and nvl(end_date - ame_util.oneSecond, l_effective_date))
3366: or
3367: (l_effective_date < start_date and start_date < nvl(end_date,start_date + ame_util.oneSecond)))
3368: and action_id <> p_action_id;
3369: --+
3363: from ame_action_usages acu
3364: where rule_id = p_rule_id
3365: and ((l_effective_date between start_date and nvl(end_date - ame_util.oneSecond, l_effective_date))
3366: or
3367: (l_effective_date < start_date and start_date < nvl(end_date,start_date + ame_util.oneSecond)))
3368: and action_id <> p_action_id;
3369: --+
3370: cursor getRuleDetails is
3371: select rule_type
3373: ,end_date
3374: ,item_class_id
3375: from ame_rules
3376: where rule_id = p_rule_id
3377: and ((l_effective_date between start_date and nvl(end_date - ame_util.oneSecond, l_effective_date))
3378: or
3379: (l_effective_date < start_date and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
3380: --+
3381: cursor getReqAttributeIds(actionIdIn in integer) is
3375: from ame_rules
3376: where rule_id = p_rule_id
3377: and ((l_effective_date between start_date and nvl(end_date - ame_util.oneSecond, l_effective_date))
3378: or
3379: (l_effective_date < start_date and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
3380: --+
3381: cursor getReqAttributeIds(actionIdIn in integer) is
3382: select man.attribute_id
3383: from ame_mandatory_attributes man
3383: from ame_mandatory_attributes man
3384: ,ame_actions act
3385: where man.action_type_id = act.action_type_id
3386: and act.action_id = actionIdIn
3387: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
3388: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date);
3389: --+
3390: cursor getApplications(ruleIdIn in integer)is
3391: select item_id
3384: ,ame_actions act
3385: where man.action_type_id = act.action_type_id
3386: and act.action_id = actionIdIn
3387: and l_effective_date between man.start_date and nvl(man.end_date - ame_util.oneSecond, l_effective_date)
3388: and l_effective_date between act.start_date and nvl(act.end_date - ame_util.oneSecond, l_effective_date);
3389: --+
3390: cursor getApplications(ruleIdIn in integer)is
3391: select item_id
3392: from ame_rule_usages
3391: select item_id
3392: from ame_rule_usages
3393: where rule_id = ruleIdIn
3394: and (l_effective_date between start_date
3395: and nvl(end_date - ame_util.oneSecond, l_effective_date)
3396: or
3397: (l_effective_date < start_date
3398: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
3399: --+
3394: and (l_effective_date between start_date
3395: and nvl(end_date - ame_util.oneSecond, l_effective_date)
3396: or
3397: (l_effective_date < start_date
3398: and start_date < nvl(end_date, start_date + ame_util.oneSecond)));
3399: --+
3400: cursor getAttributeUsages(attributeIdIn in integer
3401: ,applicationIdIn in integer) is
3402: select application_id
3407: from ame_attribute_usages
3408: where attribute_id = attributeIdIn
3409: and application_id = applicationIdIn
3410: and l_effective_date between start_date
3411: and nvl(end_date - ame_util.oneSecond, l_effective_date);
3412: --+
3413: l_count number;
3414: l_allowAllApproverTypes varchar2(30);
3415: l_allowProduction varchar2(30);
3423: l_acu_start_date date;
3424: l_acu_end_date date;
3425: l_use_count number := 0;
3426: l_swi_package_name varchar2(30) := 'AME_RULE_SWI';
3427: actionIdList ame_util.idList;
3428: conditionIdList ame_util.idList;
3429: l_swi_call boolean;
3430: begin
3431: hr_utility.set_location('Entering:'|| l_proc, 10);
3424: l_acu_end_date date;
3425: l_use_count number := 0;
3426: l_swi_package_name varchar2(30) := 'AME_RULE_SWI';
3427: actionIdList ame_util.idList;
3428: conditionIdList ame_util.idList;
3429: l_swi_call boolean;
3430: begin
3431: hr_utility.set_location('Entering:'|| l_proc, 10);
3432: --
3641: ,attribute_id
3642: from ame_conditions
3643: where condition_id = p_condition_id
3644: and l_effective_date between start_date
3645: and nvl(end_date - ame_util.oneSecond,l_effective_date);
3646: --+
3647: cursor getRuleDetails is
3648: select rule_type
3649: ,start_date
3651: ,item_class_id
3652: from ame_rules
3653: where rule_id = p_rule_id
3654: and (l_effective_date between start_date
3655: and nvl(end_date - ame_util.oneSecond,l_effective_date) or
3656: (l_effective_date < start_date
3657: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
3658: --+
3659: cursor getApplicationIds(p_rule_id in integer) is
3653: where rule_id = p_rule_id
3654: and (l_effective_date between start_date
3655: and nvl(end_date - ame_util.oneSecond,l_effective_date) or
3656: (l_effective_date < start_date
3657: and start_date < nvl(end_date,start_date + ame_util.oneSecond)));
3658: --+
3659: cursor getApplicationIds(p_rule_id in integer) is
3660: select distinct item_id
3661: from ame_rule_usages
3669: l_item_class_id number;
3670: l_rul_start_date date;
3671: l_rul_end_date date;
3672: l_count number;
3673: appIdList ame_util.idList;
3674: l_action_id_list ame_util.idList;
3675: l_old_condition_id number;
3676: l_cnu_object_version_number number;
3677: l_cnu_start_date date;
3670: l_rul_start_date date;
3671: l_rul_end_date date;
3672: l_count number;
3673: appIdList ame_util.idList;
3674: l_action_id_list ame_util.idList;
3675: l_old_condition_id number;
3676: l_cnu_object_version_number number;
3677: l_cnu_start_date date;
3678: l_cnu_end_date date;
3738: close getRuleDetails;
3739: --+
3740: --+ Error out if condition is not LM.
3741: --+
3742: if l_condition_type <> ame_util.listModConditionType then
3743: fnd_message.set_name('PER','AME_400776_NON_LM_COND');
3744: hr_multi_message.add (p_associated_column1 => 'CONDITION_ID');
3745: end if;
3746: --+
3745: end if;
3746: --+
3747: --+ Error out if rule is not LM/SUB/ LMCOMB.
3748: --+
3749: if (l_rule_type = ame_util.combinationRuleType and not ame_rule_utility_pkg.is_LM_comb_rule(p_rule_id)) then
3750: fnd_message.set_name('PER','AME_400777_NON_LM_SUB_RULE');
3751: hr_multi_message.add (p_associated_column1 => 'RULE_ID');
3752: end if;
3753: if l_rule_type not in(ame_util.listModRuleType
3749: if (l_rule_type = ame_util.combinationRuleType and not ame_rule_utility_pkg.is_LM_comb_rule(p_rule_id)) then
3750: fnd_message.set_name('PER','AME_400777_NON_LM_SUB_RULE');
3751: hr_multi_message.add (p_associated_column1 => 'RULE_ID');
3752: end if;
3753: if l_rule_type not in(ame_util.listModRuleType
3754: ,ame_util.substitutionRuleType) then
3755: fnd_message.set_name('PER','AME_400777_NON_LM_SUB_RULE');
3756: hr_multi_message.add (p_associated_column1 => 'RULE_ID');
3757: end if;
3750: fnd_message.set_name('PER','AME_400777_NON_LM_SUB_RULE');
3751: hr_multi_message.add (p_associated_column1 => 'RULE_ID');
3752: end if;
3753: if l_rule_type not in(ame_util.listModRuleType
3754: ,ame_util.substitutionRuleType) then
3755: fnd_message.set_name('PER','AME_400777_NON_LM_SUB_RULE');
3756: hr_multi_message.add (p_associated_column1 => 'RULE_ID');
3757: end if;
3758: --+
3763: from ame_condition_usages cnu
3764: ,ame_conditions cnd
3765: where cnu.rule_id = p_rule_id
3766: and cnu.condition_id = cnd.condition_id
3767: and cnd.condition_type = ame_util.listModConditionType
3768: and sysdate between cnd.start_date and nvl(cnd.end_date - (1/86400),sysdate)
3769: and ((sysdate between cnu.start_date and nvl(cnu.end_date - (1/86400),sysdate))
3770: or
3771: (sysdate < cnu.start_date and cnu.start_date < nvl(cnu.end_date, cnu.start_date + (1/86400)))