20:
21: procedure delete_rows is
22: l_proc varchar2(60) := g_package||'delete_rows';
23: begin
24: hr_utility.set_location('Entering into '||l_proc,10);
25: g_quota_grid.delete;
26: hr_utility.set_location('Leaving '||l_proc,10);
27: end ;
28:
22: l_proc varchar2(60) := g_package||'delete_rows';
23: begin
24: hr_utility.set_location('Entering into '||l_proc,10);
25: g_quota_grid.delete;
26: hr_utility.set_location('Leaving '||l_proc,10);
27: end ;
28:
29: Procedure Update_grid(p_corp_id in number,
30: p_corp_name in varchar2,
36: l_flag varchar2(1);
37: l_next_row number;
38: l_proc varchar2(60) := g_package||'Update_grid';
39: Begin
40: hr_utility.set_location('Entering into '||l_proc,10);
41:
42: if NVL(g_quota_grid.LAST, 0) = 0 then
43: hr_utility.set_location('First row in the grid',10);
44: g_quota_grid(1).corp_id := p_corp_id;
39: Begin
40: hr_utility.set_location('Entering into '||l_proc,10);
41:
42: if NVL(g_quota_grid.LAST, 0) = 0 then
43: hr_utility.set_location('First row in the grid',10);
44: g_quota_grid(1).corp_id := p_corp_id;
45: g_quota_grid(1).corp_name := p_corp_name;
46: g_quota_grid(1).grade_id := p_grade_id;
47: g_quota_grid(1).grade_name := p_grade_name;
77: g_quota_grid(l_next_row).effective_date := p_effective_date;
78: end if;
79:
80: end if;
81: hr_utility.set_location('Leaving '||l_proc,10);
82: end Update_grid;
83:
84: Function population_corp(p_corp_id number,
85: p_business_group_id number,
90: l_effective_date date;
91: l_corp_id number;
92:
93: Begin
94: hr_utility.set_location('Entering into '||l_proc,5);
95: l_effective_date := p_effective_date;
96: l_corp_id := p_corp_id;
97:
98: Select count(asg.assignment_id)
109: And per.person_id = asg.person_id
110: And l_effective_date between per.effective_start_date And per.effective_end_date
111: And per.per_information15 = '01';
112:
113: hr_utility.set_location('Poplation for Corp'||to_char(l_corp_id)||': '||to_char(l_corp_population),5);
114: hr_utility.set_location('Leaving from '||l_proc,5);
115: Return l_corp_population;
116:
117: End population_corp;
110: And l_effective_date between per.effective_start_date And per.effective_end_date
111: And per.per_information15 = '01';
112:
113: hr_utility.set_location('Poplation for Corp'||to_char(l_corp_id)||': '||to_char(l_corp_population),5);
114: hr_utility.set_location('Leaving from '||l_proc,5);
115: Return l_corp_population;
116:
117: End population_corp;
118:
126: l_effective_date date;
127: l_corp_id number;
128: l_grade_id number;
129: Begin
130: hr_utility.set_location('Entering into '||l_proc,5);
131:
132: Select count(asg.assignment_id)
133: into l_grade_population
134: From Per_all_assignments_f asg,
144: And per.person_id = asg.person_id
145: And p_effective_date between per.effective_start_date And per.effective_end_date
146: And per.per_information15 = '01';
147:
148: hr_utility.set_location('Poplation for Grade '||to_char(p_grade_id)||' in corp '||to_char(p_corp_id)||': '||to_char(l_grade_population),5);
149:
150: hr_utility.set_location('Leaving from '||l_proc,5);
151: Return l_grade_population;
152: End population_grade;
146: And per.per_information15 = '01';
147:
148: hr_utility.set_location('Poplation for Grade '||to_char(p_grade_id)||' in corp '||to_char(p_corp_id)||': '||to_char(l_grade_population),5);
149:
150: hr_utility.set_location('Leaving from '||l_proc,5);
151: Return l_grade_population;
152: End population_grade;
153:
154: Function Quota_applicable (p_corp_id number,
156: l_proc varchar2(60) := g_package||'Quota_applicable';
157: l_quota_flag varchar2(1);
158: Begin
159:
160: hr_utility.set_location('Entering into '||l_proc,5);
161:
162: select nvl(pei.pgi_information1,'N') Quota_flag
163: into l_quota_flag
164: from ben_pgm_extra_info pei,
167: and pei.pgm_id = corps.ben_pgm_id
168: and corps.corps_definition_id = p_corp_id;
169:
170:
171: hr_utility.set_location('Leaving from '||l_proc,5);
172:
173: return l_quota_flag;
174: exception
175: when no_data_found then
200: l_comma_pos number;
201: l_cond_grade_id number;
202: l_proc varchar2(60) := g_package||'Quota_occupancy';
203: Begin
204: hr_utility.set_location('Entering into '||l_proc,5);
205: Open grade_condition;
206: fetch grade_condition into l_percentage,l_cond_type,l_grade_ids;
207: Close grade_condition;
208:
206: fetch grade_condition into l_percentage,l_cond_type,l_grade_ids;
207: Close grade_condition;
208:
209: if l_percentage is null then
210: hr_utility.set_location('No Quota defined for the Grade '||to_char(p_grade_id),5);
211: l_Quota_occupancy := null;
212: elsif l_cond_type = 'CORPS' then
213: hr_utility.set_location('Quota defined in percentage of Corp for Grade '||to_char(p_grade_id),5);
214: l_corps_population := population_corp(p_corp_id,
209: if l_percentage is null then
210: hr_utility.set_location('No Quota defined for the Grade '||to_char(p_grade_id),5);
211: l_Quota_occupancy := null;
212: elsif l_cond_type = 'CORPS' then
213: hr_utility.set_location('Quota defined in percentage of Corp for Grade '||to_char(p_grade_id),5);
214: l_corps_population := population_corp(p_corp_id,
215: p_business_group_id ,
216: p_effective_date);
217: l_quota_occupancy := floor(((l_percentage * l_corps_population)/100));
215: p_business_group_id ,
216: p_effective_date);
217: l_quota_occupancy := floor(((l_percentage * l_corps_population)/100));
218: elsif l_cond_type = 'COMB_GRADES' then
219: hr_utility.set_location('Quota defined in percentage of combination of Grades for Grade '||to_char(p_grade_id),5);
220: l_start:= 1;
221: l_occurance := 1;
222: l_comma_pos := instr(l_grade_ids,',',l_start,l_occurance);
223: l_grades_population := 0;
241: p_effective_date );
242: l_quota_occupancy := round(((l_percentage * l_grades_population)/100),0);
243:
244: end if;
245: hr_utility.set_location('Leaving from '||l_proc,5);
246: return l_Quota_occupancy;
247: end Quota_occupancy;
248:
249: procedure quota_grid_formation(p_elctbl_chc_id in number,
296: l_person_info person_cur_info%rowtype;
297: l_business_group_info business_group_info%rowtype;
298:
299: begin
300: hr_utility.set_location('Entering into '||l_proc,5);
301: l_elctbl_chc_id := p_elctbl_chc_id;
302:
303: if l_elctbl_chc_id is not null then
304:
322:
323: if l_person_info.agent_type = '01' then
324: if (l_person_info.pgm_id <> l_elctbl_chc_det_rec.program_id
325: or l_person_info.grade_id <> l_elctbl_chc_det_rec.grade_id ) then
326: hr_utility.set_location('Before Update Grid Call',5);
327: Update_grid(p_corp_id => l_elctbl_chc_det_rec.corp_id,
328: p_corp_name => l_elctbl_chc_det_rec.corp_name,
329: p_grade_id => l_elctbl_chc_det_rec.grade_id,
330: p_grade_name => l_elctbl_chc_det_rec.grade_name,
330: p_grade_name => l_elctbl_chc_det_rec.grade_name,
331: p_effective_date => p_effective_date );
332:
333: else
334: hr_utility.set_location('No change in Grade',5);
335: end if;
336: end if;
337:
338: end if;
336: end if;
337:
338: end if;
339: end if;
340: hr_utility.set_location('Leaving from '||l_proc,5);
341: end quota_grid_formation;
342:
343: procedure check_quota(p_business_group_id in number, p_return_status out nocopy varchar2) is
344:
349: l_already_app number;
350: l_quota_allowed_char varchar2(10);
351: --l_return_status varchar2(1) := 'Y';
352: begin
353: hr_utility.set_location('Entering into '||l_proc, 10);
354: hr_multi_message.enable_message_list;
355: l_number_of_rows := g_quota_grid.COUNT;
356:
357: if l_number_of_rows > 0 then
358: For table_row in 1..l_number_of_rows
359: loop
360: if Quota_applicable(g_quota_grid(table_row).corp_id,g_quota_grid(table_row).effective_date) = 'Y' then
361:
362: hr_utility.set_location('checking Quota for Grade'||g_quota_grid(table_row).grade_name, 10);
363:
364: l_grade_cur_pop := population_grade(p_corp_id => g_quota_grid(table_row).corp_id ,
365: p_grade_id => g_quota_grid(table_row).grade_id ,
366: p_business_group_id => p_business_group_id,
411: end if;
412: end loop;
413: end if;
414: p_return_status := hr_multi_message.get_return_status_disable;
415: hr_utility.set_location('Leaving '||l_proc, 10);
416: exception
417: when hr_multi_message.error_message_exist then
418: --
419: -- Catch the Multiple Message List exception which
419: -- Catch the Multiple Message List exception which
420: -- indicates Quota check failed.
421: --
422: p_return_status := hr_multi_message.get_return_status_disable;
423: hr_utility.set_location(' Leaving:' || l_proc, 30);
424: when others then
425: --
426: -- When Multiple Message Detection is enabled catch
427: -- any Application specific or other unexpected
429: -- Multiple Message List. Otherwise re-raise the
430: -- error.
431: --
432: if hr_multi_message.unexpected_error_add(l_proc) then
433: hr_utility.set_location(' Leaving:' || l_proc,40);
434: raise;
435: end if;
436: --
437: -- Reset IN OUT and set OUT parameters
436: --
437: -- Reset IN OUT and set OUT parameters
438: --
439: p_return_status := hr_multi_message.get_return_status_disable;
440: hr_utility.set_location(' Leaving:' || l_proc,50);
441: end check_quota;
442:
443: procedure check_quota(p_business_group_id in number,
444: p_effective_date in date,
454: l_proc varchar2(60) := g_package||'check_quota 2';
455: l_return_status varchar2(1) := 'Y';
456: l_corp_id number;
457: Begin
458: hr_utility.set_location('Entering into '||l_proc, 10);
459:
460: select name, corps_definition_id into l_corp_name, l_corp_id
461: from pqh_corps_definitions
462: where ben_pgm_id = p_corp_id;
504: end if;
505: end if;
506: end if;
507: p_return_status := l_return_status;
508: hr_utility.set_location('Leaving '||l_proc, 10);
509: End check_quota;
510: End PQH_FR_QUOTA_CHECK;