[Home] [Help]
PACKAGE BODY: APPS.HR_PERF_MGMT_PLAN_INTERNAL
Source
1 Package Body HR_PERF_MGMT_PLAN_INTERNAL as
2 /* $Header: pepmpbsi.pkb 120.43.12010000.12 2008/12/22 09:32:25 psugumar ship $ */
3 -- Package Variables
4 -- Package Variables
5 --
6
7 g_package VARCHAR2(33) := 'hr_perf_mgmt_plan_internal.';
8 g_debug BOOLEAN := hr_utility.debug_enabled;
9 g_num_errors NUMBER := 0;
10 g_max_errors NUMBER;
11
12 --
13 -- Proprietory debugging. Allows for concurrent request output, etc.
14 -- (see procedures "op").
15 --
16 g_dbg BOOLEAN := g_debug;
17 g_dbg_type NUMBER := g_NO_DEBUG;
18 g_log_level VARCHAR2(1) := g_REGULAR_LOG;
19 --
20 --
21 -- Package (private) constants.
22 --
23 LOGGING CONSTANT pay_action_parameters.parameter_name%TYPE := 'LOGGING';
24 MAX_ERRORS CONSTANT pay_action_parameters.parameter_name%TYPE := 'MAX_ERRORS_ALLOWED';
25 NEWLINE CONSTANT VARCHAR2(10) := fnd_global.newline;
26 TAB CONSTANT VARCHAR2(30) := fnd_global.tab;
27 --
28 g_error_txt VARCHAR2(32000);
29 g_cp_error_txt VARCHAR2(32000);
30 --
31
32 --
33 -- Private user-defined types.
34 --
35
36 -- Used for populating Plan Population
37 TYPE g_qual_pop_r IS RECORD (assignment_id per_all_assignments_f.assignment_id%TYPE,
38 person_id per_all_assignments_f.person_id%TYPE,
39 business_group_id per_all_assignments_f.business_group_id%TYPE,
40 supervisor_id per_all_assignments_f.supervisor_id%TYPE,
41 supervisor_assignment_id per_all_assignments_f.supervisor_assignment_id%TYPE,
42 organization_id per_all_assignments_f.organization_id%TYPE,
43 position_id per_all_assignments_f.position_id%TYPE);
44 TYPE g_qual_pop_t IS TABLE OF g_qual_pop_r INDEX BY binary_integer;
45 g_qual_pop_tbl g_qual_pop_t;
46
47 -- Used for populating existing scorecard population
48 TYPE g_curr_sc_pop_r IS RECORD (assignment_id per_personal_scorecards.assignment_id%TYPE,
49 scorecard_id per_personal_scorecards.scorecard_id%TYPE,
50 object_version_number per_personal_scorecards.object_version_number%TYPE,
51 status_code per_personal_scorecards.status_code%TYPE);
52 TYPE g_curr_sc_pop_t IS TABLE OF g_curr_sc_pop_r INDEX BY binary_integer;
53 g_curr_sc_pop_tbl g_curr_sc_pop_t;
54
55 -- Used for populating qualifying objectives
56 TYPE g_qual_obj_r IS RECORD (
57 objective_id per_objectives_library.objective_id%TYPE,
58 objective_name per_objectives_library.objective_name%TYPE,
59 valid_from per_objectives_library.valid_from%TYPE,
60 valid_to per_objectives_library.valid_to%TYPE,
61 target_date per_objectives_library.target_date%TYPE,
62 next_review_date per_objectives_library.NEXT_review_date%TYPE,
63 group_code per_objectives_library.group_code%TYPE,
64 priority_code per_objectives_library.priority_code%TYPE,
65 appraise_flag per_objectives_library.appraise_flag%TYPE,
66 weighting_percent per_objectives_library.weighting_percent%TYPE,
67 target_value per_objectives_library.target_value%TYPE,
68 uom_code per_objectives_library.uom_code%TYPE,
69 measurement_style_code per_objectives_library.measurement_style_code%TYPE,
70 measure_name per_objectives_library.measure_name%TYPE,
71 measure_type_code per_objectives_library.measure_type_code%TYPE,
72 measure_comments per_objectives_library.measure_comments%TYPE,
73 details per_objectives_library.details%TYPE,
74 success_criteria per_objectives_library.success_criteria%TYPE,
75 comments per_objectives_library.comments%TYPE,
76 elig_obj_id ben_elig_obj_f.ELIG_OBJ_ID%type);
77
78 TYPE g_qual_obj_t is table of g_qual_obj_r INDEX BY binary_integer;
79 g_qual_obj_tbl g_qual_obj_t;
80
81 -- User for populating existing scorecard objectives
82 TYPE g_curr_sc_obj_r IS RECORD (copied_from_library_id per_objectives.copied_from_library_id%TYPE,
83 objective_id per_objectives.objective_id%TYPE,
84 object_version_number per_objectives.object_version_number%TYPE);
85 TYPE g_curr_sc_obj_t IS TABLE OF g_curr_sc_obj_r INDEX BY binary_integer;
86 g_curr_sc_obj_tbl g_curr_sc_obj_t;
87
88 -- User for populating plan appraisal periods
89 TYPE g_plan_aprsl_pds_r IS RECORD (appraisal_period_id per_appraisal_periods.appraisal_period_id%TYPE,
90 appraisal_template_id per_appraisal_periods.appraisal_template_id%TYPE,
91 start_date per_appraisal_periods.start_date%TYPE,
92 end_date per_appraisal_periods.end_date%TYPE,
93 task_start_date per_appraisal_periods.task_start_date%TYPE,
94 task_end_date per_appraisal_periods.task_end_date%TYPE,
95 initiator_code per_appraisal_periods.initiator_code%TYPE,
96 appraisal_system_type per_appraisal_periods.appraisal_system_type%TYPE,
97 auto_conc_process per_appraisal_periods.auto_conc_process%TYPE,
98 days_before_task_st_dt per_appraisal_periods.days_before_task_st_dt%TYPE,
99 appraisal_assmt_status per_appraisal_periods.appraisal_assmt_status%TYPE,
100 appraisal_type per_appraisal_periods.appraisal_type%TYPE);
101 TYPE g_plan_aprsl_pds_t IS TABLE OF g_plan_aprsl_pds_r INDEX BY binary_integer;
102 g_plan_aprsl_pds_tbl g_plan_aprsl_pds_t;
103 --
104 TYPE g_boolean_t IS TABLE OF BOOLEAN INDEX BY binary_integer;
105 g_plan_pop_known_t g_boolean_t;
106 g_fetched_plan_member_index number;
107 --
108
109 TYPE scorecard_info is RECORD (
110 scorecard_id per_personal_scorecards.scorecard_id%TYPE,
111 assignment_id per_personal_scorecards.assignment_id%TYPE,
112 person_id per_personal_scorecards.person_id%TYPE,
113 scorecard_name per_personal_scorecards.scorecard_name%TYPE);
114
115 TYPE assignment_info is RECORD (
116 assignment_id per_all_assignments_f.assignment_id%TYPE,
117 business_group_id per_all_assignments_f.business_group_id%TYPE,
118 grade_id per_all_assignments_f.grade_id%TYPE,
119 position_id per_all_assignments_f.position_id%TYPE,
120 job_id per_all_assignments_f.job_id%TYPE,
121 org_id per_all_assignments_f.organization_id%TYPE,
122 supervisor_id per_all_assignments_f.supervisor_id%TYPE,
123 effective_state_date per_all_assignments_f.effective_start_date%TYPE
124 );
125
126 TYPE appraisal_templ_info is RECORD (
127 appraisal_template_id per_appraisal_templates.appraisal_template_id%TYPE,
128 assessment_type_id per_appraisal_templates.assessment_type_id%TYPE,
129 objective_asmnt_type_id per_appraisal_templates.objective_asmnt_type_id%TYPE,
130 business_group_id per_appraisal_templates.business_group_id%TYPE
131 );
132
133 TYPE assess_comps_info is RECORD (
134 competence_id per_competence_elements.competence_id%TYPE,
135 competence_element_id per_competence_elements.competence_element_id%TYPE,
136 type per_competence_elements.type%TYPE,
137 parent_competence_element_id per_competence_elements.parent_competence_element_id%TYPE,
138 name per_competences_vl.name%TYPE,
139 rank number );
140
141 TYPE bus_rules_comps IS RECORD(
142 name per_competences_vl.name%TYPE,
143 competence_id per_competences.competence_id%TYPE,
144 competence_element_id per_competence_elements.competence_element_id%TYPE,
145 mandatory per_competence_elements.mandatory%TYPE,
146 proficiency_level_id per_competence_elements.proficiency_level_id%TYPE,
147 high_proficiency_level_id per_competence_elements.high_proficiency_level_id%TYPE,
148 organization_id per_competence_elements.organization_id%TYPE,
149 job_id per_competence_elements.job_id%TYPE,
150 position_id per_competence_elements.position_id%TYPE,
151 valid_grade_id per_competence_elements.valid_grade_id%TYPE,
152 business_group_id per_competence_elements.business_group_id%TYPE,
153 enterprise_id per_competence_elements.enterprise_id%TYPE,
154 structure_type hr_lookups.meaning%TYPE,
155 read_only_attr number,
156 detail_attr number,
157 competence_alias per_competences.competence_alias%TYPE,
158 global varchar2(1),
159 description per_competences.description%TYPE,
160 date_from per_competences.date_from%TYPE,
161 certification_required per_competences.certification_required%TYPE,
162 behavioural_indicator per_competences.behavioural_indicator%TYPE,
163 low_step_value per_rating_levels_vl.step_value%TYPE,
164 low_step_name per_rating_levels_vl.name%TYPE,
165 high_step_value per_rating_levels_vl.step_value%TYPE,
166 high_step_name per_rating_levels_vl.name%TYPE,
167 lookup_code hr_lookups.lookup_code%TYPE,
168 minimum_proficiency varchar2(100),
169 maximum_proficiency varchar2(100),
170 type per_competence_elements.type%TYPE);
171
172 TYPE sel_comp_tab IS TABLE OF bus_rules_comps INDEX BY BINARY_INTEGER ;
173
174 type competences_rc is RECORD (
175 competence_id per_competences.competence_id%TYPE );
176 type competences_tbl is TABLE OF competences_rc INDEX BY BINARY_INTEGER;
177
178 TYPE appr_prds_rc is RECORD (
179 appraisal_period_id per_appraisal_periods.appraisal_period_id%TYPE,
180 appraisal_template_id per_appraisal_periods.appraisal_template_id%TYPE,
181 business_group_id per_appraisal_templates.business_group_id%TYPE);
182 type appr_prds_tbl is table of appr_prds_rc index by binary_integer;
183
184
185 -- added for PERF ADMIN ACTIONS
186 TYPE t_selected_entities IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
187 g_selected_entities t_selected_entities;
188 TYPE t_plan_rec IS TABLE OF per_perf_mgmt_plans%ROWTYPE INDEX BY
189 BINARY_INTEGER;
190 g_plan_rec t_plan_rec;
191 g_plan_dtls t_plan_rec;
192 g_appraisals_exist VARCHAR2(1) := 'N';
193 -- END Changes for PERF ADMIN ACTIONS
194 --
195 -- ----------------------------------------------------------------------------
196 -- |----------------------< initialize_logging >------------------------------|
197 -- ----------------------------------------------------------------------------
198 --
199 PROCEDURE initialize_logging
200 (p_action_parameter_group_id in number,
201 p_log_output in varchar2)
202 IS
203
204 --
205 -- Gets an action parameter value.
206 --
207 CURSOR csr_get_action_param
208 (p_parameter_name IN VARCHAR2) IS
209 SELECT pap.parameter_value
210 FROM pay_action_parameters pap
211 WHERE pap.parameter_name = p_parameter_name;
212
213 l_logging pay_action_parameters.parameter_value%TYPE;
214 l_max_errors pay_action_parameters.parameter_value%TYPE;
215 l_string VARCHAR2(500);
216
217 BEGIN
218
219 --
220 -- Reset the package globals.
221 --
222 g_errbuf := NULL;
223 g_retcode := SUCCESS;
224 g_max_errors := 0;
225 g_error_txt := '';
226
227 --
228 -- If the action parameter ID is passed in, the action param group
229 -- is set. Native dynamic PL/SQL is used to eliminate the
230 -- the dependency on the pay package procedure.
231
232 -- This option we disabled because thriough application we pass explicit null
233 -- but when run through concurrent program this validation can fail
234 -- so keeping at par with application submit of cp we bypass this validation.
235 /* IF p_action_parameter_group_id IS NOT NULL THEN
236
237 l_string :=
238 'BEGIN
239 pay_core_utils.set_pap_group_id(p_pap_group_id => ' ||
240 to_char(p_action_parameter_group_id) || ');
241 END;';
242
243 EXECUTE IMMEDIATE l_string;
244
245 END IF;*/
246
247 --
248 IF (p_log_output = 'Y' and FND_GLOBAL.CONC_REQUEST_ID > 0) THEN
249
250 -- Call from concurrent program
251 g_dbg := True;
252 g_dbg_type := g_FND_LOG;
253
254 --
255 -- Get the Payroll Action logging parameter
256 --
257 OPEN csr_get_action_param (LOGGING);
258 FETCH csr_get_action_param INTO l_logging;
259 CLOSE csr_get_action_param;
260
261 --
262 -- If logging is set to General in Payroll Action parameters, enable debugging.
263 --
264 IF (instr(NVL(l_logging, 'N'), 'G') <> 0) THEN
265 g_log_level := g_DEBUG_LOG;
266 ELSE
267 g_log_level := g_REGULAR_LOG;
268 END IF;
269
270 ELSIF (p_log_output <> 'Y') THEN
271
272 -- Call from API
273 IF (g_debug) THEN
274 g_dbg := True;
275 g_dbg_type := g_PIPE;
276 g_log_level := g_DEBUG_LOG;
277 END IF;
278 END IF;
279
280 --
281 -- Set the max number of errors allowed.
282 --
283 OPEN csr_get_action_param (MAX_ERRORS);
284 FETCH csr_get_action_param INTO l_max_errors;
285 CLOSE csr_get_action_param;
286
287 g_max_errors := NVL(to_number(l_max_errors), 0);
288
289 END initialize_logging;
290
291
292 --
293 -- ----------------------------------------------------------------------------
294 -- |----------------------< op >----------------------------------------------|
295 -- ----------------------------------------------------------------------------
296 --
297 PROCEDURE op
298 (p_msg IN VARCHAR2
299 ,p_log_level IN NUMBER
300 ,p_location IN NUMBER default null
301 )
302 IS
303
304 l_msg VARCHAR2(32000) := p_msg;
305
306 BEGIN
307
308 IF (g_dbg_type IS NOT NULL AND p_msg IS NOT NULL and p_log_level <= g_log_level) THEN
309 --
310 -- Break the output into chunks of 70 characters.
311 --
312 WHILE LENGTH(l_msg) > 0
313 LOOP
314 IF g_dbg_type = g_PIPE OR g_debug THEN
315 IF p_location IS NOT NULL THEN
316 hr_utility.set_location(SUBSTR(l_msg, 1, 70), p_location);
317 ELSE
318 hr_utility.trace(SUBSTR(l_msg, 1, 70));
319 END IF;
320 ELSIF g_dbg_type = g_FND_LOG THEN
321 IF p_location IS NOT NULL THEN
322 fnd_file.put_line(FND_FILE.log, SUBSTR(l_msg, 1, 70)
323 ||', '||to_char(p_location));
324 ELSE
325 fnd_file.put_line(FND_FILE.log, SUBSTR(l_msg, 1, 70));
326 END IF;
327 END IF;
328
329 l_msg := SUBSTR(l_msg, 71);
330 END LOOP;
331 END IF;
332
333 END op;
334 --
335 -- ----------------------------------------------------------------------------
336 -- |-------------------------< chk_publishing_status >------------------------|
337 -- ----------------------------------------------------------------------------
338 -- {Start Of Comments}
339 --
340 -- Description:
341 -- Checks that the status code is a valid for Publish o Reverse Publish plan
342 -- action.
343 --
344 -- Prerequisites:
345 -- None.
346 --
347 -- In Arguments:
348 --
349 --
350 -- Post Success:
351 -- Processing continues if the status is valid.
352 --
353 -- Post Failure:
354 -- An application error is raised if the status code is not valid.
355 --
356 -- Access Status:
357 -- Internal Only.
358 --
359 -- {End Of Comments}
360 -- ----------------------------------------------------------------------------
361 procedure chk_publishing_status
362 (p_reverse_mode in varchar2
363 ,p_status_code in varchar2
364 ) is
365
366 -- Declare local variables
367 l_proc varchar2(72) := g_package||'chk_publishing_status';
368 e_status_check_failed exception;
369
370 Begin
371 --
372 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
373 --
374 IF (p_reverse_mode = 'N' and p_status_code NOT IN ('DRAFT', 'UPDATED','SUBMITTED','RESUBMITTED')) THEN
375
376 -- Set the message name, so that exception handler can get translated text
377 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 20); END IF;
378 fnd_message.set_name('PER','HR_50294_WPM_INV_PLAN_STS_PUB');
379 g_error_txt := nvl(fnd_message.get, 'HR_50294_WPM_INV_PLAN_STS_PUB');
380 raise e_status_check_failed;
381
382 ELSIF (p_reverse_mode <> 'N' and p_status_code NOT IN ('PUBLISHED')) THEN
383
384 -- Set the message name, so that exception handler can get translated text
385 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 30); END IF;
386 fnd_message.set_name('PER','HR_50295_WPM_INV_PLAN_STS_RPUB');
387 g_error_txt := nvl(fnd_message.get, 'HR_50295_WPM_INV_PLAN_STS_RPUB');
388 raise e_status_check_failed;
389
390 END IF;
391 --
392 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
393 --
394
395 exception
396 when others then
397 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
398 --
399 g_retcode := WARNING;
400 g_errbuf := g_error_txt;
401 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
402 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
403 RAISE;
404
405 End chk_publishing_status;
406 --
407 -- ----------------------------------------------------------------------------
408 -- |---------------------< populate_qual_plan_population >---------------------|
409 -- ----------------------------------------------------------------------------
410 -- {Start Of Comments}
411 --
412 -- Description:
413 -- Populate the qualifying plan population and loads in cache(i.e. PLSQL table
414 -- with index as assignment id and other values.
415 --
416 -- Prerequisites:
417 -- None.
418 --
419 -- In Arguments:
420 --
421 --
422 -- Post Success:
423 -- Processing continues on successful population.
424 --
425 -- Post Failure:
426 -- An application error is raised if population fails.
427
428 --
429 -- Access Status:
430 -- Internal Use Only.
431 --
432 -- {End Of Comments}
433 -- ----------------------------------------------------------------------------
434 procedure populate_qual_plan_population
435 (p_plan_rec in per_perf_mgmt_plans%ROWTYPE
436 ,p_effective_date in date
437 ) is
438
439 -- Declare local variables
440 l_proc varchar2(72) := g_package||'populate_qual_plan_population';
441 l_temp_pop_tbl g_qual_pop_t;
442
443
444 -- Supervisor Hierarchy population
445 -- Includes supervisor assignment and person assignments that are in not more than N level
446 -- below in hierarchy, where N is the value specified in hierarchy level attribute of the plan
447 --
448 CURSOR csr_sup_hier_pop IS
449 select * from
450 ( SELECT asg.assignment_id, asg.person_id, asg.business_group_id,
451 asg.supervisor_id, asg.supervisor_assignment_id, asg.organization_id, asg.position_id
452 FROM per_all_assignments_f asg
453 WHERE ((p_plan_rec.assignment_types_code in ('E', 'C')
454 and asg.assignment_type = p_plan_rec.assignment_types_code) OR
455 (p_plan_rec.assignment_types_code = 'EC'
456 and asg.assignment_type IN ('E', 'C')))
457 AND p_effective_date BETWEEN
458 asg.effective_start_date AND asg.effective_end_date
459 AND ((p_plan_rec.primary_asg_only_flag = 'N') OR
460 p_plan_rec.primary_asg_only_flag = 'Y' AND
461 asg.primary_flag = 'Y')
462 AND 'x' = ( select 'x' from per_all_people_f ppf
463 where asg.person_id = ppf.person_id
464 and p_effective_date between ppf.effective_start_date and ppf.effective_end_date
465 and ('Y' = decode( p_plan_rec.assignment_types_code, 'E', ppf.current_employee_flag, 'C',
466 ppf.current_npw_flag, 'EC', (select 'Y' from dual where
467 ppf.current_employee_flag = 'Y' or ppf.current_npw_flag = 'Y') )) )
468 ) o
469 CONNECT BY o.supervisor_id = PRIOR o.person_id
470 AND LEVEL <= NVL(p_plan_rec.hierarchy_levels, LEVEL) + 1
471 START WITH o.person_id = p_plan_rec.supervisor_id;
472
473 -- Supervisor Assignment Hierarchy population
474 -- Includes supervisor assignment and person assignments that are in not more than N level
475 -- below in hierarchy, where N is the value specified in hierarchy level attribute of the plan
476 --
477 CURSOR csr_sup_asg_hier_pop IS
478 SELECT * from
479 (SELECT asg.assignment_id, asg.person_id, asg.business_group_id, asg.supervisor_id,
480 asg.supervisor_assignment_id, asg.organization_id, asg.position_id
481 FROM per_all_assignments_f asg
482 WHERE ((p_plan_rec.assignment_types_code in ('E', 'C')
483 and asg.assignment_type = p_plan_rec.assignment_types_code) OR
484 (p_plan_rec.assignment_types_code = 'EC'
485 and asg.assignment_type IN ('E', 'C')))
486 AND p_effective_date BETWEEN
487 asg.effective_start_date AND asg.effective_end_date
488 AND 'x' = ( select 'x' from per_all_people_f ppf
489 where asg.person_id = ppf.person_id
490 and p_effective_date between ppf.effective_start_date and ppf.effective_end_date
491 and ('Y' = decode( p_plan_rec.assignment_types_code, 'E', ppf.current_employee_flag, 'C',
492 ppf.current_npw_flag, 'EC', (select 'Y' from dual where
493 ppf.current_employee_flag = 'Y' or ppf.current_npw_flag = 'Y') )) )
494 ) o
495 CONNECT BY o.supervisor_assignment_id = PRIOR o.assignment_id
496 AND LEVEL <= NVL(p_plan_rec.hierarchy_levels, LEVEL) + 1
497 START WITH o.assignment_id = p_plan_rec.supervisor_assignment_id;
498
499
500 -- Organization hierarchy population
501 -- Includes assignment where assignment organization is top organization or in next N levels of the plan
502 -- organization hierarchy, where N is the value specified in hierarchy level attribute of the plan
503 --
504 CURSOR csr_org_hier_pop IS
505 SELECT asg.assignment_id, asg.person_id, asg.business_group_id, asg.supervisor_id,
506 asg.supervisor_assignment_id, asg.organization_id, asg.position_id
507 FROM per_all_assignments_f asg
508 WHERE ((p_plan_rec.assignment_types_code in ('E', 'C')
509 and asg.assignment_type = 'E') OR
510 (p_plan_rec.assignment_types_code = 'EC'
511 and asg.assignment_type IN ('E', 'C')))
512 AND p_effective_date BETWEEN
513 asg.effective_start_date AND asg.effective_end_date
514 AND ((p_plan_rec.primary_asg_only_flag = 'N') OR
515 p_plan_rec.primary_asg_only_flag = 'Y' AND
516 asg.primary_flag = 'Y')
517 AND 'x' = ( select 'x' from per_all_people_f ppf
518 where asg.person_id = ppf.person_id
519 and p_effective_date between ppf.effective_start_date and ppf.effective_end_date
520 and ('Y' = decode( p_plan_rec.assignment_types_code, 'E', ppf.current_employee_flag, 'C',
521 ppf.current_npw_flag, 'EC', (select 'Y' from dual where
522 ppf.current_employee_flag = 'Y' or ppf.current_npw_flag = 'Y') )) )
523 AND asg.organization_id in
524 (select o.organization_id_child from
525 (SELECT o.organization_id_child
526 FROM per_org_structure_elements o
527 CONNECT BY o.organization_id_parent = PRIOR o.organization_id_child
528 AND o.org_structure_version_id = PRIOR o.org_structure_version_id
529 AND LEVEL <= NVL(p_plan_rec.hierarchy_levels, LEVEL)
530 START WITH o.organization_id_parent = p_plan_rec.top_organization_id
531 AND o.org_structure_version_id = p_plan_rec.org_structure_version_id
532 UNION
533 SELECT p_plan_rec.top_organization_id organization_id_child from dual) o, hr_organization_units org
534 where o.organization_id_child = org.organization_id
535 and p_effective_date between org.date_from and nvl(org.date_to, p_effective_date));
536
537
538 -- Position Hierarchy population
539 -- Includes assignments whose assignment position is top position or in next N levels of
540 -- plan position hierarchy, where N is the value specified in hierarchy level attribute of the plan
541 --
542 CURSOR csr_pos_hier_pop IS
543 SELECT asg.assignment_id, asg.person_id, asg.business_group_id, asg.supervisor_id,
544 asg.supervisor_assignment_id, asg.organization_id, asg.position_id
545 FROM per_all_assignments_f asg
546 WHERE ((p_plan_rec.assignment_types_code in ('E', 'C')
547 and asg.assignment_type = p_plan_rec.assignment_types_code) OR
548 (p_plan_rec.assignment_types_code = 'EC'
549 and asg.assignment_type IN ('E', 'C')))
550 AND p_effective_date BETWEEN
551 asg.effective_start_date AND asg.effective_end_date
552 AND ((p_plan_rec.primary_asg_only_flag = 'N') OR
553 p_plan_rec.primary_asg_only_flag = 'Y' AND
554 asg.primary_flag = 'Y')
555 AND 'x' = ( select 'x' from per_all_people_f ppf
556 where asg.person_id = ppf.person_id
557 and p_effective_date between ppf.effective_start_date and ppf.effective_end_date
558 and ('Y' = decode( p_plan_rec.assignment_types_code, 'E', ppf.current_employee_flag, 'C',
559 ppf.current_npw_flag, 'EC', (select 'Y' from dual where
560 ppf.current_employee_flag = 'Y' or ppf.current_npw_flag = 'Y') )) )
561 AND ( asg.position_id in
562 (select o.subordinate_position_id from (SELECT p.subordinate_position_id
563 FROM per_pos_structure_elements p
564 CONNECT BY p.parent_position_id = PRIOR p.subordinate_position_id
565 AND p.pos_structure_version_id = PRIOR p.pos_structure_version_id
566 AND LEVEL <= NVL(p_plan_rec.hierarchy_levels, LEVEL)
567 START WITH p.parent_position_id = p_plan_rec.top_position_id
568 AND p.pos_structure_version_id = p_plan_rec.pos_structure_version_id) o, per_positions pos
569 where o.subordinate_position_id = pos.position_id
570 and p_effective_date between pos.date_effective and nvl(pos.date_end,p_effective_date)
571 UNION
572 select p_plan_rec.top_position_id subordinate_position_id from dual));
573
574 CURSOR csr_apprl_periods(p_pln_id per_perf_mgmt_plans.plan_id%TYPE) IS
575 select prds.appraisal_period_id, prds.appraisal_template_id, templ.business_group_id
576 from per_appraisal_periods prds, per_appraisal_templates templ
577 where prds.plan_id = p_pln_id
578 and templ.appraisal_template_id = prds.appraisal_template_id;
579
580 l_last_bg_id per_appraisal_templates.business_group_id%TYPE;
581 l_bg_change boolean default false;
582 l_check_cross_bg_templ boolean default false;
583 l_appr_prds_tbl appr_prds_tbl;
584 e_invl_templ_popl exception;
585
586 Begin
587 --
588 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
589 --
590 g_plan_pop_known_t.delete;
591
592 --
593 -- Check the hierarchy_type and populate the assignment table
594 --
595 IF (p_plan_rec.hierarchy_type_code = 'SUP') THEN
596 --
597 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 20); END IF;
598 --
599 OPEN csr_sup_hier_pop;
600 FETCH csr_sup_hier_pop BULK COLLECT INTO l_temp_pop_tbl;
601 CLOSE csr_sup_hier_pop;
602 --
603 ELSIF (p_plan_rec.hierarchy_type_code = 'SUP_ASG') THEN
604 --
605 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 30); END IF;
606 --
607 OPEN csr_sup_asg_hier_pop;
608 FETCH csr_sup_asg_hier_pop BULK COLLECT INTO l_temp_pop_tbl;
609 CLOSE csr_sup_asg_hier_pop;
610 --
611 ELSIF (p_plan_rec.hierarchy_type_code = 'ORG') THEN
612 --
613 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 40); END IF;
614 --
615 OPEN csr_org_hier_pop;
616 FETCH csr_org_hier_pop BULK COLLECT INTO l_temp_pop_tbl;
617 CLOSE csr_org_hier_pop;
618 --
619 ELSIF (p_plan_rec.hierarchy_type_code = 'POS') THEN
620 --
621 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 50); END IF;
622 --
623 OPEN csr_pos_hier_pop;
624 FETCH csr_pos_hier_pop BULK COLLECT INTO l_temp_pop_tbl;
625 CLOSE csr_pos_hier_pop;
626 --
627 END IF;
628
629 --
630 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 60); END IF;
631 --
632
633
634 OPEN csr_apprl_periods( p_plan_rec.plan_id );
635 FETCH csr_apprl_periods BULK COLLECT INTO l_appr_prds_tbl;
636 CLOSE csr_apprl_periods;
637
638 --
639 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 60); END IF;
640 --
641
642 IF l_appr_prds_tbl.COUNT > 0 THEN
643 FOR i IN l_appr_prds_tbl.FIRST..l_appr_prds_tbl.LAST
644 LOOP
645 IF g_dbg THEN op(' Entered Appraisal Template Local Check ' || l_appr_prds_tbl(i).appraisal_period_id, g_DEBUG_LOG, 60); END IF;
646 IF( l_appr_prds_tbl(i).business_group_id is not null) then
647 l_check_cross_bg_templ := true;
648 EXIT WHEN l_check_cross_bg_templ;
649 END IF;
650 END LOOP;
651 END IF;
652
653 IF l_check_cross_bg_templ THEN
654 IF g_dbg THEN op(' Entered l_check_cross_bg_templ ' , g_DEBUG_LOG, 60); END IF;
655
656 FOR i IN l_temp_pop_tbl.FIRST..l_temp_pop_tbl.LAST
657 LOOP
658 FOR j in l_appr_prds_tbl.FIRST..l_appr_prds_tbl.LAST
659 LOOP
660 IF( l_appr_prds_tbl(j).business_group_id <> l_temp_pop_tbl(i).business_group_id) then
661 l_bg_change := true;
662 IF g_dbg THEN op(' Selected Population is not in Appraisal Template BG ', g_REGULAR_LOG, 90); END IF;
663 IF g_dbg THEN op(' Appraisal Template BG=' || l_appr_prds_tbl(j).business_group_id || ' Person Id=' || l_temp_pop_tbl(i).assignment_id || ' BG=' || l_temp_pop_tbl(i).business_group_id, g_REGULAR_LOG, 90); END IF;
664 EXIT WHEN l_bg_change;
665 END IF;
666 END LOOP;
667
668 IF (not l_bg_change) then
669 IF(i = 1) then
670 l_last_bg_id := l_temp_pop_tbl(i).business_group_id;
671 ELSE
672 IF(l_last_bg_id <> l_temp_pop_tbl(i).business_group_id) then
673 l_bg_change := true;
674 IF g_dbg THEN op(' Population is spanned across Business Groups ' , g_REGULAR_LOG, 90); END IF;
675 EXIT WHEN l_bg_change;
676 ELSE
677 l_last_bg_id := l_temp_pop_tbl(i).business_group_id;
678 END IF;
679 END IF;
680 ELSE
681 EXIT WHEN l_bg_change;
682 END IF;
683 END LOOP;
684 END IF;
685
686
687 IF(l_bg_change) THEN
688 RAISE e_invl_templ_popl;
689 END IF;
690
691 --
692 -- Populate the plan population global cache
693 -- with index as assignment id and other values in respective columns
694 --
695 IF l_temp_pop_tbl.COUNT > 0 THEN
696
697 FOR i IN l_temp_pop_tbl.FIRST..l_temp_pop_tbl.LAST
698 LOOP
699 --
700 IF g_dbg THEN op('Assignment Id = ' || l_temp_pop_tbl(i).assignment_id, g_DEBUG_LOG); END IF;
701 --
702 IF NOT g_qual_pop_tbl.EXISTS(l_temp_pop_tbl(i).assignment_id) THEN
703 g_qual_pop_tbl(l_temp_pop_tbl(i).assignment_id).assignment_id := l_temp_pop_tbl(i).assignment_id;
704 g_qual_pop_tbl(l_temp_pop_tbl(i).assignment_id).person_id := l_temp_pop_tbl(i).person_id;
705 g_qual_pop_tbl(l_temp_pop_tbl(i).assignment_id).business_group_id := l_temp_pop_tbl(i).business_group_id;
706 g_qual_pop_tbl(l_temp_pop_tbl(i).assignment_id).supervisor_id := l_temp_pop_tbl(i).supervisor_id;
707 g_qual_pop_tbl(l_temp_pop_tbl(i).assignment_id).supervisor_assignment_id := l_temp_pop_tbl(i).supervisor_assignment_id;
708 g_qual_pop_tbl(l_temp_pop_tbl(i).assignment_id).organization_id := l_temp_pop_tbl(i).organization_id;
709 g_qual_pop_tbl(l_temp_pop_tbl(i).assignment_id).position_id := l_temp_pop_tbl(i).position_id;
710 END IF;
711 END LOOP;
712 --
713 END IF;
714 --
715 g_plan_pop_known_t(p_plan_rec.plan_id) := TRUE;
716 --
717 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 80); END IF;
718 --
719 exception
720 when e_invl_templ_popl then
721 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
722 fnd_message.set_name('PER','HR_WPM_INVL_TMPL_POPL');
723 g_error_txt := nvl(fnd_message.get, 'HR_WPM_INVL_TMPL_POPL');
724 g_retcode := ERROR;
725 g_errbuf := g_error_txt;
726 RAISE;
727 when others then
728 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 90); END IF;
729 --
730 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
731 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
732 g_retcode := WARNING;
733 g_errbuf := g_cp_error_txt;
734 g_num_errors := g_num_errors + 1;
735 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
736 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
737
738 --
739 -- If the max number of errors has been exceeded, raise the error and
740 -- terminate processing of this plan.
741 --
742 IF g_num_errors > g_max_errors THEN
743 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
744 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
745 g_retcode := ERROR;
746 g_errbuf := g_error_txt;
747 RAISE;
748 END IF;
749
750 End populate_qual_plan_population;
751 --
752 -- ----------------------------------------------------------------------------
753 -- |---------------------< populate_curr_plan_population >---------------------|
754 -- ----------------------------------------------------------------------------
755 -- {Start Of Comments}
756 --
757 -- Description:
758 -- Populate the current plan population and loads in cache(i.e. PLSQL table
759 -- with index as assignment id and other values.
760 --
761 -- Prerequisites:
762 -- None.
763 --
764 -- In Arguments:
765 --
766 --
767 -- Post Success:
768 -- Processing continues on successful population.
769 --
770 -- Post Failure:
771 -- An application error is raised if population fails.
772
773 --
774 -- Access Status:
775 -- Internal Use Only.
776 --
777 -- {End Of Comments}
778 -- ----------------------------------------------------------------------------
779 procedure populate_curr_plan_population
780 (p_plan_id in number
781 ) is
782
783 -- Declare local variables
784 l_proc varchar2(72) := g_package||'populate_curr_plan_population';
785 l_temp_pop_tbl g_curr_sc_pop_t;
786
787 -- Current Plan population
788 CURSOR csr_curr_plan_pop IS
789 select assignment_id, scorecard_id, object_version_number, status_code
790 from per_personal_scorecards
791 where creator_type = 'AUTO'
792 and plan_id = p_plan_id
793 and status_code <> 'TRANSFER_OUT';
794 --
795 Begin
796 --
797 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
798 --
799
800 --
801 -- Get the plan population and populate the current population table
802 --
803 OPEN csr_curr_plan_pop;
804 FETCH csr_curr_plan_pop BULK COLLECT INTO l_temp_pop_tbl;
805 CLOSE csr_curr_plan_pop;
806
807 --
808 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 60); END IF;
809 --
810
811 --
812 -- Populate the plan population global cache
813 -- with index as assignment id and other values in respective columns
814 --
815 IF l_temp_pop_tbl.COUNT > 0 THEN
816
817 FOR i IN l_temp_pop_tbl.FIRST..l_temp_pop_tbl.LAST
818 LOOP
819 --
820 IF g_dbg THEN op('Assignment Id = ' || l_temp_pop_tbl(i).assignment_id, g_DEBUG_LOG); END IF;
821 --
822 IF NOT g_curr_sc_pop_tbl.EXISTS(l_temp_pop_tbl(i).assignment_id) THEN
823 g_curr_sc_pop_tbl(l_temp_pop_tbl(i).assignment_id).assignment_id := l_temp_pop_tbl(i).assignment_id;
824 g_curr_sc_pop_tbl(l_temp_pop_tbl(i).assignment_id).scorecard_id := l_temp_pop_tbl(i).scorecard_id;
825 g_curr_sc_pop_tbl(l_temp_pop_tbl(i).assignment_id).object_version_number := l_temp_pop_tbl(i).object_version_number;
826
827 g_curr_sc_pop_tbl(l_temp_pop_tbl(i).assignment_id).status_code := l_temp_pop_tbl(i).status_code;
828
829 END IF;
830 END LOOP;
831 --
832 END IF;
833
834 --
835 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 80); END IF;
836 --
837 exception
838 when others then
839 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 90); END IF;
840 --
841 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
842 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
843 g_retcode := WARNING;
844 g_errbuf := g_cp_error_txt;
845 g_num_errors := g_num_errors + 1;
846 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
847 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
848
849 --
850 -- If the max number of errors has been exceeded, raise the error and
851 -- terminate processing of this plan.
852 --
853 IF g_num_errors > g_max_errors THEN
854 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
855 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
856 g_retcode := ERROR;
857 g_errbuf := g_error_txt;
858
859 END IF;
860
861 End populate_curr_plan_population;
862 --
863 -- ----------------------------------------------------------------------------
864 -- |-----------------------< populate_qual_objectives >-----------------------|
865 -- ----------------------------------------------------------------------------
866 -- {Start Of Comments}
867 --
868 -- Description:
869 -- Populate the qualifying objectives for a given plan period (i.e. PLSQL table
870 -- with index as assignment id and boolean value.
871 --
872 -- Prerequisites:
873 -- None.
874 --
875 -- In Arguments:
876 --
877 --
878 -- Post Success:
879 -- Processing continues on successful population.
880 --
881 -- Post Failure:
882 -- An application error is raised if population fails.
883
884 --
885 -- Access Status:
886 -- Internal Use Only.
887 --
888 -- {End Of Comments}
889 -- ----------------------------------------------------------------------------
890 procedure populate_qual_objectives
891 (p_start_date in date
892 ,p_end_date in date
893
894 ) is
895
896 -- Declare local variables
897 l_proc varchar2(72) := g_package||'populate_qual_objectives';
898 l_temp_obj_tbl g_qual_obj_t;
899
900
901 -- Current Plan population
902 CURSOR csr_qual_objectives IS
903 select objective_id, objective_name, valid_from, valid_to, target_date, next_review_date, group_code,
904 priority_code, appraise_flag, weighting_percent, target_value, uom_code, measurement_style_code,
905 measure_name, measure_type_code, measure_comments, details, success_criteria, comments,
906 elig.elig_obj_id
907 from per_objectives_library pol,
908 ben_elig_obj_f elig
909 where (pol.valid_from between p_start_date and p_end_date OR
910 p_start_date between pol.valid_from and nvl(pol.valid_to,to_date('31-12-4712', 'DD-MM-YYYY')))
911 and POL.ELIGIBILITY_TYPE_CODE <> 'N_P'
912 and elig.table_name = 'PER_OBJECTIVES_LIBRARY'
913 and column_name = 'OBJECTIVE_ID'
914 and elig.column_value = pol.objective_id;
915
916 Begin
917 --
918 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
919 --
920
921 --
922 -- Get the plan population and populate the qualifying objectives for plan
923 --
924 OPEN csr_qual_objectives;
925 FETCH csr_qual_objectives BULK COLLECT INTO l_temp_obj_tbl;
926 CLOSE csr_qual_objectives;
927
928 --
929 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 20); END IF;
930 --
931
932 --
933 -- Populate the plan population global cache
934 -- with index as library objective id and other values in respective columns
935 --
936 IF l_temp_obj_tbl.COUNT > 0 THEN
937
938 FOR i IN l_temp_obj_tbl.FIRST..l_temp_obj_tbl.LAST
939 LOOP
940 --
941 IF g_dbg THEN op('Objective Id = ' || l_temp_obj_tbl(i).objective_id, g_DEBUG_LOG); END IF;
942 --
943 -- Condition removed for bug no 6875448
944 --IF NOT g_curr_sc_pop_tbl.EXISTS(l_temp_obj_tbl(i).objective_id) THEN
945 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).objective_id := l_temp_obj_tbl(i).objective_id;
946 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).objective_name := l_temp_obj_tbl(i).objective_name;
947 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).valid_from := l_temp_obj_tbl(i).valid_from;
948 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).valid_to := l_temp_obj_tbl(i).valid_to;
949 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).target_date := l_temp_obj_tbl(i).target_date;
950 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).NEXT_review_date := l_temp_obj_tbl(i).NEXT_review_date;
951 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).group_code := l_temp_obj_tbl(i).group_code;
952 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).priority_code := l_temp_obj_tbl(i).priority_code;
953 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).appraise_flag := l_temp_obj_tbl(i).appraise_flag;
954 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).weighting_percent := l_temp_obj_tbl(i).weighting_percent;
955 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).target_value := l_temp_obj_tbl(i).target_value;
956 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).uom_code := l_temp_obj_tbl(i).uom_code;
957 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).measurement_style_code := l_temp_obj_tbl(i).measurement_style_code;
958 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).measure_name := l_temp_obj_tbl(i).measure_name;
959 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).measure_type_code := l_temp_obj_tbl(i).measure_type_code;
960 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).measure_comments := l_temp_obj_tbl(i).measure_comments;
961 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).details := l_temp_obj_tbl(i).details;
962 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).success_criteria := l_temp_obj_tbl(i).success_criteria;
963 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).comments := l_temp_obj_tbl(i).comments;
964 g_qual_obj_tbl(l_temp_obj_tbl(i).objective_id).elig_obj_id := l_temp_obj_tbl(i).elig_obj_id;
965 -- END IF;
966 END LOOP;
967 --
968 END IF;
969
970 --
971 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 80); END IF;
972 --
973 exception
974 when others then
975 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 90); END IF;
976 --
977 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
978 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
979 g_retcode := WARNING;
980 g_errbuf := g_cp_error_txt;
981 g_num_errors := g_num_errors + 1;
982 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
983 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
984
985 --
986 -- If the max number of errors has been exceeded, raise the error and
987 -- terminate processing of this plan.
988 --
989 IF g_num_errors > g_max_errors THEN
990 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
991 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
992 g_retcode := ERROR;
993 g_errbuf := g_error_txt;
994 RAISE;
995 END IF;
996
997 End populate_qual_objectives;
998 --
999 -- ----------------------------------------------------------------------------
1000 -- |---------------------< populate_curr_sc_objectives >----------------------|
1001 -- ----------------------------------------------------------------------------
1002 -- {Start Of Comments}
1003 --
1004 -- Description:
1005 -- Populate the current objectivesfor a gives scorecard (i.e. PLSQL table
1006 -- with index as library objective id and other values.
1007 --
1008 -- Prerequisites:
1009 -- None.
1010 --
1011 -- In Arguments:
1012 --
1013 --
1014 -- Post Success:
1015 -- Processing continues on successful population.
1016 --
1017 -- Post Failure:
1018 -- An application error is raised if population fails.
1019
1020 --
1021 -- Access Status:
1022 -- Internal Use Only.
1023 --
1024 -- {End Of Comments}
1025 -- ----------------------------------------------------------------------------
1026 procedure populate_curr_sc_objectives
1027 (p_scorecard_id in number
1028 ) is
1029
1030 -- Declare local variables
1031 l_proc varchar2(72) := g_package||'populate_curr_sc_objectives';
1032 l_temp_obj_tbl g_curr_sc_obj_t;
1033
1034 -- Current scorecard objectives
1035 CURSOR csr_curr_sc_objs IS
1036 select copied_from_library_id, objective_id, object_version_number
1037 from per_objectives pob
1038 where pob.copied_from_library_id IS NOT NULL
1039 and pob.scorecard_id = p_scorecard_id;
1040 --
1041 Begin
1042 --
1043 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
1044 --
1045
1046 --
1047 -- Initialize the objectivestables that is used for different scorecards in loop
1048 --
1049 -- g_curr_sc_obj_tbl := l_temp_obj_tbl;
1050 g_curr_sc_obj_tbl.DELETE;
1051
1052 --
1053 -- Get the plan population and populate the current scorecard objectives
1054 --
1055 OPEN csr_curr_sc_objs;
1056 FETCH csr_curr_sc_objs BULK COLLECT INTO l_temp_obj_tbl;
1057 CLOSE csr_curr_sc_objs;
1058
1059 --
1060 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 60); END IF;
1061 --
1062
1063 --
1064 -- Populate the plan population global cache
1065 -- with index as library objective id and other values in respective columns
1066 --
1067 IF l_temp_obj_tbl.COUNT > 0 THEN
1068
1069 FOR i IN l_temp_obj_tbl.FIRST..l_temp_obj_tbl.LAST
1070 LOOP
1071 --
1072 IF g_dbg THEN op('Objective Id = ' || l_temp_obj_tbl(i).objective_id, g_DEBUG_LOG); END IF;
1073 --
1074 -- Condition removed for bug no 6875448
1075 --IF NOT g_curr_sc_pop_tbl.EXISTS(l_temp_obj_tbl(i).copied_from_library_id) THEN
1076 g_curr_sc_obj_tbl(l_temp_obj_tbl(i).copied_from_library_id).copied_from_library_id := l_temp_obj_tbl(i).copied_from_library_id;
1077 g_curr_sc_obj_tbl(l_temp_obj_tbl(i).copied_from_library_id).objective_id := l_temp_obj_tbl(i).objective_id;
1078 g_curr_sc_obj_tbl(l_temp_obj_tbl(i).copied_from_library_id).object_version_number := l_temp_obj_tbl(i).object_version_number;
1079 --END IF;
1080 END LOOP;
1081 --
1082 END IF;
1083
1084 --
1085 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 80); END IF;
1086 --
1087 exception
1088 when others then
1089 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 90); END IF;
1090 --
1091 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
1092 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
1093 g_retcode := WARNING;
1094 g_errbuf := g_cp_error_txt;
1095 g_num_errors := g_num_errors + 1;
1096 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
1097 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
1098
1099 --
1100 -- If the max number of errors has been exceeded, raise the error and
1101 -- terminate processing of this plan.
1102 --
1103 IF g_num_errors > g_max_errors THEN
1104 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
1105 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
1106 g_retcode := ERROR;
1107 g_errbuf := g_error_txt;
1108 RAISE;
1109 END IF;
1110
1111 End populate_curr_sc_objectives;
1112 --
1113 -- ----------------------------------------------------------------------------
1114 -- |---------------------< populate_plan_apprsl_periods >---------------------|
1115 -- ----------------------------------------------------------------------------
1116 -- {Start Of Comments}
1117 --
1118 -- Description:
1119 -- Populates the appraisal periods for a given plan.
1120 --
1121 -- Prerequisites:
1122 -- None.
1123 --
1124 -- In Arguments:
1125 --
1126 --
1127 -- Post Success:
1128 -- Processing continues on successful population.
1129 --
1130 -- Post Failure:
1131 -- An application error is raised if population fails.
1132
1133 --
1134 -- Access Status:
1135 -- Internal Use Only.
1136 --
1137 -- {End Of Comments}
1138 -- ----------------------------------------------------------------------------
1139 procedure populate_plan_apprsl_periods
1140 (p_plan_id in number
1141 ) is
1142
1143 -- Declare local variables
1144 l_proc varchar2(72) := g_package||'populate_plan_apprsl_periods';
1145
1146 -- Current scorecard objectives
1147 CURSOR csr_plan_apprsl_pds IS
1148 select appraisal_period_id, appraisal_template_id, start_date, end_date, task_start_date,
1149 task_end_date, initiator_code, appraisal_system_type, auto_conc_process, days_before_task_st_dt,
1150 appraisal_assmt_status, appraisal_type
1151 from per_appraisal_periods pap
1152 where pap.plan_id = p_plan_id;
1153 --
1154 Begin
1155 --
1156 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
1157 --
1158
1159 --
1160 -- Get the plan appraisal periods
1161 --
1162 OPEN csr_plan_apprsl_pds;
1163 FETCH csr_plan_apprsl_pds BULK COLLECT INTO g_plan_aprsl_pds_tbl;
1164 CLOSE csr_plan_apprsl_pds;
1165
1166 --
1167 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 60); END IF;
1168 --
1169
1170 --
1171 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 80); END IF;
1172 --
1173 exception
1174 when others then
1175 IF g_dbg THEN op('Leaving:'|| l_proc, g_REGULAR_LOG, 90); END IF;
1176 --
1177 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
1178 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
1179 g_retcode := WARNING;
1180 g_errbuf := g_cp_error_txt;
1181 g_num_errors := g_num_errors + 1;
1182 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
1183 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
1184
1185 --
1186 -- If the max number of errors has been exceeded, raise the error and
1187 -- terminate processing of this plan.
1188 --
1189 IF g_num_errors > g_max_errors THEN
1190 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
1191 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
1192 g_retcode := ERROR;
1193 g_errbuf := g_error_txt;
1194 RAISE;
1195 END IF;
1196
1197 End populate_plan_apprsl_periods;
1198 --
1199 -- ----------------------------------------------------------------------------
1200 -- |----------------------< create_scorecard_for_person >---------------------|
1201 -- ----------------------------------------------------------------------------
1202 -- {Start Of Comments}
1203 --
1204 -- Description:
1205 -- Creates scorecard for a given person when plan is published.
1206 --
1207 -- Prerequisites:
1208 -- None.
1209 --
1210 -- In Arguments:
1211 --
1212 --
1213 -- Post Success:
1214 -- Processing continues if scorecard is created.
1215 --
1216 -- Post Failure:
1217 -- An application error is raised if scorecard is not created.
1218 --
1219 -- Access Status:
1220 -- Internal Only.
1221 --
1222 -- {End Of Comments}
1223 -- ----------------------------------------------------------------------------
1224 procedure create_scorecard_for_person
1225 (p_effective_date in date
1226 ,p_scorecard_name in varchar2
1227 ,p_assignment_id in number
1228 ,p_start_date in date
1229 ,p_end_date in date
1230 ,p_plan_id in number
1231 ,p_creator_type in varchar2
1232 ,p_status_code in varchar2
1233 ,p_scorecard_id out nocopy number
1234 ) is
1235
1236 -- Declare local variables
1237 l_proc varchar2(72) := g_package||'create_scorecard_for_person';
1238 --
1239 l_scorecard_id number;
1240 l_object_version_number number;
1241 --l_status_code varchar2(30);
1242 l_duplicate_name_warning boolean;
1243 --
1244 Begin
1245 --
1246 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
1247 --
1248
1249 --
1250 -- Call create_scorecard
1251 --
1252 hr_personal_scorecard_api.create_scorecard(
1253 p_effective_date => p_effective_date
1254 ,p_scorecard_name => p_scorecard_name
1255 ,p_assignment_id => p_assignment_id
1256 ,p_start_date => p_start_date
1257 ,p_end_date => p_end_date
1258 ,p_plan_id => p_plan_id
1259 ,p_creator_type => p_creator_type
1260 ,p_scorecard_id => l_scorecard_id
1261 ,p_object_version_number => l_object_version_number
1262 ,p_status_code => p_status_code
1263 ,p_duplicate_name_warning => l_duplicate_name_warning
1264 );
1265
1266 -- Out parameter
1267 p_scorecard_id := l_scorecard_id;
1268 IF g_dbg THEN op('Scorecard Id = ' || l_scorecard_id, g_DEBUG_LOG); END IF;
1269
1270 --
1271 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
1272 --
1273 exception
1274 when others then
1275 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
1276 --
1277 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
1278 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
1279 g_retcode := WARNING;
1280 g_errbuf := g_cp_error_txt;
1281 g_num_errors := g_num_errors + 1;
1282 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
1283 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
1284
1285 --
1286 -- If the max number of errors has been exceeded, raise the error and
1287 -- terminate processing of this plan.
1288 --
1289 IF g_num_errors > g_max_errors THEN
1290 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
1291 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
1292 g_retcode := ERROR;
1293 g_errbuf := g_error_txt;
1294 RAISE;
1295 END IF;
1296
1297 End create_scorecard_for_person;
1298 --
1299 -- ----------------------------------------------------------------------------
1300 -- |----------------------< update_scorecard_for_person >---------------------|
1301 -- ----------------------------------------------------------------------------
1302 -- {Start Of Comments}
1303 --
1304 -- Description:
1305 -- Updates the given scorecard when plan is republished.
1306 --
1307 -- Prerequisites:
1308 -- None.
1309 --
1310 -- In Arguments:
1311 --
1312 --
1313 -- Post Success:
1314 -- Processing continues if scorecard is updated.
1315 --
1316 -- Post Failure:
1317 -- An application error is raised if scorecard is not updated.
1318 --
1319 -- Access Status:
1320 -- Internal Only.
1321 --
1322 -- {End Of Comments}
1323 -- ----------------------------------------------------------------------------
1324 procedure update_scorecard_for_person
1325 (p_effective_date in date
1326 ,p_scorecard_id in number
1327 ,p_object_version_number in number
1328 ,p_scorecard_name in varchar2 default hr_api.g_varchar2
1329 ,p_start_date in date default hr_api.g_date
1330 ,p_end_date in date default hr_api.g_date
1331 ,p_status_code in varchar2 default hr_api.g_varchar2
1332 ) is
1333
1334 -- Declare local variables
1335 l_proc varchar2(72) := g_package||'update_scorecard_for_person';
1336 --
1337 l_duplicate_name_warning boolean;
1338 l_object_version_number number := p_object_version_number;
1339 --
1340 Begin
1341 --
1342 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
1343 --
1344
1345 --
1346 -- Call update_scorecard
1347 --
1348 hr_personal_scorecard_api.update_scorecard(
1349 p_effective_date => p_effective_date
1350 ,p_scorecard_id => p_scorecard_id
1351 ,p_object_version_number => l_object_version_number
1352 ,p_scorecard_name => p_scorecard_name
1353 ,p_start_date => p_start_date
1354 ,p_end_date => p_end_date
1355 ,p_status_code => p_status_code
1356 ,p_duplicate_name_warning => l_duplicate_name_warning
1357 );
1358
1359 --
1360 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
1361 --
1362 exception
1363 when others then
1364 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
1365 --
1366 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
1367 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
1368 g_retcode := WARNING;
1369 g_errbuf := g_cp_error_txt;
1370 g_num_errors := g_num_errors + 1;
1371 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
1372 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
1373
1374 --
1375 -- If the max number of errors has been exceeded, raise the error and
1376 -- terminate processing of this plan.
1377 --
1378 IF g_num_errors > g_max_errors THEN
1379 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
1380 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
1381 g_retcode := ERROR;
1382 g_errbuf := g_error_txt;
1383 RAISE;
1384 END IF;
1385
1386 End update_scorecard_for_person;
1387 --
1388 -- ----------------------------------------------------------------------------
1389 -- |----------------------< delete_scorecard_for_person >---------------------|
1390 -- ----------------------------------------------------------------------------
1391 -- {Start Of Comments}
1392 --
1393 -- Description:
1394 -- Delete the given scorecard.
1395 --
1396 -- Prerequisites:
1397 -- None.
1398 --
1399 -- In Arguments:
1400 --
1401 --
1402 -- Post Success:
1403 -- Processing continues if scorecard is deleted.
1404 --
1405 -- Post Failure:
1406 -- An application error is raised if scorecard is not deleted.
1407 --
1408 -- Access Status:
1409 -- Internal Only.
1410 --
1411 -- {End Of Comments}
1412 -- ----------------------------------------------------------------------------
1413 procedure delete_scorecard_for_person
1414 (p_scorecard_id in number
1415 ,p_object_version_number in number
1416 ) is
1417
1418 -- Declare local variables
1419 l_proc varchar2(72) := g_package||'delete_scorecard_for_person';
1420 --
1421 l_created_by_plan_warning boolean;
1422
1423 Begin
1424 --
1425 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
1426 --
1427
1428 --
1429 -- Call update_scorecard
1430 --
1431 hr_personal_scorecard_api.delete_scorecard(
1432 p_scorecard_id => p_scorecard_id
1433 ,p_object_version_number => p_object_version_number
1434 ,p_created_by_plan_warning => l_created_by_plan_warning
1435 );
1436
1437 --
1438 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
1439 --
1440 exception
1441 when others then
1442 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
1443 --
1444 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
1445 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
1446 g_retcode := WARNING;
1447 g_errbuf := g_cp_error_txt;
1448 g_num_errors := g_num_errors + 1;
1449 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
1450 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
1451
1452 --
1453 -- If the max number of errors has been exceeded, raise the error and
1454 -- terminate processing of this plan.
1455 --
1456 IF g_num_errors > g_max_errors THEN
1457 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
1458 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
1459 g_retcode := ERROR;
1460 g_errbuf := g_error_txt;
1461 RAISE;
1462 END IF;
1463
1464 End delete_scorecard_for_person;
1465 --
1466 -- ----------------------------------------------------------------------------
1467 -- |-------------------------< create_scorecard_objective >------------------|
1468 -- ----------------------------------------------------------------------------
1469 -- {Start Of Comments}
1470 --
1471 -- Description:
1472 -- Creates objective for a given scorecard when plan is published.
1473 --
1474 -- Prerequisites:
1475 -- None.
1476 --
1477 -- In Arguments:
1478 --
1479 --
1480 -- Post Success:
1481 -- Processing continues if objective is created.
1482 --
1483 -- Post Failure:
1484 -- An application error is raised if objective is not created.
1485 --
1486 -- Access Status:
1487 -- Internal Only.
1488 --
1489 -- {End Of Comments}
1490 -- ----------------------------------------------------------------------------
1491 procedure create_scorecard_objective
1492 (p_effective_date in date
1493 ,p_business_group_id in number
1494 ,p_person_id in number
1495 ,p_scorecard_id in number
1496 ,p_start_date in date
1497 ,p_end_date in date
1498 ,p_objective_name in varchar2
1499 ,p_valid_from in date
1500 ,p_valid_to in date
1501 ,p_target_date in date
1502 ,p_copied_from_library_id in number
1503 ,p_next_review_date in date
1504 ,p_group_code in varchar2
1505 ,p_priority_code in varchar2
1506 ,p_appraise_flag in varchar2
1507 ,p_weighting_percent in number
1508 ,p_target_value in number
1509 ,p_uom_code in varchar2
1510 ,p_measurement_style_code in varchar2
1511 ,p_measure_name in varchar2
1512 ,p_measure_type_code in varchar2
1513 ,p_measure_comments in varchar2
1514 ,p_details in varchar2
1515 ,p_success_criteria in varchar2
1516 ,p_comments in varchar2
1517 )
1518 is
1519
1520 -- Declare local variables
1521 l_proc varchar2(72) := g_package||'create_scorecard_objective';
1522 --
1523 l_objective_id number;
1524 l_object_version_number number;
1525 l_duplicate_name_warning boolean := false;
1526 l_comb_weight_over_100_warning boolean := false;
1527 l_weighting_appraisal_warning boolean := false;
1528 l_pc_v_act_mismatch_warning boolean := false;
1529 l_quant_met_not_pc_warning boolean := false;
1530 l_qual_met_not_pc_warning boolean := false;
1531 --
1532 l_start_date date;
1533 l_target_date date;
1534 l_next_review_date date;
1535 --
1536 Begin
1537 --
1538 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
1539 --
1540
1541 --
1542 -- Derive objective target date p_target_date < p_start date is added to fix 5233771
1543 --
1544 IF (p_target_date IS NULL OR p_target_date > p_end_date OR p_target_date < p_start_date) THEN
1545 l_target_date := p_end_date;
1546 ELSE
1547 l_target_date := p_target_date;
1548 END IF;
1549
1550 -- while fixing 5233771, following is added to be in synch with Duncans mail
1551 -- and the same is incorporated in copy functionality from ui
1552 -- Derive Next review date
1553 --
1554 IF (p_next_review_date IS NULL OR p_next_review_date > p_end_date OR p_next_review_date < p_start_date) THEN
1555 l_next_review_date := null;
1556 ELSE
1557 l_next_review_date := p_next_review_date;
1558 END IF;
1559
1560 --
1561 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 20); END IF;
1562 --
1563
1564 --
1565 -- Call create_objective
1566 --
1567 hr_objectives_api.create_objective(
1568 p_effective_date => p_effective_date
1569 ,p_business_group_id => p_business_group_id
1570 -- below param value is changed to -3 as per requirement.
1571 ,p_owning_person_id => -3 --p_person_id
1572 ,p_scorecard_id => p_scorecard_id
1573 ,p_start_date => p_start_date
1574 ,p_name => p_objective_name
1575 ,p_target_date => l_target_date
1576 ,p_copied_from_library_id => p_copied_from_library_id
1577 ,p_next_review_date => l_next_review_date
1578 ,p_group_code => p_group_code
1579 ,p_priority_code => p_priority_code
1580 ,p_appraise_flag => p_appraise_flag
1581 ,p_weighting_percent => p_weighting_percent
1582 ,p_target_value => p_target_value
1583 ,p_uom_code => p_uom_code
1584 ,p_measurement_style_code => p_measurement_style_code
1585 ,p_measure_name => p_measure_name
1586 ,p_measure_type_code => p_measure_type_code
1587 ,p_measure_comments => p_measure_comments
1588 ,p_detail => p_details
1589 ,p_comments => p_comments
1590 ,p_success_criteria => p_success_criteria
1591 ,p_objective_id => l_objective_id
1592 ,p_object_version_number => l_object_version_number
1593 -- ,p_duplicate_name_warning => l_duplicate_name_warning
1594 ,p_weighting_over_100_warning => l_comb_weight_over_100_warning
1595 -- ,p_comb_weight_over_100_warning => l_comb_weight_over_100_warning
1596 ,p_weighting_appraisal_warning => l_weighting_appraisal_warning
1597 -- ,p_pc_v_act_mismatch_warning => l_pc_v_act_mismatch_warning
1598 -- ,p_quant_met_not_pc_warning => l_quant_met_not_pc_warning
1599 -- ,p_qual_met_not_pc_warning => l_qual_met_not_pc_warning
1600 );
1601
1602 --
1603 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
1604 --
1605 exception
1606 when others then
1607 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
1608 --
1609 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
1610 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
1611 g_retcode := WARNING;
1612 g_errbuf := g_cp_error_txt;
1613 g_num_errors := g_num_errors + 1;
1614 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
1615 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
1616
1617 --
1618 -- If the max number of errors has been exceeded, raise the error and
1619 -- terminate processing of this plan.
1620 --
1621 IF g_num_errors > g_max_errors THEN
1622 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
1623 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
1624 g_retcode := ERROR;
1625 g_errbuf := g_error_txt;
1626 RAISE;
1627 END IF;
1628
1629 End create_scorecard_objective;
1630 --
1631 -- ----------------------------------------------------------------------------
1632 -- |----------------------< update_scorecard_objective >----------------------|
1633 -- ----------------------------------------------------------------------------
1634 -- {Start Of Comments}
1635 --
1636 -- Description:
1637 -- Updates objective for a given scorecard when plan is republished.
1638 --
1639 -- Prerequisites:
1640 -- None.
1641 --
1642 -- In Arguments:
1643 --
1644 --
1645 -- Post Success:
1646 -- Processing continues if objective is updated.
1647 --
1648 -- Post Failure:
1649 -- An application error is raised if objective is not updated.
1650 --
1651 -- Access Status:
1652 -- Internal Only.
1653 --
1654 -- {End Of Comments}
1655 -- ----------------------------------------------------------------------------
1656 procedure update_scorecard_objective
1657 (p_effective_date in date
1658 ,p_objective_id in number
1659 ,p_object_version_number in number
1660 ,p_scorecard_id in number default hr_api.g_number
1661 ,p_start_date in date default hr_api.g_date
1662 ,p_end_date in date default hr_api.g_date
1663 ,p_objective_name in varchar2 default hr_api.g_varchar2
1664 ,p_valid_from in date default hr_api.g_date
1665 ,p_valid_to in date default hr_api.g_date
1666 ,p_target_date in date default hr_api.g_date
1667 ,p_copied_from_library_id in number default hr_api.g_number
1668 ,p_next_review_date in date default hr_api.g_date
1669 ,p_group_code in varchar2 default hr_api.g_varchar2
1670 ,p_priority_code in varchar2 default hr_api.g_varchar2
1671 ,p_appraise_flag in varchar2 default hr_api.g_varchar2
1672 ,p_weighting_percent in number default hr_api.g_number
1673 ,p_target_value in number default hr_api.g_number
1674 ,p_uom_code in varchar2 default hr_api.g_varchar2
1675 ,p_measurement_style_code in varchar2 default hr_api.g_varchar2
1676 ,p_measure_name in varchar2 default hr_api.g_varchar2
1677 ,p_measure_type_code in varchar2 default hr_api.g_varchar2
1678 ,p_measure_comments in varchar2 default hr_api.g_varchar2
1679 ,p_details in varchar2 default hr_api.g_varchar2
1680 ,p_success_criteria in varchar2 default hr_api.g_varchar2
1681 ,p_comments in varchar2 default hr_api.g_varchar2
1682 )
1683 is
1684
1685 -- Declare local variables
1686 l_proc varchar2(72) := g_package||'update_scorecard_objective';
1687 --
1688 l_object_version_number number := p_object_version_number;
1689 l_duplicate_name_warning boolean := false;
1690 l_comb_weight_over_100_warning boolean := false;
1691 l_weighting_appraisal_warning boolean := false;
1692 l_pc_v_act_mismatch_warning boolean := false;
1693 l_quant_met_not_pc_warning boolean := false;
1694 l_qual_met_not_pc_warning boolean := false;
1695 --
1696 l_start_date date;
1697 l_target_date date;
1698 l_next_review_date date;
1699 --
1700 Begin
1701 --
1702 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
1703 --
1704 --
1705 -- Derive objective target date p_target_date < p_start date is added to fix 5233771
1706 --
1707 IF (p_target_date IS NULL OR p_target_date > p_end_date OR p_target_date < p_start_date) THEN
1708 l_target_date := p_end_date;
1709 ELSE
1710 l_target_date := p_target_date;
1711 END IF;
1712
1713 -- while fixing 5233771, following is added to be in synch with Duncans mail
1714 -- and the same is incorporated in copy functionality from ui
1715 -- Derive Next review date
1716 --
1717 IF (p_next_review_date IS NULL OR p_next_review_date > p_end_date OR p_next_review_date < p_start_date) THEN
1718 l_next_review_date := null;
1719 ELSE
1720 l_next_review_date := p_next_review_date;
1721 END IF;
1722 --
1723 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 20); END IF;
1724 --
1725
1726 --
1727 -- Call update_objective
1728 --
1729 hr_objectives_api.update_objective(
1730 p_effective_date => p_effective_date
1731 ,p_objective_id => p_objective_id
1732 ,p_object_version_number => l_object_version_number
1733 ,p_scorecard_id => p_scorecard_id
1734 ,p_start_date => p_start_date
1735 ,p_name => p_objective_name
1736 ,p_target_date => l_target_date
1737 ,p_copied_from_library_id => p_copied_from_library_id
1738 ,p_next_review_date => l_next_review_date
1739 ,p_group_code => p_group_code
1740 ,p_priority_code => p_priority_code
1741 ,p_appraise_flag => p_appraise_flag
1742 ,p_weighting_percent => p_weighting_percent
1743 ,p_target_value => p_target_value
1744 ,p_uom_code => p_uom_code
1745 ,p_measurement_style_code => p_measurement_style_code
1746 ,p_measure_name => p_measure_name
1747 ,p_measure_type_code => p_measure_type_code
1748 ,p_measure_comments => p_measure_comments
1749 ,p_detail => p_details
1750 ,p_comments => p_comments
1751 ,p_success_criteria => p_success_criteria
1752 -- ,p_duplicate_name_warning => l_duplicate_name_warning
1753 ,p_weighting_over_100_warning => l_comb_weight_over_100_warning
1754 -- ,p_comb_weight_over_100_warning => l_comb_weight_over_100_warning
1755 ,p_weighting_appraisal_warning => l_weighting_appraisal_warning
1756 -- ,p_pc_v_act_mismatch_warning => l_pc_v_act_mismatch_warning
1757 -- ,p_quant_met_not_pc_warning => l_quant_met_not_pc_warning
1758 -- ,p_qual_met_not_pc_warning => l_qual_met_not_pc_warning
1759 );
1760
1761 --
1762 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
1763 --
1764 exception
1765 when others then
1766 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
1767 --
1768 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
1769 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
1770 g_retcode := WARNING;
1771 g_errbuf := g_cp_error_txt;
1772 g_num_errors := g_num_errors + 1;
1773 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
1774 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
1775
1776 --
1777 -- If the max number of errors has been exceeded, raise the error and
1778 -- terminate processing of this plan.
1779 --
1780 IF g_num_errors > g_max_errors THEN
1781 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
1782 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
1783 g_retcode := ERROR;
1784 g_errbuf := g_error_txt;
1785 RAISE;
1786 END IF;
1787
1788 End update_scorecard_objective;
1789 --
1790 -- ----------------------------------------------------------------------------
1791 -- |----------------------< delete_scorecard_objective >---------------------|
1792 -- ----------------------------------------------------------------------------
1793 -- {Start Of Comments}
1794 --
1795 -- Description:
1796 -- Deletes a given objective.
1797 --
1798 -- Prerequisites:
1799 -- None.
1800 --
1801 -- In Arguments:
1802 --
1803 --
1804 -- Post Success:
1805 -- Processing continues if objective is deleted.
1806 --
1807 -- Post Failure:
1808 -- An application error is raised if objective is not deleted.
1809 --
1810 -- Access Status:
1811 -- Internal Only.
1812 --
1813 -- {End Of Comments}
1814 -- ----------------------------------------------------------------------------
1815 procedure delete_scorecard_objective
1816 (p_objective_id in number
1817 ,p_object_version_number in number
1818 )
1819 is
1820
1821 -- Declare local variables
1822 l_proc varchar2(72) := g_package||'delete_scorecard_objective';
1823 --
1824 Begin
1825 --
1826 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
1827 --
1828
1829 --
1830 -- Call delete_objective
1831 --
1832 hr_objectives_api.delete_objective(
1833 p_objective_id => p_objective_id
1834 ,p_object_version_number => p_object_version_number
1835 );
1836
1837 --
1838 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
1839 --
1840 exception
1841 when others then
1842 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
1843 --
1844 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
1845 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
1846 g_retcode := WARNING;
1847 g_errbuf := g_cp_error_txt;
1848 g_num_errors := g_num_errors + 1;
1849 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
1850 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
1851
1852 --
1853 -- If the max number of errors has been exceeded, raise the error and
1854 -- terminate processing of this plan.
1855 --
1856 IF g_num_errors > g_max_errors THEN
1857 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
1858 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
1859 g_retcode := ERROR;
1860 g_errbuf := g_error_txt;
1861 RAISE;
1862 END IF;
1863 End delete_scorecard_objective;
1864
1865 function get_appraisal_config_params(p_appr_initiator_code in per_appraisal_periods.initiator_code%TYPE,
1866 p_function_id in out nocopy fnd_form_functions.function_id%TYPE,
1867 p_function_name in out nocopy fnd_form_functions.function_name%TYPE,
1868 p_func_parameters in out nocopy fnd_form_functions.parameters%TYPE,
1869 p_appraisal_sys_type in out nocopy per_appraisals.appraisal_system_status%TYPE
1870 )
1871 return boolean
1872 is
1873 l_resp_id number;
1874 l_appraisal_mgr_menu fnd_menus.menu_name%TYPE default null;
1875 l_appraisal_empl_menu fnd_menus.menu_name%TYPE default null;
1876 l_selected_menu fnd_menus.menu_name%TYPE default null;
1877 l_function_id fnd_form_functions.function_id%TYPE;
1878 l_function_name fnd_form_functions.function_name%TYPE;
1879 l_initiation_type varchar2(10) default null;
1880 l_func_params fnd_form_functions.parameters%TYPE;
1881 l_system_type varchar2(50);
1882 l_menu_id fnd_menus.menu_id%TYPE;
1883
1884
1885 cursor get_appraisal_function(p_menu_name fnd_menus.menu_name%TYPE, p_search_func varchar2)
1886 is
1887 select menu_functions.function_id, ff.function_name, ff.parameters, menu_id from FND_COMPILED_MENU_FUNCTIONS menu_functions, fnd_form_functions ff
1888 where menu_id = (select menu_id from fnd_menus where menu_name = p_menu_name)
1889 and ff.function_id = menu_functions.function_id
1890 and ff.parameters like p_search_func;
1891
1892 begin
1893 -- to be derived from plan id
1894
1895 /*
1896 fnd_global.apps_initialize(user_id =>1922,
1897 resp_id =>21540,
1898 resp_appl_id=> 800);
1899 */
1900
1901 IF g_dbg THEN op('p_appr_initiator_code = ' || p_appr_initiator_code, g_DEBUG_LOG); END IF;
1902 IF g_dbg THEN op('login person = ' || fnd_global.user_id, g_DEBUG_LOG); END IF;
1903 IF g_dbg THEN op('login name = ' || fnd_global.user_name, g_DEBUG_LOG); END IF;
1904 IF g_dbg THEN op('resp id = ' || fnd_global.resp_id, g_DEBUG_LOG); END IF;
1905
1906
1907 l_initiation_type := 'MGR';
1908 l_resp_id := fnd_global.resp_id;
1909 l_appraisal_mgr_menu := fnd_profile.value_specific(name => 'HR_MANAGER_APPRAISALS_MENU',
1910 responsibility_id => l_resp_id);
1911
1912 IF g_dbg THEN op('MGR MENU = ' || fnd_profile.value('HR_MANAGER_APPRAISALS_MENU'), g_DEBUG_LOG); END IF;
1913 IF g_dbg THEN op('EMP MENU = ' || fnd_profile.value('HR_WORKER_APPRAISALS_MENU'), g_DEBUG_LOG); END IF;
1914
1915
1916 IF g_dbg THEN op('l_appraisal_mgr_menu = ' || l_appraisal_mgr_menu, g_DEBUG_LOG); END IF;
1917
1918 l_appraisal_empl_menu := fnd_profile.value_specific(name => 'HR_WORKER_APPRAISALS_MENU',
1919 responsibility_id => l_resp_id);
1920 IF g_dbg THEN op('l_appraisal_empl_menu = ' || l_appraisal_empl_menu, g_DEBUG_LOG); END IF;
1921
1922
1923 if ( p_appr_initiator_code = 'MGR' and l_appraisal_mgr_menu is not null ) then
1924 l_selected_menu := l_appraisal_mgr_menu;
1925 p_appraisal_sys_type := p_appr_initiator_code || p_appraisal_sys_type;
1926 l_system_type := '%' || p_appr_initiator_code || p_appraisal_sys_type ||'%';
1927 elsif ( p_appr_initiator_code = 'EMP' and l_appraisal_empl_menu is not null ) then
1928 l_selected_menu := l_appraisal_empl_menu;
1929 p_appraisal_sys_type := p_appr_initiator_code || p_appraisal_sys_type;
1930 l_system_type := '%' || p_appr_initiator_code || p_appraisal_sys_type || '%';
1931 end if;
1932
1933 IF g_dbg THEN op('l_selected_menu = ' || l_selected_menu, g_DEBUG_LOG); END IF;
1934
1935 open get_appraisal_function(l_selected_menu, l_system_type);
1936 fetch get_appraisal_function into l_function_id, l_function_name, l_func_params,l_menu_id;
1937 if get_appraisal_function%NOTFOUND then
1938 return false;
1939 else
1940 p_function_id := l_function_id;
1941 p_function_name := l_function_name;
1942 p_func_parameters := l_func_params||'&'||'pFunctionId='||l_function_id||'&'||'pMenuId='||l_menu_id||'&'||'OAFunc='||l_function_name;
1943 end if;
1944
1945 IF g_dbg THEN op('l_function_id = ' || l_function_id, g_DEBUG_LOG); END IF;
1946 IF g_dbg THEN op('l_function_name = ' || l_function_name, g_DEBUG_LOG); END IF;
1947
1948
1949 return true;
1950
1951 exception when others then
1952 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
1953
1954 raise;
1955 end;
1956
1957
1958
1959 procedure apply_overridding_rules(
1960 p_enterprise_id in number
1961 ,p_organization_id in number
1962 ,p_job_id in number
1963 ,p_position_id in number
1964 ,p_skip_duplicate boolean
1965 ,l_sel_comp_table in out nocopy sel_comp_tab
1966 )
1967 is
1968 cursor get_asgn_req_comps(enterprise_id number,
1969 org_id number,
1970 job_id number,
1971 pos_id number
1972 )
1973 is
1974 SELECT pc.name competence_name,
1975 pce.competence_id,
1976 pce.competence_element_id,
1977 pce.mandatory,
1978 pce.proficiency_level_id,
1979 pce.high_proficiency_level_id,
1980 pce.organization_id,
1981 nvl(pce.job_id, -1) job_id,
1982 nvl(pce.position_id, -1) position_id,
1983 pce.valid_grade_id,
1984 nvl(pce.business_group_id, -1) business_group_id,
1985 pce.enterprise_id,
1986 hrl.meaning structure_type,
1987 decode(job_id, null, decode(position_id, null, 1, 0), 0) read_only_attr,
1988 0 detail_attr,
1989 pc.competence_alias,
1990 decode(pc.business_group_id, null, 'Y', 'N') global,
1991 pc.description,
1992 pc.date_from,
1993 pc.certification_required,
1994 pc.behavioural_indicator,
1995 r1.step_value low_step_value,
1996 r1.name low_step_name,
1997 r2.step_value high_step_value,
1998 r2.name high_step_name,
1999 hrl.lookup_code,
2000 decode(r1.step_value, null, null, r1.step_value||' - '||r1.name) minimum_proficiency,
2001 decode(r2.step_value, null, null, r2.step_value||' - '||r2.name) maximum_proficiency,
2002 pce.type
2003 FROM per_competence_elements pce,
2004 per_competences_vl pc,
2005 hr_lookups hrl,
2006 per_rating_levels_vl r1,
2007 per_rating_levels_vl r2
2008 WHERE pce.type = 'REQUIREMENT'
2009 AND pce.competence_id = pc.competence_id
2010 AND trunc(sysdate) between nvl(pce.effective_date_from, trunc(sysdate))
2011 and nvl(pce.effective_date_to, trunc(sysdate))
2012 AND hrl.lookup_type (+) = 'STRUCTURE_TYPE'
2013 AND hrl.lookup_code (+) = decode(pce.organization_id, null, (decode(pce.job_id, null, (decode(pce.position_id, null, 'BUS', 'POS')), 'JOB')), 'ORG')
2014 AND pce.proficiency_level_id = r1.rating_level_id(+)
2015 AND pce.high_proficiency_level_id = r2.rating_level_id(+)
2016 AND pce.business_group_id = enterprise_id
2017 and( pce.enterprise_id = nvl(enterprise_id, -1) or pce.organization_id = nvl(org_id, -1) or pce.job_id = nvl(job_id, -1) or pce.position_id = nvl(pos_id,-1) );
2018
2019 l_mat_comp_table sel_comp_tab;
2020
2021 I integer default 0;
2022
2023 isSameCompetence boolean default false;
2024 isSameStructureType boolean default false;
2025 isIgnore boolean default false;
2026 isBEssential boolean default false;
2027 isBDesired boolean default false;
2028 markOuterRowForIgnore boolean;
2029 isEssentialDesired boolean;
2030
2031 begin
2032
2033 IF g_dbg THEN op('p_enterprise_id = ' ||p_enterprise_id, g_DEBUG_LOG); END IF;
2034 IF g_dbg THEN op('p_organization_id = ' ||p_organization_id, g_DEBUG_LOG); END IF;
2035 IF g_dbg THEN op('p_job_id = ' ||p_job_id, g_DEBUG_LOG); END IF;
2036 IF g_dbg THEN op('p_position_id = ' ||p_position_id, g_DEBUG_LOG); END IF;
2037
2038 OPEN get_asgn_req_comps(p_enterprise_id, p_organization_id, p_job_id, p_position_id);
2039 FETCH get_asgn_req_comps BULK COLLECT INTO l_sel_comp_table;
2040 CLOSE get_asgn_req_comps;
2041
2042 l_mat_comp_table := l_sel_comp_table;
2043
2044 -- execute the cursor and apply the overriding rules
2045 FOR J IN 1 ..l_sel_comp_table.count LOOP
2046 markOuterRowForIgnore := false;
2047 FOR K IN 1 ..l_mat_comp_table.count LOOP
2048 BEGIN
2049 isSameCompetence := (l_sel_comp_table(J).competence_id = l_mat_comp_table(K).competence_id);
2050 isSameStructureType := (l_sel_comp_table(J).lookup_code = l_mat_comp_table(K).lookup_code);
2051 isIgnore := ('I' = l_mat_comp_table(K).mandatory);
2052
2053 if(not isIgnore and isSameCompetence and not isSameStructureType)
2054 then
2055
2056 if('POS' = l_mat_comp_table(K).lookup_code) then
2057 markOuterRowForIgnore := true;
2058 goto end_block;
2059 end if;
2060
2061 if( ('POS' = l_sel_comp_table(J).lookup_code) and (not 'POS' = l_mat_comp_table(K).lookup_code)) then
2062 l_mat_comp_table(K).mandatory := 'I';
2063 goto end_block;
2064 end if;
2065
2066 isBEssential := ('Y' = l_mat_comp_table(K).mandatory and
2067 'Y' = l_sel_comp_table(J).mandatory);
2068 isBDesired := ('N' = l_mat_comp_table(K).mandatory and
2069 'N' = l_sel_comp_table(J).mandatory);
2070
2071 if(isBEssential and 'ORG' = l_sel_comp_table(J).lookup_code and
2072 'JOB' = l_mat_comp_table(K).lookup_code)
2073 then
2074 l_mat_comp_table(K).mandatory := 'I';
2075 goto end_block;
2076 end if;
2077
2078 if(isBEssential and 'JOB' = l_sel_comp_table(J).lookup_code and
2079 'ORG' = l_mat_comp_table(K).lookup_code)
2080 then
2081 markOuterRowForIgnore := true;
2082 goto end_block;
2083 end if;
2084
2085 if(isBDesired and (('ORG' = l_sel_comp_table(J).lookup_code and
2086 'JOB' = l_mat_comp_table(K).lookup_code) or
2087 ('JOB' = l_sel_comp_table(J).lookup_code and
2088 'ORG' = l_mat_comp_table(K).lookup_code)) )
2089 then
2090
2091 if((l_mat_comp_table(K).low_step_value is not null) and (l_sel_comp_table(J).low_step_value is not null))
2092 then
2093 --fix for bug 3063145.
2094 if(l_mat_comp_table(K).low_step_value >= l_sel_comp_table(J).low_step_value)
2095 then
2096 l_sel_comp_table(J).low_step_value := l_mat_comp_table(K).low_step_value;
2097 l_mat_comp_table(K).mandatory := 'I';
2098 end if;
2099 elsif(l_mat_comp_table(K).low_step_value is not null and l_sel_comp_table(J).low_step_value is null ) then
2100 l_sel_comp_table(J).low_step_value := l_mat_comp_table(K).low_step_value;
2101 l_mat_comp_table(K).mandatory := 'I';
2102 else
2103 l_mat_comp_table(K).mandatory := 'I';
2104 end if;
2105
2106
2107 if((l_mat_comp_table(K).high_step_value is not null) and (l_sel_comp_table(J).high_step_value is not null))
2108 then
2109 --fix for bug 3063145.
2110 if( l_mat_comp_table(K).high_step_value <= l_sel_comp_table(J).high_step_value ) then
2111 l_sel_comp_table(J).high_step_value := l_mat_comp_table(K).high_step_value;
2112 l_mat_comp_table(K).mandatory := 'I';
2113 end if;
2114 elsif((l_mat_comp_table(K).high_step_value is not null) and (l_sel_comp_table(J).high_step_value is null))
2115 then
2116 l_sel_comp_table(J).high_step_value := l_mat_comp_table(K).high_step_value;
2117 l_mat_comp_table(K).mandatory := 'I';
2118 else
2119 l_mat_comp_table(K).mandatory := 'I';
2120 end if;
2121
2122 end if;
2123
2124
2125
2126 if ( p_skip_duplicate ) then
2127 isEssentialDesired := (('Y' = l_sel_comp_table(J).mandatory and 'N' = l_mat_comp_table(K).mandatory ) or
2128 ('N' = l_sel_comp_table(J).mandatory and 'Y' = l_mat_comp_table(K).mandatory ) );
2129
2130 if( isEssentialDesired and (( 'ORG' = l_sel_comp_table(J).lookup_code and 'JOB' = l_mat_comp_table(K).lookup_code )) or
2131 (( 'ORG' = l_mat_comp_table(K).lookup_code and 'JOB' = l_sel_comp_table(J).lookup_code)) )
2132 then
2133 l_mat_comp_table(K).mandatory := 'I';
2134 end if;
2135
2136 end if;
2137
2138 if ( 'BUS' = l_sel_comp_table(J).lookup_code and 'BUS' = l_mat_comp_table(K).lookup_code )
2139 then
2140 l_mat_comp_table(K).mandatory := 'I';
2141 end if;
2142
2143
2144
2145 end if;
2146 <<end_block>>
2147 null;
2148 END;
2149
2150 END LOOP;
2151
2152 if(markOuterRowForIgnore)
2153 then
2154 l_sel_comp_table(J).mandatory := 'I';
2155 end if;
2156
2157
2158 FOR I IN 1 ..l_sel_comp_table.count LOOP
2159 if( l_sel_comp_table(I).mandatory = 'I') then
2160 l_sel_comp_table(I) := null;
2161 end if;
2162 END LOOP;
2163
2164
2165 END LOOP;
2166
2167 FOR J IN 1 ..l_sel_comp_table.count LOOP
2168 IF g_dbg THEN op(' from overriding comp = ' ||l_sel_comp_table(J).competence_id || ' ' || l_sel_comp_table(J).name, g_DEBUG_LOG); END IF;
2169 END LOOP;
2170
2171 end apply_overridding_rules;
2172
2173
2174 -- ----------------------------------------------------------------------------
2175 -- |----------------------< create_appraisal_for_person >---------------------|
2176 -- ----------------------------------------------------------------------------
2177 -- {Start Of Comments}
2178 --
2179 -- Description:
2180 -- Creates Appraisal for a given person when plan is published.
2181 --
2182 -- Prerequisites:
2183 -- None.
2184 --
2185 -- In Arguments:
2186 --
2187 --
2188 -- Post Success:
2189 -- Processing continues if Appraisal is created.
2190 --
2191 -- Post Failure:
2192 -- An application error is raised if scorecard is not created.
2193 --
2194 -- Access Status:
2195 -- Internal Only.
2196 --
2197 -- {End Of Comments}
2198 -- ----------------------------------------------------------------------------
2199 PROCEDURE create_appraisal_for_person
2200 ( p_score_card_id per_personal_scorecards.scorecard_id%TYPE,
2201 p_appraisal_templ_id per_appraisal_templates.appraisal_template_id%TYPE,
2202 p_effective_date DATE,
2203 p_appraisal_start_date DATE,
2204 p_appraisal_end_date DATE,
2205 p_appraisal_status per_appraisals.status%TYPE default 'PLANNED',
2206 p_type per_appraisals.type%TYPE default null,
2207 p_appraisal_date per_appraisals.appraisal_date%TYPE,
2208 -- p_appraisal_system_status per_appraisals.appraisal_system_status%TYPE,
2209 p_plan_id number,
2210 p_next_appraisal_date per_appraisals.next_appraisal_date%TYPE default null,
2211 p_status per_appraisals.status%TYPE default null,
2212 p_comments per_appraisals.comments%TYPE default null,
2213 p_appraisee_access per_appraisals.appraisee_access%TYPE default null,
2214 p_appraisal_initiator per_appraisal_periods.initiator_code%TYPE,
2215 p_return_status out nocopy VARCHAR2
2216 )
2217 IS
2218
2219 cursor get_scorecard_info(p_scorecard_id per_personal_scorecards.scorecard_id%TYPE)
2220 IS
2221 SELECT scorecard_id, assignment_id, person_id, scorecard_name FROM per_personal_scorecards
2222 WHERE scorecard_id = p_scorecard_id;
2223
2224 cursor get_assignment_info(p_assignment_id per_all_assignments_f.assignment_id%TYPE)
2225 IS
2226 SELECT assignment_id, business_group_id, grade_id, position_id, job_id, organization_id, supervisor_id, effective_start_date
2227 FROM per_all_assignments_f
2228 WHERE assignment_id = p_assignment_id
2229 and trunc(sysdate) between effective_start_date and effective_end_date;
2230
2231 cursor get_appraisal_templ_info (p_appraisal_templ_id per_appraisals.appraisal_template_id%TYPE)
2232 IS
2233 SELECT appraisal_template_id, assessment_type_id, objective_asmnt_type_id, business_group_id
2234 FROM per_appraisal_templates
2235 WHERE appraisal_template_id = p_appraisal_templ_id;
2236
2237
2238 cursor get_assess_templ_comps(p_assess_type_id per_competence_elements.assessment_type_id%TYPE)
2239 IS
2240 select ce.competence_id, ce.competence_element_id, ce.type, ce.parent_competence_element_id, c.name,
2241 rank() over (partition by ce.competence_id order by ce.competence_element_id) rank
2242 from per_competence_elements a, per_competence_elements ce, per_competences_vl c
2243 where a.assessment_type_id = p_assess_type_id
2244 and a.type = 'ASSESSMENT_GROUP'
2245 and (nvl(c.date_from,trunc(sysdate)) <= trunc(sysdate))
2246 and nvl(c.date_to,trunc(sysdate)) >= trunc(sysdate)
2247 and a.competence_element_id = ce.parent_competence_element_id
2248 and ce.competence_id = c.competence_id;
2249
2250
2251 cursor check_default_job_competency(p_assessment_type_id per_assessment_types.assessment_type_id%TYPE)
2252 IS
2253 select DEFAULT_JOB_COMPETENCIES from per_assessment_types
2254 where assessment_type_id = p_assessment_type_id;
2255
2256 cursor get_scorecard_objectives(p_scorecard_id per_objectives.scorecard_id%TYPE)
2257 is
2258 select objective_id, scorecard_id, object_version_number, name from per_objectives
2259 where scorecard_id = p_scorecard_id
2260 and APPRAISE_FLAG = 'Y';
2261
2262 cursor get_assess_templ_info (p_assess_templ per_appraisal_templates.assessment_type_id%TYPE)
2263 IS
2264 select DEFAULT_JOB_COMPETENCIES, ASSESSMENT_TYPE_ID from per_assessment_types
2265 where ASSESSMENT_TYPE_ID = p_assess_templ;
2266
2267 l_scorecard_info scorecard_info;
2268 NO_SCORE_CARD_WITH_THIS_ID EXCEPTION;
2269 l_assignment_info assignment_info;
2270 NO_ASSIGNMENT_WITH_THIS_ID EXCEPTION;
2271 l_appraisal_ovn per_appraisals.object_version_number%TYPE;
2272 l_apprl_return_status VARCHAR2(10) default null;
2273 l_assess_comp_return_status VARCHAR2(10) default null;
2274 l_assess_obj_return_status VARCHAR2(10) default null;
2275 l_apprl_id per_appraisals.appraisal_id%TYPE default null;
2276 l_apprl_templ_info appraisal_templ_info;
2277 NO_APPRL_TEMPL_WITH_THIS_ID EXCEPTION;
2278 l_assessment_comp_id per_assessments.assessment_id%TYPE;
2279 l_assessment_obj_id per_assessments.assessment_id%TYPE;
2280 l_assessment_comp_ovn per_assessments.object_version_number%TYPE;
2281 l_assessment_obj_ovn per_assessments.object_version_number%TYPE;
2282 l_assess_comps assess_comps_info;
2283 l_check_default_job_comps varchar2(2) default '';
2284
2285 l_comp_ele_id per_competence_elements.competence_element_id%TYPE;
2286 l_comp_ovn per_competence_elements.object_version_number%TYPE;
2287 l_return_status varchar2(10) default '';
2288 l_competence_error varchar2(1000) default null;
2289 module_name varchar2(100) default 'MASS APPRAISAL CREATION';
2290 l_error_message varchar2(1000) default null;
2291 APPRAISAL_CREATION_ERROR EXCEPTION;
2292 ASSESS_COMP_ERROR EXCEPTION;
2293 ASSESS_OBJ_ERROR EXCEPTION;
2294 l_appraisal_sys_type varchar2(10);
2295 function_360_exists boolean default false;
2296 APPRAISAL_SYSTEM_TYPE_ERROR EXCEPTION;
2297 l_weighting_over_100_warning boolean;
2298 l_weighting_appraisal_warning boolean;
2299 NO_APPRL_FUNCTION_DEFINED EXCEPTION;
2300 l_function_id fnd_form_functions.function_id%TYPE;
2301 l_function_name fnd_form_functions.function_name%TYPE;
2302 l_func_params fnd_form_functions.parameters%TYPE;
2303 l_object_id NUMBER;
2304 l_assess_comps_processed competences_tbl;
2305 z PLS_INTEGER;
2306 l_def_job_comps sel_comp_tab;
2307 APPRAISAL_SETUP_ISSUE EXCEPTION;
2308
2309
2310
2311
2312 -- Declare local variables
2313 l_proc varchar2(72) := g_package||'create_appraisal_for_person';
2314 --
2315 l_scorecard_id number;
2316 l_object_version_number number;
2317 --l_status_code varchar2(30);
2318 l_duplicate_name_warning boolean;
2319 l_found_comp boolean;
2320 --
2321 l_templ_def_job_comps per_assessment_types.default_job_competencies%TYPE;
2322 l_assess_type_id per_assessment_types.assessment_type_id%TYPE;
2323 Begin
2324 --
2325 IF g_dbg THEN op('Entering:'|| l_proc, g_DEBUG_LOG, 10); END IF;
2326 --
2327
2328 --
2329 -- Call create_scorecard
2330 --
2331 l_scorecard_info.scorecard_id := null;
2332 l_scorecard_info.assignment_id := null;
2333
2334
2335 OPEN get_scorecard_info(p_score_card_id);
2336 FETCH get_scorecard_info INTO l_scorecard_info;
2337 CLOSE get_scorecard_info;
2338 if(l_scorecard_info.scorecard_id is null or l_scorecard_info.assignment_id is null) then
2339 RAISE NO_SCORE_CARD_WITH_THIS_ID;
2340 end if;
2341
2342 IF g_dbg THEN op(' get_scorecard_info '|| l_proc, g_DEBUG_LOG, 20); END IF;
2343
2344
2345 l_assignment_info.assignment_id := null;
2346 OPEN get_assignment_info(l_scorecard_info.assignment_id);
2347 FETCH get_assignment_info INTO l_assignment_info;
2348 CLOSE get_assignment_info;
2349 if(l_assignment_info.assignment_id is null) then
2350 RAISE NO_ASSIGNMENT_WITH_THIS_ID;
2351 end if;
2352
2353 IF g_dbg THEN op(' get_assignment_info '|| l_proc, g_DEBUG_LOG, 20); END IF;
2354
2355
2356 OPEN get_appraisal_templ_info(p_appraisal_templ_id);
2357 FETCH get_appraisal_templ_info INTO l_apprl_templ_info;
2358 CLOSE get_appraisal_templ_info;
2359 if(l_apprl_templ_info.appraisal_template_id is null) then
2360 RAISE NO_APPRL_TEMPL_WITH_THIS_ID;
2361 end if;
2362
2363 IF g_dbg THEN op(' get_appraisal_templ_info '|| l_proc, g_DEBUG_LOG, 20); END IF;
2364
2365
2366 l_appraisal_sys_type := p_type;
2367 function_360_exists := get_appraisal_config_params(p_appr_initiator_code => p_appraisal_initiator,
2368 p_function_id => l_function_id,
2369 p_function_name => l_function_name,
2370 p_func_parameters => l_func_params,
2371 p_appraisal_sys_type => l_appraisal_sys_type);
2372 IF g_dbg THEN op('l_function_id = ' || l_function_id, g_DEBUG_LOG); END IF;
2373 IF g_dbg THEN op('l_function_name = ' || l_function_name, g_DEBUG_LOG); END IF;
2374 IF g_dbg THEN op('l_func_params = ' || l_func_params, g_DEBUG_LOG); END IF;
2375
2376 IF(l_function_id is null or l_appraisal_sys_type is null) then
2377 IF g_dbg THEN
2378 op('Could not derive Appraisal Function or Appraisal System Type', g_DEBUG_LOG);
2379 END IF;
2380 raise APPRAISAL_SETUP_ISSUE;
2381 END IF;
2382
2383
2384 /*
2385 IF (function_360_exists = true) then
2386 IF g_dbg THEN op(' Appraisal System Function ' || l_appraisal_sys_status, g_DEBUG_LOG); END IF;
2387 end if;
2388
2389 -- throw exception as there is no Function
2390 if(function_360_exists = false) then
2391 raise NO_APPRL_FUNCTION_DEFINED;
2392 IF g_dbg THEN op(' Appraisal System Function ' || l_appraisal_sys_status, g_DEBUG_LOG); END IF;
2393
2394 end if;
2395 */
2396
2397
2398 --function_360_exists := true; -- to be changed
2399
2400
2401 /*
2402
2403 if(function_360_exists = false) then
2404 raise APPRAISAL_SYSTEM_TYPE_ERROR;
2405 end if;
2406
2407 */
2408
2409 --fnd_log.string(fnd_log.level_error,module_name,' Appraisal Creation for Score Card ' || l_scorecard_info.scorecard_name);
2410
2411 -- to be, in case of Position Hierarchy we need get the supervisor id using the Plan and
2412 -- position hierarchy cursor.
2413
2414
2415
2416 hr_appraisals_api.create_appraisal(
2417 p_validate => false,
2418 p_effective_date => p_effective_date,
2419 p_business_group_id => l_assignment_info.business_group_id,
2420 p_appraisal_template_id => p_appraisal_templ_id,
2421 p_appraisee_person_id => l_scorecard_info.person_id,
2422 p_appraiser_person_id => l_assignment_info.supervisor_id, --to be changed for position
2423 p_appraisal_date => p_appraisal_date,
2424 p_appraisal_period_start_date => p_appraisal_start_date ,
2425 p_appraisal_period_end_date => p_appraisal_end_date,
2426 p_type => p_type, -- ANN,
2427 p_next_appraisal_date => p_next_appraisal_date,
2428 p_status => p_status, -- PLANNED,TRANSFER,RFC,
2429 p_comments => p_comments,
2430 p_system_type => l_appraisal_sys_type, --MGR360 EMP360
2431 p_system_params => l_func_params,
2432 --p_appraisee_access,
2433 p_main_appraiser_id => l_assignment_info.supervisor_id, --to be changed for position
2434 p_assignment_id => l_assignment_info.assignment_id ,
2435 p_assignment_start_date => l_assignment_info.effective_state_date,
2436 p_asg_business_group_id => l_assignment_info.business_group_id ,
2437 p_assignment_organization_id => l_assignment_info.org_id ,
2438 p_assignment_job_id => l_assignment_info.job_id ,
2439 --p_assignment_position_id = l_assignment_info.position_id ,
2440 p_assignment_grade_id => l_assignment_info.grade_id ,
2441 p_appraisal_id => l_apprl_id,
2442 p_object_version_number => l_appraisal_ovn ,
2443 p_appraisal_system_status => p_appraisal_status ,
2444 p_plan_id => p_plan_id);
2445
2446 IF g_dbg THEN op('Appraisal Id = ' || l_apprl_id, g_DEBUG_LOG); END IF;
2447
2448
2449 if( l_apprl_id is not null and l_apprl_templ_info.assessment_type_id is not null) then
2450 hr_assessments_api.create_assessment
2451 (p_assessment_id => l_assessment_comp_id,
2452 p_assessment_type_id => l_apprl_templ_info.assessment_type_id,
2453 p_business_group_id => l_assignment_info.business_group_id,
2454 p_person_id => l_scorecard_info.person_id,
2455 --p_assessment_group_id,
2456 p_assessment_period_start_date => p_appraisal_start_date,
2457 p_assessment_period_end_date => p_appraisal_end_date,
2458 p_assessment_date => p_appraisal_date,
2459 p_assessor_person_id => l_assignment_info.supervisor_id, --to be changed for position
2460 p_appraisal_id => l_apprl_id,
2461 --p_comments,
2462 p_object_version_number => l_assessment_comp_ovn,
2463 p_validate => false,
2464 p_effective_date => p_effective_date);
2465 end if;
2466
2467 IF g_dbg THEN op('Competence Assesment Id = ' || l_assessment_comp_id, g_DEBUG_LOG); END IF;
2468
2469
2470 -- this record is created for final ratings on Objectives.
2471
2472 if(l_apprl_id is not null and l_apprl_templ_info.objective_asmnt_type_id is not null) then
2473 hr_assessments_api.create_assessment
2474 (p_assessment_id => l_assessment_obj_id,
2475 p_assessment_type_id => l_apprl_templ_info.assessment_type_id,
2476 p_business_group_id => l_assignment_info.business_group_id,
2477 p_person_id => l_scorecard_info.person_id,
2478 --p_assessment_group_id,
2479 p_assessment_period_start_date => p_appraisal_start_date,
2480 p_assessment_period_end_date => p_appraisal_end_date,
2481 p_assessment_date => p_appraisal_date,
2482 p_assessor_person_id => l_assignment_info.supervisor_id, --to be changed for position
2483 p_appraisal_id => l_apprl_id,
2484 --p_comments,
2485 p_object_version_number => l_assessment_obj_ovn,
2486 p_validate => false,
2487 p_effective_date => p_effective_date);
2488
2489 end if;
2490
2491 IF g_dbg THEN op('Objective Assessment Id = ' || l_assessment_obj_id, g_DEBUG_LOG); END IF;
2492
2493 -- to be
2494
2495 IF ( p_appraisal_initiator = 'MA') then
2496 l_object_id := l_assignment_info.supervisor_id;
2497 elsif (p_appraisal_initiator = 'A') then
2498 l_object_id := l_scorecard_info.person_id;
2499 end if;
2500
2501 z := 1;
2502 if( l_assessment_comp_id is not null ) then
2503 for competences in get_assess_templ_comps(l_apprl_templ_info.assessment_type_id)
2504 loop
2505 begin
2506 l_return_status := '';
2507 l_competence_error := null;
2508
2509 l_assess_comps_processed(z).competence_id := competences.competence_id;
2510 hr_competence_element_api.create_competence_element(
2511 p_validate => false,
2512 p_competence_element_id => l_comp_ele_id,
2513 p_object_version_number => l_comp_ovn,
2514 p_type => 'ASSESSMENT',
2515 p_business_group_id => l_assignment_info.business_group_id,
2516 p_competence_id => competences.competence_id,
2517 p_assessment_id => l_assessment_comp_id,
2518 p_effective_date_from => p_appraisal_start_date,
2519 p_effective_date =>p_effective_date,
2520 p_object_name => 'ASSESSOR_ID',
2521 p_object_id => l_object_id
2522 );
2523 z := z+1;
2524 IF g_dbg THEN op('Competence Element Id = ' || l_comp_ele_id, g_DEBUG_LOG); END IF;
2525
2526 exception when others then
2527 -- to be added a message to identify competence element error
2528 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
2529 end;
2530 end loop;
2531 end if;
2532
2533 open get_assess_templ_info(l_apprl_templ_info.assessment_type_id);
2534 fetch get_assess_templ_info into l_templ_def_job_comps, l_assess_type_id;
2535 close get_assess_templ_info;
2536
2537 if(l_templ_def_job_comps = 'Y') then
2538 apply_overridding_rules(p_enterprise_id => l_assignment_info.business_group_id,
2539 p_organization_id => l_assignment_info.org_id,
2540 p_job_id => l_assignment_info.job_id,
2541 p_position_id => l_assignment_info.position_id,
2542 p_skip_duplicate => true,
2543 l_sel_comp_table => l_def_job_comps);
2544
2545 -- create the Job Comps eliminating duplicates
2546 if( l_assessment_comp_id is not null ) then
2547 FOR J IN 1 ..l_def_job_comps.count LOOP
2548 begin
2549 l_found_comp := false;
2550 for k in 1..l_assess_comps_processed.count LOOP
2551 if( l_def_job_comps(j).competence_id is not null and l_def_job_comps(j).competence_id = l_assess_comps_processed(k).competence_id) then
2552 l_found_comp := true;
2553 end if;
2554 end loop;
2555
2556 if(l_def_job_comps(j).competence_id is not null and not l_found_comp ) then
2557 hr_competence_element_api.create_competence_element(
2558 p_validate => false,
2559 p_competence_element_id => l_comp_ele_id,
2560 p_object_version_number => l_comp_ovn,
2561 p_type => 'ASSESSMENT',
2562 p_business_group_id => l_assignment_info.business_group_id,
2563 p_competence_id => l_def_job_comps(J).competence_id,
2564 p_assessment_id => l_assessment_comp_id,
2565 p_effective_date_from => p_appraisal_start_date,
2566 p_effective_date =>p_effective_date,
2567 p_object_name => 'ASSESSOR_ID',
2568 p_object_id => l_object_id
2569 );
2570 IF g_dbg THEN op(' Def Job Competence Id and Element Id = ' || l_comp_ele_id || l_def_job_comps(J).competence_id, g_DEBUG_LOG); END IF;
2571
2572 end if;
2573
2574 exception when others then
2575 -- to be added a message to identify competence element error
2576 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
2577 end;
2578 end loop;
2579 end if;
2580 end if;
2581
2582 if( l_apprl_id is not null) then
2583 for objectives in get_scorecard_objectives( p_score_card_id )
2584 loop
2585 begin
2586 hr_objectives_api.update_objective(p_validate => false,
2587 p_objective_id => objectives.objective_id,
2588 p_object_version_number => objectives.object_version_number,
2589 p_effective_date => p_effective_date,
2590 p_appraisal_id => l_apprl_id, -- to be changed in SWI,API,RHI
2591 p_weighting_over_100_warning => l_weighting_over_100_warning,
2592 p_weighting_appraisal_warning => l_weighting_appraisal_warning
2593 );
2594
2595 IF g_dbg THEN op('Linked objective Id to Appraisal = ' || objectives.objective_id, g_DEBUG_LOG); END IF;
2596
2597 exception when others then
2598 -- to be added a message to identify update objective error
2599 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
2600 end;
2601 end loop;
2602 end if;
2603
2604
2605 -- Out parameter
2606
2607 --
2608 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
2609 --
2610 exception
2611 when others then
2612 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
2613 --
2614 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
2615 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
2616 g_retcode := WARNING;
2617 g_errbuf := g_cp_error_txt;
2618 g_num_errors := g_num_errors + 1;
2619 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
2620 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
2621
2622 --
2623 -- If the max number of errors has been exceeded, raise the error and
2624 -- terminate processing of this plan.
2625 --
2626 IF g_num_errors > g_max_errors THEN
2627 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
2628 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
2629 g_retcode := ERROR;
2630 g_errbuf := g_error_txt;
2631 RAISE;
2632 END IF;
2633
2634 End create_appraisal_for_person;
2635
2636 --
2637 -- ----------------------------------------------------------------------------
2638 -- |----------------------< create_appraisal_for_person >---------------------|
2639 -- ----------------------------------------------------------------------------
2640 -- {Start Of Comments}
2641 --
2642 -- Description:
2643 -- Creates appraisal for a given person when plan is published.
2644 --
2645 -- Prerequisites:
2646 -- None.
2647 --
2648 -- In Arguments:
2649 --
2650 --
2651 -- Post Success:
2652 -- Processing continues if appraisal is created.
2653 --
2654 -- Post Failure:
2655 -- An application error is raised if appraisal is not created.
2656 --
2657 -- Access Status:
2658 -- Internal Only.
2659 --
2660 -- {End Of Comments}
2661 -- ----------------------------------------------------------------------------
2662 procedure create_appraisal_for_person
2663 (p_effective_date in date
2664 ,p_business_group_id in number
2665 ,p_appraisal_template_id in number
2666 ,p_appraisee_person_id in number
2667 ,p_appraiser_person_id in number
2668 ,p_appraisal_period_start_date in date
2669 ,p_appraisal_period_end_date in date
2670 ) is
2671
2672
2673 -- Declare local variables
2674 l_proc varchar2(72) := g_package||'create_appraisal_for_person ';
2675 --
2676 l_appraisal_id number;
2677 l_object_version_number number;
2678 --
2679 Begin
2680 --
2681 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
2682 --
2683
2684 --
2685 -- Call create_appraisal
2686 --
2687 hr_appraisals_api.create_appraisal(
2688 p_effective_date => p_effective_date
2689 ,p_business_group_id => p_business_group_id
2690 ,p_appraisal_template_id => p_appraisal_template_id
2691 ,p_appraisee_person_id => p_appraisee_person_id
2692 ,p_appraiser_person_id => p_appraiser_person_id
2693 ,p_appraisal_period_start_date => p_appraisal_period_start_date
2694 ,p_appraisal_period_end_date => p_appraisal_period_end_date
2695 ,p_appraisal_id => l_appraisal_id
2696 ,p_object_version_number => l_object_version_number
2697 );
2698
2699 --
2700 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
2701 --
2702 exception
2703 when others then
2704 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
2705 --
2706 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
2707 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
2708 g_retcode := WARNING;
2709 g_errbuf := g_cp_error_txt;
2710 g_num_errors := g_num_errors + 1;
2711 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
2712 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
2713
2714 --
2715 -- If the max number of errors has been exceeded, raise the error and
2716 -- terminate processing of this plan.
2717 --
2718 IF g_num_errors > g_max_errors THEN
2719 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
2720 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
2721 g_retcode := ERROR;
2722 g_errbuf := g_error_txt;
2723 RAISE;
2724 END IF;
2725
2726 End create_appraisal_for_person;
2727 --
2728 -- ----------------------------------------------------------------------------
2729 -- |----------------------< update_appraisal_for_person >---------------------|
2730 -- ----------------------------------------------------------------------------
2731 -- {Start Of Comments}
2732 --
2733 -- Description:
2734 -- Updates appraisal for a given person when plan is published.
2735 --
2736 -- Prerequisites:
2737 -- None.
2738 --
2739 -- In Arguments:
2740 --
2741 --
2742 -- Post Success:
2743 -- Processing continues if appraisal is updated.
2744 --
2745 -- Post Failure:
2746 -- An application error is raised if appraisal is not updated.
2747 --
2748 -- Access Status:
2749 -- Internal Only.
2750 --
2751 -- {End Of Comments}
2752 -- ----------------------------------------------------------------------------
2753 procedure update_appraisal_for_person
2754 (p_effective_date in date
2755 ,p_appraisal_id in number
2756 ,p_object_version_number in number
2757 ,p_appraiser_person_id in number
2758 ,p_appraisal_period_start_date in date
2759 ,p_appraisal_period_end_date in date
2760 ) is
2761
2762
2763 -- Declare local variables
2764 l_proc varchar2(72) := g_package||'update_appraisal_for_person ';
2765 --
2766 l_object_version_number number := p_object_version_number;
2767 --
2768 Begin
2769 --
2770 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
2771 --
2772
2773 --
2774 -- Call update_appraisal
2775 --
2776 hr_appraisals_api.update_appraisal(
2777 p_effective_date => p_effective_date
2778 ,p_appraisal_id => p_appraisal_id
2779 ,p_object_version_number => l_object_version_number
2780 ,p_appraiser_person_id => p_appraiser_person_id
2781 ,p_appraisal_period_start_date => p_appraisal_period_start_date
2782 ,p_appraisal_period_end_date => p_appraisal_period_end_date
2783 );
2784
2785 --
2786 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
2787 --
2788 exception
2789
2790 when others then
2791 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
2792 --
2793 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
2794 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
2795 g_retcode := WARNING;
2796 g_errbuf := g_cp_error_txt;
2797 g_num_errors := g_num_errors + 1;
2798 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
2799 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
2800
2801 --
2802 -- If the max number of errors has been exceeded, raise the error and
2803 -- terminate processing of this plan.
2804 --
2805 IF g_num_errors > g_max_errors THEN
2806 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
2807 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
2808 g_retcode := ERROR;
2809 g_errbuf := g_error_txt;
2810 RAISE;
2811 END IF;
2812
2813 End update_appraisal_for_person;
2814 --
2815 -- ----------------------------------------------------------------------------
2816 -- |----------------------< delete_appraisal_for_person >---------------------|
2817 -- ----------------------------------------------------------------------------
2818 -- {Start Of Comments}
2819 --
2820 -- Description:
2821 -- Deletes appraisal for a given person when plan is published.
2822 --
2823 -- Prerequisites:
2824 -- None.
2825 --
2826 -- In Arguments:
2827 --
2828 --
2829 -- Post Success:
2830 -- Processing continues if appraisal is deleted.
2831 --
2832 -- Post Failure:
2833 -- An application error is raised if appraisal is not deleted.
2834 --
2835 -- Access Status:
2836 -- Internal Only.
2837 --
2838 -- {End Of Comments}
2839 -- ----------------------------------------------------------------------------
2840 procedure delete_appraisal_for_person
2841 (p_appraisal_id in number
2842 ,p_object_version_number in number
2843 ) is
2844
2845
2846 -- Declare local variables
2847 l_proc varchar2(72) := g_package||'delete_appraisal_for_person ';
2848
2849 cursor get_assessm_for_apprl(apprl_id per_appraisals.appraisal_id%TYPE) is
2850 select assessment_id, object_version_number from per_assessments
2851 where appraisal_id = apprl_id;
2852
2853 cursor get_competences(assess_id per_assessments.assessment_id%TYPE) is
2854 select competence_element_id, object_version_number from per_competence_elements
2855 where assessment_id = assess_id order by competence_element_id desc ;
2856
2857 --
2858 Begin
2859 --
2860 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
2861 --
2862
2863 --
2864 -- Call delete_appraisal
2865 --
2866 for assess_records in get_assessm_for_apprl(p_appraisal_id)
2867 loop
2868 for assess_comps in get_competences(assess_records.assessment_id)
2869 loop
2870 hr_competence_element_api.delete_competence_element
2871 (p_validate => false,
2872 p_competence_element_id => assess_comps.competence_element_id,
2873 p_object_version_number => assess_comps.object_version_number);
2874 end loop;
2875 hr_assessments_api.delete_assessment
2876 (p_validate => false,
2877 p_assessment_id => assess_records.assessment_id,
2878 p_object_version_number => assess_records.object_version_number);
2879 end loop;
2880
2881 hr_appraisals_api.delete_appraisal
2882 (p_validate => false,
2883 p_appraisal_id => p_appraisal_id
2884 ,p_object_version_number => p_object_version_number
2885 );
2886
2887 --
2888 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
2889 --
2890 exception
2891 when others then
2892 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
2893 --
2894 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
2895 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
2896 g_retcode := WARNING;
2897 g_errbuf := g_cp_error_txt;
2898 g_num_errors := g_num_errors + 1;
2899 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
2900 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
2901
2902 --
2903 -- If the max number of errors has been exceeded, raise the error and
2904 -- terminate processing of this plan.
2905 --
2906 IF g_num_errors > g_max_errors THEN
2907 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
2908 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
2909 g_retcode := ERROR;
2910 g_errbuf := g_error_txt;
2911 RAISE;
2912 END IF;
2913
2914 End delete_appraisal_for_person;
2915 --
2916 --
2917 -- ----------------------------------------------------------------------------
2918 -- |---------------------------< get_plan_action >----------------------------|
2919 -- ----------------------------------------------------------------------------
2920 --
2921 procedure get_plan_action(itemtype in varchar2,
2922 itemkey in varchar2,
2923 actid in number,
2924 funcmode in varchar2,
2925 resultout out nocopy varchar2)
2926 is
2927 --
2928 l_action varchar2(30);
2929 --
2930 begin
2931 --
2932 IF ( funcmode = 'RUN' ) then
2933 --
2934 l_action := wf_engine.GetItemAttrText(itemtype => itemtype,
2935 itemkey => itemkey,
2936 aname => 'WPM_PLAN_ACTION');
2937 --
2938 IF (l_action IN ('PUBLISH', 'REVERSE_PUBLISH')) THEN
2939 resultout := 'COMPLETE:' || l_action;
2940 ELSE
2941 resultout := 'ERROR' || 'Y';
2942 END IF;
2943 ELSE
2944 resultout := 'ERROR' || 'Y';
2945 END IF;
2946 --
2947 exception
2948 when others then
2949 WF_CORE.CONTEXT('HR_PERF_MGMT_PLANS_INTERNAL'
2950 ,'GET_PLAN_ACTION'
2951 ,itemtype
2952 ,itemkey
2953 ,to_char(actid)
2954 ,funcmode);
2955 raise;
2956 end get_plan_action;
2957 --
2958 -- ----------------------------------------------------------------------------
2959 -- |---------------------------< get_plan_method >----------------------------|
2960 -- ----------------------------------------------------------------------------
2961 --
2962 procedure get_plan_method(itemtype in varchar2,
2963 itemkey in varchar2,
2964 actid in number,
2965 funcmode in varchar2,
2966 resultout out nocopy varchar2)
2967 is
2968 --
2969 l_method varchar2(30);
2970 --
2971 begin
2972 --
2973 IF ( funcmode = 'RUN' ) then
2974 --
2975 l_method := wf_engine.GetItemAttrText(itemtype => itemtype,
2976 itemkey => itemkey,
2977 aname => 'WPM_PLAN_METHOD');
2978 --
2979 IF (l_method IN ('CAS', 'PAR')) THEN
2980 resultout := 'COMPLETE:' || l_method;
2981 ELSE
2982 resultout := 'ERROR' || 'Y';
2983 END IF;
2984 ELSE
2985 resultout := 'ERROR' || 'Y';
2986 END IF;
2987 --
2988 exception
2989 when others then
2990 WF_CORE.CONTEXT('HR_PERF_MGMT_PLANS_INTERNAL'
2991 ,'GET_PLAN_METHOD'
2992 ,itemtype
2993 ,itemkey
2994 ,to_char(actid)
2995 ,funcmode);
2996 raise;
2997 end get_plan_method;
2998 --
2999 -- ----------------------------------------------------------------------------
3000 -- |-----------------------------< start_process >----------------------------|
3001 -- ----------------------------------------------------------------------------
3002 --
3003 procedure start_process
3004 (p_plan_rec in per_perf_mgmt_plans%ROWTYPE
3005 ,p_effective_date in date
3006 ,p_reverse_mode in varchar2
3007 ,p_item_type in varchar2
3008 ,p_wf_process in varchar2)
3009 is
3010 -- Declare local variables
3011 l_proc varchar2(72) := g_package||'start_process';
3012 --
3013 l_item_key varchar2(30);
3014 l_item_user_key varchar2(80) := p_plan_rec.plan_id;
3015 l_plan_action varchar2(80);
3016 l_top_msg_hdr varchar2(2000);
3017 l_top_msg_txt varchar2(2000);
3018 l_mbr_msg_hdr varchar2(2000);
3019 l_mbr_msg_txt varchar2(2000);
3020
3021 l_role_name wf_roles.name%type;
3022 l_role_displayname wf_roles.display_name%type;
3023 l_admin_role_name wf_roles.name%type;
3024 l_admin_role_displayname wf_roles.display_name%type;
3025 --
3026 begin
3027 --
3028 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
3029 --
3030 --
3031 -- Derive the item key
3032 --
3033 select hr_workflow_item_key_s.nextval
3034 into l_item_key
3035 from dual;
3036
3037 --
3038 -- Derive the other values based on plan action
3039 --
3040 IF (p_reverse_mode = 'N') THEN
3041 l_plan_action := 'PUBLISH';
3042 ELSIF (p_reverse_mode = 'Y') THEN
3043 l_plan_action := 'REVERSE_PUBLISH';
3044 END IF;
3045
3046 -- WF Process
3047 wf_engine.CreateProcess (itemtype => p_item_type,
3048 itemkey => l_item_key,
3049 process => p_wf_process );
3050
3051 -- Item User Key
3052 wf_engine.SetItemUserKey (itemtype => p_item_type,
3053 itemkey => l_item_key,
3054 userkey => l_item_user_key);
3055
3056 -- Effective Date
3057 wf_engine.SetItemAttrText (itemtype => p_item_type,
3058 itemkey => l_item_key,
3059 aname => 'EFFECTIVE_DATE',
3060 avalue => p_effective_date);
3061 -- Plan Id
3062 wf_engine.SetItemAttrText (itemtype => p_item_type,
3063 itemkey => l_item_key,
3064 aname => 'WPM_PLAN_ID',
3065 avalue => p_plan_rec.plan_id);
3066
3067 -- Plan Name
3068 wf_engine.SetItemAttrText (itemtype => p_item_type,
3069 itemkey => l_item_key,
3070 aname => 'WPM_PLAN',
3071 avalue => p_plan_rec.plan_name);
3072
3073 -- Plan Action
3074 wf_engine.SetItemAttrText (itemtype => p_item_type,
3075 itemkey => l_item_key,
3076 aname => 'WPM_PLAN_ACTION',
3077 avalue => l_plan_action);
3078 -- Plan Method
3079 wf_engine.SetItemAttrText (itemtype => p_item_type,
3080 itemkey => l_item_key,
3081 aname => 'WPM_PLAN_METHOD',
3082 avalue => p_plan_rec.method_code);
3083
3084 -- Plan Hierarchy
3085 wf_engine.SetItemAttrText (itemtype => p_item_type,
3086 itemkey => l_item_key,
3087 aname => 'WPM_PLAN_HIERARCHY',
3088 avalue => p_plan_rec.hierarchy_type_code);
3089
3090 -- Plan Supervisor Id
3091 wf_engine.SetItemAttrText (itemtype => p_item_type,
3092 itemkey => l_item_key,
3093 aname => 'WPM_PLAN_SUPERVISOR_ID',
3094 avalue => p_plan_rec.supervisor_id);
3095
3096 -- Plan Supervisor Assignment Id
3097 wf_engine.SetItemAttrText (itemtype => p_item_type,
3098 itemkey => l_item_key,
3099 aname => 'WPM_PLAN_SUPERVISOR_ASG_ID',
3100 avalue => p_plan_rec.supervisor_assignment_id);
3101
3102 -- Plan Top Organization Id
3103 wf_engine.SetItemAttrText (itemtype => p_item_type,
3104 itemkey => l_item_key,
3105 aname => 'WPM_PLAN_TOP_ORG_ID',
3106 avalue => p_plan_rec.top_organization_id);
3107
3108 -- Plan Top Position Id
3109 wf_engine.SetItemAttrText (itemtype => p_item_type,
3110 itemkey => l_item_key,
3111 aname => 'WPM_PLAN_TOP_POS_ID',
3112 avalue => p_plan_rec.top_position_id);
3113
3114 -- Objective Setting Start Date
3115 wf_engine.SetItemAttrText (itemtype => p_item_type,
3116 itemkey => l_item_key,
3117 aname => 'OBJ_SET_START',
3118 avalue => p_plan_rec.obj_setting_start_date);
3119
3120 -- Objective Setting End Date
3121 wf_engine.SetItemAttrText (itemtype => p_item_type,
3122 itemkey => l_item_key,
3123 aname => 'OBJ_SET_FINISH',
3124 avalue => p_plan_rec.obj_setting_deadline);
3125 -- start changes for Bug#5903006
3126 wf_engine.SetItemAttrText (itemtype => p_item_type,
3127 itemkey => l_item_key,
3128 aname => 'HR_WPM_OBJ_SETTING_FLAG',
3129 avalue => p_plan_rec.include_obj_setting_flag);
3130 -- End Changes for bug#5903006
3131
3132 --
3133 -- ------------------------------------
3134 -- Get the Role for plan Administrator
3135 -- ------------------------------------
3136 --
3137 wf_directory.getRoleName
3138 (p_orig_system => 'PER'
3139 ,p_orig_system_id => p_plan_rec.administrator_person_id
3140 ,p_name => l_admin_role_name
3141 ,p_display_name => l_admin_role_displayname);
3142 --
3143 -- Plan Administrator
3144 --
3145 wf_engine.SetItemAttrText (itemtype => p_item_type,
3146 itemkey => l_item_key,
3147 aname => 'HR_WPM_PLAN_ADMINISTRATOR',
3148 avalue => l_admin_role_name);
3149 --
3150 -- ---------------------------------
3151 -- Get the Role for the Owner
3152 -- ---------------------------------
3153 --
3154 wf_directory.getRoleName
3155 (p_orig_system => 'FND_USR'
3156 ,p_orig_system_id => fnd_global.user_id
3157 ,p_name => l_role_name
3158 ,p_display_name => l_role_displayname);
3159 --
3160 wf_engine.SetItemOwner (itemtype => p_item_type,
3161 itemkey => l_item_key,
3162 owner => l_role_name);
3163 --
3164 wf_engine.StartProcess (itemtype => p_item_type,
3165 itemkey => l_item_key);
3166 --
3167 --
3168 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 80); END IF;
3169 --
3170 exception
3171 when others then
3172 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
3173 --
3174 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
3175 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
3176 g_retcode := ERROR;
3177 g_errbuf := g_cp_error_txt;
3178 g_num_errors := g_num_errors + 1;
3179 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
3180 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
3181 raise;
3182 end start_process;
3183 --
3184 -- ----------------------------------------------------------------------------
3185 -- |----------------------< populate_plan_members_cache >---------------------|
3186 -- ----------------------------------------------------------------------------
3187 --
3188 procedure populate_plan_members_cache(itemtype in varchar2,
3189 itemkey in varchar2,
3190 actid in number,
3191 funcmode in varchar2,
3192 resultout out nocopy varchar2)
3193 is
3194 --
3195 l_plan_id number;
3196 l_effective_date date;
3197
3198 -- Plan record
3199 CURSOR csr_get_plan_rec (p_plan_id number) IS
3200 SELECT *
3201 FROM per_perf_mgmt_plans
3202 WHERE plan_id = p_plan_id;
3203 --
3204 l_plan_rec per_perf_mgmt_plans%ROWTYPE;
3205 begin
3206 --
3207 IF (funcmode = 'RUN') then
3208
3209 -- Get the workwlow attribute values
3210 l_plan_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3211 itemkey => itemkey,
3212 aname => 'WPM_PLAN_ID');
3213 l_effective_date := wf_engine.GetItemAttrText(itemtype => itemtype,
3214 itemkey => itemkey,
3215 aname => 'EFFECTIVE_DATE');
3216 --
3217 -- Get plan record
3218 --
3219 OPEN csr_get_plan_rec(l_plan_id);
3220 FETCH csr_get_plan_rec INTO l_plan_rec;
3221 CLOSE csr_get_plan_rec;
3222
3223 -- populate plan cache table
3224 populate_qual_plan_population(l_plan_rec, l_effective_date);
3225 --
3226 IF (g_plan_pop_known_t(l_plan_id) AND g_qual_pop_tbl.COUNT > 0) THEN
3227 resultout := 'COMPLETE:' || 'Y';
3228 ELSE
3229 resultout := 'COMPLETE:' || 'N';
3230 END IF;
3231 ELSE
3232 -- function mode is not Run
3233 resultout := 'ERROR' || 'Y';
3234 END IF;
3235 --
3236 exception
3237 when others then
3238 WF_CORE.CONTEXT('HR_PERF_MGMT_PLANS_INTERNAL'
3239 ,'POPULATE_PLAN_MEMBERS_CACHE'
3240 ,itemtype
3241 ,itemkey
3242 ,to_char(actid)
3243 ,funcmode);
3244 raise;
3245 end populate_plan_members_cache;
3246 --
3247 -- ----------------------------------------------------------------------------
3248 -- |---------------------------< get_plan_member >----------------------------|
3249 -- ----------------------------------------------------------------------------
3250 --
3251 procedure get_plan_member(itemtype in varchar2,
3252 itemkey in varchar2,
3253 actid in number,
3254 funcmode in varchar2,
3255 resultout out nocopy varchar2)
3256 is
3257 --
3258 l_plan_id number;
3259 l_role_name wf_roles.name%type;
3260 l_role_displayname wf_roles.display_name%type;
3261 --
3262 begin
3263 --
3264 IF (funcmode = 'RUN') then
3265
3266 -- Get the workwlow attribute values
3267 l_plan_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3268 itemkey => itemkey,
3269 aname => 'WPM_PLAN_ID');
3270 -- If plan population is known
3271 IF (g_plan_pop_known_t(l_plan_id)) THEN
3272
3273 -- Get the current plan member index
3274 IF (g_fetched_plan_member_index IS NULL) THEN
3275 g_fetched_plan_member_index := g_qual_pop_tbl.FIRST;
3276 ELSE
3277 g_fetched_plan_member_index := g_qual_pop_tbl.NEXT(g_fetched_plan_member_index);
3278 END IF;
3279
3280 -- Loop till member is found with wf role
3281 WHILE (g_fetched_plan_member_index IS NOT NULL)
3282 LOOP
3283 -- Get the Role for the Owner
3284 wf_directory.getRoleName(p_orig_system => 'PER'
3285 ,p_orig_system_id => g_qual_pop_tbl(g_fetched_plan_member_index).person_id
3286 ,p_name => l_role_name
3287 ,p_display_name => l_role_displayname);
3288 --
3289 IF (l_role_name IS NOT NULL) THEN
3290 WF_ENGINE.setItemAttrText(itemtype, itemkey,'WPM_PLAN_MEMBER', l_role_name);
3291 resultout := 'COMPLETE:' || 'Y';
3292 return;
3293 END IF;
3294 --
3295 g_fetched_plan_member_index := g_qual_pop_tbl.NEXT(g_fetched_plan_member_index);
3296 --
3297 END LOOP;
3298 -- Loop complete wf role is not found for any plan member
3299 resultout := 'COMPLETE:' || 'N';
3300 --
3301 ELSE
3302 -- Plan population is not known
3303 resultout := 'ERROR' || 'Y';
3304 END IF;
3305 ELSE
3306 -- function mode is not Run
3307 resultout := 'ERROR' || 'Y';
3308 END IF;
3309 --
3310 exception
3311 when others then
3312 WF_CORE.CONTEXT('HR_PERF_MGMT_PLANS_INTERNAL'
3313 ,'GET_PLAN_MEMBER'
3314 ,itemtype
3315 ,itemkey
3316 ,to_char(actid)
3317 ,funcmode);
3318 raise;
3319 end get_plan_member;
3320 --
3321 -- ----------------------------------------------------------------------------
3322 -- |------------------------< get_top_plan_member >--------------------------|
3323 -- ----------------------------------------------------------------------------
3324 --
3325 procedure get_top_plan_member(itemtype in varchar2,
3326 itemkey in varchar2,
3327 actid in number,
3328 funcmode in varchar2,
3329 resultout out nocopy varchar2)
3330 is
3331 --
3332 l_plan_id number;
3333 l_plan_hierarchy varchar2(30);
3334 l_top_id number;
3335 l_role_name wf_roles.name%type;
3336 l_role_displayname wf_roles.display_name%type;
3337 --
3338 begin
3339 --
3340 IF (funcmode = 'RUN') then
3341
3342 -- Get the workwlow attribute values
3343 l_plan_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3344 itemkey => itemkey,
3345 aname => 'WPM_PLAN_ID');
3346 --
3347 l_plan_hierarchy := wf_engine.GetItemAttrText(itemtype => itemtype,
3348 itemkey => itemkey,
3349 aname => 'WPM_PLAN_HIERARCHY');
3350 IF (l_plan_hierarchy = 'SUP') THEN
3351 --
3352 l_top_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3353 itemkey => itemkey,
3354 aname => 'WPM_PLAN_SUPERVISOR_ID');
3355 ELSIF (l_plan_hierarchy = 'SUP_ASG') THEN
3356 --
3357 l_top_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3358 itemkey => itemkey,
3359 aname => 'WPM_PLAN_SUPERVISOR_ASG_ID');
3360 ELSIF (l_plan_hierarchy = 'ORG') THEN
3361 --
3362 l_top_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3363 itemkey => itemkey,
3364 aname => 'WPM_PLAN_TOP_ORG_ID');
3365 ELSIF (l_plan_hierarchy = 'POS') THEN
3366 --
3367 l_top_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3368 itemkey => itemkey,
3369 aname => 'WPM_PLAN_TOP_POS_ID');
3370 END IF;
3371
3372 -- If plan population is known
3373 IF (g_plan_pop_known_t(l_plan_id)) THEN
3374
3375 -- Get the current plan member index
3376 IF (g_fetched_plan_member_index IS NULL) THEN
3377 g_fetched_plan_member_index := g_qual_pop_tbl.FIRST;
3378 ELSE
3379 g_fetched_plan_member_index := g_qual_pop_tbl.NEXT(g_fetched_plan_member_index);
3380 END IF;
3381
3382 -- Loop till member is found with wf role
3383 WHILE (g_fetched_plan_member_index IS NOT NULL)
3384 LOOP
3385
3386 IF (l_plan_hierarchy = 'SUP' AND
3387 g_qual_pop_tbl(g_fetched_plan_member_index).person_id = l_top_id) OR
3388 (l_plan_hierarchy = 'SUP_ASG' AND
3389 g_qual_pop_tbl(g_fetched_plan_member_index).assignment_id = l_top_id) OR
3390 (l_plan_hierarchy = 'ORG' AND
3391 g_qual_pop_tbl(g_fetched_plan_member_index).organization_id = l_top_id) OR
3392 (l_plan_hierarchy = 'POS' AND
3393 g_qual_pop_tbl(g_fetched_plan_member_index).position_id = l_top_id)
3394 THEN
3395 -- Get the Role for the Owner
3396 wf_directory.getRoleName(p_orig_system => 'PER'
3397 ,p_orig_system_id => g_qual_pop_tbl(g_fetched_plan_member_index).person_id
3398 ,p_name => l_role_name
3399 ,p_display_name => l_role_displayname);
3400 --
3401 IF (l_role_name IS NOT NULL) THEN
3402 WF_ENGINE.setItemAttrText(itemtype, itemkey,'WPM_PLAN_MEMBER', l_role_name);
3403 resultout := 'COMPLETE:' || 'Y';
3404 return;
3405 END IF;
3406 --
3407 END IF;
3408
3409 --
3410 g_fetched_plan_member_index := g_qual_pop_tbl.NEXT(g_fetched_plan_member_index);
3411 --
3412 END LOOP;
3413 -- Loop complete wf role is not found for any plan member
3414 resultout := 'COMPLETE:' || 'N';
3415 --
3416 ELSE
3417 -- Plan population is not known
3418 resultout := 'ERROR' || 'Y';
3419 END IF;
3420 ELSE
3421 -- function mode is not Run
3422 resultout := 'ERROR' || 'Y';
3423 END IF;
3424 --
3425 exception
3426 when others then
3427 WF_CORE.CONTEXT('HR_PERF_MGMT_PLANS_INTERNAL'
3428 ,'GET_TOP_PLAN_MEMBER'
3429 ,itemtype
3430 ,itemkey
3431 ,to_char(actid)
3432 ,funcmode);
3433 raise;
3434 end get_top_plan_member;
3435 --
3436 -- ----------------------------------------------------------------------------
3437 -- |----------------------< get_non_top_plan_member >-------------------------|
3438 -- ----------------------------------------------------------------------------
3439 --
3440 procedure get_non_top_plan_member(itemtype in varchar2,
3441 itemkey in varchar2,
3442 actid in number,
3443 funcmode in varchar2,
3444 resultout out nocopy varchar2)
3445 is
3446 --
3447 l_plan_id number;
3448 l_plan_hierarchy varchar2(30);
3449 l_top_id number;
3450 l_role_name wf_roles.name%type;
3451 l_role_displayname wf_roles.display_name%type;
3452 --
3453 begin
3454 --
3455 IF (funcmode = 'RUN') then
3456
3457 -- Get the workwlow attribute values
3458 l_plan_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3459 itemkey => itemkey,
3460 aname => 'WPM_PLAN_ID');
3461 --
3462 l_plan_hierarchy := wf_engine.GetItemAttrText(itemtype => itemtype,
3463 itemkey => itemkey,
3464 aname => 'WPM_PLAN_HIERARCHY');
3465 IF (l_plan_hierarchy = 'SUP') THEN
3466 --
3467 l_top_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3468 itemkey => itemkey,
3469 aname => 'WPM_PLAN_SUPERVISOR_ID');
3470 ELSIF (l_plan_hierarchy = 'SUP_ASG') THEN
3471 --
3472 l_top_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3473 itemkey => itemkey,
3474 aname => 'WPM_PLAN_SUPERVISOR_ASG_ID');
3475 ELSIF (l_plan_hierarchy = 'ORG') THEN
3476 --
3477 l_top_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3478 itemkey => itemkey,
3479 aname => 'WPM_PLAN_TOP_ORG_ID');
3480 ELSIF (l_plan_hierarchy = 'POS') THEN
3481 --
3482 l_top_id := wf_engine.GetItemAttrText(itemtype => itemtype,
3483 itemkey => itemkey,
3484 aname => 'WPM_PLAN_TOP_POS_ID');
3485 END IF;
3486
3487 -- If plan population is known
3488 IF (g_plan_pop_known_t(l_plan_id)) THEN
3489
3490 -- Get the current plan member index
3491 IF (g_fetched_plan_member_index IS NULL) THEN
3492 g_fetched_plan_member_index := g_qual_pop_tbl.FIRST;
3493 ELSE
3494 g_fetched_plan_member_index := g_qual_pop_tbl.NEXT(g_fetched_plan_member_index);
3495 END IF;
3496
3497 -- Loop till member is found with wf role
3498 WHILE (g_fetched_plan_member_index IS NOT NULL)
3499 LOOP
3500
3501 IF (l_plan_hierarchy = 'SUP' AND
3502 g_qual_pop_tbl(g_fetched_plan_member_index).person_id <> l_top_id) OR
3503 (l_plan_hierarchy = 'SUP_ASG' AND
3504 g_qual_pop_tbl(g_fetched_plan_member_index).assignment_id <> l_top_id) OR
3505 (l_plan_hierarchy = 'ORG' AND
3506 g_qual_pop_tbl(g_fetched_plan_member_index).organization_id <> l_top_id) OR
3507 (l_plan_hierarchy = 'POS' AND
3508 g_qual_pop_tbl(g_fetched_plan_member_index).position_id <> l_top_id)
3509 THEN
3510 -- Get the Role for the Owner
3511 wf_directory.getRoleName(p_orig_system => 'PER'
3512 ,p_orig_system_id => g_qual_pop_tbl(g_fetched_plan_member_index).person_id
3513 ,p_name => l_role_name
3514 ,p_display_name => l_role_displayname);
3515 --
3516 IF (l_role_name IS NOT NULL) THEN
3517 WF_ENGINE.setItemAttrText(itemtype, itemkey,'WPM_PLAN_MEMBER', l_role_name);
3518 resultout := 'COMPLETE:' || 'Y';
3519 return;
3520 END IF;
3521 --
3522 END IF;
3523
3524 --
3525 g_fetched_plan_member_index := g_qual_pop_tbl.NEXT(g_fetched_plan_member_index);
3526 --
3527 END LOOP;
3528 -- Loop complete wf role is not found for any plan member
3529 resultout := 'COMPLETE:' || 'N';
3530 --
3531 ELSE
3532 -- Plan population is not known
3533 resultout := 'ERROR' || 'Y';
3534 END IF;
3535 ELSE
3536 -- function mode is not Run
3537 resultout := 'ERROR' || 'Y';
3538 END IF;
3539 --
3540 exception
3541 when others then
3542 WF_CORE.CONTEXT('HR_PERF_MGMT_PLANS_INTERNAL'
3543 ,'GET_NON_TOP_PLAN_MEMBER'
3544 ,itemtype
3545 ,itemkey
3546 ,to_char(actid)
3547 ,funcmode);
3548 raise;
3549 end get_non_top_plan_member;
3550 --
3551 -- ----------------------------------------------------------------------------
3552 -- |---------------------< submit_publish_plan_cp >---------------------------|
3553 -- ----------------------------------------------------------------------------
3554 --
3555 procedure submit_publish_plan_cp(p_effective_date in varchar2
3556 ,p_plan_id in number
3557 ,p_reverse_mode in varchar2
3558 ,p_item_type in varchar2
3559 ,p_wf_process in varchar2
3560 ,p_object_version_number in out nocopy number
3561 ,p_status_code in out nocopy varchar2)
3562 is
3563 --
3564 l_object_version_number number := p_object_version_number;
3565 l_status_code per_perf_mgmt_plans.status_code%TYPE;
3566 l_dummy boolean;
3567 l_request_id number;
3568 l_effective_date date := nvl(p_effective_date,trunc(sysdate));
3569 -- Plan record
3570 CURSOR csr_get_plan_rec IS
3571 SELECT *
3572 FROM per_perf_mgmt_plans
3573 WHERE plan_id = p_plan_id;
3574 l_plan_rec per_perf_mgmt_plans%ROWTYPE;
3575 --
3576 begin
3577 -- Submit the request
3578 l_request_id := fnd_request.submit_request(
3579 application => 'PER'
3580 ,program => 'PERPLNPUB'
3581 ,sub_request => FALSE
3582 ,argument1 => fnd_date.date_to_canonical(l_effective_date)
3583 ,argument2 => p_plan_id
3584 ,argument3 => p_reverse_mode
3585 ,argument4 => 'N'
3586 ,argument5 => 'Y'
3587 ,argument6 => null
3588 ,argument7 => 'HRWPM'
3589 ,argument8 => 'HR_NOTIFY_WPM_PLAN_POP_PRC');
3590 --
3591 if l_request_id > 0 then
3592 -- Update the status of plan
3593 if (p_status_code = 'DRAFT') then
3594 l_status_code := 'SUBMITTED';
3595 elsif (p_status_code = 'UPDATED' or p_status_code = 'FAILED') then
3596 l_status_code := 'RESUBMITTED';
3597 end if;
3598 --
3599 per_pmp_upd.upd(p_plan_id => p_plan_id
3600 ,p_effective_date => l_effective_date
3601 ,p_object_version_number => l_object_version_number
3602 ,p_status_code => l_status_code
3603 ,p_duplicate_name_warning => l_dummy
3604 ,p_no_life_events_warning => l_dummy);
3605 --
3606 p_object_version_number := l_object_version_number;
3607 p_status_code := l_status_code;
3608 --
3609 -- Get Plan record
3610 --
3611 OPEN csr_get_plan_rec;
3612 FETCH csr_get_plan_rec INTO l_plan_rec;
3613 CLOSE csr_get_plan_rec;
3614 --
3615 -- Send notification to administrator that plan publish errored
3616 --
3617 send_fyi_admin(p_plan_rec => l_plan_rec
3618 ,p_status => 'SUBMITTED'
3619 ,p_request_id => l_request_id);
3620 else
3621 p_status_code := 'E';
3622 end if;
3623 --
3624 end submit_publish_plan_cp;
3625 --
3626 -- ----------------------------------------------------------------------------
3627 -- |---------------------------< publish_plan_cp >----------------------------|
3628 -- ----------------------------------------------------------------------------
3629 --
3630 procedure publish_plan_cp
3631 (errbuf out nocopy varchar2
3632 ,retcode out nocopy number
3633 ,p_effective_date in varchar2
3634 ,p_plan_id in number
3635 ,p_reverse_mode in varchar2 default 'N'
3636 ,p_what_if in varchar2 default 'N'
3637 ,p_log_output in varchar2 default 'N'
3638 ,p_action_parameter_group_id in number default NULL
3639 ,p_item_type in varchar2 default 'HRWPM'
3640 ,p_wf_process in varchar2 default 'HR_NOTIFY_WPM_PLAN_POP_PRC'
3641 ) is
3642
3643 --
3644 cursor csr_plan_ovn is
3645 select object_version_number
3646 from per_perf_mgmt_plans
3647 where plan_id = p_plan_id;
3648 cursor csr_plan_status_code is
3649 select status_code
3650 from per_perf_mgmt_plans
3651 where plan_id = p_plan_id;
3652
3653 l_object_version_number number;
3654 l_status_code per_perf_mgmt_plans.status_code%TYPE;
3655 l_dummy boolean;
3656 --
3657 begin
3658 --
3659 -- Derive the object version number of plan record
3660 --
3661 open csr_plan_ovn;
3662 fetch csr_plan_ovn into l_object_version_number;
3663 close csr_plan_ovn;
3664
3665 -- get the status of plan, if it is called from scheduled concureent program status should be chsnged to resubmitted.
3666 open csr_plan_status_code;
3667 fetch csr_plan_status_code into l_status_code;
3668 close csr_plan_status_code;
3669 -- Initialize return status
3670 retcode := WARNING;
3671
3672 -- (bug 6460457) changes to allow published plan to be rerun through scheduled concurrent prgms.
3673 if l_status_code in ('PUBLISHED','FAILED') then
3674 l_status_code := 'RESUBMITTED';
3675
3676
3677 per_pmp_upd.upd(p_plan_id => p_plan_id
3678 ,p_effective_date => fnd_date.canonical_to_date(p_effective_date)
3679 ,p_object_version_number => l_object_version_number
3680 ,p_status_code => l_status_code
3681 ,p_duplicate_name_warning => l_dummy
3682 ,p_no_life_events_warning => l_dummy);
3683
3684 -- get the new ovn number to pass it to publish_plan function as update is called before this once
3685 open csr_plan_ovn;
3686 fetch csr_plan_ovn into l_object_version_number;
3687 close csr_plan_ovn;
3688
3689 end if;
3690 --
3691 -- Call the publish plan
3692 --
3693 publish_plan
3694 (p_effective_date => fnd_date.canonical_to_date(p_effective_date)
3695 ,p_plan_id => p_plan_id
3696 ,p_object_version_number => l_object_version_number
3697 ,p_reverse_mode => p_reverse_mode
3698 ,p_what_if => p_what_if
3699 ,p_log_output => p_log_output
3700 ,p_action_parameter_group_id => p_action_parameter_group_id
3701 ,p_item_type => p_item_type
3702 ,p_wf_process => p_wf_process
3703 );
3704
3705 --
3706 errbuf := g_errbuf;
3707 retcode:= g_retcode;
3708 --
3709 commit;
3710 --
3711 exception
3712 when others then
3713 rollback;
3714 --
3715 -- update status of the plan to 'Failed'
3716 --
3717 update per_perf_mgmt_plans
3718 set status_code = 'FAILED'
3719 where plan_id = p_plan_id;
3720 commit;
3721 --
3722 errbuf := g_errbuf;
3723 retcode:= g_retcode;
3724 --
3725 end publish_plan_cp;
3726 --
3727 -- ----------------------------------------------------------------------------
3728 -- |-----------------------------< publish_plan >-----------------------------|
3729 -- ----------------------------------------------------------------------------
3730 --
3731 procedure publish_plan
3732 (p_effective_date in date
3733 ,p_plan_id in number
3734 ,p_object_version_number in out nocopy number
3735 ,p_reverse_mode in varchar2 default 'N'
3736 ,p_what_if in varchar2 default 'N'
3737 ,p_log_output in varchar2 default 'N'
3738 ,p_action_parameter_group_id in number default NULL
3739 ,p_item_type in varchar2 default 'HRWPM'
3740 ,p_wf_process in varchar2 default 'HR_NOTIFY_WPM_PLAN_POP_PRC'
3741 ) is
3742
3743 --
3744 -- Declare cursors and local variables
3745 --
3746 l_proc varchar2(72) := g_package||'publish_plan';
3747 l_logging pay_action_parameters.parameter_value%type;
3748 l_debug boolean := FALSE;
3749 l_effective_date date := TRUNC(nvl(p_effective_date, sysdate));
3750 l_object_version_number number;
3751 l_status_code per_perf_mgmt_plans.status_code%TYPE;
3752 l_dummy boolean;
3753
3754 --
3755 l_scorecard_id per_personal_scorecards.scorecard_id%TYPE;
3756 --
3757 l_message_count number := 0;
3758 l_message varchar2(256);
3759 l_qual_pop_index binary_integer;
3760 l_curr_sc_pop_index binary_integer;
3761 l_qual_obj_index binary_integer;
3762 l_plan_aprsl_pds_index binary_integer;
3763 l_curr_sc_obj_index binary_integer;
3764 l_appr_ret_status varchar2(1);
3765 l_check_elig varchar2(1);
3766 -- Cursor to get the Participants of an appraisal other than MA
3767 CURSOR csr_get_appr_part(p_appraisal_id per_appraisals.appraisal_id%TYPE) IS
3768 select PARTICIPANT_ID ,OBJECT_VERSION_NUMBER,PARTICIPATION_TYPE from per_participants
3769 where participation_in_id =p_appraisal_id
3770 and participation_in_table = 'PER_APPRAISALS'
3771 and participation_in_column = 'APPRAISAL_ID'
3772 and PARTICIPATION_TYPE <> 'MAINAP'
3773 and PARTICIPATION_STATUS = 'OPEN';
3774
3775 -- Plan record
3776 CURSOR csr_get_plan_rec IS
3777 SELECT *
3778 FROM per_perf_mgmt_plans
3779 WHERE plan_id = p_plan_id;
3780
3781 -- Scorecard Objectives
3782 CURSOR csr_sc_objectives(p_scorecard_id number) IS
3783 select objective_id, object_version_number
3784 from per_objectives
3785 where scorecard_id = p_scorecard_id;
3786
3787 CURSOR csr_plan_appraisals(plan_id per_appraisals.plan_id%TYPE) IS
3788 select appraisal_id, object_version_number from per_appraisals
3789 where plan_id = plan_id;
3790
3791 CURSOR csr_find_appr_for_scorecard(p_plan_id per_appraisals.plan_id%TYPE,p_scorecard_id per_personal_scorecards.SCORECARD_ID%TYPE ) IS
3792 select pa.appraisal_id, pa.object_version_number ,pa.appraisal_system_status
3793 from per_appraisals pa,per_personal_scorecards pps
3794 where pa.plan_id = p_plan_id
3795 and APPRAISEE_PERSON_ID =pps.person_id
3796 and pps.scorecard_id =p_scorecard_id;
3797
3798
3799 l_plan_rec per_perf_mgmt_plans%ROWTYPE;
3800 l_obj_date date :=trunc(sysdate);
3801 l_scorecard_status_code varchar2(30);
3802 l_process_date date;
3803 l_process_date_char varchar2(50);
3804 l_request_id number;
3805 l_appr_ovn per_appraisals.object_version_number%TYPE;
3806 l_appr_id per_appraisals.appraisal_id%TYPE;
3807 l_appr_sys_status per_appraisals.appraisal_system_status%TYPE;
3808 l_appraiser_person_id per_appraisals.appraiser_person_id%TYPE;
3809 begin
3810 --
3811 -- Initialize logging
3812 --
3813 initialize_logging(p_action_parameter_group_id => p_action_parameter_group_id,
3814 p_log_output => p_log_output);
3815
3816 --
3817 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
3818 --
3819 -- Get Plan record
3820 --
3821 OPEN csr_get_plan_rec;
3822 FETCH csr_get_plan_rec INTO l_plan_rec;
3823 CLOSE csr_get_plan_rec;
3824 --
3825 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 20); END IF;
3826 l_request_id := fnd_global.conc_request_id;
3827 IF g_dbg THEN op('Plan Name: '|| substr(l_plan_rec.plan_name,1,40), g_DEBUG_LOG, 21); END IF;
3828 IF g_dbg THEN op('Concurrent Request ID: '|| to_char(l_request_id), g_DEBUG_LOG, 22); END IF;
3829 --
3830 -- Checks that the status is valid for PLAN PUBLISH OR REVERSE PUBLISH
3831 --
3832 chk_publishing_status(p_reverse_mode, l_plan_rec.status_code);
3833 --
3834 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 30); END IF;
3835 -- If objective setting flag or appraisals flag is set then
3836 -- populate qualifying population table
3837 IF ((l_plan_rec.include_obj_setting_flag = 'Y') OR
3838 (l_plan_rec.include_appraisals_flag = 'Y')) THEN
3839 --
3840 -- Get the qualifying plan population
3841 -- g_qual_pop_tbl is populated with index as 'assignment_id'
3842 --
3843 populate_qual_plan_population(l_plan_rec, l_effective_date);
3844 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 40); END IF;
3845 END IF;
3846
3847 -- If objective setting flag is set then
3848 -- populate current population and qualifying objectives tables
3849 IF ((l_plan_rec.include_obj_setting_flag = 'Y') OR
3850 (l_plan_rec.include_appraisals_flag = 'Y')) THEN
3851 --
3852 -- Get existing plan population if plan is republished or reverse published
3853 -- g_curr_sc_pop_tbl is populated with index as 'assignment_id'
3854 --
3855 IF (l_plan_rec.status_code IN ('UPDATED','RESUBMITTED','PUBLISHED')) THEN
3856 --
3857 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 50); END IF;
3858 populate_curr_plan_population(p_plan_id);
3859 END IF;
3860 --
3861 -- Get the qualifying objectives
3862 -- g_qual_obj_tbl is populated with index as 'objective_id'
3863 --
3864 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 60); END IF;
3865 --
3866 IF (l_plan_rec.automatic_allocation_flag = 'Y') THEN
3867 populate_qual_objectives(l_plan_rec.start_date, l_plan_rec.end_date);
3868 END IF;
3869 END IF;
3870
3871
3872 -- If appraisals flag is set then
3873 -- populate appraisala period table
3874 IF (l_plan_rec.include_appraisals_flag = 'Y') THEN
3875 --
3876 -- Get the qualifying plan periods
3877 -- g_plan_aprsl_pds_tbl is populated with details
3878 --
3879 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 70); END IF;
3880 --
3881 populate_plan_apprsl_periods(l_plan_rec.plan_id);
3882 END IF;
3883 --
3884 -- Loop through plan population to create/update/delete scorecards, objectives and appraisal
3885 --
3886 l_qual_pop_index := g_qual_pop_tbl.FIRST;
3887 WHILE (l_qual_pop_index IS NOT NULL)
3888 LOOP
3889 --
3890 l_qual_obj_index := g_qual_obj_tbl.FIRST;
3891 IF (l_plan_rec.status_code in ('DRAFT','SUBMITTED') OR
3892 (l_plan_rec.status_code in ('UPDATED','RESUBMITTED') AND NOT g_curr_sc_pop_tbl.EXISTS(l_qual_pop_index)))
3893 THEN
3894
3895 -- If objective setting flag is set
3896 IF ((l_plan_rec.include_obj_setting_flag = 'Y') OR
3897 (l_plan_rec.include_appraisals_flag = 'Y'))
3898 THEN
3899 -- Create the scorecard for this assignment
3900 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 80); END IF;
3901 IF l_plan_rec.method_code = 'CAS' THEN
3902
3903 IF (l_plan_rec.hierarchy_type_code ='SUP' AND
3904 l_plan_rec.supervisor_id = g_qual_pop_tbl(l_qual_pop_index).person_id) OR
3905 (l_plan_rec.hierarchy_type_code = 'SUP_ASG' AND
3906 l_plan_rec.supervisor_assignment_id = g_qual_pop_tbl(l_qual_pop_index).assignment_id) OR
3907 (l_plan_rec.hierarchy_type_code in ('POS') AND
3908 l_plan_rec.top_position_id = g_qual_pop_tbl(l_qual_pop_index).position_id) OR
3909 ( l_plan_rec.hierarchy_type_code ='ORG' AND
3910 is_supervisor_in_org(l_plan_rec.top_organization_id,g_qual_pop_tbl(l_qual_pop_index).person_id)=1)
3911 THEN
3912 l_scorecard_status_code := 'NOT_STARTED_WITH_WKR';
3913 ELSE
3914 l_scorecard_status_code := 'NOT_STARTED_WITH_MGR';
3915 END IF;
3916 ELSE
3917 l_scorecard_status_code := 'NOT_STARTED_WITH_WKR';
3918 END IF;
3919 --
3920 create_scorecard_for_person(
3921 p_effective_date => l_effective_date
3922 ,p_scorecard_name => l_plan_rec.plan_name
3923 ,p_assignment_id => g_qual_pop_tbl(l_qual_pop_index).assignment_id
3924 ,p_start_date => l_plan_rec.start_date
3925 ,p_end_date => l_plan_rec.end_date
3926 ,p_plan_id => l_plan_rec.plan_id
3927 ,p_creator_type => 'AUTO'
3928 ,p_status_code => l_scorecard_status_code
3929 ,p_scorecard_id => l_scorecard_id);
3930 -- Loop through objectives and create the qualifying objectives for scorecard
3931 -- make sure objectives are not created if scorecard is not created
3932 IF (l_plan_rec.automatic_allocation_flag = 'Y' AND l_scorecard_id is not NULL)
3933 THEN
3934 l_qual_obj_index := g_qual_obj_tbl.FIRST;
3935 WHILE (l_qual_obj_index IS NOT NULL)
3936 LOOP
3937 -- Following is commented, and l_obj_date is being set to sysdate bug# 5211538
3938 -- l_obj_date is being seto to sysdate in the declare block itself
3939 /*
3940 -- objective date should be later of plan start date on obgective valif_from date
3941 l_obj_date := l_plan_rec.start_date;
3942 IF (l_plan_rec.start_date < g_qual_obj_tbl(l_qual_obj_index).valid_from) THEN
3943 l_obj_date := g_qual_obj_tbl(l_qual_obj_index).valid_from;
3944 END IF;
3945 */
3946 --
3947 -- Enclose the call to eligibility within a block, so that if for any
3948 -- reason the eligibility engine errors, then process can still
3949 -- continue by skipping the current person/assignemnt as not eligible
3950 --
3951 BEGIN
3952 --
3953 ben_env_object.init
3954 (p_business_group_id => g_qual_pop_tbl(l_qual_pop_index).business_group_id,
3955 p_thread_id => null,
3956 p_chunk_size => null,
3957 p_threads => null,
3958 p_max_errors => null,
3959 p_benefit_action_id => null,
3960 p_effective_date => l_obj_date);
3961 --
3962 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 222);
3963 op(l_proc||g_qual_obj_tbl(l_qual_obj_index).elig_obj_id, g_DEBUG_LOG, 222);
3964 op(l_proc, g_DEBUG_LOG, 222);
3965 END IF;
3966 --
3967 l_check_elig:= ben_per_asg_elig.eligible(g_qual_pop_tbl(l_qual_pop_index).person_id
3968 ,g_qual_pop_tbl(l_qual_pop_index).assignment_id
3969 ,g_qual_obj_tbl(l_qual_obj_index).elig_obj_id
3970 ,l_obj_date
3971 ,g_qual_pop_tbl(l_qual_pop_index).business_group_id);
3972 EXCEPTION
3973 when others then
3974 l_check_elig := 'N';
3975 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 333); END IF;
3976 IF g_dbg THEN op(l_proc||' SKIPPED '||g_qual_obj_tbl(l_qual_obj_index).elig_obj_id, g_DEBUG_LOG, 333); END IF;
3977 END;
3978 IF (l_check_elig = 'Y') THEN
3979
3980
3981 -- Create the objective
3982 create_scorecard_objective(
3983 p_effective_date => l_effective_date
3984 ,p_scorecard_id => l_scorecard_id
3985 ,p_business_group_id => g_qual_pop_tbl(l_qual_pop_index).business_group_id
3986 ,p_person_id => g_qual_pop_tbl(l_qual_pop_index).person_id
3987 ,p_start_date => l_plan_rec.start_date
3988 ,p_end_date => l_plan_rec.end_date
3989 ,p_objective_name => g_qual_obj_tbl(l_qual_obj_index).objective_name
3990 ,p_valid_from => g_qual_obj_tbl(l_qual_obj_index).valid_from
3991 ,p_valid_to => g_qual_obj_tbl(l_qual_obj_index).valid_to
3992 ,p_target_date => g_qual_obj_tbl(l_qual_obj_index).target_date
3993 ,p_copied_from_library_id => g_qual_obj_tbl(l_qual_obj_index).objective_id
3994 ,p_next_review_date => g_qual_obj_tbl(l_qual_obj_index).NEXT_review_date
3995 ,p_group_code => g_qual_obj_tbl(l_qual_obj_index).group_code
3996 ,p_priority_code => g_qual_obj_tbl(l_qual_obj_index).priority_code
3997 ,p_appraise_flag => g_qual_obj_tbl(l_qual_obj_index).appraise_flag
3998 ,p_weighting_percent => g_qual_obj_tbl(l_qual_obj_index).weighting_percent
3999 ,p_target_value => g_qual_obj_tbl(l_qual_obj_index).target_value
4000 ,p_uom_code => g_qual_obj_tbl(l_qual_obj_index).uom_code
4001 ,p_measurement_style_code => g_qual_obj_tbl(l_qual_obj_index).measurement_style_code
4002 ,p_measure_name => g_qual_obj_tbl(l_qual_obj_index).measure_name
4003 ,p_measure_type_code => g_qual_obj_tbl(l_qual_obj_index).measure_type_code
4004 ,p_measure_comments => g_qual_obj_tbl(l_qual_obj_index).measure_comments
4005 ,p_details => g_qual_obj_tbl(l_qual_obj_index).details
4006 ,p_success_criteria => g_qual_obj_tbl(l_qual_obj_index).success_criteria
4007 ,p_comments => g_qual_obj_tbl(l_qual_obj_index).comments);
4008 END IF;
4009 --
4010 l_qual_obj_index := g_qual_obj_tbl.NEXT(l_qual_obj_index);
4011 --
4012 END LOOP; -- l_qual_obj_index IS NOT NULL
4013 END IF; -- l_plan_rec.automatic_allocation_flag
4014 --
4015 -- Copy past objectives if the flag is set and previous plan id is available
4016 --
4017 IF (l_plan_rec.copy_past_objectives_flag = 'Y' AND l_plan_rec.previous_plan_id is not NULL)
4018 THEN
4019 --
4020 copy_past_objectives
4021 (p_effective_date => l_effective_date
4022 ,p_business_group_id => g_qual_pop_tbl(l_qual_pop_index).business_group_id
4023 ,p_person_id => g_qual_pop_tbl(l_qual_pop_index).person_id
4024 ,p_scorecard_id => l_scorecard_id
4025 ,p_start_date => l_plan_rec.start_date
4026 ,p_end_date => l_plan_rec.end_date
4027 ,p_target_date => null
4028 ,p_assignemnt_id => g_qual_pop_tbl(l_qual_pop_index).assignment_id
4029 ,p_prev_plan_id => l_plan_rec.previous_plan_id
4030 ,p_curr_plan_id => l_plan_rec.plan_id);
4031 --
4032 END IF; -- Copying past Objectives
4033 --
4034
4035 --
4036 END IF;
4037
4038 ELSIF (l_plan_rec.status_code in ('UPDATED','RESUBMITTED') AND g_curr_sc_pop_tbl.EXISTS(l_qual_pop_index)) THEN
4039
4040 -- If objective setting flag is set
4041 IF ((l_plan_rec.include_obj_setting_flag = 'Y') OR
4042 (l_plan_rec.include_appraisals_flag = 'Y'))
4043 THEN
4044
4045 -- Update the scorecard for this assignment
4046 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 90); END IF;
4047 l_scorecard_id := g_curr_sc_pop_tbl(l_qual_pop_index).scorecard_id;
4048
4049 -- additional AND clause added to the IF condition, as we do not want to change the
4050 -- scorecard status unless status is PUBLISHED
4051 IF (nvl(l_plan_rec.change_sc_status_flag,'N') = 'Y'
4052 AND g_curr_sc_pop_tbl(l_qual_pop_index).status_code='PUBLISHED')
4053 THEN
4054 IF l_plan_rec.method_code = 'CAS' THEN
4055 --
4056 IF (l_plan_rec.hierarchy_type_code ='SUP' AND
4057 l_plan_rec.supervisor_id = g_qual_pop_tbl(l_qual_pop_index).person_id) OR
4058 (l_plan_rec.hierarchy_type_code = 'SUP_ASG' AND
4059 l_plan_rec.supervisor_assignment_id = g_qual_pop_tbl(l_qual_pop_index).assignment_id) OR
4060 (l_plan_rec.hierarchy_type_code in ('POS') AND
4061 l_plan_rec.top_position_id = g_qual_pop_tbl(l_qual_pop_index).position_id) OR
4062 ( l_plan_rec.hierarchy_type_code ='ORG' AND
4063 is_supervisor_in_org(l_plan_rec.top_organization_id,g_qual_pop_tbl(l_qual_pop_index).person_id)=1)
4064 THEN
4065 l_scorecard_status_code := 'NOT_STARTED_WITH_WKR';
4066 ELSE
4067 l_scorecard_status_code := 'NOT_STARTED_WITH_MGR';
4068 END IF;
4069 ELSE
4070 l_scorecard_status_code := 'NOT_STARTED_WITH_WKR';
4071 END IF;
4072 --
4073 update_scorecard_for_person(
4074 p_effective_date => l_effective_date
4075 ,p_scorecard_id => l_scorecard_id
4076 ,p_object_version_number => g_curr_sc_pop_tbl(l_qual_pop_index).object_version_number
4077 ,p_scorecard_name => l_plan_rec.plan_name
4078 ,p_start_date => l_plan_rec.start_date
4079 ,p_end_date => l_plan_rec.end_date
4080 ,p_status_code => l_scorecard_status_code
4081 );
4082 ELSE
4083 update_scorecard_for_person(
4084 p_effective_date => l_effective_date
4085 ,p_scorecard_id => l_scorecard_id
4086 ,p_object_version_number => g_curr_sc_pop_tbl(l_qual_pop_index).object_version_number
4087 ,p_scorecard_name => l_plan_rec.plan_name
4088 ,p_start_date => l_plan_rec.start_date
4089 ,p_end_date => l_plan_rec.end_date);
4090 END IF;
4091 --
4092 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 100); END IF;
4093
4094 --
4095 -- Populate existing objectives for this scorecard
4096 -- g_curr_sc_obj_tbl is populated with index as 'copied_from_library_id'
4097 --
4098 populate_curr_sc_objectives(l_scorecard_id);
4099
4100 -- Loop through objectives and create the qualifying objectives for scorecard
4101 -- make sure objectives are not created if scorecard is not created
4102 IF (l_plan_rec.automatic_allocation_flag = 'Y' AND l_scorecard_id is not NULL)
4103 THEN
4104
4105 l_qual_obj_index := g_qual_obj_tbl.FIRST;
4106 WHILE (l_qual_obj_index IS NOT NULL)
4107 LOOP
4108 -- Following is commented, and l_obj_date is being set to sysdate bug# 5211538
4109 -- l_obj_date is being seto to sysdate in the declare block itself
4110 /*
4111 -- objective date should be later of plan start date on obgective valif_from date
4112 l_obj_date := l_plan_rec.start_date;
4113 IF (l_plan_rec.start_date < g_qual_obj_tbl(l_qual_obj_index).valid_from) THEN
4114 l_obj_date := g_qual_obj_tbl(l_qual_obj_index).valid_from;
4115 END IF;
4116 */
4117 --
4118 -- Enclose the call to eligibility within a block, so that if for any
4119 -- reason the eligibility engine errors, then process can still
4120 -- continue by skipping the current person/assignemnt as not eligible
4121 --
4122 BEGIN
4123 --
4124 ben_env_object.init
4125 (p_business_group_id => g_qual_pop_tbl(l_qual_pop_index).business_group_id,
4126 p_thread_id => null,
4127 p_chunk_size => null,
4128 p_threads => null,
4129 p_max_errors => null,
4130 p_benefit_action_id => null,
4131 p_effective_date => l_obj_date);
4132 --
4133 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 222);
4134 op(l_proc||g_qual_obj_tbl(l_qual_obj_index).elig_obj_id, g_DEBUG_LOG, 222);
4135 op(l_proc, g_DEBUG_LOG, 222);
4136 END IF;
4137 --
4138 l_check_elig:= ben_per_asg_elig.eligible(g_qual_pop_tbl(l_qual_pop_index).person_id
4139 ,g_qual_pop_tbl(l_qual_pop_index).assignment_id
4140 ,g_qual_obj_tbl(l_qual_obj_index).elig_obj_id
4141 ,l_obj_date
4142 ,g_qual_pop_tbl(l_qual_pop_index).business_group_id);
4143 EXCEPTION
4144 when others then
4145 l_check_elig := 'N';
4146 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 333); END IF;
4147 IF g_dbg THEN op(l_proc||'-- SKIPPED --'||g_qual_obj_tbl(l_qual_obj_index).elig_obj_id, g_DEBUG_LOG, 333); END IF;
4148 END;
4149 --
4150 IF (l_check_elig = 'Y') THEN
4151 --
4152 -- if it's newly qualified objective then create else update
4153 --
4154 IF (NOT g_curr_sc_obj_tbl.EXISTS(g_qual_obj_tbl(l_qual_obj_index).objective_id)) THEN
4155 -- Create the objective
4156 create_scorecard_objective(
4157 p_effective_date => l_effective_date
4158 ,p_scorecard_id => l_scorecard_id
4159 ,p_business_group_id => g_qual_pop_tbl(l_qual_pop_index).business_group_id
4160 ,p_person_id => g_qual_pop_tbl(l_qual_pop_index).person_id
4161 ,p_start_date => l_plan_rec.start_date
4162 ,p_end_date => l_plan_rec.end_date
4163 ,p_objective_name => g_qual_obj_tbl(l_qual_obj_index).objective_name
4164 ,p_valid_from => g_qual_obj_tbl(l_qual_obj_index).valid_from
4165 ,p_valid_to => g_qual_obj_tbl(l_qual_obj_index).valid_to
4166 ,p_target_date => g_qual_obj_tbl(l_qual_obj_index).target_date
4167 ,p_copied_from_library_id => g_qual_obj_tbl(l_qual_obj_index).objective_id
4168 ,p_next_review_date => g_qual_obj_tbl(l_qual_obj_index).NEXT_review_date
4169 ,p_group_code => g_qual_obj_tbl(l_qual_obj_index).group_code
4170 ,p_priority_code => g_qual_obj_tbl(l_qual_obj_index).priority_code
4171 ,p_appraise_flag => g_qual_obj_tbl(l_qual_obj_index).appraise_flag
4172 ,p_weighting_percent => g_qual_obj_tbl(l_qual_obj_index).weighting_percent
4173 ,p_target_value => g_qual_obj_tbl(l_qual_obj_index).target_value
4174 ,p_uom_code => g_qual_obj_tbl(l_qual_obj_index).uom_code
4175 ,p_measurement_style_code => g_qual_obj_tbl(l_qual_obj_index).measurement_style_code
4176 ,p_measure_name => g_qual_obj_tbl(l_qual_obj_index).measure_name
4177 ,p_measure_type_code => g_qual_obj_tbl(l_qual_obj_index).measure_type_code
4178 ,p_measure_comments => g_qual_obj_tbl(l_qual_obj_index).measure_comments
4179 ,p_details => g_qual_obj_tbl(l_qual_obj_index).details
4180 ,p_success_criteria => g_qual_obj_tbl(l_qual_obj_index).success_criteria
4181 ,p_comments => g_qual_obj_tbl(l_qual_obj_index).comments);
4182 --
4183 ELSE
4184 -- Update the objective
4185
4186 update_scorecard_objective(
4187 p_effective_date => l_effective_date
4188 ,p_objective_id => g_curr_sc_obj_tbl(l_qual_obj_index).objective_id
4189 ,p_object_version_number => g_curr_sc_obj_tbl(l_qual_obj_index).object_version_number
4190 ,p_scorecard_id => l_scorecard_id
4191 ,p_start_date => l_plan_rec.start_date
4192 ,p_end_date => l_plan_rec.end_date
4193 ,p_objective_name => g_qual_obj_tbl(l_qual_obj_index).objective_name
4194 ,p_valid_from => g_qual_obj_tbl(l_qual_obj_index).valid_from
4195 ,p_valid_to => g_qual_obj_tbl(l_qual_obj_index).valid_to
4196 ,p_target_date => g_qual_obj_tbl(l_qual_obj_index).target_date
4197 ,p_copied_from_library_id => g_qual_obj_tbl(l_qual_obj_index).objective_id
4198 ,p_next_review_date => g_qual_obj_tbl(l_qual_obj_index).NEXT_review_date
4199 ,p_group_code => g_qual_obj_tbl(l_qual_obj_index).group_code
4200 ,p_priority_code => g_qual_obj_tbl(l_qual_obj_index).priority_code
4201 ,p_appraise_flag => g_qual_obj_tbl(l_qual_obj_index).appraise_flag
4202 ,p_weighting_percent => g_qual_obj_tbl(l_qual_obj_index).weighting_percent
4203 ,p_target_value => g_qual_obj_tbl(l_qual_obj_index).target_value
4204 ,p_uom_code => g_qual_obj_tbl(l_qual_obj_index).uom_code
4205 ,p_measurement_style_code => g_qual_obj_tbl(l_qual_obj_index).measurement_style_code
4206 ,p_measure_name => g_qual_obj_tbl(l_qual_obj_index).measure_name
4207 ,p_measure_type_code => g_qual_obj_tbl(l_qual_obj_index).measure_type_code
4208 ,p_measure_comments => g_qual_obj_tbl(l_qual_obj_index).measure_comments
4209 ,p_details => g_qual_obj_tbl(l_qual_obj_index).details
4210 ,p_success_criteria => g_qual_obj_tbl(l_qual_obj_index).success_criteria
4211 ,p_comments => g_qual_obj_tbl(l_qual_obj_index).comments);
4212 END IF;
4213 --
4214 ELSE
4215 --
4216 -- End date objectives that qulify but are not eligible anymore and exists in current objectives
4217 --
4218 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 110); END IF;
4219 --
4220 IF (g_curr_sc_obj_tbl.EXISTS(g_qual_obj_tbl(l_qual_obj_index).objective_id)) THEN
4221
4222 update_scorecard_objective(
4223 p_effective_date => l_effective_date
4224 ,p_start_date => l_plan_rec.start_date
4225 ,p_objective_id => g_curr_sc_obj_tbl(l_qual_obj_index).objective_id
4226 ,p_object_version_number => g_curr_sc_obj_tbl(l_qual_obj_index).object_version_number
4227 ,p_end_date => l_effective_date);
4228
4229 END IF;
4230 --
4231 END IF; --Eligible check
4232 --
4233 l_qual_obj_index := g_qual_obj_tbl.NEXT(l_qual_obj_index);
4234 --
4235 END LOOP;
4236 --
4237 END IF; --automatic_allocation_flag
4238 --
4239 -- Copy past objectives if the flag is set and previous plan id is available
4240 --
4241 IF (l_plan_rec.copy_past_objectives_flag = 'Y' AND l_plan_rec.previous_plan_id is not NULL)
4242 THEN
4243 --
4244 copy_past_objectives
4245 (p_effective_date => l_effective_date
4246 ,p_business_group_id => g_qual_pop_tbl(l_qual_pop_index).business_group_id
4247 ,p_person_id => g_qual_pop_tbl(l_qual_pop_index).person_id
4248 ,p_scorecard_id => l_scorecard_id
4249 ,p_start_date => l_plan_rec.start_date
4250 ,p_end_date => l_plan_rec.end_date
4251 ,p_target_date => null
4252 ,p_assignemnt_id => g_qual_pop_tbl(l_qual_pop_index).assignment_id
4253 ,p_prev_plan_id => l_plan_rec.previous_plan_id
4254 ,p_curr_plan_id => l_plan_rec.plan_id);
4255 --
4256 END IF;
4257 --
4258 -- End date objectives that exists in current scorecard objectives but does not qualify anymore
4259 --
4260 /* Commenting as this code is rdundant.. for fixing bug#7560950
4261 l_curr_sc_obj_index := g_curr_sc_obj_tbl.FIRST;
4262 WHILE(l_curr_sc_obj_index IS NOT NULL)
4263 LOOP
4264 IF (NOT g_qual_obj_tbl.EXISTS(l_curr_sc_obj_index)) THEN
4265 --
4266 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 120); END IF;
4267 --
4268 update_scorecard_objective(
4269 p_effective_date => l_effective_date
4270 ,p_start_date => l_plan_rec.start_date
4271 ,p_objective_id => g_curr_sc_obj_tbl(l_curr_sc_obj_index).objective_id
4272 ,p_object_version_number => g_curr_sc_obj_tbl(l_curr_sc_obj_index).object_version_number
4273 ,p_end_date => l_effective_date);
4274 END IF;
4275 --
4276 l_curr_sc_obj_index := g_curr_sc_obj_tbl.NEXT(l_curr_sc_obj_index);
4277 --
4278 END LOOP;
4279 --commented upto here for bug#7560950*/
4280 END IF;
4281 --
4282 /* ELSIF (l_plan_rec.status_code = 'PUBLISHED') THEN
4283 -- If objective setting flag is set
4284 IF (l_plan_rec.include_obj_setting_flag = 'Y') THEN
4285
4286 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 130); END IF;
4287 -- Loop though and delete the objectives for scorecard
4288 FOR obj_rec IN csr_sc_objectives(g_curr_sc_pop_tbl(l_qual_pop_index).scorecard_id)
4289 LOOP
4290 delete_scorecard_objective(p_objective_id => obj_rec.objective_id
4291 ,p_object_version_number => obj_rec.object_version_number);
4292 END LOOP;
4293
4294 -- Delete the scorecard
4295 delete_scorecard_for_person(g_curr_sc_pop_tbl(l_qual_pop_index).scorecard_id
4296 ,g_curr_sc_pop_tbl(l_qual_pop_index).object_version_number);
4297 END IF;
4298 --
4299 IF (l_plan_rec.include_appraisals_flag = 'Y') THEN
4300 FOR plan_appraisals IN csr_plan_appraisals(p_plan_id)
4301 LOOP
4302 delete_appraisal_for_person(plan_appraisals.appraisal_id,plan_appraisals.object_version_number);
4303 END LOOP;
4304 END IF;*/
4305 --
4306 END IF;
4307 --
4308 -- Get the next index value
4309 --
4310 l_qual_pop_index := g_qual_pop_tbl.NEXT(l_qual_pop_index);
4311 --
4312 END LOOP;
4313 --
4314 -- ===========================================================================================
4315 --- DELETE the non qualifying scorecards and the appraisals( for terminated employees) changes for 6460457
4316 l_curr_sc_pop_index := g_curr_sc_pop_tbl.FIRST;
4317 WHILE (l_curr_sc_pop_index IS NOT NULL)
4318 LOOP
4319
4320 IF (l_plan_rec.status_code in ('UPDATED','RESUBMITTED') AND NOT g_qual_pop_tbl.EXISTS(l_curr_sc_pop_index))
4321 THEN
4322 -- If objective setting flag is set
4323
4324 --IF (l_plan_rec.include_obj_setting_flag = 'Y') THEN
4325
4326 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 130); END IF;
4327 -- Loop though and delete the objectives for scorecard
4328 -- 7321947 will not delete any record for non-qualifying scorecards.
4329 /* FOR obj_rec IN csr_sc_objectives(g_curr_sc_pop_tbl(l_curr_sc_pop_index).scorecard_id)
4330 LOOP
4331
4332 delete_scorecard_objective(p_objective_id => obj_rec.objective_id
4333 ,p_object_version_number => obj_rec.object_version_number);
4334 END LOOP;*/
4335 -- END IF;
4336 --- delete the appraisals for the person
4337 IF (l_plan_rec.include_appraisals_flag = 'Y') THEN
4338 -- FOR plan_appraisals IN csr_plan_appraisals(p_plan_id)
4339 open csr_find_appr_for_scorecard(p_plan_id,g_curr_sc_pop_tbl(l_curr_sc_pop_index).scorecard_id);
4340 LOOP
4341 hr_utility.set_location('Before transfer out _for_person',107);
4342 fetch csr_find_appr_for_scorecard into l_appr_id,l_appr_ovn,l_appr_sys_status;
4343 exit when csr_find_appr_for_scorecard%notfound;
4344 IF l_appr_sys_status <> 'COMPLETED' THEN
4345 UPDATE per_appraisals
4346 SET appraisal_system_status = 'TRANSFER_OUT'
4347 WHERE appraisal_id =l_appr_id;
4348 -- revoke the participant statuses and close them.NOt deleting them if feedback is already provided.
4349 FOR i in csr_get_appr_part(l_appr_id)
4350 LOOP
4351 UPDATE PER_PARTICIPANTS
4352 SET PARTICIPATION_STATUS ='CLOSED'
4353 WHERE PARTICIPANT_ID =i.PARTICIPANT_ID ;
4354 END LOOP;
4355 -- we are doing a direct update as update API will not work for terminated and traansfer employees
4356 -- update it to transfer out so as to not show the details anywhere
4357
4358 END IF;
4359 hr_utility.set_location('After transfer out appraisal_for_person appraisal_id: '|| l_appr_id,107);
4360
4361 END LOOP;
4362 close csr_find_appr_for_scorecard;
4363 END IF;
4364
4365 -- Delete the scorecard
4366
4367 /* delete_scorecard_for_person(g_curr_sc_pop_tbl(l_curr_sc_pop_index).scorecard_id
4368 ,g_curr_sc_pop_tbl(l_curr_sc_pop_index).object_version_number); */
4369 hr_personal_scorecard_api.update_scorecard
4370 (p_effective_date => trunc(sysdate)
4371 ,p_scorecard_id => g_curr_sc_pop_tbl(l_curr_sc_pop_index).scorecard_id
4372 ,p_object_version_number => g_curr_sc_pop_tbl(l_curr_sc_pop_index).object_version_number
4373 ,p_duplicate_name_warning => l_dummy
4374 ,p_status_code => 'TRANSFER_OUT' );
4375
4376 --
4377
4378 --
4379 END IF;
4380
4381 --------- iterate the loop
4382
4383 l_curr_sc_pop_index := g_curr_sc_pop_tbl.NEXT(l_curr_sc_pop_index);
4384 END LOOP;
4385 --- DELETE logic ends( replaced by 7321947 changes)
4386 --============================================================================================
4387 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 140); END IF;
4388 --
4389 -- If the plan is republished, End date scorecards, objectives and
4390 -- appraisals for existing population that does not qualify anymore
4391 --
4392 /* Bug# 6648036 changes Begin Commenting the if Condition
4393 IF (l_plan_rec.status_code in ('UPDATED','RESUBMITTED') AND l_plan_rec.include_obj_setting_flag = 'Y') THEN
4394 --
4395 l_curr_sc_pop_index := g_curr_sc_pop_tbl.FIRST;
4396 WHILE (l_curr_sc_pop_index IS NOT NULL)
4397 LOOP
4398 IF (NOT g_qual_pop_tbl.EXISTS(l_curr_sc_pop_index)) THEN
4399 --
4400 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 150); END IF;
4401 --
4402 -- Loop though objectives for scorecards
4403 FOR obj_rec IN csr_sc_objectives(g_curr_sc_pop_tbl(l_curr_sc_pop_index).scorecard_id)
4404 LOOP
4405 update_scorecard_objective(
4406 p_effective_date => l_effective_date
4407 ,p_start_date => l_plan_rec.start_date
4408 ,p_objective_id => obj_rec.objective_id
4409 ,p_object_version_number => obj_rec.object_version_number
4410 ,p_end_date => l_effective_date);
4411 END LOOP;
4412
4413 --
4414 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 160); END IF;
4415 --
4416 update_scorecard_for_person(
4417 p_effective_date => l_effective_date
4418 ,p_start_date => l_plan_rec.start_date --Added for 5725110
4419 ,p_scorecard_id => g_curr_sc_pop_tbl(l_curr_sc_pop_index).scorecard_id
4420 ,p_object_version_number => g_curr_sc_pop_tbl(l_curr_sc_pop_index).object_version_number
4421 ,p_end_date => l_effective_date);
4422 END IF;
4423 --
4424 l_curr_sc_pop_index := g_curr_sc_pop_tbl.NEXT(l_curr_sc_pop_index);
4425 --
4426 END LOOP;
4427 END IF;
4428
4429 Bug# 6648036 Changes End */
4430
4431 --
4432 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 170); END IF;
4433 --
4434 -- Update the plan status
4435 --
4436 l_object_version_number := l_plan_rec.object_version_number;
4437 IF (p_reverse_mode = 'Y') THEN
4438 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 180); END IF;
4439 l_status_code := 'DRAFT';
4440 ELSE
4441 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 190); END IF;
4442 l_status_code := 'PUBLISHED';
4443 END IF;
4444 --
4445 per_pmp_upd.upd(p_plan_id => l_plan_rec.plan_id
4446 ,p_effective_date => l_effective_date
4447 ,p_object_version_number => l_object_version_number
4448 ,p_status_code => l_status_code
4449 ,p_change_sc_status_flag => NULL
4450 ,p_duplicate_name_warning => l_dummy
4451 ,p_no_life_events_warning => l_dummy);
4452
4453 -- Return the new object version number
4454 p_object_version_number := l_object_version_number;
4455
4456 --
4457 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 200); END IF;
4458 --
4459 -- Submit the workflow process for notifying plan population
4460 -- Commented out the following line. No matter what this flag,
4461 -- notifications to be sent. Bug# 5225196
4462 --IF (l_plan_rec.include_obj_setting_flag = 'Y' AND
4463 IF (l_plan_rec.notify_population_flag = 'Y') THEN
4464 --
4465 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 210); END IF;
4466 --
4467 start_process(p_plan_rec => l_plan_rec
4468 ,p_effective_date => l_effective_date
4469 ,p_reverse_mode => p_reverse_mode
4470 ,p_item_type => p_item_type
4471 ,p_wf_process => p_wf_process);
4472
4473 END IF;
4474 --
4475 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 220); END IF;
4476 --
4477 -- Always Send notification to administrator that plan has been published.
4478 --
4479 send_fyi_admin(p_plan_rec => l_plan_rec
4480 ,p_status => 'PUBLISHED'
4481 ,p_request_id => fnd_global.conc_request_id);
4482
4483 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 210); END IF;
4484 --
4485 commit;
4486 IF (l_plan_rec.status_code in ('DRAFT','SUBMITTED') OR
4487 (l_plan_rec.status_code in ('UPDATED','RESUBMITTED') AND NOT g_curr_sc_pop_tbl.EXISTS(l_qual_pop_index)))
4488 THEN
4489
4490 --
4491 -- Create Appraisals if flag is set
4492 --
4493 IF (l_plan_rec.include_appraisals_flag = 'Y') THEN
4494 --
4495 l_plan_aprsl_pds_index := g_plan_aprsl_pds_tbl.FIRST;
4496 WHILE (l_plan_aprsl_pds_index IS NOT NULL)
4497 LOOP
4498 --
4499 IF (g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).auto_conc_process = 'Y')
4500 THEN
4501 l_process_date := g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).task_start_date - nvl(g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).days_before_task_st_dt,0);
4502 l_process_date_char := to_char(l_process_date,fnd_conc_date.get_date_format(trunc(sysdate)));
4503 --
4504 IF g_dbg THEN
4505 op('Eff_date is '||p_effective_date, g_DEBUG_LOG, 90);
4506 op('l_process_date is '||l_process_date, g_DEBUG_LOG, 90);
4507 op('l_process_date_CHAR is '||l_process_date_CHAR, g_DEBUG_LOG, 90);
4508 END IF;
4509 --
4510 -- Do not call appraisal_push, if process_date < sysdate.
4511 --
4512 IF l_process_date >= trunc(sysdate) THEN
4513 HR_WPM_MASS_APR_PUSH.submit_appraisal_cp
4514 (p_effective_date => l_process_date
4515 ,p_start_date => l_process_date_char
4516 ,p_plan_id => p_plan_id
4517 ,p_appraisal_period_id => g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).appraisal_period_id
4518 ,p_log_output => p_log_output
4519 );
4520 END IF; -- run only if process date >= sysdate
4521 END IF;
4522 --
4523 l_plan_aprsl_pds_index := g_plan_aprsl_pds_tbl.NEXT(l_plan_aprsl_pds_index);
4524 --
4525 END LOOP;
4526 -- populate the hierarchy for appraisal summary
4527 PER_WPM_SUMMARY_PKG.populate_plan_hierarchy(p_plan_id => p_plan_id
4528 ,p_effective_date => TRUNC(SYSDATE) );
4529 --
4530 END IF; --include appraisal flag
4531 --
4532 END IF;
4533 --
4534 -- Error logging
4535 --
4536 l_message_count := per_accrual_message_pkg.count_messages;
4537 FOR j in 1..l_message_count LOOP
4538 l_message := per_accrual_message_pkg.get_message(j);
4539 IF g_dbg THEN op(l_message, g_REGULAR_LOG); END IF;
4540 END LOOP;
4541
4542 --
4543 IF g_dbg THEN
4544 op('Max Errors Allowed is: '||to_char(g_MAX_ERRORS), g_REGULAR_LOG, 988);
4545 op('Errors encountered is: '||to_char(g_num_errors), g_REGULAR_LOG, 989);
4546 op('Leaving: '||l_proc, g_REGULAR_LOG, 990);
4547 END IF;
4548 --
4549 exception
4550 when others then
4551 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG, 90); END IF;
4552 --
4553 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
4554 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
4555 g_retcode := ERROR;
4556 g_errbuf := g_cp_error_txt;
4557 g_num_errors := g_num_errors + 1;
4558 IF g_dbg THEN
4559 op('Max Errors Allowed is: '||to_char(g_MAX_ERRORS), g_REGULAR_LOG);
4560 op('Errors encountered is: '||to_char(g_num_errors), g_REGULAR_LOG);
4561 op(g_error_txt, g_REGULAR_LOG);
4562 op(SQLERRM, g_REGULAR_LOG);
4563 END IF;
4564 --
4565 -- Send notification to administrator that plan publish errored
4566 --
4567 send_fyi_admin(p_plan_rec => l_plan_rec
4568 ,p_status => 'ERROR'
4569 ,p_request_id => fnd_global.conc_request_id);
4570 IF g_dbg THEN op('Leaving:'||l_proc, g_REGULAR_LOG,91); END IF;
4571 --
4572 raise;
4573 end publish_plan;
4574 --
4575 -- ----------------------------------------------------------------------------
4576 -- |----------------------------< send_fyi_ntf >------------------------------|
4577 -- ----------------------------------------------------------------------------
4578 --
4579 procedure SEND_FYI_NTF
4580 (itemtype in varchar2
4581 ,itemkey in varchar2
4582 ,actid in number
4583 ,funcmode in varchar2
4584 ,resultout out nocopy varchar2
4585 ) is
4586 prole wf_users.name%type; -- Fix 3210283.
4587 l_role_name wf_roles.name%type;
4588 expand_role varchar2(1);
4589 l_msg varchar2(30);
4590 -- Start changes for bug#5903006
4591 l_obj_setting_flag VARCHAR2(30);
4592 --end changes for bug#5903006
4593 --
4594 begin
4595 if (funcmode <> wf_engine.eng_run) then
4596 resultout := wf_engine.eng_null;
4597 return;
4598 end if;
4599 l_role_name :=wf_engine.GetItemAttrText(
4600 itemtype => itemtype,
4601 itemkey => itemkey,
4602 aname => 'WPM_PLAN_MEMBER');
4603 l_msg := upper(Wf_Engine.GetActivityAttrText(itemtype, itemkey,
4604 actid, 'MESSAGE_NAME'));
4605 -- Start Changes for bug#5903006
4606 l_obj_setting_flag := wf_engine.GetItemAttrText(
4607 itemtype => itemtype,
4608 itemkey => itemkey,
4609 aname => 'HR_WPM_OBJ_SETTING_FLAG');
4610 IF NVL(l_obj_setting_flag,'N') = 'N' THEN
4611 IF l_msg = 'WPM_PLAN_PUB_ALL_POP_MSG' THEN
4612 l_msg := 'WPM_PLAN_PUB_ALL_NO_OBJ_MSG';
4613 ELSIF l_msg = 'WPM_PLAN_PUB_NON_TOP_POP_MSG' THEN
4614 l_msg := 'WPM_PLAN_PUB_NON_TOP_NOOBJ_MSG';
4615 ELSIF l_msg = 'WPM_PLAN_PUB_TOP_POP_MSG' THEN
4616 l_msg := 'WPM_PLAN_PUB_TOP_NO_OBJ_MSG';
4617 END IF;
4618 END IF;
4619 -- End Changes for bug#5903006
4620 expand_role := 'N';
4621 if l_role_name is null then
4622 Wf_Core.Token('TYPE', itemtype);
4623 Wf_Core.Token('ACTID', to_char(actid));
4624 Wf_Core.Raise('WFENG_NOTIFICATION_PERFORMER');
4625 end if;
4626 --
4627 Wf_Engine_Util.Notification_Send(itemtype, itemkey, actid,
4628 l_msg, 'HRWPM', l_role_name, expand_role,
4629 resultout);
4630
4631 exception when others then
4632 raise;
4633 end SEND_FYI_NTF;
4634 --
4635 -- ----------------------------------------------------------------------------
4636 -- |----------------------------< send_fyi_ntf_admin >------------------------|
4637 -- ----------------------------------------------------------------------------
4638 --
4639 procedure SEND_FYI_NTF_ADMIN
4640 (itemtype in varchar2
4641 ,itemkey in varchar2
4642 ,actid in number
4643 ,funcmode in varchar2
4644 ,resultout out nocopy varchar2
4645 ) is
4646 prole wf_users.name%type;
4647 l_role_name wf_roles.name%type;
4648 l_role_displayname wf_roles.display_name%type;
4649 expand_role varchar2(1);
4650 l_msg varchar2(30);
4651 l_plan_id number;
4652 cursor csr_get_admin
4653 is
4654 SELECT
4655 administrator_person_id
4656 ,supervisor_id
4657 FROM
4658 PER_PERF_MGMT_PLANS
4659 WHERE plan_id = l_plan_id;
4660 l_admin_person_id number;
4661 l_supervisor_id number;
4662 --
4663 begin
4664 if (funcmode <> wf_engine.eng_run) then
4665 resultout := wf_engine.eng_null;
4666 return;
4667 end if;
4668 --
4669 -- get plan id
4670 --
4671 l_plan_id :=wf_engine.GetItemAttrNumber(
4672 itemtype => itemtype,
4673 itemkey => itemkey,
4674 aname => 'WPM_PLAN_ID');
4675 --
4676 -- get administrator person id from plan
4677 --
4678 open csr_get_admin;
4679 fetch csr_get_admin into l_admin_person_id,l_supervisor_id;
4680 close csr_get_admin;
4681 --
4682 -- Continue only if supervisor id is different from admin person id
4683 --
4684 if l_admin_person_id <> nvl(l_supervisor_id,-1) then
4685 -- Get the Role for the Owner
4686 wf_directory.getRoleName(p_orig_system => 'PER'
4687 ,p_orig_system_id => l_admin_person_id
4688 ,p_name => l_role_name
4689 ,p_display_name => l_role_displayname);
4690 /*
4691 l_role_name :=wf_engine.GetItemAttrText(
4692 itemtype => itemtype,
4693 itemkey => itemkey,
4694 aname => 'WPM_PLAN_MEMBER');
4695 */
4696 l_msg := upper(Wf_Engine.GetActivityAttrText(itemtype, itemkey,
4697 actid, 'MESSAGE_NAME'));
4698
4699 expand_role := 'N';
4700 if l_role_name is null then
4701 Wf_Core.Token('TYPE', itemtype);
4702 Wf_Core.Token('ACTID', to_char(actid));
4703 Wf_Core.Raise('WFENG_NOTIFICATION_PERFORMER');
4704 end if;
4705 --
4706 Wf_Engine_Util.Notification_Send(itemtype, itemkey, actid,
4707 l_msg, 'HRWPM', l_role_name, expand_role,
4708 resultout);
4709 end if; --l_admin <> l_supervisor_id
4710 exception when others then
4711 raise;
4712 end SEND_FYI_NTF_ADMIN;
4713 --
4714 -- ----------------------------------------------------------------------------
4715 -- |------------------------------< send_fyi_admin >--------------------------|
4716 -- ----------------------------------------------------------------------------
4717 --
4718 procedure SEND_FYI_ADMIN
4719 (p_plan_rec in per_perf_mgmt_plans%ROWTYPE
4720 ,p_status in varchar2
4721 ,p_request_id in number
4722 )
4723 IS
4724
4725 l_to_role_name wf_roles.name%type;
4726 l_to_role_displayname wf_roles.display_name%type;
4727 l_from_role_name wf_roles.name%type;
4728 l_from_role_displayname wf_roles.display_name%type;
4729 expand_role varchar2(1);
4730 l_msg varchar2(30);
4731 l_notification_id number;
4732 FROM_ROLE_NOT_EXISTS exception;
4733 TO_ROLE_NOT_EXISTS exception;
4734 l_subject varchar2(200) default null;
4735 l_proc varchar2(72) := g_package||'send_fyi_admin';
4736 --
4737 begin
4738 IF g_dbg THEN op(l_proc, g_REGULAR_LOG, 10); END IF;
4739 --
4740
4741 -- Get the Role for the Owner
4742 wf_directory.getRoleName(
4743 p_orig_system => 'PER'
4744 ,p_orig_system_id => p_plan_rec.administrator_person_id
4745 ,p_name => l_to_role_name
4746 ,p_display_name => l_to_role_displayname
4747 );
4748
4749 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 20); END IF;
4750 --
4751 if l_to_role_name is null then
4752 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 25); END IF;
4753 raise to_role_not_exists;
4754 end if;
4755 /* Owner is always administrator, we don;t need to check for the from role
4756 -- ---------------------------------
4757 -- Get the Role for the Owner
4758 -- ---------------------------------
4759 --
4760 wf_directory.getRoleName
4761 (p_orig_system => 'FND_USR'
4762 ,p_orig_system_id => fnd_global.user_id
4763 ,p_name => l_from_role_name
4764 ,p_display_name => l_from_role_displayname);
4765 --
4766 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 30); END IF;
4767 if l_from_role_name is null then
4768 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 45); END IF;
4769 raise from_role_not_exists;
4770 end if;
4771 */
4772 expand_role := 'N';
4773 --
4774 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 50); END IF;
4775 if p_status = 'PUBLISHED' then
4776 l_notification_id := wf_notification.send
4777 (role => l_to_role_name
4778 ,msg_type => 'HRWPM'
4779 ,msg_name => 'WPM_PLAN_PUB_ADMIN_MSG'
4780 ,callback => null
4781 ,context => null
4782 ,send_comment => null
4783 ,priority => 50
4784 );
4785 wf_notification.SetAttrText(l_notification_id,'PUB_PLAN_NAME', p_plan_rec.plan_name);
4786 wf_notification.SetAttrNumber(l_notification_id,'PUB_REQ_ID', p_request_id);
4787 elsif p_status = 'ERROR' then
4788 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 51); END IF;
4789 l_notification_id := wf_notification.send
4790 (role => l_to_role_name
4791 ,msg_type => 'HRWPM'
4792 ,msg_name => 'WPM_PLANPUB_ERROR_ADMIN_MSG'
4793 ,callback => null
4794 ,context => null
4795 ,send_comment => null
4796 ,priority => 50
4797 );
4798 wf_notification.SetAttrText(l_notification_id,'FAILED_PLAN_NAME', p_plan_rec.plan_name);
4799 wf_notification.SetAttrNumber(l_notification_id,'FAILED_REQ_ID', p_request_id);
4800 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 52); END IF;
4801 elsif p_status = 'SUBMITTED' then
4802 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 52); END IF;
4803 l_notification_id := wf_notification.send
4804 (role => l_to_role_name
4805 ,msg_type => 'HRWPM'
4806 ,msg_name => 'WPM_PLAN_SUBMIT_ADMIN_MSG'
4807 ,callback => null
4808 ,context => null
4809 ,send_comment => null
4810 ,priority => 50
4811 );
4812 wf_notification.SetAttrText(l_notification_id,'SUBMIT_PLAN_NAME', p_plan_rec.plan_name);
4813 wf_notification.SetAttrNumber(l_notification_id,'SUBMIT_REQ_ID', p_request_id);
4814 else
4815 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 53); END IF;
4816 null;
4817 end if;
4818 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 60); END IF;
4819 wf_notification.SetAttrText(l_notification_id,'#FROM_ROLE',l_to_role_name);
4820 wf_notification.SetAttrText(l_notification_id,'WPM_PLAN', p_plan_rec.plan_name);
4821 wf_notification.SetAttrText(l_notification_id,'PLAN_START_DATE', p_plan_rec.start_date);
4822 wf_notification.SetAttrText(l_notification_id,'PLAN_END_DATE', p_plan_rec.end_date);
4823 wf_notification.SetAttrNumber(l_notification_id,'CONCREQID', p_request_id);
4824 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 70); END IF;
4825
4826 exception when others then
4827 IF g_dbg THEN op(l_proc, g_REGULAR_LOG, 100); END IF;
4828 raise;
4829 end SEND_FYI_ADMIN;
4830 --
4831 -- ----------------------------------------------------------------------------
4832 -- |-----------------------< copy_past_objectives >---------------------------|
4833 -- ----------------------------------------------------------------------------
4834 --
4835 procedure copy_past_objectives
4836 (p_effective_date in date
4837 ,p_business_group_id in number
4838 ,p_person_id in number
4839 ,p_scorecard_id in number
4840 ,p_start_date in date
4841 ,p_end_date in date
4842 ,p_target_date in date default null
4843 ,p_assignemnt_id in number
4844 ,p_prev_plan_id in number
4845 ,p_curr_plan_id in number
4846 )
4847 is
4848 --
4849 -- Declare local variables
4850 --
4851 l_proc varchar2(72) := g_package||'copy_past_objectives';
4852 l_objective_id number;
4853 l_object_version_number number;
4854 l_duplicate_name_warning boolean := false;
4855 l_comb_weight_over_100_warning boolean := false;
4856 l_weighting_appraisal_warning boolean := false;
4857 l_pc_v_act_mismatch_warning boolean := false;
4858 l_quant_met_not_pc_warning boolean := false;
4859 l_qual_met_not_pc_warning boolean := false;
4860 --
4861 l_start_date date;
4862 l_target_date date;
4863 l_next_review_date date;
4864 --
4865 cursor past_obj is
4866 SELECT obj.*
4867 FROM per_objectives obj
4868 ,per_personal_scorecards psc
4869 WHERE psc.plan_id = p_prev_plan_id
4870 AND psc.assignment_id = p_assignemnt_id
4871 AND psc.scorecard_id = obj.scorecard_id
4872 AND obj.achievement_date is null
4873 AND obj.appraisal_id is null
4874 AND not exists (select 'X'
4875 from per_personal_scorecards psc1, per_objectives pobj1
4876 where psc1.plan_id = p_curr_plan_id
4877 and psc1.assignment_id = psc.assignment_id
4878 and psc1.scorecard_id = pobj1.scorecard_id
4879 and pobj1.copied_from_objective_id = obj.objective_id);
4880 --
4881 Begin
4882 --
4883 IF g_dbg THEN op('Entering:'|| l_proc, g_REGULAR_LOG, 10); END IF;
4884 --
4885 For pobj in past_obj LOOP
4886 --
4887 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 20); END IF;
4888 --
4889 BEGIN
4890 l_objective_id := null;
4891 l_object_version_number := null;
4892 l_duplicate_name_warning := false;
4893 l_comb_weight_over_100_warning := false;
4894 l_weighting_appraisal_warning := false;
4895 l_pc_v_act_mismatch_warning := false;
4896 l_quant_met_not_pc_warning := false;
4897 l_qual_met_not_pc_warning := false;
4898
4899 --
4900 -- Derive objective target date
4901 --
4902 IF (p_target_date IS NULL OR p_target_date > p_end_date OR p_target_date < p_start_date) THEN
4903 l_target_date := p_end_date;
4904 ELSE
4905 l_target_date := p_target_date;
4906 END IF;
4907 --
4908 --
4909 IF (pobj.next_review_date IS NULL OR
4910 pobj.next_review_date < p_start_date OR
4911 pobj.next_review_date > p_end_date )
4912 THEN
4913 l_next_review_date := null;
4914 ELSE
4915 l_next_review_date := pobj.next_review_date;
4916 END IF;
4917 --
4918 IF g_dbg THEN op(l_proc, g_DEBUG_LOG, 40); END IF;
4919 --
4920 -- Call create_objective
4921 --
4922 hr_objectives_api.create_objective(
4923 p_effective_date => p_effective_date
4924 ,p_business_group_id => p_business_group_id
4925 ,p_owning_person_id => pobj.owning_person_id
4926 ,p_scorecard_id => p_scorecard_id
4927 ,p_start_date => p_start_date
4928 ,p_appraise_flag => pobj.appraise_flag
4929 ,p_name => pobj.name
4930 ,p_target_date => l_target_date
4931 ,p_copied_from_objective_id => pobj.objective_id
4932 ,p_complete_percent => pobj.complete_percent
4933 ,p_next_review_date => l_next_review_date
4934 ,p_group_code => pobj.group_code
4935 ,p_priority_code => pobj.priority_code
4936 ,p_weighting_percent => pobj.weighting_percent
4937 ,p_target_value => pobj.target_value
4938 ,p_uom_code => pobj.uom_code
4939 ,p_measurement_style_code => pobj.measurement_style_code
4940 ,p_measure_name => pobj.measure_name
4941 ,p_measure_type_code => pobj.measure_type_code
4942 ,p_measure_comments => pobj.measure_comments
4943 ,p_detail => pobj.detail
4944 ,p_comments => pobj.comments
4945 ,p_success_criteria => pobj.success_criteria
4946 ,p_objective_id => l_objective_id
4947 ,p_object_version_number => l_object_version_number
4948 ,p_weighting_appraisal_warning => l_weighting_appraisal_warning
4949 ,p_weighting_over_100_warning => l_comb_weight_over_100_warning
4950 --,p_duplicate_name_warning => l_duplicate_name_warning
4951 --,p_comb_weight_over_100_warning => l_comb_weight_over_100_warning
4952 --,p_pc_v_act_mismatch_warning => l_pc_v_act_mismatch_warning
4953 --,p_quant_met_not_pc_warning => l_quant_met_not_pc_warning
4954 --,p_qual_met_not_pc_warning => l_qual_met_not_pc_warning
4955 );
4956 --
4957 IF g_dbg THEN op(l_proc, g_REGULAR_LOG, 50); END IF;
4958 --
4959 --
4960 exception
4961 when others then
4962
4963 IF g_dbg THEN op('Leaving Inner:'||l_proc, g_REGULAR_LOG, 90); END IF;
4964 --
4965 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
4966 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
4967 g_retcode := WARNING;
4968 g_errbuf := g_cp_error_txt;
4969 g_num_errors := g_num_errors + 1;
4970 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
4971 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
4972
4973 --
4974 -- If the max number of errors has been exceeded, raise the error and
4975 -- terminate processing of this plan.
4976 --
4977 IF g_num_errors > g_max_errors THEN
4978 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
4979 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
4980 g_retcode := ERROR;
4981 g_errbuf := g_error_txt;
4982 RAISE;
4983 END IF;
4984 END;
4985 END LOOP;
4986 --
4987 IF g_dbg THEN op('Leaving:'||l_proc, g_DEBUG_LOG, 190); END IF;
4988 --
4989 exception
4990 when others then
4991 IF g_dbg THEN op('Leaving Outer:'||l_proc, g_REGULAR_LOG, 200); END IF;
4992 --
4993 fnd_message.set_name('PER','HR_50297_WPM_CP_ERROR');
4994 g_cp_error_txt := nvl(fnd_message.get, 'HR_50297_WPM_CP_ERROR');
4995 g_retcode := WARNING;
4996 g_errbuf := g_cp_error_txt;
4997 g_num_errors := g_num_errors + 1;
4998 IF g_dbg THEN op(g_error_txt, g_REGULAR_LOG); END IF;
4999 IF g_dbg THEN op(SQLERRM, g_REGULAR_LOG); END IF;
5000
5001 --
5002 -- If the max number of errors has been exceeded, raise the error and
5003 -- terminate processing of this plan.
5004 --
5005 IF g_num_errors > g_max_errors THEN
5006 fnd_message.set_name('PER','HR_50298_WPM_MAX_ERRORS');
5007 g_error_txt := nvl(fnd_message.get, 'HR_50298_WPM_MAX_ERRORS');
5008 g_retcode := ERROR;
5009 g_errbuf := g_error_txt;
5010
5011 RAISE;
5012 END IF;
5013 --
5014 End copy_past_objectives;
5015 ----------------------------------------------------------------------------------
5016 -----------------< is_supervisor_in_org >-----------------------------------------
5017 ----------------------------------------------------------------------------------
5018 FUNCTION is_supervisor_in_org
5019
5020 (p_top_organization_id in number
5021 ,p_person_id in number
5022
5023 )RETURN NUMBER
5024 IS
5025 -- Declare cursors and local variables
5026 ---- cursor to get the organisation of the supervisor of the preson.Passing supervisor_id as person id
5027 CURSOR csr_get_supervisor_org
5028 (p_supervisor_id in number)
5029
5030 IS
5031 select
5032 paa.person_id,
5033 paa.ORGANIZATION_ID,
5034 paa.SUPERVISOR_ID
5035 from
5036 per_all_assignments_f paa
5037 where
5038 ( trunc(sysdate) between paa.effective_start_date and paa.effective_end_date)
5039 and paa.person_id = p_supervisor_id
5040 and paa.PRIMARY_FLAG = 'Y';
5041
5042 --- cursor variable
5043 get_sup_org csr_get_supervisor_org%ROWTYPE;
5044 get_per_org csr_get_supervisor_org%ROWTYPE;
5045
5046 BEGIN
5047 ------- get the supervisor id of the person
5048
5049 OPEN csr_get_supervisor_org(p_person_id);
5050 FETCH csr_get_supervisor_org into get_per_org;
5051 CLOSE csr_get_supervisor_org;
5052
5053
5054
5055 IF ( get_per_org.SUPERVISOR_ID <>p_top_organization_id) then
5056 return 0;
5057 END IF;
5058 IF (get_per_org.SUPERVISOR_ID is not null) Then --- check if he at all has a supervisor, if not
5059 -- he is the topmost
5060
5061 --- get the records for the supervisor in to the cursor.
5062 OPEN csr_get_supervisor_org(get_per_org.SUPERVISOR_ID);
5063 FETCH csr_get_supervisor_org into get_sup_org;
5064 if csr_get_supervisor_org%FOUND
5065 then
5066 if(get_sup_org.ORGANIZATION_ID =p_top_organization_id) then -- supervisor in same org
5067 return 0;
5068 else --- supervisor in diffrent org
5069 return 1;
5070 end if;
5071 Else -- no record returned , means not a valid supervisor.
5072 return 1;
5073 end if;
5074 CLOSE csr_get_supervisor_org;
5075
5076 END IF;
5077 RETURN 1; -- doesnt have a supervisor, hence he is the topmost
5078
5079
5080
5081 END ;
5082
5083 ---------------------------------------------------------------------------------------
5084 -----------------< change_plan_active_status >-----------------------------------------
5085 ---------------------------------------------------------------------------------------
5086 procedure change_plan_active_status
5087
5088 (p_plan_id in number
5089 )
5090 IS
5091 l_status_code per_perf_mgmt_plans.status_code%type;
5092 BEGIN
5093
5094 select status_code into l_status_code from per_perf_mgmt_plans where plan_id =p_plan_id;
5095 --- this is the logic for dectivating a published plan .
5096 if (l_status_code ='PUBLISHED') then
5097 UPDATE per_perf_mgmt_plans
5098 SET STATUS_CODE = 'INACTIVE'
5099 WHERE plan_id =p_plan_id;
5100 commit;
5101 --- logic for status code updated to published if already inactive
5102 elsif (l_status_code ='INACTIVE') then
5103 UPDATE per_perf_mgmt_plans
5104 SET STATUS_CODE = 'PUBLISHED'
5105 WHERE plan_id =p_plan_id;
5106 commit;
5107 -- UI allows only published plan and Inactivate plan to access this function through the functional button.
5108 -- if any other call is made it will not do anything.
5109
5110
5111 end if;
5112
5113 END ;
5114
5115
5116 --
5117 --
5118 PROCEDURE log_message(p_message_text IN VARCHAR2) IS
5119 BEGIN
5120 IF fnd_global.conc_request_id = -1 THEN
5121 hr_utility.trace(SUBSTR(p_message_text,1,200));
5122 hr_utility.trace(SUBSTR(p_message_text,201,200));
5123 ELSE
5124 fnd_file.put_line(fnd_file.log,p_message_text);
5125 END IF;
5126 END log_message;
5127 --
5128 --
5129 --
5130 PROCEDURE report_plan_summary(p_plan_id IN NUMBER
5131 ,p_sc_summary IN VARCHAR2
5132 ,p_appraisal_summary IN VARCHAR2) IS
5133 CURSOR csr_sc_summary(p_plan_id IN NUMBER) IS
5134 SELECT hr_general.decode_lookup('HR_WPM_SCORECARD_STATUS',status_code)
5135 STATUS
5136 , count(*) COUNT
5137 FROM per_personal_scorecards
5138 WHERE plan_id = p_plan_id
5139 GROUP BY hr_general.decode_lookup('HR_WPM_SCORECARD_STATUS',status_code)
5140 ORDER BY hr_general.decode_lookup('HR_WPM_SCORECARD_STATUS',status_code);
5141 --
5142 CURSOR csr_appraisal_summary(p_plan_id IN NUMBER) IS
5143 SELECT
5144 hr_general.decode_lookup('APPRAISAL_SYSTEM_STATUS',appraisal_system_status)
5145 STATUS
5146 ,pat.name APPRAISAL_TEMPLATE_NAME
5147 ,pa.appraisal_period_start_date
5148 ,pa.appraisal_period_end_date
5149 , count(*) COUNT
5150 FROM per_appraisals pa
5151 ,per_appraisal_templates pat
5152 WHERE pa.plan_id = p_plan_id
5153 AND pa.appraisal_template_id = pat.appraisal_template_id
5154 GROUP BY
5155 hr_general.decode_lookup('APPRAISAL_SYSTEM_STATUS',appraisal_system_status)
5156 ,pat.name
5157 ,pa.appraisal_period_start_date
5158 ,pa.appraisal_period_end_date
5159 ORDER BY
5160 hr_general.decode_lookup('APPRAISAL_SYSTEM_STATUS',appraisal_system_status)
5161 ,pat.name
5162 ,pa.appraisal_period_start_date
5163 ,pa.appraisal_period_end_date;
5164 BEGIN
5165 IF p_sc_summary = 'Y' THEN
5166 log_message('Score card summary by status:');
5167 log_message('------------------------------------------------------------');
5168 log_message('Status Count
5169 ');
5170 log_message('------------------------------------------------------------');
5171 FOR i in csr_sc_summary(p_plan_id)
5172 LOOP
5173 log_message(i.status||' '||i.count);
5174 END LOOP;
5175 log_message('------------------------------------------------------------');
5176 END IF;
5177 IF p_appraisal_summary = 'Y' THEN
5178 log_message('Appraisal summary by status:');
5179 log_message('------------------------------------------------------------------------');
5180 log_message('Template Name Start Date End Date Status
5181 Count ');
5182 log_message('------------------------------------------------------------------------');
5183 FOR i in csr_appraisal_summary(p_plan_id)
5184 LOOP
5185 log_message(i.appraisal_template_name||' '
5186 ||TO_CHAR(i.appraisal_period_start_date,'DD/MM/YYYY')
5187 ||' '
5188 ||TO_CHAR(i.appraisal_period_end_date,'DD/MM/YYYY')
5189 ||i.status
5190 ||i.count);
5191 END LOOP;
5192 log_message('------------------------------------------------------------------------');
5193 END IF;
5194 ---
5195 END report_plan_summary;
5196 --
5197 --
5198 PROCEDURE delete_scorecards(p_plan_id IN NUMBER) IS
5199 CURSOR csr_sc_ids (p_plan_id IN NUMBER) IS
5200 SELECT scorecard_id
5201 FROM per_personal_scorecards
5202 WHERE plan_id = p_plan_id;
5203 TYPE t_sc_ids IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
5204 l_sc_ids t_sc_ids;
5205 BEGIN
5206 --
5207 log_message('Deleting Score cards for the plan');
5208 OPEN csr_sc_ids(p_plan_id);
5209 LOOP
5210 FETCH csr_sc_ids BULK COLLECT INTO l_sc_ids LIMIT 1000;
5211 --Delete any transactions from HR_API_Transactions and transaction steps
5212 FORALL i IN l_sc_ids.FIRST .. l_sc_ids.LAST
5213 DELETE
5214 FROM hr_api_transaction_steps step
5215 WHERE step.transaction_id IN (SELECT trn.transaction_id
5216 FROM hr_api_transactions trn
5217 WHERE trn.transaction_ref_id =
5218 l_sc_ids(i)
5219 AND trn.transaction_ref_table =
5220 'PER_PERSONAL_SCORECARDS');
5221 FORALL i IN l_sc_ids.FIRST .. l_sc_ids.LAST
5222 DELETE
5223 FROM hr_api_transactions
5224 WHERE transaction_ref_id = l_sc_ids(i)
5225 AND transaction_ref_table = 'PER_PERSONAL_SCORECARDS';
5226 -- Delete all score card objectives
5227 FORALL i in l_sc_ids.FIRST .. l_sc_ids.LAST
5228 DELETE
5229 FROM per_objectives
5230 WHERE scorecard_id = l_sc_ids(i);
5231 -- Delete all score cards now
5232 FORALL i in l_sc_ids.FIRST .. l_sc_ids.LAST
5233 DELETE
5234 FROM per_personal_scorecards
5235 WHERE scorecard_id = l_sc_ids(i);
5236 EXIT WHEN csr_sc_ids%NOTFOUND;
5237 END LOOP;
5238 CLOSE csr_sc_ids;
5239 log_message('Score cards deleted successfully for the plan');
5240 --
5241 EXCEPTION
5242 WHEN Others THEN
5243 log_message('Error while deleting score cards');
5244 log_message(SqlErrm);
5245 RAISE;
5246 END delete_scorecards;
5247 --
5248 --
5249 --
5250 PROCEDURE delete_appraisals(p_plan_id IN NUMBER) IS
5251 CURSOR csr_appr(p_plan_id IN NUMBER) IS
5252 SELECT appraisal_id
5253 ,object_version_number
5254 FROM per_appraisals
5255 WHERE plan_id = p_plan_id;
5256 BEGIN
5257 log_message('Deleting Appraisals for the plan');
5258 FOR i IN csr_appr(p_plan_id)
5259 LOOP
5260 -- hr_appraisals_api.delete_appraisal
5261 delete_appraisal_for_person(p_appraisal_id => i.appraisal_id
5262 ,p_object_version_number =>
5263 i.object_version_number);
5264 END LOOP;
5265 log_message('Appraisals deleted successfully for the plan');
5266 EXCEPTION
5267 WHEN Others THEN
5268 log_message('Error while deleting appraisals');
5269 log_message(SqlErrm);
5270 RAISE;
5271 END delete_appraisals;
5272 --
5273 --
5274 FUNCTION backout_perf_mgmt_plan_cp(p_effective_date in date
5275 ,p_plan_id in number
5276 ,p_report_only in VARCHAR2
5277 DEFAULT 'Y') RETURN NUMBER IS
5278 l_request_id NUMBER;
5279 l_proc VARCHAR2(72) :=
5280 g_package||'backout_perf_mgmt_plan_cp';
5281 BEGIN
5282 hr_utility.set_location('Entering '||l_proc,10);
5283 IF p_plan_id IS NULL THEN
5284 hr_api.mandatory_arg_error(p_api_name => 'BACKOUT_PERF_MGMT_PLAN_CP'
5285 ,p_argument => 'P_PLAN_ID'
5286 ,p_argument_value => p_plan_id);
5287 END IF;
5288 IF p_effective_date IS NULL THEN
5289 hr_api.mandatory_arg_error(p_api_name => 'BACKOUT_PERF_MGMT_PLAN_CP'
5290 ,p_argument => 'P_EFFECTIVE_DATE'
5291 ,p_argument_value => p_effective_date);
5292 END IF;
5293 l_request_id := fnd_request.submit_request(
5294 application => 'PER'
5295 ,program => 'PERWPMBKOUT'
5296 ,sub_request => FALSE
5297 ,argument1 =>
5298 fnd_date.date_to_canonical(p_effective_date)
5299 ,argument2 => p_plan_id
5300 ,argument3 => p_report_only);
5301 COMMIT;
5302
5303 hr_utility.trace('Request id: '||l_request_id);
5304 hr_utility.set_location('Leaving '||l_proc,20);
5305 return l_request_id;
5306 EXCEPTION
5307 WHEN Others THEN
5308 hr_utility.set_location('Error submitting the request.'||l_proc,30);
5309 RETURN -1;
5310 RAISE;
5311 END backout_perf_mgmt_plan_cp;
5312 -- ----------------------------------------------------------------------------
5313 -- |----------------------------< backout_perf_mgmt_plan>----------------------|
5314 -- ----------------------------------------------------------------------------
5315 PROCEDURE backout_perf_mgmt_plan
5316 (errbuf out nocopy varchar2
5317 ,retcode out nocopy number
5318 ,p_effective_date in Varchar2
5319 ,p_plan_id in number
5320 ,p_report_only in VARCHAR2 DEFAULT 'Y'
5321 ) IS
5322 l_proc VARCHAR2(72) :=
5323 g_package||'backout_perf_mgmt_plan';
5324 CURSOR csr_valid_plan (p_plan_id IN NUMBER) IS
5325 SELECT *
5326 FROM per_perf_mgmt_plans
5327 WHERE plan_id = p_plan_id;
5328 l_plan_rec csr_valid_plan%ROWTYPE;
5329 --psugumar 7294077
5330 CURSOR csr_person_ids(p_plan_id IN NUMBER) IS
5331 SELECT person_id
5332 FROM per_personal_scorecards
5333 WHERE plan_id = p_plan_id;
5334
5335
5336
5337 l_plan_name per_perf_mgmt_plans.plan_name%type;
5338 TYPE tab_person_id IS TABLE OF per_appraisals.appraisee_person_id%TYPE INDEX BY binary_integer;
5339 person_ids tab_person_id;
5340 l_effective_date DATE;
5341 l_object_version_number number;
5342 l_status_code per_perf_mgmt_plans.status_code%TYPE;
5343 l_dummy boolean;
5344 BEGIN
5345 hr_utility.set_location('Entering:'||l_proc,10);
5346 --Bug7294077
5347 OPEN csr_person_ids(p_plan_id);
5348 FETCH csr_person_ids BULK COLLECT INTO person_ids LIMIT 1000;
5349 CLOSE csr_person_ids;
5350 IF p_plan_id IS NULL THEN
5351 hr_api.mandatory_arg_error(p_api_name => 'BACKOUT_PERF_MGMT_PLAN'
5352 ,p_argument => 'P_PLAN_ID'
5353 ,p_argument_value => p_plan_id);
5354 END IF;
5355 IF p_effective_date IS NULL THEN
5356 hr_api.mandatory_arg_error(p_api_name => 'BACKOUT_PERF_MGMT_PLAN'
5357 ,p_argument => 'P_EFFECTIVE_DATE'
5358 ,p_argument_value => p_effective_date);
5359 END IF;
5360 l_effective_date := fnd_date.canonical_to_date(p_effective_date);
5361 OPEN csr_valid_plan(p_plan_id);
5362 FETCH csr_valid_plan INTO l_plan_rec;
5363 IF csr_valid_plan%NOTFOUND THEN
5364 hr_utility.set_message(800,'HR_50264_PMS_INVALID_PLAN');
5365 log_message('Perf. Management Plan doesn''t exist.');
5366 hr_utility.raise_error;
5367 END IF;
5368 CLOSE csr_valid_plan;
5369 IF l_plan_rec.status_code IN ('DRAFT','INACTIVE') THEN
5370 fnd_message.set_name('PER','HR_50780_WPM_INVALID_STATUS_BACKOUT');
5371 log_message('This plan cannot be backed out as this is currently in
5372 '||l_plan_rec.status_code);
5373 fnd_message.set_token('STATUS',l_plan_rec.status_code);
5374 hr_utility.raise_error;
5375 END IF;
5376 IF trunc(sysdate)>trunc(l_plan_rec.END_DATE) THEN
5377 log_message('This plan cannot be backed out as this plan is Completed');
5378 hr_utility.raise_error;
5379 END IF;
5380 log_message('Details of the Plan: '||l_plan_rec.plan_name);
5381 log_message('--------------------------------------------------------------');
5382 log_message('Administrator :
5383 '||hr_general.decode_person_name(l_plan_rec.administrator_person_id));
5384 log_message('Start Date :
5385 '||TO_CHAR(l_plan_rec.start_date,'DD/MM/YYYY'));
5386 log_message('End Date :
5387 '||TO_CHAR(l_plan_rec.start_date,'DD/MM/YYYY'));
5388 log_message('Status :
5389 '||hr_general.decode_lookup('HR_WPM_PLAN_STATUS',l_plan_rec.status_code));
5390 log_message('Objective Setting Included? :
5391 '||hr_general.decode_lookup('YES_NO',l_plan_rec.include_obj_setting_flag));
5392 log_message('Appraisals Included? :
5393 '||hr_general.decode_lookup('YES_NO',l_plan_rec.include_appraisals_flag));
5394 log_message('Sharing/Align Objectives Enabled?:
5395 '||hr_general.decode_lookup('YES_NO',l_plan_rec.sharing_alignment_task_flag));
5396 log_message('Appraisals Included? :
5397 '||hr_general.decode_lookup('YES_NO',l_plan_rec.include_appraisals_flag));
5398 log_message('--------------------------------------------------------------');
5399 report_plan_summary(p_plan_id=> p_plan_id
5400 ,p_sc_summary =>
5401 NVL(l_plan_rec.include_obj_setting_flag,'N')
5402 ,p_appraisal_summary =>
5403 NVL(l_plan_rec.include_appraisals_flag,'N')
5404 );
5405 IF p_report_only = 'Y' THEN
5406 RETURN;
5407 END IF;
5408 --Update the plan status to SUBMITTED so that no further updates can happen to the plan
5409 l_object_version_number := l_plan_rec.object_version_number;
5410 l_status_code := 'SUBMITTED';
5411 per_pmp_upd.upd(p_plan_id => p_plan_id
5412 ,p_effective_date => l_effective_date
5413 ,p_object_version_number => l_object_version_number
5414 ,p_status_code => l_status_code
5415 ,p_duplicate_name_warning => l_dummy
5416 ,p_no_life_events_warning => l_dummy);
5417 COMMIT;
5418 IF NVL(l_plan_rec.include_obj_setting_flag,'N') = 'Y' THEN
5419 delete_scorecards(p_plan_id);
5420 END IF;
5421 IF NVL(l_plan_rec.include_appraisals_flag,'N') = 'Y' THEN
5422 delete_appraisals(p_plan_id);
5423 END IF;
5424 --
5425 -- reset the plan status to DRAFT now
5426 l_status_code := 'DRAFT';
5427 per_pmp_upd.upd(p_plan_id => p_plan_id
5428 ,p_effective_date => l_effective_date
5429 ,p_object_version_number => l_object_version_number
5430 ,p_status_code => l_status_code
5431 ,p_duplicate_name_warning => l_dummy
5432 ,p_no_life_events_warning => l_dummy);
5433 --remove the plan details from hierarchy table as plan is rolled back.
5434 delete PER_WPM_PLAN_HIERARCHY
5435 where PLAN_ID = p_plan_id;
5436 --remove the plan details from Appraisal Summary table as plan is rolled back.
5437 delete PER_WPM_APPRAISAL_SUMMARY
5438 where PLAN_ID = p_plan_id;
5439
5440 --7294077
5441 for j in 1..person_ids.count loop
5442 send_message_notification(person_ids(j),'WPM_PLAN_ROLLBACK_MSG',p_plan_id,null);
5443 end loop;
5444 COMMIT;
5445 hr_utility.set_location('Leaving:'||l_proc,50);
5446 EXCEPTION
5447 WHEN OTHERS THEN
5448 retcode := ERROR;
5449 errbuf := SqlERRM;
5450 ROLLBACK;
5451 l_status_code := 'PUBLISHED';
5452 per_pmp_upd.upd(p_plan_id => p_plan_id
5453 ,p_effective_date => l_effective_date
5454 ,p_object_version_number => l_object_version_number
5455 ,p_status_code => l_status_code
5456 ,p_duplicate_name_warning => l_dummy
5457 ,p_no_life_events_warning => l_dummy);
5458 COMMIT;
5459 RAISE;
5460 END backout_perf_mgmt_plan;
5461 --
5462 --
5463 FUNCTION plan_admin_actions_cp (p_effective_date in date
5464 ,p_plan_id in number
5465 ,p_selected_entities_list in varchar2
5466 ,p_task_code in varchar2)
5467 RETURN NUMBER IS
5468 l_request_id NUMBER;
5469 l_proc VARCHAR2(72) :=
5470 g_package||'plan_admin_actions_cp';
5471 BEGIN
5472 --
5473 hr_utility.set_location('Entering '||l_proc,10);
5474 IF p_plan_id IS NULL THEN
5475 hr_api.mandatory_arg_error(p_api_name => 'PLAN_ADMIN_ACTIONS_CP'
5476 ,p_argument => 'P_PLAN_ID'
5477 ,p_argument_value => p_plan_id);
5478 END IF;
5479 IF p_effective_date IS NULL THEN
5480 hr_api.mandatory_arg_error(p_api_name => 'PLAN_ADMIN_ACTIONS_CP'
5481 ,p_argument => 'P_EFFECTIVE_DATE'
5482 ,p_argument_value => p_effective_date);
5483 END IF;
5484 IF p_selected_entities_list IS NULL THEN
5485 hr_api.mandatory_arg_error(p_api_name => 'PLAN_ADMIN_ACTIONS_CP'
5486 ,p_argument => 'P_SELECTED_ENTITIES_LIST'
5487 ,p_argument_value => p_selected_entities_list);
5488 END IF;
5489 IF p_task_code IS NULL THEN
5490 hr_api.mandatory_arg_error(p_api_name => 'PLAN_ADMIN_ACTIONS_CP'
5491 ,p_argument => 'P_TASK_CODE'
5492 ,p_argument_value => p_task_code);
5493 END IF;
5494 IF hr_api.not_exists_in_hr_lookups(p_effective_date => p_effective_date
5495 ,p_lookup_type => 'HR_WPM_ADMIN_ACTIONS'
5496 ,p_lookup_code => p_task_code) THEN
5497 log_message('Invalid task code selected.'||p_task_code);
5498 hr_utility.set_message(800,'HR_WPM_TASK_CODE_NOT_EXISTS');
5499 hr_utility.raise_error;
5500 END IF;
5501 --
5502 l_request_id := fnd_request.submit_request(
5503 application => 'PER'
5504 ,program => 'PERWPMADMINCP'
5505 ,sub_request => FALSE
5506 ,argument1 =>
5507 fnd_date.date_to_canonical(p_effective_date)
5508 ,argument2 => p_plan_id
5509 ,argument3 => p_selected_entities_list
5510 ,argument4 => p_task_code);
5511 COMMIT;
5512 hr_utility.trace('Request id: '||l_request_id);
5513 hr_utility.set_location('Leaving '||l_proc,20);
5514 --
5515 return l_request_id;
5516 EXCEPTION
5517 WHEN Others THEN
5518 hr_utility.set_location('Error submitting the request.'||l_proc,30);
5519 RAISE;
5520 END plan_admin_actions_cp;
5521 --
5522 --
5523 FUNCTION string_to_array(p_selected_entities_list IN VARCHAR2)
5524 RETURN NUMBER IS
5525 i NUMBER;
5526 l_pos NUMBER;
5527 l_sel_list VARCHAR2(32767);
5528 BEGIN
5529 -- Delete existing pl/sql table, if any.
5530 g_selected_entities.DELETE;
5531 l_sel_list := p_selected_entities_list;
5532 i := 0;
5533 l_pos := INSTR(l_sel_list,',');
5534 LOOP
5535 IF l_pos <> 0 THEN
5536 g_selected_entities(i) := SUBSTR(l_sel_list,1,l_pos-1);
5537 ELSE
5538 g_selected_entities(i) := l_sel_list;
5539 END IF;
5540 EXIT WHEN l_sel_list IS NULL OR l_pos = 0;
5541 l_sel_list := SUBSTR(l_sel_list,l_pos+1);
5542 i := i+1;
5543 l_pos := INSTR(l_sel_list,',');
5544 END LOOP;
5545 RETURN g_selected_entities.COUNT;
5546 EXCEPTION
5547 WHEN OTHERS THEN
5548 RAISE;
5549 END string_to_array;
5550 --
5551 FUNCTION chk_assignment_in_population (p_assignment_id IN NUMBER)
5552 RETURN VARCHAR2 IS
5553 l_chk VARCHAR2(1) := 'N';
5554 i BINARY_INTEGER;
5555 BEGIN
5556 IF g_qual_pop_tbl.COUNT > 0 THEN
5557 IF g_qual_pop_tbl.EXISTS(p_assignment_id) THEN
5558 l_chk := 'Y';
5559 END IF;
5560 END IF;
5561
5562 RETURN l_chk;
5563 EXCEPTION
5564 WHEN OTHERS THEN
5565 RETURN 'N';
5566 END chk_assignment_in_population;
5567 --
5568 --
5569 PROCEDURE enroll_a_person (p_plan_id IN NUMBER,
5570 p_assignment_id IN NUMBER,
5571 p_person_id IN NUMBER,
5572 p_effective_date IN DATE) IS
5573 l_effective_date DATE := p_effective_date;
5574 l_qual_pop_index BINARY_INTEGER;
5575 l_scorecard_status_code VARCHAR2(40);
5576 l_scorecard_id NUMBER;
5577 l_qual_obj_index BINARY_INTEGER;
5578 l_obj_date DATE := trunc(sysdate);
5579 l_check_elig VARCHAR2(1);
5580 l_plan_aprsl_pds_index BINARY_INTEGER;
5581 l_appr_ret_status VARCHAR2(30);
5582 BEGIN
5583 IF (g_plan_dtls(1).automatic_allocation_flag = 'Y') THEN
5584 populate_qual_objectives(g_plan_dtls(1).start_date,
5585 g_plan_dtls(1).end_date);
5586 END IF;
5587
5588
5589 IF (g_plan_dtls(1).include_appraisals_flag = 'Y') THEN
5590 populate_plan_apprsl_periods(g_plan_dtls(1).plan_id);
5591 END IF;
5592 --
5593 -- Loop through plan population to create/update/delete scorecards, objectives and appraisal
5594 --
5595 l_qual_pop_index := p_assignment_id;
5596 IF g_plan_dtls(1).status_code = 'PUBLISHED' THEN
5597 ----
5598 -- If objective setting flag is set
5599 IF ((g_plan_dtls(1).include_obj_setting_flag = 'Y') OR
5600 (g_plan_dtls(1).include_appraisals_flag = 'Y'))
5601 THEN
5602 -- Create the scorecard for this assignment
5603 IF g_plan_dtls(1).method_code = 'CAS' THEN
5604 IF (g_plan_dtls(1).hierarchy_type_code ='SUP' AND
5605 g_plan_dtls(1).supervisor_id =
5606 g_qual_pop_tbl(l_qual_pop_index).person_id) OR
5607 (g_plan_dtls(1).hierarchy_type_code = 'SUP_ASG' AND
5608 g_plan_dtls(1).supervisor_assignment_id =
5609 g_qual_pop_tbl(l_qual_pop_index).assignment_id) OR
5610 (g_plan_dtls(1).hierarchy_type_code in ('POS') AND
5611 g_plan_dtls(1).top_position_id =
5612 g_qual_pop_tbl(l_qual_pop_index).position_id) OR
5613 ( g_plan_dtls(1).hierarchy_type_code ='ORG' AND
5614 is_supervisor_in_org(g_plan_dtls(1).top_organization_id,g_qual_pop_tbl(l_qual_pop_index).person_id)=1)
5615 THEN
5616 l_scorecard_status_code := 'NOT_STARTED_WITH_WKR';
5617 ELSE
5618 l_scorecard_status_code := 'NOT_STARTED_WITH_MGR';
5619 END IF;
5620 ELSE
5621 l_scorecard_status_code := 'NOT_STARTED_WITH_WKR';
5622 END IF;
5623 --
5624 create_scorecard_for_person(
5625 p_effective_date => l_effective_date
5626 ,p_scorecard_name => g_plan_dtls(1).plan_name
5627 ,p_assignment_id =>
5628 g_qual_pop_tbl(l_qual_pop_index).assignment_id
5629 ,p_start_date => g_plan_dtls(1).start_date
5630 ,p_end_date => g_plan_dtls(1).end_date
5631 ,p_plan_id => g_plan_dtls(1).plan_id
5632 ,p_creator_type => 'AUTO'
5633 ,p_status_code => l_scorecard_status_code
5634 ,p_scorecard_id => l_scorecard_id);
5635 -- Now update the plan hierarchy for this person
5636 per_wpm_summary_pkg.build_hierarchy_for_sc(p_plan_id =>g_plan_dtls(1).plan_id, p_sc_id => l_scorecard_id);
5637 -- added the above line to update hierarchy for this sc.
5638 IF (g_plan_dtls(1).automatic_allocation_flag = 'Y' AND l_scorecard_id
5639 is not NULL)
5640 THEN
5641 l_qual_obj_index := g_qual_obj_tbl.FIRST;
5642 WHILE (l_qual_obj_index IS NOT NULL)
5643 LOOP
5644 --
5645 -- Enclose the call to eligibility within a block, so that if for any
5646 -- reason the eligibility engine errors, then process can still
5647 -- continue by skipping the current person/assignemnt as not eligible
5648 --
5649 BEGIN
5650 --
5651 ben_env_object.init
5652 (p_business_group_id =>
5653 g_qual_pop_tbl(l_qual_pop_index).business_group_id,
5654 p_thread_id => null,
5655 p_chunk_size => null,
5656 p_threads => null,
5657 p_max_errors => null,
5658 p_benefit_action_id => null,
5659 p_effective_date => l_obj_date);
5660 --
5661 --
5662 l_check_elig:=
5663 ben_per_asg_elig.eligible(g_qual_pop_tbl(l_qual_pop_index).person_id
5664 ,g_qual_pop_tbl(l_qual_pop_index).assignment_id
5665 ,g_qual_obj_tbl(l_qual_obj_index).elig_obj_id
5666 ,l_obj_date
5667 ,g_qual_pop_tbl(l_qual_pop_index).business_group_id);
5668 EXCEPTION
5669 when others then
5670 NULL;
5671 END;
5672 IF (l_check_elig = 'Y') THEN
5673 -- Create the objective
5674 create_scorecard_objective(
5675 p_effective_date => l_effective_date
5676 ,p_scorecard_id => l_scorecard_id
5677 ,p_business_group_id =>
5678 g_qual_pop_tbl(l_qual_pop_index).business_group_id
5679 ,p_person_id =>
5680 g_qual_pop_tbl(l_qual_pop_index).person_id
5681 ,p_start_date => g_plan_dtls(1).start_date
5682 ,p_end_date => g_plan_dtls(1).end_date
5683 ,p_objective_name =>
5684 g_qual_obj_tbl(l_qual_obj_index).objective_name
5685 ,p_valid_from =>
5686 g_qual_obj_tbl(l_qual_obj_index).valid_from
5687 ,p_valid_to =>
5688 g_qual_obj_tbl(l_qual_obj_index).valid_to
5689 ,p_target_date =>
5690 g_qual_obj_tbl(l_qual_obj_index).target_date
5691 ,p_copied_from_library_id =>
5692 g_qual_obj_tbl(l_qual_obj_index).objective_id
5693 ,p_next_review_date =>
5694 g_qual_obj_tbl(l_qual_obj_index).NEXT_review_date
5695 ,p_group_code =>
5696 g_qual_obj_tbl(l_qual_obj_index).group_code
5697 ,p_priority_code =>
5698 g_qual_obj_tbl(l_qual_obj_index).priority_code
5699 ,p_appraise_flag =>
5700 g_qual_obj_tbl(l_qual_obj_index).appraise_flag
5701 ,p_weighting_percent =>
5702 g_qual_obj_tbl(l_qual_obj_index).weighting_percent
5703 ,p_target_value =>
5704 g_qual_obj_tbl(l_qual_obj_index).target_value
5705 ,p_uom_code =>
5706 g_qual_obj_tbl(l_qual_obj_index).uom_code
5707 ,p_measurement_style_code =>
5708 g_qual_obj_tbl(l_qual_obj_index).measurement_style_code
5709 ,p_measure_name =>
5710 g_qual_obj_tbl(l_qual_obj_index).measure_name
5711 ,p_measure_type_code =>
5712 g_qual_obj_tbl(l_qual_obj_index).measure_type_code
5713 ,p_measure_comments =>
5714 g_qual_obj_tbl(l_qual_obj_index).measure_comments
5715 ,p_details =>
5716 g_qual_obj_tbl(l_qual_obj_index).details
5717 ,p_success_criteria =>
5718 g_qual_obj_tbl(l_qual_obj_index).success_criteria
5719 ,p_comments =>
5720 g_qual_obj_tbl(l_qual_obj_index).comments);
5721 END IF;
5722 --
5723 l_qual_obj_index := g_qual_obj_tbl.NEXT(l_qual_obj_index);
5724 --
5725 END LOOP;
5726 END IF; --auto allocation flag = 'y'
5727 IF (g_plan_dtls(1).copy_past_objectives_flag = 'Y' AND
5728 g_plan_dtls(1).previous_plan_id is not NULL)
5729 THEN
5730 --
5731 copy_past_objectives
5732 (p_effective_date => l_effective_date
5733 ,p_business_group_id =>
5734 g_qual_pop_tbl(l_qual_pop_index).business_group_id
5735 ,p_person_id =>
5736 g_qual_pop_tbl(l_qual_pop_index).person_id
5737 ,p_scorecard_id => l_scorecard_id
5738 ,p_start_date => g_plan_dtls(1).start_date
5739 ,p_end_date => g_plan_dtls(1).end_date
5740 ,p_target_date => null
5741 ,p_assignemnt_id =>
5742 g_qual_pop_tbl(l_qual_pop_index).assignment_id
5743 ,p_prev_plan_id => g_plan_dtls(1).previous_plan_id
5744 ,p_curr_plan_id => g_plan_dtls(1).plan_id);
5745 --
5746 END IF; --
5747 -- Create appraisals for this person only if there exists any appraisals for this plan.
5748 IF g_plan_dtls(1).include_appraisals_flag = 'Y' AND g_appraisals_exist
5749 = 'Y' THEN
5750 l_plan_aprsl_pds_index := g_plan_aprsl_pds_tbl.FIRST;
5751 WHILE (l_plan_aprsl_pds_index IS NOT NULL)
5752 LOOP
5753 hr_wpm_mass_apr_push.create_appraisal_for_person
5754 ( p_score_card_id =>l_scorecard_id,
5755 p_appraisal_templ_id =>
5756 g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).appraisal_template_id,
5757 p_effective_date => p_effective_date, --to be validated
5758 p_appraisal_start_date =>
5759 g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).start_date,
5760 p_appraisal_end_date =>
5761 g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).end_date,
5762 p_appraisal_date =>
5763 g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).task_start_date,
5764 p_appraisal_status => 'PLANNED', -- decided in the meeting
5765 p_plan_id => p_plan_id,
5766 p_next_appraisal_date => null, -- to be
5767 p_appraisal_initiator =>
5768 g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).initiator_code,
5769 p_type =>
5770 g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).appraisal_type, -- A column to be added to UI and table in per_appraisal_periods
5771 p_appraisal_system_type =>
5772 g_plan_aprsl_pds_tbl(l_plan_aprsl_pds_index).appraisal_system_type,
5773 p_return_status => l_appr_ret_status
5774 );
5775 --
5776 l_plan_aprsl_pds_index :=
5777 g_plan_aprsl_pds_tbl.NEXT(l_plan_aprsl_pds_index);
5778 --
5779 END LOOP;
5780
5781 END IF;
5782 END IF; -- appraisal = y or objective setting 'y'
5783 END IF; -- plan PUBLISHD
5784 END enroll_a_person;
5785 --
5786 --
5787 PROCEDURE admin_enroll_into_plan(p_plan_id IN NUMBER
5788 ,p_effective_date IN DATE) IS
5789 l_proc VARCHAR2(72) := g_package||'admin_enroll_into_plan';
5790 l_plan_name per_perf_mgmt_plans.plan_name%type;
5791 --
5792 CURSOR csr_person_dtls (p_assignment_id IN NUMBER
5793 ,p_effective_date IN DATE) IS
5794 SELECT papf.person_id
5795 ,papf.full_name FULL_NAME
5796 ,paaf.assignment_id
5797 ,paaf.assignment_number
5798 ,paaf.position_id
5799 ,paaf.organization_id
5800 ,paaf.supervisor_id
5801 ,paaf.supervisor_assignment_id
5802 ,suppapf.full_name SUPERVISOR_NAME
5803 FROM per_people_f papf
5804 ,per_assignments_f paaf
5805 ,per_all_people_f suppapf
5806 WHERE paaf.assignment_id = p_assignment_id
5807 AND papf.person_id = paaf.person_id
5808 AND p_effective_date BETWEEN papf.effective_start_date AND
5809 papf.effective_end_date
5810 AND p_effective_date BETWEEN paaf.effective_start_date AND
5811 paaf.effective_end_date
5812 AND paaf.supervisor_id = suppapf.person_id(+)
5813 AND p_effective_date BETWEEN suppapf.effective_start_date(+) AND
5814 papf.effective_end_date(+);
5815 --
5816 l_person_rec csr_person_dtls%ROWTYPE;
5817 --
5818 --
5819 CURSOR csr_apprs_exist(p_plan_id IN NUMBER) IS
5820 SELECT 'Y'
5821 FROM dual
5822 WHERE EXISTS (SELECT 'x'
5823 FROM per_appraisals
5824 WHERE plan_id = p_plan_id);
5825 l_chk_exists VARCHAR2(1);
5826 --
5827 --
5828 CURSOR csr_asg_enrolled(p_assignment_id IN NUMBER,
5829 p_plan_id IN NUMBER) IS
5830 SELECT 'Y'
5831 FROM per_personal_scorecards
5832 WHERE plan_id = p_plan_id
5833 AND assignment_id = p_assignment_id;
5834 l_asg_already_enrolled VARCHAR2(1);
5835 l_person_id number;
5836 BEGIN
5837 hr_utility.set_location('Entering:'||l_proc,10);
5838 g_qual_pop_tbl.DELETE;
5839 populate_qual_plan_population(g_plan_dtls(1),p_effective_date);
5840 hr_utility.set_location(l_proc,11);
5841 IF (g_plan_dtls(1).automatic_allocation_flag = 'Y') THEN
5842 populate_qual_objectives(g_plan_dtls(1).start_date,
5843 g_plan_dtls(1).end_date);
5844 END IF;
5845 hr_utility.set_location(l_proc,12);
5846 IF (g_plan_dtls(1).include_appraisals_flag = 'Y') THEN
5847 populate_plan_apprsl_periods(g_plan_dtls(1).plan_id);
5848 OPEN csr_apprs_exist(p_plan_id);
5849 FETCH csr_apprs_exist INTO g_appraisals_exist;
5850 CLOSE csr_apprs_exist;
5851 END IF;
5852 hr_utility.set_location(l_proc,13);
5853 --
5854 l_asg_already_enrolled := 'N' ;
5855 FOR i in g_selected_entities.FIRST .. g_selected_entities.LAST
5856 LOOP
5857 hr_utility.set_location(l_proc,14);
5858 OPEN csr_asg_enrolled(g_selected_entities(i),p_plan_id);
5859 FETCH csr_asg_enrolled INTO l_asg_already_enrolled;
5860 CLOSE csr_asg_enrolled;
5861 -- Bug 7277335 Fix
5862 -- IF NVL(l_asg_already_enrolled,'N') = 'N' THEN
5863 FOR j IN csr_person_dtls(g_selected_entities(i),p_effective_date)
5864 LOOP
5865 l_chk_exists := chk_assignment_in_population(j.assignment_id);
5866 hr_utility.set_location(l_proc,15);
5867 l_person_id := j.person_id;
5868 IF l_chk_exists = 'N' THEN
5869 log_message(j.full_name||'-'||j.assignment_id||'-'||j.assignment_number||' is not in the plan population. Cannot enroll.');
5870 g_num_errors := NVL(g_num_errors,0)+1;
5871 --EDIT -- write a message to the conc.log
5872 ELSE
5873 BEGIN
5874 IF NVL(l_asg_already_enrolled,'N') = 'N' THEN
5875 log_message(j.full_name||'-'||j.assignment_number||' is in the plan population. Trying to enroll.');
5876 enroll_a_person(p_plan_id => p_plan_id,
5877 p_assignment_id => j.assignment_id,
5878 p_person_id => j.person_id,
5879 p_effective_date => p_effective_date);
5880 log_message('Successfully enrolled '||j.full_name||'-'||j.assignment_number||'.');
5881 ELSE
5882 log_message(j.full_name||'-'||j.assignment_id||'-'||j.assignment_number||' is already Enrolled ');
5883 g_num_errors := NVL(g_num_errors,0)+1;
5884 END IF;
5885
5886 EXCEPTION
5887 WHEN OTHERS THEN
5888 log_message('Error
5889 enrolling:'||j.full_name||'-'||j.assignment_number||'.');
5890 log_message(Sqlerrm);
5891 g_num_errors := NVL(g_num_errors,0)+1;
5892 END;
5893 END IF;
5894 END LOOP;
5895 send_message_notification(l_person_id,'WPM_AP_ENROLL_MSG',p_plan_id,null);
5896 -- END IF; -- asg not enrolled
5897 END LOOP;
5898 hr_utility.set_location('Leaving:'||l_proc,100);
5899 END admin_enroll_into_plan;
5900 --
5901 --
5902 PROCEDURE revert_appraisal_details(p_appraisal_id IN NUMBER
5903 ,p_plan_id IN NUMBER
5904 ,p_effective_date IN DATE) IS
5905 CURSOR csr_event_dtls(p_appraisal_id NUMBER) IS
5906 SELECT pa.appraisee_person_id
5907 ,pe.event_id
5908 ,pe.object_version_number EVENT_OVN
5909 ,ppr.performance_review_id
5910 ,ppr.object_version_number REVIEW_OVN
5911 FROM per_appraisals pa
5912 ,per_events pe
5913 ,per_performance_reviews ppr
5914 WHERE pa.appraisal_id = p_appraisal_id
5915 AND pa.event_id = pe.event_id
5916 AND pe.event_id = ppr.event_id;
5917 l_appraisee_person_id NUMBER;
5918 --
5919 CURSOR csr_appr_objs(p_appraisal_id NUMBER) IS
5920 SELECT po.objective_id
5921 ,po.object_version_number
5922 FROM per_objectives po
5923 WHERE appraisal_id = p_appraisal_id;
5924 --
5925 CURSOR csr_sc_obj(p_sc_id NUMBER, p_objective_id NUMBER) IS
5926 SELECT po.objective_id
5927 ,po.object_version_number
5928 FROM per_objectives po
5929 WHERE scorecard_id = p_sc_id
5930 AND copied_from_objective_id = p_objective_id;
5931 --
5932 CURSOR csr_sc_id (p_appraisee_person_id NUMBER
5933 ,p_plan_id NUMBER) IS
5934 SELECT scorecard_id
5935 FROM per_personal_scorecards sc
5936 WHERE person_id = p_appraisee_person_id
5937 AND plan_id = p_plan_id;
5938 l_sc_id NUMBER;
5939 -- Variables for IN/OUT parameters
5940 l_weighting_over_100_warning boolean;
5941 l_weighting_appraisal_warning boolean;
5942 l_object_version_number number;
5943 BEGIN
5944 -- Delete the event that is created and the performance review row as well
5945 FOR i in csr_event_dtls(p_appraisal_id)
5946 LOOP
5947 l_appraisee_person_id := i.appraisee_person_id;
5948 hr_perf_review_api.delete_perf_review
5949 (
5950 p_performance_review_id => i.performance_review_id
5951 ,p_object_version_number => i.review_ovn
5952 );
5953 --
5954 per_events_api.delete_event
5955 (
5956 p_event_id => i.event_id
5957 ,p_object_version_number => i.event_ovn
5958 );
5959 END LOOP;
5960 OPEN csr_sc_id(l_appraisee_person_id,p_plan_id);
5961 FETCH csr_sc_id INTO l_sc_id;
5962 CLOSE csr_sc_id;
5963 --
5964 -- Update the scorecard_id back in all the appraisal objectives
5965 -- and delete the duplicated objectives from the sc
5966 IF l_sc_id IS NOT NULL THEN
5967 FOR j in csr_appr_objs(p_appraisal_id)
5968 LOOP
5969 l_object_version_number := j.object_version_number;
5970 hr_objectives_api.update_objective
5971 (p_validate => false
5972 ,p_effective_date => p_effective_date
5973 ,p_objective_id => j.objective_id
5974 ,p_object_version_number => l_object_version_number
5975 ,p_scorecard_id => l_sc_id
5976 ,p_weighting_over_100_warning => l_weighting_over_100_warning
5977 ,p_weighting_appraisal_warning => l_weighting_appraisal_warning
5978 ,p_appraise_flag => 'Y'
5979 );
5980 --now delete the duplicated objective from the SC
5981 FOR i IN csr_sc_obj(l_sc_id,j.objective_id)
5982 LOOP
5983 hr_objectives_api.delete_objective
5984 (p_validate => false
5985 ,p_objective_id => i.objective_id
5986 ,p_object_version_number => i.object_version_number);
5987 END LOOP;
5988 END LOOP;
5989 END IF;
5990 --
5991 END revert_appraisal_details;
5992 --
5993 --
5994 PROCEDURE admin_reopen_plan_appraisals(p_plan_id IN NUMBER
5995 ,p_effective_date IN DATE) IS
5996 CURSOR csr_appraisal_dtls(p_appraisal_id IN NUMBER
5997 ,p_plan_id IN NUMBER
5998 ,p_effective_date IN DATE) IS
5999 SELECT pa.APPRAISAL_ID
6000 ,pa.main_appraiser_id
6001 ,pa.appraisee_person_id
6002 ,papf.full_name "MAIN_APPRAISER_NAME"
6003 ,papf1.full_name "APPRAISEE_NAME"
6004 ,to_char(appraisal_period_start_date,'DD-MON-YYYY')
6005 appraisal_period_start_date
6006 ,to_char(appraisal_period_end_date,'DD-MON-YYYY')
6007 appraisal_period_end_date
6008 ,to_char(appraisal_date,'DD-MON-YYYY') appraisal_date
6009 ,pa.status
6010 ,pa.assignment_id
6011 FROM per_appraisals pa
6012 ,per_people_f papf
6013 ,per_people_f papf1
6014 WHERE pa.appraisal_id = p_appraisal_id
6015 AND pa.plan_id = p_plan_id
6016 AND pa.main_appraiser_id = papf.person_id
6017 AND p_effective_date BETWEEN papf.effective_start_date AND
6018 papf.effective_end_date
6019 AND pa.appraisee_person_id = papf1.person_id
6020 AND p_effective_date BETWEEN papf1.effective_start_date AND
6021 papf1.effective_end_date;
6022 l_appraisal_dtls VARCHAR2(4000);
6023 l_person_id per_appraisals.appraisee_person_id%type;
6024 l_assignment_id per_appraisals.assignment_id%type;
6025 l_full_name per_people_f.full_name%type;
6026 BEGIN
6027 FOR i in g_selected_entities.FIRST .. g_selected_entities.LAST
6028 LOOP
6029 BEGIN
6030 FOR j IN csr_appraisal_dtls(g_selected_entities(i),p_plan_id,p_effective_date)
6031 LOOP
6032 log_message('Opening appraisal for: '||j.appraisee_name);
6033 log_message('This appraisal will be assigned to the main appraiser,'||j.main_appraiser_name||' in Ongoing Status.');
6034 l_appraisal_dtls := j.appraisee_name||'-'||j.appraisal_period_start_date||' - '||j.appraisal_period_end_date;
6035 l_person_id := j.appraisee_person_id;
6036 l_assignment_id := j.assignment_id;
6037 l_full_name := j.APPRAISEE_NAME;
6038 END LOOP;
6039 --
6040 revert_appraisal_details(p_appraisal_id => g_selected_entities(i)
6041 ,p_plan_id => p_plan_id
6042 ,p_effective_date => p_effective_date);
6043 --
6044 UPDATE per_appraisals pa
6045 SET system_params = SUBSTR(system_params,1,instr(pa.system_params,'pItemKey=')-2),
6046 appraisal_system_status = 'ONGOING' ,
6047 event_id = NULL
6048 WHERE pa.appraisal_id = g_selected_entities(i);
6049 --
6050 --
6051 send_message_notification(get_manager_id(l_person_id,l_assignment_id),'WPM_APPRAISAL_REOPEN_MGR_MSG',p_plan_id,l_full_name);
6052 send_message_notification(l_person_id,'WPM_APPRAISAL_REOPEN_WKR_MSG',p_plan_id,null);
6053 --
6054 EXCEPTION
6055 WHEN OTHERS THEN
6056 log_message('Error reopening appraisal:'||l_appraisal_dtls||'.');
6057 log_message(Sqlerrm);
6058 g_num_errors := NVL(g_num_errors,0)+1;
6059 END;
6060 END LOOP;
6061 END admin_reopen_plan_appraisals;
6062 --
6063 --
6064 PROCEDURE remove_scorecard_details(p_scorecard_id IN NUMBER) IS
6065 BEGIN
6066 DELETE
6067 FROM hr_api_transaction_steps step
6068 WHERE step.transaction_id IN (SELECT trn.transaction_id
6069 FROM hr_api_transactions trn
6070 WHERE trn.transaction_ref_id =
6071 p_scorecard_id
6072 AND trn.transaction_ref_table =
6073 'PER_PERSONAL_SCORECARDS');
6074 DELETE
6075 FROM hr_api_transactions
6076 WHERE transaction_ref_id = p_scorecard_id
6077 AND transaction_ref_table = 'PER_PERSONAL_SCORECARDS';
6078 --
6079 DELETE
6080 FROM per_objectives
6081 WHERE scorecard_id = p_scorecard_id;
6082 END remove_scorecard_details;
6083 PROCEDURE admin_remove_scorecard(p_plan_id IN NUMBER
6084 ,p_effective_date IN DATE) IS
6085 CURSOR csr_sc_dtls(p_sc_id IN NUMBER
6086 ,p_plan_id IN NUMBER
6087 ,p_effective_date IN DATE) IS
6088 SELECT pc.scorecard_id
6089 ,pc.person_id
6090 ,papf.full_name scorecard_owner
6091 ,pc.status_code
6092 FROM per_personal_scorecards pc
6093 ,per_people_f papf
6094 WHERE pc.scorecard_id = p_sc_id
6095 AND pc.plan_id = p_plan_id
6096 AND pc.person_id = papf.person_id
6097 AND p_effective_date BETWEEN papf.effective_start_date AND
6098 papf.effective_end_date;
6099 --
6100 CURSOR csr_appr_dtls(p_person_id NUMBER, p_plan_id NUMBER) IS
6101 SELECT appraisal_id,object_version_number
6102 FROM per_appraisals
6103 WHERE plan_id = p_plan_id
6104 AND appraisee_person_id = p_person_id;
6105 --
6106 l_sc_dtls VARCHAR2(500);
6107 l_person_id per_personal_scorecards.person_id%type;
6108 BEGIN
6109 FOR i in g_selected_entities.FIRST .. g_selected_entities.LAST
6110 LOOP
6111 BEGIN
6112 FOR j IN csr_sc_dtls(g_selected_entities(i),p_plan_id,p_effective_date)
6113 LOOP
6114 log_message('Removing scorecard for: '||j.scorecard_owner);
6115 l_sc_dtls := j.scorecard_owner||'- '||j.status_code;
6116 -- no need to remove score card details
6117 remove_scorecard_details(g_selected_entities(i));
6118 -- UPdate the status of score card to DELETED
6119 DELETE per_personal_scorecards
6120 WHERE scorecard_id = g_selected_entities(i);
6121 --
6122 FOR k IN csr_appr_dtls(j.person_id,p_plan_id)
6123 LOOP
6124 delete_appraisal_for_person(k.appraisal_id,k.object_version_number);
6125 END LOOP;
6126 -- remove the node from the hierarchy
6127 DELETE
6128 FROM per_wpm_plan_hierarchy
6129 WHERE employee_person_id = j.person_id;
6130 --
6131 l_person_id := j.person_id;
6132 END LOOP;
6133 send_message_notification(l_person_id,'WPM_SC_REMOVE_MSG',p_plan_id,null);
6134 --
6135 EXCEPTION
6136 WHEN OTHERS THEN
6137 log_message('Error removing scorecard:'||l_sc_dtls||'.');
6138 log_message(Sqlerrm);
6139 g_num_errors := NVL(g_num_errors,0)+1;
6140 END;
6141 END LOOP;
6142 --
6143 END admin_remove_scorecard;
6144 --
6145 --
6146 PROCEDURE admin_reopen_scorecard(p_plan_id IN NUMBER
6147 ,p_effective_date IN DATE) IS
6148 CURSOR csr_sc_dtls(p_sc_id IN NUMBER
6149 ,p_plan_id IN NUMBER
6150 ,p_effective_date IN DATE) IS
6151 SELECT pc.scorecard_id
6152 ,pc.person_id
6153 ,papf.full_name scorecard_owner
6154 ,pc.status_code
6155 ,papf.business_group_id
6156 ,paaf.organization_id
6157 ,paaf.position_id
6158 ,paaf.job_id
6159 ,pc.assignment_id
6160 ,paaf.supervisor_id -- Bug7567079
6161 FROM per_personal_scorecards pc
6162 ,per_people_f papf
6163 ,per_assignments_f paaf
6164 WHERE pc.scorecard_id = p_sc_id
6165 AND pc.plan_id = p_plan_id
6166 AND pc.assignment_id = paaf.assignment_id
6167 AND pc.person_id = papf.person_id
6168 AND p_effective_date BETWEEN paaf.effective_start_date AND
6169 paaf.effective_end_date
6170 AND p_effective_date BETWEEN papf.effective_start_date AND
6171 papf.effective_end_date;
6172 CURSOR csr_appr_in_progress(p_plan_id IN NUMBER,
6173 p_effective_date IN DATE) IS
6174 SELECT 'Y'
6175 FROM per_appraisal_periods
6176 WHERE plan_id = p_plan_id
6177 AND p_effective_date BETWEEN task_start_date AND task_end_date;
6178 l_appraisals_in_progress VARCHAR2(1) := 'N';
6179 l_sc_dtls VARCHAR2(500);
6180 l_scorecard_status_code VARCHAR2(30);
6181 --Bug7567079 l_sup_id per_all_assignments_f.supervisor_id%type default null;
6182 BEGIN
6183 OPEN csr_appr_in_progress(p_plan_id,p_effective_date);
6184 FETCH csr_appr_in_progress INTO l_appraisals_in_progress;
6185 CLOSE csr_appr_in_progress;
6186 FOR i in g_selected_entities.FIRST .. g_selected_entities.LAST
6187 LOOP
6188 FOR j IN csr_sc_dtls(g_selected_entities(i),p_plan_id,p_effective_date)
6189 LOOP
6190 BEGIN
6191 log_message('Reopening scorecard for: '||j.scorecard_owner);
6192 l_sc_dtls := j.scorecard_owner||'- '||j.status_code;
6193 IF ( TRUNC(sysdate) BETWEEN g_plan_dtls(1).obj_setting_start_date
6194 AND g_plan_dtls(1).obj_setting_deadline
6195 OR ( g_plan_dtls(1).obj_set_outside_period_flag = 'Y'
6196 AND NVL(l_appraisals_in_progress,'N') = 'N' )) THEN
6197 log_message('Within Objective setting deadline, so reopening the score
6198 card.');
6199 --included for fixing bug#6918115
6200 -- IF g_plan_dtls(1).method_code = 'CAS' THEN
6201 IF (g_plan_dtls(1).hierarchy_type_code ='SUP' AND
6202 g_plan_dtls(1).supervisor_id = j.person_id) OR
6203 (g_plan_dtls(1).hierarchy_type_code = 'SUP_ASG' AND
6204 g_plan_dtls(1).supervisor_assignment_id = j.assignment_id) OR
6205 (g_plan_dtls(1).hierarchy_type_code in ('POS') AND
6206 g_plan_dtls(1).top_position_id = j.position_id) OR
6207 ( g_plan_dtls(1).hierarchy_type_code ='ORG' AND
6208 is_supervisor_in_org(g_plan_dtls(1).top_organization_id,j.person_id)=1)
6209 THEN
6210 l_scorecard_status_code := 'NOT_STARTED_WITH_WKR';
6211 ELSE
6212 l_scorecard_status_code := 'MGR';
6213 END IF;
6214 --ELSE
6215 -- l_scorecard_status_code := 'MGR';
6216 --END IF;
6217 UPDATE per_personal_scorecards
6218 SET status_code = l_scorecard_status_code
6219 WHERE scorecard_id = g_selected_entities(i);
6220 --l_sup_id := get_manager_id(j.person_id);
6221 send_message_notification(j.person_id,'WPM_SC_REOPEN_WKR_MSG',p_plan_id,null);
6222 send_message_notification(j.supervisor_id,'WPM_SC_REOPEN_MGR_MSG',p_plan_id,j.scorecard_owner);
6223 ELSE
6224 log_message('Score card is outside the Objective setting deadline, so
6225 cannot be reopened.');
6226 END IF;
6227 EXCEPTION
6228 WHEN OTHERS THEN
6229 log_message('Error reopening scorecard:'||l_sc_dtls||'.');
6230 log_message(Sqlerrm);
6231 g_num_errors := NVL(g_num_errors,0)+1;
6232 END;
6233 END LOOP;
6234 END LOOP;
6235 --
6236 END admin_reopen_scorecard;
6237 --
6238 PROCEDURE admin_refresh_scorecard(p_plan_id IN NUMBER
6239 ,p_effective_date IN DATE) IS
6240 CURSOR csr_sc_dtls(p_sc_id IN NUMBER
6241 ,p_plan_id IN NUMBER
6242 ,p_effective_date IN DATE) IS
6243 SELECT pc.scorecard_id
6244 ,pc.person_id
6245 ,papf.full_name scorecard_owner
6246 ,pc.status_code
6247 ,papf.business_group_id
6248 ,paaf.organization_id
6249 ,paaf.position_id
6250 ,paaf.job_id
6251 ,pc.assignment_id
6252 ,paaf.supervisor_id -- Bug7567079
6253 FROM per_personal_scorecards pc
6254 ,per_people_f papf
6255 ,per_assignments_f paaf
6256 WHERE pc.scorecard_id = p_sc_id
6257 AND pc.plan_id = p_plan_id
6258 AND pc.assignment_id = paaf.assignment_id
6259 AND pc.person_id = papf.person_id
6260 AND p_effective_date BETWEEN paaf.effective_start_date AND
6261 paaf.effective_end_date
6262 AND p_effective_date BETWEEN papf.effective_start_date AND
6263 papf.effective_end_date;
6264 l_sc_rec csr_sc_dtls%ROWTYPE;
6265 l_qual_obj_index BINARY_INTEGER;
6266 l_scorecard_id NUMBER;
6267 l_obj_date DATE := trunc(sysdate);
6268 l_scorecard_status_code VARCHAR2(30);
6269 l_check_elig VARCHAR2(10);
6270 CURSOR csr_sc_dup_obj (p_scorecard_id IN NUMBER,
6271 p_library_id IN NUMBER) IS
6272 SELECT 'Y'
6273 FROM per_objectives
6274 WHERE scorecard_id = p_scorecard_id
6275 AND copied_from_library_id = p_library_id;
6276 l_sc_dup_obj VARCHAR2(1);
6277 l_sup_id per_all_assignments_f.supervisor_id%type default null;
6278 BEGIN
6279 IF (g_plan_dtls(1).automatic_allocation_flag = 'Y') THEN
6280 populate_qual_objectives(g_plan_dtls(1).start_date,
6281 g_plan_dtls(1).end_date);
6282 END IF;
6283 FOR i in g_selected_entities.FIRST .. g_selected_entities.LAST
6284 LOOP
6285 l_scorecard_id :=g_selected_entities(i);
6286 log_message('Processing Scorecard:'||l_scorecard_id);
6287 BEGIN
6288 OPEN csr_sc_dtls(l_scorecard_id,p_plan_id,p_effective_date);
6289 FETCH csr_sc_dtls INTO l_sc_rec;
6290 CLOSE csr_sc_dtls;
6291 -- No need remove details. reevaluate objectives eligibility and insert any not existing ones
6292 -- remove_scorecard_details(l_scorecard_id);
6293 --
6294 log_message('select scorecard_id rec:'||l_sc_rec.scorecard_owner);
6295 IF (g_plan_dtls(1).automatic_allocation_flag = 'Y')
6296 THEN
6297 l_qual_obj_index := g_qual_obj_tbl.FIRST;
6298 WHILE (l_qual_obj_index IS NOT NULL)
6299 LOOP
6300 --
6301 -- Enclose the call to eligibility within a block, so that if for any
6302 -- reason the eligibility engine errors, then process can still
6303 -- continue by skipping the current person/assignemnt as not eligible
6304 --
6305 log_message('Evaluating: '||g_qual_obj_tbl(l_qual_obj_index).objective_name);
6306 BEGIN
6307 --
6308 ben_env_object.init
6309 (p_business_group_id => l_sc_rec.business_group_id,
6310 p_thread_id => null,
6311 p_chunk_size => null,
6312 p_threads => null,
6313 p_max_errors => null,
6314 p_benefit_action_id => null,
6315 p_effective_date => l_obj_date);
6316 --
6317 --
6318 l_check_elig:= ben_per_asg_elig.eligible(l_sc_rec.person_id
6319 ,l_sc_rec.assignment_id
6320 ,g_qual_obj_tbl(l_qual_obj_index).elig_obj_id
6321 ,l_obj_date
6322 ,l_sc_rec.business_group_id);
6323 log_message('eLIGI CHECK:'||L_CHECK_ELIG);
6324 EXCEPTION
6325 when others then
6326 log_message('Error while evaluating eligibility for'||g_qual_obj_tbl(l_qual_obj_index).objective_name);
6327 log_message(SQLERRM);
6328 NULL;
6329 END;
6330 IF (l_check_elig = 'Y') THEN
6331 -- Create the objective
6332 OPEN
6333 csr_sc_dup_obj(l_scorecard_id,g_qual_obj_tbl(l_qual_obj_index).objective_id);
6334 FETCH csr_sc_dup_obj INTO l_sc_dup_obj;
6335 IF csr_sc_dup_obj%NOTFOUND THEN
6336 create_scorecard_objective(
6337 p_effective_date => p_effective_date
6338 ,p_scorecard_id => l_scorecard_id
6339 ,p_business_group_id => l_sc_rec.business_group_id
6340 ,p_person_id => l_sc_rec.person_id
6341 ,p_start_date => g_plan_dtls(1).start_date
6342 ,p_end_date => g_plan_dtls(1).end_date
6343 ,p_objective_name =>
6344 g_qual_obj_tbl(l_qual_obj_index).objective_name
6345 ,p_valid_from =>
6346 g_qual_obj_tbl(l_qual_obj_index).valid_from
6347 ,p_valid_to =>
6348 g_qual_obj_tbl(l_qual_obj_index).valid_to
6349 ,p_target_date =>
6350 g_qual_obj_tbl(l_qual_obj_index).target_date
6351 ,p_copied_from_library_id =>
6352 g_qual_obj_tbl(l_qual_obj_index).objective_id
6353 ,p_next_review_date =>
6354 g_qual_obj_tbl(l_qual_obj_index).NEXT_review_date
6355 ,p_group_code =>
6356 g_qual_obj_tbl(l_qual_obj_index).group_code
6357 ,p_priority_code =>
6358 g_qual_obj_tbl(l_qual_obj_index).priority_code
6359 ,p_appraise_flag =>
6360 g_qual_obj_tbl(l_qual_obj_index).appraise_flag
6361 ,p_weighting_percent =>
6362 g_qual_obj_tbl(l_qual_obj_index).weighting_percent
6363 ,p_target_value =>
6364 g_qual_obj_tbl(l_qual_obj_index).target_value
6365 ,p_uom_code =>
6366 g_qual_obj_tbl(l_qual_obj_index).uom_code
6367 ,p_measurement_style_code =>
6368 g_qual_obj_tbl(l_qual_obj_index).measurement_style_code
6369 ,p_measure_name =>
6370 g_qual_obj_tbl(l_qual_obj_index).measure_name
6371 ,p_measure_type_code =>
6372 g_qual_obj_tbl(l_qual_obj_index).measure_type_code
6373 ,p_measure_comments =>
6374 g_qual_obj_tbl(l_qual_obj_index).measure_comments
6375 ,p_details =>
6376 g_qual_obj_tbl(l_qual_obj_index).details
6377 ,p_success_criteria =>
6378 g_qual_obj_tbl(l_qual_obj_index).success_criteria
6379 ,p_comments =>
6380 g_qual_obj_tbl(l_qual_obj_index).comments);
6381 END IF; -- create only if the objective is not already copied.
6382 CLOSE csr_sc_dup_obj;
6383 END IF;
6384 --
6385 l_qual_obj_index := g_qual_obj_tbl.NEXT(l_qual_obj_index);
6386 --
6387 END LOOP;
6388 END IF; --auto allocation flag = 'y'
6389 --
6390 IF g_plan_dtls(1).method_code = 'CAS' THEN
6391 IF (g_plan_dtls(1).hierarchy_type_code ='SUP' AND
6392 g_plan_dtls(1).supervisor_id = l_sc_rec.person_id) OR
6393 (g_plan_dtls(1).hierarchy_type_code = 'SUP_ASG' AND
6394 g_plan_dtls(1).supervisor_assignment_id =
6395 l_sc_rec.assignment_id) OR
6396 (g_plan_dtls(1).hierarchy_type_code in ('POS') AND
6397 g_plan_dtls(1).top_position_id = l_sc_rec.position_id) OR
6398 ( g_plan_dtls(1).hierarchy_type_code ='ORG' AND
6399 is_supervisor_in_org(g_plan_dtls(1).top_organization_id,l_sc_rec.person_id)=1)
6400 THEN
6401 l_scorecard_status_code := 'NOT_STARTED_WITH_WKR';
6402 ELSE
6403 l_scorecard_status_code := 'NOT_STARTED_WITH_MGR';
6404 END IF;
6405 ELSE
6406 l_scorecard_status_code := 'NOT_STARTED_WITH_WKR';
6407 END IF;
6408 UPDATE per_personal_scorecards
6409 SET status_code = l_scorecard_status_code
6410 WHERE scorecard_id = l_scorecard_id;
6411 --Bug7567079 l_sup_id := get_manager_id(l_sc_rec.person_id);
6412 send_message_notification(l_sc_rec.person_id ,'WPM_SC_REFRESH_WKR',p_plan_id,null);
6413 send_message_notification(l_sc_rec.supervisor_id,'WPM_SC_REFRESH_MGR',p_plan_id,l_sc_rec.scorecard_owner);
6414 EXCEPTION
6415 WHEN Others THEN
6416 log_message('Error refreshing
6417 scorecard:'||l_sc_rec.scorecard_owner||'.');
6418 log_message(Sqlerrm);
6419 g_num_errors := NVL(g_num_errors,0)+1;
6420 END;
6421 END LOOP;
6422 END admin_refresh_scorecard;
6423 --
6424 --
6425 PROCEDURE plan_admin_actions (
6426 errbuf OUT nocopy VARCHAR2
6427 ,retcode OUT nocopy NUMBER
6428 ,p_effective_date in varchar2
6429 ,p_plan_id in number
6430 ,p_selected_entities_list in varchar2
6431 ,p_task_code in varchar2) IS
6432 l_proc VARCHAR2(72) := g_package||'plan_admin_actions';
6433 l_person_count NUMBER;
6434 CURSOR csr_plan_dtls(p_plan_id IN NUMBER) IS
6435 SELECT *
6436 FROM per_perf_mgmt_plans
6437 WHERE plan_id = p_plan_id;
6438 l_effective_date DATE;
6439 BEGIN
6440 --
6441 hr_utility.set_location('Entering '||l_proc,10);
6442
6443 g_plan_dtls.delete;
6444 OPEN csr_plan_dtls(p_plan_id);
6445 FETCH csr_plan_dtls INTO g_plan_dtls(1);
6446 CLOSE csr_plan_dtls;
6447
6448 g_num_errors := 0;
6449 --
6450 IF p_plan_id IS NULL THEN
6451 hr_api.mandatory_arg_error(p_api_name => 'PLAN_ADMIN_ACTIONS_CP'
6452 ,p_argument => 'P_PLAN_ID'
6453 ,p_argument_value => p_plan_id);
6454 END IF;
6455 IF p_effective_date IS NULL THEN
6456 hr_api.mandatory_arg_error(p_api_name => 'PLAN_ADMIN_ACTIONS_CP'
6457 ,p_argument => 'P_EFFECTIVE_DATE'
6458 ,p_argument_value => p_effective_date);
6459 END IF;
6460 IF p_selected_entities_list IS NULL THEN
6461 hr_api.mandatory_arg_error(p_api_name => 'PLAN_ADMIN_ACTIONS_CP'
6462 ,p_argument => 'P_SELECTED_ENTITIES_LIST'
6463 ,p_argument_value => p_selected_entities_list);
6464 END IF;
6465 IF p_task_code IS NULL THEN
6466 hr_api.mandatory_arg_error(p_api_name => 'PLAN_ADMIN_ACTIONS_CP'
6467 ,p_argument => 'P_TASK_CODE'
6468 ,p_argument_value => p_task_code);
6469 END IF;
6470 l_effective_date := fnd_date.canonical_to_date(p_effective_date);
6471 IF hr_api.not_exists_in_hr_lookups(p_effective_date => l_effective_date
6472 ,p_lookup_type => 'HR_WPM_ADMIN_ACTIONS'
6473 ,p_lookup_code => p_task_code) THEN
6474 log_message('Invalid task code selected.'||p_task_code);
6475 hr_utility.set_message(800,'HR_WPM_TASK_CODE_NOT_EXISTS');
6476 hr_utility.raise_error;
6477 END IF;
6478 l_person_count := string_to_array(p_selected_entities_list =>
6479 p_selected_entities_list);
6480 log_message('Number of selected persons: '||l_person_count);
6481 IF p_task_code = 'ENROLL_PLAN' THEN
6482 admin_enroll_into_plan(p_plan_id => p_plan_id
6483 ,p_effective_date => l_effective_date);
6484 ELSIF p_task_code = 'REOPEN_APPRAISALS' THEN
6485 admin_reopen_plan_appraisals(p_plan_id => p_plan_id
6486 ,p_effective_date => l_effective_date);
6487 ELSIF p_task_code = 'REMOVE_SC' THEN
6488 admin_remove_scorecard(p_plan_id => p_plan_id
6489 ,p_effective_date => l_effective_date);
6490 ELSIF p_task_code = 'REOPEN_SC' THEN
6491 admin_reopen_scorecard(p_plan_id => p_plan_id
6492 ,p_effective_date => l_effective_date);
6493 ELSIF p_task_code = 'REFRESH_SC' THEN
6494 admin_refresh_scorecard(p_plan_id => p_plan_id
6495 ,p_effective_date => l_effective_date);
6496 ELSE
6497 log_message('Invalid task code selected.'||p_task_code);
6498 hr_utility.set_message(800,'HR_WPM_TASK_CODE_NOT_VALID');
6499 hr_utility.raise_error;
6500 END IF;
6501 --
6502 --
6503 COMMIT;
6504 IF g_num_errors > 0 THEN
6505 log_message('No. of persons errored: '|| g_num_errors);
6506 retcode := WARNING;
6507 errbuf := 'Errors occured processing the selected persons. Pl. check the
6508 concurrent log for details.';
6509 END IF;
6510 hr_utility.set_location('Leaving '||l_proc,100);
6511 EXCEPTION
6512 WHEN OTHERS THEN
6513 log_message('Error Completing the process.');
6514 errbuf := SQLERRM;
6515 retcode := ERROR;
6516 ROLLBACK;
6517 RAISE;
6518 END plan_admin_actions;
6519 --
6520 procedure send_message_notification (p_person_id in number,
6521 p_message varchar2,
6522 p_plan_id per_perf_mgmt_plans.plan_id%type default null,
6523 p_full_name per_all_people_f.full_name%type
6524 )
6525 is
6526
6527 cursor get_role(person_id per_all_people_f.person_id%TYPE)
6528 is
6529 select wf.name role_name
6530 from wf_roles wf
6531 where wf.orig_system = 'PER'
6532 and wf.orig_system_id = person_id;
6533
6534 cursor csr_plan_det(p_plan_id per_perf_mgmt_plans.plan_id%type)
6535 is
6536 select plan_name,administrator_person_id
6537 from per_perf_mgmt_plans
6538 where plan_id = p_plan_id;
6539
6540 l_plan_rec csr_plan_det%rowtype;
6541
6542
6543 TO_ROLE_NOT_EXISTS exception;
6544 FROM_ROLE_NOT_EXISTS exception;
6545
6546 err_msg varchar2(2000);
6547 l_to_role wf_local_roles.name%TYPE default null;
6548 l_from_role wf_local_roles.name%TYPE default null;
6549 ln_notification_id number;
6550 begin
6551
6552 open get_role(p_person_id);
6553 fetch get_role into l_to_role;
6554 close get_role;
6555
6556
6557
6558 if l_to_role is null then
6559 raise to_role_not_exists;
6560 end if;
6561
6562 if p_plan_id is not null then
6563 open csr_plan_det(p_plan_id);
6564 fetch csr_plan_det into l_plan_rec;
6565 close csr_plan_det;
6566 end if;
6567
6568
6569 open get_role(l_plan_rec.administrator_person_id);
6570 fetch get_role into l_from_role;
6571 close get_role;
6572
6573 if l_from_role is null then
6574 raise FROM_ROLE_NOT_EXISTS;
6575 end if;
6576
6577 open get_role(p_person_id);
6578 fetch get_role into l_to_role;
6579 close get_role;
6580
6581
6582 ln_notification_id := wf_notification.send(role => l_to_role,
6583 msg_type => 'HRWPM' ,
6584 -- msg_name => 'HR_WPM_SC_REMOVE',
6585 msg_name => p_message,
6586 callback => null,
6587 context => null,
6588 send_comment => null,
6589 priority => 50) ;
6590
6591 wf_notification.SetAttrText(ln_notification_id,'#FROM_ROLE',l_from_role);
6592
6593 if (p_message='WPM_AP_ENROLL_MSG' or p_message = 'WPM_SC_REMOVE_MSG' or p_message = 'WPM_PLAN_ROLLBACK_MSG' ) then
6594 wf_notification.SetAttrText(ln_notification_id,'HR_WPM_PLAN_NAME' ,l_plan_rec.plan_name);
6595 elsif p_message = 'WPM_SC_REOPEN_MGR_MSG' or p_message = 'WPM_SC_REFRESH_MGR' then
6596 wf_notification.SetAttrText(ln_notification_id,'SCORE_CARD_EMP_NAME' ,p_full_name);
6597 elsif p_message = 'WPM_APPRAISAL_REOPEN_MGR_MSG' then
6598 wf_notification.SetAttrText(ln_notification_id,'APPRAISAL_EMP_NAME' ,p_full_name);
6599 end if;
6600 wf_notification.Denormalize_Notification(ln_notification_id,null,null);
6601
6602
6603 exception
6604 WHEN OTHERS THEN
6605 dbms_output.put_line(SubStr('Error '||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
6606 err_msg := SubStr('Error '||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255);
6607 end send_message_notification;
6608
6609 function get_manager_id ( p_person_id in per_all_assignments_f.person_id%type, p_assignment_id per_all_assignments_f.assignment_id%type)
6610 return number
6611 is
6612
6613 cursor get_supervisor_id(person_id per_all_people_f.person_id%TYPE)
6614 is
6615 select supervisor_id from per_all_assignments_f
6616 where person_id=p_person_id
6617 and trunc(sysdate) between effective_start_date and effective_end_date
6618 and primary_flag = 'Y';
6619
6620
6621 l_super_visor_id per_all_assignments_f.supervisor_id%type;
6622 l_role wf_local_roles.name%TYPE default null;
6623 begin
6624
6625 open get_supervisor_id(p_person_id);
6626 fetch get_supervisor_id into l_super_visor_id;
6627 close get_supervisor_id;
6628 return l_super_visor_id;
6629 exception
6630 when others then
6631 null;
6632 end get_manager_id;
6633
6634 end HR_PERF_MGMT_PLAN_INTERNAL;