[Home] [Help]
PACKAGE BODY: APPS.PA_RES_MANAGEMENT_AMG_PUB
Source
1 PACKAGE BODY PA_RES_MANAGEMENT_AMG_PUB AS
2 /* $Header: PAPMRSPB.pls 120.14.12020000.2 2012/07/19 09:56:24 admarath ship $ */
3
4 G_PA_MISS_NUM CONSTANT NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM;
5 G_PA_MISS_DATE CONSTANT DATE := PA_INTERFACE_UTILS_PUB.G_PA_MISS_DATE;
6 G_PA_MISS_CHAR CONSTANT VARCHAR2(3) := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR;
7
8 /*---Bug 6511907 PJR Date Validation Enhancement ----- Start---*/
9
10 FUNCTION GET_PROJECT_START_DATE(l_prj_id NUMBER)
11 RETURN DATE
12 IS
13
14 l_start_dt DATE;
15
16 BEGIN
17
18 SELECT start_date
19 INTO l_start_dt
20 FROM pa_projects_all
21 WHERE project_id = l_prj_id;
22
23 RETURN l_start_dt;
24
25 EXCEPTION
26 WHEN NO_DATA_FOUND THEN
27 RETURN NULL;
28 WHEN OTHERS THEN
29 RETURN NULL;
30 END;
31
32 FUNCTION GET_PROJECT_COMPLETION_DATE(l_prj_id NUMBER)
33 RETURN DATE
34 IS
35
36 l_compl_dt DATE;
37
38 BEGIN
39
40 SELECT completion_date
41 INTO l_compl_dt
42 FROM pa_projects_all
43 WHERE project_id = l_prj_id;
44
45 RETURN l_compl_dt;
46
47 EXCEPTION
48 WHEN NO_DATA_FOUND THEN
49 RETURN NULL;
50 WHEN OTHERS THEN
51 RETURN NULL;
52 END;
53
54 /*---Bug 6511907 PJR Date Validation Enhancement ----- End---*/
55
56 FUNCTION IS_VALID_APPROVER(l_approver_id NUMBER,l_resource_id NUMBER,l_start_date DATE)
57 RETURN VARCHAR2
58 IS
59
60 l_dummy VARCHAR2(1) := 'N';
61
62 BEGIN
63
64 BEGIN
65 SELECT 'Y' into l_dummy
66 FROM dual
67 WHERE l_approver_id in
68 (SELECT pa_resource_utils.get_hr_manager_id(res_denorm.resource_id,l_start_date) approver_id
69 from pa_resources_denorm res_denorm
70 WHERE l_start_date between resource_effective_start_date
71 and resource_effective_end_date
72 START WITH resource_id = l_resource_id
73 CONNECT BY
74 prior pa_resource_utils.get_hr_manager_id(res_denorm.resource_id,l_start_date)= person_id
75 and pa_resource_utils.get_hr_manager_id(res_denorm.resource_id,l_start_date) <> prior person_id
76 and l_start_date between prior resource_effective_start_date and prior resource_effective_end_date
77 and l_start_date between resource_effective_start_date and resource_effective_end_date
78 UNION
79 SELECT per.person_id approver_id
80 from pa_resources_denorm res_denorm,
81 fnd_grants fg,
82 fnd_objects fob,
83 per_all_people_f per,
84 wf_roles wfr,
85 (select pa_security_pvt.get_menu_id('PA_PRM_RES_PRMRY_CONTACT') menu_id
86 from dual) prmry_contact_menu
87 where fob.obj_name = 'ORGANIZATION'
88 and res_denorm.resource_id = l_resource_id
89 and l_start_date between res_denorm.resource_effective_start_date and res_denorm.resource_effective_end_date
90 and fg.instance_pk1_value = to_char(res_denorm.resource_organization_id)
91 and fg.instance_type = 'INSTANCE'
92 and fg.object_id = fob.object_id
93 and fg.grantee_type = 'USER'
94 AND fg.grantee_key = wfr.name
95 AND wfr.orig_system = 'HZ_PARTY'
96 AND per.party_id = wfr.orig_system_id
97 and sysdate between per.effective_start_date and per.effective_end_date
98 and fg.menu_id = prmry_contact_menu.menu_id
99 and trunc(SYSDATE) between trunc(fg.start_date) and trunc(NVL(fg.end_date, SYSDATE+1))
100 UNION
101 select per.person_id approver_id
102 from pa_resources_denorm res_denorm,
103 fnd_grants fg,
104 fnd_objects fob,
105 wf_roles wfr,
106 per_people_f per,
107 (select pa_security_pvt.get_menu_id('PA_PRM_RES_AUTH') menu_id
108 from dual) res_auth_menu
109 where fob.obj_name = 'ORGANIZATION'
110 and res_denorm.resource_id = l_resource_id
111 and fg.instance_pk1_value = to_char(res_denorm.resource_organization_id)
112 and l_start_date between res_denorm.resource_effective_start_date and res_denorm.resource_effective_end_date
113 and fg.instance_type = 'INSTANCE'
114 and fg.object_id = fob.object_id
115 and fg.grantee_type = 'USER'
116 and fg.menu_id = res_auth_menu.menu_id
117 and trunc(SYSDATE) between trunc(fg.start_date)
118 and trunc(NVL(fg.end_date, SYSDATE+1))
119 AND fg.grantee_key = wfr.name
120 AND wfr.orig_system = 'HZ_PARTY'
121 AND per.party_id = wfr.orig_system_id
122 and sysdate between per.effective_start_date and per.effective_end_date
123 and per.person_id <> res_denorm.manager_id
124 and per.person_id not in
125 (
126 select per2.person_Id
127 from
128 fnd_grants fg2,
129 fnd_objects fob2,
130 wf_roles wfr2,
131 (select pa_security_pvt.get_menu_id('PA_PRM_RES_PRMRY_CONTACT') menu_id
132 from dual) prmry_contact_menu,
133 per_people_f per2
134 where fob.obj_name = 'ORGANIZATION'
135 and fg2.instance_pk1_value = to_char(res_denorm.resource_organization_id)
136 and fg2.instance_type = 'INSTANCE'
137 and fg2.object_id = fob2.object_id
138 and fg2.grantee_type = 'USER'
139 and fg2.menu_id = prmry_contact_menu.menu_id
140 and trunc(SYSDATE) between trunc(fg2.start_date)
141 and trunc(NVL(fg2.end_date, SYSDATE+1))
142 AND fg2.grantee_key = wfr2.name
143 AND wfr2.orig_system = 'HZ_PARTY'
144 AND per2.party_id = wfr2.orig_system_id
145 and sysdate between per2.effective_start_date
146 and per2.effective_end_date
147 )
148 ) ;
149 EXCEPTION
150 WHEN NO_DATA_FOUND THEN
151 l_dummy := 'N';
152 WHEN OTHERS THEN
153 l_dummy := 'N';
154 RAISE ;
155 END;
156
157 return l_dummy;
158 END IS_VALID_APPROVER;
159
160 -- Start of comments
161 -- API name : VALIDATE_FLEX_FIELD
162 -- Type : Private
163 -- Pre-reqs : None.
164 -- Function : This is a private API to validate Flex Field segments.
165 -- Usage : This API will be called from AMG.
166 -- Parameters :
167 -- IN/INOUT : p_desc_flex_name IN VARCHAR2
168 -- Name of the descriptive flex field.
169 -- p_attribute_category IN VARCHAR2
170 -- Context value of the flex field.
171 -- px_attribute1 .. 15 IN VARCHAR2
172 -- Attribute values.
173 -- OUT :
174 -- x_return_status OUT VARCHAR2
175 -- Indicates the return status of the API.
176 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
177 -- x_msg_count OUT NUMBER
178 -- Indicates the number of error messages in the message stack
179 -- x_msg_data OUT VARCHAR2
180 -- Indicates the error message text if only one error exists
181 -- History :
182 -- 01-Mar-2006 - amksingh - Created
183 -- End of comments
184 PROCEDURE VALIDATE_FLEX_FIELD(
185 p_desc_flex_name IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
186 , p_attribute_category IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
187 , px_attribute1 IN OUT NOCOPY VARCHAR2
188 , px_attribute2 IN OUT NOCOPY VARCHAR2
189 , px_attribute3 IN OUT NOCOPY VARCHAR2
190 , px_attribute4 IN OUT NOCOPY VARCHAR2
191 , px_attribute5 IN OUT NOCOPY VARCHAR2
192 , px_attribute6 IN OUT NOCOPY VARCHAR2
193 , px_attribute7 IN OUT NOCOPY VARCHAR2
194 , px_attribute8 IN OUT NOCOPY VARCHAR2
195 , px_attribute9 IN OUT NOCOPY VARCHAR2
196 , px_attribute10 IN OUT NOCOPY VARCHAR2
197 , px_attribute11 IN OUT NOCOPY VARCHAR2
198 , px_attribute12 IN OUT NOCOPY VARCHAR2
199 , px_attribute13 IN OUT NOCOPY VARCHAR2
200 , px_attribute14 IN OUT NOCOPY VARCHAR2
201 , px_attribute15 IN OUT NOCOPY VARCHAR2
202 , x_return_status OUT NOCOPY VARCHAR2
203 , x_msg_count OUT NOCOPY NUMBER
204 , x_msg_data OUT NOCOPY VARCHAR2
205 )
206 IS
207 TYPE seg_col_name IS TABLE OF VARCHAR2(150)
208 INDEX BY BINARY_INTEGER;
209
210 l_segment_column_name seg_col_name;
211 l_attribute seg_col_name;
212 BEGIN
213 -- This API will return only those segment values which are enabled as part of
214 -- Global Data Elements context and the passed context.
215 x_return_status := FND_API.G_RET_STS_SUCCESS;
216
217 -- I don't think we need to do null check here
218 -- If we do this check, then if some sgements are mandatory
219 -- the error will not come
220 --IF p_attribute_category IS NULL AND px_attribute1 IS NULL AND px_attribute2 IS NULL
221 --AND px_attribute3 IS NULl AND px_attribute4 IS NULL AND px_attribute5 IS NULL
222 --AND px_attribute6 IS NULL AND px_attribute7 IS NULL AND px_attribute8 IS NULL
223 --AND px_attribute9 IS NULL AND px_attribute10 IS NULL AND px_attribute11 IS NULL
224 --AND px_attribute12 IS NULL AND px_attribute13 IS NULL AND px_attribute14 IS NULL
225 --AND px_attribute15 IS NULL
226 --THEN
227 -- return;
228 --END IF;
229
230 -- DEFINE ID COLUMNS
231 fnd_flex_descval.set_context_value(p_attribute_category);
232 fnd_flex_descval.set_column_value('ATTRIBUTE1', px_attribute1);
233 fnd_flex_descval.set_column_value('ATTRIBUTE2', px_attribute2);
234 fnd_flex_descval.set_column_value('ATTRIBUTE3', px_attribute3);
235 fnd_flex_descval.set_column_value('ATTRIBUTE4', px_attribute4);
236 fnd_flex_descval.set_column_value('ATTRIBUTE5', px_attribute5);
237 fnd_flex_descval.set_column_value('ATTRIBUTE6', px_attribute6);
238 fnd_flex_descval.set_column_value('ATTRIBUTE7', px_attribute7);
239 fnd_flex_descval.set_column_value('ATTRIBUTE8', px_attribute8);
240 fnd_flex_descval.set_column_value('ATTRIBUTE9', px_attribute9);
241 fnd_flex_descval.set_column_value('ATTRIBUTE10', px_attribute10);
242 fnd_flex_descval.set_column_value('ATTRIBUTE11', px_attribute11);
243 fnd_flex_descval.set_column_value('ATTRIBUTE12', px_attribute12);
244 fnd_flex_descval.set_column_value('ATTRIBUTE13', px_attribute13);
245 fnd_flex_descval.set_column_value('ATTRIBUTE14', px_attribute14);
246 fnd_flex_descval.set_column_value('ATTRIBUTE15', px_attribute15);
247 px_attribute1 := null;
248 px_attribute2 := null;
249 px_attribute3 := null;
250 px_attribute4 := null;
251 px_attribute5 := null;
252 px_attribute6 := null;
253 px_attribute7 := null;
254 px_attribute8 := null;
255 px_attribute9 := null;
256 px_attribute10 := null;
257 px_attribute11 := null;
258 px_attribute12 := null;
259 px_attribute13 := null;
260 px_attribute14 := null;
261 px_attribute15 := null;
262 -- VALIDATE
263 IF (fnd_flex_descval.validate_desccols( 'PA',p_desc_flex_name,'D', sysdate)) then
264 x_msg_data := 'VALID: ' || fnd_flex_descval.concatenated_ids;
265 x_return_status := 'S';
266 FOR j IN 1 ..15 LOOP --Bug 7240954
267 l_segment_column_name(j) := ltrim(rtrim(FND_FLEX_DESCVAL.segment_column_name(j)));
268 l_attribute(j) := ltrim(rtrim(FND_FLEX_DESCVAL.segment_id(j)));
269
270 IF l_segment_column_name(j) = 'ATTRIBUTE1' Then
271 px_attribute1 := l_attribute(j);
272 ELSIF l_segment_column_name(j) = 'ATTRIBUTE2' Then
273 px_attribute2 := l_attribute(j);
274 ELSIF l_segment_column_name(j) = 'ATTRIBUTE3' Then
275 px_attribute3 := l_attribute(j);
276 ELSIF l_segment_column_name(j) = 'ATTRIBUTE4' Then
277 px_attribute4 := l_attribute(j);
278 ELSIF l_segment_column_name(j) = 'ATTRIBUTE5' Then
279 px_attribute5 := l_attribute(j);
280 ELSIF l_segment_column_name(j) = 'ATTRIBUTE6' Then
281 px_attribute6 := l_attribute(j);
282 ELSIF l_segment_column_name(j) = 'ATTRIBUTE7' Then
283 px_attribute7 := l_attribute(j);
284 ELSIF l_segment_column_name(j) = 'ATTRIBUTE8' Then
285 px_attribute8 := l_attribute(j);
286 ELSIF l_segment_column_name(j) = 'ATTRIBUTE9' Then
287 px_attribute9 := l_attribute(j);
288 ELSIF l_segment_column_name(j) = 'ATTRIBUTE10' Then
289 px_attribute10 := l_attribute(j);
290 ELSIF l_segment_column_name(j) = 'ATTRIBUTE11' Then
291 px_attribute11 := l_attribute(j);
292 ELSIF l_segment_column_name(j) = 'ATTRIBUTE12' Then
293 px_attribute12 := l_attribute(j);
294 ELSIF l_segment_column_name(j) = 'ATTRIBUTE13' Then
295 px_attribute13 := l_attribute(j);
296 ELSIF l_segment_column_name(j) = 'ATTRIBUTE14' Then
297 px_attribute14 := l_attribute(j);
298 ELSIF l_segment_column_name(j) = 'ATTRIBUTE15' Then
299 px_attribute15 := l_attribute(j);
300 END IF;
301 END LOOP;
302 ELSE
303 x_msg_data := 'INVALID: ' || fnd_flex_descval.error_message;
304 x_return_status := 'E';
305 END IF;
306 EXCEPTION
307 WHEN OTHERS THEN
308 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
309 x_msg_data := SQLERRM;
310
311 FND_MSG_PUB.add_exc_msg
312 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
313 , p_procedure_name => 'VALIDATE_FLEX_FIELD'
314 , p_error_text => x_msg_data);
315
316 x_msg_count := FND_MSG_PUB.count_msg;
317
318 RAISE;
319 END VALIDATE_FLEX_FIELD;
320
321 -- Start of comments
322 -- API name : CREATE_REQUIREMENTS
323 -- Type : Public
324 -- Pre-reqs : None.
325 -- Function : This is a public API to create one or more requirements for one or more projects.
326 -- Usage : This API will be called from AMG.
327 -- Parameters :
328 -- IN : p_api_version_number IN NUMBER Required
329 -- To be compliant with Applications API coding standards.
330 -- p_init_msg_list IN VARCHAR2
331 -- Identifier to initialize the error message stack.
332 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
333 -- p_commit IN VARCHAR2
334 -- Identifier to commit the transaction.
335 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
336 -- p_requirement_in_tbl IN REQUIREMENT_IN_TBL_TYPE Required
337 -- Table of requirement records. Please see the REQUIREMENT_IN_TBL_TYPE datatype table.
338 -- OUT :
339 -- x_requirement_id_tbl OUT SYSTEM.PA_NUM_TBL_TYPE
340 -- Table to store requirement_ids created by the API.
341 -- Reference: pa_project_assignments.assignment_id
342 -- x_return_status OUT VARCHAR2
343 -- Indicates the return status of the API.
344 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
345 -- x_msg_count OUT NUMBER
346 -- Indicates the number of error messages in the message stack
347 -- x_msg_data OUT VARCHAR2
348 -- Indicates the error message text if only one error exists
349 -- History :
350 -- 01-Mar-2006 - amksingh - Created
351 -- End of comments
352 PROCEDURE CREATE_REQUIREMENTS
353 (
354 p_api_version_number IN NUMBER := 1.0
355 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
356 , p_commit IN VARCHAR2 := FND_API.G_FALSE
357 , p_requirement_in_tbl IN REQUIREMENT_IN_TBL_TYPE
358 , x_requirement_id_tbl OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE
359 , x_return_status OUT NOCOPY VARCHAR2
360 , x_msg_count OUT NOCOPY NUMBER
361 , x_msg_data OUT NOCOPY VARCHAR2
362 )
363 IS
364 l_calling_application VARCHAR2(10) := 'PLSQL';
365 l_calling_module VARCHAR2(10) := 'AMG';
366 l_check_id_flag VARCHAR2(1) := 'Y';
367 l_check_role_security_flag VARCHAR2(1) := 'Y';
368 l_check_resource_security_flag VARCHAR2(1) := 'Y';
369 l_log_level NUMBER := 3;
370 l_module VARCHAR2(100) := 'PA_RES_MANAGEMENT_AMG_PUB.CREATE_REQUIREMENTS';
371 l_commit VARCHAR2(1) := FND_API.G_FALSE;
372 l_init_msg_list VARCHAR2(1) := FND_API.G_FALSE;
373 l_validate_only VARCHAR2(1) := FND_API.G_FALSE;
374 l_msg_count NUMBER;
375 l_msg_data VARCHAR2(2000);
376 l_msg_index_out NUMBER;
377 l_data VARCHAR2(2000);
378 l_debug_mode VARCHAR2(1);
379
380 i NUMBER;
381 l_new_assignment_id_tbl SYSTEM.PA_NUM_TBL_TYPE := SYSTEM.PA_NUM_TBL_TYPE();
382 l_new_assignment_id NUMBER;
383 l_assignment_number NUMBER;
384 l_assignment_row_id ROWID;
385 l_resource_id NUMBER;
386 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
387 l_error_flag VARCHAR2(1) := 'N';
388 l_error_flag_local VARCHAR2(1) := 'N';
389 l_req_rec REQUIREMENT_IN_REC_TYPE;
390 l_asgn_creation_mode VARCHAR2(10) := 'FULL';
391 l_assignment_type VARCHAR2(30) := 'OPEN_ASSIGNMENT';
392 l_multiple_status_flag VARCHAR2(1) := 'N';
393 l_dummy_code VARCHAR2(30);
394 l_loop_msg_count NUMBER :=0;
395 l_start_msg_count NUMBER :=0;
396 l_end_msg_count NUMBER :=0;
397 l_missing_params VARCHAR2(1000);
398 l_privilege VARCHAR2(30);
399 l_object_name VARCHAR2(30);
400 l_object_key NUMBER;
401 l_error_message_code VARCHAR2(30);
402 l_ret_code VARCHAR2(1);
403
404
405 CURSOR c_get_valid_calendar_types(c_code VARCHAR2) IS
406 SELECT lookup_code
407 FROM pa_lookups
408 WHERE lookup_type = 'CHANGE_CALENDAR_TYPE_CODE'
409 AND lookup_code = c_code
410 AND lookup_code <> 'RESOURCE';
411
412 CURSOR c_get_project_dtls(c_project_id NUMBER) IS
413 SELECT role_list_id, multi_currency_billing_flag, calendar_id, work_type_id, location_id
414 FROM pa_projects_all
415 WHERE project_id = c_project_id;
416
417 CURSOR c_get_team_templ_dtls(c_team_templ_id NUMBER) IS
418 SELECT role_list_id, calendar_id, work_type_id
419 FROM pa_team_templates
420 WHERE team_template_id = c_team_templ_id;
421
422 CURSOR c_get_role_dtls(c_role_id NUMBER) IS
423 SELECT meaning, default_min_job_level, default_max_job_level, default_job_id
424 FROM pa_project_role_types_vl
425 WHERE project_role_id = c_role_id ;
426
427 CURSOR get_bill_rate_override_flags(c_project_id NUMBER) IS
428 SELECT impl.rate_discount_reason_flag ,impl.br_override_flag, impl.br_discount_override_flag
429 FROM pa_implementations_all impl
430 , pa_projects_all proj
431 WHERE proj.org_id=impl.org_id -- Removed nvl condition from org_id : Post review changes for Bug 5130421
432 AND proj.project_id = c_project_id ;
433
434 CURSOR c_get_lookup_exists(c_lookup_type VARCHAR2, c_lookup_code VARCHAR2) IS
435 SELECT 'Y'
436 FROM dual
437 WHERE EXISTS
438 (SELECT 'XYZ' FROM pa_lookups WHERE lookup_type = c_lookup_type AND lookup_code = c_lookup_code);
439
440
441 CURSOR c_get_location(c_location_id NUMBER) IS
442 SELECT country_code, region, city
443 FROM pa_locations
444 WHERE location_id = c_location_id;
445
446 CURSOR c_derive_country_code(c_country_name IN VARCHAR2) IS
447 SELECT country_code
448 FROM pa_country_v
449 WHERE name = c_country_name;
450
451 CURSOR c_derive_country_name(c_country_code IN VARCHAR2) IS
452 SELECT name
453 FROM pa_country_v
454 WHERE country_code = c_country_code;
455
456
457 -- This cursor is for future extension when we support creation of team role from planning resource
458 CURSOR c_get_planning_res_info(c_resource_list_member_id NUMBER, c_budget_version_id NUMBER, c_project_id NUMBER) IS
459 SELECT
460 ra.resource_list_member_id
461 , firstrow.person_id
462 , rlm.resource_id
463 , PA_RESOURCE_UTILS.get_person_name_no_date(firstrow.person_id)
464 , ra.project_id
465 , ra.budget_version_id
466 , decode (ra.role_count, 1, firstrow.named_role, null) named_role
467 , decode (ra.role_count, 1, firstrow.project_role_id, null) project_role_id
468 , decode (ra.role_count, 1, ro.meaning, null) project_role
469 , ra.min_date task_assign_start_date
470 , ra.max_date task_assign_end_date
471 , firstrow.resource_assignment_id
472 , firstrow.res_type_code
473 FROM pa_resource_assignments firstrow
474 , pa_resource_list_members rlm
475 , pa_proj_roles_v ro
476 , (SELECT project_id , budget_version_id , resource_list_member_id , count(1) role_count , max(max_id) max_id
477 , min(min_date) min_date , max(max_date) max_date
478 FROM (SELECT project_id , budget_version_id , resource_list_member_id , project_role_id
479 , max(resource_assignment_id) max_id , min(SCHEDULE_START_DATE) min_date , max(SCHEDULE_END_DATE) max_date
480 FROM pa_resource_assignments
481 WHERE ta_display_flag = 'Y' and nvl(PROJECT_ASSIGNMENT_ID, -1) = -1
482 AND resource_class_code = 'PEOPLE'
483 GROUP BY project_id, budget_version_id, resource_list_member_id, project_role_id
484 ) res_roles
485 GROUP BY project_id, budget_version_id, resource_list_member_id
486 ) ra
487 WHERE ra.resource_list_member_id = rlm.resource_list_member_id
488 AND firstrow.resource_assignment_id = ra.max_id
489 AND firstrow.project_role_id = ro.project_role_id (+)
490 AND ra.budget_version_id = c_budget_version_id
491 AND ra.resource_list_member_id = c_resource_list_member_id
492 AND ra.project_id = c_project_id
493 AND firstrow.person_id IS NULL;
494 -- If the value from this cusror is returned, then passed resource list member id is valid
495 -- Pass this resource list member id, budget version id to internal API
496 -- Pass calendar type as PROJECT and calendar_id as of project
497 -- Pass sum_tasks_flag as N
498
499 -- In case of assignments, user can choose calendar type between PROJECT or RESOURCE
500 -- Pass this resource list member id, budget version id to internal API
501 -- Pass sum_tasks_flag as Y if calendar is RESOURCE
502 -- pass person_id, resource_id
503
504 -- Added for Bug 5202329
505 CURSOR c_get_exp_organization_id(c_business_group_id NUMBER, c_exp_organization_name VARCHAR) IS
506 SELECT organization_id
507 FROM hr_organization_units
508 WHERE business_group_id = c_business_group_id
509 AND name = c_exp_organization_name;
510
511
512 l_role_list_id NUMBER;
513 l_multi_currency_billing_flag VARCHAR2(1);
514 l_calendar_id NUMBER;
515 l_work_type_id NUMBER;
516 l_location_id NUMBER;
517 l_role_name VARCHAR2(80);
518 l_min_job_level NUMBER;
519 l_max_job_level NUMBER;
520 l_fcst_job_id NUMBER;
521 l_valid_flag VARCHAR2(1);
522 l_tp_amount_type_desc_tmp VARCHAR2(80);
523 l_rate_discount_reason_flag VARCHAR2(1);
524 l_br_override_flag VARCHAR2(1);
525 l_br_discount_override_flag VARCHAR2(1);
526 l_project_id_tmp NUMBER;
527 l_project_role_id_tmp NUMBER;
528 l_search_country_code_tmp VARCHAR2(2);
529 l_srch_exp_org_str_ver_id_tmp NUMBER;
530 l_search_exp_start_org_id_tmp NUMBER;
531 l_expenditure_org_id_tmp NUMBER;
532 l_exp_organization_id_tmp NUMBER;
533 l_fcst_job_group_id_tmp NUMBER;
534 l_fcst_job_id_tmp NUMBER;
535 l_tp_currency_override_tmp VARCHAR2(30);
536 l_valid_country VARCHAR2(1);
537 l_dummy_country_code VARCHAR2(2);
538 l_dummy_state VARCHAR2(240);
539 l_dummy_city VARCHAR2(80);
540 l_out_location_id NUMBER;
541 l_bill_currency_override_tmp VARCHAR2(30); -- 5144288, 5144369
542 l_business_group_id NUMBER; -- Added for Bug 5202329
543
544 BEGIN
545
546 --Flows which are supported by this API
547 ---------------------------------------
548 --1. Create project requirements
549 -- 1.1 Setting basic information(staffing priority, staffing owner, subteams, location etc..)
550 -- 1.2 Setting schedule information(dates, status, calendar etc..)
551 -- 1.3 Setting competencies defaulted by team role
552 -- 1.4 Setting advertisement rule
553 -- 1.5 Setting candidate search(search organization, weightages etc..) information
554 -- 1.6 Setting financial information(expendtiture organization, bill rate etc..)
555 -- 1.7 Setting forecast infomation(job, job group, expenditure type etc..)
556 --2. Create team template requirments
557 -- 2.1 Setting basic information(staffing priority, staffing owner, subteams, location etc..)
558 -- 2.2 Setting schedule information(dates, status, calendar etc..)
559 -- 2.3 Setting competencies defaulted by team role
560 --
561 --Flows which are not supported by this API
562 -------------------------------------------
563 --1. Create team role for given planning resource
564 --2. Adding candidates while creating requirements
565 --3. Adding new competencies(other than defaulted by role) while creating requirement
566
567
568 -- Mandatory Parameters
569 -----------------------
570 --1. Either project_role_id or project_role_name should be passed.
571 --2. Either team_template_id or one of project_id, project_name, project_number should be passed.
572 --3. Both start_date and end_date should be passed.
573 --4. Either status_code or status_name should be specified.
574
575
576 x_return_status := FND_API.G_RET_STS_SUCCESS;
577 x_requirement_id_tbl:= SYSTEM.pa_num_tbl_type();
578
579 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE', fnd_global.user_id, fnd_global.login_id, 275, null, null), 'N');
580
581 IF l_debug_mode = 'Y' THEN
582 PA_DEBUG.set_curr_function(p_function => 'CREATE_REQUIREMENTS', p_debug_mode => l_debug_mode);
583 END IF;
584
585 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list, FND_API.G_TRUE)) THEN
586 FND_MSG_PUB.initialize;
587 END IF;
588
589 IF p_commit = FND_API.G_TRUE THEN
590 savepoint CREATE_REQUIREMENTS_SP;
591 END IF;
592
593 IF l_debug_mode = 'Y' THEN
594 pa_debug.write(l_module, 'Start of create_requirements', l_log_level);
595 END IF;
596
597 IF l_debug_mode = 'Y' THEN
598 pa_debug.write(l_module, 'Printing Input Parameters......', l_log_level);
599 i := p_requirement_in_tbl.first;
600 WHILE i IS NOT NULL LOOP
601 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').requirement_id'||p_requirement_in_tbl(i).requirement_id, l_log_level);
602 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').requirement_name'||p_requirement_in_tbl(i).requirement_name, l_log_level);
603 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').team_template_id'||p_requirement_in_tbl(i).team_template_id, l_log_level);
604 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').number_of_requirements'||p_requirement_in_tbl(i).number_of_requirements, l_log_level);
605 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_role_id'||p_requirement_in_tbl(i).project_role_id, l_log_level);
606 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_role_name'||p_requirement_in_tbl(i).project_role_name, l_log_level);
607 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_id'||p_requirement_in_tbl(i).project_id, l_log_level);
608 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_name'||p_requirement_in_tbl(i).project_name, l_log_level);
609 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_number'||p_requirement_in_tbl(i).project_number, l_log_level);
610 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').staffing_owner_person_id'||p_requirement_in_tbl(i).staffing_owner_person_id, l_log_level);
611 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').staffing_priority_code'||p_requirement_in_tbl(i).staffing_priority_code, l_log_level);
612 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').staffing_priority_name'||p_requirement_in_tbl(i).staffing_priority_name, l_log_level);
613 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_subteam_id'||p_requirement_in_tbl(i).project_subteam_id, l_log_level);
614 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_subteam_name'||p_requirement_in_tbl(i).project_subteam_name, l_log_level);
615 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_id'||p_requirement_in_tbl(i).location_id, l_log_level);
616 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_country_code'||p_requirement_in_tbl(i).location_country_code, l_log_level);
617 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_country_name'||p_requirement_in_tbl(i).location_country_name, l_log_level);
618 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_region'||p_requirement_in_tbl(i).location_region, l_log_level);
619 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_city'||p_requirement_in_tbl(i).location_city, l_log_level);
620 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').min_resource_job_level'||p_requirement_in_tbl(i).min_resource_job_level, l_log_level);
621 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').max_resource_job_level'||p_requirement_in_tbl(i).max_resource_job_level, l_log_level);
622 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').description'||p_requirement_in_tbl(i).description, l_log_level);
623 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').additional_information'||p_requirement_in_tbl(i).additional_information, l_log_level);
624 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').start_date'||p_requirement_in_tbl(i).start_date, l_log_level);
625 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').end_date'||p_requirement_in_tbl(i).end_date, l_log_level);
626 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').status_code'||p_requirement_in_tbl(i).status_code, l_log_level);
627 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').status_name'||p_requirement_in_tbl(i).status_name, l_log_level);
628 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').calendar_type'||p_requirement_in_tbl(i).calendar_type, l_log_level);
629 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').calendar_id'||p_requirement_in_tbl(i).calendar_id, l_log_level);
630 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').calendar_name'||p_requirement_in_tbl(i).calendar_name, l_log_level);
631 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').start_adv_action_set_flag'||p_requirement_in_tbl(i).start_adv_action_set_flag, l_log_level);
632 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').adv_action_set_id'||p_requirement_in_tbl(i).adv_action_set_id, l_log_level);
633 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').adv_action_set_name'||p_requirement_in_tbl(i).adv_action_set_name, l_log_level);
634 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').comp_match_weighting'||p_requirement_in_tbl(i).comp_match_weighting, l_log_level);
635 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').avail_match_weighting'||p_requirement_in_tbl(i).avail_match_weighting, l_log_level);
636 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').job_level_match_weighting'||p_requirement_in_tbl(i).job_level_match_weighting, l_log_level);
637 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').enable_auto_cand_nom_flag'||p_requirement_in_tbl(i).enable_auto_cand_nom_flag, l_log_level);
638 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_min_availability'||p_requirement_in_tbl(i).search_min_availability, l_log_level);
639 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_exp_org_str_ver_id'||p_requirement_in_tbl(i).search_exp_org_str_ver_id, l_log_level);
640 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_exp_org_hier_name'||p_requirement_in_tbl(i).search_exp_org_hier_name, l_log_level);
641 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_exp_start_org_id'||p_requirement_in_tbl(i).search_exp_start_org_id, l_log_level);
642 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_exp_start_org_name'||p_requirement_in_tbl(i).search_exp_start_org_name, l_log_level);
643 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_country_code'||p_requirement_in_tbl(i).search_country_code, l_log_level);
644 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_country_name'||p_requirement_in_tbl(i).search_country_name, l_log_level);
645 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_min_candidate_score'||p_requirement_in_tbl(i).search_min_candidate_score, l_log_level);
646 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_org_id'||p_requirement_in_tbl(i).expenditure_org_id, l_log_level);
647 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_org_name'||p_requirement_in_tbl(i).expenditure_org_name, l_log_level);
648 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_organization_id'||p_requirement_in_tbl(i).expenditure_organization_id, l_log_level);
649 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_organization_name'||p_requirement_in_tbl(i).expenditure_organization_name, l_log_level);
650 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_type_class'||p_requirement_in_tbl(i).expenditure_type_class, l_log_level);
651 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_type'||p_requirement_in_tbl(i).expenditure_type, l_log_level);
652 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').fcst_job_group_id'||p_requirement_in_tbl(i).fcst_job_group_id, l_log_level);
653 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').fcst_job_group_name'||p_requirement_in_tbl(i).fcst_job_group_name, l_log_level);
654 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').fcst_job_id'||p_requirement_in_tbl(i).fcst_job_id, l_log_level);
655 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').fcst_job_name'||p_requirement_in_tbl(i).fcst_job_name, l_log_level);
656 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').work_type_id'||p_requirement_in_tbl(i).work_type_id, l_log_level);
657 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').work_type_name'||p_requirement_in_tbl(i).work_type_name, l_log_level);
658 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').bill_rate_option'||p_requirement_in_tbl(i).bill_rate_option, l_log_level);
659 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').bill_rate_override'||p_requirement_in_tbl(i).bill_rate_override, l_log_level);
660 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').bill_rate_curr_override'||p_requirement_in_tbl(i).bill_rate_curr_override, l_log_level);
661 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').markup_percent_override'||p_requirement_in_tbl(i).markup_percent_override, l_log_level);
662 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').discount_percentage'||p_requirement_in_tbl(i).discount_percentage, l_log_level);
663 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').rate_disc_reason_code'||p_requirement_in_tbl(i).rate_disc_reason_code, l_log_level);
664 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_rate_option'||p_requirement_in_tbl(i).tp_rate_option, l_log_level);
665 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_rate_override'||p_requirement_in_tbl(i).tp_rate_override, l_log_level);
666 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_currency_override'||p_requirement_in_tbl(i).tp_currency_override, l_log_level);
667 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_calc_base_code_override'||p_requirement_in_tbl(i).tp_calc_base_code_override, l_log_level);
668 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_percent_applied_override'||p_requirement_in_tbl(i).tp_percent_applied_override, l_log_level);
669 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').extension_possible'||p_requirement_in_tbl(i).extension_possible, l_log_level);
670 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expense_owner'||p_requirement_in_tbl(i).expense_owner, l_log_level);
671 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expense_limit'||p_requirement_in_tbl(i).expense_limit, l_log_level);
672 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').orig_system_code'||p_requirement_in_tbl(i).orig_system_code, l_log_level);
673 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').orig_system_reference'||p_requirement_in_tbl(i).orig_system_reference, l_log_level);
674 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').record_version_number'||p_requirement_in_tbl(i).record_version_number, l_log_level);
675 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute_category'||p_requirement_in_tbl(i).attribute_category, l_log_level);
676 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute1'||p_requirement_in_tbl(i).attribute1, l_log_level);
677 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute2'||p_requirement_in_tbl(i).attribute2, l_log_level);
678 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute3'||p_requirement_in_tbl(i).attribute3, l_log_level);
679 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute4'||p_requirement_in_tbl(i).attribute4, l_log_level);
680 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute5'||p_requirement_in_tbl(i).attribute5, l_log_level);
681 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute6'||p_requirement_in_tbl(i).attribute6, l_log_level);
682 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute7'||p_requirement_in_tbl(i).attribute7, l_log_level);
683 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute8'||p_requirement_in_tbl(i).attribute8, l_log_level);
684 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute9'||p_requirement_in_tbl(i).attribute9, l_log_level);
685 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute10'||p_requirement_in_tbl(i).attribute10, l_log_level);
686 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute11'||p_requirement_in_tbl(i).attribute11, l_log_level);
687 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute12'||p_requirement_in_tbl(i).attribute12, l_log_level);
688 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute13'||p_requirement_in_tbl(i).attribute13, l_log_level);
689 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute14'||p_requirement_in_tbl(i).attribute14, l_log_level);
690 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute15'||p_requirement_in_tbl(i).attribute15, l_log_level);
691 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
692 i := p_requirement_in_tbl.next(i);
693 END LOOP;
694 END IF;
695
696 PA_STARTUP.INITIALIZE(
697 p_calling_application => l_calling_application
698 , p_calling_module => l_calling_module
699 , p_check_id_flag => l_check_id_flag
700 , p_check_role_security_flag => l_check_role_security_flag
701 , p_check_resource_security_flag => l_check_resource_security_flag
702 , p_debug_level => l_log_level
703 );
704
705 IF l_debug_mode = 'Y' THEN
706 pa_debug.write(l_module, 'After call of pa_startup.initialize', l_log_level);
707 END IF;
708
709 -- Page does not check PRM licensing, but keeping this code so in future if required, can be used
710 --l_prm_license_flag := nvl(FND_PROFILE.VALUE('PA_PRM_LICENSED'),'N');
711 --IF l_prm_license_flag <> 'Y' THEN
712 -- null;
713 --END IF;
714
715 i := p_requirement_in_tbl.first;
716
717 WHILE i IS NOT NULL LOOP
718 l_error_flag_local := 'N';
719 l_missing_params := null;
720 l_req_rec := null;
721 l_valid_country := 'Y';
722
723 l_start_msg_count := FND_MSG_PUB.count_msg;
724
725 l_req_rec := p_requirement_in_tbl(i);
726
727 -- Blank Out Parameters if not passed.
728 IF l_debug_mode = 'Y' THEN
729 pa_debug.write(l_module, 'Record#'||i, l_log_level);
730 pa_debug.write(l_module, '-----------------------------', l_log_level);
731 pa_debug.write(l_module, 'NullOut parameters which are not required.', l_log_level);
732 END IF;
733
734 /*--Bug 6511907 PJR Date Validation Enhancement ----- Start--*/
735 /*-- Validating Resource Req Start and End Date against
736 Project Start and Completion dates --*/
737
738 Declare
739 l_validate VARCHAR2(10);
740 l_start_date_status VARCHAR2(10);
741 l_end_date_status VARCHAR2(10);
742 l_start_date DATE;
743 l_end_date DATE;
744 Begin
745 If l_req_rec.start_date is not null or l_req_rec.end_date is not null then
746 l_start_date := l_req_rec.start_date;
747 l_end_date := l_req_rec.end_date;
748 PA_PROJECT_DATES_UTILS.Validate_Resource_Dates
749 (l_req_rec.project_id, l_start_date, l_end_date,
750 l_validate, l_start_date_status, l_end_date_status);
751
752 If l_validate = 'Y' and l_start_date_status = 'I' Then
753
754 pa_utils.add_message
755 ( p_app_short_name => 'PA'
756 ,p_msg_name => 'PA_PJR_DATE_START_ERROR'
757 ,p_token1 => 'PROJ_TXN_START_DATE'
758 ,p_value1 => GET_PROJECT_START_DATE(l_req_rec.project_id)
759 ,p_token2 => ''
760 ,p_value2 => ''
761 ,p_token3 => ''
762 ,p_value3 => ''
763 );
764
765 RAISE FND_API.G_EXC_ERROR;
766 End If;
767
768 If l_validate = 'Y' and l_end_date_status = 'I' Then
769
770 pa_utils.add_message
771 ( p_app_short_name => 'PA'
772 ,p_msg_name => 'PA_PJR_DATE_FINISH_ERROR'
773 ,p_token1 => 'PROJ_TXN_END_DATE'
774 ,p_value1 => GET_PROJECT_COMPLETION_DATE(l_req_rec.project_id)
775 ,p_token2 => ''
776 ,p_value2 => ''
777 ,p_token3 => ''
778 ,p_value3 => ''
779 );
780
781 RAISE FND_API.G_EXC_ERROR;
782 End If;
783 End If;
784 End;
785
786 /*--Bug 6511907 PJR Date Validation Enhancement ----- End--*/
787 IF l_req_rec.requirement_id = G_PA_MISS_NUM THEN
788 l_req_rec.requirement_id := null;
789 END IF;
790
791 IF l_req_rec.requirement_name = G_PA_MISS_CHAR THEN
792 l_req_rec.requirement_name := null;
793 END IF;
794
795 IF l_req_rec.team_template_id = G_PA_MISS_NUM THEN
796 l_req_rec.team_template_id := null;
797 END IF;
798
799 IF l_req_rec.number_of_requirements = G_PA_MISS_NUM THEN
800 l_req_rec.number_of_requirements := 1;
801 END IF;
802
803 IF l_req_rec.project_role_id = G_PA_MISS_NUM THEN
804 l_req_rec.project_role_id := null;
805 END IF;
806
807 IF l_req_rec.project_role_name = G_PA_MISS_CHAR THEN
808 l_req_rec.project_role_name := null;
809 END IF;
810
811 IF l_req_rec.project_id = G_PA_MISS_NUM THEN
812 l_req_rec.project_id := null;
813 END IF;
814
815 IF l_req_rec.project_name = G_PA_MISS_CHAR THEN
816 l_req_rec.project_name := null;
817 END IF;
818
819 IF l_req_rec.project_number = G_PA_MISS_CHAR THEN
820 l_req_rec.project_number := null;
821 END IF;
822
823 -- Some fields like Staffing Owner will be defaulted further in internal APIs
824 -- But user may like to pass them explicitely as null
825 -- So in that case we need to distinguish MISS NUM with null
826 -- But there is a problem that pa_inerface_utils_pub.g_pa_miss_num
827 -- is diffrent than fnd_api.g_miss_num. PJR internal code uses
828 -- fnd_api.g_miss_num, so it throws the error.
829 -- For this reason, we need to convert the G_PA_MISS_NUM/CHAR to FND_API.G_MISS_NUM/CHAR
830 -- before sending it to internal APIs
831
832 IF l_req_rec.staffing_owner_person_id = G_PA_MISS_NUM THEN
833 -- We can not make null here
834 -- Because underlying API treat null as override and does not
835 -- default value.
836 l_req_rec.staffing_owner_person_id := FND_API.G_MISS_NUM;
837 END IF;
838
839 IF l_req_rec.staffing_priority_code = G_PA_MISS_CHAR THEN
840 l_req_rec.staffing_priority_code := null;
841 END IF;
842
843 IF l_req_rec.staffing_priority_name = G_PA_MISS_CHAR THEN
844 l_req_rec.staffing_priority_name := null;
845 END IF;
846
847 IF l_req_rec.project_subteam_id = G_PA_MISS_NUM THEN
848 l_req_rec.project_subteam_id := null;
849 END IF;
850
851 IF l_req_rec.project_subteam_name = G_PA_MISS_CHAR THEN
852 l_req_rec.project_subteam_name := null;
853 END IF;
854
855 -- Location will be default to project location for project requirements
856 -- But user may like to pass them explicitely as null
857 -- So in that case we need to distinguish MISS CHAR with null
858 IF l_req_rec.location_id = G_PA_MISS_NUM THEN
859 l_req_rec.location_id := FND_API.G_MISS_NUM;
860 END IF;
861
862 IF l_req_rec.location_country_code = G_PA_MISS_CHAR THEN
863 l_req_rec.location_country_code := FND_API.G_MISS_CHAR;
864 END IF;
865
866 IF l_req_rec.location_country_name = G_PA_MISS_CHAR THEN
867 l_req_rec.location_country_name := FND_API.G_MISS_CHAR;
868 END IF;
869
870 IF l_req_rec.location_region = G_PA_MISS_CHAR THEN
871 l_req_rec.location_region := FND_API.G_MISS_CHAR;
872 END IF;
873
874 IF l_req_rec.location_city = G_PA_MISS_CHAR THEN
875 l_req_rec.location_city := FND_API.G_MISS_CHAR;
876 END IF;
877
878
879 IF l_req_rec.min_resource_job_level = G_PA_MISS_NUM THEN
880 l_req_rec.min_resource_job_level := null;
881 END IF;
882
883 IF l_req_rec.max_resource_job_level = G_PA_MISS_NUM THEN
884 l_req_rec.max_resource_job_level := null;
885 END IF;
886
887 IF l_req_rec.description = G_PA_MISS_CHAR THEN
888 l_req_rec.description := null;
889 END IF;
890
891 IF l_req_rec.additional_information = G_PA_MISS_CHAR THEN
892 l_req_rec.additional_information := null;
893 END IF;
894
895 IF l_req_rec.start_date = G_PA_MISS_DATE THEN
896 l_req_rec.start_date := null;
897 END IF;
898
899 IF l_req_rec.end_date = G_PA_MISS_DATE THEN
900 l_req_rec.end_date := null;
901 END IF;
902
903 IF l_req_rec.status_code = G_PA_MISS_CHAR THEN
904 l_req_rec.status_code := null;
905 END IF;
906
907 IF l_req_rec.status_name = G_PA_MISS_CHAR THEN
908 l_req_rec.status_name := null;
909 END IF;
910
911 IF l_req_rec.calendar_type = G_PA_MISS_CHAR THEN
912 l_req_rec.calendar_type := 'PROJECT';
913 END IF;
914
915 IF l_req_rec.calendar_id = G_PA_MISS_NUM THEN
916 l_req_rec.calendar_id := null;
917 END IF;
918
919 IF l_req_rec.calendar_name = G_PA_MISS_CHAR THEN
920 l_req_rec.calendar_name := null;
921 END IF;
922
923 IF l_req_rec.start_adv_action_set_flag = G_PA_MISS_CHAR THEN
924 l_req_rec.start_adv_action_set_flag := null;
925 END IF;
926
927 IF l_req_rec.adv_action_set_id = G_PA_MISS_NUM THEN
928 l_req_rec.adv_action_set_id := null;
929 END IF;
930
931 IF l_req_rec.adv_action_set_name = G_PA_MISS_CHAR THEN
932 l_req_rec.adv_action_set_name := null;
933 END IF;
934
935 IF l_req_rec.comp_match_weighting = G_PA_MISS_NUM THEN
936 l_req_rec.comp_match_weighting := null;
937 END IF;
938
939 IF l_req_rec.avail_match_weighting = G_PA_MISS_NUM THEN
940 l_req_rec.avail_match_weighting := null;
941 END IF;
942
943 IF l_req_rec.job_level_match_weighting = G_PA_MISS_NUM THEN
944 l_req_rec.job_level_match_weighting := null;
945 END IF;
946
947 IF l_req_rec.enable_auto_cand_nom_flag = G_PA_MISS_CHAR THEN
948 l_req_rec.enable_auto_cand_nom_flag := null;
949 END IF;
950
951 IF l_req_rec.search_min_availability = G_PA_MISS_NUM THEN
952 l_req_rec.search_min_availability := null;
953 END IF;
954
955 IF l_req_rec.search_exp_org_str_ver_id = G_PA_MISS_NUM THEN
956 l_req_rec.search_exp_org_str_ver_id := null;
957 END IF;
958
959 IF l_req_rec.search_exp_org_hier_name = G_PA_MISS_CHAR THEN
960 l_req_rec.search_exp_org_hier_name := null;
961 END IF;
962
963 IF l_req_rec.search_exp_start_org_id = G_PA_MISS_NUM THEN
964 l_req_rec.search_exp_start_org_id := null;
965 END IF;
966
967 IF l_req_rec.search_exp_start_org_name = G_PA_MISS_CHAR THEN
968 l_req_rec.search_exp_start_org_name := null;
969 END IF;
970
971 -- Search country code, name can be made as null, so we need to distinguish
972 -- miss char with null
973 IF l_req_rec.search_country_code = G_PA_MISS_CHAR THEN
974 l_req_rec.search_country_code := FND_API.G_MISS_CHAR;
975 END IF;
976
977 IF l_req_rec.search_country_name = G_PA_MISS_CHAR THEN
978 l_req_rec.search_country_name := FND_API.G_MISS_CHAR;
979 END IF;
980
981 IF l_req_rec.search_min_candidate_score = G_PA_MISS_NUM THEN
982 l_req_rec.search_min_candidate_score := null;
983 END IF;
984
985 IF l_req_rec.expenditure_org_id = G_PA_MISS_NUM THEN
986 l_req_rec.expenditure_org_id := null;
987 END IF;
988
989 IF l_req_rec.expenditure_org_name = G_PA_MISS_CHAR THEN
990 l_req_rec.expenditure_org_name := null;
991 END IF;
992
993 IF l_req_rec.expenditure_organization_id = G_PA_MISS_NUM THEN
994 l_req_rec.expenditure_organization_id := null;
995 END IF;
996
997 IF l_req_rec.expenditure_organization_name = G_PA_MISS_CHAR THEN
998 l_req_rec.expenditure_organization_name := null;
999 END IF;
1000
1001 IF l_req_rec.expenditure_type_class = G_PA_MISS_CHAR THEN
1002 l_req_rec.expenditure_type_class := null;
1003 END IF;
1004
1005 IF l_req_rec.expenditure_type = G_PA_MISS_CHAR THEN
1006 l_req_rec.expenditure_type := null;
1007 END IF;
1008
1009 -- Job Group and ID can be null, so we need to distinguish b/w null and miss chars
1010 IF l_req_rec.fcst_job_group_id = G_PA_MISS_NUM THEN
1011 l_req_rec.fcst_job_group_id := FND_API.G_MISS_NUM;
1012 END IF;
1013
1014 IF l_req_rec.fcst_job_group_name = G_PA_MISS_CHAR THEN
1015 l_req_rec.fcst_job_group_name := FND_API.G_MISS_CHAR;
1016 END IF;
1017
1018 IF l_req_rec.fcst_job_id = G_PA_MISS_NUM THEN
1019 l_req_rec.fcst_job_id := FND_API.G_MISS_NUM;
1020 END IF;
1021
1022 IF l_req_rec.fcst_job_name = G_PA_MISS_CHAR THEN
1023 l_req_rec.fcst_job_name := FND_API.G_MISS_CHAR;
1024 END IF;
1025
1026 IF l_req_rec.work_type_id = G_PA_MISS_NUM THEN
1027 l_req_rec.work_type_id := null;
1028 END IF;
1029
1030 IF l_req_rec.work_type_name = G_PA_MISS_CHAR THEN
1031 l_req_rec.work_type_name := null;
1032 END IF;
1033
1034 IF l_req_rec.bill_rate_option = G_PA_MISS_CHAR THEN
1035 l_req_rec.bill_rate_option := 'NONE';
1036 END IF;
1037
1038 IF l_req_rec.bill_rate_override = G_PA_MISS_NUM THEN
1039 l_req_rec.bill_rate_override := null;
1040 END IF;
1041
1042 IF l_req_rec.bill_rate_curr_override = G_PA_MISS_CHAR THEN
1043 l_req_rec.bill_rate_curr_override := null;
1044 END IF;
1045
1046 IF l_req_rec.markup_percent_override = G_PA_MISS_NUM THEN
1047 l_req_rec.markup_percent_override := null;
1048 END IF;
1049
1050 IF l_req_rec.discount_percentage = G_PA_MISS_NUM THEN
1051 l_req_rec.discount_percentage := null;
1052 END IF;
1053
1054 IF l_req_rec.rate_disc_reason_code = G_PA_MISS_CHAR THEN
1055 l_req_rec.rate_disc_reason_code := null;
1056 END IF;
1057
1058 IF l_req_rec.tp_rate_option = G_PA_MISS_CHAR THEN
1059 l_req_rec.tp_rate_option := 'NONE';
1060 END IF;
1061
1062 IF l_req_rec.tp_rate_override = G_PA_MISS_NUM THEN
1063 l_req_rec.tp_rate_override := null;
1064 END IF;
1065
1066 IF l_req_rec.tp_currency_override = G_PA_MISS_CHAR THEN
1067 l_req_rec.tp_currency_override := null;
1068 END IF;
1069
1070 IF l_req_rec.tp_calc_base_code_override = G_PA_MISS_CHAR THEN
1071 l_req_rec.tp_calc_base_code_override := null;
1072 END IF;
1073
1074 IF l_req_rec.tp_percent_applied_override = G_PA_MISS_NUM THEN
1075 l_req_rec.tp_percent_applied_override := null;
1076 END IF;
1077
1078 IF l_req_rec.extension_possible = G_PA_MISS_CHAR THEN
1079 l_req_rec.extension_possible := null;
1080 END IF;
1081
1082 IF l_req_rec.expense_owner = G_PA_MISS_CHAR THEN
1083 l_req_rec.expense_owner := null;
1084 END IF;
1085
1086 IF l_req_rec.expense_limit = G_PA_MISS_NUM THEN
1087 l_req_rec.expense_limit := null;
1088 END IF;
1089
1090 IF l_req_rec.orig_system_code = G_PA_MISS_CHAR THEN
1091 l_req_rec.orig_system_code := null;
1092 END IF;
1093
1094 IF l_req_rec.orig_system_reference = G_PA_MISS_CHAR THEN
1095 l_req_rec.orig_system_reference := null;
1096 END IF;
1097
1098 IF l_req_rec.record_version_number = G_PA_MISS_NUM THEN
1099 l_req_rec.record_version_number := 1;
1100 END IF;
1101
1102 IF l_req_rec.attribute_category = G_PA_MISS_CHAR THEN
1103 l_req_rec.attribute_category := null;
1104 END IF;
1105
1106 IF l_req_rec.attribute1 = G_PA_MISS_CHAR THEN
1107 l_req_rec.attribute1 := null;
1108 END IF;
1109
1110 IF l_req_rec.attribute2 = G_PA_MISS_CHAR THEN
1111 l_req_rec.attribute2 := null;
1112 END IF;
1113
1114 IF l_req_rec.attribute3 = G_PA_MISS_CHAR THEN
1115 l_req_rec.attribute3 := null;
1116 END IF;
1117
1118 IF l_req_rec.attribute4 = G_PA_MISS_CHAR THEN
1119 l_req_rec.attribute4 := null;
1120 END IF;
1121
1122 IF l_req_rec.attribute5 = G_PA_MISS_CHAR THEN
1123 l_req_rec.attribute5 := null;
1124 END IF;
1125
1126 IF l_req_rec.attribute6 = G_PA_MISS_CHAR THEN
1127 l_req_rec.attribute6 := null;
1128 END IF;
1129
1130 IF l_req_rec.attribute7 = G_PA_MISS_CHAR THEN
1131 l_req_rec.attribute7 := null;
1132 END IF;
1133
1134 IF l_req_rec.attribute8 = G_PA_MISS_CHAR THEN
1135 l_req_rec.attribute8 := null;
1136 END IF;
1137
1138 IF l_req_rec.attribute9 = G_PA_MISS_CHAR THEN
1139 l_req_rec.attribute9 := null;
1140 END IF;
1141
1142 IF l_req_rec.attribute10 = G_PA_MISS_CHAR THEN
1143 l_req_rec.attribute10 := null;
1144 END IF;
1145
1146 IF l_req_rec.attribute11 = G_PA_MISS_CHAR THEN
1147 l_req_rec.attribute11 := null;
1148 END IF;
1149
1150 IF l_req_rec.attribute12 = G_PA_MISS_CHAR THEN
1151 l_req_rec.attribute12 := null;
1152 END IF;
1153
1154 IF l_req_rec.attribute13 = G_PA_MISS_CHAR THEN
1155 l_req_rec.attribute13 := null;
1156 END IF;
1157
1158 IF l_req_rec.attribute14 = G_PA_MISS_CHAR THEN
1159 l_req_rec.attribute14 := null;
1160 END IF;
1161
1162 IF l_req_rec.attribute15 = G_PA_MISS_CHAR THEN
1163 l_req_rec.attribute15 := null;
1164 END IF;
1165
1166
1167 -- Mandatory Parameters Check
1168 -----------------------------
1169
1170 IF l_debug_mode = 'Y' THEN
1171 pa_debug.write(l_module, 'Mandatory parameter validation starts', l_log_level);
1172 END IF;
1173
1174 IF l_req_rec.number_of_requirements IS NULL THEN
1175 l_missing_params := l_missing_params||', NUMBER_OF_REQUIREMENTS';
1176 END IF;
1177
1178 IF l_req_rec.project_role_id IS NULL AND l_req_rec.project_role_name IS NULL THEN
1179 l_missing_params := l_missing_params||', PROJECT_ROLE_ID, PROJECT_ROLE_NAME';
1180 END IF;
1181
1182 IF (l_req_rec.team_template_id IS NULL AND l_req_rec.project_id IS NULL
1183 AND l_req_rec.project_name IS NULL AND l_req_rec.project_number IS NULL
1184 )
1185 OR
1186 (l_req_rec.team_template_id IS NOT NULL AND
1187 (l_req_rec.project_id IS NOT NULL OR l_req_rec.project_name IS NOT NULL
1188 OR l_req_rec.project_number IS NOT NULL
1189 )
1190 )
1191 THEN
1192 -- Note that here we are supporting only Project Requirment and Team Template Requirment Flow.
1193 -- We are not supporting apply team template flow in which team template id and project id
1194 -- both are present.
1195 l_missing_params := l_missing_params||', TEAM_TEMPLATE_ID, PROJECT_ID, PROJECT_NAME, PROJECT_NUMBER';
1196 END IF;
1197
1198 IF l_req_rec.start_date IS NULL OR l_req_rec.end_date IS NULL THEN
1199 l_missing_params := l_missing_params||', START_DATE, END_DATE';
1200 END IF;
1201
1202 -- Requirment status is not mandatory, if not passed we default it to 101 (Open)
1203 --IF l_req_rec.status_code IS NULL AND l_req_rec.status_name IS NULL THEN
1204 -- l_missing_params := l_missing_params||', STATUS_CODE, STATUS_NAME';
1205 --END IF;
1206 IF l_req_rec.status_code IS NULL AND l_req_rec.status_name IS NULL THEN
1207 l_req_rec.status_code := 101;
1208 END IF;
1209
1210 IF l_req_rec.location_id IS NULL OR l_req_rec.location_id = FND_API.G_MISS_NUM THEN
1211 -- If either city or state (or) both are passed ,then country is
1212 -- mandatory
1213 IF (l_req_rec.location_country_code IS NULL AND l_req_rec.location_country_name IS NULL)
1214 OR (l_req_rec.location_country_code = FND_API.G_MISS_CHAR AND l_req_rec.location_country_name = FND_API.G_MISS_CHAR)
1215 THEN
1216 IF (l_req_rec.location_region <> FND_API.G_MISS_CHAR AND l_req_rec.location_region IS NOT NULL)
1217 OR (l_req_rec.location_city <> FND_API.G_MISS_CHAR AND l_req_rec.location_city IS NOT NULL)
1218 THEN
1219 l_missing_params := l_missing_params||', LOCATION_COUNTRY_CODE, LOCATION_COUNTRY_NAME';
1220 l_valid_country := 'N';
1221 END IF;
1222 ELSIF l_req_rec.location_country_code IS NOT NULL AND l_req_rec.location_country_code <> FND_API.G_MISS_CHAR
1223 THEN
1224 OPEN c_derive_country_name(l_req_rec.location_country_code);
1225 FETCH c_derive_country_name INTO l_req_rec.location_country_name;
1226 IF c_derive_country_name%NOTFOUND THEN
1227 -- Invalid Country code passed.
1228 l_missing_params := l_missing_params||', LOCATION_COUNTRY_CODE';
1229 l_valid_country := 'N';
1230 ELSE
1231 l_valid_country := 'Y';
1232 END IF;
1233 CLOSE c_derive_country_name;
1234 ELSIF l_req_rec.location_country_name IS NOT NULL AND l_req_rec.location_country_name <> FND_API.G_MISS_CHAR
1235 THEN
1236 OPEN c_derive_country_code(l_req_rec.location_country_name);
1237 FETCH c_derive_country_code INTO l_req_rec.location_country_code;
1238 IF c_derive_country_code%NOTFOUND THEN
1239 -- Invalid Country Name passed.
1240 l_missing_params := l_missing_params||', LOCATION_COUNTRY_NAME';
1241 l_valid_country := 'N';
1242 ELSE
1243 l_valid_country := 'Y';
1244 END IF;
1245 CLOSE c_derive_country_code;
1246 END IF;
1247
1248 -- If the country is valid,then proceed with the state and city validations
1249 IF l_valid_country = 'Y' AND l_req_rec.location_country_code IS NOT NULL
1250 AND l_req_rec.location_country_code <> FND_API.G_MISS_CHAR
1251 THEN
1252
1253 l_dummy_country_code := l_req_rec.location_country_code;
1254 IF l_req_rec.location_region IS NULL OR l_req_rec.location_region = FND_API.G_MISS_CHAR THEN
1255 l_dummy_state := null;
1256 ELSE
1257 l_dummy_state := l_req_rec.location_region;
1258 END IF;
1259
1260 IF l_req_rec.location_city IS NULL OR l_req_rec.location_city = FND_API.G_MISS_CHAR THEN
1261 l_dummy_city := null;
1262 ELSE
1263 l_dummy_city := l_req_rec.location_city;
1264 END IF;
1265
1266 PA_LOCATION_UTILS.CHECK_LOCATION_EXISTS
1267 (
1268 p_country_code => l_dummy_country_code
1269 ,p_city => l_dummy_city
1270 ,p_region => l_dummy_state
1271 ,x_location_id => l_out_location_id
1272 ,x_return_status => l_return_status
1273 );
1274
1275 IF l_out_location_id IS NULL THEN
1276 PA_UTILS.ADD_MESSAGE('PA','PA_AMG_RES_INV_CRC_COMB');
1277 l_error_flag_local := 'Y'; -- 5148975
1278 ELSE
1279 l_req_rec.location_id := l_out_location_id;
1280 END IF;
1281 END IF;
1282 ELSE
1283 -- if location id is passed, then it will override the city, region, country code
1284 OPEN c_get_location(l_req_rec.location_id);
1285 FETCH c_get_location INTO l_req_rec.location_country_code, l_req_rec.location_region, l_req_rec.location_city;
1286
1287 IF c_get_location%NOTFOUND THEN
1288 l_missing_params := l_missing_params||', LOCATION_ID';
1289 END IF;
1290 CLOSE c_get_location;
1291 END IF; -- l_req_rec.location_id IS NULL OR l_req_rec.location_id = FND_API.G_MISS_NUM
1292
1293
1294 IF l_req_rec.team_template_id IS NULL THEN
1295 -- Project Requirement Flow
1296
1297 IF l_req_rec.calendar_type IS NULL OR (l_req_rec.calendar_type NOT IN('PROJECT','OTHER')) THEN
1298 l_missing_params := l_missing_params||', CALENDAR_TYPE';
1299 ELSE
1300 IF l_req_rec.calendar_type = 'OTHER' AND l_req_rec.calendar_id IS NULL
1301 AND l_req_rec.calendar_name IS NULL
1302 THEN
1303 l_missing_params := l_missing_params||', CALENDAR_ID, CALENDAR_NAME';
1304 END IF;
1305 END IF;
1306
1307 -- 5148545 : Added check for search org hier and start org name
1308 IF l_req_rec.search_exp_org_str_ver_id IS NULL AND l_req_rec.search_exp_org_hier_name IS NULL
1309 AND (l_req_rec.search_exp_start_org_id IS NOT NULL OR l_req_rec.search_exp_start_org_name IS NOT NULL) THEN
1310 l_missing_params := l_missing_params||', SEARCH_EXP_ORG_STR_VER_ID, SEARCH_EXP_ORG_HIER_NAME';
1311 END IF;
1312
1313 IF l_req_rec.search_exp_start_org_id IS NULL AND l_req_rec.search_exp_start_org_name IS NULL
1314 AND (l_req_rec.search_exp_org_str_ver_id IS NOT NULL OR l_req_rec.search_exp_org_hier_name IS NOT NULL) THEN
1315 l_missing_params := l_missing_params||', SEARCH_EXP_START_ORG_ID, SEARCH_EXP_START_ORG_NAME';
1316 END IF;
1317
1318
1319 IF l_req_rec.bill_rate_option IS NULL OR l_req_rec.bill_rate_option NOT IN('RATE','MARKUP','DISCOUNT','NONE') THEN
1320 l_missing_params := l_missing_params||', BILL_RATE_OPTION';
1321 ELSE
1322 IF l_req_rec.bill_rate_option = 'NONE' THEN
1323 l_req_rec.bill_rate_override := null;
1324 l_req_rec.bill_rate_curr_override := null;
1325 l_req_rec.markup_percent_override := null;
1326 l_req_rec.discount_percentage := null;
1327 l_req_rec.rate_disc_reason_code := null;
1328 ELSIF l_req_rec.bill_rate_option = 'RATE' THEN
1329 l_req_rec.markup_percent_override := null;
1330 l_req_rec.discount_percentage := null;
1331 IF l_req_rec.bill_rate_override IS NULL THEN
1332 l_missing_params := l_missing_params||', BILL_RATE_OVERRIDE';
1333 END IF;
1334 ELSIF l_req_rec.bill_rate_option = 'MARKUP' THEN
1335 l_req_rec.bill_rate_override := null;
1336 l_req_rec.bill_rate_curr_override := null;
1337 l_req_rec.discount_percentage := null;
1338 IF l_req_rec.markup_percent_override IS NULL THEN
1339 l_missing_params := l_missing_params||', MARKUP_PERCENT_OVERRIDE';
1340 END IF;
1341 ELSIF l_req_rec.bill_rate_option = 'DISCOUNT' THEN
1342 l_req_rec.bill_rate_override := null;
1343 l_req_rec.bill_rate_curr_override := null;
1344 l_req_rec.markup_percent_override := null;
1345 IF l_req_rec.discount_percentage IS NULL THEN
1346 l_missing_params := l_missing_params||', DISCOUNT_PERCENTAGE';
1347 END IF;
1348 END IF;
1349 END IF;
1350
1351 IF l_req_rec.expenditure_type_class IS NULL AND l_req_rec.expenditure_type IS NOT NULL THEN
1352 -- Expenditue type is specified then class must also be there
1353 l_missing_params := l_missing_params||', EXPENDITURE_TYPE_CLASS';
1354 ELSIF l_req_rec.expenditure_type_class IS NOT NULL AND l_req_rec.expenditure_type IS NULL THEN
1355 l_missing_params := l_missing_params||', EXPENDITURE_TYPE';
1356 END IF;
1357
1358 IF l_req_rec.tp_rate_option IS NULL OR l_req_rec.tp_rate_option NOT IN('RATE','BASIS','NONE') THEN
1359 l_missing_params := l_missing_params||', TP_RATE_OPTION';
1360 ELSE
1361 IF l_req_rec.tp_rate_option = 'NONE' THEN
1362 l_req_rec.tp_rate_override := null;
1363 l_req_rec.tp_currency_override := null;
1364 l_req_rec.tp_calc_base_code_override := null;
1365 l_req_rec.tp_percent_applied_override := null;
1366 ELSIF l_req_rec.tp_rate_option = 'RATE' THEN
1367 l_req_rec.tp_calc_base_code_override := null;
1368 l_req_rec.tp_percent_applied_override := null;
1369 IF l_req_rec.tp_rate_override IS NULL OR l_req_rec.tp_currency_override IS NULL THEN
1370 l_missing_params := l_missing_params||', TP_RATE_OVERRIDE, TP_CURRENCY_OVERRIDE';
1371 END IF;
1372 ELSIF l_req_rec.tp_rate_option = 'BASIS' THEN
1373 l_req_rec.tp_rate_override := null;
1374 l_req_rec.tp_currency_override := null;
1375 IF l_req_rec.tp_calc_base_code_override IS NULL OR l_req_rec.tp_percent_applied_override IS NULL THEN
1376 l_missing_params := l_missing_params||', TP_CALC_BASE_CODE_OVERRIDE, TP_PERCENT_APPLIED_OVERRIDE';
1377 END IF;
1378 END IF;
1379 END IF;
1380
1381 IF l_req_rec.extension_possible IS NOT NULL AND l_req_rec.extension_possible NOT IN ('Y','N') THEN
1382 l_missing_params := l_missing_params||', EXTENSION_POSSIBLE';
1383 END IF;
1384 END IF; -- l_req_rec.team_template_id IS NULL THEN
1385
1386 IF l_debug_mode = 'Y' THEN
1387 pa_debug.write(l_module, 'Mandatory parameter validation over. List of Missing Parameters='||l_missing_params, l_log_level);
1388 END IF;
1389
1390 IF l_missing_params IS NOT NULL THEN
1391 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
1392 'INVALID_PARAMS', l_missing_params);
1393 l_error_flag_local := 'Y';
1394 END IF;
1395
1396 -- NullOut parameters which are not required in team template flow
1397 IF l_req_rec.team_template_id IS NOT NULL THEN
1398 -- Team Template flow
1399 l_req_rec.extension_possible := null;
1400 --5152025 : Mistakenly work_type_id and work_type_name was getting nulled out
1401 --l_req_rec.work_type_id := null;
1402 --l_req_rec.work_type_name := null;
1403 l_req_rec.bill_rate_override := null;
1404 l_req_rec.bill_rate_curr_override := null;
1405 l_req_rec.markup_percent_override := null;
1406 l_req_rec.discount_percentage := null;
1407 l_req_rec.rate_disc_reason_code := null;
1408 l_req_rec.tp_rate_override := null;
1409 l_req_rec.tp_currency_override := null;
1410 l_req_rec.tp_calc_base_code_override := null;
1411 l_req_rec.tp_percent_applied_override := null;
1412 l_req_rec.expense_owner := null;
1413 l_req_rec.expense_limit := null;
1414 l_req_rec.fcst_job_id := null;
1415 l_req_rec.fcst_job_group_id := null;
1416 l_req_rec.expenditure_org_id := null;
1417 l_req_rec.expenditure_organization_id := null;
1418 l_req_rec.expenditure_type_class := null;
1419 l_req_rec.expenditure_type := null;
1420 l_req_rec.fcst_job_group_name := null;
1421 l_req_rec.fcst_job_name := null;
1422 l_req_rec.expenditure_org_name := null;
1423 l_req_rec.expenditure_organization_name := null;
1424 l_req_rec.start_adv_action_set_flag := null;
1425 l_req_rec.adv_action_set_id := null;
1426 l_req_rec.adv_action_set_name := null;
1427 END IF; -- l_req_rec.team_template_id IS NOT NULL THEN
1428
1429
1430 -- Project Name, Number to ID Conversion
1431 -- Though it is done by pa_assignmnts_pub.create_assignment
1432 -- But we require to get project_id so that we can defualt
1433 -- values from the project and check security on project
1434 -- Also project name to id conversion does not happen by internal APIs
1435 IF l_debug_mode = 'Y' THEN
1436 pa_debug.write(l_module, 'Deriving ProjectId', l_log_level);
1437 END IF;
1438
1439 IF l_error_flag_local <> 'Y' AND l_req_rec.team_template_id IS NULL THEN
1440 l_project_id_tmp := l_req_rec.project_id;
1441 IF l_req_rec.project_number IS NOT NULL THEN
1442 l_return_status := FND_API.G_RET_STS_SUCCESS;
1443 l_error_message_code := null;
1444
1445 PA_PROJECT_UTILS2.CHECK_PROJECT_NUMBER_OR_ID(
1446 p_project_id => l_project_id_tmp
1447 ,p_project_number => l_req_rec.project_number
1448 ,p_check_id_flag => PA_STARTUP.g_check_id_flag
1449 ,x_project_id => l_req_rec.project_id
1450 ,x_return_status => l_return_status
1451 ,x_error_message_code => l_error_message_code );
1452
1453 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1454 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1455 l_error_flag_local := 'Y';
1456 END IF;
1457 END IF;
1458 IF l_req_rec.project_name IS NOT NULL THEN
1459 l_return_status := FND_API.G_RET_STS_SUCCESS;
1460 l_error_message_code := null;
1461
1462 PA_TASKS_MAINT_UTILS.CHECK_PROJECT_NAME_OR_ID(
1463 p_project_id => l_project_id_tmp
1464 ,p_project_name => l_req_rec.project_name
1465 ,p_check_id_flag => PA_STARTUP.g_check_id_flag
1466 ,x_project_id => l_req_rec.project_id
1467 ,x_return_status => l_return_status
1468 ,x_error_msg_code => l_error_message_code );
1469
1470 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1471 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1472 l_error_flag_local := 'Y';
1473 END IF;
1474 END IF;
1475 END IF; -- l_error_flag_local <> 'Y' AND l_req_rec.team_template_id IS NULL
1476
1477 IF l_debug_mode = 'Y' THEN
1478 pa_debug.write(l_module, 'ProjectId='||l_req_rec.project_id, l_log_level);
1479 pa_debug.write(l_module, 'TeamTemplateId='||l_req_rec.team_template_id, l_log_level);
1480 pa_debug.write(l_module, 'l_error_flag_local='||l_error_flag_local, l_log_level);
1481 END IF;
1482
1483 IF l_error_flag_local <> 'Y' AND l_req_rec.team_template_id IS NULL THEN
1484 -- Project Requirement Flow
1485 l_role_list_id := null;
1486 l_multi_currency_billing_flag := null;
1487 l_calendar_id := null;
1488 l_work_type_id := null;
1489 l_location_id := null;
1490
1491 OPEN c_get_project_dtls(l_req_rec.project_id);
1492 FETCH c_get_project_dtls INTO l_role_list_id, l_multi_currency_billing_flag, l_calendar_id
1493 , l_work_type_id, l_location_id;
1494 CLOSE c_get_project_dtls;
1495
1496 IF l_req_rec.bill_rate_option = 'RATE' AND nvl(l_multi_currency_billing_flag,'N') <> 'Y'
1497 THEN
1498 l_req_rec.bill_rate_curr_override := null;
1499 END IF;
1500 ELSIF l_error_flag_local <> 'Y' AND l_req_rec.team_template_id IS NOT NULL THEN
1501 -- Team Template Flow
1502 l_role_list_id := null;
1503 l_multi_currency_billing_flag := null;
1504 l_calendar_id := null;
1505 l_work_type_id := null;
1506 OPEN c_get_team_templ_dtls(l_req_rec.team_template_id);
1507 FETCH c_get_team_templ_dtls INTO l_role_list_id, l_calendar_id, l_work_type_id;
1508 CLOSE c_get_team_templ_dtls;
1509 END IF;
1510
1511 IF l_debug_mode = 'Y' THEN
1512 pa_debug.write(l_module, 'Defaults Value from Project or Team Template Flow', l_log_level);
1513 pa_debug.write(l_module, 'l_role_list_id='||l_role_list_id, l_log_level);
1514 pa_debug.write(l_module, 'l_multi_currency_billing_flag='||l_multi_currency_billing_flag, l_log_level);
1515 pa_debug.write(l_module, 'l_calendar_id='||l_calendar_id, l_log_level);
1516 pa_debug.write(l_module, 'l_work_type_id='||l_work_type_id, l_log_level);
1517 pa_debug.write(l_module, 'l_location_id='||l_location_id, l_log_level);
1518 END IF;
1519
1520
1521 -- Default calendar, location, work type, requirement name, min max res job level
1522 IF l_error_flag_local <> 'Y' THEN
1523 IF l_debug_mode = 'Y' THEN
1524 pa_debug.write(l_module, 'Default values of calendar, work type, location from project or team template', l_log_level);
1525 END IF;
1526
1527 -- For OTHER type of calendar there is alredy check done above in code
1528 -- For PROJECT type ignore the user value and take the project value
1529 IF l_req_rec.calendar_type = 'PROJECT' THEN
1530 l_req_rec.calendar_id := l_calendar_id;
1531 END IF;
1532
1533 IF l_req_rec.work_type_id IS NULL AND l_req_rec.work_type_name IS NULL
1534 THEN
1535 l_req_rec.work_type_id := l_work_type_id;
1536 END IF;
1537
1538 IF l_req_rec.project_id IS NOT NULL AND l_req_rec.location_id = FND_API.G_MISS_NUM
1539 AND l_req_rec.location_country_code = FND_API.G_MISS_CHAR
1540 AND l_req_rec.location_country_name = FND_API.G_MISS_CHAR
1541 AND l_req_rec.location_region = FND_API.G_MISS_CHAR
1542 AND l_req_rec.location_city = FND_API.G_MISS_CHAR
1543 THEN
1544 l_req_rec.location_id := l_location_id;
1545 END IF;
1546
1547 -- Role Validation
1548 -- Though it is done by pa_assignmnts_pub.create_assignment
1549 -- But we require to get role_id so that we can defualt
1550 -- values from the role
1551 -- Defaulting is required
1552
1553 IF l_debug_mode = 'Y' THEN
1554 pa_debug.write(l_module, 'Validating Role against Role List and doing Role Name to ID conversion', l_log_level);
1555 END IF;
1556
1557 l_return_status := FND_API.G_RET_STS_SUCCESS;
1558 l_error_message_code := null;
1559 l_project_role_id_tmp := l_req_rec.project_role_id;
1560
1561 /*passing p_check_id_flag as Y for bug 8557593 */
1562 PA_ROLE_UTILS.Check_Role_RoleList (
1563 p_role_id => l_project_role_id_tmp
1564 ,p_role_name => l_req_rec.project_role_name
1565 ,p_role_list_id => l_role_list_id
1566 ,p_role_list_name => NULL
1567 ,p_check_id_flag => 'Y'
1568 ,x_role_id => l_req_rec.project_role_id
1569 ,x_role_list_id => l_role_list_id
1570 ,x_return_status => l_return_status
1571 ,x_error_message_code => l_error_message_code );
1572
1573 IF l_debug_mode = 'Y' THEN
1574 pa_debug.write(l_module, 'After role validation Role id='||l_req_rec.project_role_id, l_log_level);
1575 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1576 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1577 END IF;
1578
1579 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1580 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1581 l_error_flag_local := 'Y';
1582 END IF;
1583
1584 IF l_debug_mode = 'Y' THEN
1585 pa_debug.write(l_module, 'Defaulting RequirmentName, Min Job Level, Max Job Level from Role ', l_log_level);
1586 END IF;
1587
1588 l_role_name := null;
1589 l_min_job_level := null;
1590 l_max_job_level := null;
1591 l_fcst_job_id := null;
1592
1593 OPEN c_get_role_dtls(l_req_rec.project_role_id);
1594 FETCH c_get_role_dtls INTO l_role_name, l_min_job_level, l_max_job_level, l_fcst_job_id;
1595 CLOSE c_get_role_dtls;
1596
1597 IF l_req_rec.requirement_name IS NULL THEN
1598 l_req_rec.requirement_name := l_role_name;
1599 END IF;
1600 IF l_req_rec.min_resource_job_level IS NULL THEN
1601 l_req_rec.min_resource_job_level := l_min_job_level;
1602 END IF;
1603 IF l_req_rec.max_resource_job_level IS NULL THEN
1604 l_req_rec.max_resource_job_level := l_max_job_level;
1605 END IF;
1606
1607 IF l_debug_mode = 'Y' THEN
1608 pa_debug.write(l_module, 'l_role_name='||l_role_name, l_log_level);
1609 pa_debug.write(l_module, 'l_min_job_level='||l_min_job_level, l_log_level);
1610 pa_debug.write(l_module, 'l_max_job_level='||l_max_job_level, l_log_level);
1611 END IF;
1612 END IF; -- l_error_flag_local <> 'Y' THEN
1613
1614 -- All validations are not required as some validation is done in underlying code
1615 -- Here, we are doing only those validations which are not done internally.
1616 -- NOTE : In update flow, all these validations are done and it is taken from there
1617 -- Ideally in create flow also, underlying code should do these validations
1618 -- But we are doing here to avoid more code changes in existing code.
1619
1620 IF l_error_flag_local <> 'Y' AND l_req_rec.project_id IS NOT NULL THEN
1621 -- Project Requirement Flow
1622
1623 -- Search Info Validation
1624 -------------------------
1625
1626
1627 -- 5147921 : In create requirment flow, weightages were not checked between 0 and 100
1628 -- They are checked by internal API in update flow but not in create flow.
1629 -- Hence added checks here
1630
1631 IF (l_req_rec.comp_match_weighting IS NOT NULL AND (l_req_rec.comp_match_weighting < 0 OR l_req_rec.comp_match_weighting > 100))
1632 OR (l_req_rec.avail_match_weighting IS NOT NULL AND (l_req_rec.avail_match_weighting < 0 OR l_req_rec.avail_match_weighting > 100))
1633 OR (l_req_rec.job_level_match_weighting IS NOT NULL AND (l_req_rec.job_level_match_weighting < 0 OR l_req_rec.job_level_match_weighting > 100))
1634 THEN
1635 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_MATCH_WEIGHTING');
1636 l_error_flag_local := 'Y';
1637 END IF;
1638
1639 IF l_req_rec.search_min_availability IS NOT NULL AND (l_req_rec.search_min_availability < 0 OR l_req_rec.search_min_availability > 100)
1640 THEN
1641 PA_UTILS.ADD_MESSAGE('PA', 'PA_MIN_AVAIL_INVALID');
1642 l_error_flag_local := 'Y';
1643 END IF;
1644
1645 IF l_req_rec.search_min_candidate_score IS NOT NULL AND (l_req_rec.search_min_candidate_score < 0 OR l_req_rec.search_min_candidate_score > 100 )
1646 THEN
1647 PA_UTILS.ADD_MESSAGE('PA', 'PA_MIN_CAN_SCORE_INVALID');
1648 l_error_flag_local := 'Y';
1649 END IF;
1650
1651 IF (l_req_rec.search_country_code IS NOT NULL AND l_req_rec.search_country_code <> FND_API.G_MISS_CHAR)
1652 OR (l_req_rec.search_country_name IS NOT NULL AND l_req_rec.search_country_name <> FND_API.G_MISS_CHAR)
1653 THEN
1654 l_return_status := FND_API.G_RET_STS_SUCCESS;
1655 l_error_message_code := null;
1656 l_search_country_code_tmp := l_req_rec.search_country_code;
1657
1658 IF l_debug_mode = 'Y' THEN
1659 pa_debug.write(l_module, 'Validating Search Country Code and Name to Code Conversion', l_log_level);
1660 END IF;
1661
1662 PA_LOCATION_UTILS.CHECK_COUNTRY_NAME_OR_CODE
1663 (p_country_code => l_search_country_code_tmp,
1664 p_country_name => l_req_rec.search_country_name,
1665 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1666 x_country_code => l_req_rec.search_country_code,
1667 x_return_status => l_return_status,
1668 x_error_message_code => l_error_message_code);
1669
1670 IF l_debug_mode = 'Y' THEN
1671 pa_debug.write(l_module, 'After Search Country Code Validation l_req_rec.search_country_code='||l_req_rec.search_country_code, l_log_level);
1672 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1673 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1674 END IF;
1675
1676 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1677 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1678 l_error_flag_local := 'Y';
1679 END IF;
1680 END IF; -- l_req_rec.search_country_code IS NOT NULL
1681
1682 IF l_req_rec.search_exp_org_hier_name IS NOT NULL OR l_req_rec.search_exp_org_str_ver_id IS NOT NULL THEN
1683 l_return_status := FND_API.G_RET_STS_SUCCESS;
1684 l_error_message_code := null;
1685 l_srch_exp_org_str_ver_id_tmp := l_req_rec.search_exp_org_str_ver_id;
1686
1687 IF l_debug_mode = 'Y' THEN
1688 pa_debug.write(l_module, 'Validating Search Organization Hierarchy and Name to ID Conversion', l_log_level);
1689 END IF;
1690
1691 PA_HR_ORG_UTILS.CHECK_ORGHIERNAME_OR_ID
1692 (p_org_hierarchy_version_id => l_srch_exp_org_str_ver_id_tmp,
1693 p_org_hierarchy_name => l_req_rec.search_exp_org_hier_name,
1694 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1695 x_org_hierarchy_version_id => l_req_rec.search_exp_org_str_ver_id,
1696 x_return_status => l_return_status,
1697 x_error_msg_code => l_error_message_code);
1698
1699 IF l_debug_mode = 'Y' THEN
1700 pa_debug.write(l_module, 'After Search Organization Hierarchy Validation l_req_rec.search_exp_org_str_ver_id='||l_req_rec.search_exp_org_str_ver_id, l_log_level);
1701 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1702 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1703 END IF;
1704
1705
1706 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1707 -- PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1708 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_SRCH_ORG_HIER_NA'); -- Changed for Bug 5148154
1709 l_error_flag_local := 'Y';
1710 ELSE
1711 l_return_status := FND_API.G_RET_STS_SUCCESS;
1712 l_error_message_code := null;
1713
1714 IF l_debug_mode = 'Y' THEN
1715 pa_debug.write(l_module, 'Validating Search Organization Hierarchy Type', l_log_level);
1716 END IF;
1717
1718 PA_ORG_UTILS.CHECK_ORGHIERARCHY_TYPE(
1719 p_org_structure_version_id => l_req_rec.search_exp_org_str_ver_id,
1720 p_org_structure_type => 'EXPENDITURES',
1721 x_return_status => l_return_status,
1722 x_error_message_code => l_error_message_code);
1723
1724 IF l_debug_mode = 'Y' THEN
1725 pa_debug.write(l_module, 'After Search Organization Hierarchy Type Validation', l_log_level);
1726 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1727 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1728 END IF;
1729
1730 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1731 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1732 l_error_flag_local := 'Y';
1733 END IF;
1734 END IF;
1735 END IF; -- l_req_rec.search_exp_org_hier_name IS NOT NULL
1736
1737 IF l_req_rec.search_exp_start_org_name IS NOT NULL OR l_req_rec.search_exp_start_org_id IS NOT NULL THEN
1738 l_return_status := FND_API.G_RET_STS_SUCCESS;
1739 l_error_message_code := null;
1740 l_search_exp_start_org_id_tmp := l_req_rec.search_exp_start_org_id;
1741
1742 IF l_debug_mode = 'Y' THEN
1743 pa_debug.write(l_module, 'Validating Search Organization and Name to ID Conversion', l_log_level);
1744 END IF;
1745
1746 PA_HR_ORG_UTILS.CHECK_ORGNAME_OR_ID
1747 (p_organization_id => l_search_exp_start_org_id_tmp,
1748 p_organization_name => l_req_rec.search_exp_start_org_name,
1749 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1750 x_organization_id => l_req_rec.search_exp_start_org_id,
1751 x_return_status => l_return_status,
1752 x_error_msg_code => l_error_message_code);
1753
1754 IF l_debug_mode = 'Y' THEN
1755 pa_debug.write(l_module, 'After Search Organization Name Validation', l_log_level);
1756 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1757 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1758 END IF;
1759
1760 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1761 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1762 l_error_flag_local := 'Y';
1763 ELSE
1764 l_return_status := FND_API.G_RET_STS_SUCCESS;
1765 l_error_message_code := null;
1766
1767 IF l_debug_mode = 'Y' THEN
1768 pa_debug.write(l_module, 'Validating Search Organization Type', l_log_level);
1769 END IF;
1770
1771 PA_ORG_UTILS.CHECK_ORG_TYPE(
1772 p_organization_id => l_req_rec.search_exp_start_org_id,
1773 p_org_structure_type => 'EXPENDITURES',
1774 x_return_status => l_return_status,
1775 x_error_message_code => l_error_message_code);
1776
1777 IF l_debug_mode = 'Y' THEN
1778 pa_debug.write(l_module, 'After Search Organization Type Validation', l_log_level);
1779 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1780 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1781 END IF;
1782
1783 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1784 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1785 l_error_flag_local := 'Y';
1786 END IF;
1787 END IF;
1788 END IF; -- l_req_rec.search_exp_start_org_name IS NOT NULL
1789
1790 IF l_req_rec.search_exp_org_str_ver_id IS NOT NULL AND l_req_rec.search_exp_start_org_id IS NOT NULL THEN
1791 l_return_status := FND_API.G_RET_STS_SUCCESS;
1792 l_error_message_code := null;
1793
1794 IF l_debug_mode = 'Y' THEN
1795 pa_debug.write(l_module, 'Validating Search Organization wrt Search Org Hierarchy', l_log_level);
1796 END IF;
1797
1798 PA_ORG_UTILS.CHECK_ORG_IN_ORGHIERARCHY(
1799 p_organization_id => l_req_rec.search_exp_start_org_id,
1800 p_org_structure_version_id => l_req_rec.search_exp_org_str_ver_id,
1801 p_org_structure_type => 'EXPENDITURES',
1802 x_return_status => l_return_status,
1803 x_error_message_code => l_error_message_code);
1804
1805 IF l_debug_mode = 'Y' THEN
1806 pa_debug.write(l_module, 'After Search wrt Search Org Hierarchy Validation', l_log_level);
1807 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1808 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1809 END IF;
1810
1811 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1812 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1813 l_error_flag_local := 'Y';
1814 END IF;
1815 END IF;
1816
1817 -- Financial Information Validation
1818 -----------------------------------
1819
1820 IF l_req_rec.expenditure_org_id IS NOT NULL OR l_req_rec.expenditure_org_name IS NOT NULL THEN
1821 l_return_status := FND_API.G_RET_STS_SUCCESS;
1822 l_error_message_code := null;
1823 l_expenditure_org_id_tmp := l_req_rec.expenditure_org_id;
1824
1825 IF l_debug_mode = 'Y' THEN
1826 pa_debug.write(l_module, 'Validating Expenditure OU and Name to ID conversion', l_log_level);
1827 END IF;
1828
1829 PA_HR_ORG_UTILS.CHECK_ORGNAME_OR_ID
1830 (p_organization_id => l_expenditure_org_id_tmp,
1831 p_organization_name => l_req_rec.expenditure_org_name,
1832 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1833 x_organization_id => l_req_rec.expenditure_org_id,
1834 x_return_status => l_return_status,
1835 x_error_msg_code => l_error_message_code );
1836
1837 IF l_debug_mode = 'Y' THEN
1838 pa_debug.write(l_module, 'After Expenditure OU Validation l_req_rec.expenditure_org_id='||l_req_rec.expenditure_org_id, l_log_level);
1839 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1840 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1841 END IF;
1842
1843 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1844 PA_UTILS.ADD_MESSAGE('PA', 'PA_EXP_OU_INVALID');
1845 l_error_flag_local := 'Y';
1846 ELSE
1847 l_return_status := FND_API.G_RET_STS_SUCCESS;
1848 l_error_message_code := null;
1849
1850 IF l_debug_mode = 'Y' THEN
1851 pa_debug.write(l_module, 'Validating OU to be used in PA Implementation', l_log_level);
1852 END IF;
1853
1854 PA_HR_UPDATE_API.CHECK_EXP_OU
1855 (p_org_id => l_req_rec.expenditure_org_id
1856 ,x_return_status => l_return_status
1857 ,x_error_message_code => l_error_message_code ) ;
1858
1859 IF l_debug_mode = 'Y' THEN
1860 pa_debug.write(l_module, 'After Expenditure OU to be used in PA Implementation Validation', l_log_level);
1861 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1862 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1863 END IF;
1864
1865 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1866 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1867 l_error_flag_local := 'Y';
1868 -- Start 1: Changed for Bug 5202329
1869 ELSE
1870 SELECT business_group_id
1871 INTO l_business_group_id
1872 FROM hr_organization_units
1873 WHERE organization_id = l_req_rec.expenditure_org_id;
1874 END IF;
1875 -- End 1: Changed for Bug 5202329
1876 END IF;
1877 END IF; -- l_req_rec.expenditure_org_id IS NOT NULL
1878
1879 -- l_error_flag_local <> 'Y' for Bug 5202329
1880 IF l_error_flag_local <> 'Y' AND (l_req_rec.expenditure_organization_id IS NOT NULL
1881 OR l_req_rec.expenditure_organization_name IS NOT NULL) THEN
1882 l_return_status := FND_API.G_RET_STS_SUCCESS;
1883 l_error_message_code := null;
1884 l_exp_organization_id_tmp := l_req_rec.expenditure_organization_id;
1885
1886 IF l_debug_mode = 'Y' THEN
1887 pa_debug.write(l_module, 'Validating Expenditure Organization and Name to ID conversion', l_log_level);
1888 END IF;
1889
1890 PA_HR_ORG_UTILS.CHECK_ORGNAME_OR_ID
1891 (p_organization_id => l_exp_organization_id_tmp,
1892 p_organization_name => l_req_rec.expenditure_organization_name,
1893 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1894 x_organization_id => l_req_rec.expenditure_organization_id,
1895 x_return_status => l_return_status,
1896 x_error_msg_code => l_error_message_code );
1897
1898 IF l_debug_mode = 'Y' THEN
1899 pa_debug.write(l_module, 'After Expenditure Organization Validation', l_log_level);
1900 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1901 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1902 END IF;
1903
1904 -- Start 2: Changes for Bug 5202329
1905 IF l_error_message_code = 'PA_ORG_NOT_UNIQUE' AND l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1906 OPEN c_get_exp_organization_id(l_business_group_id, l_req_rec.expenditure_organization_name);
1907 FETCH c_get_exp_organization_id INTO l_req_rec.expenditure_organization_id;
1908 IF c_get_exp_organization_id%NOTFOUND IS NULL THEN
1909 PA_UTILS.ADD_MESSAGE('PA', 'PA_EXP_ORG_INVALID');
1910 l_error_flag_local := 'Y';
1911 END IF;
1912 CLOSE c_get_exp_organization_id;
1913 END IF;
1914 IF l_error_message_code <> 'PA_ORG_NOT_UNIQUE' AND l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1915 -- IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1916 -- End 2: Changes for Bug 5202329
1917 PA_UTILS.ADD_MESSAGE('PA', 'PA_EXP_ORG_INVALID');
1918 l_error_flag_local := 'Y';
1919 ELSE
1920 l_valid_flag := null;
1921
1922 IF l_debug_mode = 'Y' THEN
1923 pa_debug.write(l_module, 'Validating Expenditure Organization to be used in PA', l_log_level);
1924 END IF;
1925
1926 l_valid_flag := PA_UTILS2.CHECKEXPORG
1927 (x_org_id => l_req_rec.expenditure_organization_id,
1928 x_txn_date => l_req_rec.start_date);
1929
1930 IF l_debug_mode = 'Y' THEN
1931 pa_debug.write(l_module, 'After Expenditure Organization to be used in PA Implementation Validation', l_log_level);
1932 pa_debug.write(l_module, 'l_valid_flag='||l_valid_flag, l_log_level);
1933 END IF;
1934
1935 IF l_valid_flag <> 'Y' THEN
1936 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_EXP_ORG');
1937 l_error_flag_local := 'Y';
1938 END IF;
1939 END IF;
1940 END IF; -- l_req_rec.expenditure_organization_id IS NOT NULL
1941
1942 -- Forecast Info Validations
1943 -----------------------------
1944
1945 IF (l_req_rec.fcst_job_group_name IS NOT NULL AND l_req_rec.fcst_job_group_name <> FND_API.G_MISS_CHAR)
1946 OR (l_req_rec.fcst_job_group_id IS NOT NULL AND l_req_rec.fcst_job_group_id <> FND_API.G_MISS_NUM)
1947 THEN
1948 l_return_status := FND_API.G_RET_STS_SUCCESS;
1949 l_error_message_code := null;
1950 l_fcst_job_group_id_tmp := l_req_rec.fcst_job_group_id;
1951
1952 IF l_debug_mode = 'Y' THEN
1953 pa_debug.write(l_module, 'Validating Job Group and Name to ID conversion', l_log_level);
1954 END IF;
1955
1956 PA_JOB_UTILS.CHECK_JOB_GROUPNAME_OR_ID(
1957 p_job_group_id => l_fcst_job_group_id_tmp
1958 ,p_job_group_name => l_req_rec.fcst_job_group_name
1959 ,p_check_id_flag => PA_STARTUP.G_Check_ID_Flag
1960 ,x_job_group_id => l_req_rec.fcst_job_group_id
1961 ,x_return_status => l_return_status
1962 ,x_error_message_code => l_error_message_code );
1963
1964 IF l_debug_mode = 'Y' THEN
1965 pa_debug.write(l_module, 'After Job Group Validation l_req_rec.fcst_job_group_id='||l_req_rec.fcst_job_group_id, l_log_level);
1966 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1967 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
1968 END IF;
1969
1970 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1971 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
1972 l_error_flag_local := 'Y';
1973 END IF;
1974 END IF;
1975
1976 IF (l_req_rec.fcst_job_name IS NOT NULL AND l_req_rec.fcst_job_name <> FND_API.G_MISS_CHAR)
1977 OR (l_req_rec.fcst_job_id IS NOT NULL AND l_req_rec.fcst_job_id <> FND_API.G_MISS_NUM)
1978 THEN
1979 l_return_status := FND_API.G_RET_STS_SUCCESS;
1980 l_error_message_code := null;
1981 l_fcst_job_id_tmp := l_req_rec.fcst_job_id;
1982
1983 IF l_debug_mode = 'Y' THEN
1984 pa_debug.write(l_module, 'Validating Job and Name to ID conversion', l_log_level);
1985 END IF;
1986
1987 PA_JOB_UTILS.CHECK_JOBNAME_OR_ID (
1988 p_job_id => l_fcst_job_id_tmp
1989 ,p_job_name => l_req_rec.fcst_job_name
1990 ,p_job_group_id => l_req_rec.fcst_job_group_id -- 5144999
1991 ,p_check_id_flag => PA_STARTUP.G_Check_ID_Flag
1992 ,x_job_id => l_req_rec.fcst_job_id
1993 ,x_return_status => l_return_status
1994 ,x_error_message_code => l_error_message_code);
1995
1996 IF l_debug_mode = 'Y' THEN
1997 pa_debug.write(l_module, 'After Job Validation l_req_rec.fcst_job_id='||l_req_rec.fcst_job_id, l_log_level);
1998 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
1999 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
2000 END IF;
2001
2002 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2003 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
2004 l_error_flag_local := 'Y';
2005 END IF;
2006 END IF;
2007
2008 IF l_req_rec.fcst_job_id IS NOT NULL AND l_req_rec.fcst_job_id <> FND_API.G_MISS_NUM
2009 AND l_req_rec.fcst_job_group_id IS NOT NULL AND l_req_rec.fcst_job_group_id <> FND_API.G_MISS_NUM
2010 THEN
2011 l_return_status := FND_API.G_RET_STS_SUCCESS;
2012 l_error_message_code := null;
2013
2014 IF l_debug_mode = 'Y' THEN
2015 pa_debug.write(l_module, 'Validating Job wrt Job Group', l_log_level);
2016 END IF;
2017
2018 PA_JOB_UTILS.VALIDATE_JOB_RELATIONSHIP (
2019 p_job_id => l_req_rec.fcst_job_id
2020 ,p_job_group_id => l_req_rec.fcst_job_group_id
2021 ,x_return_status => l_return_status
2022 ,x_error_message_code => l_error_message_code);
2023
2024 IF l_debug_mode = 'Y' THEN
2025 pa_debug.write(l_module, 'After Job wrt Job Group Validation', l_log_level);
2026 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
2027 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
2028 END IF;
2029
2030 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2031 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
2032 l_error_flag_local := 'Y';
2033 END IF;
2034 END IF;
2035
2036
2037 -- Bill Rate Options Validation
2038 -------------------------------
2039
2040 IF l_req_rec.bill_rate_option <> 'NONE' THEN
2041 l_rate_discount_reason_flag := 'N';
2042 l_br_override_flag := 'N';
2043 l_br_discount_override_flag := 'N';
2044
2045 OPEN get_bill_rate_override_flags(l_req_rec.project_id);
2046 FETCH get_bill_rate_override_flags INTO l_rate_discount_reason_flag, l_br_override_flag, l_br_discount_override_flag;
2047 CLOSE get_bill_rate_override_flags;
2048
2049 IF l_debug_mode = 'Y' THEN
2050 pa_debug.write(l_module, 'Validating Bill Rate Options', l_log_level);
2051 pa_debug.write(l_module, 'l_rate_discount_reason_flag='||l_rate_discount_reason_flag, l_log_level);
2052 pa_debug.write(l_module, 'l_br_override_flag='||l_br_override_flag, l_log_level);
2053 pa_debug.write(l_module, 'l_br_discount_override_flag='||l_br_discount_override_flag, l_log_level);
2054 END IF;
2055
2056 IF l_req_rec.bill_rate_option = 'RATE' THEN
2057 IF l_br_override_flag <> 'Y' OR l_req_rec.bill_rate_override <= 0 THEN /* OR l_req_rec.bill_rate_override > 100 - Removed for Bug 5703021*/
2058 IF l_br_override_flag <> 'Y' THEN
2059 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_BILL_RATE_OVRD_NA');
2060 l_error_flag_local := 'Y';
2061 ELSE
2062 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_BILL_RATE_OVRD');
2063 l_error_flag_local := 'Y';
2064 END IF;
2065 END IF;
2066
2067 -- 5144288, 5144369 : Added bill rate currency check below
2068 -- Begin
2069 IF nvl(l_multi_currency_billing_flag,'N') = 'Y' AND l_br_override_flag = 'Y' THEN
2070
2071 l_return_status := FND_API.G_RET_STS_SUCCESS;
2072 l_error_message_code := null;
2073 l_bill_currency_override_tmp := l_req_rec.bill_rate_curr_override;
2074
2075 IF l_debug_mode = 'Y' THEN
2076 pa_debug.write(l_module, 'Validating Bill Rate Currency', l_log_level);
2077 END IF;
2078
2079 PA_PROJECTS_MAINT_UTILS.CHECK_CURRENCY_NAME_OR_CODE(
2080 p_agreement_currency => l_bill_currency_override_tmp
2081 ,p_agreement_currency_name => null
2082 ,p_check_id_flag => 'Y'
2083 ,x_agreement_currency => l_req_rec.bill_rate_curr_override
2084 ,x_return_status => l_return_status
2085 ,x_error_msg_code => l_error_message_code);
2086
2087 IF l_debug_mode = 'Y' THEN
2088 pa_debug.write(l_module, 'After Bill Rate Currency Validation', l_log_level);
2089 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
2090 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
2091 END IF;
2092
2093 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2094 PA_UTILS.ADD_MESSAGE('PA', 'PA_CISI_CURRENCY_NULL');
2095 l_error_flag_local := 'Y';
2096 END IF;
2097 END IF;
2098 -- 5144288, 5144369 : End
2099 ELSIF l_req_rec.bill_rate_option = 'MARKUP' THEN
2100 -- 5144675 Changed l_req_rec.markup_percent_override <= 0 to < 0
2101 IF l_br_override_flag <> 'Y' OR l_req_rec.markup_percent_override < 0
2102 OR l_req_rec.markup_percent_override > 100 THEN
2103 IF l_br_override_flag <> 'Y' THEN
2104 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_BILL_RATE_OVRD_NA');
2105 l_error_flag_local := 'Y';
2106 ELSE
2107 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_MARKUP_PERCENT');
2108 l_error_flag_local := 'Y';
2109 END IF;
2110 END IF;
2111 ELSIF l_req_rec.bill_rate_option = 'DISCOUNT' THEN
2112 -- 5144675 Changed l_req_rec.discount_percentage <=0 to < 0
2113 IF l_br_discount_override_flag <> 'Y' OR l_req_rec.discount_percentage < 0
2114 OR l_req_rec.discount_percentage > 100 THEN
2115 IF l_br_override_flag <> 'Y' THEN
2116 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_DISC_OVRD_NA');
2117 l_error_flag_local := 'Y';
2118 ELSE
2119 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_DISCOUNT_PERCENT');
2120 l_error_flag_local := 'Y';
2121 END IF;
2122 END IF;
2123 END IF;
2124 IF l_req_rec.rate_disc_reason_code IS NULL THEN
2125 IF (l_rate_discount_reason_flag ='Y' AND (l_br_override_flag ='Y' OR l_br_discount_override_flag='Y') AND
2126 (l_req_rec.bill_rate_override IS NOT NULL OR l_req_rec.markup_percent_override IS NOT NULL OR l_req_rec.discount_percentage IS NOT NULL)
2127 )
2128 THEN
2129 PA_UTILS.ADD_MESSAGE('PA', 'PA_RATE_DISC_REASON_REQUIRED');
2130 l_error_flag_local := 'Y';
2131 END IF;
2132 ELSE
2133 l_valid_flag := 'N';
2134 OPEN c_get_lookup_exists('RATE AND DISCOUNT REASON', l_req_rec.rate_disc_reason_code);
2135 FETCH c_get_lookup_exists INTO l_valid_flag;
2136 CLOSE c_get_lookup_exists;
2137 IF nvl(l_valid_flag,'N') <> 'Y' THEN
2138 -- This is a new message, define it
2139 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_DISC_RSN_INVALID');
2140 l_error_flag_local := 'Y';
2141 END IF;
2142 END IF;
2143
2144 IF l_debug_mode = 'Y' THEN
2145 pa_debug.write(l_module, 'After Validating Bill Rate Options l_error_flag_local='||l_error_flag_local, l_log_level);
2146 END IF;
2147 END IF; -- l_req_rec.bill_rate_option <> 'NONE'
2148
2149 -- Transfer Price Rate Options Validation
2150 -----------------------------------------
2151
2152 IF l_req_rec.tp_rate_option <> 'NONE' THEN
2153
2154 IF l_debug_mode = 'Y' THEN
2155 pa_debug.write(l_module, 'Validating Transfer Price Rate Options', l_log_level);
2156 END IF;
2157
2158 IF l_req_rec.tp_rate_option = 'RATE' THEN
2159 -- 5144675 Changed l_req_rec.tp_rate_override <= 0 to < 0
2160 IF l_req_rec.tp_rate_override < 0 OR l_req_rec.tp_rate_override > 100 THEN
2161 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_TP_RATE_OVRD');
2162 l_error_flag_local := 'Y';
2163 END IF;
2164
2165 l_return_status := FND_API.G_RET_STS_SUCCESS;
2166 l_error_message_code := null;
2167 l_tp_currency_override_tmp := l_req_rec.tp_currency_override;
2168
2169 IF l_debug_mode = 'Y' THEN
2170 pa_debug.write(l_module, 'Validating Transfer Price Rate Currency', l_log_level);
2171 END IF;
2172
2173 PA_PROJECTS_MAINT_UTILS.CHECK_CURRENCY_NAME_OR_CODE(
2174 p_agreement_currency => l_tp_currency_override_tmp
2175 ,p_agreement_currency_name => null
2176 ,p_check_id_flag => 'Y'
2177 ,x_agreement_currency => l_req_rec.tp_currency_override
2178 ,x_return_status => l_return_status
2179 ,x_error_msg_code => l_error_message_code);
2180
2181 IF l_debug_mode = 'Y' THEN
2182 pa_debug.write(l_module, 'After Transfer Price Rate Currency Validation', l_log_level);
2183 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
2184 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
2185 END IF;
2186
2187 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2188 PA_UTILS.ADD_MESSAGE('PA', 'PA_CURR_NOT_VALID');
2189 l_error_flag_local := 'Y';
2190 END IF;
2191 ELSIF l_req_rec.tp_rate_option = 'BASIS' THEN
2192 -- 5144675 Changed l_req_rec.tp_percent_applied_override <=0 to < 0
2193 IF l_req_rec.tp_percent_applied_override < 0 OR l_req_rec.tp_percent_applied_override > 100 THEN
2194 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_APPLY_BASIS_PERCENT');
2195 l_error_flag_local := 'Y';
2196 END IF;
2197 l_valid_flag := 'N';
2198 IF l_debug_mode = 'Y' THEN
2199 pa_debug.write(l_module, 'Validating Transfer Price Rate Basis', l_log_level);
2200 END IF;
2201
2202 OPEN c_get_lookup_exists('CC_MARKUP_BASE_CODE', l_req_rec.tp_calc_base_code_override);
2203 FETCH c_get_lookup_exists INTO l_valid_flag;
2204 CLOSE c_get_lookup_exists;
2205
2206 IF l_debug_mode = 'Y' THEN
2207 pa_debug.write(l_module, 'After Transfer Price Rate Basis Validation', l_log_level);
2208 pa_debug.write(l_module, 'l_valid_flag='||l_valid_flag, l_log_level);
2209 END IF;
2210
2211 IF nvl(l_valid_flag,'N') <> 'Y' THEN
2212 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_TP_BASIS_INVALID');
2213 l_error_flag_local := 'Y';
2214 END IF;
2215 END IF;
2216
2217 IF l_debug_mode = 'Y' THEN
2218 pa_debug.write(l_module, 'After Validating Transfer Price Rate Options l_error_flag_local='||l_error_flag_local, l_log_level);
2219 END IF;
2220 END IF; -- l_req_rec.tp_rate_option <> 'NONE'
2221
2222 -- Res Loan Agreement Validations
2223 ---------------------------------
2224
2225 IF l_req_rec.expense_owner IS NOT NULL THEN
2226 l_valid_flag := 'N';
2227
2228 IF l_debug_mode = 'Y' THEN
2229 pa_debug.write(l_module, 'Validating Expense Owner Option', l_log_level);
2230 END IF;
2231
2232 OPEN c_get_lookup_exists('EXPENSE_OWNER_TYPE', l_req_rec.expense_owner);
2233 FETCH c_get_lookup_exists INTO l_valid_flag;
2234 CLOSE c_get_lookup_exists;
2235
2236 IF l_debug_mode = 'Y' THEN
2237 pa_debug.write(l_module, 'After Expense Owner Option Validation', l_log_level);
2238 pa_debug.write(l_module, 'l_valid_flag='||l_valid_flag, l_log_level);
2239 END IF;
2240
2241 IF nvl(l_valid_flag,'N') <> 'Y' THEN
2242 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_EXP_OWNER_INVALID');
2243 l_error_flag_local := 'Y';
2244 END IF;
2245 END IF;
2246 END IF; -- l_error_flag_local <> 'Y' AND l_req_rec.project_id IS NOT NULL
2247
2248 IF l_debug_mode = 'Y' THEN
2249 pa_debug.write(l_module, 'After all validations l_error_flag_local='||l_error_flag_local, l_log_level);
2250 END IF;
2251
2252 -- Flex field Validation
2253 ------------------------
2254
2255 IF l_error_flag_local <> 'Y' THEN
2256 l_return_status := FND_API.G_RET_STS_SUCCESS;
2257
2258 VALIDATE_FLEX_FIELD(
2259 p_desc_flex_name => 'PA_TEAM_ROLE_DESC_FLEX'
2260 , p_attribute_category => l_req_rec.attribute_category
2261 , px_attribute1 => l_req_rec.attribute1
2262 , px_attribute2 => l_req_rec.attribute2
2263 , px_attribute3 => l_req_rec.attribute3
2264 , px_attribute4 => l_req_rec.attribute4
2265 , px_attribute5 => l_req_rec.attribute5
2266 , px_attribute6 => l_req_rec.attribute6
2267 , px_attribute7 => l_req_rec.attribute7
2268 , px_attribute8 => l_req_rec.attribute8
2269 , px_attribute9 => l_req_rec.attribute9
2270 , px_attribute10 => l_req_rec.attribute10
2271 , px_attribute11 => l_req_rec.attribute11
2272 , px_attribute12 => l_req_rec.attribute12
2273 , px_attribute13 => l_req_rec.attribute13
2274 , px_attribute14 => l_req_rec.attribute14
2275 , px_attribute15 => l_req_rec.attribute15
2276 , x_return_status => l_return_status
2277 , x_msg_count => l_msg_count
2278 , x_msg_data => l_msg_data
2279 );
2280
2281 IF l_debug_mode = 'Y' THEN
2282 pa_debug.write(l_module, 'After Flex Field Validation l_return_status='||l_return_status, l_log_level);
2283 pa_debug.write(l_module, 'After Flex Field Validation l_msg_data='||l_msg_data, l_log_level);
2284 END IF;
2285
2286
2287 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2288 -- This message does not have toekn defined, still it is ok to pass token as the value
2289 -- returned by flex APIs because token are appended as it is
2290 PA_UTILS.ADD_MESSAGE('PA', 'PA_DFF_VALIDATION_FAILED',
2291 'ERROR_MESSAGE', l_msg_data );
2292 l_error_flag_local := 'Y';
2293 END IF;
2294 END IF; -- l_error_flag_local <> 'Y'
2295
2296 -- Security Check
2297 -----------------
2298
2299 IF l_error_flag_local <> 'Y' THEN
2300
2301 IF l_debug_mode = 'Y' THEN
2302 pa_debug.write(l_module, 'Checking Security for Record#'||i, l_log_level);
2303 END IF;
2304
2305 IF l_req_rec.team_template_id IS NOT NULL THEN
2306 l_privilege := 'PA_PRM_DEFINE_TEAM_TEMPLATE';
2307 l_object_name := null;
2308 l_object_key := null;
2309 ELSIF l_req_rec.project_id IS NOT NULL THEN
2310 l_privilege := 'PA_ASN_CR_AND_DL';
2311 l_object_name := 'PA_PROJECTS';
2312 l_object_key := null;
2313 ELSE
2314 PA_UTILS.ADD_MESSAGE('PA', 'PA_UNEXPECTED ERROR');
2315 raise FND_API.G_EXC_ERROR;
2316 END IF;
2317
2318 IF l_debug_mode = 'Y' THEN
2319 pa_debug.write(l_module, 'l_privilege='||l_privilege, l_log_level);
2320 pa_debug.write(l_module, 'l_object_name='||l_object_name, l_log_level);
2321 pa_debug.write(l_module, 'l_object_key='||l_object_key, l_log_level);
2322 END IF;
2323
2324 l_return_status := FND_API.G_RET_STS_SUCCESS;
2325 l_ret_code := 'T';
2326
2327 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
2328 x_ret_code => l_ret_code
2329 , x_return_status => l_return_status
2330 , x_msg_count => l_msg_count
2331 , x_msg_data => l_msg_data
2332 , p_init_msg_list => 'F'
2333 , p_privilege => l_privilege
2334 , p_object_name => l_object_name
2335 , p_object_key => l_object_key);
2336
2337 IF l_debug_mode = 'Y' THEN
2338 pa_debug.write(l_module, 'After Security Check l_ret_code='||l_ret_code, l_log_level);
2339 END IF;
2340
2341
2342 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2343 -- This message does not have token defined, but intentionally putting token
2344 -- bcoz we still want to show the privielge name which is missing
2345 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_CR_DL'
2346 ,'MISSING_PRIVILEGE', l_privilege);
2347 l_error_flag_local := 'Y';
2348 END IF;
2349 END IF;
2350
2351 -- Call Core Actual API
2352 -----------------------
2353
2354 IF l_error_flag_local <> 'Y' THEN
2355 l_return_status := FND_API.G_RET_STS_SUCCESS;
2356
2357 IF l_debug_mode = 'Y' THEN
2358 pa_debug.write(l_module, 'Calling pa_assignments_pub.execute_create_assignment for Record#'||i, l_log_level);
2359 END IF;
2360
2361 l_new_assignment_id_tbl := null;
2362 l_new_assignment_id := null;
2363 l_assignment_number := null;
2364 l_assignment_row_id := null;
2365 l_resource_id := null;
2366
2367 PA_ASSIGNMENTS_PUB.EXECUTE_CREATE_ASSIGNMENT
2368 (
2369 p_api_version => p_api_version_number
2370 , p_init_msg_list => l_init_msg_list
2371 , p_commit => l_commit
2372 , p_validate_only => l_validate_only
2373 , p_asgn_creation_mode => l_asgn_creation_mode
2374 , p_assignment_name => l_req_rec.requirement_name
2375 , p_assignment_type => l_assignment_type
2376 , p_assignment_template_id => l_req_rec.team_template_id
2377 -- , p_source_assignment_id => l_req_rec.source_requirement_id
2378 , p_number_of_requirements => l_req_rec.number_of_requirements
2379 , p_project_role_id => l_req_rec.project_role_id
2380 , p_project_role_name => l_req_rec.project_role_name
2381 , p_project_id => l_req_rec.project_id
2382 , p_project_name => l_req_rec.project_name
2383 , p_project_number => l_req_rec.project_number
2384 -- , p_resource_id =>
2385 -- , p_project_party_id =>
2386 -- , p_resource_name =>
2387 -- , p_resource_source_id => null
2388 , p_staffing_owner_person_id => l_req_rec.staffing_owner_person_id
2389 -- , p_staffing_owner_name =>
2390 , p_staffing_priority_code => l_req_rec.staffing_priority_code
2391 , p_staffing_priority_name => l_req_rec.staffing_priority_name
2392 , p_project_subteam_id => l_req_rec.project_subteam_id
2393 , p_project_subteam_name => l_req_rec.project_subteam_name
2394 , p_location_id => l_req_rec.location_id
2395 , p_location_city => l_req_rec.location_city
2396 , p_location_region => l_req_rec.location_region
2397 , p_location_country_name => l_req_rec.location_country_name
2398 , p_location_country_code => l_req_rec.location_country_code
2399 , p_min_resource_job_level => l_req_rec.min_resource_job_level
2400 , p_max_resource_job_level => l_req_rec.max_resource_job_level
2401 , p_description => l_req_rec.description
2402 , p_additional_information => l_req_rec.additional_information
2403 , p_start_date => l_req_rec.start_date
2404 , p_end_date => l_req_rec.end_date
2405 , p_status_code => l_req_rec.status_code
2406 , p_project_status_name => l_req_rec.status_name
2407 -- , p_multiple_status_flag => l_multiple_status_flag
2408 -- , p_assignment_effort =>
2409 -- , p_resource_list_member_id =>
2410 -- , p_budget_version_id =>
2411 -- , p_sum_tasks_flag =>
2412 , p_calendar_type => l_req_rec.calendar_type
2413 , p_calendar_id => l_req_rec.calendar_id
2414 , p_calendar_name => l_req_rec.calendar_name
2415 , p_start_adv_action_set_flag => l_req_rec.start_adv_action_set_flag
2416 , p_adv_action_set_id => l_req_rec.adv_action_set_id
2417 , p_adv_action_set_name => l_req_rec.adv_action_set_name
2418 -- As of now internal code does not support setting the candidate search options
2419 -- at create time. It can only be updated.
2420 , p_comp_match_weighting => l_req_rec.comp_match_weighting
2421 , p_avail_match_weighting => l_req_rec.avail_match_weighting
2422 , p_job_level_match_weighting => l_req_rec.job_level_match_weighting
2423 , p_enable_auto_cand_nom_flag => l_req_rec.enable_auto_cand_nom_flag
2424 , p_search_min_availability => l_req_rec.search_min_availability
2425 , p_search_exp_org_struct_ver_id => l_req_rec.search_exp_org_str_ver_id
2426 , p_search_exp_start_org_id => l_req_rec.search_exp_start_org_id
2427 , p_search_country_code => l_req_rec.search_country_code
2428 , p_search_min_candidate_score => l_req_rec.search_min_candidate_score
2429 , p_expenditure_org_id => l_req_rec.expenditure_org_id
2430 , p_expenditure_org_name => l_req_rec.expenditure_org_name
2431 , p_expenditure_organization_id => l_req_rec.expenditure_organization_id
2432 , p_exp_organization_name => l_req_rec.expenditure_organization_name
2433 , p_expenditure_type_class => l_req_rec.expenditure_type_class
2434 , p_expenditure_type => l_req_rec.expenditure_type
2435 , p_fcst_job_group_id => l_req_rec.fcst_job_group_id
2436 , p_fcst_job_group_name => l_req_rec.fcst_job_group_name
2437 , p_fcst_job_id => l_req_rec.fcst_job_id
2438 , p_fcst_job_name => l_req_rec.fcst_job_name
2439 -- , p_fcst_tp_amount_type => l_req_rec.fcst_tp_amount_type
2440 , p_work_type_id => l_req_rec.work_type_id
2441 , p_work_type_name => l_req_rec.work_type_name
2442 , p_bill_rate_override => l_req_rec.bill_rate_override
2443 , p_bill_rate_curr_override => l_req_rec.bill_rate_curr_override
2444 , p_markup_percent_override => l_req_rec.markup_percent_override
2445 , p_discount_percentage => l_req_rec.discount_percentage
2446 , p_rate_disc_reason_code => l_req_rec.rate_disc_reason_code
2447 , p_tp_rate_override => l_req_rec.tp_rate_override
2448 , p_tp_currency_override => l_req_rec.tp_currency_override
2449 , p_tp_calc_base_code_override => l_req_rec.tp_calc_base_code_override
2450 , p_tp_percent_applied_override => l_req_rec.tp_percent_applied_override
2451 , p_extension_possible => l_req_rec.extension_possible
2452 , p_expense_owner => l_req_rec.expense_owner
2453 , p_expense_limit => l_req_rec.expense_limit
2454 -- , p_revenue_currency_code =>
2455 -- , p_revenue_bill_rate =>
2456 -- , p_markup_percent =>
2457 -- , p_resource_calendar_percent =>
2458 , p_attribute_category => l_req_rec.attribute_category
2459 , p_attribute1 => l_req_rec.attribute1
2460 , p_attribute2 => l_req_rec.attribute2
2461 , p_attribute3 => l_req_rec.attribute3
2462 , p_attribute4 => l_req_rec.attribute4
2463 , p_attribute5 => l_req_rec.attribute5
2464 , p_attribute6 => l_req_rec.attribute6
2465 , p_attribute7 => l_req_rec.attribute7
2466 , p_attribute8 => l_req_rec.attribute8
2467 , p_attribute9 => l_req_rec.attribute9
2468 , p_attribute10 => l_req_rec.attribute10
2469 , p_attribute11 => l_req_rec.attribute11
2470 , p_attribute12 => l_req_rec.attribute12
2471 , p_attribute13 => l_req_rec.attribute13
2472 , p_attribute14 => l_req_rec.attribute14
2473 , p_attribute15 => l_req_rec.attribute15
2474 , x_new_assignment_id_tbl => l_new_assignment_id_tbl
2475 , x_new_assignment_id => l_new_assignment_id
2476 , x_assignment_number => l_assignment_number
2477 , x_assignment_row_id => l_assignment_row_id
2478 , x_resource_id => l_resource_id
2479 , x_return_status => l_return_status
2480 , x_msg_count => l_msg_count
2481 , x_msg_data => l_msg_data
2482 );
2483
2484 IF l_debug_mode = 'Y' THEN
2485 pa_debug.write(l_module, 'After call pa_assignments_pub.execute_create_assignment l_return_status='||l_return_status, l_log_level);
2486 END IF;
2487
2488 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2489 l_error_flag_local := 'Y';
2490 -- Still we populating out tables so that if calling env tries
2491 -- to get all ids even after error has occured
2492 x_requirement_id_tbl.extend(1);
2493 x_requirement_id_tbl(x_requirement_id_tbl.count):= -1;
2494 ELSE
2495 IF l_debug_mode = 'Y' THEN
2496 pa_debug.write(l_module, 'Updating Original System Code and Reference', l_log_level);
2497 pa_debug.write(l_module, 'l_new_assignment_id_tbl.count'||l_new_assignment_id_tbl.count, l_log_level);
2498 END IF;
2499
2500 IF l_new_assignment_id_tbl.count > 0 THEN
2501 FOR j in l_new_assignment_id_tbl.FIRST..l_new_assignment_id_tbl.LAST LOOP
2502 IF l_new_assignment_id_tbl.exists(j) THEN
2503 x_requirement_id_tbl.extend(1);
2504 x_requirement_id_tbl(x_requirement_id_tbl.count):= l_new_assignment_id_tbl(j);
2505 IF (l_req_rec.orig_system_code IS NOT NULL OR l_req_rec.orig_system_reference IS NOT NULL) THEN
2506 UPDATE PA_PROJECT_ASSIGNMENTS
2507 SET orig_system_code = l_req_rec.orig_system_code
2508 , orig_system_reference = l_req_rec.orig_system_reference
2509 WHERE assignment_id = l_new_assignment_id_tbl(j);
2510 END IF;
2511 END IF;
2512 END LOOP;
2513 END IF;
2514 IF l_debug_mode = 'Y' THEN
2515 pa_debug.write(l_module, 'After Updating Original System Code and Reference', l_log_level);
2516 END IF;
2517 END IF;
2518 ELSE
2519 -- Still we populating out tables so that if calling env tries
2520 -- to get all ids even after error has occured
2521 x_requirement_id_tbl.extend(1);
2522 x_requirement_id_tbl(x_requirement_id_tbl.count):= -1;
2523 END IF;
2524
2525 l_end_msg_count := FND_MSG_PUB.count_msg;
2526 IF l_debug_mode = 'Y' THEN
2527 pa_debug.write(l_module, 'l_start_msg_count='||l_start_msg_count, l_log_level);
2528 pa_debug.write(l_module, 'l_end_msg_count='||l_end_msg_count, l_log_level);
2529 END IF;
2530 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
2531
2532 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
2533 l_error_flag := 'Y';
2534
2535 IF l_debug_mode = 'Y' THEN
2536 pa_debug.write(l_module, 'Repopulating Error Message Stack', l_log_level);
2537 END IF;
2538
2539 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
2540 -- Always get from first location in stack i.e. l_start_msg_count+1
2541 -- Because stack moves down after delete
2542 FND_MSG_PUB.get (
2543 p_msg_index => l_start_msg_count+1,
2544 p_encoded => FND_API.G_FALSE,
2545 p_data => l_data,
2546 p_msg_index_out => l_msg_index_out );
2547
2548 -- Always delete at first location in stack i.e. l_start_msg_count+1
2549 -- Because stack moves down after delete
2550 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
2551
2552 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
2553 'RECORD_NO', i,
2554 'MESSAGE', l_data);
2555 END LOOP;
2556 IF l_debug_mode = 'Y' THEN
2557 pa_debug.write(l_module, 'After Repopulating Error Message Stack', l_log_level);
2558 END IF;
2559 END IF;
2560 i := p_requirement_in_tbl.next(i);
2561 END LOOP;
2562
2563 IF l_debug_mode = 'Y' THEN
2564 pa_debug.write(l_module, 'All records are done', l_log_level);
2565 pa_debug.write(l_module, 'l_error_flag='||l_error_flag, l_log_level);
2566 pa_debug.write(l_module, 'FND_MSG_PUB.count_msg='||FND_MSG_PUB.count_msg, l_log_level);
2567 END IF;
2568
2569 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
2570 RAISE FND_API.G_EXC_ERROR;
2571 END IF;
2572
2573 IF l_debug_mode = 'Y' THEN
2574 PA_DEBUG.reset_curr_function;
2575 END IF;
2576
2577 IF p_commit = FND_API.G_TRUE THEN
2578 commit;
2579 END IF;
2580
2581
2582 EXCEPTION
2583 WHEN FND_API.G_EXC_ERROR THEN
2584 x_return_status := FND_API.G_RET_STS_ERROR;
2585 l_msg_count := FND_MSG_PUB.count_msg;
2586
2587 IF p_commit = FND_API.G_TRUE THEN
2588 ROLLBACK TO CREATE_REQUIREMENTS_SP;
2589 END IF;
2590
2591 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
2592 PA_INTERFACE_UTILS_PUB.get_messages
2593 ( p_encoded => FND_API.G_FALSE
2594 , p_msg_index => 1
2595 , p_msg_count => l_msg_count
2596 , p_msg_data => l_msg_data
2597 , p_data => l_data
2598 , p_msg_index_out => l_msg_index_out);
2599
2600 x_msg_data := l_data;
2601 x_msg_count := l_msg_count;
2602 ELSE
2603 x_msg_count := l_msg_count;
2604 END IF;
2605
2606 IF l_debug_mode = 'Y' THEN
2607 Pa_Debug.reset_curr_function;
2608 END IF;
2609
2610 WHEN OTHERS THEN
2611
2612 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2613 x_msg_data := SQLERRM;
2614
2615 IF p_commit = FND_API.G_TRUE THEN
2616 ROLLBACK TO CREATE_REQUIREMENTS_SP;
2617 END IF;
2618
2619 FND_MSG_PUB.add_exc_msg
2620 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
2621 , p_procedure_name => 'CREATE_REQUIREMENTS'
2622 , p_error_text => x_msg_data);
2623
2624 x_msg_count := FND_MSG_PUB.count_msg;
2625
2626 IF l_debug_mode = 'Y' THEN
2627 PA_DEBUG.reset_curr_function;
2628 END IF;
2629 RAISE;
2630 END CREATE_REQUIREMENTS;
2631
2632 -- Start of comments
2633 -- API name : UPDATE_REQUIREMENTS
2634 -- Type : Public
2635 -- Pre-reqs : None.
2636 -- Function : This is a public API to update one or more requirements for one or more projects
2637 -- Usage : This API will be called from AMG.
2638 -- Parameters :
2639 -- IN : p_commit IN VARCHAR2
2640 -- Identifier to commit the transaction.
2641 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
2642 -- p_init_msg_list IN VARCHAR2
2643 -- Identifier to initialize the error message stack.
2644 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
2645 -- p_api_version_number IN NUMBER Required
2646 -- To be compliant with Applications API coding standards.
2647 -- p_requirement_in_tbl IN REQUIREMENT_IN_TBL_TYPE Required
2648 -- Table of requirement records. Please see the REQUIREMENT_IN_TBL_TYPE datatype table.
2649 -- OUT :
2650 -- x_return_status OUT VARCHAR2
2651 -- Indicates the return status of the API.
2652 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
2653 -- x_msg_count OUT NUMBER
2654 -- Indicates the number of error messages in the message stack
2655 -- x_msg_data OUT VARCHAR2
2656 -- Indicates the error message text if only one error exists
2657 -- History :
2658 -- 01-Mar-2006 - amksingh - Created
2659 -- End of comments
2660 PROCEDURE UPDATE_REQUIREMENTS
2661 (
2662 p_api_version_number IN NUMBER := 1.0
2663 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
2664 , p_commit IN VARCHAR2 := FND_API.G_FALSE
2665 , p_requirement_in_tbl IN REQUIREMENT_IN_TBL_TYPE
2666 , x_return_status OUT NOCOPY VARCHAR2
2667 , x_msg_count OUT NOCOPY NUMBER
2668 , x_msg_data OUT NOCOPY VARCHAR2
2669 )
2670 IS
2671 l_calling_application VARCHAR2(10) := 'PLSQL';
2672 l_calling_module VARCHAR2(10) := 'AMG';
2673 l_check_id_flag VARCHAR2(1) := 'Y';
2674 l_check_role_security_flag VARCHAR2(1) := 'Y';
2675 l_check_resource_security_flag VARCHAR2(1) := 'Y';
2676 l_log_level NUMBER := 3;
2677 l_module VARCHAR2(100) := 'PA_RES_MANAGEMENT_AMG_PUB.UPDATE_REQUIREMENTS';
2678 l_commit VARCHAR2(1) := FND_API.G_FALSE;
2679 l_init_msg_list VARCHAR2(1) := FND_API.G_FALSE;
2680 l_validate_only VARCHAR2(1) := FND_API.G_FALSE;
2681 l_msg_count NUMBER;
2682 l_msg_data VARCHAR2(2000);
2683 l_msg_index_out NUMBER;
2684 l_data VARCHAR2(2000);
2685 l_debug_mode VARCHAR2(1);
2686
2687 i NUMBER;
2688 l_new_assignment_id_tbl SYSTEM.PA_NUM_TBL_TYPE := SYSTEM.PA_NUM_TBL_TYPE();
2689 l_new_assignment_id NUMBER;
2690 l_assignment_number NUMBER;
2691 l_assignment_row_id ROWID;
2692 l_resource_id NUMBER;
2693 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
2694 l_error_flag VARCHAR2(1) := 'N';
2695 l_error_flag_local VARCHAR2(1) := 'N';
2696 l_req_rec REQUIREMENT_IN_REC_TYPE;
2697 l_asgn_update_mode VARCHAR2(10) := 'FULL';
2698 l_assignment_type VARCHAR2(30) := 'OPEN_ASSIGNMENT';
2699 l_multiple_status_flag VARCHAR2(1) := 'N';
2700 l_loop_msg_count NUMBER :=0;
2701 l_start_msg_count NUMBER :=0;
2702 l_end_msg_count NUMBER :=0;
2703 l_missing_params VARCHAR2(1000);
2704 l_privilege VARCHAR2(30);
2705 l_object_name VARCHAR2(30);
2706 l_object_key NUMBER;
2707 l_error_message_code VARCHAR2(30);
2708 l_ret_code VARCHAR2(1);
2709
2710
2711 CURSOR get_bill_rate_override_flags(c_project_id NUMBER) IS
2712 SELECT impl.rate_discount_reason_flag ,impl.br_override_flag, impl.br_discount_override_flag
2713 FROM pa_implementations_all impl
2714 , pa_projects_all proj
2715 WHERE proj.org_id=impl.org_id -- Removed nvl condition from org_id : Post review changes for Bug 5130421
2716 AND proj.project_id = c_project_id ;
2717
2718 CURSOR c_get_lookup_exists(c_lookup_type VARCHAR2, c_lookup_code VARCHAR2) IS
2719 SELECT 'Y'
2720 FROM dual
2721 WHERE EXISTS
2722 (SELECT 'XYZ' FROM pa_lookups WHERE lookup_type = c_lookup_type AND lookup_code = c_lookup_code);
2723
2724 CURSOR c_get_subteam_party_id(c_requirement_id NUMBER) IS
2725 SELECT project_subteam_party_id, project_subteam_id
2726 FROM pa_project_subteam_parties
2727 WHERE object_id = c_requirement_id
2728 AND object_type = 'PA_PROJECT_ASSIGNMENTS'
2729 AND primary_subteam_flag = 'Y';
2730
2731 CURSOR c_get_requirement_details(c_requirement_id NUMBER) IS
2732 SELECT *
2733 FROM pa_project_assignments
2734 WHERE assignment_type = 'OPEN_ASSIGNMENT'
2735 AND assignment_id = c_requirement_id;
2736
2737 CURSOR c_get_system_status_code(c_status_code VARCHAR2, c_status_type VARCHAR2) IS
2738 SELECT project_system_status_code
2739 FROM pa_project_statuses
2740 WHERE status_type = c_status_type
2741 AND project_status_code = c_status_code;
2742
2743 CURSOR c_get_location(c_location_id NUMBER) IS
2744 SELECT country_code, region, city
2745 FROM pa_locations
2746 WHERE location_id = c_location_id;
2747
2748 CURSOR c_derive_country_code(c_country_name IN VARCHAR2) IS
2749 SELECT country_code
2750 FROM pa_country_v
2751 WHERE name = c_country_name;
2752
2753 CURSOR c_derive_country_name(c_country_code IN VARCHAR2) IS
2754 SELECT name
2755 FROM pa_country_v
2756 WHERE country_code = c_country_code;
2757
2758 -- 5144288, 5144369 : Added c_get_mcb_flag
2759 CURSOR c_get_mcb_flag(c_project_id NUMBER) IS
2760 SELECT multi_currency_billing_flag
2761 FROM pa_projects_all
2762 WHERE project_id = c_project_id;
2763
2764
2765 l_req_dtls_csr c_get_requirement_details%ROWTYPE;
2766 l_valid_flag VARCHAR2(1);
2767 l_rate_discount_reason_flag VARCHAR2(1);
2768 l_br_override_flag VARCHAR2(1);
2769 l_br_discount_override_flag VARCHAR2(1);
2770 l_project_subteam_party_id NUMBER;
2771 l_project_subteam_id NUMBER;
2772 l_system_status_code VARCHAR2(30);
2773 l_basic_info_changed VARCHAR2(1);
2774 l_candidate_info_changed VARCHAR2(1);
2775 l_fin_info_changed VARCHAR2(1);
2776 l_fin_bill_rate_info_changed VARCHAR2(1);
2777 l_fin_tp_rate_info_changed VARCHAR2(1);
2778 l_valid_country VARCHAR2(1);
2779 l_dummy_country_code VARCHAR2(2);
2780 l_dummy_state VARCHAR2(240);
2781 l_dummy_city VARCHAR2(80);
2782 l_out_location_id NUMBER;
2783 l_multi_currency_billing_flag VARCHAR2(1); -- 5144288, 5144369
2784 l_bill_currency_override_tmp VARCHAR2(30); -- 5144288, 5144369
2785
2786 BEGIN
2787
2788 --Flows which are supported by this API
2789 ---------------------------------------
2790 --1. Update project requirements
2791 -- 1.1 Updating basic information(staffing priority, staffing owner, subteams, location etc..)
2792 -- 1.2 Updating candidate search(search organization, weightages etc..) information
2793 -- 1.3 Updating financial information(expendtiture organization, bill rate etc..)
2794 -- 1.4 Updating forecast infomation(job, job group, expenditure type etc..)
2795 --2. Create team template requirments
2796 -- 2.1 Updating basic information(staffing priority, staffing owner, subteams, location etc..)
2797 --
2798 --Flows which are not supported by this API
2799 -------------------------------------------
2800 --1. Update team role for given planning resource
2801 --2. Adding candidates while updating requirements
2802 --3. Adding/Updating competencies
2803 --4. Updating schedule information(dates, status, calendar etc..)
2804 --5. Updating advertisement rule
2805
2806 -- Mandatory Parameters
2807 -----------------------
2808 --1. Requirement_id should be passed.
2809
2810 x_return_status := FND_API.G_RET_STS_SUCCESS;
2811
2812 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE',fnd_global.user_id,fnd_global.login_id,275,null,null), 'N');
2813
2814 IF l_debug_mode = 'Y' THEN
2815 PA_DEBUG.set_curr_function(p_function => 'UPDATE_REQUIREMENTS', p_debug_mode => l_debug_mode);
2816 END IF;
2817
2818 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
2819 FND_MSG_PUB.initialize;
2820 END IF;
2821
2822 IF p_commit = FND_API.G_TRUE THEN
2823 savepoint UPDATE_REQUIREMENTS_SP;
2824 END IF;
2825
2826 IF l_debug_mode = 'Y' THEN
2827 pa_debug.write(l_module, 'Start of update_requirements', l_log_level);
2828 END IF;
2829
2830 IF l_debug_mode = 'Y' THEN
2831 pa_debug.write(l_module, 'Printing Input Parameters......', l_log_level);
2832 i := p_requirement_in_tbl.first;
2833 WHILE i IS NOT NULL LOOP
2834 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').requirement_id'||p_requirement_in_tbl(i).requirement_id, l_log_level);
2835 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').requirement_name'||p_requirement_in_tbl(i).requirement_name, l_log_level);
2836 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').team_template_id'||p_requirement_in_tbl(i).team_template_id, l_log_level);
2837 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').number_of_requirements'||p_requirement_in_tbl(i).number_of_requirements, l_log_level);
2838 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_role_id'||p_requirement_in_tbl(i).project_role_id, l_log_level);
2839 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_role_name'||p_requirement_in_tbl(i).project_role_name, l_log_level);
2840 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_id'||p_requirement_in_tbl(i).project_id, l_log_level);
2841 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_name'||p_requirement_in_tbl(i).project_name, l_log_level);
2842 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_number'||p_requirement_in_tbl(i).project_number, l_log_level);
2843 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').staffing_owner_person_id'||p_requirement_in_tbl(i).staffing_owner_person_id, l_log_level);
2844 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').staffing_priority_code'||p_requirement_in_tbl(i).staffing_priority_code, l_log_level);
2845 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').staffing_priority_name'||p_requirement_in_tbl(i).staffing_priority_name, l_log_level);
2846 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_subteam_id'||p_requirement_in_tbl(i).project_subteam_id, l_log_level);
2847 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').project_subteam_name'||p_requirement_in_tbl(i).project_subteam_name, l_log_level);
2848 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_id'||p_requirement_in_tbl(i).location_id, l_log_level);
2849 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_country_code'||p_requirement_in_tbl(i).location_country_code, l_log_level);
2850 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_country_name'||p_requirement_in_tbl(i).location_country_name, l_log_level);
2851 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_region'||p_requirement_in_tbl(i).location_region, l_log_level);
2852 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').location_city'||p_requirement_in_tbl(i).location_city, l_log_level);
2853 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').min_resource_job_level'||p_requirement_in_tbl(i).min_resource_job_level, l_log_level);
2854 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').max_resource_job_level'||p_requirement_in_tbl(i).max_resource_job_level, l_log_level);
2855 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').description'||p_requirement_in_tbl(i).description, l_log_level);
2856 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').additional_information'||p_requirement_in_tbl(i).additional_information, l_log_level);
2857 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').start_date'||p_requirement_in_tbl(i).start_date, l_log_level);
2858 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').end_date'||p_requirement_in_tbl(i).end_date, l_log_level);
2859 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').status_code'||p_requirement_in_tbl(i).status_code, l_log_level);
2860 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').status_name'||p_requirement_in_tbl(i).status_name, l_log_level);
2861 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').calendar_type'||p_requirement_in_tbl(i).calendar_type, l_log_level);
2862 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').calendar_id'||p_requirement_in_tbl(i).calendar_id, l_log_level);
2863 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').calendar_name'||p_requirement_in_tbl(i).calendar_name, l_log_level);
2864 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').start_adv_action_set_flag'||p_requirement_in_tbl(i).start_adv_action_set_flag, l_log_level);
2865 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').adv_action_set_id'||p_requirement_in_tbl(i).adv_action_set_id, l_log_level);
2866 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').adv_action_set_name'||p_requirement_in_tbl(i).adv_action_set_name, l_log_level);
2867 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').comp_match_weighting'||p_requirement_in_tbl(i).comp_match_weighting, l_log_level);
2868 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').avail_match_weighting'||p_requirement_in_tbl(i).avail_match_weighting, l_log_level);
2869 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').job_level_match_weighting'||p_requirement_in_tbl(i).job_level_match_weighting, l_log_level);
2870 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').enable_auto_cand_nom_flag'||p_requirement_in_tbl(i).enable_auto_cand_nom_flag, l_log_level);
2871 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_min_availability'||p_requirement_in_tbl(i).search_min_availability, l_log_level);
2872 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_exp_org_str_ver_id'||p_requirement_in_tbl(i).search_exp_org_str_ver_id, l_log_level);
2873 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_exp_org_hier_name'||p_requirement_in_tbl(i).search_exp_org_hier_name, l_log_level);
2874 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_exp_start_org_id'||p_requirement_in_tbl(i).search_exp_start_org_id, l_log_level);
2875 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_exp_start_org_name'||p_requirement_in_tbl(i).search_exp_start_org_name, l_log_level);
2876 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_country_code'||p_requirement_in_tbl(i).search_country_code, l_log_level);
2877 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_country_name'||p_requirement_in_tbl(i).search_country_name, l_log_level);
2878 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').search_min_candidate_score'||p_requirement_in_tbl(i).search_min_candidate_score, l_log_level);
2879 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_org_id'||p_requirement_in_tbl(i).expenditure_org_id, l_log_level);
2880 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_org_name'||p_requirement_in_tbl(i).expenditure_org_name, l_log_level);
2881 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_organization_id'||p_requirement_in_tbl(i).expenditure_organization_id, l_log_level);
2882 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_organization_name'||p_requirement_in_tbl(i).expenditure_organization_name, l_log_level);
2883 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_type_class'||p_requirement_in_tbl(i).expenditure_type_class, l_log_level);
2884 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expenditure_type'||p_requirement_in_tbl(i).expenditure_type, l_log_level);
2885 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').fcst_job_group_id'||p_requirement_in_tbl(i).fcst_job_group_id, l_log_level);
2886 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').fcst_job_group_name'||p_requirement_in_tbl(i).fcst_job_group_name, l_log_level);
2887 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').fcst_job_id'||p_requirement_in_tbl(i).fcst_job_id, l_log_level);
2888 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').fcst_job_name'||p_requirement_in_tbl(i).fcst_job_name, l_log_level);
2889 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').work_type_id'||p_requirement_in_tbl(i).work_type_id, l_log_level);
2890 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').work_type_name'||p_requirement_in_tbl(i).work_type_name, l_log_level);
2891 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').bill_rate_option'||p_requirement_in_tbl(i).bill_rate_option, l_log_level);
2892 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').bill_rate_override'||p_requirement_in_tbl(i).bill_rate_override, l_log_level);
2893 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').bill_rate_curr_override'||p_requirement_in_tbl(i).bill_rate_curr_override, l_log_level);
2894 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').markup_percent_override'||p_requirement_in_tbl(i).markup_percent_override, l_log_level);
2895 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').discount_percentage'||p_requirement_in_tbl(i).discount_percentage, l_log_level);
2896 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').rate_disc_reason_code'||p_requirement_in_tbl(i).rate_disc_reason_code, l_log_level);
2897 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_rate_option'||p_requirement_in_tbl(i).tp_rate_option, l_log_level);
2898 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_rate_override'||p_requirement_in_tbl(i).tp_rate_override, l_log_level);
2899 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_currency_override'||p_requirement_in_tbl(i).tp_currency_override, l_log_level);
2900 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_calc_base_code_override'||p_requirement_in_tbl(i).tp_calc_base_code_override, l_log_level);
2901 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').tp_percent_applied_override'||p_requirement_in_tbl(i).tp_percent_applied_override, l_log_level);
2902 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').extension_possible'||p_requirement_in_tbl(i).extension_possible, l_log_level);
2903 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expense_owner'||p_requirement_in_tbl(i).expense_owner, l_log_level);
2904 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').expense_limit'||p_requirement_in_tbl(i).expense_limit, l_log_level);
2905 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').orig_system_code'||p_requirement_in_tbl(i).orig_system_code, l_log_level);
2906 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').orig_system_reference'||p_requirement_in_tbl(i).orig_system_reference, l_log_level);
2907 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').record_version_number'||p_requirement_in_tbl(i).record_version_number, l_log_level);
2908 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute_category'||p_requirement_in_tbl(i).attribute_category, l_log_level);
2909 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute1'||p_requirement_in_tbl(i).attribute1, l_log_level);
2910 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute2'||p_requirement_in_tbl(i).attribute2, l_log_level);
2911 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute3'||p_requirement_in_tbl(i).attribute3, l_log_level);
2912 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute4'||p_requirement_in_tbl(i).attribute4, l_log_level);
2913 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute5'||p_requirement_in_tbl(i).attribute5, l_log_level);
2914 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute6'||p_requirement_in_tbl(i).attribute6, l_log_level);
2915 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute7'||p_requirement_in_tbl(i).attribute7, l_log_level);
2916 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute8'||p_requirement_in_tbl(i).attribute8, l_log_level);
2917 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute9'||p_requirement_in_tbl(i).attribute9, l_log_level);
2918 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute10'||p_requirement_in_tbl(i).attribute10, l_log_level);
2919 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute11'||p_requirement_in_tbl(i).attribute11, l_log_level);
2920 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute12'||p_requirement_in_tbl(i).attribute12, l_log_level);
2921 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute13'||p_requirement_in_tbl(i).attribute13, l_log_level);
2922 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute14'||p_requirement_in_tbl(i).attribute14, l_log_level);
2923 pa_debug.write(l_module, 'p_requirement_in_tbl('||i||').attribute15'||p_requirement_in_tbl(i).attribute15, l_log_level);
2924 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
2925 i := p_requirement_in_tbl.next(i);
2926 END LOOP;
2927 END IF;
2928
2929 PA_STARTUP.INITIALIZE(
2930 p_calling_application => l_calling_application
2931 , p_calling_module => l_calling_module
2932 , p_check_id_flag => l_check_id_flag
2933 , p_check_role_security_flag => l_check_role_security_flag
2934 , p_check_resource_security_flag => l_check_resource_security_flag
2935 , p_debug_level => l_log_level
2936 );
2937
2938 IF l_debug_mode = 'Y' THEN
2939 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
2940 END IF;
2941
2942 -- Page does not check PRM licensing, but keeping this code so in future if required, can be used
2943 --l_prm_license_flag := nvl(FND_PROFILE.VALUE('PA_PRM_LICENSED'),'N');
2944 --IF l_prm_license_flag <> 'Y' THEN
2945 -- null;
2946 --END IF;
2947
2948
2949 i := p_requirement_in_tbl.first;
2950
2951 WHILE i IS NOT NULL LOOP
2952 l_error_flag_local := 'N';
2953 l_missing_params := null;
2954 l_req_rec := null;
2955 l_valid_country := 'Y';
2956 l_basic_info_changed := 'N';
2957 l_candidate_info_changed := 'N';
2958 l_fin_info_changed := 'N';
2959 l_fin_bill_rate_info_changed := 'N';
2960 l_fin_tp_rate_info_changed := 'N';
2961
2962 l_start_msg_count := FND_MSG_PUB.count_msg;
2963
2964 l_req_rec := p_requirement_in_tbl(i);
2965
2966 -- Mandatory Parameters Check
2967 ------------------------------
2968
2969 IF l_debug_mode = 'Y' THEN
2970 pa_debug.write(l_module, 'Record#'||i, l_log_level);
2971 pa_debug.write(l_module, '-----------------------------', l_log_level);
2972 pa_debug.write(l_module, 'Validate requirement_id.', l_log_level);
2973 END IF;
2974
2975 /*--Bug 6511907 PJR Date Validation Enhancement ----- Start--*/
2976 /*-- Validating Resource Req Start and End Date against
2977 Project Start and Completion dates --*/
2978
2979 Declare
2980 l_validate VARCHAR2(10);
2981 l_start_date_status VARCHAR2(10);
2982 l_end_date_status VARCHAR2(10);
2983 l_start_date DATE;
2984 l_end_date DATE;
2985 Begin
2986 If l_req_rec.start_date is not null or l_req_rec.end_date is not null then
2987 l_start_date := l_req_rec.start_date;
2988 l_end_date := l_req_rec.end_date;
2989 PA_PROJECT_DATES_UTILS.Validate_Resource_Dates
2990 (l_req_rec.project_id, l_start_date, l_end_date,
2991 l_validate, l_start_date_status, l_end_date_status);
2992
2993 If l_validate = 'Y' and l_start_date_status = 'I' Then
2994
2995 pa_utils.add_message
2996 ( p_app_short_name => 'PA'
2997 ,p_msg_name => 'PA_PJR_DATE_START_ERROR'
2998 ,p_token1 => 'PROJ_TXN_START_DATE'
2999 ,p_value1 => GET_PROJECT_START_DATE(l_req_rec.project_id)
3000 ,p_token2 => ''
3001 ,p_value2 => ''
3002 ,p_token3 => ''
3003 ,p_value3 => ''
3004 );
3005
3006 RAISE FND_API.G_EXC_ERROR;
3007 End If;
3008
3009 If l_validate = 'Y' and l_end_date_status = 'I' Then
3010
3011 pa_utils.add_message
3012 ( p_app_short_name => 'PA'
3013 ,p_msg_name => 'PA_PJR_DATE_FINISH_ERROR'
3014 ,p_token1 => 'PROJ_TXN_END_DATE'
3015 ,p_value1 => GET_PROJECT_COMPLETION_DATE(l_req_rec.project_id)
3016 ,p_token2 => ''
3017 ,p_value2 => ''
3018 ,p_token3 => ''
3019 ,p_value3 => ''
3020 );
3021
3022 RAISE FND_API.G_EXC_ERROR;
3023 End If;
3024 End If;
3025 End;
3026
3027 /*--Bug 6511907 PJR Date Validation Enhancement ----- End--*/
3028 l_req_dtls_csr := null;
3029 OPEN c_get_requirement_details(l_req_rec.requirement_id);
3030 FETCH c_get_requirement_details INTO l_req_dtls_csr;
3031
3032 IF c_get_requirement_details%NOTFOUND THEN
3033 l_missing_params := l_missing_params||', REQUIREMENT_ID';
3034 ELSE
3035 l_system_status_code := null;
3036 OPEN c_get_system_status_code(l_req_dtls_csr.status_code, 'OPEN_ASGMT');
3037 FETCH c_get_system_status_code INTO l_system_status_code;
3038 CLOSE c_get_system_status_code;
3039
3040 IF l_system_status_code IN ('OPEN_ASGMT_FILLED','OPEN_ASGMT_CANCEL') THEN
3041 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_STS_ACT_NOT_ALLW');
3042 l_error_flag_local := 'Y';
3043 END IF;
3044
3045 IF nvl(l_req_dtls_csr.mass_wf_in_progress_flag, 'N') = 'Y' THEN
3046 PA_UTILS.ADD_MESSAGE('PA', 'PA_ASSIGNMENT_WF');
3047 l_error_flag_local := 'Y';
3048 END IF;
3049 END IF;
3050
3051 CLOSE c_get_requirement_details;
3052
3053 IF l_req_rec.work_type_id IS NULL AND l_req_rec.work_type_name IS NULL THEN
3054 l_missing_params := l_missing_params||', WORK_TYPE_ID, WORK_TYPE_NAME';
3055 END IF;
3056
3057 IF l_req_rec.min_resource_job_level IS NULL THEN
3058 l_missing_params := l_missing_params||', MIN_RESOURCE_JOB_LEVEL';
3059 END IF;
3060
3061 IF l_req_rec.max_resource_job_level IS NULL THEN
3062 l_missing_params := l_missing_params||', MAX_RESOURCE_JOB_LEVEL';
3063 END IF;
3064
3065 IF l_req_rec.location_id IS NULL OR l_req_rec.location_id = G_PA_MISS_NUM THEN
3066 -- If either city or state (or) both are passed ,then country is
3067 -- mandatory
3068 IF (l_req_rec.location_country_code IS NULL AND l_req_rec.location_country_name IS NULL)
3069 OR (l_req_rec.location_country_code = G_PA_MISS_CHAR AND l_req_rec.location_country_name = G_PA_MISS_CHAR)
3070 THEN
3071 IF (l_req_rec.location_region <> G_PA_MISS_CHAR AND l_req_rec.location_region IS NOT NULL)
3072 OR (l_req_rec.location_city <> G_PA_MISS_CHAR AND l_req_rec.location_city IS NOT NULL)
3073 THEN
3074 l_missing_params := l_missing_params||', LOCATION_COUNTRY_CODE, LOCATION_COUNTRY_NAME';
3075 l_valid_country := 'N';
3076 END IF;
3077 ELSIF l_req_rec.location_country_code IS NOT NULL AND l_req_rec.location_country_code <> G_PA_MISS_CHAR
3078 THEN
3079 OPEN c_derive_country_name(l_req_rec.location_country_code);
3080 FETCH c_derive_country_name INTO l_req_rec.location_country_name;
3081 IF c_derive_country_name%NOTFOUND THEN
3082 -- Invalid Country code passed.
3083 l_missing_params := l_missing_params||', LOCATION_COUNTRY_CODE';
3084 l_valid_country := 'N';
3085 ELSE
3086 l_valid_country := 'Y';
3087 END IF;
3088 CLOSE c_derive_country_name;
3089 ELSIF l_req_rec.location_country_name IS NOT NULL AND l_req_rec.location_country_name <> G_PA_MISS_CHAR
3090 THEN
3091 OPEN c_derive_country_code(l_req_rec.location_country_name);
3092 FETCH c_derive_country_code INTO l_req_rec.location_country_code;
3093 IF c_derive_country_code%NOTFOUND THEN
3094 -- Invalid Country Name passed.
3095 l_missing_params := l_missing_params||', LOCATION_COUNTRY_NAME';
3096 l_valid_country := 'N';
3097 ELSE
3098 l_valid_country := 'Y';
3099 END IF;
3100 CLOSE c_derive_country_code;
3101 END IF;
3102
3103 -- If the country is valid,then proceed with the state and city validations
3104 IF l_valid_country = 'Y' AND l_req_rec.location_country_code IS NOT NULL
3105 AND l_req_rec.location_country_code <> G_PA_MISS_CHAR
3106 THEN
3107
3108 IF l_req_rec.location_id = G_PA_MISS_NUM THEN
3109 OPEN c_get_location(l_req_dtls_csr.location_id);
3110 FETCH c_get_location INTO l_dummy_country_code, l_dummy_state, l_dummy_city;
3111 CLOSE c_get_location;
3112 END IF;
3113
3114 l_dummy_country_code := l_req_rec.location_country_code;
3115
3116 IF l_req_rec.location_region IS NULL THEN
3117 l_dummy_state := null;
3118 ELSIF l_req_rec.location_region = G_PA_MISS_CHAR THEN
3119 l_dummy_state := l_dummy_state;
3120 ELSE
3121 l_dummy_state := l_req_rec.location_region;
3122 END IF;
3123
3124 IF l_req_rec.location_city IS NULL THEN
3125 l_dummy_city := null;
3126 ELSIF l_req_rec.location_city = G_PA_MISS_CHAR THEN
3127 l_dummy_city := l_dummy_city;
3128 ELSE
3129 l_dummy_city := l_req_rec.location_city;
3130 END IF;
3131
3132 PA_LOCATION_UTILS.CHECK_LOCATION_EXISTS
3133 (
3134 p_country_code => l_dummy_country_code
3135 ,p_city => l_dummy_city
3136 ,p_region => l_dummy_state
3137 ,x_location_id => l_out_location_id
3138 ,x_return_status => l_return_status
3139 );
3140
3141 IF l_out_location_id IS NULL THEN
3142 PA_UTILS.ADD_MESSAGE('PA','PA_AMG_RES_INV_CRC_COMB');
3143 l_error_flag_local := 'Y'; -- 5148975
3144 ELSE
3145 l_req_rec.location_id := l_out_location_id;
3146 END IF;
3147 END IF;
3148 ELSE
3149 -- if location id is passed, then it will override the city, region, country code
3150 OPEN c_get_location(l_req_rec.location_id);
3151 FETCH c_get_location INTO l_req_rec.location_country_code, l_req_rec.location_region, l_req_rec.location_city;
3152
3153 IF c_get_location%NOTFOUND THEN
3154 l_missing_params := l_missing_params||', LOCATION_ID';
3155 END IF;
3156 CLOSE c_get_location;
3157 END IF; -- l_req_rec.location_id IS NULL OR l_req_rec.location_id = FND_API.G_MISS_NUM
3158
3159
3160
3161 -- For start date, and end dates, status, calendar uses cant update from this flow
3162 --IF l_req_rec.start_date IS NULL THEN
3163 -- l_missing_params := l_missing_params||', START_DATE';
3164 --END IF;
3165
3166 --IF l_req_rec.end_date IS NULL THEN
3167 -- l_missing_params := l_missing_params||', END_DATE';
3168 --END IF;
3169
3170 --IF l_req_rec.status_code IS NULL AND l_req_rec.status_name IS NULL THEN
3171 -- l_missing_params := l_missing_params||', STATUS_CODE, STATUS_NAME';
3172 --END IF;
3173
3174 --IF l_req_rec.calendar_id IS NULL AND l_req_rec.calendar_name IS NULL THEN
3175 -- l_missing_params := l_missing_params||', CALENDAR_ID, CALENDAR_NAME';
3176 --END IF;
3177
3178 IF nvl(l_req_dtls_csr.template_flag, 'N') = 'N' AND l_req_dtls_csr.project_id IS NOT NULL THEN
3179 -- Project Requirement Flow
3180
3181 -- These checks are NULL checks, which means user is passing them explicitely as NULL
3182 -- If user does not pass anything, then it will be G_PA_MISS_XXX
3183
3184 IF l_req_rec.comp_match_weighting IS NULL THEN
3185 l_missing_params := l_missing_params||', COMP_MATCH_WEIGHTING';
3186 END IF;
3187
3188 IF l_req_rec.avail_match_weighting IS NULL THEN
3189 l_missing_params := l_missing_params||', AVAIL_MATCH_WEIGHTING';
3190 END IF;
3191
3192 IF l_req_rec.job_level_match_weighting IS NULL THEN
3193 l_missing_params := l_missing_params||', JOB_LEVEL_MATCH_WEIGHTING';
3194 END IF;
3195
3196 -- Let enable_auto_cand_nom_flag be null, If null then we shd take it as N
3197 --IF l_req_rec.enable_auto_cand_nom_flag IS NULL THEN
3198 -- l_missing_params := l_missing_params||', ENABLE_AUTO_CAND_NOM_FLAG';
3199 --END IF;
3200
3201 IF l_req_rec.search_min_availability IS NULL THEN
3202 l_missing_params := l_missing_params||', SEARCH_MIN_AVAILABILITY';
3203 END IF;
3204
3205 IF l_req_rec.search_exp_org_str_ver_id IS NULL AND l_req_rec.search_exp_org_hier_name IS NULL THEN
3206 l_missing_params := l_missing_params||', SEARCH_EXP_ORG_STR_VER_ID, SEARCH_EXP_ORG_HIER_NAME';
3207 END IF;
3208
3209 IF l_req_rec.search_exp_start_org_id IS NULL AND l_req_rec.search_exp_start_org_name IS NULL THEN
3210 l_missing_params := l_missing_params||', SEARCH_EXP_START_ORG_ID, SEARCH_EXP_START_ORG_NAME';
3211 END IF;
3212
3213 IF l_req_rec.search_min_candidate_score IS NULL THEN
3214 l_missing_params := l_missing_params||', SEARCH_MIN_CANDIDATE_SCORE';
3215 END IF;
3216
3217 IF l_req_rec.expenditure_org_id IS NULL AND l_req_rec.expenditure_org_name IS NULL THEN
3218 l_missing_params := l_missing_params||', EXPENDITURE_ORG_ID, EXPENDITURE_ORG_NAME';
3219 END IF;
3220
3221 IF l_req_rec.expenditure_organization_id IS NULL AND l_req_rec.expenditure_organization_name IS NULL THEN
3222 l_missing_params := l_missing_params||', EXPENDITURE_ORGANIZATION_ID, EXPENDITURE_ORGANIZATION_NAME';
3223 END IF;
3224
3225 IF l_req_rec.expenditure_type_class IS NULL THEN
3226 l_missing_params := l_missing_params||', EXPENDITURE_TYPE_CLASS';
3227 END IF;
3228
3229 IF l_req_rec.expenditure_type IS NULL THEN
3230 l_missing_params := l_missing_params||', EXPENDITURE_TYPE';
3231 END IF;
3232
3233 IF l_req_rec.bill_rate_option IS NULL THEN
3234 l_missing_params := l_missing_params||', BILL_RATE_OPTION';
3235 ELSIF l_req_rec.bill_rate_option <> G_PA_MISS_CHAR AND l_req_rec.bill_rate_option NOT IN('RATE','MARKUP','DISCOUNT','NONE') THEN
3236 l_missing_params := l_missing_params||', BILL_RATE_OPTION';
3237 ELSIF l_req_rec.bill_rate_option = 'NONE' THEN
3238 l_req_rec.bill_rate_override := null;
3239 l_req_rec.bill_rate_curr_override := null;
3240 l_req_rec.markup_percent_override := null;
3241 l_req_rec.discount_percentage := null;
3242 l_req_rec.rate_disc_reason_code := null;
3243 ELSIF l_req_rec.bill_rate_option = 'RATE' THEN
3244 l_req_rec.markup_percent_override := null;
3245 l_req_rec.discount_percentage := null;
3246 IF (l_req_rec.bill_rate_override IS NULL OR l_req_rec.bill_rate_override = G_PA_MISS_NUM)
3247 AND l_req_dtls_csr.bill_rate_override IS NULL
3248 THEN
3249 l_missing_params := l_missing_params||', BILL_RATE_OVERRIDE';
3250 END IF;
3251 ELSIF l_req_rec.bill_rate_option = 'MARKUP' THEN
3252 l_req_rec.bill_rate_override := null;
3253 l_req_rec.bill_rate_curr_override := null;
3254 l_req_rec.discount_percentage := null;
3255 IF (l_req_rec.markup_percent_override IS NULL OR l_req_rec.markup_percent_override = G_PA_MISS_NUM)
3256 AND l_req_dtls_csr.markup_percent_override IS NULL
3257 THEN
3258 l_missing_params := l_missing_params||', MARKUP_PERCENT_OVERRIDE';
3259 END IF;
3260 ELSIF l_req_rec.bill_rate_option = 'DISCOUNT' THEN
3261 l_req_rec.bill_rate_override := null;
3262 l_req_rec.bill_rate_curr_override := null;
3263 l_req_rec.markup_percent_override := null;
3264 IF (l_req_rec.discount_percentage IS NULL OR l_req_rec.discount_percentage = G_PA_MISS_NUM)
3265 AND l_req_dtls_csr.discount_percentage IS NULL
3266 THEN
3267 l_missing_params := l_missing_params||', DISCOUNT_PERCENTAGE';
3268 END IF;
3269 END IF;
3270
3271
3272 IF l_req_rec.tp_rate_option IS NULL THEN
3273 l_missing_params := l_missing_params||', TP_RATE_OPTION';
3274 ELSIF l_req_rec.tp_rate_option <> G_PA_MISS_CHAR AND l_req_rec.tp_rate_option NOT IN('RATE','BASIS','NONE')
3275 THEN
3276 l_missing_params := l_missing_params||', TP_RATE_OPTION';
3277 ELSIF l_req_rec.tp_rate_option = 'NONE' THEN
3278 l_req_rec.tp_rate_override := null;
3279 l_req_rec.tp_currency_override := null;
3280 l_req_rec.tp_calc_base_code_override := null;
3281 l_req_rec.tp_percent_applied_override := null;
3282 ELSIF l_req_rec.tp_rate_option = 'RATE' THEN
3283 l_req_rec.tp_calc_base_code_override := null;
3284 l_req_rec.tp_percent_applied_override := null;
3285 IF (((l_req_rec.tp_rate_override IS NULL OR l_req_rec.tp_rate_override = G_PA_MISS_NUM)
3286 AND l_req_dtls_csr.tp_rate_override IS NULL)
3287 OR
3288 ((l_req_rec.tp_currency_override IS NULL OR l_req_rec.tp_currency_override = G_PA_MISS_CHAR)
3289 AND l_req_dtls_csr.tp_currency_override IS NULL)
3290 )
3291 THEN
3292 l_missing_params := l_missing_params||', TP_RATE_OVERRIDE, TP_CURRENCY_OVERRIDE';
3293 END IF;
3294 ELSIF l_req_rec.tp_rate_option = 'BASIS' THEN
3295 l_req_rec.tp_rate_override := null;
3296 l_req_rec.tp_currency_override := null;
3297 IF (((l_req_rec.tp_calc_base_code_override IS NULL OR l_req_rec.tp_calc_base_code_override = G_PA_MISS_CHAR)
3298 AND l_req_dtls_csr.tp_calc_base_code_override IS NULL)
3299 OR
3300 ((l_req_rec.tp_percent_applied_override IS NULL OR l_req_rec.tp_percent_applied_override = G_PA_MISS_NUM)
3301 AND l_req_dtls_csr.tp_percent_applied_override IS NULL)
3302 )
3303 THEN
3304 l_missing_params := l_missing_params||', TP_CALC_BASE_CODE_OVERRIDE, TP_PERCENT_APPLIED_OVERRIDE';
3305 END IF;
3306 END IF;
3307
3308 IF l_req_rec.extension_possible <> G_PA_MISS_CHAR AND l_req_rec.extension_possible NOT IN ('Y','N') THEN
3309 l_missing_params := l_missing_params||', EXTENSION_POSSIBLE';
3310 END IF;
3311 END IF; -- nvl(l_req_dtls_csr.team_template_flag, 'N')
3312
3313 IF l_debug_mode = 'Y' THEN
3314 pa_debug.write(l_module, 'Mandatory parameter validation over. List of Missing Parameters='||l_missing_params, l_log_level);
3315 END IF;
3316
3317 IF l_missing_params IS NOT NULL THEN
3318 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
3319 'INVALID_PARAMS', l_missing_params);
3320 l_error_flag_local := 'Y';
3321 END IF;
3322
3323 -- Retrieve values from data base if Parameters are not passed.
3324 ---------------------------------------------------------------
3325
3326
3327 IF l_debug_mode = 'Y' THEN
3328 pa_debug.write(l_module, 'Take values from database for those parameters which are not passed.', l_log_level);
3329 END IF;
3330
3331 IF l_req_rec.requirement_name = G_PA_MISS_CHAR THEN
3332 l_req_rec.requirement_name := l_req_dtls_csr.assignment_name;
3333 END IF;
3334
3335
3336 -- These parameters are Not used for Update Flow:
3337
3338 -- Internal API requires to pass FND_API miss nums instead of null
3339 -- if we pass null, they treat it as update and raise error
3340 l_req_rec.team_template_id := l_req_dtls_csr.assignment_template_id;
3341
3342 l_req_rec.number_of_requirements := FND_API.G_MISS_NUM;
3343
3344 l_req_rec.project_role_id := FND_API.G_MISS_NUM;
3345
3346 l_req_rec.project_role_name := FND_API.G_MISS_CHAR;
3347
3348 l_req_rec.project_id := l_req_dtls_csr.project_id;
3349
3350 l_req_rec.project_name := FND_API.G_MISS_CHAR;
3351
3352 l_req_rec.project_number := FND_API.G_MISS_CHAR;
3353
3354 IF l_req_rec.staffing_owner_person_id = G_PA_MISS_NUM THEN
3355 l_req_rec.staffing_owner_person_id := l_req_dtls_csr.staffing_owner_person_id;
3356 END IF;
3357
3358 IF l_req_rec.staffing_priority_code = G_PA_MISS_CHAR THEN
3359 l_req_rec.staffing_priority_code := l_req_dtls_csr.staffing_priority_code;
3360 END IF;
3361
3362 IF l_req_rec.staffing_priority_name = G_PA_MISS_CHAR THEN
3363 l_req_rec.staffing_priority_name := null;
3364 END IF;
3365
3366 l_project_subteam_party_id := null;
3367
3368 OPEN c_get_subteam_party_id(l_req_rec.requirement_id);
3369 FETCH c_get_subteam_party_id INTO l_project_subteam_party_id, l_project_subteam_id;
3370 CLOSE c_get_subteam_party_id;
3371
3372 IF l_req_rec.project_subteam_id = G_PA_MISS_NUM THEN
3373 -- The reason we need to check name here, because
3374 -- If name is passed and id is not. In this case, id
3375 -- will default to previous id and new name will be lost
3376 IF l_req_rec.project_subteam_name = G_PA_MISS_CHAR THEN
3377 l_req_rec.project_subteam_id := l_project_subteam_id;
3378 ELSIF l_req_rec.project_subteam_name IS NULL THEN
3379 l_req_rec.project_subteam_id := null;
3380 ELSE
3381 l_req_rec.project_subteam_id := null;
3382 END IF;
3383 END IF;
3384
3385 IF l_req_rec.project_subteam_name = G_PA_MISS_CHAR THEN
3386 l_req_rec.project_subteam_name := null;
3387 END IF;
3388
3389
3390 IF l_req_rec.location_id = G_PA_MISS_NUM THEN
3391 l_req_rec.location_id := l_req_dtls_csr.location_id;
3392 END IF;
3393
3394 IF l_req_rec.location_country_code = G_PA_MISS_CHAR THEN
3395 l_req_rec.location_country_code := null;
3396 END IF;
3397
3398 IF l_req_rec.location_country_name = G_PA_MISS_CHAR THEN
3399 l_req_rec.location_country_name := null;
3400 END IF;
3401
3402 IF l_req_rec.location_region = G_PA_MISS_CHAR THEN
3403 l_req_rec.location_region := null;
3404 END IF;
3405
3406 IF l_req_rec.location_city = G_PA_MISS_CHAR THEN
3407 l_req_rec.location_city := null;
3408 END IF;
3409
3410 IF l_req_rec.min_resource_job_level = G_PA_MISS_NUM THEN
3411 l_req_rec.min_resource_job_level := l_req_dtls_csr.min_resource_job_level;
3412 END IF;
3413
3414 IF l_req_rec.max_resource_job_level = G_PA_MISS_NUM THEN
3415 l_req_rec.max_resource_job_level := l_req_dtls_csr.max_resource_job_level;
3416 END IF;
3417
3418 IF l_req_rec.description = G_PA_MISS_CHAR THEN
3419 l_req_rec.description := l_req_dtls_csr.description;
3420 END IF;
3421
3422 IF l_req_rec.additional_information = G_PA_MISS_CHAR THEN
3423 l_req_rec.additional_information := l_req_dtls_csr.additional_information;
3424 END IF;
3425
3426 -- These parameters are not For Update flow
3427 l_req_rec.start_date := l_req_dtls_csr.start_date;
3428 l_req_rec.end_date := l_req_dtls_csr.end_date;
3429 l_req_rec.status_code := l_req_dtls_csr.status_code;
3430 l_req_rec.status_name := null;
3431 l_req_rec.calendar_type := null;
3432 l_req_rec.calendar_id := l_req_dtls_csr.calendar_id;
3433 l_req_rec.calendar_name := null;
3434 l_req_rec.start_adv_action_set_flag := null;
3435 l_req_rec.adv_action_set_id := null;
3436 l_req_rec.adv_action_set_name := null;
3437
3438
3439 IF l_req_rec.comp_match_weighting = G_PA_MISS_NUM THEN
3440 l_req_rec.comp_match_weighting := l_req_dtls_csr.competence_match_weighting;
3441 END IF;
3442
3443 IF l_req_rec.avail_match_weighting = G_PA_MISS_NUM THEN
3444 l_req_rec.avail_match_weighting := l_req_dtls_csr.availability_match_weighting;
3445 END IF;
3446
3447 IF l_req_rec.job_level_match_weighting = G_PA_MISS_NUM THEN
3448 l_req_rec.job_level_match_weighting := l_req_dtls_csr.job_level_match_weighting;
3449 END IF;
3450
3451 IF l_req_rec.enable_auto_cand_nom_flag = G_PA_MISS_CHAR THEN
3452 l_req_rec.enable_auto_cand_nom_flag := l_req_dtls_csr.enable_auto_cand_nom_flag;
3453 END IF;
3454
3455 -- Treat null as N for flags
3456 IF l_req_rec.enable_auto_cand_nom_flag IS NULL THEN
3457 l_req_rec.enable_auto_cand_nom_flag := 'N';
3458 END IF;
3459
3460 IF l_req_rec.search_min_availability = G_PA_MISS_NUM THEN
3461 l_req_rec.search_min_availability := l_req_dtls_csr.search_min_availability;
3462 END IF;
3463
3464 IF l_req_rec.search_exp_org_str_ver_id = G_PA_MISS_NUM THEN
3465 IF l_req_rec.search_exp_org_hier_name = G_PA_MISS_CHAR THEN
3466 l_req_rec.search_exp_org_str_ver_id := l_req_dtls_csr.search_exp_org_struct_ver_id;
3467 ELSIF l_req_rec.search_exp_org_hier_name IS NULL THEN
3468 l_req_rec.search_exp_org_str_ver_id := null;
3469 ELSE
3470 l_req_rec.search_exp_org_str_ver_id := null;
3471 END IF;
3472 END IF;
3473
3474 IF l_req_rec.search_exp_org_hier_name = G_PA_MISS_CHAR THEN
3475 l_req_rec.search_exp_org_hier_name := null;
3476 END IF;
3477
3478 IF l_req_rec.search_exp_start_org_id = G_PA_MISS_NUM THEN
3479 IF l_req_rec.search_exp_start_org_name = G_PA_MISS_CHAR THEN
3480 l_req_rec.search_exp_start_org_id := l_req_dtls_csr.search_exp_start_org_id;
3481 ELSIF l_req_rec.search_exp_start_org_name IS NULL THEN
3482 l_req_rec.search_exp_start_org_id := null;
3483 ELSE
3484 l_req_rec.search_exp_start_org_id := null;
3485 END IF;
3486 END IF;
3487
3488 IF l_req_rec.search_exp_start_org_name = G_PA_MISS_CHAR THEN
3489 l_req_rec.search_exp_start_org_name := null;
3490 END IF;
3491
3492 IF l_req_rec.search_country_code = G_PA_MISS_CHAR THEN
3493 IF l_req_rec.search_country_name = G_PA_MISS_CHAR THEN
3494 l_req_rec.search_country_code := l_req_dtls_csr.search_country_code;
3495 ELSIF l_req_rec.search_country_name IS NULL THEN
3496 l_req_rec.search_country_code := null;
3497 ELSE
3498 l_req_rec.search_country_code := null;
3499 END IF;
3500 END IF;
3501
3502 IF l_req_rec.search_country_name = G_PA_MISS_CHAR THEN
3503 l_req_rec.search_country_name := null;
3504 END IF;
3505
3506 IF l_req_rec.search_min_candidate_score = G_PA_MISS_NUM THEN
3507 l_req_rec.search_min_candidate_score := l_req_dtls_csr.search_min_candidate_score;
3508 END IF;
3509
3510 IF l_req_rec.expenditure_org_id = G_PA_MISS_NUM THEN
3511 IF l_req_rec.expenditure_org_name = G_PA_MISS_CHAR THEN
3512 l_req_rec.expenditure_org_id := l_req_dtls_csr.expenditure_org_id;
3513 ELSIF l_req_rec.expenditure_org_name IS NULL THEN
3514 l_req_rec.expenditure_org_id := null;
3515 ELSE
3516 l_req_rec.expenditure_org_id := null;
3517 END IF;
3518 END IF;
3519
3520 IF l_req_rec.expenditure_org_name = G_PA_MISS_CHAR THEN
3521 l_req_rec.expenditure_org_name := null;
3522 END IF;
3523
3524 IF l_req_rec.expenditure_organization_id = G_PA_MISS_NUM THEN
3525 IF l_req_rec.expenditure_organization_name = G_PA_MISS_CHAR THEN
3526 l_req_rec.expenditure_organization_id := l_req_dtls_csr.expenditure_organization_id;
3527 ELSIF l_req_rec.expenditure_organization_name IS NULL THEN
3528 l_req_rec.expenditure_organization_id := null;
3529 ELSE
3530 l_req_rec.expenditure_organization_id := null;
3531 END IF;
3532 END IF;
3533
3534 IF l_req_rec.expenditure_organization_name = G_PA_MISS_CHAR THEN
3535 l_req_rec.expenditure_organization_name := null;
3536 END IF;
3537
3538 IF l_req_rec.expenditure_type_class = G_PA_MISS_CHAR THEN
3539 l_req_rec.expenditure_type_class := l_req_dtls_csr.expenditure_type_class;
3540 END IF;
3541
3542 IF l_req_rec.expenditure_type = G_PA_MISS_CHAR THEN
3543 l_req_rec.expenditure_type := l_req_dtls_csr.expenditure_type;
3544 END IF;
3545
3546
3547 IF l_req_rec.fcst_job_group_id = G_PA_MISS_NUM THEN
3548 IF l_req_rec.fcst_job_group_name = G_PA_MISS_CHAR THEN
3549 l_req_rec.fcst_job_group_id := l_req_dtls_csr.fcst_job_group_id;
3550 ELSIF l_req_rec.fcst_job_group_name IS NULL THEN
3551 l_req_rec.fcst_job_group_id := null;
3552 ELSE
3553 l_req_rec.fcst_job_group_id := null;
3554 END IF;
3555 END IF;
3556
3557 IF l_req_rec.fcst_job_group_name = G_PA_MISS_CHAR THEN
3558 l_req_rec.fcst_job_group_name := null;
3559 END IF;
3560
3561 IF l_req_rec.fcst_job_id = G_PA_MISS_NUM THEN
3562 IF l_req_rec.fcst_job_name = G_PA_MISS_CHAR THEN
3563 l_req_rec.fcst_job_id := l_req_dtls_csr.fcst_job_id;
3564 ELSIF l_req_rec.fcst_job_name IS NULL THEN
3565 l_req_rec.fcst_job_id := null;
3566 ELSE
3567 l_req_rec.fcst_job_id := null;
3568 END IF;
3569 END IF;
3570
3571 IF l_req_rec.fcst_job_name = G_PA_MISS_CHAR THEN
3572 l_req_rec.fcst_job_name := null;
3573 END IF;
3574
3575 IF l_req_rec.work_type_id = G_PA_MISS_NUM THEN
3576 IF l_req_rec.work_type_name = G_PA_MISS_CHAR THEN
3577 l_req_rec.work_type_id := l_req_dtls_csr.work_type_id;
3578 ELSIF l_req_rec.work_type_name IS NULL THEN
3579 l_req_rec.work_type_id := null;
3580 ELSE
3581 l_req_rec.work_type_id := null;
3582 END IF;
3583 END IF;
3584
3585 IF l_req_rec.work_type_name = G_PA_MISS_CHAR THEN
3586 l_req_rec.work_type_name := null;
3587 END IF;
3588
3589 -- No need to default this
3590 -- l_req_rec.bill_rate_option := 'NONE';
3591
3592 IF l_req_rec.bill_rate_override = G_PA_MISS_NUM THEN
3593 l_req_rec.bill_rate_override := l_req_dtls_csr.bill_rate_override;
3594 END IF;
3595
3596 IF l_req_rec.bill_rate_curr_override = G_PA_MISS_CHAR THEN
3597 l_req_rec.bill_rate_curr_override := l_req_dtls_csr.bill_rate_curr_override;
3598 END IF;
3599
3600 IF l_req_rec.markup_percent_override = G_PA_MISS_NUM THEN
3601 l_req_rec.markup_percent_override := l_req_dtls_csr.markup_percent_override;
3602 END IF;
3603
3604 IF l_req_rec.discount_percentage = G_PA_MISS_NUM THEN
3605 l_req_rec.discount_percentage := l_req_dtls_csr.discount_percentage;
3606 END IF;
3607
3608 IF l_req_rec.rate_disc_reason_code = G_PA_MISS_CHAR THEN
3609 l_req_rec.rate_disc_reason_code := l_req_dtls_csr.rate_disc_reason_code;
3610 END IF;
3611
3612 -- No need to default this
3613 -- l_req_rec.tp_rate_option := 'NONE';
3614
3615 IF l_req_rec.tp_rate_override = G_PA_MISS_NUM THEN
3616 l_req_rec.tp_rate_override := l_req_dtls_csr.tp_rate_override;
3617 END IF;
3618
3619 IF l_req_rec.tp_currency_override = G_PA_MISS_CHAR THEN
3620 l_req_rec.tp_currency_override := l_req_dtls_csr.tp_currency_override;
3621 END IF;
3622
3623 IF l_req_rec.tp_calc_base_code_override = G_PA_MISS_CHAR THEN
3624 l_req_rec.tp_calc_base_code_override := l_req_dtls_csr.tp_calc_base_code_override;
3625 END IF;
3626
3627 IF l_req_rec.tp_percent_applied_override = G_PA_MISS_NUM THEN
3628 l_req_rec.tp_percent_applied_override := l_req_dtls_csr.tp_percent_applied_override;
3629 END IF;
3630
3631 IF l_req_rec.extension_possible = G_PA_MISS_CHAR THEN
3632 l_req_rec.extension_possible := l_req_dtls_csr.extension_possible;
3633 END IF;
3634
3635 IF l_req_rec.expense_owner = G_PA_MISS_CHAR THEN
3636 l_req_rec.expense_owner := l_req_dtls_csr.expense_owner;
3637 END IF;
3638
3639 IF l_req_rec.expense_limit = G_PA_MISS_NUM THEN
3640 l_req_rec.expense_limit := l_req_dtls_csr.expense_limit;
3641 END IF;
3642
3643 IF l_req_rec.orig_system_code = G_PA_MISS_CHAR THEN
3644 l_req_rec.orig_system_code := l_req_dtls_csr.orig_system_code;
3645 END IF;
3646
3647 IF l_req_rec.orig_system_reference = G_PA_MISS_CHAR THEN
3648 l_req_rec.orig_system_reference := l_req_dtls_csr.orig_system_reference;
3649 END IF;
3650
3651 IF l_req_rec.record_version_number = G_PA_MISS_NUM THEN
3652 l_req_rec.record_version_number := l_req_dtls_csr.record_version_number;
3653 END IF;
3654
3655 IF l_req_rec.attribute_category = G_PA_MISS_CHAR THEN
3656 l_req_rec.attribute_category := l_req_dtls_csr.attribute_category;
3657 END IF;
3658
3659 IF l_req_rec.attribute1 = G_PA_MISS_CHAR THEN
3660 l_req_rec.attribute1 := l_req_dtls_csr.attribute1;
3661 END IF;
3662
3663 IF l_req_rec.attribute2 = G_PA_MISS_CHAR THEN
3664 l_req_rec.attribute2 := l_req_dtls_csr.attribute2;
3665 END IF;
3666
3667 IF l_req_rec.attribute3 = G_PA_MISS_CHAR THEN
3668 l_req_rec.attribute3 := l_req_dtls_csr.attribute3;
3669 END IF;
3670
3671 IF l_req_rec.attribute4 = G_PA_MISS_CHAR THEN
3672 l_req_rec.attribute4 := l_req_dtls_csr.attribute4;
3673 END IF;
3674
3675 IF l_req_rec.attribute5 = G_PA_MISS_CHAR THEN
3676 l_req_rec.attribute5 := l_req_dtls_csr.attribute5;
3677 END IF;
3678
3679 IF l_req_rec.attribute6 = G_PA_MISS_CHAR THEN
3680 l_req_rec.attribute6 := l_req_dtls_csr.attribute6;
3681 END IF;
3682
3683 IF l_req_rec.attribute7 = G_PA_MISS_CHAR THEN
3684 l_req_rec.attribute7 := l_req_dtls_csr.attribute7;
3685 END IF;
3686
3687 IF l_req_rec.attribute8 = G_PA_MISS_CHAR THEN
3688 l_req_rec.attribute8 := l_req_dtls_csr.attribute8;
3689 END IF;
3690
3691 IF l_req_rec.attribute9 = G_PA_MISS_CHAR THEN
3692 l_req_rec.attribute9 := l_req_dtls_csr.attribute9;
3693 END IF;
3694
3695 IF l_req_rec.attribute10 = G_PA_MISS_CHAR THEN
3696 l_req_rec.attribute10 := l_req_dtls_csr.attribute10;
3697 END IF;
3698
3699 IF l_req_rec.attribute11 = G_PA_MISS_CHAR THEN
3700 l_req_rec.attribute11 := l_req_dtls_csr.attribute11;
3701 END IF;
3702
3703 IF l_req_rec.attribute12 = G_PA_MISS_CHAR THEN
3704 l_req_rec.attribute12 := l_req_dtls_csr.attribute12;
3705 END IF;
3706
3707 IF l_req_rec.attribute13 = G_PA_MISS_CHAR THEN
3708 l_req_rec.attribute13 := l_req_dtls_csr.attribute13;
3709 END IF;
3710
3711 IF l_req_rec.attribute14 = G_PA_MISS_CHAR THEN
3712 l_req_rec.attribute14 := l_req_dtls_csr.attribute14;
3713 END IF;
3714
3715 IF l_req_rec.attribute15 = G_PA_MISS_CHAR THEN
3716 l_req_rec.attribute15 := l_req_dtls_csr.attribute15;
3717 END IF;
3718
3719
3720 IF l_debug_mode = 'Y' THEN
3721 pa_debug.write(l_module, 'Got the values from database.', l_log_level);
3722 pa_debug.write(l_module, 'DB value of ProjectId='||l_req_dtls_csr.project_id, l_log_level);
3723 pa_debug.write(l_module, 'DB value of TeamTemplateId='||l_req_dtls_csr.assignment_template_id, l_log_level);
3724 pa_debug.write(l_module, 'DB value of TeamTemplateFlag='||l_req_dtls_csr.template_flag, l_log_level);
3725 pa_debug.write(l_module, 'l_error_flag_local='||l_error_flag_local, l_log_level);
3726 END IF;
3727
3728
3729 -- All validations are not required as some validation is done in underlying code
3730 -- Here, we are doing only those validations which are not done internally.
3731
3732 IF l_error_flag_local <> 'Y' AND nvl(l_req_dtls_csr.template_flag,'N') = 'N' THEN
3733 -- Project Requirement Flow
3734
3735
3736 -- Bill Rate Options Validation
3737 -------------------------------
3738
3739 IF l_req_rec.bill_rate_option <> 'NONE' THEN
3740 l_rate_discount_reason_flag := 'N';
3741 l_br_override_flag := 'N';
3742 l_br_discount_override_flag := 'N';
3743
3744 OPEN get_bill_rate_override_flags(l_req_rec.project_id);
3745 FETCH get_bill_rate_override_flags INTO l_rate_discount_reason_flag, l_br_override_flag, l_br_discount_override_flag;
3746 CLOSE get_bill_rate_override_flags;
3747
3748 IF l_debug_mode = 'Y' THEN
3749 pa_debug.write(l_module, 'Validating Bill Rate Options', l_log_level);
3750 pa_debug.write(l_module, 'l_rate_discount_reason_flag='||l_rate_discount_reason_flag, l_log_level);
3751 pa_debug.write(l_module, 'l_br_override_flag='||l_br_override_flag, l_log_level);
3752 pa_debug.write(l_module, 'l_br_discount_override_flag='||l_br_discount_override_flag, l_log_level);
3753 END IF;
3754
3755 IF l_req_rec.bill_rate_option = 'RATE' THEN
3756
3757 IF l_br_override_flag <> 'Y' OR l_req_rec.bill_rate_override <= 0 THEN /* OR l_req_rec.bill_rate_override > 100 - Removed for Bug 5703021*/
3758 IF l_br_override_flag <> 'Y' THEN
3759 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_BILL_RATE_OVRD_NA');
3760 l_error_flag_local := 'Y';
3761 ELSE
3762 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_BILL_RATE_OVRD');
3763 l_error_flag_local := 'Y';
3764 END IF;
3765 END IF;
3766
3767 -- 5144288, 5144369 : Begin
3768 l_multi_currency_billing_flag := null;
3769 OPEN c_get_mcb_flag(l_req_rec.project_id);
3770 FETCH c_get_mcb_flag INTO l_multi_currency_billing_flag;
3771 CLOSE c_get_mcb_flag;
3772
3773 IF nvl(l_multi_currency_billing_flag,'N') = 'Y' AND l_br_override_flag = 'Y' THEN
3774 l_return_status := FND_API.G_RET_STS_SUCCESS;
3775 l_error_message_code := null;
3776 l_bill_currency_override_tmp := l_req_rec.bill_rate_curr_override;
3777
3778 IF l_debug_mode = 'Y' THEN
3779 pa_debug.write(l_module, 'Validating Bill Rate Currency', l_log_level);
3780 END IF;
3781
3782 PA_PROJECTS_MAINT_UTILS.CHECK_CURRENCY_NAME_OR_CODE(
3783 p_agreement_currency => l_bill_currency_override_tmp
3784 ,p_agreement_currency_name => null
3785 ,p_check_id_flag => 'Y'
3786 ,x_agreement_currency => l_req_rec.bill_rate_curr_override
3787 ,x_return_status => l_return_status
3788 ,x_error_msg_code => l_error_message_code);
3789
3790 IF l_debug_mode = 'Y' THEN
3791 pa_debug.write(l_module, 'After Bill Rate Currency Validation', l_log_level);
3792 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
3793 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
3794 END IF;
3795
3796 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3797 PA_UTILS.ADD_MESSAGE('PA', 'PA_CISI_CURRENCY_NULL');
3798 l_error_flag_local := 'Y';
3799 END IF;
3800 END IF;
3801 -- 5144288, 5144369 : End
3802 ELSIF l_req_rec.bill_rate_option = 'MARKUP' THEN
3803 -- 5144675 Changed l_req_rec.markup_percent_override <= 0 to < 0
3804 IF l_br_override_flag <> 'Y' OR l_req_rec.markup_percent_override < 0
3805 OR l_req_rec.markup_percent_override > 100 THEN
3806 IF l_br_override_flag <> 'Y' THEN
3807 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_BILL_RATE_OVRD_NA');
3808 l_error_flag_local := 'Y';
3809 ELSE
3810 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_MARKUP_PERCENT');
3811 l_error_flag_local := 'Y';
3812 END IF;
3813 END IF;
3814 ELSIF l_req_rec.bill_rate_option = 'DISCOUNT' THEN
3815 -- 5144675 Changed l_req_rec.discount_percentage <= 0 to < 0
3816 IF l_br_discount_override_flag <> 'Y' OR l_req_rec.discount_percentage < 0
3817 OR l_req_rec.discount_percentage > 100 THEN
3818 IF l_br_discount_override_flag <> 'Y' THEN
3819 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_DISC_OVRD_NA');
3820 l_error_flag_local := 'Y';
3821 ELSE
3822 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_DISCOUNT_PERCENT');
3823 l_error_flag_local := 'Y';
3824 END IF;
3825 END IF;
3826 END IF;
3827
3828 IF l_req_rec.rate_disc_reason_code IS NULL THEN
3829 IF (l_rate_discount_reason_flag ='Y' AND (l_br_override_flag ='Y' OR l_br_discount_override_flag='Y') AND
3830 (l_req_rec.bill_rate_override IS NOT NULL OR l_req_rec.markup_percent_override IS NOT NULL OR l_req_rec.discount_percentage IS NOT NULL)
3831 )
3832 THEN
3833 PA_UTILS.ADD_MESSAGE('PA', 'PA_RATE_DISC_REASON_REQUIRED');
3834 l_error_flag_local := 'Y';
3835 END IF;
3836 ELSE
3837 l_valid_flag := 'N';
3838 OPEN c_get_lookup_exists('RATE AND DISCOUNT REASON', l_req_rec.rate_disc_reason_code);
3839 FETCH c_get_lookup_exists INTO l_valid_flag;
3840 CLOSE c_get_lookup_exists;
3841 IF nvl(l_valid_flag,'N') <> 'Y' THEN
3842 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_DISC_RSN_INVALID');
3843 l_error_flag_local := 'Y';
3844 END IF;
3845 END IF;
3846
3847 IF l_debug_mode = 'Y' THEN
3848 pa_debug.write(l_module, 'After Validating Bill Rate Options l_error_flag_local='||l_error_flag_local, l_log_level);
3849 END IF;
3850 END IF; -- l_req_rec.bill_rate_option <> 'NONE'
3851
3852 -- Transfer Price Rate Options Validation
3853 -----------------------------------------
3854
3855 IF l_req_rec.tp_rate_option <> 'NONE' THEN
3856
3857 IF l_debug_mode = 'Y' THEN
3858 pa_debug.write(l_module, 'Validating Transfer Price Rate Options', l_log_level);
3859 END IF;
3860
3861 IF l_req_rec.tp_rate_option = 'RATE' THEN
3862 null; -- This validation is done internally
3863 ELSIF l_req_rec.tp_rate_option = 'BASIS' THEN
3864 IF l_debug_mode = 'Y' THEN
3865 pa_debug.write(l_module, 'Validating Transfer Price Rate Basis', l_log_level);
3866 END IF;
3867
3868 OPEN c_get_lookup_exists('CC_MARKUP_BASE_CODE', l_req_rec.tp_calc_base_code_override);
3869 FETCH c_get_lookup_exists INTO l_valid_flag;
3870 CLOSE c_get_lookup_exists;
3871
3872 IF l_debug_mode = 'Y' THEN
3873 pa_debug.write(l_module, 'After Transfer Price Rate Basis Validation', l_log_level);
3874 pa_debug.write(l_module, 'l_valid_flag='||l_valid_flag, l_log_level);
3875 END IF;
3876
3877 IF nvl(l_valid_flag,'N') <> 'Y' THEN
3878 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_TP_BASIS_INVALID');
3879 l_error_flag_local := 'Y';
3880 END IF;
3881 END IF;
3882
3883 IF l_debug_mode = 'Y' THEN
3884 pa_debug.write(l_module, 'After Validating Transfer Price Rate Options l_error_flag_local='||l_error_flag_local, l_log_level);
3885 END IF;
3886 END IF; -- l_req_rec.tp_rate_option <> 'NONE'
3887
3888 -- Res Loan Agreement Validations
3889 ---------------------------------
3890
3891 IF l_req_rec.expense_owner IS NOT NULL THEN
3892 l_valid_flag := 'N';
3893
3894 IF l_debug_mode = 'Y' THEN
3895 pa_debug.write(l_module, 'Validating Expense Owner Option', l_log_level);
3896 END IF;
3897
3898 OPEN c_get_lookup_exists('EXPENSE_OWNER_TYPE', l_req_rec.expense_owner);
3899 FETCH c_get_lookup_exists INTO l_valid_flag;
3900 CLOSE c_get_lookup_exists;
3901
3902 IF l_debug_mode = 'Y' THEN
3903 pa_debug.write(l_module, 'After Expense Owner Option Validation', l_log_level);
3904 pa_debug.write(l_module, 'l_valid_flag='||l_valid_flag, l_log_level);
3905 END IF;
3906
3907 IF nvl(l_valid_flag,'N') <> 'Y' THEN
3908 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_EXP_OWNER_INVALID');
3909 l_error_flag_local := 'Y';
3910 END IF;
3911 END IF;
3912 END IF; -- l_error_flag_local <> 'Y' AND nvl(l_req_dtls_csr.template_flag,'N') = 'N'
3913
3914 IF l_debug_mode = 'Y' THEN
3915 pa_debug.write(l_module, 'After all validations l_error_flag_local='||l_error_flag_local, l_log_level);
3916 END IF;
3917
3918 -- Flex field Validation
3919 ------------------------
3920
3921 IF l_error_flag_local <> 'Y' THEN
3922 l_return_status := FND_API.G_RET_STS_SUCCESS;
3923
3924 VALIDATE_FLEX_FIELD(
3925 p_desc_flex_name => 'PA_TEAM_ROLE_DESC_FLEX'
3926 , p_attribute_category => l_req_rec.attribute_category
3927 , px_attribute1 => l_req_rec.attribute1
3928 , px_attribute2 => l_req_rec.attribute2
3929 , px_attribute3 => l_req_rec.attribute3
3930 , px_attribute4 => l_req_rec.attribute4
3931 , px_attribute5 => l_req_rec.attribute5
3932 , px_attribute6 => l_req_rec.attribute6
3933 , px_attribute7 => l_req_rec.attribute7
3934 , px_attribute8 => l_req_rec.attribute8
3935 , px_attribute9 => l_req_rec.attribute9
3936 , px_attribute10 => l_req_rec.attribute10
3937 , px_attribute11 => l_req_rec.attribute11
3938 , px_attribute12 => l_req_rec.attribute12
3939 , px_attribute13 => l_req_rec.attribute13
3940 , px_attribute14 => l_req_rec.attribute14
3941 , px_attribute15 => l_req_rec.attribute15
3942 , x_return_status => l_return_status
3943 , x_msg_count => l_msg_count
3944 , x_msg_data => l_msg_data
3945 );
3946
3947 IF l_debug_mode = 'Y' THEN
3948 pa_debug.write(l_module, 'After Flex Field Validation l_return_status='||l_return_status, l_log_level);
3949 pa_debug.write(l_module, 'After Flex Field Validation l_msg_data='||l_msg_data, l_log_level);
3950 END IF;
3951
3952
3953 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3954 -- This message does not have toekn defined, still it is ok to pass token as the value
3955 -- returned by flex APIs because token are appended as it is
3956 PA_UTILS.ADD_MESSAGE('PA', 'PA_DFF_VALIDATION_FAILED',
3957 'MESSAGE', l_msg_data );
3958 l_error_flag_local := 'Y';
3959 END IF;
3960 END IF; -- l_error_flag_local <> 'Y'
3961
3962 -- Security Check
3963 -----------------
3964 -- The underlying API does security check of PA_ASN_BASIC_INFO_ED
3965 -- , PA_CREATE_CANDIDATES, PA_ASN_FCST_INFO_ED
3966 -- But still we need to do check here because there are some more checks required
3967 -- Also the underlying API does not consider the MISS chars
3968
3969 IF l_error_flag_local <> 'Y' AND nvl(l_req_dtls_csr.template_flag,'N') = 'N' THEN
3970 -- Project Requirement
3971
3972 IF nvl(l_req_rec.requirement_name, 'XYZ') <> nvl(l_req_dtls_csr.assignment_name, 'XYZ')
3973 OR nvl(l_req_rec.min_resource_job_level, -1) <> nvl(l_req_dtls_csr.min_resource_job_level, -1)
3974 OR nvl(l_req_rec.max_resource_job_level, -1) <> nvl(l_req_dtls_csr.max_resource_job_level, -1)
3975 OR nvl(l_req_rec.staffing_priority_code, 'XYZ') <> nvl(l_req_dtls_csr.staffing_priority_code, 'XYZ')
3976 OR nvl(l_req_rec.staffing_owner_person_id, -1) <> nvl(l_req_dtls_csr.staffing_owner_person_id, -1)
3977 OR nvl(l_req_rec.description, 'XYZ') <> nvl(l_req_dtls_csr.description, 'XYZ')
3978 OR nvl(l_req_rec.additional_information, 'XYZ') <> nvl(l_req_dtls_csr.additional_information, 'XYZ')
3979 OR nvl(l_req_rec.project_subteam_id, -1) <> nvl(l_project_subteam_id, -1)
3980 OR nvl(l_req_rec.location_id, -1) <> nvl(l_req_dtls_csr.location_id, -1)
3981 THEN
3982 l_basic_info_changed := 'Y';
3983 END IF;
3984
3985 IF nvl(l_req_rec.comp_match_weighting, -1) <> nvl(l_req_dtls_csr.competence_match_weighting, -1)
3986 OR nvl(l_req_rec.avail_match_weighting, -1) <> nvl(l_req_dtls_csr.availability_match_weighting, -1)
3987 OR nvl(l_req_rec.job_level_match_weighting, -1) <> nvl(l_req_dtls_csr.job_level_match_weighting, -1)
3988 OR nvl(l_req_rec.enable_auto_cand_nom_flag, 'XYZ') <> nvl(l_req_dtls_csr.enable_auto_cand_nom_flag, 'XYZ')
3989 OR nvl(l_req_rec.search_min_availability, -1) <> nvl(l_req_dtls_csr.search_min_availability, -1)
3990 OR nvl(l_req_rec.search_exp_org_str_ver_id, -1) <> nvl(l_req_dtls_csr.search_exp_org_struct_ver_id, -1)
3991 OR nvl(l_req_rec.search_exp_start_org_id, -1) <> nvl(l_req_dtls_csr.search_exp_start_org_id, -1)
3992 OR nvl(l_req_rec.search_country_code, 'XYZ') <> nvl(l_req_dtls_csr.search_country_code, 'XYZ')
3993 OR nvl(l_req_rec.search_min_candidate_score, -1) <> nvl(l_req_dtls_csr.search_min_candidate_score, -1)
3994 THEN
3995 l_candidate_info_changed := 'Y';
3996 END IF;
3997
3998 IF nvl(l_req_rec.extension_possible, 'XYZ') <> nvl(l_req_dtls_csr.extension_possible, 'XYZ')
3999 OR nvl(l_req_rec.expense_owner, 'XYZ') <> nvl(l_req_dtls_csr.expense_owner, 'XYZ')
4000 OR nvl(l_req_rec.expense_limit, -1) <> nvl(l_req_dtls_csr.expense_limit, -1)
4001 OR nvl(l_req_rec.expenditure_org_id, -1) <> nvl(l_req_dtls_csr.expenditure_org_id, -1)
4002 OR nvl(l_req_rec.expenditure_organization_id, -1) <> nvl(l_req_dtls_csr.expenditure_organization_id, -1)
4003 OR nvl(l_req_rec.expenditure_type_class, 'XYZ') <> nvl(l_req_dtls_csr.expenditure_type_class, 'XYZ')
4004 OR nvl(l_req_rec.fcst_job_group_id, -1) <> nvl(l_req_dtls_csr.fcst_job_group_id, -1)
4005 OR nvl(l_req_rec.fcst_job_id, -1) <> nvl(l_req_dtls_csr.fcst_job_id, -1)
4006 OR nvl(l_req_rec.work_type_id, -1) <> nvl(l_req_dtls_csr.work_type_id, -1)
4007 THEN
4008 l_fin_info_changed := 'Y';
4009 END IF;
4010
4011 IF nvl(l_req_rec.bill_rate_override, -1) <> nvl(l_req_dtls_csr.bill_rate_override, -1)
4012 OR nvl(l_req_rec.bill_rate_curr_override, 'XYZ') <> nvl(l_req_dtls_csr.bill_rate_curr_override, 'XYZ')
4013 OR nvl(l_req_rec.markup_percent_override, -1) <> nvl(l_req_dtls_csr.markup_percent_override, -1)
4014 OR nvl(l_req_rec.discount_percentage, -1) <> nvl(l_req_dtls_csr.discount_percentage, -1)
4015 OR nvl(l_req_rec.rate_disc_reason_code, 'XYZ') <> nvl(l_req_dtls_csr.rate_disc_reason_code, 'XYZ')
4016 THEN
4017 l_fin_bill_rate_info_changed := 'Y';
4018 END IF;
4019
4020 IF nvl(l_req_rec.tp_rate_override, -1) <> nvl(l_req_dtls_csr.tp_rate_override, -1)
4021 OR nvl(l_req_rec.tp_currency_override, 'XYZ') <> nvl(l_req_dtls_csr.tp_currency_override, 'XYZ')
4022 OR nvl(l_req_rec.tp_percent_applied_override, -1) <> nvl(l_req_dtls_csr.tp_percent_applied_override, -1)
4023 OR nvl(l_req_rec.tp_calc_base_code_override, 'XYZ') <> nvl(l_req_dtls_csr.tp_calc_base_code_override, 'XYZ')
4024 THEN
4025 l_fin_tp_rate_info_changed := 'Y';
4026 END IF;
4027
4028
4029 IF l_basic_info_changed = 'Y' THEN
4030
4031 l_return_status := FND_API.G_RET_STS_SUCCESS;
4032 l_ret_code := 'T';
4033 l_privilege := 'PA_ASN_BASIC_INFO_ED';
4034 l_object_name := 'PA_PROJECTS';
4035 l_object_key := l_req_rec.project_id;
4036
4037 IF l_debug_mode = 'Y' THEN
4038 pa_debug.write(l_module, 'Checking Project Level Security for PA_ASN_BASIC_INFO_ED', l_log_level);
4039 END IF ;
4040
4041 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4042 x_ret_code => l_ret_code
4043 , x_return_status => l_return_status
4044 , x_msg_count => l_msg_count
4045 , x_msg_data => l_msg_data
4046 , p_privilege => l_privilege
4047 , p_object_name => l_object_name
4048 , p_object_key => l_object_key
4049 , p_init_msg_list => FND_API.G_FALSE);
4050
4051 IF l_debug_mode = 'Y' THEN
4052 pa_debug.write(l_module, 'Project Level Security for PA_ASN_BASIC_INFO_ED l_ret_code '|| l_ret_code , l_log_level);
4053 pa_debug.write(l_module, 'Project Level Security for PA_ASN_BASIC_INFO_ED l_return_status '|| l_return_status , l_log_level);
4054 END IF ;
4055
4056 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4057
4058 IF l_debug_mode = 'Y' THEN
4059 pa_debug.write(l_module,'Checking Requirement Level Security for PA_ASN_BASIC_INFO_ED', l_log_level);
4060 END IF ;
4061
4062 l_return_status := FND_API.G_RET_STS_SUCCESS;
4063 l_ret_code := 'T';
4064 l_privilege := 'PA_ASN_BASIC_INFO_ED';
4065 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
4066 l_object_key := l_req_rec.requirement_id;
4067
4068 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4069 x_ret_code => l_ret_code
4070 , x_return_status => l_return_status
4071 , x_msg_count => l_msg_count
4072 , x_msg_data => l_msg_data
4073 , p_privilege => l_privilege
4074 , p_object_name => l_object_name
4075 , p_object_key => l_object_key
4076 , p_init_msg_list => FND_API.G_FALSE );
4077
4078 IF l_debug_mode = 'Y' THEN
4079 pa_debug.write(l_module,'Requirement Level Security for PA_ASN_BASIC_INFO_ED l_ret_code='||l_ret_code, l_log_level);
4080 pa_debug.write(l_module,'Requirement Level Security for PA_ASN_BASIC_INFO_ED l_return_status='||l_return_status, l_log_level);
4081 END IF ;
4082 END IF;
4083
4084 IF nvl(l_ret_code,'F') <> 'T' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4085 PA_UTILS.ADD_MESSAGE('PA', 'PA_UPD_ASGN_BASIC_INFO'
4086 ,'MISSING_PRIVILEGE', l_privilege);
4087 l_error_flag_local := 'Y';
4088 END IF;
4089
4090 END IF;-- l_basic_info_changed = 'Y'
4091
4092 IF l_candidate_info_changed = 'Y' THEN
4093
4094 l_return_status := FND_API.G_RET_STS_SUCCESS;
4095 l_ret_code := 'T';
4096 l_privilege := 'PA_CREATE_CANDIDATES';
4097 l_object_name := 'PA_PROJECTS';
4098 l_object_key := l_req_rec.project_id;
4099
4100 IF l_debug_mode = 'Y' THEN
4101 pa_debug.write(l_module, 'Checking Project Level Security for PA_CREATE_CANDIDATES', l_log_level);
4102 END IF ;
4103
4104 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4105 x_ret_code => l_ret_code
4106 , x_return_status => l_return_status
4107 , x_msg_count => l_msg_count
4108 , x_msg_data => l_msg_data
4109 , p_privilege => l_privilege
4110 , p_object_name => l_object_name
4111 , p_object_key => l_object_key
4112 , p_init_msg_list => FND_API.G_FALSE);
4113
4114 IF l_debug_mode = 'Y' THEN
4115 pa_debug.write(l_module, 'Project Level Security for PA_CREATE_CANDIDATES l_ret_code '|| l_ret_code , l_log_level);
4116 pa_debug.write(l_module, 'Project Level Security for PA_CREATE_CANDIDATES l_return_status '|| l_return_status , l_log_level);
4117 END IF ;
4118
4119 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4120
4121 IF l_debug_mode = 'Y' THEN
4122 pa_debug.write(l_module,'Checking Requirement Level Security for PA_CREATE_CANDIDATES', l_log_level);
4123 END IF ;
4124
4125 l_return_status := FND_API.G_RET_STS_SUCCESS;
4126 l_ret_code := 'T';
4127 l_privilege := 'PA_CREATE_CANDIDATES';
4128 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
4129 l_object_key := l_req_rec.requirement_id;
4130
4131 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4132 x_ret_code => l_ret_code
4133 , x_return_status => l_return_status
4134 , x_msg_count => l_msg_count
4135 , x_msg_data => l_msg_data
4136 , p_privilege => l_privilege
4137 , p_object_name => l_object_name
4138 , p_object_key => l_object_key
4139 , p_init_msg_list => FND_API.G_FALSE );
4140
4141 IF l_debug_mode = 'Y' THEN
4142 pa_debug.write(l_module,'Requirement Level Security for PA_CREATE_CANDIDATES l_ret_code='||l_ret_code, l_log_level);
4143 pa_debug.write(l_module,'Requirement Level Security for PA_CREATE_CANDIDATES l_return_status='||l_return_status, l_log_level);
4144 END IF ;
4145 END IF;
4146
4147 IF nvl(l_ret_code,'F') <> 'T' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4148 PA_UTILS.ADD_MESSAGE('PA', 'PA_UPD_ASGN_CANDIDATE'
4149 ,'MISSING_PRIVILEGE', l_privilege);
4150 l_error_flag_local := 'Y';
4151 END IF;
4152
4153 END IF;-- l_candidate_info_changed = 'Y'
4154
4155 IF l_fin_info_changed = 'Y' OR l_fin_bill_rate_info_changed = 'Y' OR l_fin_tp_rate_info_changed = 'Y' THEN
4156
4157 l_return_status := FND_API.G_RET_STS_SUCCESS;
4158 l_ret_code := 'T';
4159 l_privilege := 'PA_ASN_FCST_INFO_ED';
4160 l_object_name := 'PA_PROJECTS';
4161 l_object_key := l_req_rec.project_id;
4162
4163 IF l_debug_mode = 'Y' THEN
4164 pa_debug.write(l_module, 'Checking Project Level Security for PA_ASN_FCST_INFO_ED', l_log_level);
4165 END IF ;
4166
4167 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4168 x_ret_code => l_ret_code
4169 , x_return_status => l_return_status
4170 , x_msg_count => l_msg_count
4171 , x_msg_data => l_msg_data
4172 , p_privilege => l_privilege
4173 , p_object_name => l_object_name
4174 , p_object_key => l_object_key
4175 , p_init_msg_list => FND_API.G_FALSE);
4176
4177 IF l_debug_mode = 'Y' THEN
4178 pa_debug.write(l_module, 'Project Level Security for PA_ASN_FCST_INFO_ED l_ret_code '|| l_ret_code , l_log_level);
4179 pa_debug.write(l_module, 'Project Level Security for PA_ASN_FCST_INFO_ED l_return_status '|| l_return_status , l_log_level);
4180 END IF ;
4181
4182 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4183
4184 IF l_debug_mode = 'Y' THEN
4185 pa_debug.write(l_module,'Checking Requirement Level Security for PA_CREATE_CANDIDATES', l_log_level);
4186 END IF ;
4187
4188 l_return_status := FND_API.G_RET_STS_SUCCESS;
4189 l_ret_code := 'T';
4190 l_privilege := 'PA_ASN_FCST_INFO_ED';
4191 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
4192 l_object_key := l_req_rec.requirement_id;
4193
4194 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4195 x_ret_code => l_ret_code
4196 , x_return_status => l_return_status
4197 , x_msg_count => l_msg_count
4198 , x_msg_data => l_msg_data
4199 , p_privilege => l_privilege
4200 , p_object_name => l_object_name
4201 , p_object_key => l_object_key
4202 , p_init_msg_list => FND_API.G_FALSE );
4203
4204 IF l_debug_mode = 'Y' THEN
4205 pa_debug.write(l_module,'Requirement Level Security for PA_ASN_FCST_INFO_ED l_ret_code='||l_ret_code, l_log_level);
4206 pa_debug.write(l_module,'Requirement Level Security for PA_ASN_FCST_INFO_ED l_return_status='||l_return_status, l_log_level);
4207 END IF ;
4208 END IF;
4209
4210 IF nvl(l_ret_code,'F') <> 'T' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4211 PA_UTILS.ADD_MESSAGE('PA', 'PA_UPD_ASGN_FIN_INFO'
4212 ,'MISSING_PRIVILEGE', l_privilege);
4213 l_error_flag_local := 'Y';
4214 END IF;
4215
4216 END IF;-- l_fin_info_changed = 'Y' OR l_fin_bill_rate_info_changed = 'Y' OR l_fin_tp_rate_info_changed = 'Y'
4217
4218
4219 IF l_fin_bill_rate_info_changed = 'Y' THEN
4220
4221 l_return_status := FND_API.G_RET_STS_SUCCESS;
4222 l_ret_code := 'T';
4223 l_privilege := 'PA_ASN_FCST_INFO_BILL_ED';
4224 l_object_name := 'PA_PROJECTS';
4225 l_object_key := l_req_rec.project_id;
4226
4227 IF l_debug_mode = 'Y' THEN
4228 pa_debug.write(l_module, 'Checking Project Level Security for PA_ASN_FCST_INFO_BILL_ED', l_log_level);
4229 END IF ;
4230
4231 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4232 x_ret_code => l_ret_code
4233 , x_return_status => l_return_status
4234 , x_msg_count => l_msg_count
4235 , x_msg_data => l_msg_data
4236 , p_privilege => l_privilege
4237 , p_object_name => l_object_name
4238 , p_object_key => l_object_key
4239 , p_init_msg_list => FND_API.G_FALSE);
4240
4241 IF l_debug_mode = 'Y' THEN
4242 pa_debug.write(l_module, 'Project Level Security for PA_ASN_FCST_INFO_BILL_ED l_ret_code '|| l_ret_code , l_log_level);
4243 pa_debug.write(l_module, 'Project Level Security for PA_ASN_FCST_INFO_BILL_ED l_return_status '|| l_return_status , l_log_level);
4244 END IF ;
4245
4246 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4247
4248 IF l_debug_mode = 'Y' THEN
4249 pa_debug.write(l_module,'Checking Requirement Level Security for PA_ASN_FCST_INFO_BILL_ED', l_log_level);
4250 END IF ;
4251
4252 l_return_status := FND_API.G_RET_STS_SUCCESS;
4253 l_ret_code := 'T';
4254 l_privilege := 'PA_ASN_FCST_INFO_BILL_ED';
4255 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
4256 l_object_key := l_req_rec.requirement_id;
4257
4258 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4259 x_ret_code => l_ret_code
4260 , x_return_status => l_return_status
4261 , x_msg_count => l_msg_count
4262 , x_msg_data => l_msg_data
4263 , p_privilege => l_privilege
4264 , p_object_name => l_object_name
4265 , p_object_key => l_object_key
4266 , p_init_msg_list => FND_API.G_FALSE );
4267
4268 IF l_debug_mode = 'Y' THEN
4269 pa_debug.write(l_module,'Requirement Level Security for PA_ASN_FCST_INFO_BILL_ED l_ret_code='||l_ret_code, l_log_level);
4270 pa_debug.write(l_module,'Requirement Level Security for PA_ASN_FCST_INFO_BILL_ED l_return_status='||l_return_status, l_log_level);
4271 END IF ;
4272 END IF;
4273
4274 IF nvl(l_ret_code,'F') <> 'T' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4275 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_UPD_ASGN_BR_INFO'
4276 ,'MISSING_PRIVILEGE', l_privilege);
4277 l_error_flag_local := 'Y';
4278 END IF;
4279
4280 END IF;-- l_fin_bill_rate_info_changed = 'Y'
4281
4282 IF l_fin_tp_rate_info_changed = 'Y' THEN
4283
4284 l_return_status := FND_API.G_RET_STS_SUCCESS;
4285 l_ret_code := 'T';
4286 l_privilege := 'PA_ASN_FCST_INFO_TP_ED';
4287 l_object_name := 'PA_PROJECTS';
4288 l_object_key := l_req_rec.project_id;
4289
4290 IF l_debug_mode = 'Y' THEN
4291 pa_debug.write(l_module, 'Checking Project Level Security for PA_ASN_FCST_INFO_TP_ED', l_log_level);
4292 END IF ;
4293
4294 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4295 x_ret_code => l_ret_code
4296 , x_return_status => l_return_status
4297 , x_msg_count => l_msg_count
4298 , x_msg_data => l_msg_data
4299 , p_privilege => l_privilege
4300 , p_object_name => l_object_name
4301 , p_object_key => l_object_key
4302 , p_init_msg_list => FND_API.G_FALSE);
4303
4304 IF l_debug_mode = 'Y' THEN
4305 pa_debug.write(l_module, 'Project Level Security for PA_ASN_FCST_INFO_TP_ED l_ret_code '|| l_ret_code , l_log_level);
4306 pa_debug.write(l_module, 'Project Level Security for PA_ASN_FCST_INFO_TP_ED l_return_status '|| l_return_status , l_log_level);
4307 END IF ;
4308
4309 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4310
4311 IF l_debug_mode = 'Y' THEN
4312 pa_debug.write(l_module,'Checking Requirement Level Security for PA_ASN_FCST_INFO_TP_ED', l_log_level);
4313 END IF ;
4314
4315 l_return_status := FND_API.G_RET_STS_SUCCESS;
4316 l_ret_code := 'T';
4317 l_privilege := 'PA_ASN_FCST_INFO_TP_ED';
4318 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
4319 l_object_key := l_req_rec.requirement_id;
4320
4321 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4322 x_ret_code => l_ret_code
4323 , x_return_status => l_return_status
4324 , x_msg_count => l_msg_count
4325 , x_msg_data => l_msg_data
4326 , p_privilege => l_privilege
4327 , p_object_name => l_object_name
4328 , p_object_key => l_object_key
4329 , p_init_msg_list => FND_API.G_FALSE );
4330
4331 IF l_debug_mode = 'Y' THEN
4332 pa_debug.write(l_module,'Requirement Level Security for PA_ASN_FCST_INFO_TP_ED l_ret_code='||l_ret_code, l_log_level);
4333 pa_debug.write(l_module,'Requirement Level Security for PA_ASN_FCST_INFO_TP_ED l_return_status='||l_return_status, l_log_level);
4334 END IF ;
4335 END IF;
4336
4337 IF nvl(l_ret_code,'F') <> 'T' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4338 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_UPD_ASGN_TP_INFO'
4339 ,'MISSING_PRIVILEGE', l_privilege);
4340 l_error_flag_local := 'Y';
4341 END IF;
4342 END IF;-- l_fin_tp_rate_info_changed = 'Y'
4343 ELSIF l_error_flag_local <> 'Y' AND nvl(l_req_dtls_csr.template_flag,'N') = 'Y' THEN
4344 -- Template Requirement
4345 l_return_status := FND_API.G_RET_STS_SUCCESS;
4346 l_ret_code := 'T';
4347 l_privilege := 'PA_PRM_DEFINE_TEAM_TEMPLATE';
4348 l_object_name := null;
4349 l_object_key := null;
4350
4351 IF l_debug_mode = 'Y' THEN
4352 pa_debug.write(l_module,'Checking Team template security', l_log_level);
4353 END IF ;
4354
4355 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4356 x_ret_code => l_ret_code
4357 , x_return_status => l_return_status
4358 , x_msg_count => l_msg_count
4359 , x_msg_data => l_msg_data
4360 , p_privilege => l_privilege
4361 , p_object_name => l_object_name
4362 , p_object_key => l_object_key
4363 , p_init_msg_list => FND_API.G_FALSE );
4364
4365 IF l_debug_mode = 'Y' THEN
4366 pa_debug.write(l_module,'Team Template Security l_ret_code='||l_ret_code, l_log_level);
4367 pa_debug.write(l_module,'Team Template Security l_return_status='||l_return_status, l_log_level);
4368 END IF ;
4369
4370 IF nvl(l_ret_code,'F') <> 'T' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4371 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_UPD'
4372 ,'MISSING_PRIVILEGE', l_privilege);
4373 l_error_flag_local := 'Y';
4374 END IF;
4375 END IF; -- l_error_flag_local <> 'Y' AND nvl(l_req_dtls_csr.template_flag,'N') = 'N'
4376
4377
4378 -- Call Core Actual API
4379 -----------------------
4380
4381 IF l_error_flag_local <> 'Y' THEN
4382 l_return_status := FND_API.G_RET_STS_SUCCESS;
4383
4384 IF l_debug_mode = 'Y' THEN
4385 pa_debug.write(l_module, 'Calling PA_ASSIGNMENTS_PUB.EXECUTE_UPDATE_REQUIREMENT for Record#'||i, l_log_level);
4386 END IF;
4387
4388
4389 PA_ASSIGNMENTS_PUB.EXECUTE_UPDATE_REQUIREMENT
4390 (
4391 p_api_version => p_api_version_number
4392 , p_init_msg_list => l_init_msg_list
4393 , p_commit => l_commit
4394 , p_validate_only => l_validate_only
4395 , p_asgn_update_mode => l_asgn_update_mode
4396 , p_assignment_id => l_req_rec.requirement_id
4397 , p_assignment_name => l_req_rec.requirement_name
4398 -- , p_assignment_number =>
4399 , p_assignment_type => l_assignment_type
4400 , p_assignment_template_id => l_req_rec.team_template_id
4401 -- , p_source_assignment_id => l_req_dtls_csr.source_assignment_id
4402 -- , p_number_of_requirements => l_req_rec.number_of_requirements
4403 , p_project_role_id => l_req_rec.project_role_id
4404 , p_project_role_name => l_req_rec.project_role_name
4405 , p_project_id => l_req_rec.project_id
4406 -- , p_project_name => l_req_rec.project_name
4407 , p_project_number => l_req_rec.project_number
4408 -- , p_resource_id =>
4409 -- , p_project_party_id =>
4410 -- , p_resource_name =>
4411 -- , p_resource_source_id => null
4412 , p_staffing_owner_person_id => l_req_rec.staffing_owner_person_id
4413 -- , p_staffing_owner_name =>
4414 , p_staffing_priority_code => l_req_rec.staffing_priority_code
4415 , p_staffing_priority_name => l_req_rec.staffing_priority_name
4416 , p_project_subteam_id => l_req_rec.project_subteam_id
4417 , p_project_subteam_name => l_req_rec.project_subteam_name
4418 , p_project_subteam_party_id => l_project_subteam_party_id
4419 , p_location_id => l_req_rec.location_id
4420 , p_location_city => l_req_rec.location_city
4421 , p_location_region => l_req_rec.location_region
4422 , p_location_country_name => l_req_rec.location_country_name
4423 , p_location_country_code => l_req_rec.location_country_code
4424 , p_min_resource_job_level => l_req_rec.min_resource_job_level
4425 , p_max_resource_job_level => l_req_rec.max_resource_job_level
4426 , p_description => l_req_rec.description
4427 , p_additional_information => l_req_rec.additional_information
4428 , p_start_date => l_req_rec.start_date
4429 , p_end_date => l_req_rec.end_date
4430 , p_status_code => l_req_rec.status_code
4431 , p_project_status_name => l_req_rec.status_name
4432 , p_multiple_status_flag => l_req_dtls_csr.multiple_status_flag
4433 -- , p_assignment_effort =>
4434 -- , p_resource_list_member_id => l_req_dtls_csr.resource_list_member_id
4435 -- , p_budget_version_id =>
4436 -- , p_sum_tasks_flag =>
4437 -- , p_calendar_type => l_req_rec.calendar_type
4438 , p_calendar_id => l_req_rec.calendar_id
4439 , p_calendar_name => l_req_rec.calendar_name
4440 -- , p_start_adv_action_set_flag => l_req_rec.start_adv_action_set_flag
4441 -- , p_adv_action_set_id => l_req_rec.adv_action_set_id
4442 -- , p_adv_action_set_name => l_req_rec.adv_action_set_name
4443 -- As of now internal code does not support setting the candidate search options
4444 -- at create time. It can only be updated.
4445 , p_comp_match_weighting => l_req_rec.comp_match_weighting
4446 , p_avail_match_weighting => l_req_rec.avail_match_weighting
4447 , p_job_level_match_weighting => l_req_rec.job_level_match_weighting
4448 , p_enable_auto_cand_nom_flag => l_req_rec.enable_auto_cand_nom_flag
4449 , p_search_min_availability => l_req_rec.search_min_availability
4450 , p_search_exp_org_struct_ver_id => l_req_rec.search_exp_org_str_ver_id
4451 , p_search_exp_org_hier_name => l_req_rec.search_exp_org_hier_name
4452 , p_search_exp_start_org_id => l_req_rec.search_exp_start_org_id
4453 , p_search_exp_start_org_name => l_req_rec.search_exp_start_org_name
4454 , p_search_country_code => l_req_rec.search_country_code
4455 , p_search_country_name => l_req_rec.search_country_name
4456 , p_search_min_candidate_score => l_req_rec.search_min_candidate_score
4457 , p_expenditure_org_id => l_req_rec.expenditure_org_id
4458 , p_expenditure_org_name => l_req_rec.expenditure_org_name
4459 , p_expenditure_organization_id => l_req_rec.expenditure_organization_id
4460 , p_exp_organization_name => l_req_rec.expenditure_organization_name
4461 , p_expenditure_type_class => l_req_rec.expenditure_type_class
4462 , p_expenditure_type => l_req_rec.expenditure_type
4463 , p_fcst_job_group_id => l_req_rec.fcst_job_group_id
4464 , p_fcst_job_group_name => l_req_rec.fcst_job_group_name
4465 , p_fcst_job_id => l_req_rec.fcst_job_id
4466 , p_fcst_job_name => l_req_rec.fcst_job_name
4467 -- , p_fcst_tp_amount_type => l_req_rec.fcst_tp_amount_type
4468 , p_work_type_id => l_req_rec.work_type_id
4469 , p_work_type_name => l_req_rec.work_type_name
4470 , p_bill_rate_override => l_req_rec.bill_rate_override
4471 , p_bill_rate_curr_override => l_req_rec.bill_rate_curr_override
4472 , p_markup_percent_override => l_req_rec.markup_percent_override
4473 , p_discount_percentage => l_req_rec.discount_percentage
4474 , p_rate_disc_reason_code => l_req_rec.rate_disc_reason_code
4475 , p_tp_rate_override => l_req_rec.tp_rate_override
4476 , p_tp_currency_override => l_req_rec.tp_currency_override
4477 , p_tp_calc_base_code_override => l_req_rec.tp_calc_base_code_override
4478 , p_tp_percent_applied_override => l_req_rec.tp_percent_applied_override
4479 , p_extension_possible => l_req_rec.extension_possible
4480 , p_expense_owner => l_req_rec.expense_owner
4481 , p_expense_limit => l_req_rec.expense_limit
4482 , p_expense_limit_currency_code => l_req_dtls_csr.expense_limit_currency_code
4483 , p_revenue_currency_code => l_req_dtls_csr.revenue_currency_code
4484 , p_revenue_bill_rate => l_req_dtls_csr.revenue_bill_rate
4485 , p_markup_percent => l_req_dtls_csr.markup_percent
4486 -- , p_resource_calendar_percent =>
4487 , p_record_version_number => l_req_rec.record_version_number
4488 , p_attribute_category => l_req_rec.attribute_category
4489 , p_attribute1 => l_req_rec.attribute1
4490 , p_attribute2 => l_req_rec.attribute2
4491 , p_attribute3 => l_req_rec.attribute3
4492 , p_attribute4 => l_req_rec.attribute4
4493 , p_attribute5 => l_req_rec.attribute5
4494 , p_attribute6 => l_req_rec.attribute6
4495 , p_attribute7 => l_req_rec.attribute7
4496 , p_attribute8 => l_req_rec.attribute8
4497 , p_attribute9 => l_req_rec.attribute9
4498 , p_attribute10 => l_req_rec.attribute10
4499 , p_attribute11 => l_req_rec.attribute11
4500 , p_attribute12 => l_req_rec.attribute12
4501 , p_attribute13 => l_req_rec.attribute13
4502 , p_attribute14 => l_req_rec.attribute14
4503 , p_attribute15 => l_req_rec.attribute15
4504 , x_return_status => l_return_status
4505 , x_msg_count => l_msg_count
4506 , x_msg_data => l_msg_data
4507 );
4508
4509 IF l_debug_mode = 'Y' THEN
4510 pa_debug.write(l_module, 'After call PA_ASSIGNMENTS_PUB.EXECUTE_CREATE_ASSIGNMENT l_return_status='||l_return_status, l_log_level);
4511 END IF;
4512
4513 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4514 --l_error_flag := 'Y';
4515 l_error_flag_local := 'Y';
4516 ELSE
4517 IF l_debug_mode = 'Y' THEN
4518 pa_debug.write(l_module, 'Updating Original System Code and Reference', l_log_level);
4519 END IF;
4520
4521 IF l_req_rec.orig_system_code IS NOT NULL OR l_req_rec.orig_system_reference IS NOT NULL THEN
4522 UPDATE PA_PROJECT_ASSIGNMENTS
4523 SET orig_system_code = decode(l_req_rec.orig_system_code, null, orig_system_code, l_req_rec.orig_system_code)
4524 , orig_system_reference = decode(l_req_rec.orig_system_reference, null, orig_system_reference, l_req_rec.orig_system_reference)
4525 WHERE assignment_id = l_req_rec.requirement_id;
4526 END IF;
4527
4528 IF l_debug_mode = 'Y' THEN
4529 pa_debug.write(l_module, 'After Updating Original System Code and Reference', l_log_level);
4530 END IF;
4531 END IF;
4532 END IF;
4533
4534 l_end_msg_count := FND_MSG_PUB.count_msg;
4535 IF l_debug_mode = 'Y' THEN
4536 pa_debug.write(l_module, 'l_start_msg_count='||l_start_msg_count, l_log_level);
4537 pa_debug.write(l_module, 'l_end_msg_count='||l_end_msg_count, l_log_level);
4538 END IF;
4539 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
4540
4541 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
4542 l_error_flag := 'Y';
4543
4544 IF l_debug_mode = 'Y' THEN
4545 pa_debug.write(l_module, 'Repopulating Error Message Stack', l_log_level);
4546 END IF;
4547
4548 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
4549 -- Always get from first location in stack i.e. l_start_msg_count+1
4550 -- Because stack moves down after delete
4551 FND_MSG_PUB.get (
4552 p_msg_index => l_start_msg_count+1,
4553 p_encoded => FND_API.G_FALSE,
4554 p_data => l_data,
4555 p_msg_index_out => l_msg_index_out );
4556
4557 -- Always delete at first location in stack i.e. l_start_msg_count+1
4558 -- Because stack moves down after delete
4559 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
4560
4561 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
4562 'RECORD_NO', i,
4563 'MESSAGE', l_data);
4564 END LOOP;
4565 IF l_debug_mode = 'Y' THEN
4566 pa_debug.write(l_module, 'After Repopulating Error Message Stack', l_log_level);
4567 END IF;
4568 END IF;
4569 i := p_requirement_in_tbl.next(i);
4570 END LOOP;
4571
4572 IF l_debug_mode = 'Y' THEN
4573 pa_debug.write(l_module, 'All records are done', l_log_level);
4574 pa_debug.write(l_module, 'l_error_flag='||l_error_flag, l_log_level);
4575 pa_debug.write(l_module, 'FND_MSG_PUB.count_msg='||FND_MSG_PUB.count_msg, l_log_level);
4576 END IF;
4577
4578 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
4579 RAISE FND_API.G_EXC_ERROR;
4580 END IF;
4581
4582 IF l_debug_mode = 'Y' THEN
4583 PA_DEBUG.reset_curr_function;
4584 END IF;
4585
4586 IF p_commit = FND_API.G_TRUE THEN
4587 commit;
4588 END IF;
4589
4590
4591 EXCEPTION
4592 WHEN FND_API.G_EXC_ERROR THEN
4593 x_return_status := FND_API.G_RET_STS_ERROR;
4594 l_msg_count := FND_MSG_PUB.count_msg;
4595
4596 IF p_commit = FND_API.G_TRUE THEN
4597 ROLLBACK TO UPDATE_REQUIREMENTS_SP;
4598 END IF;
4599
4600 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
4601 PA_INTERFACE_UTILS_PUB.get_messages
4602 ( p_encoded => FND_API.G_FALSE
4603 , p_msg_index => 1
4604 , p_msg_count => l_msg_count
4605 , p_msg_data => l_msg_data
4606 , p_data => l_data
4607 , p_msg_index_out => l_msg_index_out);
4608
4609 x_msg_data := l_data;
4610 x_msg_count := l_msg_count;
4611 ELSE
4612 x_msg_count := l_msg_count;
4613 END IF;
4614
4615 IF l_debug_mode = 'Y' THEN
4616 Pa_Debug.reset_curr_function;
4617 END IF;
4618
4619 WHEN OTHERS THEN
4620
4621 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4622 x_msg_data := SQLERRM;
4623
4624 IF p_commit = FND_API.G_TRUE THEN
4625 ROLLBACK TO UPDATE_REQUIREMENTS_SP;
4626 END IF;
4627
4628 FND_MSG_PUB.add_exc_msg
4629 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
4630 , p_procedure_name => 'UPDATE_REQUIREMENTS'
4631 , p_error_text => x_msg_data);
4632
4633 x_msg_count := FND_MSG_PUB.count_msg;
4634
4635 IF l_debug_mode = 'Y' THEN
4636 PA_DEBUG.reset_curr_function;
4637 END IF;
4638 RAISE;
4639 END UPDATE_REQUIREMENTS;
4640
4641 -- Start of comments
4642 -- API name : DELETE_REQUIREMENTS
4643 -- Type : Public
4644 -- Pre-reqs : None.
4645 -- Function : This API is a public API to delete one or more requirements for one or more projects.
4646 -- Usage : This API will be called from AMG.
4647 -- Parameters :
4648 -- IN : p_commit IN VARCHAR2
4649 -- Identifier to commit the transaction.
4650 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
4651 -- p_init_msg_list IN VARCHAR2
4652 -- Identifier to initialize the error message stack.
4653 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
4654 -- p_api_version_number IN NUMBER Required
4655 -- To be compliant with Applications API coding standards.
4656 -- p_requirement_in_tbl IN REQUIREMENT_IN_TBL_TYPE Required
4657 -- Table of requirement records. Please see the REQUIREMENT_IN_TBL_TYPE datatype table.
4658 -- OUT :
4659 -- x_return_status OUT VARCHAR2
4660 -- Indicates the return status of the API.
4661 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
4662 -- x_msg_count OUT NUMBER
4663 -- Indicates the number of error messages in the message stack
4664 -- x_msg_data OUT VARCHAR2
4665 -- Indicates the error message text if only one error exists
4666 -- History :
4667 -- 01-Mar-2006 - avaithia - Created
4668 -- End of comments
4669 PROCEDURE DELETE_REQUIREMENTS
4670 (
4671 p_api_version_number IN NUMBER := 1.0
4672 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
4673 , p_commit IN VARCHAR2 := FND_API.G_FALSE
4674 , p_requirement_in_tbl IN REQUIREMENT_IN_TBL_TYPE
4675 , x_return_status OUT NOCOPY VARCHAR2
4676 , x_msg_count OUT NOCOPY NUMBER
4677 , x_msg_data OUT NOCOPY VARCHAR2
4678 )
4679 IS
4680 l_calling_application VARCHAR2(10) := 'PLSQL';
4681 l_calling_module VARCHAR2(10) := 'AMG';
4682 l_check_id_flag VARCHAR2(1) := 'Y';
4683 l_check_role_security_flag VARCHAR2(1) := 'Y';
4684 l_check_resource_security_flag VARCHAR2(1) := 'Y';
4685
4686 l_log_level NUMBER := 3;
4687 l_module VARCHAR2(100) := 'PA_RES_MANAGEMENT_AMG_PUB.DELETE_REQUIREMENTS';
4688 l_commit VARCHAR2(1) := FND_API.G_FALSE;
4689 l_init_msg_list VARCHAR2(1) := FND_API.G_FALSE;
4690 l_validate_only VARCHAR2(1) := FND_API.G_FALSE;
4691
4692 l_msg_count NUMBER;
4693 l_msg_data VARCHAR2(2000);
4694 l_msg_index_out NUMBER;
4695 l_data VARCHAR2(2000);
4696 l_debug_mode VARCHAR2(1);
4697
4698 i NUMBER;
4699
4700 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
4701 l_error_flag VARCHAR2(1) := 'N';
4702 l_error_flag_local VARCHAR2(1) := 'N';
4703
4704 l_req_rec REQUIREMENT_IN_REC_TYPE;
4705
4706 l_dummy_code VARCHAR2(30);
4707 l_loop_msg_count NUMBER :=0;
4708 l_start_msg_count NUMBER :=0;
4709 l_end_msg_count NUMBER :=0;
4710
4711 l_missing_params VARCHAR2(1000);
4712 l_privilege VARCHAR2(30);
4713 l_object_name VARCHAR2(30);
4714 l_object_key NUMBER;
4715 l_error_message_code VARCHAR2(30);
4716 l_ret_code VARCHAR2(1);
4717
4718 l_assignment_number NUMBER;
4719 l_assignment_row_id ROWID;
4720 l_assignment_type VARCHAR2(30) := 'OPEN_ASSIGNMENT';
4721 l_record_version_number NUMBER;
4722 l_assignment_id NUMBER;
4723 l_project_id NUMBER;
4724 l_team_template_id NUMBER;
4725 l_status_code VARCHAR2(30);
4726 l_system_status_code VARCHAR2(30);
4727
4728 CURSOR c_derive_values(p_requirement_id IN NUMBER) IS
4729 SELECT ROWID,project_id,record_version_number,ASSIGNMENT_TEMPLATE_ID,assignment_number,status_code
4730 FROM pa_project_assignments
4731 WHERE assignment_id = p_requirement_id
4732 AND ASSIGNMENT_TYPE = l_assignment_type ;
4733
4734 CURSOR c_get_system_status IS
4735 SELECT PROJECT_SYSTEM_STATUS_CODE
4736 FROM pa_project_statuses
4737 WHERE project_status_code = l_status_code
4738 AND status_type = 'OPEN_ASGMT';
4739
4740 BEGIN
4741
4742 --------------------------------------------------
4743 -- RESET OUT params
4744 --------------------------------------------------
4745 x_return_status := FND_API.G_RET_STS_SUCCESS;
4746 x_msg_count := 0;
4747 x_msg_data := NULL ;
4748
4749 --------------------------------------------------
4750 -- Initialize Current Function and Msg Stack
4751 --------------------------------------------------
4752 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE',fnd_global.user_id,fnd_global.login_id,275,null,null), 'N');
4753
4754 IF l_debug_mode = 'Y' THEN
4755 PA_DEBUG.set_curr_function(p_function => 'DELETE_REQUIREMENTS', p_debug_mode => l_debug_mode);
4756 END IF;
4757
4758 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
4759 FND_MSG_PUB.initialize;
4760 END IF;
4761 --------------------------------------------------
4762 -- Create Savepoint
4763 --------------------------------------------------
4764 IF p_commit = FND_API.G_TRUE THEN
4765 savepoint DELETE_REQUIREMENTS_SP;
4766 END IF;
4767
4768 IF l_debug_mode = 'Y' THEN
4769 pa_debug.write(l_module, 'Start of DELETE_REQUIREMENTS', l_log_level);
4770 END IF;
4771 --------------------------------------------------
4772 -- Start Initialize
4773 --------------------------------------------------
4774 PA_STARTUP.INITIALIZE(
4775 p_calling_application => l_calling_application
4776 , p_calling_module => l_calling_module
4777 , p_check_id_flag => l_check_id_flag
4778 , p_check_role_security_flag => l_check_role_security_flag
4779 , p_check_resource_security_flag => l_check_resource_security_flag
4780 , p_debug_level => l_log_level
4781 );
4782
4783 IF l_debug_mode = 'Y' THEN
4784 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
4785 END IF;
4786 --------------------------------------------------
4787 -- Defaulting Values and Mandatory param validations
4788 -- Security Check
4789 -- Core Logic
4790 --------------------------------------------------
4791 i := p_requirement_in_tbl.first;
4792
4793 WHILE i is not NULL LOOP
4794 l_error_flag_local := 'N';
4795 l_missing_params := null;
4796 l_req_rec := null;
4797
4798 l_start_msg_count := FND_MSG_PUB.count_msg;
4799
4800 l_req_rec := p_requirement_in_tbl(i);
4801
4802 -- Blank Out Parameters if not passed.
4803 IF l_req_rec.requirement_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
4804 l_req_rec.requirement_id := NULL ;
4805 END IF;
4806
4807 IF l_req_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
4808 l_req_rec.record_version_number := NULL ;
4809 END IF;
4810
4811 IF l_debug_mode = 'Y' THEN
4812 pa_debug.write(l_module, 'Requirement_id is ' || l_req_rec.requirement_id,l_log_level);
4813 pa_debug.write(l_module, 'Record Version Number is ' || l_req_rec.record_version_number, l_log_level);
4814 END IF;
4815
4816 -- Mandatory Parameters Check
4817 IF l_debug_mode = 'Y' THEN
4818 pa_debug.write(l_module, 'Mandatory Parameter Validation Starts', l_log_level);
4819 END IF;
4820
4821 IF l_req_rec.requirement_id IS NULL THEN
4822 l_missing_params := l_missing_params||'REQUIREMENT_ID ' ;
4823 END IF;
4824
4825
4826 IF l_debug_mode = 'Y' THEN
4827 pa_debug.write(l_module, 'Mandatory Parameter Validation Over. ',l_log_level);
4828 pa_debug.write(l_module, 'The missing parameters are '||l_missing_params, l_log_level);
4829 END IF;
4830
4831 IF l_missing_params IS NOT NULL THEN
4832 l_error_flag_local := 'Y';
4833 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
4834 'INVALID_PARAMS', l_missing_params);
4835 END IF;
4836
4837 IF l_error_flag_local <> 'Y' THEN
4838
4839 l_assignment_id := l_req_rec.requirement_id ;
4840 -- Derive the other values
4841 OPEN c_derive_values(l_assignment_id);
4842 FETCH c_derive_values INTO l_assignment_row_id ,l_project_id,l_record_version_number,l_team_template_id,l_assignment_number,l_status_code;
4843 IF c_derive_values%NOTFOUND THEN
4844 l_missing_params := l_missing_params||'REQUIREMENT_ID ' ;
4845 l_error_flag_local := 'Y';
4846 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
4847 'INVALID_PARAMS', l_missing_params);
4848 END IF;
4849 CLOSE c_derive_values;
4850
4851 IF l_error_flag_local <> 'Y' THEN
4852
4853 l_system_status_code := null;
4854 OPEN c_get_system_status ;
4855 FETCH c_get_system_status INTO l_system_status_code ;
4856 CLOSE c_get_system_status;
4857
4858 --IF l_system_status_code IN ('OPEN_ASGMT_CANCEL','OPEN_ASGMT_FILLED') THEN --Bug 7638990
4859 IF l_system_status_code IN ('OPEN_ASGMT_FILLED') THEN --Bug 7638990
4860 l_error_flag_local := 'Y' ;
4861 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_STS_ACT_NOT_ALLW');
4862 END IF;
4863
4864 -- Security Check
4865 IF l_debug_mode = 'Y' THEN
4866 pa_debug.write(l_module, 'Checking Security for record number '||i, l_log_level);
4867 END IF;
4868
4869 IF l_project_id IS NOT NULL THEN
4870 l_privilege := 'PA_ASN_CR_AND_DL';
4871 l_object_name := 'PA_PROJECTS';
4872 l_object_key := l_project_id ;
4873 ELSIF l_team_template_id IS NOT NULL THEN
4874 l_privilege := 'PA_PRM_DEFINE_TEAM_TEMPLATE';
4875 l_object_name := null;
4876 l_object_key := null;
4877 ELSE -- This wont happen
4878 PA_UTILS.ADD_MESSAGE('PA', 'PA_UNEXPECTED ERROR');
4879 raise FND_API.G_EXC_ERROR;
4880 END IF;
4881
4882 l_return_status := FND_API.G_RET_STS_SUCCESS;
4883 l_ret_code := 'T';
4884
4885 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
4886 x_ret_code => l_ret_code
4887 , x_return_status => l_return_status
4888 , x_msg_count => l_msg_count
4889 , x_msg_data => l_msg_data
4890 , p_privilege => l_privilege
4891 , p_object_name => l_object_name
4892 , p_object_key => l_object_key
4893 ,p_init_msg_list => FND_API.G_FALSE);
4894
4895 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4896 -- This message does not have token defined, but intentionally putting token
4897 -- because we still want to show the privilege name which is missing
4898 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_CR_DL'
4899 ,'MISSING_PRIVILEGE', l_privilege);
4900 l_error_flag_local := 'Y';
4901 END IF;
4902
4903 END IF;
4904 END IF;
4905
4906 -- Call Actual API
4907 IF l_error_flag_local <> 'Y' THEN
4908 l_return_status := FND_API.G_RET_STS_SUCCESS;
4909
4910 IF l_debug_mode = 'Y' THEN
4911 pa_debug.write(l_module, 'Calling PA_ASSIGNMENTS_PUB.DELETE_ASSIGNMENT for record number'||i, l_log_level);
4912 END IF;
4913
4914
4915 PA_ASSIGNMENTS_PUB.Delete_Assignment
4916 ( p_assignment_row_id => l_assignment_row_id
4917 , p_assignment_id => l_assignment_id
4918 , p_record_version_number => l_record_version_number
4919 , p_assignment_type => l_assignment_type
4920 , p_assignment_number => l_assignment_number
4921 , p_commit => l_commit
4922 , p_validate_only => l_validate_only
4923 , x_return_status => l_return_status
4924 , x_msg_count => l_msg_count
4925 , x_msg_data => l_msg_data
4926 );
4927 IF l_debug_mode = 'Y' THEN
4928 pa_debug.write(l_module, 'After call PA_ASSIGNMENTS_PUB.DELETE_ASSIGNMENT l_return_status='||l_return_status, l_log_level);
4929 END IF;
4930
4931 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4932 l_error_flag_local := 'Y';
4933 END IF;
4934 END IF;
4935
4936 l_end_msg_count := FND_MSG_PUB.count_msg;
4937 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
4938
4939 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
4940 l_error_flag := 'Y';
4941
4942 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
4943 -- Always get from first location in stack i.e. l_start_msg_count+1
4944 -- Because stack moves down after delete
4945 FND_MSG_PUB.get (
4946 p_msg_index => l_start_msg_count+1,
4947 p_encoded => FND_API.G_FALSE,
4948 p_data => l_data,
4949 p_msg_index_out => l_msg_index_out );
4950
4951 -- Always delete at first location in stack i.e. l_start_msg_count+1
4952 -- Because stack moves down after delete
4953 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
4954
4955 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
4956 'RECORD_NO', i,
4957 'MESSAGE', l_data);
4958 END LOOP;
4959 END IF;
4960 i := p_requirement_in_tbl.next(i);
4961 END LOOP;
4962
4963 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
4964 RAISE FND_API.G_EXC_ERROR;
4965 END IF;
4966
4967 IF l_debug_mode = 'Y' THEN
4968 PA_DEBUG.reset_curr_function;
4969 END IF;
4970
4971 IF p_commit = FND_API.G_TRUE THEN
4972 commit;
4973 END IF;
4974
4975
4976 EXCEPTION
4977 WHEN FND_API.G_EXC_ERROR THEN
4978 x_return_status := FND_API.G_RET_STS_ERROR;
4979 l_msg_count := FND_MSG_PUB.count_msg;
4980
4981 IF p_commit = FND_API.G_TRUE THEN
4982 ROLLBACK TO DELETE_REQUIREMENTS_SP;
4983 END IF;
4984
4985 IF c_derive_values%ISOPEN THEN
4986 CLOSE c_derive_values ;
4987 END IF;
4988
4989 IF c_get_system_status%ISOPEN THEN
4990 CLOSE c_get_system_status ;
4991 END IF;
4992
4993 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
4994 PA_INTERFACE_UTILS_PUB.get_messages
4995 ( p_encoded => FND_API.G_FALSE
4996 , p_msg_index => 1
4997 , p_msg_count => l_msg_count
4998 , p_msg_data => l_msg_data
4999 , p_data => l_data
5000 , p_msg_index_out => l_msg_index_out);
5001
5002 x_msg_data := l_data;
5003 x_msg_count := l_msg_count;
5004 ELSE
5005 x_msg_count := l_msg_count;
5006 END IF;
5007
5008 IF l_debug_mode = 'Y' THEN
5009 Pa_Debug.reset_curr_function;
5010 END IF;
5011
5012 WHEN OTHERS THEN
5013
5014 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5015 x_msg_data := SQLERRM;
5016
5017 IF p_commit = FND_API.G_TRUE THEN
5018 ROLLBACK TO DELETE_REQUIREMENTS_SP;
5019 END IF;
5020
5021 IF c_derive_values%ISOPEN THEN
5022 CLOSE c_derive_values ;
5023 END IF;
5024
5025 IF c_get_system_status%ISOPEN THEN
5026 CLOSE c_get_system_status ;
5027 END IF;
5028
5029 FND_MSG_PUB.add_exc_msg
5030 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
5031 , p_procedure_name => 'DELETE_REQUIREMENTS'
5032 , p_error_text => x_msg_data);
5033
5034 x_msg_count := FND_MSG_PUB.count_msg;
5035
5036 IF l_debug_mode = 'Y' THEN
5037 PA_DEBUG.reset_curr_function;
5038 END IF;
5039 RAISE;
5040 END DELETE_REQUIREMENTS;
5041
5042 -- Start of comments
5043 -- API name : STAFF_REQUIREMENTS
5044 -- Type : Public
5045 -- Pre-reqs : None.
5046 -- Function : This is a public API to staff the requirements.
5047 -- Usage : This API will be called from AMG.
5048 -- Parameters :
5049 -- IN : p_commit IN VARCHAR2
5050 -- Identifier to commit the transaction.
5051 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
5052 -- p_init_msg_list IN VARCHAR2
5053 -- Identifier to initialize the error message stack.
5054 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
5055 -- p_api_version_number IN NUMBER Required
5056 -- To be compliant with Applications API coding standards.
5057 -- p_staff_requirement_tbl IN STAFF_REQUIREMENT_TBL_TYPE Required
5058 -- Table of staffing information for each requirement. Please see the datatype Staff_requirement_tbl_TYPE.
5059 -- OUT :
5060 -- x_assignment_id_tbl OUT SYSTEM.PA_NUM_TBL_TYPE
5061 -- Table to store the staffed assignment ids and newly created requirement_ids
5062 -- x_return_status OUT VARCHAR2
5063 -- Indicates the return status of the API.
5064 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
5065 -- x_msg_count OUT NUMBER
5066 -- Indicates the number of error messages in the message stack
5067 -- x_msg_data OUT VARCHAR2
5068 -- Indicates the error message text if only one error exists
5069 -- History :
5070 -- 01-Mar-2006 - avaithia - Created
5071 -- End of comments
5072 PROCEDURE STAFF_REQUIREMENTS
5073 (
5074 p_api_version_number IN NUMBER := 1.0
5075 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
5076 , p_commit IN VARCHAR2 := FND_API.G_FALSE
5077 , P_STAFF_REQUIREMENT_TBL IN STAFF_REQUIREMENT_TBL_TYPE
5078 , X_ASSIGNMENT_ID_TBL OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE
5079 , x_return_status OUT NOCOPY VARCHAR2
5080 , x_msg_count OUT NOCOPY NUMBER
5081 , x_msg_data OUT NOCOPY VARCHAR2
5082 )
5083 IS
5084 l_calling_application VARCHAR2(10) := 'PLSQL';
5085 l_calling_module VARCHAR2(10) := 'AMG';
5086 l_check_id_flag VARCHAR2(1) := 'Y';
5087 l_check_role_security_flag VARCHAR2(1) := 'Y';
5088 l_check_resource_security_flag VARCHAR2(1) := 'Y';
5089
5090 l_log_level NUMBER := 3;
5091 l_module VARCHAR2(100) := 'PA_RES_MANAGEMENT_AMG_PUB.STAFF_REQUIREMENTS';
5092 l_commit VARCHAR2(1) := FND_API.G_FALSE;
5093 l_init_msg_list VARCHAR2(1) := FND_API.G_FALSE;
5094 l_validate_only VARCHAR2(1) := FND_API.G_FALSE;
5095
5096 l_msg_count NUMBER;
5097 l_msg_data VARCHAR2(2000);
5098 l_msg_index_out NUMBER;
5099 l_data VARCHAR2(2000);
5100 l_debug_mode VARCHAR2(1);
5101
5102 i NUMBER;
5103
5104 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
5105 l_error_flag VARCHAR2(1) := 'N';
5106 l_error_flag_local VARCHAR2(1) := 'N';
5107
5108 l_loop_msg_count NUMBER :=0;
5109 l_start_msg_count NUMBER :=0;
5110 l_end_msg_count NUMBER :=0;
5111 l_before_api_msg_count NUMBER :=0;
5112 l_after_api_msg_count NUMBER :=0;
5113
5114 l_missing_params VARCHAR2(1000);
5115 l_privilege VARCHAR2(30);
5116 l_object_name VARCHAR2(30);
5117 l_object_key NUMBER;
5118 l_error_message_code VARCHAR2(30);
5119 l_ret_code VARCHAR2(1);
5120
5121 l_staff_rec STAFF_REQUIREMENT_REC_TYPE ;
5122
5123 l_requirement_creation_mode VARCHAR2(10);
5124 l_source_requirement_id NUMBER;
5125 l_resource_id NUMBER;
5126 l_person_id NUMBER;
5127 l_assignment_status_code VARCHAR2(30);
5128 l_assignment_status_name VARCHAR2(80);
5129 l_unfilled_assign_status_code VARCHAR2(30);
5130 l_unfilled_assign_status_name VARCHAR2(80);
5131 l_remaining_candidate_code VARCHAR2(30);
5132 l_change_reason_code VARCHAR2(30);
5133 l_record_version_number NUMBER;
5134 l_start_date DATE;
5135 l_end_date DATE;
5136
5137 l_project_id NUMBER;
5138 l_team_template_id NUMBER;
5139 l_status_code NUMBER;
5140 l_db_start_date DATE;
5141 l_db_end_date DATE;
5142
5143 l_out_assignment_id NUMBER;
5144 l_out_assignment_number NUMBER;
5145 l_out_assignment_row_id ROWID;
5146 l_out_resource_id NUMBER;
5147
5148 CURSOR c_derive_values(c_source_reqmt_id IN NUMBER) IS
5149 SELECT project_id,ASSIGNMENT_TEMPLATE_ID ,status_code,start_date,end_date
5150 FROM pa_project_assignments
5151 WHERE assignment_id = c_source_reqmt_id ;
5152
5153 CURSOR c_valid_status_code IS
5154 SELECT project_status_name from pa_project_statuses
5155 where
5156 status_type = 'STAFFED_ASGMT'
5157 and project_status_code = l_assignment_status_code
5158 and trunc(SYSDATE) between start_date_active and nvl(end_date_active, trunc(SYSDATE))
5159 and starting_status_flag = 'Y' and project_system_status_code <> 'STAFFED_ASGMT_CONF';
5160
5161 CURSOR c_valid_unfilled_status_code IS
5162 SELECT project_status_name from pa_project_statuses
5163 where
5164 status_type = 'OPEN_ASGMT'
5165 and project_status_code = l_unfilled_assign_status_code
5166 and trunc(SYSDATE) between start_date_active and nvl(end_date_active, trunc(SYSDATE))
5167 and starting_status_flag = 'Y' ;
5168
5169 CURSOR c_valid_status_name IS
5170 SELECT project_status_code from pa_project_statuses
5171 where
5172 status_type = 'STAFFED_ASGMT'
5173 and project_status_name = l_assignment_status_name
5174 and trunc(SYSDATE) between start_date_active and nvl(end_date_active, trunc(SYSDATE))
5175 and starting_status_flag = 'Y' and project_system_status_code <> 'STAFFED_ASGMT_CONF';
5176
5177 CURSOR c_valid_unfilled_status_name IS
5178 SELECT project_status_code from pa_project_statuses
5179 where
5180 status_type = 'OPEN_ASGMT'
5181 and project_status_name = l_unfilled_assign_status_name
5182 and trunc(SYSDATE) between start_date_active and nvl(end_date_active, trunc(SYSDATE))
5183 and starting_status_flag = 'Y' ;
5184
5185 BEGIN
5186
5187 --------------------------------------------------
5188 -- RESET OUT params
5189 --------------------------------------------------
5190 x_return_status := FND_API.G_RET_STS_SUCCESS;
5191 x_msg_count := 0;
5192 x_msg_data := NULL ;
5193
5194 X_ASSIGNMENT_ID_TBL := SYSTEM.PA_NUM_TBL_TYPE();
5195 --------------------------------------------------
5196 -- Initialize Current Function and Msg Stack
5197 --------------------------------------------------
5198 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE',fnd_global.user_id,fnd_global.login_id,275,null,null), 'N');
5199
5200 IF l_debug_mode = 'Y' THEN
5201 PA_DEBUG.set_curr_function(p_function => 'STAFF_REQUIREMENTS', p_debug_mode => l_debug_mode);
5202 END IF;
5203
5204 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
5205 FND_MSG_PUB.initialize;
5206 END IF;
5207 --------------------------------------------------
5208 -- Create Savepoint
5209 --------------------------------------------------
5210 IF p_commit = FND_API.G_TRUE THEN
5211 savepoint STAFF_REQUIREMENTS_SP;
5212 END IF;
5213
5214 IF l_debug_mode = 'Y' THEN
5215 pa_debug.write(l_module, 'Start of STAFF_REQUIREMENTS', l_log_level);
5216 END IF;
5217 --------------------------------------------------
5218 -- Start Initialize
5219 --------------------------------------------------
5220 PA_STARTUP.INITIALIZE(
5221 p_calling_application => l_calling_application
5222 , p_calling_module => l_calling_module
5223 , p_check_id_flag => l_check_id_flag
5224 , p_check_role_security_flag => l_check_role_security_flag
5225 , p_check_resource_security_flag => l_check_resource_security_flag
5226 , p_debug_level => l_log_level
5227 );
5228
5229 IF l_debug_mode = 'Y' THEN
5230 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
5231 END IF;
5232 --------------------------------------------------
5233 -- Defaulting Values and Mandatory param validations
5234 -- Security Check
5235 -- Core Logic
5236 --------------------------------------------------
5237 i := P_STAFF_REQUIREMENT_TBL.FIRST ;
5238
5239 WHILE i is not NULL LOOP
5240 l_error_flag_local := 'N';
5241 l_missing_params := null;
5242 l_staff_rec := NULL ;
5243 l_start_msg_count := FND_MSG_PUB.count_msg;
5244
5245 l_staff_rec := P_STAFF_REQUIREMENT_TBL(i);
5246
5247 ------------------------------------------------------------------------------------------
5248 -- Blank Out Parameters if not passed.
5249 ------------------------------------------------------------------------------------------
5250 -- Commented out as this param needs to be derived inside code
5251 -- it should not be exposed to the user
5252
5253
5254 IF l_staff_rec.source_requirement_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
5255 l_staff_rec.source_requirement_id := NULL ;
5256 END IF;
5257
5258 IF l_staff_rec.resource_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
5259 l_staff_rec.resource_id := NULL ;
5260 END IF;
5261
5262 IF l_staff_rec.person_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
5263 l_staff_rec.person_id := NULL ;
5264 END IF;
5265
5266 IF l_staff_rec.assignment_status_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
5267 l_staff_rec.assignment_status_code := NULL ;
5268 END IF;
5269
5270 IF l_staff_rec.assignment_status_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
5271 l_staff_rec.assignment_status_name := NULL ;
5272 END IF;
5273
5274 IF l_staff_rec.unfilled_assign_status_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
5275 l_staff_rec.unfilled_assign_status_code := NULL ;
5276 END IF;
5277
5278 IF l_staff_rec.unfilled_assign_status_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
5279 l_staff_rec.unfilled_assign_status_name := NULL ;
5280 END IF;
5281
5282 IF l_staff_rec.remaining_candidate_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
5283 l_staff_rec.remaining_candidate_code := NULL ;
5284 END IF;
5285
5286 IF l_staff_rec.change_reason_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
5287 l_staff_rec.change_reason_code := NULL ;
5288 END IF;
5289
5290 IF l_staff_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
5291 l_staff_rec.record_version_number := NULL ;
5292 END IF;
5293
5294 IF l_staff_rec.start_date = PA_INTERFACE_UTILS_PUB.G_PA_MISS_DATE THEN
5295 l_staff_rec.start_date := NULL ;
5296 END IF;
5297
5298 IF l_staff_rec.end_Date = PA_INTERFACE_UTILS_PUB.G_PA_MISS_DATE THEN
5299 l_staff_rec.end_Date := NULL ;
5300 END IF;
5301
5302 IF l_debug_mode = 'Y' THEN
5303 pa_debug.write(l_module,'Source Requirement ID ' || l_staff_rec.source_requirement_id,l_log_level);
5304 pa_debug.write(l_module,'Record Version Number ' ||l_staff_rec.record_version_number,l_log_level);
5305 pa_debug.write(l_module,'Resource id ' || l_staff_rec.resource_id,l_log_level);
5306 pa_debug.write(l_module,'Person Id ' || l_staff_rec.person_id,l_log_level);
5307 pa_debug.write(l_module,'Asgmt Status code ' ||l_staff_rec.assignment_status_code,l_log_level);
5308 pa_debug.write(l_module,'Asgmt Status name ' ||l_staff_rec.assignment_status_name,l_log_level);
5309 pa_debug.write(l_module,'Unfilled Asgmt Status code ' ||l_staff_rec.unfilled_assign_status_code,l_log_level);
5310 pa_debug.write(l_module,'Unfilled Asgmt Status Name ' ||l_staff_rec.unfilled_assign_status_name,l_log_level);
5311 pa_debug.write(l_module,'Remaining Candidate Code ' ||l_staff_rec.remaining_candidate_code,l_log_level);
5312 pa_debug.write(l_module,'Change Reason Code ' ||l_staff_rec.change_reason_code,l_log_level);
5313 pa_debug.write(l_module,'Start date ' || l_staff_rec.start_date,l_log_level);
5314 pa_debug.write(l_module,'End date ' || l_staff_rec.end_Date,l_log_level);
5315
5316 END IF;
5317
5318 l_source_requirement_id := l_staff_rec.source_requirement_id;
5319 l_record_version_number := l_staff_rec.record_version_number;
5320 -- l_requirement_creation_mode := l_staff_rec.requirement_creation_mode;
5321 l_resource_id := l_staff_rec.resource_id ;
5322 l_person_id := l_staff_rec.person_id ;
5323 l_assignment_status_code := l_staff_rec.assignment_status_code ;
5324 l_assignment_status_name := l_staff_rec.assignment_status_name ;
5325 l_unfilled_assign_status_code := l_staff_rec.unfilled_assign_status_code;
5326 l_unfilled_assign_status_name := l_staff_rec.unfilled_assign_status_name ;
5327 l_remaining_candidate_code := l_staff_rec.remaining_candidate_code;
5328 l_change_reason_code := l_staff_rec.change_reason_code ;
5329 l_start_date := l_staff_rec.start_date ;
5330 l_end_date := l_staff_rec.end_Date;
5331 ------------------------------------------
5332 -- Mandatory params check
5333 ------------------------------------------
5334 IF l_source_requirement_id IS NULL THEN
5335 l_missing_params := l_missing_params||'SOURCE_REQUIREMENT_ID' ;
5336 END IF;
5337
5338 IF l_record_version_number IS NULL THEN
5339 l_missing_params := l_missing_params||', RECORD_VERSION_NUMBER ';
5340 END IF;
5341
5342 IF l_start_date IS NULL THEN
5343 l_missing_params := l_missing_params||', START_DATE ';
5344 END IF;
5345
5346 IF l_end_Date IS NULL THEN
5347 l_missing_params := l_missing_params||', END_DATE ';
5348 END IF;
5349
5350 IF l_resource_id IS NULL THEN
5351 IF l_person_id IS NOT NULL THEN
5352 l_resource_id := PA_RESOURCE_UTILS.GET_RESOURCE_ID(l_person_id);
5353 ELSE -- if both are NULL
5354 l_missing_params := l_missing_params||', RESOURCE_ID ';
5355 END IF;
5356 END IF;
5357
5358 IF l_person_id IS NULL THEN
5359 IF l_resource_id IS NOT NULL THEN
5360 l_person_id := PA_RESOURCE_UTILS.GET_PERSON_ID(l_resource_id);
5361 ELSE -- if both are NULL
5362 l_missing_params := l_missing_params||', PERSON_ID ';
5363 END IF;
5364 END IF;
5365
5366 IF l_assignment_status_code IS NULL THEN
5367 IF l_assignment_status_name IS NULL THEN
5368 -- both NULL ,then add them .Any one is available,derive the other
5369 l_missing_params := l_missing_params||', ASSIGNMENT_STATUS_CODE , ASSIGNMENT_STATUS_NAME';
5370 END IF;
5371 END IF;
5372
5373 IF l_missing_params IS NOT NULL THEN
5374 l_error_flag_local := 'Y';
5375 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
5376 'INVALID_PARAMS', l_missing_params);
5377 IF l_debug_mode = 'Y' THEN
5378 pa_debug.write(l_module, 'The missing parameters are '||l_missing_params, l_log_level);
5379 END IF;
5380 END IF;
5381
5382 ------------------------------------------------------------------------
5383 -- 1) Derive Values and verify for valid values 2) Do Security Check
5384 ------------------------------------------------------------------------
5385 IF l_error_flag_local <> 'Y' THEN
5386 OPEN c_derive_values(l_source_requirement_id);
5387 FETCH c_derive_values INTO l_project_id,l_team_template_id,l_status_code,l_db_start_date,l_db_end_date;
5388 IF c_derive_values%NOTFOUND THEN
5389 l_error_flag_local := 'Y' ;
5390 l_missing_params := l_missing_params||'SOURCE_REQUIREMENT_ID' ;
5391 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
5392 'INVALID_PARAMS', l_missing_params);
5393 ELSE
5394 -- If the requirement exists ,determine the mode and validate status values passed
5395 -- Logic got from AssignResourceVORowImpl.java
5396
5397 -- 1) Creation Mode
5398 IF l_start_date > l_db_start_date OR l_end_date < l_db_end_date THEN
5399 l_requirement_creation_mode := 'PARTIAL';
5400 ELSE
5401 l_requirement_creation_mode := 'FULL';
5402 END IF;
5403
5404 -- 2) Assignment Status Code Validation
5405 IF l_assignment_status_code IS NOT NULL THEN
5406 -- Anusha : Existing API just checks whether the status code name exists in
5407 -- pa_project_statuses table
5408
5409 -- It does not check whether the status is a valid starting status and not
5410 -- Confirmed etc.
5411
5412 -- Hence we need in explicitly here. In UI (SS) its controlled by poplist query.
5413
5414 -- Validate the passed status code
5415 -- If its a valid code passed,it will auto populate status name
5416 OPEN c_valid_status_code;
5417 FETCH c_valid_status_code into l_assignment_status_name;
5418
5419 IF c_valid_status_code%NOTFOUND THEN
5420 -- Invalid status code has been passed.
5421 l_error_flag_local := 'Y' ;
5422 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_ASG_STATUS',--New message
5423 'SOURCE_REQUIREMENT_ID',l_source_requirement_id,'STATUS_CODE',l_assignment_status_code);
5424 END IF;
5425 CLOSE c_valid_status_code ;
5426 ELSE -- if status code is NULL
5427 -- Validate the passed status name
5428 -- If its a valid name passed,it will auto populate status code
5429 OPEN c_valid_status_name;
5430 FETCH c_valid_status_name into l_assignment_status_code;
5431
5432 IF c_valid_status_name%NOTFOUND THEN
5433 -- Invalid status name has been passed .Here ,code is also nt passed
5434 l_error_flag_local := 'Y' ;
5435 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_ASG_STATUS',
5436 'SOURCE_REQUIREMENT_ID',l_source_requirement_id,'STATUS_NAME',l_assignment_status_name);
5437 END IF;
5438 CLOSE c_valid_status_name ;
5439 END IF;
5440
5441 -- 3) Validate the unfilled open assignment status value passed
5442 IF l_unfilled_assign_status_code is not NULL THEN
5443
5444 -- Anusha : Existing API just checks whether the status code name exists in
5445 -- pa_project_statuses table
5446
5447 -- It does not check whether the status is a valid starting status and
5448 -- whether its a status specific to Open Requirements .
5449 -- In SS ,this condition is controlled by Poplist query.So,here we need to
5450 -- simulate the same
5451
5452 -- Validate the passed status code
5453 -- If its a valid code passed,it will auto populate status name
5454 OPEN c_valid_unfilled_status_code;
5455 FETCH c_valid_unfilled_status_code into l_unfilled_assign_status_name ;
5456
5457 IF c_valid_unfilled_status_code%NOTFOUND THEN
5458 -- Invalid statuscode has been passed.
5459 l_error_flag_local := 'Y' ;
5460 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_UNFILL_INV_STATUS',--New message
5461 'SOURCE_REQUIREMENT_ID',l_source_requirement_id,'UNFILLED_STATUS_CODE',l_unfilled_assign_status_code);
5462 END IF;
5463 CLOSE c_valid_unfilled_status_code;
5464 ELSE -- if unfilled status code is NULL
5465 -- Validate the passed unfilled status name
5466 -- If its a valid name passed,it will auto populate status code
5467 OPEN c_valid_unfilled_status_name;
5468 FETCH c_valid_unfilled_status_name into l_unfilled_assign_status_code;
5469 IF c_valid_unfilled_status_name%NOTFOUND THEN
5470 -- Invalid unfilled status name has been passed .Here ,code is also nt passed
5471 l_error_flag_local := 'Y' ;
5472 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_UNFILL_INV_STATUS',
5473 'SOURCE_REQUIREMENT_ID',l_source_requirement_id,'UNFILLED_STATUS_NAME',l_unfilled_assign_status_name);
5474 END IF;
5475 CLOSE c_valid_unfilled_status_name;
5476 END IF;
5477 END IF;
5478 CLOSE c_derive_values;
5479 END IF;
5480
5481 IF l_error_flag_local <> 'Y' THEN
5482 IF l_debug_mode = 'Y' THEN
5483 pa_debug.write(l_module, 'Checking Security for record number '||i, l_log_level);
5484 END IF;
5485
5486 IF l_project_id IS NOT NULL THEN
5487 l_privilege := 'PA_ASN_CR_AND_DL';
5488 l_object_name := 'PA_PROJECTS';
5489 l_object_key := l_project_id ;
5490 ELSIF l_team_template_id IS NOT NULL THEN
5491 l_privilege := 'PA_PRM_DEFINE_TEAM_TEMPLATE';
5492 l_object_name := null;
5493 l_object_key := null;
5494 ELSE -- This wont happen though (using hard coded english for internal reference)
5495 PA_UTILS.ADD_MESSAGE('PA', 'PA_UNEXPECTED ERROR');
5496 raise FND_API.G_EXC_ERROR;
5497 END IF;
5498
5499 l_return_status := FND_API.G_RET_STS_SUCCESS;
5500 l_ret_code := 'T';
5501
5502 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
5503 x_ret_code => l_ret_code
5504 , x_return_status => l_return_status
5505 , x_msg_count => l_msg_count
5506 , x_msg_data => l_msg_data
5507 , p_privilege => l_privilege
5508 , p_object_name => l_object_name
5509 , p_object_key => l_object_key
5510 ,p_init_msg_list => FND_API.G_FALSE);
5511 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5512
5513 -- This message does not have token defined, but intentionally putting token
5514 -- because we still want to show the privilege name which is missing
5515 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_STAFF'
5516 ,'MISSING_PRIVILEGE', l_privilege);
5517 l_error_flag_local := 'Y';
5518 END IF;
5519 END IF;
5520
5521 --------------------------------------------------------
5522 -- Call Actual API
5523 --------------------------------------------------------
5524 IF l_error_flag_local <> 'Y' THEN
5525 l_return_status := FND_API.G_RET_STS_SUCCESS;
5526 l_msg_count:= 0;
5527 l_msg_data := NULL ;
5528
5529 IF l_debug_mode = 'Y' THEN
5530 pa_debug.write(l_module, 'Calling PA_ASSIGNMENTS_PUB.Execute_Staff_Assign_From_Open for record number ' || i, l_log_level);
5531 END IF;
5532
5533 l_before_api_msg_count := FND_MSG_PUB.count_msg;
5534 PA_ASSIGNMENTS_PUB.Execute_Staff_Assign_From_Open
5535 ( p_asgn_creation_mode => l_requirement_creation_mode
5536 ,p_record_version_number => l_record_version_number
5537 ,p_multiple_status_flag => 'N'
5538 ,p_assignment_status_code => l_assignment_status_code
5539 ,p_assignment_status_name => l_assignment_status_name
5540 ,p_unfilled_assign_status_code => l_unfilled_assign_status_code
5541 ,p_unfilled_assign_status_name => l_unfilled_assign_status_name
5542 ,p_remaining_candidate_code => l_remaining_candidate_code
5543 ,p_change_reason_code => l_change_reason_code
5544 ,p_resource_id => l_resource_id
5545 ,p_source_assignment_id => l_source_requirement_id
5546 ,p_start_date => l_start_date
5547 ,p_end_date => l_end_date
5548 ,p_init_msg_list => l_init_msg_list
5549 ,p_commit => l_commit
5550 ,p_validate_only => l_validate_only
5551 ,x_new_assignment_id => l_out_assignment_id
5552 ,x_assignment_number => l_out_assignment_number
5553 ,x_assignment_row_id => l_out_assignment_row_id
5554 ,x_resource_id => l_out_resource_id
5555 ,x_return_status => l_return_status
5556 ,x_msg_count => l_msg_count
5557 ,x_msg_data => l_msg_data
5558 );
5559
5560 l_after_api_msg_count := FND_MSG_PUB.count_msg;
5561 IF l_debug_mode = 'Y' THEN
5562 pa_debug.write(l_module, 'After main API Call l_return_status ' || l_return_status,l_log_level);
5563 pa_debug.write(l_module, 'l_msg_count is ' || l_msg_count ||' and l_msg_data is ' ||l_msg_data);
5564 END IF;
5565
5566 ---------------------------------------------------------------------------------------------
5567 -- Populate OUT table appropriately
5568 ---------------------------------------------------------------------------------------------
5569 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5570 l_error_flag_local := 'Y';
5571 X_ASSIGNMENT_ID_TBL.EXTEND(1);
5572 X_ASSIGNMENT_ID_TBL(X_ASSIGNMENT_ID_TBL.COUNT) := -1;
5573 ELSE -- Success
5574 IF (l_after_api_msg_count - l_before_api_msg_count) = 0 AND l_msg_data is NULL THEN
5575 X_ASSIGNMENT_ID_TBL.EXTEND(1);
5576 X_ASSIGNMENT_ID_TBL(X_ASSIGNMENT_ID_TBL.COUNT) := l_out_assignment_id ;
5577 ELSE -- some message populated while executing the called API
5578 l_error_flag_local := 'Y';
5579 X_ASSIGNMENT_ID_TBL.EXTEND(1);
5580 X_ASSIGNMENT_ID_TBL(X_ASSIGNMENT_ID_TBL.COUNT) := -1;
5581 END IF;
5582 END IF;
5583
5584 ---------------------------------------------------------------------------------------------
5585 l_end_msg_count := FND_MSG_PUB.count_msg;
5586
5587 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
5588
5589 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
5590 l_error_flag := 'Y';
5591
5592 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
5593 -- Always get from first location in stack i.e. l_start_msg_count+1
5594 -- Because stack moves down after delete
5595 FND_MSG_PUB.get (
5596 p_msg_index => l_start_msg_count+1,
5597 p_encoded => FND_API.G_FALSE,
5598 p_data => l_data,
5599 p_msg_index_out => l_msg_index_out );
5600
5601 -- Always delete at first location in stack i.e. l_start_msg_count+1
5602 -- Because stack moves down after delete
5603 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
5604
5605 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
5606 'RECORD_NO', i,'MESSAGE', l_data);
5607 END LOOP;
5608 END IF;
5609 ---------------------------------------------------------------------------------------------
5610 END IF;
5611 i := P_STAFF_REQUIREMENT_TBL.NEXT(i);
5612 END LOOP;
5613
5614 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
5615 RAISE FND_API.G_EXC_ERROR;
5616 END IF;
5617
5618 IF l_debug_mode = 'Y' THEN
5619 PA_DEBUG.reset_curr_function;
5620 END IF;
5621
5622 IF p_commit = FND_API.G_TRUE THEN
5623 commit;
5624 END IF;
5625
5626 EXCEPTION
5627 WHEN FND_API.G_EXC_ERROR THEN
5628 x_return_status := FND_API.G_RET_STS_ERROR;
5629 l_msg_count := FND_MSG_PUB.count_msg;
5630
5631 IF p_commit = FND_API.G_TRUE THEN
5632 ROLLBACK TO STAFF_REQUIREMENTS_SP;
5633 END IF;
5634
5635 IF c_derive_values%ISOPEN THEN
5636 CLOSE c_derive_values ;
5637 END IF;
5638
5639 IF c_valid_status_code%ISOPEN THEN
5640 CLOSE c_valid_status_code ;
5641 END IF;
5642
5643 IF c_valid_status_name%ISOPEN THEN
5644 CLOSE c_valid_status_name;
5645 END IF;
5646
5647 IF c_valid_unfilled_status_code%ISOPEN THEN
5648 CLOSE c_valid_unfilled_status_code ;
5649 END IF;
5650
5651 IF c_valid_unfilled_status_name%ISOPEN THEN
5652 CLOSE c_valid_unfilled_status_name ;
5653 END IF;
5654
5655 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
5656 PA_INTERFACE_UTILS_PUB.get_messages
5657 ( p_encoded => FND_API.G_FALSE
5658 , p_msg_index => 1
5659 , p_msg_count => l_msg_count
5660 , p_msg_data => l_msg_data
5661 , p_data => l_data
5662 , p_msg_index_out => l_msg_index_out);
5663
5664 x_msg_data := l_data;
5665 x_msg_count := l_msg_count;
5666 ELSE
5667 x_msg_count := l_msg_count;
5668 END IF;
5669
5670
5671 IF l_debug_mode = 'Y' THEN
5672 Pa_Debug.reset_curr_function;
5673 END IF;
5674 WHEN OTHERS THEN
5675
5676 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5677 x_msg_data := SUBSTRB(SQLERRM,1,240);
5678
5679 IF p_commit = FND_API.G_TRUE THEN
5680 ROLLBACK TO STAFF_REQUIREMENTS_SP;
5681 END IF;
5682
5683 IF c_derive_values%ISOPEN THEN
5684 CLOSE c_derive_values ;
5685 END IF;
5686
5687 IF c_valid_status_code%ISOPEN THEN
5688 CLOSE c_valid_status_code ;
5689 END IF;
5690
5691 IF c_valid_status_name%ISOPEN THEN
5692 CLOSE c_valid_status_name;
5693 END IF;
5694
5695 IF c_valid_unfilled_status_code%ISOPEN THEN
5696 CLOSE c_valid_unfilled_status_code ;
5697 END IF;
5698
5699 IF c_valid_unfilled_status_name%ISOPEN THEN
5700 CLOSE c_valid_unfilled_status_name ;
5701 END IF;
5702
5703 FND_MSG_PUB.add_exc_msg
5704 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
5705 , p_procedure_name => 'STAFF_REQUIREMENTS'
5706 , p_error_text => x_msg_data);
5707
5708 x_msg_count := FND_MSG_PUB.count_msg;
5709
5710 IF l_debug_mode = 'Y' THEN
5711 PA_DEBUG.reset_curr_function;
5712 END IF;
5713 RAISE;
5714
5715 END STAFF_REQUIREMENTS;
5716
5717 -- Start of comments
5718 -- API name : COPY_TEAM_ROLES
5719 -- Type : Public
5720 -- Pre-reqs : None.
5721 -- Function : This is a public API to copy team roles from project assignments or requirements.
5722 -- Usage : This API will be called from AMG.
5723 -- Parameters :
5724 -- IN : p_commit IN VARCHAR2
5725 -- Identifier to commit the transaction.
5726 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
5727 -- p_init_msg_list IN VARCHAR2
5728 -- Identifier to initialize the error message stack.
5729 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
5730 -- p_api_version_number IN NUMBER Required
5731 -- To be compliant with Applications API coding standards.
5732 -- p_req_asgn_id_tbl IN SYSTEM.PA_NUM_TBL_TYPE Required
5733 -- Table of requirement or assignment ids.
5734 -- Reference: pa_project_assignments.assignment_id
5735 -- OUT :
5736 -- x_req_asgn_id_tbl OUT SYSTEM.PA_NUM_TBL_TYPE
5737 -- Table to store the created requirement or assignment ids
5738 -- x_return_status OUT VARCHAR2
5739 -- Indicates the return status of the API.
5740 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
5741 -- x_msg_count OUT NUMBER
5742 -- Indicates the number of error messages in the message stack
5743 -- x_msg_data OUT VARCHAR2
5744 -- Indicates the error message text if only one error exists
5745 -- History :
5746 -- 01-Mar-2006 - avaithia - Created
5747 -- End of comments
5748 PROCEDURE COPY_TEAM_ROLES
5749 (
5750 p_api_version_number IN NUMBER := 1.0
5751 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
5752 , p_commit IN VARCHAR2 := FND_API.G_FALSE
5753 , p_req_asgn_id_tbl IN SYSTEM.PA_NUM_TBL_TYPE
5754 , x_req_asgn_id_tbl OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE
5755 , x_return_status OUT NOCOPY VARCHAR2
5756 , x_msg_count OUT NOCOPY NUMBER
5757 , x_msg_data OUT NOCOPY VARCHAR2
5758 )
5759 IS
5760 l_calling_application VARCHAR2(10) := 'PLSQL';
5761 l_calling_module VARCHAR2(10) := 'AMG';
5762 l_check_id_flag VARCHAR2(1) := 'Y';
5763 l_check_role_security_flag VARCHAR2(1) := 'Y';
5764 l_check_resource_security_flag VARCHAR2(1) := 'Y';
5765
5766 l_log_level NUMBER := 3;
5767 l_module VARCHAR2(100) := 'PA_RES_MANAGEMENT_AMG_PUB.COPY_TEAM_ROLES';
5768 l_commit VARCHAR2(1) := FND_API.G_FALSE;
5769 l_init_msg_list VARCHAR2(1) := FND_API.G_FALSE;
5770
5771 l_msg_count NUMBER;
5772 l_msg_data VARCHAR2(2000);
5773 l_msg_index_out NUMBER;
5774 l_data VARCHAR2(2000);
5775 l_debug_mode VARCHAR2(1);
5776
5777 i NUMBER;
5778 k NUMBER;
5779
5780 -- l_req_rec REQUIREMENT_IN_REC_TYPE;
5781 l_req_rec NUMBER ;
5782
5783 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
5784 l_error_flag VARCHAR2(1) := 'N';
5785 l_error_flag_local VARCHAR2(1) := 'N';
5786
5787 l_loop_msg_count NUMBER :=0;
5788 l_start_msg_count NUMBER :=0;
5789 l_end_msg_count NUMBER :=0;
5790
5791 l_missing_params VARCHAR2(1000);
5792 l_privilege VARCHAR2(30);
5793 l_object_name VARCHAR2(30);
5794 l_object_key NUMBER;
5795 l_error_message_code VARCHAR2(30);
5796 l_ret_code VARCHAR2(1);
5797
5798 l_req_asgn_id NUMBER;
5799 l_project_id NUMBER;
5800 l_team_template_id NUMBER;
5801
5802 l_out_req_asgn_id NUMBER;
5803 l_out_req_asgn_number NUMBER;
5804 l_out_req_asgn_row_id ROWID;
5805
5806 l_before_api_msg_count NUMBER;
5807 l_after_api_msg_count NUMBER;
5808
5809 l_status_code VARCHAR2(30);
5810
5811 CURSOR c_derive_values(p_req_asgn_id IN NUMBER) IS
5812 SELECT project_id,ASSIGNMENT_TEMPLATE_ID,status_code
5813 FROM pa_project_assignments
5814 WHERE assignment_id = p_req_asgn_id ;
5815
5816 CURSOR c_get_system_status IS
5817 SELECT PROJECT_SYSTEM_STATUS_CODE
5818 FROM pa_project_statuses
5819 WHERE project_status_code = l_status_code
5820 AND status_type in ('OPEN_ASGMT','STAFFED_ASGMT');
5821
5822 l_system_status_code VARCHAR2(30);
5823 BEGIN
5824
5825 --------------------------------------------------
5826 -- RESET OUT params
5827 --------------------------------------------------
5828 x_return_status := FND_API.G_RET_STS_SUCCESS;
5829 x_msg_count := 0;
5830 x_msg_data := NULL ;
5831
5832 X_REQ_ASGN_ID_TBL := SYSTEM.PA_NUM_TBL_TYPE();
5833 --------------------------------------------------
5834 -- Initialize Current Function and Msg Stack
5835 --------------------------------------------------
5836 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE',fnd_global.user_id,fnd_global.login_id,275,null,null), 'N');
5837
5838 IF l_debug_mode = 'Y' THEN
5839 PA_DEBUG.set_curr_function(p_function => 'COPY_TEAM_ROLES', p_debug_mode => l_debug_mode);
5840 END IF;
5841
5842 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
5843 FND_MSG_PUB.initialize;
5844 END IF;
5845 --------------------------------------------------
5846 -- Create Savepoint
5847 --------------------------------------------------
5848 IF p_commit = FND_API.G_TRUE THEN
5849 savepoint COPY_TEAM_ROLES_SP;
5850 END IF;
5851
5852 IF l_debug_mode = 'Y' THEN
5853 pa_debug.write(l_module, 'Start of COPY_TEAM_ROLES', l_log_level);
5854 END IF;
5855 --------------------------------------------------
5856 -- Start Initialize
5857 --------------------------------------------------
5858 PA_STARTUP.INITIALIZE(
5859 p_calling_application => l_calling_application
5860 , p_calling_module => l_calling_module
5861 , p_check_id_flag => l_check_id_flag
5862 , p_check_role_security_flag => l_check_role_security_flag
5863 , p_check_resource_security_flag => l_check_resource_security_flag
5864 , p_debug_level => l_log_level
5865 );
5866
5867 IF l_debug_mode = 'Y' THEN
5868 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
5869 END IF;
5870 --------------------------------------------------
5871 -- Defaulting Values and Mandatory param validations
5872 -- Security Check
5873 -- Core Logic
5874 --------------------------------------------------
5875 i := p_req_asgn_id_tbl.first;
5876 WHILE i is not NULL LOOP
5877 l_error_flag_local := 'N';
5878 l_missing_params := null;
5879 l_req_asgn_id := null;
5880 l_req_rec := NULL ;
5881
5882 l_start_msg_count := FND_MSG_PUB.count_msg;
5883
5884 l_req_rec := p_req_asgn_id_tbl(i);
5885
5886 l_req_asgn_id := l_req_rec;
5887
5888 -- Blank Out Parameters if not passed.
5889 IF l_req_asgn_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
5890 l_req_asgn_id := NULL ;
5891 END IF ;
5892
5893 -- Mandatory Parameters Check
5894 IF l_debug_mode = 'Y' THEN
5895 pa_debug.write(l_module, 'Mandatory Parameter Validation Starts', l_log_level);
5896 END IF;
5897
5898 IF l_debug_mode = 'Y' THEN
5899 pa_debug.write(l_module, 'The Passed id is : ' || l_req_asgn_id ,l_log_level);
5900 END IF;
5901
5902 IF l_req_asgn_id is NULL THEN
5903 l_missing_params := l_missing_params||'TEAM_ROLE_ID';
5904 END IF;
5905
5906 IF l_debug_mode = 'Y' THEN
5907 pa_debug.write(l_module, 'Mandatory Parameter Validation Over. ',l_log_level);
5908 pa_debug.write(l_module, 'The missing parameters are '||l_missing_params, l_log_level);
5909 END IF;
5910
5911 IF l_missing_params IS NOT NULL THEN
5912 l_error_flag_local := 'Y';
5913 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
5914 'INVALID_PARAMS', l_missing_params);
5915 END IF;
5916
5917 IF l_error_flag_local <> 'Y' THEN
5918 OPEN c_derive_values(l_req_asgn_id) ;
5919 FETCH c_derive_values INTO l_project_id ,l_team_template_id,l_status_code ;
5920 IF c_derive_values%NOTFOUND THEN
5921
5922 l_error_flag_local := 'Y' ;
5923 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS'
5924 ,'TEAM_ROLE_ID',l_req_asgn_id); -- New message to say invalid team role
5925 ELSE -- If team role exists
5926 OPEN c_get_system_status ;
5927 FETCH c_get_system_status INTO l_system_status_code ;
5928 CLOSE c_get_system_status;
5929 /* Bug 9159158
5930 IF l_system_status_code IN ('OPEN_ASGMT_CANCEL','OPEN_ASGMT_FILLED','STAFFED_ASGMT_CANCEL') THEN
5931 l_error_flag_local := 'Y' ;
5932 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_CP_STATUS'); -- New message
5933 END IF;
5934 */
5935 END IF;
5936 CLOSE c_derive_values;
5937
5938 --------------------------------------------------------
5939 -- Security Check
5940 --------------------------------------------------------
5941
5942 IF l_error_flag_local <> 'Y' THEN
5943
5944 IF l_debug_mode = 'Y' THEN
5945 pa_debug.write(l_module, 'Checking Security for record number '||i, l_log_level);
5946 END IF;
5947
5948 IF l_project_id IS NOT NULL THEN
5949 l_privilege := 'PA_ASN_CR_AND_DL';
5950 l_object_name := 'PA_PROJECTS';
5951 l_object_key := l_project_id ;
5952 /* ELSIF l_team_template_id IS NOT NULL THEN
5953 -- Commented as Copy team role functionality is not available to team templates
5954
5955 l_privilege := 'PA_PRM_DEFINE_TEAM_TEMPLATE';
5956 l_object_name := null;
5957 l_object_key := null;*/
5958 ELSE -- This wont happen though (using hard coded english for internal reference)
5959 PA_UTILS.ADD_MESSAGE('PA', 'PA_UNEXPECTED ERROR');
5960 raise FND_API.G_EXC_ERROR;
5961 END IF;
5962
5963 l_return_status := FND_API.G_RET_STS_SUCCESS;
5964 l_ret_code := 'T';
5965
5966 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
5967 x_ret_code => l_ret_code
5968 , x_return_status => l_return_status
5969 , x_msg_count => l_msg_count
5970 , x_msg_data => l_msg_data
5971 , p_privilege => l_privilege
5972 , p_object_name => l_object_name
5973 , p_object_key => l_object_key
5974 ,p_init_msg_list => FND_API.G_FALSE);
5975
5976 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5977 -- This message does not have token defined, but intentionally putting token
5978 -- because we still want to show the privilege name which is missing
5979 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_COPY_TM_RO'
5980 ,'MISSING_PRIVILEGE', l_privilege);
5981 l_error_flag_local := 'Y';
5982 END IF;
5983
5984 END IF;
5985 END IF;
5986
5987 --------------------------------------------------------
5988 -- Call Actual API
5989 --------------------------------------------------------
5990 IF l_error_flag_local <> 'Y' THEN
5991 l_return_status := FND_API.G_RET_STS_SUCCESS;
5992 l_msg_count:= 0;
5993 l_msg_data := NULL ;
5994
5995 IF l_debug_mode = 'Y' THEN
5996 pa_debug.write(l_module, 'Calling PA_ASSIGNMENTS_PUB.COPY_TEAM_ROLES for record number'||i, l_log_level);
5997 END IF;
5998
5999 l_before_api_msg_count := FND_MSG_PUB.count_msg;
6000 PA_ASSIGNMENTS_PUB.Copy_Team_Role
6001 (
6002 p_assignment_id => l_req_asgn_id,
6003 x_new_assignment_id => l_out_req_asgn_id ,
6004 x_assignment_number => l_out_req_asgn_number,
6005 x_assignment_row_id => l_out_req_asgn_row_id,
6006 x_return_status => l_return_status,
6007 x_msg_count => l_msg_count,
6008 x_msg_data => l_msg_data
6009 );
6010 l_after_api_msg_count := FND_MSG_PUB.count_msg;
6011
6012 IF l_debug_mode = 'Y' THEN
6013 pa_debug.write(l_module, 'After call PA_ASSIGNMENTS_PUB.COPY_TEAM_ROLES l_return_status='||l_return_status, l_log_level);
6014 END IF;
6015 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6016 l_error_flag_local := 'Y';
6017 X_REQ_ASGN_ID_TBL.extend(1);
6018 X_REQ_ASGN_ID_TBL(X_REQ_ASGN_ID_TBL.COUNT) := -1;
6019 ELSE -- Success
6020 IF (l_after_api_msg_count - l_before_api_msg_count) = 0 AND l_msg_data is NULL THEN
6021 X_REQ_ASGN_ID_TBL.extend(1);
6022 X_REQ_ASGN_ID_TBL(X_REQ_ASGN_ID_TBL.COUNT) := l_out_req_asgn_id ;
6023 ELSE -- some message populated while executing the called API
6024 l_error_flag_local := 'Y';
6025 X_REQ_ASGN_ID_TBL.extend(1);
6026 X_REQ_ASGN_ID_TBL(X_REQ_ASGN_ID_TBL.COUNT) := -1 ; -- to indicate some wrong operation happened
6027 END IF;
6028 END IF;
6029 END IF;
6030
6031 l_end_msg_count := FND_MSG_PUB.count_msg;
6032 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
6033
6034 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
6035 l_error_flag := 'Y';
6036
6037
6038 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
6039 -- Always get from first location in stack i.e. l_start_msg_count+1
6040 -- Because stack moves down after delete
6041
6042 FND_MSG_PUB.get (
6043 p_msg_index => l_start_msg_count+1,
6044 p_encoded => FND_API.G_FALSE,
6045 p_data => l_data,
6046 p_msg_index_out => l_msg_index_out );
6047
6048 -- Always delete at first location in stack i.e. l_start_msg_count+1
6049 -- Because stack moves down after delete
6050 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
6051
6052 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
6053 'RECORD_NO', i,
6054 'MESSAGE', l_data);
6055 END LOOP;
6056 END IF;
6057
6058 i := p_req_asgn_id_tbl.next(i);
6059 END LOOP;
6060
6061 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
6062 RAISE FND_API.G_EXC_ERROR;
6063 END IF;
6064
6065 IF l_debug_mode = 'Y' THEN
6066 PA_DEBUG.reset_curr_function;
6067 END IF;
6068
6069 IF p_commit = FND_API.G_TRUE THEN
6070 commit;
6071 END IF;
6072 EXCEPTION
6073 WHEN FND_API.G_EXC_ERROR THEN
6074 x_return_status := FND_API.G_RET_STS_ERROR;
6075 l_msg_count := FND_MSG_PUB.count_msg;
6076
6077 IF p_commit = FND_API.G_TRUE THEN
6078 ROLLBACK TO COPY_TEAM_ROLES_SP;
6079 END IF;
6080
6081 IF c_derive_values%ISOPEN THEN
6082 CLOSE c_derive_values ;
6083 END IF;
6084
6085 IF c_get_system_status%ISOPEN THEN
6086 CLOSE c_get_system_status ;
6087 END IF;
6088
6089 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
6090 PA_INTERFACE_UTILS_PUB.get_messages
6091 ( p_encoded => FND_API.G_FALSE
6092 , p_msg_index => 1
6093 , p_msg_count => l_msg_count
6094 , p_msg_data => l_msg_data
6095 , p_data => l_data
6096 , p_msg_index_out => l_msg_index_out);
6097
6098 x_msg_data := l_data;
6099 x_msg_count := l_msg_count;
6100 ELSE
6101 x_msg_count := l_msg_count;
6102 END IF;
6103
6104
6105 IF l_debug_mode = 'Y' THEN
6106 Pa_Debug.reset_curr_function;
6107 END IF;
6108
6109 WHEN OTHERS THEN
6110
6111 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
6112 x_msg_data := SUBSTRB(SQLERRM,1,240);
6113
6114 IF p_commit = FND_API.G_TRUE THEN
6115 ROLLBACK TO COPY_TEAM_ROLES_SP;
6116 END IF;
6117
6118 IF c_derive_values%ISOPEN THEN
6119 CLOSE c_derive_values ;
6120 END IF;
6121
6122 IF c_get_system_status%ISOPEN THEN
6123 CLOSE c_get_system_status ;
6124 END IF;
6125
6126 FND_MSG_PUB.add_exc_msg
6127 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
6128 , p_procedure_name => 'COPY_TEAM_ROLES'
6129 , p_error_text => x_msg_data);
6130
6131 x_msg_count := FND_MSG_PUB.count_msg;
6132
6133 IF l_debug_mode = 'Y' THEN
6134 PA_DEBUG.reset_curr_function;
6135 END IF;
6136 RAISE;
6137
6138 END COPY_TEAM_ROLES;
6139
6140 -- Start of comments
6141 -- API name : CREATE_ASSIGNMENTS
6142 -- Type : Public
6143 -- Pre-reqs : None.
6144 -- Function : This is a public API to create one or more assignments for one or more projects.
6145 -- Usage : This API will be called from AMG.
6146 -- Parameters :
6147 -- IN : p_commit IN VARCHAR2
6148 -- Identifier to commit the transaction.
6149 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
6150 -- p_init_msg_list IN VARCHAR2
6151 -- Identifier to initialize the error message stack.
6152 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
6153 -- p_api_version_number IN NUMBER Required
6154 -- To be compliant with Applications API coding standards.
6155 -- p_assignment_in_tbl IN ASSIGNMENT_IN_TBL_TYPE Required
6156 -- Table of assignment records.
6157 -- Please see the ASSIGNMENT_IN_TBL_TYPE datatype table.
6158 -- OUT :
6159 -- x_assignment_id_tbl OUT SYSTEM.PA_NUM_TBL_TYPE
6160 -- Table to store assignment ids created by the API.
6161 -- Reference: pa_project_assignments.assignment_id
6162 -- x_return_status OUT VARCHAR2
6163 -- Indicates the return status of the API.
6164 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
6165 -- x_msg_count OUT NUMBER
6166 -- Indicates the number of error messages in the message stack
6167 -- x_msg_data OUT VARCHAR2
6168 -- Indicates the error message text if only one error exists
6169 -- History :
6170 -- 01-Mar-2006 - amksingh - Created
6171 -- End of comments
6172 PROCEDURE CREATE_ASSIGNMENTS
6173 (
6174 p_api_version_number IN NUMBER := 1.0
6175 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
6176 , p_commit IN VARCHAR2 := FND_API.G_FALSE
6177 , p_assignment_in_tbl IN ASSIGNMENT_IN_TBL_TYPE
6178 , x_assignment_id_tbl OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE
6179 , x_return_status OUT NOCOPY VARCHAR2
6180 , x_msg_count OUT NOCOPY NUMBER
6181 , x_msg_data OUT NOCOPY VARCHAR2
6182 )
6183 IS
6184 l_calling_application VARCHAR2(10) := 'PLSQL';
6185 l_calling_module VARCHAR2(10) := 'AMG';
6186 l_check_id_flag VARCHAR2(1) := 'Y';
6187 l_check_role_security_flag VARCHAR2(1) := 'Y';
6188 l_check_resource_security_flag VARCHAR2(1) := 'Y';
6189 l_log_level NUMBER := 3;
6190 l_module VARCHAR2(100) := 'PA_RES_MANAGEMENT_AMG_PUB.CREATE_ASSIGNMENTS';
6191 l_commit VARCHAR2(1) := FND_API.G_FALSE;
6192 l_init_msg_list VARCHAR2(1) := FND_API.G_FALSE;
6193 l_validate_only VARCHAR2(1) := FND_API.G_FALSE;
6194 l_msg_count NUMBER;
6195 l_msg_data VARCHAR2(2000);
6196 l_msg_index_out NUMBER;
6197 l_data VARCHAR2(2000);
6198 l_debug_mode VARCHAR2(1);
6199
6200 i NUMBER;
6201 l_new_assignment_id_tbl SYSTEM.PA_NUM_TBL_TYPE := SYSTEM.PA_NUM_TBL_TYPE();
6202 l_new_assignment_id NUMBER;
6203 l_assignment_number NUMBER;
6204 l_assignment_row_id ROWID;
6205 l_resource_id NUMBER;
6206 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
6207 l_error_flag VARCHAR2(1) := 'N';
6208 l_error_flag_local VARCHAR2(1) := 'N';
6209 l_asgn_rec ASSIGNMENT_IN_REC_TYPE;
6210 l_asgn_creation_mode VARCHAR2(10) := 'FULL';
6211 --l_assignment_type VARCHAR2(30) := 'OPEN_ASSIGNMENT';
6212 l_multiple_status_flag VARCHAR2(1) := 'N';
6213 l_loop_msg_count NUMBER :=0;
6214 l_start_msg_count NUMBER :=0;
6215 l_end_msg_count NUMBER :=0;
6216 l_missing_params VARCHAR2(1000);
6217 l_privilege VARCHAR2(30);
6218 l_object_name VARCHAR2(30);
6219 l_object_key NUMBER;
6220 l_error_message_code VARCHAR2(30);
6221 l_ret_code VARCHAR2(1);
6222
6223
6224 CURSOR c_get_valid_calendar_types(c_code VARCHAR2) IS
6225 SELECT lookup_code
6226 FROM pa_lookups
6227 WHERE lookup_type = 'CHANGE_CALENDAR_TYPE_CODE'
6228 AND lookup_code = c_code
6229 AND lookup_code <> 'RESOURCE';
6230
6231 CURSOR c_get_project_dtls(c_project_id NUMBER) IS
6232 SELECT role_list_id, multi_currency_billing_flag, calendar_id, work_type_id, location_id
6233 FROM pa_projects_all
6234 WHERE project_id = c_project_id;
6235
6236 CURSOR c_get_team_templ_dtls(c_team_templ_id NUMBER) IS
6237 SELECT role_list_id, calendar_id, work_type_id
6238 FROM pa_team_templates
6239 WHERE team_template_id = c_team_templ_id;
6240
6241 CURSOR c_get_role_dtls(c_role_id NUMBER) IS
6242 SELECT meaning
6243 FROM pa_project_role_types_vl
6244 WHERE project_role_id = c_role_id ;
6245
6246 CURSOR get_bill_rate_override_flags(c_project_id NUMBER) IS
6247 SELECT impl.rate_discount_reason_flag ,impl.br_override_flag, impl.br_discount_override_flag
6248 FROM pa_implementations_all impl
6249 , pa_projects_all proj
6250 WHERE proj.org_id=impl.org_id -- Removed nvl condition from org_id : Post review changes for Bug 5130421
6251 AND proj.project_id = c_project_id ;
6252
6253 CURSOR c_get_lookup_exists(c_lookup_type VARCHAR2, c_lookup_code VARCHAR2) IS
6254 SELECT 'Y'
6255 FROM dual
6256 WHERE EXISTS
6257 (SELECT 'XYZ' FROM pa_lookups WHERE lookup_type = c_lookup_type AND lookup_code = c_lookup_code);
6258
6259 CURSOR c_get_location(c_location_id NUMBER) IS
6260 SELECT country_code, region, city
6261 FROM pa_locations
6262 WHERE location_id = c_location_id;
6263
6264 CURSOR c_derive_country_code(c_country_name IN VARCHAR2) IS
6265 SELECT country_code
6266 FROM pa_country_v
6267 WHERE name = c_country_name;
6268
6269 CURSOR c_derive_country_name(c_country_code IN VARCHAR2) IS
6270 SELECT name
6271 FROM pa_country_v
6272 WHERE country_code = c_country_code;
6273
6274
6275 -- This cursor is for future extension when we support creation of team role from planning resource
6276 CURSOR c_get_planning_res_info(c_resource_list_member_id NUMBER, c_budget_version_id NUMBER, c_project_id NUMBER) IS
6277 SELECT
6278 ra.resource_list_member_id
6279 , firstrow.person_id
6280 , rlm.resource_id
6281 , PA_RESOURCE_UTILS.get_person_name_no_date(firstrow.person_id)
6282 , ra.project_id
6283 , ra.budget_version_id
6284 , decode (ra.role_count, 1, firstrow.named_role, null) named_role
6285 , decode (ra.role_count, 1, firstrow.project_role_id, null) project_role_id
6286 , decode (ra.role_count, 1, ro.meaning, null) project_role
6287 , ra.min_date task_assign_start_date
6288 , ra.max_date task_assign_end_date
6289 , firstrow.resource_assignment_id
6290 , firstrow.res_type_code
6291 FROM pa_resource_assignments firstrow
6292 , pa_resource_list_members rlm
6293 , pa_proj_roles_v ro
6294 , (SELECT project_id , budget_version_id , resource_list_member_id , count(1) role_count , max(max_id) max_id
6295 , min(min_date) min_date , max(max_date) max_date
6296 FROM (SELECT project_id , budget_version_id , resource_list_member_id , project_role_id
6297 , max(resource_assignment_id) max_id , min(SCHEDULE_START_DATE) min_date , max(SCHEDULE_END_DATE) max_date
6298 FROM pa_resource_assignments
6299 WHERE ta_display_flag = 'Y' and nvl(PROJECT_ASSIGNMENT_ID, -1) = -1
6300 AND resource_class_code = 'PEOPLE'
6301 GROUP BY project_id, budget_version_id, resource_list_member_id, project_role_id
6302 ) res_roles
6303 GROUP BY project_id, budget_version_id, resource_list_member_id
6304 ) ra
6305 WHERE ra.resource_list_member_id = rlm.resource_list_member_id
6306 AND firstrow.resource_assignment_id = ra.max_id
6307 AND firstrow.project_role_id = ro.project_role_id (+)
6308 AND ra.budget_version_id = c_budget_version_id
6309 AND ra.resource_list_member_id = c_resource_list_member_id
6310 AND ra.project_id = c_project_id
6311 AND firstrow.person_id IS NULL;
6312 -- If the value from this cusror is returned, then passed resource list member id is valid
6313 -- Pass this resource list member id, budget version id to internal API
6314 -- Pass calendar type as PROJECT and calendar_id as of project
6315 -- Pass sum_tasks_flag as N
6316
6317 -- In case of assignments, user can choose calendar type between PROJECT or RESOURCE
6318 -- Pass this resource list member id, budget version id to internal API
6319 -- Pass sum_tasks_flag as Y if calendar is RESOURCE
6320 -- pass person_id, resource_id
6321
6322 -- Bug 5175060
6323 CURSOR c_get_system_status_code(c_status_code VARCHAR2, c_status_type VARCHAR2) IS
6324 SELECT project_system_status_code,starting_status_flag
6325 FROM pa_project_statuses
6326 WHERE status_type = c_status_type
6327 AND project_status_code = c_status_code;
6328
6329 CURSOR c_get_sys_code_from_name(c_status_name VARCHAR2, c_status_type VARCHAR2) IS
6330 SELECT project_system_status_code,starting_status_flag
6331 FROM pa_project_statuses
6332 WHERE status_type = c_status_type
6333 AND project_status_name = c_status_name;
6334
6335 l_dummy_sys_code pa_project_statuses.project_system_status_code%TYPE;
6336 --End 5175060
6337
6338 l_starting_status_flag VARCHAR2(1);
6339
6340 l_role_list_id NUMBER;
6341 l_multi_currency_billing_flag VARCHAR2(1);
6342 l_calendar_id NUMBER;
6343 l_work_type_id NUMBER;
6344 l_location_id NUMBER;
6345 l_role_name VARCHAR2(80);
6346 l_valid_flag VARCHAR2(1);
6347 l_rate_discount_reason_flag VARCHAR2(1);
6348 l_br_override_flag VARCHAR2(1);
6349 l_br_discount_override_flag VARCHAR2(1);
6350 l_project_id_tmp NUMBER;
6351 l_project_role_id_tmp NUMBER;
6352 l_tp_currency_override_tmp VARCHAR2(30);
6353 l_my_person_id NUMBER;
6354 l_my_resource_id NUMBER;
6355 l_my_resource_name VARCHAR2(240);
6356 l_valid_country VARCHAR2(1);
6357 l_dummy_country_code VARCHAR2(2);
6358 l_dummy_state VARCHAR2(240);
6359 l_dummy_city VARCHAR2(80);
6360 l_out_location_id NUMBER;
6361 l_bill_currency_override_tmp VARCHAR2(30); -- 5144288, 5144369
6362
6363 BEGIN
6364
6365 --Flows which are supported by this API
6366 ---------------------------------------
6367 --1. Create project assignments
6368 -- 1.1 Setting basic information(staffing priority, staffing owner, subteams, location etc..)
6369 -- 1.2 Setting schedule information(dates, status, calendar etc..)
6370 -- 1.3 Setting forecast infomation(expenditure type etc..)
6371 --
6372 --Flows which are not supported by this API
6373 -------------------------------------------
6374 --1. Create team role for given planning resource
6375
6376 --Mandatory parameters
6377 -----------------------
6378 --1. assignment_type should be specified.
6379 --2. Either project_role_id or project_role_name should be passed.
6380 --3. Either of project_id, project_name, project_number should be passed.
6381 --4. resource_id should be passed.
6382 --5. Both start_date and end_date should be passed.
6383 --6. Either status_code or status_name should be specified.
6384
6385
6386 x_return_status := FND_API.G_RET_STS_SUCCESS;
6387 x_assignment_id_tbl:= SYSTEM.pa_num_tbl_type();
6388
6389 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE', fnd_global.user_id, fnd_global.login_id, 275, null, null), 'N');
6390
6391 IF l_debug_mode = 'Y' THEN
6392 PA_DEBUG.set_curr_function(p_function => 'CREATE_ASSIGNMENTS', p_debug_mode => l_debug_mode);
6393 END IF;
6394
6395 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list, FND_API.G_TRUE)) THEN
6396 FND_MSG_PUB.initialize;
6397 END IF;
6398
6399 IF p_commit = FND_API.G_TRUE THEN
6400 savepoint CREATE_ASSIGNMENTS_SP;
6401 END IF;
6402
6403 IF l_debug_mode = 'Y' THEN
6404 pa_debug.write(l_module, 'Start of create_assignments', l_log_level);
6405 END IF;
6406
6407 IF l_debug_mode = 'Y' THEN
6408 pa_debug.write(l_module, 'Printing Input Parameters......', l_log_level);
6409 i := p_assignment_in_tbl.first;
6410 WHILE i IS NOT NULL LOOP
6411 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').assignment_id'||p_assignment_in_tbl(i).assignment_id, l_log_level);
6412 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').assignment_name'||p_assignment_in_tbl(i).assignment_name, l_log_level);
6413 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').assignment_type'||p_assignment_in_tbl(i).assignment_type, l_log_level);
6414 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_role_id'||p_assignment_in_tbl(i).project_role_id, l_log_level);
6415 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_role_name'||p_assignment_in_tbl(i).project_role_name, l_log_level);
6416 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_id'||p_assignment_in_tbl(i).project_id, l_log_level);
6417 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_name'||p_assignment_in_tbl(i).project_name, l_log_level);
6418 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_number'||p_assignment_in_tbl(i).project_number, l_log_level);
6419 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').resource_id'||p_assignment_in_tbl(i).resource_id, l_log_level);
6420 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').staffing_owner_person_id'||p_assignment_in_tbl(i).staffing_owner_person_id, l_log_level);
6421 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').staffing_priority_code'||p_assignment_in_tbl(i).staffing_priority_code, l_log_level);
6422 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').staffing_priority_name'||p_assignment_in_tbl(i).staffing_priority_name, l_log_level);
6423 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_subteam_id'||p_assignment_in_tbl(i).project_subteam_id, l_log_level);
6424 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_subteam_name'||p_assignment_in_tbl(i).project_subteam_name, l_log_level);
6425 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_id'||p_assignment_in_tbl(i).location_id, l_log_level);
6426 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_country_code'||p_assignment_in_tbl(i).location_country_code, l_log_level);
6427 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_country_name'||p_assignment_in_tbl(i).location_country_name, l_log_level);
6428 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_region'||p_assignment_in_tbl(i).location_region, l_log_level);
6429 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_city'||p_assignment_in_tbl(i).location_city, l_log_level);
6430 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').description'||p_assignment_in_tbl(i).description, l_log_level);
6431 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').additional_information'||p_assignment_in_tbl(i).additional_information, l_log_level);
6432 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').start_date'||p_assignment_in_tbl(i).start_date, l_log_level);
6433 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').end_date'||p_assignment_in_tbl(i).end_date, l_log_level);
6434 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').status_code'||p_assignment_in_tbl(i).status_code, l_log_level);
6435 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').status_name'||p_assignment_in_tbl(i).status_name, l_log_level);
6436 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').calendar_type'||p_assignment_in_tbl(i).calendar_type, l_log_level);
6437 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').calendar_id'||p_assignment_in_tbl(i).calendar_id, l_log_level);
6438 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').calendar_name'||p_assignment_in_tbl(i).calendar_name, l_log_level);
6439 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').resource_calendar_percent'||p_assignment_in_tbl(i).resource_calendar_percent, l_log_level);
6440 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').expenditure_type_class'||p_assignment_in_tbl(i).expenditure_type_class, l_log_level);
6441 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').expenditure_type'||p_assignment_in_tbl(i).expenditure_type, l_log_level);
6442 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').work_type_id'||p_assignment_in_tbl(i).work_type_id, l_log_level);
6443 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').work_type_name'||p_assignment_in_tbl(i).work_type_name, l_log_level);
6444 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').bill_rate_option'||p_assignment_in_tbl(i).bill_rate_option, l_log_level);
6445 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').bill_rate_override'||p_assignment_in_tbl(i).bill_rate_override, l_log_level);
6446 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').bill_rate_curr_override'||p_assignment_in_tbl(i).bill_rate_curr_override, l_log_level);
6447 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').markup_percent_override'||p_assignment_in_tbl(i).markup_percent_override, l_log_level);
6448 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').discount_percentage'||p_assignment_in_tbl(i).discount_percentage, l_log_level);
6449 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').rate_disc_reason_code'||p_assignment_in_tbl(i).rate_disc_reason_code, l_log_level);
6450 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_rate_option'||p_assignment_in_tbl(i).tp_rate_option, l_log_level);
6451 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_rate_override'||p_assignment_in_tbl(i).tp_rate_override, l_log_level);
6452 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_currency_override'||p_assignment_in_tbl(i).tp_currency_override, l_log_level);
6453 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_calc_base_code_override'||p_assignment_in_tbl(i).tp_calc_base_code_override, l_log_level);
6454 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_percent_applied_override'||p_assignment_in_tbl(i).tp_percent_applied_override, l_log_level);
6455 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').extension_possible'||p_assignment_in_tbl(i).extension_possible, l_log_level);
6456 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').expense_owner'||p_assignment_in_tbl(i).expense_owner, l_log_level);
6457 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').expense_limit'||p_assignment_in_tbl(i).expense_limit, l_log_level);
6458 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').orig_system_code'||p_assignment_in_tbl(i).orig_system_code, l_log_level);
6459 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').orig_system_reference'||p_assignment_in_tbl(i).orig_system_reference, l_log_level);
6460 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').record_version_number'||p_assignment_in_tbl(i).record_version_number, l_log_level);
6461 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').auto_approve ' || p_assignment_in_tbl(i).auto_approve, l_log_level);
6462 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute_category'||p_assignment_in_tbl(i).attribute_category, l_log_level);
6463 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute1'||p_assignment_in_tbl(i).attribute1, l_log_level);
6464 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute2'||p_assignment_in_tbl(i).attribute2, l_log_level);
6465 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute3'||p_assignment_in_tbl(i).attribute3, l_log_level);
6466 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute4'||p_assignment_in_tbl(i).attribute4, l_log_level);
6467 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute5'||p_assignment_in_tbl(i).attribute5, l_log_level);
6468 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute6'||p_assignment_in_tbl(i).attribute6, l_log_level);
6469 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute7'||p_assignment_in_tbl(i).attribute7, l_log_level);
6470 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute8'||p_assignment_in_tbl(i).attribute8, l_log_level);
6471 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute9'||p_assignment_in_tbl(i).attribute9, l_log_level);
6472 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute10'||p_assignment_in_tbl(i).attribute10, l_log_level);
6473 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute11'||p_assignment_in_tbl(i).attribute11, l_log_level);
6474 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute12'||p_assignment_in_tbl(i).attribute12, l_log_level);
6475 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute13'||p_assignment_in_tbl(i).attribute13, l_log_level);
6476 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute14'||p_assignment_in_tbl(i).attribute14, l_log_level);
6477 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute15'||p_assignment_in_tbl(i).attribute15, l_log_level);
6478 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
6479 i := p_assignment_in_tbl.next(i);
6480 END LOOP;
6481 END IF;
6482
6483 PA_STARTUP.INITIALIZE(
6484 p_calling_application => l_calling_application
6485 , p_calling_module => l_calling_module
6486 , p_check_id_flag => l_check_id_flag
6487 , p_check_role_security_flag => l_check_role_security_flag
6488 , p_check_resource_security_flag => l_check_resource_security_flag
6489 , p_debug_level => l_log_level
6490 );
6491
6492 IF l_debug_mode = 'Y' THEN
6493 pa_debug.write(l_module, 'After call of pa_startup.initialize', l_log_level);
6494 END IF;
6495
6496 -- Page does not check PRM licensing, but keeping this code so in future if required, can be used
6497 --l_prm_license_flag := nvl(FND_PROFILE.VALUE('PA_PRM_LICENSED'),'N');
6498 --IF l_prm_license_flag <> 'Y' THEN
6499 -- null;
6500 --END IF;
6501
6502 i := p_assignment_in_tbl.first;
6503
6504 WHILE i IS NOT NULL LOOP
6505 l_error_flag_local := 'N';
6506 l_missing_params := null;
6507 l_asgn_rec := null;
6508 l_valid_country := 'Y';
6509 PA_STAFFED_ASSIGNMENT_PVT.G_AUTO_APPROVE := NULL ;
6510
6511 l_start_msg_count := FND_MSG_PUB.count_msg;
6512
6513 l_asgn_rec := p_assignment_in_tbl(i);
6514
6515 -- Blank Out Parameters if not passed.
6516 IF l_debug_mode = 'Y' THEN
6517 pa_debug.write(l_module, 'Record#'||i, l_log_level);
6518 pa_debug.write(l_module, '-----------------------------', l_log_level);
6519 pa_debug.write(l_module, 'NullOut parameters which are not required.', l_log_level);
6520 END IF;
6521
6522 /*--Bug 6511907 PJR Date Validation Enhancement ----- Start--*/
6523 /*-- Validating Resource Req Start and End Date against
6524 Project Start and Completion dates --*/
6525
6526 Declare
6527 l_validate VARCHAR2(10);
6528 l_start_date_status VARCHAR2(10);
6529 l_end_date_status VARCHAR2(10);
6530 l_start_date DATE;
6531 l_end_date DATE;
6532 Begin
6533 If l_asgn_rec.start_date is not null or l_asgn_rec.end_date is not null then
6534 l_start_date := l_asgn_rec.start_date;
6535 l_end_date := l_asgn_rec.end_date;
6536 PA_PROJECT_DATES_UTILS.Validate_Resource_Dates
6537 (l_asgn_rec.project_id, l_start_date, l_end_date,
6538 l_validate, l_start_date_status, l_end_date_status);
6539
6540 If l_validate = 'Y' and l_start_date_status = 'I' Then
6541
6542 pa_utils.add_message
6543 ( p_app_short_name => 'PA'
6544 ,p_msg_name => 'PA_PJR_DATE_START_ERROR'
6545 ,p_token1 => 'PROJ_TXN_START_DATE'
6546 ,p_value1 => GET_PROJECT_START_DATE(l_asgn_rec.project_id)
6547 ,p_token2 => ''
6548 ,p_value2 => ''
6549 ,p_token3 => ''
6550 ,p_value3 => ''
6551 );
6552
6553 RAISE FND_API.G_EXC_ERROR;
6554 End If;
6555
6556 If l_validate = 'Y' and l_end_date_status = 'I' Then
6557
6558 pa_utils.add_message
6559 ( p_app_short_name => 'PA'
6560 ,p_msg_name => 'PA_PJR_DATE_FINISH_ERROR'
6561 ,p_token1 => 'PROJ_TXN_END_DATE'
6562 ,p_value1 => GET_PROJECT_COMPLETION_DATE(l_asgn_rec.project_id)
6563 ,p_token2 => ''
6564 ,p_value2 => ''
6565 ,p_token3 => ''
6566 ,p_value3 => ''
6567 );
6568
6569 RAISE FND_API.G_EXC_ERROR;
6570 End If;
6571 End If;
6572 End;
6573
6574 /*--Bug 6511907 PJR Date Validation Enhancement ----- End--*/
6575 IF l_asgn_rec.assignment_id = G_PA_MISS_NUM THEN
6576 l_asgn_rec.assignment_id := null;
6577 END IF;
6578
6579 IF l_asgn_rec.assignment_name = G_PA_MISS_CHAR THEN
6580 l_asgn_rec.assignment_name := null;
6581 END IF;
6582
6583 IF l_asgn_rec.assignment_type = G_PA_MISS_CHAR THEN
6584 l_asgn_rec.assignment_type := null;
6585 END IF;
6586
6587
6588 IF l_asgn_rec.project_role_id = G_PA_MISS_NUM THEN
6589 l_asgn_rec.project_role_id := null;
6590 END IF;
6591
6592 IF l_asgn_rec.project_role_name = G_PA_MISS_CHAR THEN
6593 l_asgn_rec.project_role_name := null;
6594 END IF;
6595
6596 IF l_asgn_rec.project_id = G_PA_MISS_NUM THEN
6597 l_asgn_rec.project_id := null;
6598 END IF;
6599
6600 IF l_asgn_rec.project_name = G_PA_MISS_CHAR THEN
6601 l_asgn_rec.project_name := null;
6602 END IF;
6603
6604 IF l_asgn_rec.project_number = G_PA_MISS_CHAR THEN
6605 l_asgn_rec.project_number := null;
6606 END IF;
6607
6608 IF l_asgn_rec.resource_id = G_PA_MISS_NUM THEN
6609 l_asgn_rec.resource_id := null;
6610 END IF;
6611
6612
6613 -- Some fields like Staffing Owner will be defaulted further in internal APIs
6614 -- But user may like to pass them explicitely as null
6615 -- So in that case we need to distinguish MISS NUM with null
6616 -- But there is a problem that pa_inerface_utils_pub.g_pa_miss_num
6617 -- is diffrent than fnd_api.g_miss_num. PJR internal code uses
6618 -- fnd_api.g_miss_num, so it throws the error.
6619 -- For this reason, we need to convert the G_PA_MISS_NUM/CHAR to FND_API.G_MISS_NUM/CHAR
6620 -- before sending it to internal APIs
6621
6622 IF l_asgn_rec.staffing_owner_person_id = G_PA_MISS_NUM THEN
6623 -- We can not make null here
6624 -- Because underlying API treat null as override and does not
6625 -- default value.
6626 l_asgn_rec.staffing_owner_person_id := FND_API.G_MISS_NUM;
6627 END IF;
6628
6629 IF l_asgn_rec.staffing_priority_code = G_PA_MISS_CHAR THEN
6630 l_asgn_rec.staffing_priority_code := null;
6631 END IF;
6632
6633 IF l_asgn_rec.staffing_priority_name = G_PA_MISS_CHAR THEN
6634 l_asgn_rec.staffing_priority_name := null;
6635 END IF;
6636
6637 IF l_asgn_rec.project_subteam_id = G_PA_MISS_NUM THEN
6638 l_asgn_rec.project_subteam_id := null;
6639 END IF;
6640
6641 IF l_asgn_rec.project_subteam_name = G_PA_MISS_CHAR THEN
6642 l_asgn_rec.project_subteam_name := null;
6643 END IF;
6644
6645 -- Location will be default to project location for project requirments
6646 -- But user may like to pass them explicitely as null
6647 -- So in that case we need to distinguish MISS CHAR with null
6648 IF l_asgn_rec.location_id = G_PA_MISS_NUM THEN
6649 l_asgn_rec.location_id := FND_API.G_MISS_NUM;
6650 END IF;
6651
6652 IF l_asgn_rec.location_country_code = G_PA_MISS_CHAR THEN
6653 l_asgn_rec.location_country_code := FND_API.G_MISS_CHAR;
6654 END IF;
6655
6656 IF l_asgn_rec.location_country_name = G_PA_MISS_CHAR THEN
6657 l_asgn_rec.location_country_name := FND_API.G_MISS_CHAR;
6658 END IF;
6659
6660 IF l_asgn_rec.location_region = G_PA_MISS_CHAR THEN
6661 l_asgn_rec.location_region := FND_API.G_MISS_CHAR;
6662 END IF;
6663
6664 IF l_asgn_rec.location_city = G_PA_MISS_CHAR THEN
6665 l_asgn_rec.location_city := FND_API.G_MISS_CHAR;
6666 END IF;
6667
6668
6669 IF l_asgn_rec.description = G_PA_MISS_CHAR THEN
6670 l_asgn_rec.description := null;
6671 END IF;
6672
6673 IF l_asgn_rec.additional_information = G_PA_MISS_CHAR THEN
6674 l_asgn_rec.additional_information := null;
6675 END IF;
6676
6677 IF l_asgn_rec.start_date = G_PA_MISS_DATE THEN
6678 l_asgn_rec.start_date := null;
6679 END IF;
6680
6681 IF l_asgn_rec.end_date = G_PA_MISS_DATE THEN
6682 l_asgn_rec.end_date := null;
6683 END IF;
6684
6685 IF l_asgn_rec.status_code = G_PA_MISS_CHAR THEN
6686 l_asgn_rec.status_code := null;
6687 END IF;
6688
6689 IF l_asgn_rec.status_name = G_PA_MISS_CHAR THEN
6690 l_asgn_rec.status_name := null;
6691 END IF;
6692
6693 IF l_asgn_rec.calendar_type = G_PA_MISS_CHAR THEN
6694 l_asgn_rec.calendar_type := 'PROJECT';
6695 END IF;
6696
6697 IF l_asgn_rec.calendar_id = G_PA_MISS_NUM THEN
6698 l_asgn_rec.calendar_id := null;
6699 END IF;
6700
6701 IF l_asgn_rec.calendar_name = G_PA_MISS_CHAR THEN
6702 l_asgn_rec.calendar_name := null;
6703 END IF;
6704 -- 5171889 : Changed = to <>
6705 --IF l_asgn_rec.resource_calendar_percent = G_PA_MISS_NUM OR l_asgn_rec.calendar_type = 'RESOURCE' THEN
6706 IF l_asgn_rec.resource_calendar_percent = G_PA_MISS_NUM OR l_asgn_rec.calendar_type <> 'RESOURCE' THEN
6707 l_asgn_rec.resource_calendar_percent := null;
6708 END IF;
6709
6710 IF l_asgn_rec.expenditure_type_class = G_PA_MISS_CHAR THEN
6711 l_asgn_rec.expenditure_type_class := null;
6712 END IF;
6713
6714 IF l_asgn_rec.expenditure_type = G_PA_MISS_CHAR THEN
6715 l_asgn_rec.expenditure_type := null;
6716 END IF;
6717
6718 IF l_asgn_rec.work_type_id = G_PA_MISS_NUM THEN
6719 l_asgn_rec.work_type_id := null;
6720 END IF;
6721
6722 IF l_asgn_rec.work_type_name = G_PA_MISS_CHAR THEN
6723 l_asgn_rec.work_type_name := null;
6724 END IF;
6725
6726 IF l_asgn_rec.bill_rate_option = G_PA_MISS_CHAR THEN
6727 l_asgn_rec.bill_rate_option := 'NONE';
6728 END IF;
6729
6730 IF l_asgn_rec.bill_rate_override = G_PA_MISS_NUM THEN
6731 l_asgn_rec.bill_rate_override := null;
6732 END IF;
6733
6734 IF l_asgn_rec.bill_rate_curr_override = G_PA_MISS_CHAR THEN
6735 l_asgn_rec.bill_rate_curr_override := null;
6736 END IF;
6737
6738 IF l_asgn_rec.markup_percent_override = G_PA_MISS_NUM THEN
6739 l_asgn_rec.markup_percent_override := null;
6740 END IF;
6741
6742 IF l_asgn_rec.discount_percentage = G_PA_MISS_NUM THEN
6743 l_asgn_rec.discount_percentage := null;
6744 END IF;
6745
6746 IF l_asgn_rec.rate_disc_reason_code = G_PA_MISS_CHAR THEN
6747 l_asgn_rec.rate_disc_reason_code := null;
6748 END IF;
6749
6750 IF l_asgn_rec.tp_rate_option = G_PA_MISS_CHAR THEN
6751 l_asgn_rec.tp_rate_option := 'NONE';
6752 END IF;
6753
6754 IF l_asgn_rec.tp_rate_override = G_PA_MISS_NUM THEN
6755 l_asgn_rec.tp_rate_override := null;
6756 END IF;
6757
6758 IF l_asgn_rec.tp_currency_override = G_PA_MISS_CHAR THEN
6759 l_asgn_rec.tp_currency_override := null;
6760 END IF;
6761
6762 IF l_asgn_rec.tp_calc_base_code_override = G_PA_MISS_CHAR THEN
6763 l_asgn_rec.tp_calc_base_code_override := null;
6764 END IF;
6765
6766 IF l_asgn_rec.tp_percent_applied_override = G_PA_MISS_NUM THEN
6767 l_asgn_rec.tp_percent_applied_override := null;
6768 END IF;
6769
6770 IF l_asgn_rec.extension_possible = G_PA_MISS_CHAR THEN
6771 l_asgn_rec.extension_possible := null;
6772 END IF;
6773
6774 IF l_asgn_rec.expense_owner = G_PA_MISS_CHAR THEN
6775 l_asgn_rec.expense_owner := null;
6776 END IF;
6777
6778 IF l_asgn_rec.expense_limit = G_PA_MISS_NUM THEN
6779 l_asgn_rec.expense_limit := null;
6780 END IF;
6781
6782 IF l_asgn_rec.orig_system_code = G_PA_MISS_CHAR THEN
6783 l_asgn_rec.orig_system_code := null;
6784 END IF;
6785
6786 IF l_asgn_rec.orig_system_reference = G_PA_MISS_CHAR THEN
6787 l_asgn_rec.orig_system_reference := null;
6788 END IF;
6789
6790 IF l_asgn_rec.record_version_number = G_PA_MISS_NUM THEN
6791 l_asgn_rec.record_version_number := 1;
6792 END IF;
6793
6794 IF l_asgn_rec.auto_approve = G_PA_MISS_CHAR THEN
6795 l_asgn_rec.auto_approve := 'N'; -- If this param is not passed ,take as 'N'
6796 END IF;
6797
6798 IF l_asgn_rec.auto_approve = 'Y' THEN
6799 -- If Auto Approve is True,then pass the status as Confirmed
6800 -- This is needed for the security check for resource authority
6801 -- to be done in PA_STAFFED_ASSIGNMENT_PVT.Create_Staffed_Assignment API (internal)
6802 -- One more reason is : Only Confirmed Assignments can be approved.
6803
6804 l_asgn_rec.status_code := '105';
6805 l_asgn_rec.status_name := 'Confirmed';
6806 END IF;
6807
6808 -- Set Global Variable for Auto Approve
6809 PA_STAFFED_ASSIGNMENT_PVT.G_AUTO_APPROVE := l_asgn_rec.auto_approve ;
6810
6811 IF l_asgn_rec.attribute_category = G_PA_MISS_CHAR THEN
6812 l_asgn_rec.attribute_category := null;
6813 END IF;
6814
6815 IF l_asgn_rec.attribute1 = G_PA_MISS_CHAR THEN
6816 l_asgn_rec.attribute1 := null;
6817 END IF;
6818
6819 IF l_asgn_rec.attribute2 = G_PA_MISS_CHAR THEN
6820 l_asgn_rec.attribute2 := null;
6821 END IF;
6822
6823 IF l_asgn_rec.attribute3 = G_PA_MISS_CHAR THEN
6824 l_asgn_rec.attribute3 := null;
6825 END IF;
6826
6827 IF l_asgn_rec.attribute4 = G_PA_MISS_CHAR THEN
6828 l_asgn_rec.attribute4 := null;
6829 END IF;
6830
6831 IF l_asgn_rec.attribute5 = G_PA_MISS_CHAR THEN
6832 l_asgn_rec.attribute5 := null;
6833 END IF;
6834
6835 IF l_asgn_rec.attribute6 = G_PA_MISS_CHAR THEN
6836 l_asgn_rec.attribute6 := null;
6837 END IF;
6838
6839 IF l_asgn_rec.attribute7 = G_PA_MISS_CHAR THEN
6840 l_asgn_rec.attribute7 := null;
6841 END IF;
6842
6843 IF l_asgn_rec.attribute8 = G_PA_MISS_CHAR THEN
6844 l_asgn_rec.attribute8 := null;
6845 END IF;
6846
6847 IF l_asgn_rec.attribute9 = G_PA_MISS_CHAR THEN
6848 l_asgn_rec.attribute9 := null;
6849 END IF;
6850
6851 IF l_asgn_rec.attribute10 = G_PA_MISS_CHAR THEN
6852 l_asgn_rec.attribute10 := null;
6853 END IF;
6854
6855 IF l_asgn_rec.attribute11 = G_PA_MISS_CHAR THEN
6856 l_asgn_rec.attribute11 := null;
6857 END IF;
6858
6859 IF l_asgn_rec.attribute12 = G_PA_MISS_CHAR THEN
6860 l_asgn_rec.attribute12 := null;
6861 END IF;
6862
6863 IF l_asgn_rec.attribute13 = G_PA_MISS_CHAR THEN
6864 l_asgn_rec.attribute13 := null;
6865 END IF;
6866
6867 IF l_asgn_rec.attribute14 = G_PA_MISS_CHAR THEN
6868 l_asgn_rec.attribute14 := null;
6869 END IF;
6870
6871 IF l_asgn_rec.attribute15 = G_PA_MISS_CHAR THEN
6872 l_asgn_rec.attribute15 := null;
6873 END IF;
6874
6875
6876 -- Mandatory Parameters Check
6877 -----------------------------
6878
6879 IF l_debug_mode = 'Y' THEN
6880 pa_debug.write(l_module, 'Mandatory parameter validation starts', l_log_level);
6881 END IF;
6882
6883 IF l_asgn_rec.assignment_type IS NULL OR l_asgn_rec.assignment_type NOT IN ('STAFFED_ASSIGNMENT','STAFFED_ADMIN_ASSIGNMENT') THEN
6884 l_missing_params := l_missing_params||', ASSIGNMENT_TYPE';
6885 END IF;
6886
6887 IF l_asgn_rec.project_role_id IS NULL AND l_asgn_rec.project_role_name IS NULL THEN
6888 l_missing_params := l_missing_params||', PROJECT_ROLE_ID, PROJECT_ROLE_NAME';
6889 END IF;
6890
6891 IF l_asgn_rec.project_id IS NULL AND l_asgn_rec.project_name IS NULL AND l_asgn_rec.project_number IS NULL
6892 THEN
6893 l_missing_params := l_missing_params||', PROJECT_ID, PROJECT_NAME, PROJECT_NUMBER';
6894 END IF;
6895
6896 IF l_asgn_rec.resource_id IS NULL THEN
6897 l_missing_params := l_missing_params||', RESOURCE_ID';
6898 END IF;
6899
6900
6901 IF l_asgn_rec.start_date IS NULL OR l_asgn_rec.end_date IS NULL THEN
6902 l_missing_params := l_missing_params||', START_DATE, END_DATE';
6903 END IF;
6904
6905 -- Assignment status is not mandatory, if not passed we default it to 104 (Provisonal)
6906 --IF l_asgn_rec.status_code IS NULL AND l_asgn_rec.status_name IS NULL THEN
6907 -- l_missing_params := l_missing_params||', STATUS_CODE, STATUS_NAME';
6908 --END IF;
6909 IF l_asgn_rec.status_code IS NULL AND l_asgn_rec.status_name IS NULL THEN
6910 l_asgn_rec.status_code := 104;
6911 END IF;
6912
6913 -- Bug 5175060 If Auto Approval is not there and Yet, Some other status other than
6914 -- Provisional is passed by user , Throw error.
6915
6916 -- If Status code is passed,it always takes precedence over name
6917
6918 IF l_asgn_rec.auto_approve = 'N' THEN
6919
6920 IF l_asgn_rec.status_code IS NOT NULL THEN
6921 OPEN c_get_system_status_code(l_asgn_rec.status_code,'STAFFED_ASGMT');
6922 FETCH c_get_system_status_code INTO l_dummy_sys_code,l_starting_status_flag; -- 5210813
6923 IF c_get_system_status_code%NOTFOUND THEN -- Not existent value passed
6924 l_missing_params := l_missing_params||', STATUS_CODE';
6925 ELSE
6926 -- If it is confirmed or its not a starting status throw error - 5210813
6927 IF l_dummy_sys_code = 'STAFFED_ASGMT_CONF' OR l_starting_status_flag ='N' THEN
6928 l_missing_params := l_missing_params||', STATUS_CODE';
6929 END IF;
6930 END IF;
6931 CLOSE c_get_system_status_code;
6932 ELSIF l_asgn_rec.status_name IS NOT NULL THEN
6933 OPEN c_get_sys_code_from_name(l_asgn_rec.status_name,'STAFFED_ASGMT');
6934 FETCH c_get_sys_code_from_name INTO l_dummy_sys_code,l_starting_status_flag; -- 5210813
6935 IF c_get_sys_code_from_name%NOTFOUND THEN -- Not existent value passed
6936 l_missing_params := l_missing_params||', STATUS_NAME';
6937 ELSE
6938 -- If it s confirmed or its not a starting status throw error
6939 IF l_dummy_sys_code = 'STAFFED_ASGMT_CONF' OR l_starting_status_flag ='N' THEN
6940 l_missing_params := l_missing_params||', STATUS_NAME';
6941 END IF;
6942 END IF;
6943 CLOSE c_get_sys_code_from_name; -- Correct spelling mistake in cursor name 5200325
6944 END IF;
6945
6946 END IF;
6947 -- End 5175060
6948 IF l_asgn_rec.location_id IS NULL OR l_asgn_rec.location_id = FND_API.G_MISS_NUM THEN
6949 -- If either city or state (or) both are passed ,then country is
6950 -- mandatory
6951 IF (l_asgn_rec.location_country_code IS NULL AND l_asgn_rec.location_country_name IS NULL)
6952 OR (l_asgn_rec.location_country_code = FND_API.G_MISS_CHAR AND l_asgn_rec.location_country_name = FND_API.G_MISS_CHAR)
6953 THEN
6954 IF (l_asgn_rec.location_region <> FND_API.G_MISS_CHAR AND l_asgn_rec.location_region IS NOT NULL)
6955 OR (l_asgn_rec.location_city <> FND_API.G_MISS_CHAR AND l_asgn_rec.location_city IS NOT NULL)
6956 THEN
6957 l_missing_params := l_missing_params||', LOCATION_COUNTRY_CODE, LOCATION_COUNTRY_NAME';
6958 l_valid_country := 'N';
6959 END IF;
6960 ELSIF l_asgn_rec.location_country_code IS NOT NULL AND l_asgn_rec.location_country_code <> FND_API.G_MISS_CHAR
6961 THEN
6962 OPEN c_derive_country_name(l_asgn_rec.location_country_code);
6963 FETCH c_derive_country_name INTO l_asgn_rec.location_country_name;
6964 IF c_derive_country_name%NOTFOUND THEN
6965 -- Invalid Country code passed.
6966 l_missing_params := l_missing_params||', LOCATION_COUNTRY_CODE';
6967 l_valid_country := 'N';
6968 ELSE
6969 l_valid_country := 'Y';
6970 END IF;
6971 CLOSE c_derive_country_name;
6972 ELSIF l_asgn_rec.location_country_name IS NOT NULL AND l_asgn_rec.location_country_name <> FND_API.G_MISS_CHAR
6973 THEN
6974 OPEN c_derive_country_code(l_asgn_rec.location_country_name);
6975 FETCH c_derive_country_code INTO l_asgn_rec.location_country_code;
6976 IF c_derive_country_code%NOTFOUND THEN
6977 -- Invalid Country Name passed.
6978 l_missing_params := l_missing_params||', LOCATION_COUNTRY_NAME';
6979 l_valid_country := 'N';
6980 ELSE
6981 l_valid_country := 'Y';
6982 END IF;
6983 CLOSE c_derive_country_code;
6984 END IF;
6985
6986 -- If the country is valid,then proceed with the state and city validations
6987 IF l_valid_country = 'Y' AND l_asgn_rec.location_country_code IS NOT NULL
6988 AND l_asgn_rec.location_country_code <> FND_API.G_MISS_CHAR
6989 THEN
6990
6991 l_dummy_country_code := l_asgn_rec.location_country_code;
6992 IF l_asgn_rec.location_region IS NULL OR l_asgn_rec.location_region = FND_API.G_MISS_CHAR THEN
6993 l_dummy_state := null;
6994 ELSE
6995 l_dummy_state := l_asgn_rec.location_region;
6996 END IF;
6997
6998 IF l_asgn_rec.location_city IS NULL OR l_asgn_rec.location_city = FND_API.G_MISS_CHAR THEN
6999 l_dummy_city := null;
7000 ELSE
7001 l_dummy_city := l_asgn_rec.location_city;
7002 END IF;
7003
7004 PA_LOCATION_UTILS.CHECK_LOCATION_EXISTS
7005 (
7006 p_country_code => l_dummy_country_code
7007 ,p_city => l_dummy_city
7008 ,p_region => l_dummy_state
7009 ,x_location_id => l_out_location_id
7010 ,x_return_status => l_return_status
7011 );
7012
7013 IF l_out_location_id IS NULL THEN
7014 PA_UTILS.ADD_MESSAGE('PA','PA_AMG_RES_INV_CRC_COMB');
7015 l_error_flag_local := 'Y'; -- 5148975
7016 ELSE
7017 l_asgn_rec.location_id := l_out_location_id;
7018 END IF;
7019 END IF;
7020 ELSE
7021 -- if location id is passed, then it will override the city, region, country code
7022 OPEN c_get_location(l_asgn_rec.location_id);
7023 FETCH c_get_location INTO l_asgn_rec.location_country_code, l_asgn_rec.location_region, l_asgn_rec.location_city;
7024
7025 IF c_get_location%NOTFOUND THEN
7026 l_missing_params := l_missing_params||', LOCATION_ID';
7027 END IF;
7028 CLOSE c_get_location;
7029 END IF; -- l_asgn_rec.location_id IS NULL OR l_asgn_rec.location_id = FND_API.G_MISS_NUM
7030
7031
7032 IF l_asgn_rec.calendar_type IS NULL OR (l_asgn_rec.calendar_type NOT IN('PROJECT','OTHER', 'RESOURCE')) THEN
7033 l_missing_params := l_missing_params||', CALENDAR_TYPE';
7034 ELSE
7035 IF l_asgn_rec.calendar_type = 'OTHER' AND l_asgn_rec.calendar_id IS NULL
7036 AND l_asgn_rec.calendar_name IS NULL
7037 THEN
7038 l_missing_params := l_missing_params||', CALENDAR_ID, CALENDAR_NAME';
7039 END IF;
7040 IF l_asgn_rec.calendar_type = 'RESOURCE' AND l_asgn_rec.resource_calendar_percent IS NULL
7041 THEN
7042 l_missing_params := l_missing_params||', RESOURCE_CALENDAR_PERCENT';
7043 END IF;
7044 END IF;
7045
7046 IF l_asgn_rec.assignment_type = 'STAFFED_ASSIGNMENT' THEN
7047 IF l_asgn_rec.bill_rate_option IS NULL OR l_asgn_rec.bill_rate_option NOT IN('RATE','MARKUP','DISCOUNT','NONE') THEN
7048 l_missing_params := l_missing_params||', BILL_RATE_OPTION';
7049 ELSE
7050 IF l_asgn_rec.bill_rate_option = 'NONE' THEN
7051 l_asgn_rec.bill_rate_override := null;
7052 l_asgn_rec.bill_rate_curr_override := null;
7053 l_asgn_rec.markup_percent_override := null;
7054 l_asgn_rec.discount_percentage := null;
7055 l_asgn_rec.rate_disc_reason_code := null;
7056 ELSIF l_asgn_rec.bill_rate_option = 'RATE' THEN
7057 l_asgn_rec.markup_percent_override := null;
7058 l_asgn_rec.discount_percentage := null;
7059 IF l_asgn_rec.bill_rate_override IS NULL THEN
7060 l_missing_params := l_missing_params||', BILL_RATE_OVERRIDE';
7061 END IF;
7062 ELSIF l_asgn_rec.bill_rate_option = 'MARKUP' THEN
7063 l_asgn_rec.bill_rate_override := null;
7064 l_asgn_rec.bill_rate_curr_override := null;
7065 l_asgn_rec.discount_percentage := null;
7066 IF l_asgn_rec.markup_percent_override IS NULL THEN
7067 l_missing_params := l_missing_params||', MARKUP_PERCENT_OVERRIDE';
7068 END IF;
7069 ELSIF l_asgn_rec.bill_rate_option = 'DISCOUNT' THEN
7070 l_asgn_rec.bill_rate_override := null;
7071 l_asgn_rec.bill_rate_curr_override := null;
7072 l_asgn_rec.markup_percent_override := null;
7073 IF l_asgn_rec.discount_percentage IS NULL THEN
7074 l_missing_params := l_missing_params||', DISCOUNT_PERCENTAGE';
7075 END IF;
7076 END IF;
7077 END IF;
7078
7079
7080 IF l_asgn_rec.tp_rate_option IS NULL OR l_asgn_rec.tp_rate_option NOT IN('RATE','BASIS','NONE') THEN
7081 l_missing_params := l_missing_params||', TP_RATE_OPTION';
7082 ELSE
7083 IF l_asgn_rec.tp_rate_option = 'NONE' THEN
7084 l_asgn_rec.tp_rate_override := null;
7085 l_asgn_rec.tp_currency_override := null;
7086 l_asgn_rec.tp_calc_base_code_override := null;
7087 l_asgn_rec.tp_percent_applied_override := null;
7088 ELSIF l_asgn_rec.tp_rate_option = 'RATE' THEN
7089 l_asgn_rec.tp_calc_base_code_override := null;
7090 l_asgn_rec.tp_percent_applied_override := null;
7091 IF l_asgn_rec.tp_rate_override IS NULL OR l_asgn_rec.tp_currency_override IS NULL THEN
7092 l_missing_params := l_missing_params||', TP_RATE_OVERRIDE, TP_CURRENCY_OVERRIDE';
7093 END IF;
7094 ELSIF l_asgn_rec.tp_rate_option = 'BASIS' THEN
7095 l_asgn_rec.tp_rate_override := null;
7096 l_asgn_rec.tp_currency_override := null;
7097 IF l_asgn_rec.tp_calc_base_code_override IS NULL OR l_asgn_rec.tp_percent_applied_override IS NULL THEN
7098 l_missing_params := l_missing_params||', TP_CALC_BASE_CODE_OVERRIDE, TP_PERCENT_APPLIED_OVERRIDE';
7099 END IF;
7100 END IF;
7101 END IF;
7102
7103 IF l_asgn_rec.extension_possible IS NOT NULL AND l_asgn_rec.extension_possible NOT IN ('Y','N') THEN
7104 l_missing_params := l_missing_params||', EXTENSION_POSSIBLE';
7105 END IF;
7106 END IF; -- l_asgn_rec.assignment_type = 'STAFFED_ASSIGNMENT'
7107
7108 IF l_asgn_rec.auto_approve NOT IN ('Y','N') THEN
7109 l_missing_params := l_missing_params||', AUTO_APPROVE' ;
7110 END IF;
7111
7112 IF l_debug_mode = 'Y' THEN
7113 pa_debug.write(l_module, 'Mandatory parameter validation over. List of Missing Parameters='||l_missing_params, l_log_level);
7114 END IF;
7115
7116 IF l_missing_params IS NOT NULL THEN
7117 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
7118 'INVALID_PARAMS', l_missing_params);
7119 l_error_flag_local := 'Y';
7120 END IF;
7121
7122 -- Project Name, Number to ID Conversion
7123 -- Though it is done by pa_assignmnts_pub.create_assignment
7124 -- But we require to get project_id so that we can defualt
7125 -- values from the project and check security on project
7126 -- Also project name to id conversion does not happen by internal APIs
7127 IF l_debug_mode = 'Y' THEN
7128 pa_debug.write(l_module, 'Deriving ProjectId', l_log_level);
7129 END IF;
7130
7131 IF l_error_flag_local <> 'Y' THEN
7132 l_project_id_tmp := l_asgn_rec.project_id;
7133 IF l_asgn_rec.project_number IS NOT NULL THEN
7134 l_return_status := FND_API.G_RET_STS_SUCCESS;
7135 l_error_message_code := null;
7136
7137 PA_PROJECT_UTILS2.CHECK_PROJECT_NUMBER_OR_ID(
7138 p_project_id => l_project_id_tmp
7139 ,p_project_number => l_asgn_rec.project_number
7140 ,p_check_id_flag => PA_STARTUP.g_check_id_flag
7141 ,x_project_id => l_asgn_rec.project_id
7142 ,x_return_status => l_return_status
7143 ,x_error_message_code => l_error_message_code );
7144
7145 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7146 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
7147 l_error_flag_local := 'Y';
7148 END IF;
7149 END IF;
7150 IF l_asgn_rec.project_name IS NOT NULL THEN
7151 l_return_status := FND_API.G_RET_STS_SUCCESS;
7152 l_error_message_code := null;
7153
7154 PA_TASKS_MAINT_UTILS.CHECK_PROJECT_NAME_OR_ID(
7155 p_project_id => l_project_id_tmp
7156 ,p_project_name => l_asgn_rec.project_name
7157 ,p_check_id_flag => PA_STARTUP.g_check_id_flag
7158 ,x_project_id => l_asgn_rec.project_id
7159 ,x_return_status => l_return_status
7160 ,x_error_msg_code => l_error_message_code );
7161
7162 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7163 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
7164 l_error_flag_local := 'Y';
7165 END IF;
7166 END IF;
7167 END IF; -- l_error_flag_local <> 'Y' AND l_asgn_rec.team_template_id IS NULL
7168
7169 IF l_debug_mode = 'Y' THEN
7170 pa_debug.write(l_module, 'ProjectId='||l_asgn_rec.project_id, l_log_level);
7171 pa_debug.write(l_module, 'l_error_flag_local='||l_error_flag_local, l_log_level);
7172 END IF;
7173
7174 IF l_error_flag_local <> 'Y' THEN
7175 -- Project assignment Flow
7176 l_role_list_id := null;
7177 l_multi_currency_billing_flag := null;
7178 l_calendar_id := null;
7179 l_work_type_id := null;
7180 l_location_id := null;
7181
7182 OPEN c_get_project_dtls(l_asgn_rec.project_id);
7183 FETCH c_get_project_dtls INTO l_role_list_id, l_multi_currency_billing_flag, l_calendar_id
7184 , l_work_type_id, l_location_id;
7185 CLOSE c_get_project_dtls;
7186
7187 IF l_asgn_rec.bill_rate_option = 'RATE' AND nvl(l_multi_currency_billing_flag,'N') <> 'Y' THEN
7188 l_asgn_rec.bill_rate_curr_override := null;
7189 END IF;
7190 END IF;
7191
7192 IF l_debug_mode = 'Y' THEN
7193 pa_debug.write(l_module, 'Defaults Value from Project', l_log_level);
7194 pa_debug.write(l_module, 'l_role_list_id='||l_role_list_id, l_log_level);
7195 pa_debug.write(l_module, 'l_multi_currency_billing_flag='||l_multi_currency_billing_flag, l_log_level);
7196 pa_debug.write(l_module, 'l_calendar_id='||l_calendar_id, l_log_level);
7197 pa_debug.write(l_module, 'l_work_type_id='||l_work_type_id, l_log_level);
7198 pa_debug.write(l_module, 'l_location_id='||l_location_id, l_log_level);
7199 END IF;
7200
7201
7202 -- Default calendar, location, work type, assignment name
7203 IF l_error_flag_local <> 'Y' THEN
7204 IF l_debug_mode = 'Y' THEN
7205 pa_debug.write(l_module, 'Default values of calendar, work type, location from project or team template', l_log_level);
7206 END IF;
7207
7208 -- For OTHER type of calendar there is alredy check done above in code
7209 -- For PROJECT type ignore the user value and take the project value
7210 IF l_asgn_rec.calendar_type = 'PROJECT' THEN
7211 l_asgn_rec.calendar_id := l_calendar_id;
7212 END IF;
7213
7214 IF l_asgn_rec.work_type_id IS NULL AND l_asgn_rec.work_type_name IS NULL
7215 THEN
7216 l_asgn_rec.work_type_id := l_work_type_id;
7217 END IF;
7218
7219 IF l_asgn_rec.project_id IS NOT NULL AND l_asgn_rec.location_id = FND_API.G_MISS_NUM
7220 AND l_asgn_rec.location_country_code = FND_API.G_MISS_CHAR
7221 AND l_asgn_rec.location_country_name = FND_API.G_MISS_CHAR
7222 AND l_asgn_rec.location_region = FND_API.G_MISS_CHAR
7223 AND l_asgn_rec.location_city = FND_API.G_MISS_CHAR
7224 THEN
7225 l_asgn_rec.location_id := l_location_id;
7226 END IF;
7227
7228 -- Role Validation
7229 -- Though it is done by pa_assignmnts_pub.create_assignment
7230 -- But we require to get role_id so that we can defualt
7231 -- values from the role
7232 -- Defaulting is required
7233
7234 IF l_debug_mode = 'Y' THEN
7235 pa_debug.write(l_module, 'Validating Role against Role List and doing Role Name to ID conversion', l_log_level);
7236 END IF;
7237
7238 l_return_status := FND_API.G_RET_STS_SUCCESS;
7239 l_error_message_code := null;
7240 l_project_role_id_tmp := l_asgn_rec.project_role_id;
7241
7242 /* passing p_check_id_flag as Y for bug 8557593 */
7243 PA_ROLE_UTILS.Check_Role_RoleList (
7244 p_role_id => l_project_role_id_tmp
7245 ,p_role_name => l_asgn_rec.project_role_name
7246 ,p_role_list_id => l_role_list_id
7247 ,p_role_list_name => NULL
7248 ,p_check_id_flag => 'Y'
7249 ,x_role_id => l_asgn_rec.project_role_id
7250 ,x_role_list_id => l_role_list_id
7251 ,x_return_status => l_return_status
7252 ,x_error_message_code => l_error_message_code );
7253
7254 IF l_debug_mode = 'Y' THEN
7255 pa_debug.write(l_module, 'After role validation Role id='||l_asgn_rec.project_role_id, l_log_level);
7256 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
7257 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
7258 END IF;
7259
7260 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7261 PA_UTILS.ADD_MESSAGE('PA', l_error_message_code);
7262 l_error_flag_local := 'Y';
7263 END IF;
7264
7265 IF l_debug_mode = 'Y' THEN
7266 pa_debug.write(l_module, 'Defaulting RequirmentName from Role ', l_log_level);
7267 END IF;
7268
7269 l_role_name := null;
7270
7271 OPEN c_get_role_dtls(l_asgn_rec.project_role_id);
7272 FETCH c_get_role_dtls INTO l_role_name;
7273 CLOSE c_get_role_dtls;
7274
7275 IF l_asgn_rec.assignment_name IS NULL THEN
7276 l_asgn_rec.assignment_name := l_role_name;
7277 END IF;
7278
7279 IF l_debug_mode = 'Y' THEN
7280 pa_debug.write(l_module, 'l_role_name='||l_role_name, l_log_level);
7281 END IF;
7282 END IF; -- l_error_flag_local <> 'Y' THEN
7283
7284 -- All validations are not required as some validation is done in underlying code
7285 -- Here, we are doing only those validations which are not done internally.
7286 -- NOTE : In update flow, all these validations are done and it is taken from there
7287 -- Ideally in create flow also, underlying code should do these validations
7288 -- But we are doing here to avoid more code changes in existing code.
7289
7290 IF l_error_flag_local <> 'Y' AND l_asgn_rec.assignment_type = 'STAFFED_ASSIGNMENT' THEN
7291
7292 -- Bill Rate Options Validation
7293 -------------------------------
7294
7295 IF l_asgn_rec.bill_rate_option <> 'NONE' THEN
7296 l_rate_discount_reason_flag := 'N';
7297 l_br_override_flag := 'N';
7298 l_br_discount_override_flag := 'N';
7299
7300 OPEN get_bill_rate_override_flags(l_asgn_rec.project_id);
7301 FETCH get_bill_rate_override_flags INTO l_rate_discount_reason_flag, l_br_override_flag, l_br_discount_override_flag;
7302 CLOSE get_bill_rate_override_flags;
7303
7304 IF l_debug_mode = 'Y' THEN
7305 pa_debug.write(l_module, 'Validating Bill Rate Options', l_log_level);
7306 pa_debug.write(l_module, 'l_rate_discount_reason_flag='||l_rate_discount_reason_flag, l_log_level);
7307 pa_debug.write(l_module, 'l_br_override_flag='||l_br_override_flag, l_log_level);
7308 pa_debug.write(l_module, 'l_br_discount_override_flag='||l_br_discount_override_flag, l_log_level);
7309 END IF;
7310
7311 IF l_asgn_rec.bill_rate_option = 'RATE' THEN
7312 IF l_br_override_flag <> 'Y' OR l_asgn_rec.bill_rate_override <= 0 THEN /* OR l_asgn_rec.bill_rate_override > 100 - Removed for Bug 5703021*/
7313 IF l_br_override_flag <> 'Y' THEN
7314 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_BILL_RATE_OVRD_NA');
7315 l_error_flag_local := 'Y';
7316 ELSE
7317 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_BILL_RATE_OVRD');
7318 l_error_flag_local := 'Y';
7319 END IF;
7320 END IF;
7321 -- 5144288, 5144369 : Added bill rate currency check below
7322 -- Begin
7323 IF nvl(l_multi_currency_billing_flag,'N') = 'Y' AND l_br_override_flag = 'Y' THEN
7324
7325 l_return_status := FND_API.G_RET_STS_SUCCESS;
7326 l_error_message_code := null;
7327 l_bill_currency_override_tmp := l_asgn_rec.bill_rate_curr_override;
7328
7329 IF l_debug_mode = 'Y' THEN
7330 pa_debug.write(l_module, 'Validating Bill Rate Currency', l_log_level);
7331 END IF;
7332
7333 PA_PROJECTS_MAINT_UTILS.CHECK_CURRENCY_NAME_OR_CODE(
7334 p_agreement_currency => l_bill_currency_override_tmp
7335 ,p_agreement_currency_name => null
7336 ,p_check_id_flag => 'Y'
7337 ,x_agreement_currency => l_asgn_rec.bill_rate_curr_override
7338 ,x_return_status => l_return_status
7339 ,x_error_msg_code => l_error_message_code);
7340
7341 IF l_debug_mode = 'Y' THEN
7342 pa_debug.write(l_module, 'After Bill Rate Currency Validation', l_log_level);
7343 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
7344 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
7345 END IF;
7346
7347 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7348 PA_UTILS.ADD_MESSAGE('PA', 'PA_CISI_CURRENCY_NULL');
7349 l_error_flag_local := 'Y';
7350 END IF;
7351 END IF;
7352 -- 5144288, 5144369 : End
7353 ELSIF l_asgn_rec.bill_rate_option = 'MARKUP' THEN
7354 -- 5144675 Changed l_asgn_rec.markup_percent_override <=0 to < 0
7355 IF l_br_override_flag <> 'Y' OR l_asgn_rec.markup_percent_override < 0
7356 OR l_asgn_rec.markup_percent_override > 100 THEN
7357 IF l_br_override_flag <> 'Y' THEN
7358 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_BILL_RATE_OVRD_NA');
7359 l_error_flag_local := 'Y';
7360 ELSE
7361 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_MARKUP_PERCENT');
7362 l_error_flag_local := 'Y';
7363 END IF;
7364 END IF;
7365 ELSIF l_asgn_rec.bill_rate_option = 'DISCOUNT' THEN
7366 -- 5144675 Changed l_asgn_rec.discount_percentage <= 0 to < 0
7367 IF l_br_discount_override_flag <> 'Y' OR l_asgn_rec.discount_percentage < 0
7368 OR l_asgn_rec.discount_percentage > 100 THEN
7369 IF l_br_discount_override_flag <> 'Y' THEN
7370 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_DISC_OVRD_NA');
7371 l_error_flag_local := 'Y';
7372 ELSE
7373 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_DISCOUNT_PERCENT');
7374 l_error_flag_local := 'Y';
7375 END IF;
7376 END IF;
7377 END IF;
7378 IF l_asgn_rec.rate_disc_reason_code IS NULL THEN
7379 IF (l_rate_discount_reason_flag ='Y' AND (l_br_override_flag ='Y' OR l_br_discount_override_flag='Y') AND
7380 (l_asgn_rec.bill_rate_override IS NOT NULL OR l_asgn_rec.markup_percent_override IS NOT NULL OR l_asgn_rec.discount_percentage IS NOT NULL)
7381 )
7382 THEN
7383 PA_UTILS.ADD_MESSAGE('PA', 'PA_RATE_DISC_REASON_REQUIRED');
7384 l_error_flag_local := 'Y';
7385 END IF;
7386 ELSE
7387 l_valid_flag := 'N';
7388 OPEN c_get_lookup_exists('RATE AND DISCOUNT REASON', l_asgn_rec.rate_disc_reason_code);
7389 FETCH c_get_lookup_exists INTO l_valid_flag;
7390 CLOSE c_get_lookup_exists;
7391 IF nvl(l_valid_flag,'N') <> 'Y' THEN
7392 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_DISC_RSN_INVALID');
7393 l_error_flag_local := 'Y';
7394 END IF;
7395 END IF;
7396
7397 IF l_debug_mode = 'Y' THEN
7398 pa_debug.write(l_module, 'After Validating Bill Rate Options l_error_flag_local='||l_error_flag_local, l_log_level);
7399 END IF;
7400 END IF; -- l_asgn_rec.bill_rate_option <> 'NONE'
7401
7402 -- Transfer Price Rate Options Validation
7403 -----------------------------------------
7404
7405 IF l_asgn_rec.tp_rate_option <> 'NONE' THEN
7406
7407 IF l_debug_mode = 'Y' THEN
7408 pa_debug.write(l_module, 'Validating Transfer Price Rate Options', l_log_level);
7409 END IF;
7410
7411 IF l_asgn_rec.tp_rate_option = 'RATE' THEN
7412 -- 5144675 Changed l_asgn_rec.tp_rate_override <= to < 0
7413 IF l_asgn_rec.tp_rate_override < 0 OR l_asgn_rec.tp_rate_override > 100 THEN
7414 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_TP_RATE_OVRD');
7415 l_error_flag_local := 'Y';
7416 END IF;
7417
7418 l_return_status := FND_API.G_RET_STS_SUCCESS;
7419 l_error_message_code := null;
7420 l_tp_currency_override_tmp := l_asgn_rec.tp_currency_override;
7421
7422 IF l_debug_mode = 'Y' THEN
7423 pa_debug.write(l_module, 'Validating Transfer Price Rate Currency', l_log_level);
7424 END IF;
7425
7426 PA_PROJECTS_MAINT_UTILS.CHECK_CURRENCY_NAME_OR_CODE(
7427 p_agreement_currency => l_tp_currency_override_tmp
7428 ,p_agreement_currency_name => null
7429 ,p_check_id_flag => 'Y'
7430 ,x_agreement_currency => l_asgn_rec.tp_currency_override
7431 ,x_return_status => l_return_status
7432 ,x_error_msg_code => l_error_message_code);
7433
7434 IF l_debug_mode = 'Y' THEN
7435 pa_debug.write(l_module, 'After Transfer Price Rate Currency Validation', l_log_level);
7436 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
7437 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
7438 END IF;
7439
7440 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7441 PA_UTILS.ADD_MESSAGE('PA', 'PA_CURR_NOT_VALID');
7442 l_error_flag_local := 'Y';
7443 END IF;
7444 ELSIF l_asgn_rec.tp_rate_option = 'BASIS' THEN
7445 -- 5144675 Changed l_asgn_rec.tp_percent_applied_override <= to < 0
7446 IF l_asgn_rec.tp_percent_applied_override < 0 OR l_asgn_rec.tp_percent_applied_override > 100 THEN
7447 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_APPLY_BASIS_PERCENT');
7448 l_error_flag_local := 'Y';
7449 END IF;
7450 l_valid_flag := 'N';
7451 IF l_debug_mode = 'Y' THEN
7452 pa_debug.write(l_module, 'Validating Transfer Price Rate Basis', l_log_level);
7453 END IF;
7454
7455 OPEN c_get_lookup_exists('CC_MARKUP_BASE_CODE', l_asgn_rec.tp_calc_base_code_override);
7456 FETCH c_get_lookup_exists INTO l_valid_flag;
7457 CLOSE c_get_lookup_exists;
7458
7459 IF l_debug_mode = 'Y' THEN
7460 pa_debug.write(l_module, 'After Transfer Price Rate Basis Validation', l_log_level);
7461 pa_debug.write(l_module, 'l_valid_flag='||l_valid_flag, l_log_level);
7462 END IF;
7463
7464 IF nvl(l_valid_flag,'N') <> 'Y' THEN
7465 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_TP_BASIS_INVALID');
7466 l_error_flag_local := 'Y';
7467 END IF;
7468 END IF;
7469
7470 IF l_debug_mode = 'Y' THEN
7471 pa_debug.write(l_module, 'After Validating Transfer Price Rate Options l_error_flag_local='||l_error_flag_local, l_log_level);
7472 END IF;
7473 END IF; -- l_asgn_rec.tp_rate_option <> 'NONE'
7474
7475 -- Res Loan Agreement Validations
7476 ---------------------------------
7477
7478 IF l_asgn_rec.expense_owner IS NOT NULL THEN
7479 l_valid_flag := 'N';
7480
7481 IF l_debug_mode = 'Y' THEN
7482 pa_debug.write(l_module, 'Validating Expense Owner Option', l_log_level);
7483 END IF;
7484
7485 OPEN c_get_lookup_exists('EXPENSE_OWNER_TYPE', l_asgn_rec.expense_owner);
7486 FETCH c_get_lookup_exists INTO l_valid_flag;
7487 CLOSE c_get_lookup_exists;
7488
7489 IF l_debug_mode = 'Y' THEN
7490 pa_debug.write(l_module, 'After Expense Owner Option Validation', l_log_level);
7491 pa_debug.write(l_module, 'l_valid_flag='||l_valid_flag, l_log_level);
7492 END IF;
7493
7494 IF nvl(l_valid_flag,'N') <> 'Y' THEN
7495 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_EXP_OWNER_INVALID');
7496 l_error_flag_local := 'Y';
7497 END IF;
7498 END IF;
7499 END IF; -- l_error_flag_local <> 'Y' AND l_asgn_rec.assignment_type = 'STAFFED_ASSIGNMENT'
7500
7501 IF l_debug_mode = 'Y' THEN
7502 pa_debug.write(l_module, 'After all validations l_error_flag_local='||l_error_flag_local, l_log_level);
7503 END IF;
7504
7505 -- Flex field Validation
7506 ------------------------
7507
7508 IF l_error_flag_local <> 'Y' THEN
7509 l_return_status := FND_API.G_RET_STS_SUCCESS;
7510
7511 VALIDATE_FLEX_FIELD(
7512 p_desc_flex_name => 'PA_TEAM_ROLE_DESC_FLEX'
7513 , p_attribute_category => l_asgn_rec.attribute_category
7514 , px_attribute1 => l_asgn_rec.attribute1
7515 , px_attribute2 => l_asgn_rec.attribute2
7516 , px_attribute3 => l_asgn_rec.attribute3
7517 , px_attribute4 => l_asgn_rec.attribute4
7518 , px_attribute5 => l_asgn_rec.attribute5
7519 , px_attribute6 => l_asgn_rec.attribute6
7520 , px_attribute7 => l_asgn_rec.attribute7
7521 , px_attribute8 => l_asgn_rec.attribute8
7522 , px_attribute9 => l_asgn_rec.attribute9
7523 , px_attribute10 => l_asgn_rec.attribute10
7524 , px_attribute11 => l_asgn_rec.attribute11
7525 , px_attribute12 => l_asgn_rec.attribute12
7526 , px_attribute13 => l_asgn_rec.attribute13
7527 , px_attribute14 => l_asgn_rec.attribute14
7528 , px_attribute15 => l_asgn_rec.attribute15
7529 , x_return_status => l_return_status
7530 , x_msg_count => l_msg_count
7531 , x_msg_data => l_msg_data
7532 );
7533
7534 IF l_debug_mode = 'Y' THEN
7535 pa_debug.write(l_module, 'After Flex Field Validation l_return_status='||l_return_status, l_log_level);
7536 pa_debug.write(l_module, 'After Flex Field Validation l_msg_data='||l_msg_data, l_log_level);
7537 END IF;
7538
7539
7540 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7541 -- This message does not have toekn defined, still it is ok to pass token as the value
7542 -- returned by flex APIs because token are appended as it is
7543 PA_UTILS.ADD_MESSAGE('PA', 'PA_DFF_VALIDATION_FAILED',
7544 'MESSAGE', l_msg_data );
7545 l_error_flag_local := 'Y';
7546 END IF;
7547 END IF; -- l_error_flag_local <> 'Y'
7548
7549 -- Security Check
7550 -----------------
7551
7552 IF l_error_flag_local <> 'Y' THEN
7553
7554 IF l_debug_mode = 'Y' THEN
7555 pa_debug.write(l_module, 'Checking Security for Record#'||i, l_log_level);
7556 END IF;
7557
7558
7559 IF l_asgn_rec.assignment_type = 'STAFFED_ASSIGNMENT' THEN
7560 l_privilege := 'PA_ASN_CR_AND_DL';
7561 l_object_name := 'PA_PROJECTS';
7562 l_object_key := l_asgn_rec.project_id;
7563 ELSIF l_asgn_rec.assignment_type = 'STAFFED_ADMIN_ASSIGNMENT' THEN
7564 l_privilege := 'PA_ADM_ASN_CR_AND_DL';
7565 l_object_name := 'PA_PROJECTS';
7566 l_object_key := l_asgn_rec.project_id;
7567 END IF;
7568
7569 IF l_debug_mode = 'Y' THEN
7570 pa_debug.write(l_module, 'l_privilege='||l_privilege, l_log_level);
7571 pa_debug.write(l_module, 'l_object_name='||l_object_name, l_log_level);
7572 pa_debug.write(l_module, 'l_object_key='||l_object_key, l_log_level);
7573 END IF;
7574
7575 --If required this may be used to get
7576 --l_my_person_id := null;
7577 --l_my_resource_id := null;
7578 --l_my_resource_name := null;
7579 --PA_COMP_PROFILE_PUB.GET_USER_INFO(
7580 -- p_user_id => fnd_global.user_id
7581 -- , x_Person_id => l_my_person_id
7582 -- , x_Resource_id => l_my_resource_id
7583 -- , x_resource_name => l_my_resource_name);
7584 --IF l_debug_mode = 'Y' THEN
7585 -- pa_debug.write(l_module, 'Logged in user Person Id='||l_my_person_id, l_log_level);
7586 -- pa_debug.write(l_module, 'Logged in user Resource Id='||l_my_resource_id, l_log_level);
7587 -- pa_debug.write(l_module, 'Logged in user Resource Name='||l_my_resource_name, l_log_level);
7588 --END IF;
7589
7590
7591 l_return_status := FND_API.G_RET_STS_SUCCESS;
7592 l_ret_code := 'T';
7593
7594 IF l_asgn_rec.assignment_type = 'STAFFED_ADMIN_ASSIGNMENT' THEN
7595 IF l_debug_mode = 'Y' THEN
7596 pa_debug.write(l_module, 'Checking Resource Authority', l_log_level);
7597 END IF;
7598
7599 PA_SECURITY_PVT.CHECK_CONFIRM_ASMT
7600 (p_project_id => l_asgn_rec.project_id
7601 , p_resource_id => l_asgn_rec.resource_id
7602 , p_resource_name => null
7603 , p_privilege => l_privilege
7604 , p_start_date => l_asgn_rec.start_date
7605 , x_ret_code => l_ret_code
7606 , x_return_status => l_return_status
7607 , x_msg_count => l_msg_count
7608 , x_msg_data => l_msg_data
7609 );
7610
7611 IF l_debug_mode = 'Y' THEN
7612 pa_debug.write(l_module, 'After Resource Authority Check l_ret_code='||l_ret_code, l_log_level);
7613 END IF;
7614 ELSE
7615 IF l_debug_mode = 'Y' THEN
7616 pa_debug.write(l_module, 'Checking Project Security', l_log_level);
7617 END IF;
7618
7619 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
7620 x_ret_code => l_ret_code
7621 , x_return_status => l_return_status
7622 , x_msg_count => l_msg_count
7623 , x_msg_data => l_msg_data
7624 , p_init_msg_list => 'F'
7625 , p_privilege => l_privilege
7626 , p_object_name => l_object_name
7627 , p_object_key => l_object_key);
7628
7629 IF l_debug_mode = 'Y' THEN
7630 pa_debug.write(l_module, 'After Project Security Check l_ret_code='||l_ret_code, l_log_level);
7631 END IF;
7632 END IF;
7633
7634
7635 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7636 -- This message does not have token defined, but intentionally putting token
7637 -- bcoz we still want to show the privielge name which is missing
7638 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_CR_DL'
7639 ,'MISSING_PRIVILEGE', l_privilege);
7640 l_error_flag_local := 'Y';
7641 END IF;
7642 END IF;
7643
7644 -- Call Core Actual API
7645 -----------------------
7646
7647 IF l_error_flag_local <> 'Y' THEN
7648 l_return_status := FND_API.G_RET_STS_SUCCESS;
7649
7650 IF l_debug_mode = 'Y' THEN
7651 pa_debug.write(l_module, 'Calling pa_assignments_pub.execute_create_assignment for Record#'||i, l_log_level);
7652 END IF;
7653
7654 l_new_assignment_id_tbl := null;
7655 l_new_assignment_id := null;
7656 l_assignment_number := null;
7657 l_assignment_row_id := null;
7658 l_resource_id := null;
7659
7660 PA_ASSIGNMENTS_PUB.EXECUTE_CREATE_ASSIGNMENT
7661 (
7662 p_api_version => p_api_version_number
7663 , p_init_msg_list => l_init_msg_list
7664 , p_commit => l_commit
7665 , p_validate_only => l_validate_only
7666 , p_asgn_creation_mode => l_asgn_creation_mode
7667 , p_assignment_name => l_asgn_rec.assignment_name
7668 , p_assignment_type => l_asgn_rec.assignment_type
7669 -- , p_assignment_template_id => l_asgn_rec.team_template_id
7670 -- , p_source_assignment_id => l_asgn_rec.source_assignment_id
7671 -- , p_number_of_assignments => l_asgn_rec.number_of_assignments
7672 , p_project_role_id => l_asgn_rec.project_role_id
7673 , p_project_role_name => l_asgn_rec.project_role_name
7674 , p_project_id => l_asgn_rec.project_id
7675 , p_project_name => l_asgn_rec.project_name
7676 , p_project_number => l_asgn_rec.project_number
7677 , p_resource_id => l_asgn_rec.resource_id
7678 -- , p_project_party_id =>
7679 -- , p_resource_name =>
7680 -- , p_resource_source_id => null
7681 , p_staffing_owner_person_id => l_asgn_rec.staffing_owner_person_id
7682 -- , p_staffing_owner_name =>
7683 , p_staffing_priority_code => l_asgn_rec.staffing_priority_code
7684 , p_staffing_priority_name => l_asgn_rec.staffing_priority_name
7685 , p_project_subteam_id => l_asgn_rec.project_subteam_id
7686 , p_project_subteam_name => l_asgn_rec.project_subteam_name
7687 , p_location_id => l_asgn_rec.location_id
7688 , p_location_city => l_asgn_rec.location_city
7689 , p_location_region => l_asgn_rec.location_region
7690 , p_location_country_name => l_asgn_rec.location_country_name
7691 , p_location_country_code => l_asgn_rec.location_country_code
7692 -- , p_min_resource_job_level => l_asgn_rec.min_resource_job_level
7693 -- , p_max_resource_job_level => l_asgn_rec.max_resource_job_level
7694 , p_description => l_asgn_rec.description
7695 , p_additional_information => l_asgn_rec.additional_information
7696 , p_start_date => l_asgn_rec.start_date
7697 , p_end_date => l_asgn_rec.end_date
7698 , p_status_code => l_asgn_rec.status_code
7699 , p_project_status_name => l_asgn_rec.status_name
7700 , p_multiple_status_flag => l_multiple_status_flag
7701 -- , p_assignment_effort =>
7702 -- , p_resource_list_member_id =>
7703 -- , p_budget_version_id =>
7704 -- , p_sum_tasks_flag =>
7705 , p_calendar_type => l_asgn_rec.calendar_type
7706 , p_calendar_id => l_asgn_rec.calendar_id
7707 , p_calendar_name => l_asgn_rec.calendar_name
7708 , p_resource_calendar_percent => l_asgn_rec.resource_calendar_percent
7709 -- , p_start_adv_action_set_flag => l_asgn_rec.start_adv_action_set_flag
7710 -- , p_adv_action_set_id => l_asgn_rec.adv_action_set_id
7711 -- , p_adv_action_set_name => l_asgn_rec.adv_action_set_name
7712 -- As of now internal code does not support setting the candidate search options
7713 -- at create time. It can only be updated.
7714 -- , p_comp_match_weighting => l_asgn_rec.comp_match_weighting
7715 -- , p_avail_match_weighting => l_asgn_rec.avail_match_weighting
7716 -- , p_job_level_match_weighting => l_asgn_rec.job_level_match_weighting
7717 -- , p_enable_auto_cand_nom_flag => l_asgn_rec.enable_auto_cand_nom_flag
7718 -- , p_search_min_availability => l_asgn_rec.search_min_availability
7719 -- , p_search_exp_org_struct_ver_id => l_asgn_rec.search_exp_org_str_ver_id
7720 -- , p_search_exp_start_org_id => l_asgn_rec.search_exp_start_org_id
7721 -- , p_search_country_code => l_asgn_rec.search_country_code
7722 -- , p_search_min_candidate_score => l_asgn_rec.search_min_candidate_score
7723 -- , p_expenditure_org_id => l_asgn_rec.expenditure_org_id
7724 -- , p_expenditure_org_name => l_asgn_rec.expenditure_org_name
7725 -- , p_expenditure_organization_id => l_asgn_rec.expenditure_organization_id
7726 -- , p_exp_organization_name => l_asgn_rec.expenditure_organization_name
7727 , p_expenditure_type_class => l_asgn_rec.expenditure_type_class
7728 , p_expenditure_type => l_asgn_rec.expenditure_type
7729 -- , p_fcst_job_group_id => l_asgn_rec.fcst_job_group_id
7730 -- , p_fcst_job_group_name => l_asgn_rec.fcst_job_group_name
7731 -- , p_fcst_job_id => l_asgn_rec.fcst_job_id
7732 -- , p_fcst_job_name => l_asgn_rec.fcst_job_name
7733 -- , p_fcst_tp_amount_type => l_asgn_rec.fcst_tp_amount_type
7734 , p_work_type_id => l_asgn_rec.work_type_id
7735 , p_work_type_name => l_asgn_rec.work_type_name
7736 , p_bill_rate_override => l_asgn_rec.bill_rate_override
7737 , p_bill_rate_curr_override => l_asgn_rec.bill_rate_curr_override
7738 , p_markup_percent_override => l_asgn_rec.markup_percent_override
7739 , p_discount_percentage => l_asgn_rec.discount_percentage
7740 , p_rate_disc_reason_code => l_asgn_rec.rate_disc_reason_code
7741 , p_tp_rate_override => l_asgn_rec.tp_rate_override
7742 , p_tp_currency_override => l_asgn_rec.tp_currency_override
7743 , p_tp_calc_base_code_override => l_asgn_rec.tp_calc_base_code_override
7744 , p_tp_percent_applied_override => l_asgn_rec.tp_percent_applied_override
7745 , p_extension_possible => l_asgn_rec.extension_possible
7746 , p_expense_owner => l_asgn_rec.expense_owner
7747 , p_expense_limit => l_asgn_rec.expense_limit
7748 -- , p_revenue_currency_code =>
7749 -- , p_revenue_bill_rate =>
7750 -- , p_markup_percent =>
7751
7752 , p_attribute_category => l_asgn_rec.attribute_category
7753 , p_attribute1 => l_asgn_rec.attribute1
7754 , p_attribute2 => l_asgn_rec.attribute2
7755 , p_attribute3 => l_asgn_rec.attribute3
7756 , p_attribute4 => l_asgn_rec.attribute4
7757 , p_attribute5 => l_asgn_rec.attribute5
7758 , p_attribute6 => l_asgn_rec.attribute6
7759 , p_attribute7 => l_asgn_rec.attribute7
7760 , p_attribute8 => l_asgn_rec.attribute8
7761 , p_attribute9 => l_asgn_rec.attribute9
7762 , p_attribute10 => l_asgn_rec.attribute10
7763 , p_attribute11 => l_asgn_rec.attribute11
7764 , p_attribute12 => l_asgn_rec.attribute12
7765 , p_attribute13 => l_asgn_rec.attribute13
7766 , p_attribute14 => l_asgn_rec.attribute14
7767 , p_attribute15 => l_asgn_rec.attribute15
7768 , x_new_assignment_id_tbl => l_new_assignment_id_tbl
7769 , x_new_assignment_id => l_new_assignment_id
7770 , x_assignment_number => l_assignment_number
7771 , x_assignment_row_id => l_assignment_row_id
7772 , x_resource_id => l_resource_id
7773 , x_return_status => l_return_status
7774 , x_msg_count => l_msg_count
7775 , x_msg_data => l_msg_data
7776 );
7777
7778 IF l_debug_mode = 'Y' THEN
7779 pa_debug.write(l_module, 'After call pa_assignments_pub.execute_create_assignment l_return_status='||l_return_status, l_log_level);
7780 END IF;
7781
7782 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7783 l_error_flag_local := 'Y';
7784 -- Still we populating out tables so that if calling env tries
7785 -- to get all ids even after error has occured
7786 x_assignment_id_tbl.extend(1);
7787 x_assignment_id_tbl(x_assignment_id_tbl.count):= -1;
7788 ELSE
7789 IF l_debug_mode = 'Y' THEN
7790 pa_debug.write(l_module, 'Updating Original System Code and Reference', l_log_level);
7791 pa_debug.write(l_module, 'l_new_assignment_id_tbl.count'||l_new_assignment_id_tbl.count, l_log_level);
7792 END IF;
7793
7794
7795 IF l_new_assignment_id_tbl.count > 0 THEN
7796 FOR j in l_new_assignment_id_tbl.FIRST..l_new_assignment_id_tbl.LAST LOOP
7797 IF l_new_assignment_id_tbl.exists(j) THEN
7798 x_assignment_id_tbl.extend(1);
7799 x_assignment_id_tbl(x_assignment_id_tbl.count):= l_new_assignment_id_tbl(j);
7800 IF (l_asgn_rec.orig_system_code IS NOT NULL OR l_asgn_rec.orig_system_reference IS NOT NULL) THEN
7801 UPDATE PA_PROJECT_ASSIGNMENTS
7802 SET orig_system_code = l_asgn_rec.orig_system_code
7803 , orig_system_reference = l_asgn_rec.orig_system_reference
7804 WHERE assignment_id = l_new_assignment_id_tbl(j);
7805 END IF;
7806 END IF;
7807 END LOOP;
7808 END IF;
7809 IF l_debug_mode = 'Y' THEN
7810 pa_debug.write(l_module, 'After Updating Original System Code and Reference', l_log_level);
7811 END IF;
7812 END IF;
7813 END IF;
7814
7815 l_end_msg_count := FND_MSG_PUB.count_msg;
7816 IF l_debug_mode = 'Y' THEN
7817 pa_debug.write(l_module, 'l_start_msg_count='||l_start_msg_count, l_log_level);
7818 pa_debug.write(l_module, 'l_end_msg_count='||l_end_msg_count, l_log_level);
7819 END IF;
7820 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
7821
7822 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
7823 l_error_flag := 'Y';
7824
7825 IF l_debug_mode = 'Y' THEN
7826 pa_debug.write(l_module, 'Repopulating Error Message Stack', l_log_level);
7827 END IF;
7828
7829 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
7830 -- Always get from first location in stack i.e. l_start_msg_count+1
7831 -- Because stack moves down after delete
7832 FND_MSG_PUB.get (
7833 p_msg_index => l_start_msg_count+1,
7834 p_encoded => FND_API.G_FALSE,
7835 p_data => l_data,
7836 p_msg_index_out => l_msg_index_out );
7837
7838 -- Always delete at first location in stack i.e. l_start_msg_count+1
7839 -- Because stack moves down after delete
7840 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
7841
7842 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
7843 'RECORD_NO', i,
7844 'MESSAGE', l_data);
7845 END LOOP;
7846 IF l_debug_mode = 'Y' THEN
7847 pa_debug.write(l_module, 'After Repopulating Error Message Stack', l_log_level);
7848 END IF;
7849 END IF;
7850 i := p_assignment_in_tbl.next(i);
7851 END LOOP;
7852
7853 IF l_debug_mode = 'Y' THEN
7854 pa_debug.write(l_module, 'All records are done', l_log_level);
7855 pa_debug.write(l_module, 'l_error_flag='||l_error_flag, l_log_level);
7856 pa_debug.write(l_module, 'FND_MSG_PUB.count_msg='||FND_MSG_PUB.count_msg, l_log_level);
7857 END IF;
7858
7859 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
7860 RAISE FND_API.G_EXC_ERROR;
7861 END IF;
7862
7863 IF l_debug_mode = 'Y' THEN
7864 PA_DEBUG.reset_curr_function;
7865 END IF;
7866
7867 IF p_commit = FND_API.G_TRUE THEN
7868 commit;
7869 END IF;
7870
7871
7872 EXCEPTION
7873 WHEN FND_API.G_EXC_ERROR THEN
7874 x_return_status := FND_API.G_RET_STS_ERROR;
7875 l_msg_count := FND_MSG_PUB.count_msg;
7876
7877 IF p_commit = FND_API.G_TRUE THEN
7878 ROLLBACK TO CREATE_ASSIGNMENTS_SP;
7879 END IF;
7880
7881 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
7882 PA_INTERFACE_UTILS_PUB.get_messages
7883 ( p_encoded => FND_API.G_FALSE
7884 , p_msg_index => 1
7885 , p_msg_count => l_msg_count
7886 , p_msg_data => l_msg_data
7887 , p_data => l_data
7888 , p_msg_index_out => l_msg_index_out);
7889
7890 x_msg_data := l_data;
7891 x_msg_count := l_msg_count;
7892 ELSE
7893 x_msg_count := l_msg_count;
7894 END IF;
7895
7896 IF l_debug_mode = 'Y' THEN
7897 Pa_Debug.reset_curr_function;
7898 END IF;
7899
7900 WHEN OTHERS THEN
7901
7902 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7903 x_msg_data := SQLERRM;
7904
7905 IF p_commit = FND_API.G_TRUE THEN
7906 ROLLBACK TO CREATE_ASSIGNMENTS_SP;
7907 END IF;
7908
7909 FND_MSG_PUB.add_exc_msg
7910 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
7911 , p_procedure_name => 'CREATE_ASSIGNMENTS'
7912 , p_error_text => x_msg_data);
7913
7914 x_msg_count := FND_MSG_PUB.count_msg;
7915
7916 IF l_debug_mode = 'Y' THEN
7917 PA_DEBUG.reset_curr_function;
7918 END IF;
7919 RAISE;
7920 END CREATE_ASSIGNMENTS;
7921
7922
7923 -- Start of comments
7924 -- API name : UPDATE_ASSIGNMENTS
7925 -- Type : Public
7926 -- Pre-reqs : None.
7927 -- Function : This is a public API to update one or more assignments for one or more projects.
7928 -- Usage : This API will be called from AMG.
7929 -- Parameters :
7930 -- IN : p_commit IN VARCHAR2
7931 -- Identifier to commit the transaction.
7932 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
7933 -- p_init_msg_list IN VARCHAR2
7934 -- Identifier to initialize the error message stack.
7935 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
7936 -- p_api_version_number IN NUMBER Required
7937 -- To be compliant with Applications API coding standards.
7938 -- p_assignment_in_tbl IN ASSIGNMENT_IN_TBL_TYPE Required
7939 -- Table of assignment records. Please see the ASSIGNMENT_IN_TBL_TYPE datatype table
7940 -- OUT :
7941 -- x_return_status OUT VARCHAR2
7942 -- Indicates the return status of the API.
7943 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
7944 -- x_msg_count OUT NUMBER
7945 -- Indicates the number of error messages in the message stack
7946 -- x_msg_data OUT VARCHAR2
7947 -- Indicates the error message text if only one error exists
7948 -- History :
7949 --
7950 -- 01-Mar-2006 - avaithia - Created
7951 -- End of comments
7952
7953 PROCEDURE UPDATE_ASSIGNMENTS
7954 (
7955 p_api_version_number IN NUMBER := 1.0
7956 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
7957 , p_commit IN VARCHAR2 := FND_API.G_FALSE
7958 , p_assignment_in_tbl IN ASSIGNMENT_IN_TBL_TYPE
7959 , x_return_status OUT NOCOPY VARCHAR2
7960 , x_msg_count OUT NOCOPY NUMBER
7961 , x_msg_data OUT NOCOPY VARCHAR2
7962 )
7963 IS
7964 l_calling_application VARCHAR2(10) := 'PLSQL';
7965 l_calling_module VARCHAR2(10) := 'AMG';
7966 l_check_id_flag VARCHAR2(1) := 'Y';
7967 l_check_role_security_flag VARCHAR2(1) := 'Y';
7968 l_check_resource_security_flag VARCHAR2(1) := 'Y';
7969
7970 l_log_level NUMBER := 3;
7971 l_module VARCHAR2(100) := 'PA_RES_MANAGEMENT_AMG_PUB.UPDATE_ASSIGNMENTS';
7972 l_commit VARCHAR2(1) := FND_API.G_FALSE;
7973 l_init_msg_list VARCHAR2(1) := FND_API.G_FALSE;
7974 l_validate_only VARCHAR2(1) := FND_API.G_FALSE;
7975 l_asgn_update_mode VARCHAR2(10) := 'FULL'; -- This is just a dummy value
7976 l_multiple_status_flag VARCHAR2(1) := 'N';
7977
7978 l_msg_count NUMBER;
7979 l_msg_data VARCHAR2(2000);
7980 l_msg_index_out NUMBER;
7981 l_data VARCHAR2(2000);
7982 l_debug_mode VARCHAR2(1);
7983
7984 i NUMBER;
7985 l_asgn_rec ASSIGNMENT_IN_REC_TYPE;
7986
7987 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
7988 l_error_flag VARCHAR2(1) := 'N';
7989 l_error_flag_local VARCHAR2(1) := 'N';
7990
7991 l_loop_msg_count NUMBER :=0;
7992 l_start_msg_count NUMBER :=0;
7993 l_end_msg_count NUMBER :=0;
7994
7995 l_missing_params VARCHAR2(1000);
7996 l_privilege VARCHAR2(30);
7997 l_object_name VARCHAR2(30);
7998 l_object_key NUMBER;
7999 l_error_message_code VARCHAR2(30);
8000 l_ret_code VARCHAR2(1);
8001
8002 l_before_api_msg_count NUMBER;
8003 l_after_api_msg_count NUMBER;
8004
8005 l_assignment_name PA_PROJECT_ASSIGNMENTS.ASSIGNMENT_NAME%TYPE;
8006 l_assignment_id PA_PROJECT_ASSIGNMENTS.ASSIGNMENT_ID%TYPE;
8007 l_record_version_number PA_PROJECT_ASSIGNMENTS.RECORD_VERSION_NUMBER%TYPE;
8008 l_status_code PA_PROJECT_ASSIGNMENTS.STATUS_CODE%TYPE;
8009 l_apprvl_status_code PA_PROJECT_ASSIGNMENTS.APPRVL_STATUS_CODE%TYPE;
8010 l_apprvl_sys_status_code PA_PROJECT_STATUSES.PROJECT_SYSTEM_STATUS_CODE%TYPE;
8011 l_mass_wf_in_progress_flag PA_PROJECT_ASSIGNMENTS.MASS_WF_IN_PROGRESS_FLAG%TYPE ;
8012
8013 CURSOR c_sys_status_code(l_in_status_code IN VARCHAR2 ) IS
8014 SELECT project_system_status_code
8015 FROM pa_project_statuses
8016 WHERE project_status_code = l_in_status_code
8017 AND status_type= 'ASGMT_APPRVL';
8018
8019 CURSOR c_asgn_db_values IS
8020 SELECT * from pa_project_assignments
8021 WHERE assignment_id = l_assignment_id
8022 AND assignment_type <> 'OPEN_ASSIGNMENT' ;
8023
8024 CURSOR c_get_subteam_party_id(l_in_assignment_id IN NUMBER) IS
8025 SELECT project_subteam_party_id, project_subteam_id
8026 FROM pa_project_subteam_parties
8027 WHERE object_id = l_in_assignment_id
8028 AND object_type = 'PA_PROJECT_ASSIGNMENTS'
8029 AND primary_subteam_flag = 'Y';
8030
8031 CURSOR get_bill_rate_override_flags(c_project_id NUMBER) IS
8032 SELECT impl.rate_discount_reason_flag ,impl.br_override_flag, impl.br_discount_override_flag
8033 FROM pa_implementations_all impl
8034 , pa_projects_all proj
8035 WHERE proj.org_id=impl.org_id -- Removed nvl condition from org_id : Post review changes for Bug 5130421
8036 AND proj.project_id = c_project_id ;
8037
8038 CURSOR c_get_lookup_exists(c_lookup_type VARCHAR2, c_lookup_code VARCHAR2) IS
8039 SELECT 'Y'
8040 FROM dual
8041 WHERE EXISTS
8042 (SELECT 'XYZ' FROM pa_lookups WHERE lookup_type = c_lookup_type AND lookup_code = c_lookup_code);
8043
8044 CURSOR c_derive_country_code(c_country_name IN VARCHAR2) IS
8045 SELECT COUNTRY_CODE
8046 FROM PA_COUNTRY_V
8047 WHERE NAME = c_country_name;
8048
8049 CURSOR c_derive_country_name(c_country_code IN VARCHAR2) IS
8050 SELECT NAME
8051 FROM PA_COUNTRY_V
8052 WHERE COUNTRY_CODE = c_country_code;
8053
8054 -- 5144288, 5144369 : Added c_get_mcb_flag
8055 CURSOR c_get_mcb_flag(c_project_id NUMBER) IS
8056 SELECT multi_currency_billing_flag
8057 FROM pa_projects_all
8058 WHERE project_id = c_project_id;
8059
8060
8061
8062 l_valid_country VARCHAR2(1):='N';
8063 l_dummy_country_code VARCHAR2(2);
8064 l_dummy_state VARCHAR2(240);
8065 l_dummy_city VARCHAR2(80);
8066 l_out_location_id NUMBER;
8067 l_asgn_db_values_rec c_asgn_db_values%ROWTYPE;
8068 l_valid_assignment VARCHAR2(1) := 'N';
8069 l_project_subteam_party_id NUMBER;
8070 l_project_subteam_id NUMBER;
8071 l_valid_flag VARCHAR2(1);
8072 l_rate_discount_reason_flag VARCHAR2(1);
8073 l_br_override_flag VARCHAR2(1);
8074 l_br_discount_override_flag VARCHAR2(1);
8075 l_basic_info_changed VARCHAR2(1);
8076 l_fin_info_changed VARCHAR2(1);
8077 l_fin_bill_rate_info_changed VARCHAR2(1);
8078 l_fin_tp_rate_info_changed VARCHAR2(1);
8079
8080 l_multi_currency_billing_flag VARCHAR2(1); -- 5144288, 5144369
8081 l_bill_currency_override_tmp VARCHAR2(30); -- 5144288, 5144369
8082
8083
8084
8085 BEGIN
8086
8087 --------------------------------------------------
8088 -- RESET OUT params
8089 --------------------------------------------------
8090 x_return_status := FND_API.G_RET_STS_SUCCESS;
8091 x_msg_count := 0;
8092 x_msg_data := NULL ;
8093 --------------------------------------------------
8094 -- Initialize Current Function and Msg Stack
8095 --------------------------------------------------
8096 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE',fnd_global.user_id,fnd_global.login_id,275,null,null), 'N');
8097
8098 IF l_debug_mode = 'Y' THEN
8099 PA_DEBUG.set_curr_function(p_function => 'UPDATE_ASSIGNMENTS', p_debug_mode => l_debug_mode);
8100 END IF;
8101
8102 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
8103 FND_MSG_PUB.initialize;
8104 END IF;
8105 --------------------------------------------------
8106 -- Create Savepoint
8107 --------------------------------------------------
8108 IF p_commit = FND_API.G_TRUE THEN
8109 savepoint UPDATE_ASSIGNMENTS_SP;
8110 END IF;
8111
8112 IF l_debug_mode = 'Y' THEN
8113 pa_debug.write(l_module, 'Start of UPDATE_ASSIGNMENTS', l_log_level);
8114 END IF;
8115 --------------------------------------------------
8116 -- Start Initialize
8117 --------------------------------------------------
8118 PA_STARTUP.INITIALIZE(
8119 p_calling_application => l_calling_application
8120 , p_calling_module => l_calling_module
8121 , p_check_id_flag => l_check_id_flag
8122 , p_check_role_security_flag => l_check_role_security_flag
8123 , p_check_resource_security_flag => l_check_resource_security_flag
8124 , p_debug_level => l_log_level
8125 );
8126
8127 IF l_debug_mode = 'Y' THEN
8128 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
8129 END IF;
8130 ----------------------------------------------------
8131 -- Mandatory param validations and Defaulting Values
8132 -- Security Check
8133 -- Core Logic
8134 ----------------------------------------------------
8135 i := p_assignment_in_tbl.first ;
8136
8137 WHILE i IS NOT NULL LOOP
8138
8139 l_error_flag_local := 'N';
8140 l_missing_params := null;
8141 l_asgn_rec := NULL ;
8142 l_basic_info_changed := 'N';
8143 l_fin_info_changed := 'N';
8144 l_fin_bill_rate_info_changed := 'N';
8145 l_fin_tp_rate_info_changed := 'N';
8146
8147 l_start_msg_count := FND_MSG_PUB.count_msg;
8148
8149 l_asgn_rec := p_assignment_in_tbl(i);
8150
8151 /*--Bug 6511907 PJR Date Validation Enhancement ----- Start--*/
8152 /*-- Validating Resource Req Start and End Date against
8153 Project Start and Completion dates --*/
8154
8155 If l_asgn_rec.start_date is not null or l_asgn_rec.end_date is not null Then
8156 Declare
8157 l_validate VARCHAR2(10);
8158 l_start_date_status VARCHAR2(10);
8159 l_end_date_status VARCHAR2(10);
8160 l_start_date DATE;
8161 l_end_date DATE;
8162 Begin
8163 If l_asgn_rec.start_date is not null or l_asgn_rec.end_date is not null then
8164 l_start_date := l_asgn_rec.start_date;
8165 l_end_date := l_asgn_rec.end_date;
8166 PA_PROJECT_DATES_UTILS.Validate_Resource_Dates
8167 (l_asgn_rec.project_id, l_start_date, l_end_date,
8168 l_validate, l_start_date_status, l_end_date_status);
8169
8170 If l_validate = 'Y' and l_start_date_status = 'I' Then
8171
8172 pa_utils.add_message
8173 ( p_app_short_name => 'PA'
8174 ,p_msg_name => 'PA_PJR_DATE_START_ERROR'
8175 ,p_token1 => 'PROJ_TXN_START_DATE'
8176 ,p_value1 => GET_PROJECT_START_DATE(l_asgn_rec.project_id)
8177 ,p_token2 => ''
8178 ,p_value2 => ''
8179 ,p_token3 => ''
8180 ,p_value3 => ''
8181 );
8182
8183 RAISE FND_API.G_EXC_ERROR;
8184 End If;
8185
8186 If l_validate = 'Y' and l_end_date_status = 'I' Then
8187
8188 pa_utils.add_message
8189 ( p_app_short_name => 'PA'
8190 ,p_msg_name => 'PA_PJR_DATE_FINISH_ERROR'
8191 ,p_token1 => 'PROJ_TXN_END_DATE'
8192 ,p_value1 => GET_PROJECT_COMPLETION_DATE(l_asgn_rec.project_id)
8193 ,p_token2 => ''
8194 ,p_value2 => ''
8195 ,p_token3 => ''
8196 ,p_value3 => ''
8197 );
8198
8199 RAISE FND_API.G_EXC_ERROR;
8200 End If;
8201 End If;
8202 End;
8203
8204 End if;
8205 /*--Bug 6511907 PJR Date Validation Enhancement ----- End--*/
8206
8207 -----------------------------------------------------------------------
8208 -- Print all the IN params here
8209 -----------------------------------------------------------------------
8210
8211 -----------------------------------------------------------------------
8212 -- Mandatory Parameters Check and Valid Values Checks
8213 -----------------------------------------------------------------------
8214 l_asgn_db_values_rec := NULL ;
8215
8216 l_assignment_id := l_asgn_rec.assignment_id ;
8217
8218 OPEN c_asgn_db_values ;
8219 FETCH c_asgn_db_values INTO l_asgn_db_values_rec ;
8220
8221 IF c_asgn_db_values%NOTFOUND THEN
8222 l_missing_params := l_missing_params || 'ASSIGNMENT_ID';
8223 ELSE
8224 l_valid_assignment := 'Y';
8225 -- Assignment ID exists
8226 l_apprvl_sys_status_code := NULL ;
8227 OPEN c_sys_status_code(l_asgn_db_values_rec.apprvl_status_code);
8228 FETCH c_sys_status_code INTO l_apprvl_sys_status_code;
8229 CLOSE c_sys_status_code ;
8230
8231 IF l_apprvl_sys_status_code in ('ASGMT_APPRVL_CANCELED','ASGMT_APPRVL_SUBMITTED') THEN
8232 l_error_flag_local := 'Y';
8233 PA_UTILS.ADD_MESSAGE('PA','PA_AMG_RES_INV_UP_ASG_STATUS') ;-- Need new msg
8234 -- Discuss with Amit
8235 END IF;
8236
8237 IF nvl(l_asgn_db_values_rec.mass_wf_in_progress_flag, 'N') = 'Y' THEN
8238 PA_UTILS.ADD_MESSAGE('PA', 'PA_ASSIGNMENT_WF');
8239 l_error_flag_local := 'Y';
8240 END IF;
8241
8242 END IF;
8243 CLOSE c_asgn_db_values ;
8244
8245 IF l_asgn_rec.work_type_id IS NULL AND l_asgn_rec.work_type_name IS NULL THEN
8246 l_missing_params := l_missing_params||', WORK_TYPE_ID, WORK_TYPE_NAME';
8247 END IF;
8248
8249 IF l_valid_assignment = 'Y' THEN
8250 IF l_asgn_db_values_rec.project_id IS NOT NULL THEN
8251 -- Update Project Assignment Flow
8252
8253 -- Bug 5174557 : Assignment Type Change is not allowed.
8254 IF l_asgn_rec.assignment_type IS NOT NULL AND
8255 l_asgn_rec.assignment_type <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8256
8257 IF l_asgn_rec.assignment_type <> l_asgn_db_values_rec.assignment_type THEN
8258 l_missing_params := l_missing_params||', ASSIGNMENT_TYPE';
8259 END IF;
8260 END IF;
8261
8262 IF l_asgn_rec.expenditure_type_class IS NULL THEN
8263 l_missing_params := l_missing_params||', EXPENDITURE_TYPE_CLASS';
8264 END IF;
8265
8266 IF l_asgn_rec.expenditure_type IS NULL THEN
8267 l_missing_params := l_missing_params||', EXPENDITURE_TYPE';
8268 END IF;
8269
8270 IF l_asgn_rec.bill_rate_option IS NULL THEN
8271 l_missing_params := l_missing_params||', BILL_RATE_OPTION';
8272 ELSIF l_asgn_rec.bill_rate_option <> G_PA_MISS_CHAR
8273 AND l_asgn_rec.bill_rate_option NOT IN('RATE','MARKUP','DISCOUNT','NONE') THEN
8274 l_missing_params := l_missing_params||', BILL_RATE_OPTION';
8275 ELSIF l_asgn_rec.bill_rate_option = 'NONE' THEN
8276 l_asgn_rec.bill_rate_override := null;
8277 l_asgn_rec.bill_rate_curr_override := NULL ;
8278 l_asgn_rec.markup_percent_override := NULL ;
8279 l_asgn_rec.discount_percentage := NULL ;
8280 l_asgn_rec.rate_disc_reason_code := NULL ;
8281 ELSIF l_asgn_rec.bill_rate_option = 'RATE' THEN
8282 l_asgn_rec.markup_percent_override := null;
8283 l_asgn_rec.discount_percentage := null;
8284 IF (l_asgn_rec.bill_rate_override IS NULL
8285 OR l_asgn_rec.bill_rate_override = G_PA_MISS_NUM)
8286 AND l_asgn_db_values_rec.bill_rate_override IS NULL
8287 THEN
8288 l_missing_params := l_missing_params||', BILL_RATE_OVERRIDE';
8289 END IF;
8290 ELSIF l_asgn_rec.bill_rate_option ='MARKUP' THEN
8291 l_asgn_rec.bill_rate_override := null;
8292 l_asgn_rec.bill_rate_curr_override := NULL ;
8293 l_asgn_rec.discount_percentage := null;
8294 IF (l_asgn_rec.markup_percent_override IS NULL
8295 OR l_asgn_rec.markup_percent_override = G_PA_MISS_NUM)
8296 AND l_asgn_db_values_rec.markup_percent_override IS NULL
8297 THEN
8298 l_missing_params := l_missing_params||', MARKUP_PERCENT_OVERRIDE';
8299 END IF;
8300 ELSIF l_asgn_rec.bill_rate_option = 'DISCOUNT' THEN
8301 l_asgn_rec.bill_rate_override := null;
8302 l_asgn_rec.bill_rate_curr_override := NULL ;
8303 l_asgn_rec.markup_percent_override := NULL ;
8304 IF (l_asgn_rec.discount_percentage IS NULL
8305 OR l_asgn_rec.discount_percentage = G_PA_MISS_NUM)
8306 AND l_asgn_db_values_rec.discount_percentage IS NULL
8307 THEN
8308 l_missing_params := l_missing_params||', DISCOUNT_PERCENTAGE';
8309 END IF;
8310 END IF;
8311
8312 IF l_asgn_rec.tp_rate_option IS NULL THEN
8313 l_missing_params := l_missing_params||', TP_RATE_OPTION';
8314 ELSIF l_asgn_rec.tp_rate_option <> G_PA_MISS_CHAR
8315 AND l_asgn_rec.tp_rate_option NOT IN('RATE','BASIS','NONE') THEN
8316 l_missing_params := l_missing_params||', TP_RATE_OPTION';
8317 ELSIF l_asgn_rec.tp_rate_option = 'NONE' THEN
8318 l_asgn_rec.tp_rate_override := null;
8319 l_asgn_rec.tp_currency_override := NULL ;
8320 l_asgn_rec.tp_calc_base_code_override := NULL ;
8321 l_asgn_rec.tp_percent_applied_override := NULL ;
8322 ELSIF l_asgn_rec.tp_rate_option = 'RATE' THEN
8323 l_asgn_rec.tp_calc_base_code_override := NULL ;
8324 l_asgn_rec.tp_percent_applied_override := NULL ;
8325 IF ((l_asgn_rec.tp_rate_override IS NULL
8326 OR l_asgn_rec.tp_rate_override = G_PA_MISS_NUM
8327 )
8328 AND l_asgn_db_values_rec.tp_rate_override IS NULL
8329 )
8330 OR
8331 ((l_asgn_rec.tp_currency_override IS NULL
8332 OR l_asgn_rec.tp_currency_override = G_PA_MISS_CHAR
8333 )
8334 AND l_asgn_db_values_rec.tp_currency_override IS NULL
8335 )
8336 THEN
8337 l_missing_params := l_missing_params||', TP_RATE_OVERRIDE, TP_CURRENCY_OVERRIDE';
8338 END IF;
8339 ELSIF l_asgn_rec.tp_rate_option = 'BASIS' THEN
8340 l_asgn_rec.tp_rate_override := null;
8341 l_asgn_rec.tp_currency_override := NULL ;
8342 IF ((l_asgn_rec.tp_calc_base_code_override IS NULL
8343 OR l_asgn_rec.tp_calc_base_code_override = G_PA_MISS_CHAR
8344 )
8345 AND l_asgn_db_values_rec.tp_calc_base_code_override IS NULL
8346 )
8347 OR
8348 (( l_asgn_rec.tp_percent_applied_override IS NULL
8349 OR l_asgn_rec.tp_percent_applied_override = G_PA_MISS_NUM
8350 )
8351 AND l_asgn_db_values_rec.tp_percent_applied_override IS NULL
8352 )
8353 THEN
8354 l_missing_params := l_missing_params||', TP_CALC_BASE_CODE_OVERRIDE,TP_PERCENT_APPLIED_OVERRIDE' ;
8355 END IF;
8356 END IF;
8357
8358 IF l_asgn_rec.extension_possible <> G_PA_MISS_CHAR
8359 AND l_asgn_rec.extension_possible NOT IN ('Y','N')
8360 THEN
8361 l_missing_params := l_missing_params||', EXTENSION_POSSIBLE';
8362 END IF;
8363
8364 IF l_asgn_rec.expense_owner <> G_PA_MISS_CHAR
8365 AND l_asgn_rec.expense_owner NOT IN ('CLIENT','PROJECT_ORG','RESOURCE_ORG')
8366 THEN
8367 l_missing_params := l_missing_params||', EXPENSE_OWNER';
8368 END IF;
8369
8370 -- If either city or state (or) both are passed ,then country is
8371 -- mandatory
8372 IF (l_asgn_rec.location_country_code IS NULL AND l_asgn_rec.location_country_name IS NULL)
8373 OR
8374 (l_asgn_rec.location_country_code = G_PA_MISS_CHAR
8375 AND l_asgn_rec.location_country_code = G_PA_MISS_CHAR
8376 AND l_asgn_db_values_rec.location_id IS NULL)
8377 THEN
8378 IF (l_asgn_rec.location_region <> G_PA_MISS_CHAR AND
8379 l_asgn_rec.location_region IS NOT NULL)
8380 OR
8381 (l_asgn_rec.location_city <> G_PA_MISS_CHAR AND
8382 l_asgn_rec.location_city IS NOT NULL)
8383 THEN
8384 -- This means,User is NULLING OUT Country Field
8385 -- But Passing State (or) City Values.
8386 -- (OR)
8387 -- In DB,No Country has been specified yet.
8388 -- User is not passing Country Value
8389 -- But user is trying to specify State or City
8390 -- We should nt allow it
8391 --PA_UTILS.ADD_MESSAGE('PA','PA_COUNTRY_INVALID');
8392 l_missing_params := l_missing_params||', LOCATION_COUNTRY_CODE, LOCATION_COUNTRY_NAME';
8393 l_valid_country := 'N';
8394 END IF;
8395 ELSIF l_asgn_rec.location_country_code IS NOT NULL
8396 AND l_asgn_rec.location_country_code <> G_PA_MISS_CHAR
8397 THEN
8398 OPEN c_derive_country_name(l_asgn_rec.location_country_code);
8399 FETCH c_derive_country_name INTO l_asgn_rec.location_country_name;
8400 IF c_derive_country_name%NOTFOUND THEN
8401 -- Invalid Country code passed.
8402 l_missing_params := l_missing_params||', LOCATION_COUNTRY_CODE';
8403 l_valid_country := 'N';
8404 ELSE
8405 l_valid_country := 'Y';
8406 END IF;
8407 CLOSE c_derive_country_name;
8408 ELSIF l_asgn_rec.location_country_name IS NOT NULL
8409 AND l_asgn_rec.location_country_name <> G_PA_MISS_CHAR
8410 THEN
8411 OPEN c_derive_country_code(l_asgn_rec.location_country_name);
8412 FETCH c_derive_country_code INTO l_asgn_rec.location_country_code;
8413 IF c_derive_country_code%NOTFOUND THEN
8414 -- Invalid Country Name passed.
8415 l_missing_params := l_missing_params||', LOCATION_COUNTRY_NAME';
8416 l_valid_country := 'N';
8417 ELSE
8418 l_valid_country := 'Y';
8419 END IF;
8420 CLOSE c_derive_country_code;
8421 END IF;
8422
8423 -- If the country is valid,then proceed with the state and city validations
8424 IF (l_valid_country = 'Y') -- This is for user passed values
8425 OR
8426 (l_asgn_rec.location_country_code = G_PA_MISS_CHAR -- This is for existing DB Value
8427 AND l_asgn_rec.location_country_name = G_PA_MISS_CHAR
8428 AND l_asgn_db_values_rec.location_id IS NOT NULL)
8429 THEN
8430 -- If Existing Location ID exists
8431 -- Derive DB values for location details
8432 IF (
8433 (l_asgn_rec.location_country_code = G_PA_MISS_CHAR
8434 AND l_asgn_rec.location_country_name = G_PA_MISS_CHAR
8435 )
8436 OR (l_asgn_rec.location_region = G_PA_MISS_CHAR)
8437 OR (l_asgn_rec.location_city = G_PA_MISS_CHAR)
8438 )
8439 AND ( l_asgn_db_values_rec.location_id IS NOT NULL)
8440 THEN
8441 SELECT country_code,region,city
8442 INTO l_dummy_country_code,l_dummy_state,l_dummy_city
8443 FROM PA_LOCATIONS
8444 WHERE location_id = l_asgn_db_values_rec.location_id;
8445 END IF;
8446
8447 IF (l_asgn_rec.location_country_code <> G_PA_MISS_CHAR)
8448 THEN
8449 l_dummy_country_code := l_asgn_rec.location_country_code;
8450 END IF;
8451
8452 IF (l_asgn_rec.location_region <> G_PA_MISS_CHAR)
8453 THEN
8454 l_dummy_state := l_asgn_rec.location_region;
8455 END IF;
8456
8457 IF (l_asgn_rec.location_city <> G_PA_MISS_CHAR)
8458 THEN
8459 l_dummy_city := l_asgn_rec.location_city;
8460 END IF;
8461
8462 -- ==== A ==== Added for 5174316 : Start
8463 l_asgn_rec.location_country_code := l_dummy_country_code ;
8464 l_asgn_rec.location_region := l_dummy_state ;
8465 l_asgn_rec.location_city := l_dummy_city ;
8466 -- ==== A ==== Added for 5174316 : End
8467
8468 -- If any of values ,not passed, DB Values will be taken
8469 pa_location_utils.Check_Location_Exists
8470 (
8471 p_country_code => l_dummy_country_code
8472 ,p_city => l_dummy_city
8473 ,p_region => l_dummy_state
8474 ,x_location_id => l_out_location_id
8475 ,x_return_status => l_return_status
8476 );
8477
8478 IF l_out_location_id IS NULL THEN
8479 PA_UTILS.ADD_MESSAGE('PA','PA_AMG_RES_INV_CRC_COMB'); -- New message to say ,Invalid comb
8480 l_error_flag_local := 'Y'; -- 5148975
8481 END IF;
8482 END IF;
8483 --
8484 END IF; -- Project Flow
8485 END IF; -- If it is a valid assignment
8486
8487 IF l_debug_mode = 'Y' THEN
8488 pa_debug.write(l_module, 'Mandatory parameter validation over.List of Missing Parameters='||l_missing_params, l_log_level);
8489 END IF;
8490
8491 IF l_missing_params IS NOT NULL THEN
8492 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
8493 'INVALID_PARAMS', l_missing_params);
8494 l_error_flag_local := 'Y';
8495 END IF;
8496
8497 -- Take the db values,if param is not passed
8498
8499 IF l_debug_mode = 'Y' THEN
8500 pa_debug.write(l_module, 'Take values from database for those parameters which are not passed.', l_log_level);
8501 END IF;
8502
8503 IF l_asgn_rec.assignment_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8504 l_asgn_rec.assignment_name := l_asgn_db_values_rec.assignment_name ;
8505 END IF;
8506
8507 IF l_asgn_rec.assignment_type = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8508 l_asgn_rec.assignment_type := l_asgn_db_values_rec.assignment_type ;
8509 END IF;
8510
8511 -- These parameters are Not used for Update Flow:
8512 -- Internal API requires to pass FND_API miss nums instead of null
8513 -- if we pass null, they treat it as update and raise error
8514
8515 l_asgn_rec.project_role_id := FND_API.G_MISS_NUM;
8516
8517 l_asgn_rec.project_role_name := FND_API.G_MISS_CHAR;
8518
8519 l_asgn_rec.project_id := l_asgn_db_values_rec.project_id;
8520
8521 l_asgn_rec.project_name := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR ;
8522
8523 l_asgn_rec.project_number := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR ;
8524
8525 -- Resource ID cant be changed once an assignment is done
8526 -- Internal API expects it to be passed as Miss NUM
8527 l_asgn_rec.resource_id := FND_API.G_MISS_NUM ;
8528
8529
8530 IF l_asgn_rec.staffing_owner_person_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
8531 l_asgn_rec.staffing_owner_person_id := l_asgn_db_values_rec.staffing_owner_person_id ;
8532 END IF;
8533
8534 IF l_asgn_rec.staffing_priority_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8535 l_asgn_rec.staffing_priority_code := l_asgn_db_values_rec.staffing_priority_code ;
8536 END IF;
8537
8538 IF l_asgn_rec.staffing_priority_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8539 l_asgn_rec.staffing_priority_name := NULL ;
8540 END IF;
8541
8542 l_project_subteam_party_id := null;
8543
8544 OPEN c_get_subteam_party_id( l_asgn_rec.assignment_id );
8545 FETCH c_get_subteam_party_id INTO l_project_subteam_party_id, l_project_subteam_id;
8546 CLOSE c_get_subteam_party_id;
8547
8548 IF l_asgn_rec.project_subteam_id = G_PA_MISS_NUM THEN
8549 -- The reason we need to check name here, because
8550 -- If name is passed and id is not. In this case, id
8551 -- will default to previous id and new name will be lost
8552 IF l_asgn_rec.project_subteam_name = G_PA_MISS_CHAR THEN
8553 l_asgn_rec.project_subteam_id := l_project_subteam_id;
8554 ELSIF l_asgn_rec.project_subteam_name IS NULL THEN
8555 l_asgn_rec.project_subteam_id := null;
8556 ELSE
8557 l_asgn_rec.project_subteam_id := null;
8558 END IF;
8559 END IF;
8560
8561 IF l_asgn_rec.project_subteam_name = G_PA_MISS_CHAR THEN
8562 l_asgn_rec.project_subteam_name := null;
8563 END IF;
8564
8565 --IF l_asgn_rec.project_subteam_id IS NULL AND l_asgn_rec.project_subteam_name IS NULL
8566 --THEN
8567 -- l_project_subteam_party_id := NULL;
8568 --END IF;
8569
8570 IF l_asgn_rec.location_id = G_PA_MISS_NUM THEN
8571 l_asgn_rec.location_id := l_asgn_db_values_rec.location_id;
8572 END IF;
8573
8574 /* Commented for Bug 5174316
8575 The following logic is wrong.If we dont pass these params ,
8576 it should not be NULLED OUT.
8577 The logic is already present in location tagged with ==== A ====
8578 IF l_asgn_rec.location_country_code = G_PA_MISS_CHAR THEN
8579 l_asgn_rec.location_country_code := null;
8580 END IF;
8581
8582 IF l_asgn_rec.location_country_name = G_PA_MISS_CHAR THEN
8583 l_asgn_rec.location_country_name := null;
8584 END IF;
8585
8586 IF l_asgn_rec.location_region = G_PA_MISS_CHAR THEN
8587 l_asgn_rec.location_region := null;
8588 END IF;
8589
8590 IF l_asgn_rec.location_city = G_PA_MISS_CHAR THEN
8591 l_asgn_rec.location_city := null;
8592 END IF;
8593 */
8594
8595 IF l_asgn_rec.description = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8596 l_asgn_rec.description := l_asgn_db_values_rec.description ;
8597 ELSE
8598 l_asgn_rec.description := SUBSTRB(l_asgn_rec.description,1,2000);
8599 END IF;
8600
8601 IF l_asgn_rec.additional_information = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8602 l_asgn_rec.additional_information := l_asgn_db_values_rec.additional_information ;
8603 ELSE
8604 l_asgn_rec.additional_information := SUBSTRB(l_asgn_rec.additional_information,1,2000) ;
8605 END IF;
8606
8607 -- These parameters are not For Update flow
8608 l_asgn_rec.start_date := l_asgn_db_values_rec.start_date ;
8609
8610 l_asgn_rec.end_date := l_asgn_db_values_rec.end_date;
8611
8612 l_asgn_rec.status_code := l_asgn_db_values_rec.status_code;
8613
8614 l_asgn_rec.status_name := NULL ;
8615
8616 l_asgn_rec.calendar_type := NULL;
8617
8618 l_asgn_rec.calendar_id := l_asgn_db_values_rec.calendar_id;
8619
8620 l_asgn_rec.calendar_name := NULL ;
8621
8622 IF l_asgn_rec.resource_calendar_percent = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
8623 l_asgn_rec.resource_calendar_percent := l_asgn_db_values_rec.resource_calendar_percent ;
8624 END IF;
8625
8626 IF l_asgn_rec.expenditure_type_class = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8627 l_asgn_rec.expenditure_type_class := l_asgn_db_values_rec.expenditure_type_class ;
8628 END IF;
8629
8630 IF l_asgn_rec.expenditure_type = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8631 l_asgn_rec.expenditure_type := l_asgn_db_values_rec.expenditure_type ;
8632 END IF;
8633
8634 IF l_asgn_rec.work_type_id = G_PA_MISS_NUM THEN
8635 IF l_asgn_rec.work_type_name = G_PA_MISS_CHAR THEN
8636 l_asgn_rec.work_type_id := l_asgn_db_values_rec.work_type_id;
8637 ELSIF l_asgn_rec.work_type_name IS NULL THEN
8638 l_asgn_rec.work_type_id := null;
8639 ELSE
8640 l_asgn_rec.work_type_id := null;
8641 END IF;
8642 END IF;
8643
8644 IF l_asgn_rec.work_type_name = G_PA_MISS_CHAR THEN
8645 l_asgn_rec.work_type_name := null;
8646 END IF;
8647
8648 IF l_asgn_rec.bill_rate_override = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
8649 l_asgn_rec.bill_rate_override := l_asgn_db_values_rec.bill_rate_override;
8650 END IF;
8651
8652 IF l_asgn_rec.bill_rate_curr_override = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8653 l_asgn_rec.bill_rate_curr_override := l_asgn_db_values_rec.bill_rate_curr_override;
8654 END IF;
8655
8656 IF l_asgn_rec.markup_percent_override = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
8657 l_asgn_rec.markup_percent_override := l_asgn_db_values_rec.markup_percent_override;
8658 END IF;
8659
8660 IF l_asgn_rec.discount_percentage = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
8661 l_asgn_rec.discount_percentage := l_asgn_db_values_rec.discount_percentage;
8662 END IF;
8663
8664 IF l_asgn_rec.rate_disc_reason_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8665 l_asgn_rec.rate_disc_reason_code := l_asgn_db_values_rec.rate_disc_reason_code;
8666 END IF;
8667
8668 IF l_asgn_rec.tp_rate_override = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
8669 l_asgn_rec.tp_rate_override := l_asgn_db_values_rec.tp_rate_override;
8670 END IF;
8671
8672 IF l_asgn_rec.tp_currency_override = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8673 l_asgn_rec.tp_currency_override := l_asgn_db_values_rec.tp_currency_override;
8674 END IF;
8675
8676 IF l_asgn_rec.tp_calc_base_code_override = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8677 l_asgn_rec.tp_calc_base_code_override := l_asgn_db_values_rec.tp_calc_base_code_override;
8678 END IF;
8679
8680 IF l_asgn_rec.tp_percent_applied_override = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
8681 l_asgn_rec.tp_percent_applied_override := l_asgn_db_values_rec.tp_percent_applied_override;
8682 END IF;
8683
8684 IF l_asgn_rec.extension_possible = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8685 l_asgn_rec.extension_possible := l_asgn_db_values_rec.extension_possible;
8686 END IF;
8687
8688 IF l_asgn_rec.expense_owner = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8689 l_asgn_rec.expense_owner := l_asgn_db_values_rec.expense_owner;
8690 END IF;
8691
8692 IF l_asgn_rec.expense_limit = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
8693 l_asgn_rec.expense_limit := l_asgn_db_values_rec.expense_limit;
8694 END IF;
8695
8696 IF l_asgn_rec.orig_system_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8697 l_asgn_rec.orig_system_code := l_asgn_db_values_rec.orig_system_code;
8698 END IF;
8699
8700 IF l_asgn_rec.orig_system_reference = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8701 l_asgn_rec.orig_system_reference := l_asgn_db_values_rec.orig_system_reference;
8702 END IF;
8703
8704 IF l_asgn_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
8705 l_asgn_rec.record_version_number := l_asgn_db_values_rec.record_version_number;
8706 END IF;
8707
8708 IF l_asgn_rec.attribute_category = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8709 l_asgn_rec.attribute_category := l_asgn_db_values_rec.attribute_category;
8710 END IF;
8711
8712 IF l_asgn_rec.attribute1 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8713 l_asgn_rec.attribute1 := l_asgn_db_values_rec.attribute1;
8714 END IF;
8715
8716 IF l_asgn_rec.attribute2 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8717 l_asgn_rec.attribute2 := l_asgn_db_values_rec.attribute2;
8718 END IF;
8719
8720 IF l_asgn_rec.attribute3 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8721 l_asgn_rec.attribute3 := l_asgn_db_values_rec.attribute3;
8722 END IF;
8723
8724 IF l_asgn_rec.attribute4 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8725 l_asgn_rec.attribute4 := l_asgn_db_values_rec.attribute4;
8726 END IF;
8727
8728 IF l_asgn_rec.attribute5 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8729 l_asgn_rec.attribute5 := l_asgn_db_values_rec.attribute5;
8730 END IF;
8731
8732 IF l_asgn_rec.attribute6 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8733 l_asgn_rec.attribute6 := l_asgn_db_values_rec.attribute6;
8734 END IF;
8735
8736 IF l_asgn_rec.attribute7 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8737 l_asgn_rec.attribute7 := l_asgn_db_values_rec.attribute7;
8738 END IF;
8739
8740 IF l_asgn_rec.attribute8 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8741 l_asgn_rec.attribute8 := l_asgn_db_values_rec.attribute8;
8742 END IF;
8743
8744 IF l_asgn_rec.attribute9 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8745 l_asgn_rec.attribute9 := l_asgn_db_values_rec.attribute9;
8746 END IF;
8747
8748 IF l_asgn_rec.attribute10 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8749 l_asgn_rec.attribute10 :=l_asgn_db_values_rec.attribute10;
8750 END IF;
8751
8752 IF l_asgn_rec.attribute11 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8753 l_asgn_rec.attribute11 := l_asgn_db_values_rec.attribute11;
8754 END IF;
8755
8756 IF l_asgn_rec.attribute12 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8757 l_asgn_rec.attribute12 :=l_asgn_db_values_rec.attribute12;
8758 END IF;
8759
8760 IF l_asgn_rec.attribute13 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8761 l_asgn_rec.attribute13 :=l_asgn_db_values_rec.attribute13;
8762 END IF;
8763
8764 IF l_asgn_rec.attribute14 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8765 l_asgn_rec.attribute14 := l_asgn_db_values_rec.attribute14;
8766 END IF;
8767
8768 IF l_asgn_rec.attribute15 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
8769 l_asgn_rec.attribute15 :=l_asgn_db_values_rec.attribute15;
8770 END IF;
8771
8772
8773 IF l_debug_mode = 'Y' THEN
8774 pa_debug.write(l_module, 'After defaulting values ', l_log_level);
8775 pa_debug.write(l_module, 'ProjectId is ' || l_asgn_db_values_rec.project_id, l_log_level);
8776 pa_debug.write(l_module, 'DB Value of TeamTemplateFlag is ' ||l_asgn_db_values_rec.template_flag, l_log_level);
8777 pa_debug.write(l_module, 'l_error_flag_local is '||l_error_flag_local, l_log_level);
8778 END IF;
8779
8780 --------------------------------------------------------------------------------------------
8781 -- Validation Of Param Values continues
8782 --------------------------------------------------------------------------------------------
8783 -- All validations are not required as some validation is done in underlying code
8784 -- Here, we are doing only those validations which are not done internally.
8785
8786 IF l_error_flag_local <> 'Y' THEN
8787 -- Project Assignment Flow
8788
8789 -------------------------------
8790 -- Bill Rate Options Validation
8791 -------------------------------
8792
8793 IF l_asgn_rec.bill_rate_option <> 'NONE' THEN
8794 l_rate_discount_reason_flag := 'N';
8795 l_br_override_flag := 'N';
8796 l_br_discount_override_flag := 'N';
8797
8798 OPEN get_bill_rate_override_flags(l_asgn_rec.project_id);
8799 FETCH get_bill_rate_override_flags INTO l_rate_discount_reason_flag, l_br_override_flag, l_br_discount_override_flag;
8800 CLOSE get_bill_rate_override_flags;
8801
8802 IF l_debug_mode = 'Y' THEN
8803 pa_debug.write(l_module, 'Validating Bill Rate Options', l_log_level);
8804 pa_debug.write(l_module, 'l_rate_discount_reason_flag is '||l_rate_discount_reason_flag, l_log_level);
8805 pa_debug.write(l_module, 'l_br_override_flag is '||l_br_override_flag, l_log_level);
8806 pa_debug.write(l_module, 'l_br_discount_override_flag is '||l_br_discount_override_flag, l_log_level);
8807 END IF;
8808
8809 IF l_asgn_rec.bill_rate_option = 'RATE' THEN
8810 IF l_br_override_flag <> 'Y' OR l_asgn_rec.bill_rate_override <= 0 THEN /* OR l_asgn_rec.bill_rate_override > 100 - Removed for Bug 5703021*/
8811 IF l_br_override_flag <> 'Y' THEN
8812 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_BILL_RATE_OVRD_NA');
8813 l_error_flag_local := 'Y';
8814 ELSE
8815 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_BILL_RATE_OVRD');
8816 l_error_flag_local := 'Y';
8817 END IF;
8818 END IF;
8819 -- 5144288, 5144369 : Begin
8820 l_multi_currency_billing_flag := null;
8821 OPEN c_get_mcb_flag(l_asgn_rec.project_id);
8822 FETCH c_get_mcb_flag INTO l_multi_currency_billing_flag;
8823 CLOSE c_get_mcb_flag;
8824
8825 IF nvl(l_multi_currency_billing_flag,'N') = 'Y' AND l_br_override_flag = 'Y' THEN
8826 l_return_status := FND_API.G_RET_STS_SUCCESS;
8827 l_error_message_code := null;
8828 l_bill_currency_override_tmp := l_asgn_rec.bill_rate_curr_override;
8829
8830 IF l_debug_mode = 'Y' THEN
8831 pa_debug.write(l_module, 'Validating Bill Rate Currency', l_log_level);
8832 END IF;
8833
8834 PA_PROJECTS_MAINT_UTILS.CHECK_CURRENCY_NAME_OR_CODE(
8835 p_agreement_currency => l_bill_currency_override_tmp
8836 ,p_agreement_currency_name => null
8837 ,p_check_id_flag => 'Y'
8838 ,x_agreement_currency => l_asgn_rec.bill_rate_curr_override
8839 ,x_return_status => l_return_status
8840 ,x_error_msg_code => l_error_message_code);
8841
8842 IF l_debug_mode = 'Y' THEN
8843 pa_debug.write(l_module, 'After Bill Rate Currency Validation', l_log_level);
8844 pa_debug.write(l_module, 'l_return_status='||l_return_status, l_log_level);
8845 pa_debug.write(l_module, 'l_error_message_code='||l_error_message_code, l_log_level);
8846 END IF;
8847
8848 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
8849 PA_UTILS.ADD_MESSAGE('PA', 'PA_CISI_CURRENCY_NULL');
8850 l_error_flag_local := 'Y';
8851 END IF;
8852 END IF;
8853 -- 5144288, 5144369 : End
8854 ELSIF l_asgn_rec.bill_rate_option = 'MARKUP' THEN
8855 -- 5144675 Changed l_asgn_rec.markup_percent_override <=0 to < 0
8856 IF l_br_override_flag <> 'Y' OR l_asgn_rec.markup_percent_override < 0
8857 OR l_asgn_rec.markup_percent_override > 100 THEN
8858 IF l_br_override_flag <> 'Y' THEN
8859 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_BILL_RATE_OVRD_NA');
8860 l_error_flag_local := 'Y';
8861 ELSE
8862 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_MARKUP_PERCENT');
8863 l_error_flag_local := 'Y';
8864 END IF;
8865 END IF;
8866 ELSIF l_asgn_rec.bill_rate_option = 'DISCOUNT' THEN
8867 -- 5144675 Changed l_asgn_rec.discount_percentage <= 0 to < 0
8868 IF l_br_discount_override_flag <> 'Y' OR l_asgn_rec.discount_percentage < 0
8869 OR l_asgn_rec.discount_percentage > 100 THEN
8870 IF l_br_discount_override_flag <> 'Y' THEN
8871 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_DISC_OVRD_NA');
8872 l_error_flag_local := 'Y';
8873 ELSE
8874 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_DISCOUNT_PERCENT');
8875 l_error_flag_local := 'Y';
8876 END IF;
8877 END IF;
8878 END IF;
8879
8880 IF l_asgn_rec.rate_disc_reason_code IS NULL THEN
8881 IF (l_rate_discount_reason_flag ='Y' AND (l_br_override_flag ='Y' OR l_br_discount_override_flag='Y') AND
8882 (l_asgn_rec.bill_rate_override IS NOT NULL OR l_asgn_rec.markup_percent_override IS NOT NULL OR l_asgn_rec.discount_percentage IS NOT NULL)
8883 )
8884 THEN
8885 PA_UTILS.ADD_MESSAGE('PA', 'PA_RATE_DISC_REASON_REQUIRED');
8886 l_error_flag_local := 'Y';
8887 END IF;
8888 ELSE
8889 l_valid_flag := 'N';
8890 OPEN c_get_lookup_exists('RATE AND DISCOUNT REASON', l_asgn_rec.rate_disc_reason_code);
8891 FETCH c_get_lookup_exists INTO l_valid_flag;
8892 CLOSE c_get_lookup_exists;
8893 IF nvl(l_valid_flag,'N') <> 'Y' THEN
8894 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_DISC_RSN_INVALID');
8895 l_error_flag_local := 'Y';
8896 END IF;
8897 END IF;
8898
8899 IF l_debug_mode = 'Y' THEN
8900 pa_debug.write(l_module, 'After Validating Bill Rate Options l_error_flag_local is '||l_error_flag_local, l_log_level);
8901 END IF;
8902 END IF; -- l_asgn_rec.bill_rate_option <> 'NONE'
8903
8904 ---------------------------------------------
8905 -- Transfer Price Rate Options Validation
8906 ---------------------------------------------
8907
8908 IF l_asgn_rec.tp_rate_option <> 'NONE' THEN
8909
8910 IF l_debug_mode = 'Y' THEN
8911 pa_debug.write(l_module, 'Validating Transfer Price Rate Options', l_log_level);
8912 END IF;
8913
8914 IF l_asgn_rec.tp_rate_option = 'RATE' THEN
8915 null; -- This validation is done internally
8916 ELSIF l_asgn_rec.tp_rate_option = 'BASIS' THEN
8917 IF l_debug_mode = 'Y' THEN
8918 pa_debug.write(l_module, 'Validating Transfer Price Rate Basis', l_log_level);
8919 END IF;
8920
8921 OPEN c_get_lookup_exists('CC_MARKUP_BASE_CODE', l_asgn_rec.tp_calc_base_code_override);
8922 FETCH c_get_lookup_exists INTO l_valid_flag;
8923 CLOSE c_get_lookup_exists;
8924
8925 IF l_debug_mode = 'Y' THEN
8926 pa_debug.write(l_module, 'After Transfer Price Rate Basis Validation', l_log_level);
8927 pa_debug.write(l_module, 'l_valid_flag='||l_valid_flag, l_log_level);
8928 END IF;
8929
8930 IF nvl(l_valid_flag,'N') <> 'Y' THEN
8931 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_TP_BASIS_INVALID');
8932 l_error_flag_local := 'Y';
8933 END IF;
8934 END IF;
8935
8936 IF l_debug_mode = 'Y' THEN
8937 pa_debug.write(l_module, 'After Validating Transfer Price Rate Options l_error_flag_local='||l_error_flag_local, l_log_level);
8938 END IF;
8939 END IF; -- l_asgn_rec.tp_rate_option <> 'NONE'
8940
8941 ---------------------------------------------
8942 -- Res Loan Agreement Validations
8943 ---------------------------------------------
8944 IF l_asgn_rec.expense_owner IS NOT NULL THEN
8945 l_valid_flag := 'N';
8946
8947 IF l_debug_mode = 'Y' THEN
8948 pa_debug.write(l_module, 'Validating Expense Owner Option', l_log_level);
8949 END IF;
8950
8951 OPEN c_get_lookup_exists('EXPENSE_OWNER_TYPE', l_asgn_rec.expense_owner);
8952 FETCH c_get_lookup_exists INTO l_valid_flag;
8953 CLOSE c_get_lookup_exists;
8954
8955 IF l_debug_mode = 'Y' THEN
8956 pa_debug.write(l_module, 'After Expense Owner Option Validation', l_log_level);
8957 pa_debug.write(l_module, 'l_valid_flag='||l_valid_flag, l_log_level);
8958 END IF;
8959
8960 IF nvl(l_valid_flag,'N') <> 'Y' THEN
8961 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_EXP_OWNER_INVALID');
8962 l_error_flag_local := 'Y';
8963 END IF;
8964 END IF;
8965 IF l_debug_mode = 'Y' THEN
8966 pa_debug.write(l_module, 'After all validations except flexfield l_error_flag_local='||l_error_flag_local, l_log_level);
8967 END IF;
8968
8969 -- Flex field Validation
8970 ------------------------
8971
8972 IF l_error_flag_local <> 'Y' THEN
8973 l_return_status := FND_API.G_RET_STS_SUCCESS;
8974
8975 VALIDATE_FLEX_FIELD(
8976 p_desc_flex_name => 'PA_TEAM_ROLE_DESC_FLEX'
8977 , p_attribute_category => l_asgn_rec.attribute_category
8978 , px_attribute1 => l_asgn_rec.attribute1
8979 , px_attribute2 => l_asgn_rec.attribute2
8980 , px_attribute3 => l_asgn_rec.attribute3
8981 , px_attribute4 => l_asgn_rec.attribute4
8982 , px_attribute5 => l_asgn_rec.attribute5
8983 , px_attribute6 => l_asgn_rec.attribute6
8984 , px_attribute7 => l_asgn_rec.attribute7
8985 , px_attribute8 => l_asgn_rec.attribute8
8986 , px_attribute9 => l_asgn_rec.attribute9
8987 , px_attribute10 => l_asgn_rec.attribute10
8988 , px_attribute11 => l_asgn_rec.attribute11
8989 , px_attribute12 => l_asgn_rec.attribute12
8990 , px_attribute13 => l_asgn_rec.attribute13
8991 , px_attribute14 => l_asgn_rec.attribute14
8992 , px_attribute15 => l_asgn_rec.attribute15
8993 , x_return_status => l_return_status
8994 , x_msg_count => l_msg_count
8995 , x_msg_data => l_msg_data
8996 );
8997
8998 IF l_debug_mode = 'Y' THEN
8999 pa_debug.write(l_module, 'After Flex Field Validation l_return_status='||l_return_status, l_log_level);
9000 pa_debug.write(l_module, 'After Flex Field Validation l_msg_data='||l_msg_data, l_log_level);
9001 END IF;
9002
9003 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
9004 -- This message does not have toekn defined, still it is ok to pass token as the value
9005 -- returned by flex APIs because token are appended as it is
9006 PA_UTILS.ADD_MESSAGE('PA', 'PA_DFF_VALIDATION_FAILED',
9007 'MESSAGE', l_msg_data );
9008 l_error_flag_local := 'Y';
9009 END IF;
9010 END IF;
9011
9012 END IF; -- End of Param Validations
9013
9014 -- Security Check
9015 -----------------
9016 -- The underlying API does security check of PA_ASN_BASIC_INFO_ED
9017 -- , PA_CREATE_CANDIDATES, PA_ASN_FCST_INFO_ED
9018 -- But still we need to do check here because there are some more checks required
9019 -- Also the underlying API does not consider the MISS chars
9020
9021 ----------- (1)
9022 IF l_error_flag_local <> 'Y' AND nvl(l_asgn_db_values_rec.template_flag,'N') = 'N' THEN
9023 -- Project Assignment
9024 IF nvl(l_asgn_rec.assignment_name, 'XYZ') <> nvl(l_asgn_db_values_rec.assignment_name, 'XYZ')
9025 OR nvl(l_asgn_rec.staffing_priority_code, 'XYZ') <> nvl(l_asgn_db_values_rec.staffing_priority_code, 'XYZ')
9026 OR nvl(l_asgn_rec.staffing_owner_person_id, -1) <> nvl(l_asgn_db_values_rec.staffing_owner_person_id, -1)
9027 OR nvl(l_asgn_rec.description, 'XYZ') <> nvl(l_asgn_db_values_rec.description, 'XYZ')
9028 OR nvl(l_asgn_rec.additional_information, 'XYZ') <> nvl(l_asgn_db_values_rec.additional_information, 'XYZ')
9029 OR nvl(l_asgn_rec.project_subteam_id, -1) <> nvl(l_project_subteam_id, -1)
9030 OR nvl(l_asgn_rec.location_id, -1) <> nvl(l_asgn_db_values_rec.location_id, -1)
9031 OR nvl(l_asgn_rec.attribute_category,'XX') <> nvl(l_asgn_db_values_rec.attribute_category,'XX')
9032 OR nvl(l_asgn_rec.attribute1,'XX') <> nvl(l_asgn_db_values_rec.attribute1,'XX')
9033 OR nvl(l_asgn_rec.attribute2,'XX') <> nvl(l_asgn_db_values_rec.attribute2,'XX')
9034 OR nvl(l_asgn_rec.attribute3,'XX') <> nvl(l_asgn_db_values_rec.attribute3,'XX')
9035 OR nvl(l_asgn_rec.attribute4,'XX') <> nvl(l_asgn_db_values_rec.attribute4,'XX')
9036 OR nvl(l_asgn_rec.attribute5,'XX') <> nvl(l_asgn_db_values_rec.attribute5,'XX')
9037 OR nvl(l_asgn_rec.attribute6,'XX') <> nvl(l_asgn_db_values_rec.attribute6,'XX')
9038 OR nvl(l_asgn_rec.attribute7,'XX') <> nvl(l_asgn_db_values_rec.attribute7,'XX')
9039 OR nvl(l_asgn_rec.attribute8,'XX') <> nvl(l_asgn_db_values_rec.attribute8,'XX')
9040 OR nvl(l_asgn_rec.attribute9,'XX') <> nvl(l_asgn_db_values_rec.attribute9,'XX')
9041 OR nvl(l_asgn_rec.attribute10,'XX') <> nvl(l_asgn_db_values_rec.attribute10,'XX')
9042 OR nvl(l_asgn_rec.attribute11,'XX') <> nvl(l_asgn_db_values_rec.attribute11,'XX')
9043 OR nvl(l_asgn_rec.attribute12,'XX') <> nvl(l_asgn_db_values_rec.attribute12,'XX')
9044 OR nvl(l_asgn_rec.attribute13,'XX') <> nvl(l_asgn_db_values_rec.attribute13,'XX')
9045 OR nvl(l_asgn_rec.attribute14,'XX') <> nvl(l_asgn_db_values_rec.attribute14,'XX')
9046 OR nvl(l_asgn_rec.attribute15,'XX') <> nvl(l_asgn_db_values_rec.attribute15,'XX')
9047 THEN
9048 l_basic_info_changed := 'Y';
9049 END IF;
9050
9051
9052 IF nvl(l_asgn_rec.extension_possible, 'XYZ') <> nvl(l_asgn_db_values_rec.extension_possible, 'XYZ')
9053 OR nvl(l_asgn_rec.expense_owner, 'XYZ') <> nvl(l_asgn_db_values_rec.expense_owner, 'XYZ')
9054 OR nvl(l_asgn_rec.expense_limit, -1) <> nvl(l_asgn_db_values_rec.expense_limit, -1)
9055 OR nvl(l_asgn_rec.expenditure_type_class, 'XYZ') <> nvl(l_asgn_db_values_rec.expenditure_type_class, 'XYZ')
9056 OR nvl(l_asgn_rec.expenditure_type, 'XYZ') <> nvl(l_asgn_db_values_rec.expenditure_type, 'XYZ')
9057 OR nvl(l_asgn_rec.work_type_id, -1) <> nvl(l_asgn_db_values_rec.work_type_id, -1)
9058 THEN
9059 l_fin_info_changed := 'Y';
9060 END IF;
9061
9062 IF nvl(l_asgn_rec.bill_rate_override, -1) <> nvl(l_asgn_db_values_rec.bill_rate_override, -1)
9063 OR nvl(l_asgn_rec.bill_rate_curr_override, 'XYZ') <> nvl(l_asgn_db_values_rec.bill_rate_curr_override, 'XYZ')
9064 OR nvl(l_asgn_rec.markup_percent_override, -1) <> nvl(l_asgn_db_values_rec.markup_percent_override, -1)
9065 OR nvl(l_asgn_rec.discount_percentage, -1) <> nvl(l_asgn_db_values_rec.discount_percentage, -1)
9066 OR nvl(l_asgn_rec.rate_disc_reason_code, 'XYZ') <> nvl(l_asgn_db_values_rec.rate_disc_reason_code, 'XYZ')
9067 THEN
9068 l_fin_bill_rate_info_changed := 'Y';
9069 END IF;
9070
9071 IF nvl(l_asgn_rec.tp_rate_override, -1) <> nvl(l_asgn_db_values_rec.tp_rate_override, -1)
9072 OR nvl(l_asgn_rec.tp_currency_override, 'XYZ') <> nvl(l_asgn_db_values_rec.tp_currency_override, 'XYZ')
9073 OR nvl(l_asgn_rec.tp_percent_applied_override, -1) <> nvl(l_asgn_db_values_rec.tp_percent_applied_override, -1)
9074 OR nvl(l_asgn_rec.tp_calc_base_code_override, 'XYZ') <> nvl(l_asgn_db_values_rec.tp_calc_base_code_override, 'XYZ')
9075 THEN
9076 l_fin_tp_rate_info_changed := 'Y';
9077 END IF;
9078
9079 IF l_basic_info_changed = 'Y' THEN
9080
9081 l_return_status := FND_API.G_RET_STS_SUCCESS;
9082 l_ret_code := 'T';
9083
9084 IF l_asgn_db_values_rec.assignment_type = 'STAFFED_ASSIGNMENT' THEN
9085
9086 l_privilege := 'PA_ASN_BASIC_INFO_ED';
9087 ELSIF l_asgn_db_values_rec.assignment_type = 'STAFFED_ADMIN_ASSIGNMENT' THEN
9088
9089 l_privilege := 'PA_ADM_ASN_CR_AND_DL';
9090 END IF;
9091
9092 l_object_name := 'PA_PROJECTS';
9093 l_object_key := l_asgn_rec.project_id;
9094
9095 IF l_debug_mode = 'Y' THEN
9096 pa_debug.write(l_module, 'Checking Project Level Security for PA_ASN_BASIC_INFO_ED', l_log_level);
9097 END IF ;
9098
9099 l_before_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9100 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
9101 x_ret_code => l_ret_code
9102 , x_return_status => l_return_status
9103 , x_msg_count => l_msg_count
9104 , x_msg_data => l_msg_data
9105 , p_privilege => l_privilege
9106 , p_object_name => l_object_name
9107 , p_object_key => l_object_key
9108 , p_init_msg_list => FND_API.G_FALSE);
9109 l_after_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9110
9111 IF l_debug_mode = 'Y' THEN
9112 pa_debug.write(l_module, 'Project Level Security for PA_ASN_BASIC_INFO_ED l_ret_code '|| l_ret_code , l_log_level);
9113 END IF ;
9114
9115 IF nvl(l_ret_code, 'F') = 'F' OR (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
9116 IF l_debug_mode = 'Y' THEN
9117 pa_debug.write(l_module,'Checking Assignment Level Security for PA_ASN_BASIC_INFO_ED', l_log_level);
9118 END IF ;
9119
9120 l_return_status := FND_API.G_RET_STS_SUCCESS;
9121 l_ret_code := 'T';
9122
9123 IF l_asgn_db_values_rec.assignment_type = 'STAFFED_ASSIGNMENT' THEN
9124
9125 l_privilege := 'PA_ASN_BASIC_INFO_ED';
9126 ELSIF l_asgn_db_values_rec.assignment_type = 'STAFFED_ADMIN_ASSIGNMENT' THEN
9127 l_privilege := 'PA_ADM_ASN_CR_AND_DL';
9128 END IF;
9129
9130 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
9131 l_object_key := l_asgn_rec.assignment_id;
9132
9133 l_before_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9134 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
9135 x_ret_code => l_ret_code
9136 , x_return_status => l_return_status
9137 , x_msg_count => l_msg_count
9138 , x_msg_data => l_msg_data
9139 , p_privilege => l_privilege
9140 , p_object_name => l_object_name
9141 , p_object_key => l_object_key
9142 , p_init_msg_list => FND_API.G_FALSE );
9143 l_after_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9144
9145 IF l_debug_mode = 'Y' THEN
9146 pa_debug.write(l_module,'Assignment Level Security for PA_ASN_BASIC_INFO_ED l_ret_code='||l_ret_code, l_log_level);
9147 END IF ;
9148 END IF;
9149
9150 IF nvl(l_ret_code,'F') <> 'T' OR (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
9151 PA_UTILS.ADD_MESSAGE('PA', 'PA_UPD_ASGN_BASIC_INFO'
9152 ,'MISSING_PRIVILEGE', l_privilege);
9153 l_error_flag_local := 'Y';
9154 END IF;
9155 END IF; -- End If basic info changed
9156
9157 IF l_fin_info_changed = 'Y' OR l_fin_bill_rate_info_changed = 'Y' OR l_fin_tp_rate_info_changed = 'Y' THEN
9158
9159 l_return_status := FND_API.G_RET_STS_SUCCESS;
9160 l_ret_code := 'T';
9161 IF l_asgn_db_values_rec.assignment_type = 'STAFFED_ASSIGNMENT' THEN
9162
9163 l_privilege := 'PA_ASN_FCST_INFO_ED';
9164 ELSIF l_asgn_db_values_rec.assignment_type = 'STAFFED_ADMIN_ASSIGNMENT' THEN
9165 l_privilege := 'PA_ADM_ASN_FCST_INFO_ED';
9166 END IF;
9167
9168 l_object_name := 'PA_PROJECTS';
9169 l_object_key := l_asgn_rec.project_id;
9170
9171 IF l_debug_mode = 'Y' THEN
9172 pa_debug.write(l_module, 'Checking Project Level Security for PA_ASN_FCST_INFO_ED', l_log_level);
9173 END IF ;
9174
9175 l_before_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9176 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
9177 x_ret_code => l_ret_code
9178 , x_return_status => l_return_status
9179 , x_msg_count => l_msg_count
9180 , x_msg_data => l_msg_data
9181 , p_privilege => l_privilege
9182 , p_object_name => l_object_name
9183 , p_object_key => l_object_key
9184 , p_init_msg_list => FND_API.G_FALSE);
9185 l_after_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9186
9187 IF l_debug_mode = 'Y' THEN
9188 pa_debug.write(l_module, 'Project Level Security for PA_ASN_FCST_INFO_ED l_ret_code '|| l_ret_code , l_log_level);
9189 END IF ;
9190
9191 IF nvl(l_ret_code,'F') <> 'T' OR (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
9192 IF l_debug_mode = 'Y' THEN
9193 pa_debug.write(l_module,'Checking Assignment Level Security for PA_CREATE_CANDIDATES', l_log_level);
9194 END IF ;
9195
9196 l_return_status := FND_API.G_RET_STS_SUCCESS;
9197 l_ret_code := 'T';
9198 IF l_asgn_db_values_rec.assignment_type = 'STAFFED_ASSIGNMENT' THEN
9199
9200 l_privilege := 'PA_ASN_FCST_INFO_ED';
9201 ELSIF l_asgn_db_values_rec.assignment_type = 'STAFFED_ADMIN_ASSIGNMENT' THEN
9202 l_privilege := 'PA_ADM_ASN_FCST_INFO_ED';
9203 END IF;
9204
9205 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
9206 l_object_key := l_asgn_rec.assignment_id;
9207
9208 l_before_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9209 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
9210 x_ret_code => l_ret_code
9211 , x_return_status => l_return_status
9212 , x_msg_count => l_msg_count
9213 , x_msg_data => l_msg_data
9214 , p_privilege => l_privilege
9215 , p_object_name => l_object_name
9216 , p_object_key => l_object_key
9217 , p_init_msg_list => FND_API.G_FALSE );
9218 l_after_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9219
9220 IF l_debug_mode = 'Y' THEN
9221 pa_debug.write(l_module,'Requirement Level Security for PA_ASN_FCST_INFO_ED l_ret_code='||l_ret_code, l_log_level);
9222 END IF ;
9223 END IF;
9224
9225 IF nvl(l_ret_code,'F') <> 'T' OR (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
9226 PA_UTILS.ADD_MESSAGE('PA', 'PA_UPD_ASGN_FIN_INFO'
9227 ,'MISSING_PRIVILEGE', l_privilege);
9228 l_error_flag_local := 'Y';
9229 END IF;
9230
9231 END IF; -- End If Financial Information changed
9232
9233 IF l_fin_bill_rate_info_changed = 'Y' THEN
9234
9235 l_return_status := FND_API.G_RET_STS_SUCCESS;
9236 l_ret_code := 'T';
9237 l_privilege := 'PA_ASN_FCST_INFO_BILL_ED';
9238 l_object_name := 'PA_PROJECTS';
9239 l_object_key := l_asgn_rec.project_id;
9240
9241 IF l_debug_mode = 'Y' THEN
9242 pa_debug.write(l_module, 'Checking Project Level Security for PA_ASN_FCST_INFO_BILL_ED', l_log_level);
9243 END IF ;
9244
9245 l_before_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9246 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
9247 x_ret_code => l_ret_code
9248 , x_return_status => l_return_status
9249 , x_msg_count => l_msg_count
9250 , x_msg_data => l_msg_data
9251 , p_privilege => l_privilege
9252 , p_object_name => l_object_name
9253 , p_object_key => l_object_key
9254 , p_init_msg_list => FND_API.G_FALSE);
9255 l_after_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9256
9257 IF l_debug_mode = 'Y' THEN
9258 pa_debug.write(l_module, 'Project Level Security for PA_ASN_FCST_INFO_BILL_ED l_ret_code '|| l_ret_code , l_log_level);
9259 END IF ;
9260
9261 IF nvl(l_ret_code, 'F') = 'F' OR (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
9262
9263 IF l_debug_mode = 'Y' THEN
9264 pa_debug.write(l_module,'Checking Assignment Level Security for PA_ASN_FCST_INFO_BILL_ED', l_log_level);
9265 END IF ;
9266
9267 l_return_status := FND_API.G_RET_STS_SUCCESS;
9268 l_ret_code := 'T';
9269 l_privilege := 'PA_ASN_FCST_INFO_BILL_ED';
9270 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
9271 l_object_key := l_asgn_rec.assignment_id;
9272
9273 l_before_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9274 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
9275 x_ret_code => l_ret_code
9276 , x_return_status => l_return_status
9277 , x_msg_count => l_msg_count
9278 , x_msg_data => l_msg_data
9279 , p_privilege => l_privilege
9280 , p_object_name => l_object_name
9281 , p_object_key => l_object_key
9282 , p_init_msg_list => FND_API.G_FALSE);
9283 l_after_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9284
9285 IF l_debug_mode = 'Y' THEN
9286 pa_debug.write(l_module,'Assignment Level Security for PA_ASN_FCST_INFO_BILL_ED l_ret_code='||l_ret_code, l_log_level);
9287 END IF ;
9288 END IF;
9289
9290 IF nvl(l_ret_code,'F') <> 'T' OR (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
9291 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_UPD_ASGN_BR_INFO'
9292 ,'MISSING_PRIVILEGE', l_privilege);
9293 l_error_flag_local := 'Y';
9294 END IF;
9295 END IF ; -- End If l_fin_bill_rate_info_changed
9296
9297 IF l_fin_tp_rate_info_changed = 'Y' THEN
9298
9299 l_return_status := FND_API.G_RET_STS_SUCCESS;
9300 l_ret_code := 'T';
9301 l_privilege := 'PA_ASN_FCST_INFO_TP_ED';
9302 l_object_name := 'PA_PROJECTS';
9303 l_object_key := l_asgn_rec.project_id;
9304
9305 IF l_debug_mode = 'Y' THEN
9306 pa_debug.write(l_module, 'Checking Project Level Security for PA_ASN_FCST_INFO_TP_ED', l_log_level);
9307 END IF ;
9308
9309 l_before_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9310 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
9311 x_ret_code => l_ret_code
9312 , x_return_status => l_return_status
9313 , x_msg_count => l_msg_count
9314 , x_msg_data => l_msg_data
9315 , p_privilege => l_privilege
9316 , p_object_name => l_object_name
9317 , p_object_key => l_object_key
9318 , p_init_msg_list => FND_API.G_FALSE);
9319 l_after_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9320
9321 IF l_debug_mode = 'Y' THEN
9322 pa_debug.write(l_module, 'Project Level Security for PA_ASN_FCST_INFO_TP_ED l_ret_code '|| l_ret_code , l_log_level);
9323 END IF ;
9324
9325 IF nvl(l_ret_code, 'F') = 'F' OR (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
9326
9327 IF l_debug_mode = 'Y' THEN
9328 pa_debug.write(l_module,'Checking Assignment Level Security for PA_ASN_FCST_INFO_TP_ED', l_log_level);
9329 END IF ;
9330
9331 l_return_status := FND_API.G_RET_STS_SUCCESS;
9332 l_ret_code := 'T';
9333 l_privilege := 'PA_ASN_FCST_INFO_TP_ED';
9334 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
9335 l_object_key := l_asgn_rec.assignment_id;
9336
9337 l_before_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9338 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
9339 x_ret_code => l_ret_code
9340 , x_return_status => l_return_status
9341 , x_msg_count => l_msg_count
9342 , x_msg_data => l_msg_data
9343 , p_privilege => l_privilege
9344 , p_object_name => l_object_name
9345 , p_object_key => l_object_key
9346 , p_init_msg_list => FND_API.G_FALSE );
9347 l_after_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9348
9349 IF l_debug_mode = 'Y' THEN
9350 pa_debug.write(l_module,'Assignment Level Security for PA_ASN_FCST_INFO_TP_ED l_ret_code='||l_ret_code, l_log_level);
9351 pa_debug.write(l_module,'Assignment Level Security for PA_ASN_FCST_INFO_TP_ED l_return_status='||l_return_status, l_log_level);
9352 END IF ;
9353 END IF;
9354
9355 IF nvl(l_ret_code,'F') <> 'T' OR (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
9356 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_UPD_ASGN_TP_INFO'
9357 ,'MISSING_PRIVILEGE', l_privilege);
9358 l_error_flag_local := 'Y';
9359 END IF;
9360 END IF;-- l_fin_tp_rate_info_changed = 'Y'
9361
9362 END IF; ----------- (1)
9363
9364 --------------------------------------------------------------------------------------
9365 -- All Validations and Security checks are over at this point
9366 -- Call Actual Core API
9367 --------------------------------------------------------------------------------------
9368 IF l_error_flag_local <> 'Y' THEN
9369 l_return_status := FND_API.G_RET_STS_SUCCESS;
9370
9371 IF l_debug_mode = 'Y' THEN
9372 pa_debug.write(l_module, 'Calling PA_ASSIGNMENTS_PUB.EXECUTE_UPDATE_ASSIGNMENT for Record No.'||i, l_log_level);
9373 END IF;
9374
9375 l_before_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9376
9377 --Before calling API ,Make location_id as NULL
9378 --If country code is made NULL
9379
9380 --This consistent with Update_Assignment API code in PARAPUBB.pls
9381 IF (l_asgn_rec.location_country_code IS NULL
9382 AND l_asgn_rec.location_country_name IS NULL)
9383 THEN
9384 l_asgn_rec.location_id := NULL ;
9385 END IF;
9386
9387 PA_ASSIGNMENTS_PUB.EXECUTE_UPDATE_ASSIGNMENT
9388 (
9389 p_api_version => p_api_version_number
9390 , p_init_msg_list => l_init_msg_list
9391 , p_commit => l_commit
9392 , p_validate_only => l_validate_only
9393 , p_asgn_update_mode => l_asgn_update_mode
9394 , p_assignment_id => l_asgn_rec.assignment_id
9395 , p_record_version_number => l_asgn_rec.record_version_number
9396 , p_assignment_name => l_asgn_rec.assignment_name
9397 , p_assignment_type => l_asgn_rec.assignment_type
9398 , p_multiple_status_flag => l_asgn_db_values_rec.multiple_status_flag
9399 , p_project_status_name => l_asgn_rec.status_name
9400 , p_status_code => l_asgn_rec.status_code
9401 , p_start_date => l_asgn_rec.start_date
9402 , p_end_date => l_asgn_rec.end_date
9403 , p_staffing_priority_code => l_asgn_rec.staffing_priority_code
9404 , p_project_id => l_asgn_rec.project_id
9405 -- , p_assignment_template_id => l_asgn_rec.assignment_template_id
9406 , p_project_role_id => l_asgn_rec.project_role_id
9407 , p_project_subteam_id => l_asgn_rec.project_subteam_id
9408 , p_project_subteam_party_id => l_project_subteam_party_id
9409 , p_description => l_asgn_rec.description
9410 -- , p_assignment_effort => l_asgn_rec.assignment_effort
9411 , p_extension_possible => l_asgn_rec.extension_possible
9412 -- , p_source_assignment_id => l_asgn_rec.source_assignment_id
9413 -- , p_min_resource_job_level => l_asgn_rec.min_resource_job_level
9414 -- , p_max_resource_job_level => l_asgn_rec.max_resource_job_level
9415 -- , p_assignment_number => l_asgn_rec.assignment_number --
9416 , p_additional_information => l_asgn_rec.additional_information
9417 , p_location_id => l_asgn_rec.location_id
9418 , p_work_type_id => l_asgn_rec.work_type_id
9419 -- ,p_revenue_currency_code => l_asgn_rec.revenue_currency_code
9420 -- ,p_revenue_bill_rate => l_asgn_rec.revenue_bill_rate
9421 -- ,p_markup_percent => l_asgn_rec.markup_percent
9422 ,p_expense_owner => l_asgn_rec.expense_owner
9423 ,p_expense_limit => l_asgn_rec.expense_limit
9424 -- ,p_expense_limit_currency_code => l_asgn_rec.expense_limit_currency_code
9425 -- ,p_fcst_tp_amount_type => l_asgn_rec.fcst_tp_amount_type
9426 -- ,p_fcst_job_id => l_asgn_rec.fcst_job_id
9427 -- ,p_fcst_job_group_id => l_asgn_rec.fcst_job_group_id
9428 -- ,p_expenditure_org_id => l_asgn_rec.expenditure_org_id
9429 -- ,p_expenditure_organization_id => l_asgn_rec.expenditure_organization_id
9430 ,p_expenditure_type_class => l_asgn_rec.expenditure_type_class
9431 ,p_expenditure_type => l_asgn_rec.expenditure_type
9432 -- ,p_project_number =>
9433 -- ,p_resource_name =>
9434 -- ,p_resource_source_id =>
9435 ,p_resource_id => l_asgn_rec.resource_id
9436 ,p_project_subteam_name => l_asgn_rec.project_subteam_name
9437 ,p_staffing_priority_name => l_asgn_rec.staffing_priority_name
9438 -- ,p_project_role_name => l_asgn_rec.project_role_name
9439 ,p_location_city => l_asgn_rec.location_city
9440 ,p_location_region => l_asgn_rec.location_region
9441 -- ,p_location_country_name => l_asgn_rec.location_country_name
9442 ,p_location_country_code => l_asgn_rec.location_country_code
9443 ,p_calendar_name => l_asgn_rec.calendar_name
9444 ,p_calendar_id => l_asgn_rec.calendar_id
9445 ,p_work_type_name => l_asgn_rec.work_type_name
9446 -- ,p_fcst_job_name =>
9447 -- ,p_fcst_job_group_name
9448 -- ,p_expenditure_org_name
9449 -- ,p_exp_organization_name
9450 -- ,p_comp_match_weighting
9451 -- ,p_avail_match_weighting
9452 -- ,p_job_level_match_weighting
9453 -- ,p_search_min_availability
9454 -- ,p_search_country_code
9455 -- ,p_search_country_name
9456 -- ,p_search_exp_org_struct_ver_id
9457 -- ,p_search_exp_org_hier_name
9458 -- ,p_search_exp_start_org_id
9459 -- ,p_search_exp_start_org_name
9460 -- ,p_search_min_candidate_score
9461 -- ,p_enable_auto_cand_nom_flag
9462 ,p_bill_rate_override => l_asgn_rec.bill_rate_override
9463 ,p_bill_rate_curr_override => l_asgn_rec.bill_rate_curr_override
9464 ,p_markup_percent_override => l_asgn_rec.markup_percent_override
9465 ,p_discount_percentage => l_asgn_rec.discount_percentage
9466 ,p_rate_disc_reason_code => l_asgn_rec.rate_disc_reason_code
9467 ,p_tp_rate_override => l_asgn_rec.tp_rate_override
9468 ,p_tp_currency_override => l_asgn_rec.tp_currency_override
9469 ,p_tp_calc_base_code_override => l_asgn_rec.tp_calc_base_code_override
9470 ,p_tp_percent_applied_override => l_asgn_rec.tp_percent_applied_override
9471 ,p_staffing_owner_person_id => l_asgn_rec.staffing_owner_person_id
9472 -- ,p_staffing_owner_name =>
9473 -- ,p_resource_list_member_id
9474 ,p_attribute_category => l_asgn_rec.attribute_category
9475 ,p_attribute1 => l_asgn_rec.attribute1
9476 ,p_attribute2 => l_asgn_rec.attribute2
9477 ,p_attribute3 => l_asgn_rec.attribute3
9478 ,p_attribute4 => l_asgn_rec.attribute4
9479 ,p_attribute5 => l_asgn_rec.attribute5
9480 ,p_attribute6 => l_asgn_rec.attribute6
9481 ,p_attribute7 => l_asgn_rec.attribute7
9482 ,p_attribute8 => l_asgn_rec.attribute8
9483 ,p_attribute9 => l_asgn_rec.attribute9
9484 ,p_attribute10 => l_asgn_rec.attribute10
9485 ,p_attribute11 => l_asgn_rec.attribute11
9486 ,p_attribute12 => l_asgn_rec.attribute12
9487 ,p_attribute13 => l_asgn_rec.attribute13
9488 ,p_attribute14 => l_asgn_rec.attribute14
9489 ,p_attribute15 => l_asgn_rec.attribute15
9490 ,x_return_status => l_return_status
9491 ,x_msg_count => l_msg_count
9492 ,x_msg_data => l_msg_data
9493 );
9494 l_after_api_msg_count := FND_MSG_PUB.COUNT_MSG;
9495
9496 IF l_debug_mode = 'Y' THEN
9497 pa_debug.write(l_module, 'After call PA_ASSIGNMENTS_PUB.EXECUTE_UPDATE_ASSIGNMENT l_return_status='||l_return_status, l_log_level);
9498 END IF;
9499
9500 IF (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
9501 --l_error_flag := 'Y';
9502 l_error_flag_local := 'Y';
9503 ELSE
9504 IF l_debug_mode = 'Y' THEN
9505 pa_debug.write(l_module, 'Updating Original System Code and Reference', l_log_level);
9506 END IF;
9507
9508 --IF l_asgn_rec.orig_system_code IS NOT NULL OR l_asgn_rec.orig_system_reference IS NOT NULL THEN
9509 -- UPDATE PA_PROJECT_ASSIGNMENTS
9510 -- SET orig_system_code = decode(l_asgn_rec.orig_system_code, null, orig_system_code, l_asgn_rec.orig_system_code)
9511 -- , orig_system_reference = decode(l_asgn_rec.orig_system_reference, null, orig_system_reference, l_asgn_rec.orig_system_reference)
9512 -- WHERE assignment_id = l_asgn_rec.assignment_id;
9513 --END IF;
9514
9515 UPDATE PA_PROJECT_ASSIGNMENTS
9516 SET orig_system_code = l_asgn_rec.orig_system_code
9517 , orig_system_reference = l_asgn_rec.orig_system_reference
9518 WHERE assignment_id = l_asgn_rec.assignment_id;
9519
9520 IF l_debug_mode = 'Y' THEN
9521 pa_debug.write(l_module, 'After Updating Original System Code and Reference', l_log_level);
9522 END IF;
9523 END IF;
9524 END IF;
9525
9526 l_end_msg_count := FND_MSG_PUB.count_msg;
9527 IF l_debug_mode = 'Y' THEN
9528 pa_debug.write(l_module, 'l_start_msg_count='||l_start_msg_count, l_log_level);
9529 pa_debug.write(l_module, 'l_end_msg_count='||l_end_msg_count, l_log_level);
9530 END IF;
9531 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
9532
9533 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
9534 l_error_flag := 'Y';
9535
9536 IF l_debug_mode = 'Y' THEN
9537 pa_debug.write(l_module, 'Repopulating Error Message Stack', l_log_level);
9538 END IF;
9539
9540 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
9541 -- Always get from first location in stack i.e. l_start_msg_count+1
9542 -- Because stack moves down after delete
9543 FND_MSG_PUB.get (
9544 p_msg_index => l_start_msg_count+1,
9545 p_encoded => FND_API.G_FALSE,
9546 p_data => l_data,
9547 p_msg_index_out => l_msg_index_out );
9548
9549 -- Always delete at first location in stack i.e. l_start_msg_count+1
9550 -- Because stack moves down after delete
9551 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
9552
9553 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
9554 'RECORD_NO', i,
9555 'MESSAGE', l_data);
9556 END LOOP;
9557 IF l_debug_mode = 'Y' THEN
9558 pa_debug.write(l_module, 'After Repopulating Error Message Stack', l_log_level);
9559 END IF;
9560 END IF;
9561
9562 i := p_assignment_in_tbl.next(i);
9563
9564 END LOOP ;
9565
9566 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
9567 RAISE FND_API.G_EXC_ERROR;
9568 END IF;
9569
9570 IF l_debug_mode = 'Y' THEN
9571 PA_DEBUG.reset_curr_function;
9572 END IF;
9573
9574 IF p_commit = FND_API.G_TRUE THEN
9575 commit;
9576 END IF;
9577 EXCEPTION
9578 WHEN FND_API.G_EXC_ERROR THEN
9579 x_return_status := FND_API.G_RET_STS_ERROR;
9580 l_msg_count := FND_MSG_PUB.count_msg;
9581
9582 IF p_commit = FND_API.G_TRUE THEN
9583 ROLLBACK TO UPDATE_ASSIGNMENTS_SP;
9584 END IF;
9585
9586 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
9587 PA_INTERFACE_UTILS_PUB.get_messages
9588 ( p_encoded => FND_API.G_FALSE
9589 , p_msg_index => 1
9590 , p_msg_count => l_msg_count
9591 , p_msg_data => l_msg_data
9592 , p_data => l_data
9593 , p_msg_index_out => l_msg_index_out);
9594
9595 x_msg_data := l_data;
9596 x_msg_count := l_msg_count;
9597 ELSE
9598 x_msg_count := l_msg_count;
9599 END IF;
9600
9601 IF l_debug_mode = 'Y' THEN
9602 Pa_Debug.reset_curr_function;
9603 END IF;
9604
9605 WHEN OTHERS THEN
9606
9607 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
9608 x_msg_data := SUBSTRB(SQLERRM,1,240);
9609
9610 IF p_commit = FND_API.G_TRUE THEN
9611 ROLLBACK TO UPDATE_ASSIGNMENTS_SP;
9612 END IF;
9613
9614 FND_MSG_PUB.add_exc_msg
9615 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
9616 , p_procedure_name => 'UPDATE_ASSIGNMENTS'
9617 , p_error_text => x_msg_data);
9618
9619 x_msg_count := FND_MSG_PUB.count_msg;
9620
9621 IF l_debug_mode = 'Y' THEN
9622 PA_DEBUG.reset_curr_function;
9623 END IF;
9624 RAISE;
9625
9626 END UPDATE_ASSIGNMENTS ;
9627 -- Start of comments
9628 -- API name : DELETE_ASSIGNMENTS
9629 -- Type : Public
9630 -- Pre-reqs : None.
9631 -- Function : This is a public API to deletes one or more assignments for one or more projects.
9632 -- Usage : This API will be called from AMG.
9633 -- Parameters :
9634 -- IN : p_commit IN VARCHAR2
9635 -- Identifier to commit the transaction.
9636 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
9637 -- p_init_msg_list IN VARCHAR2
9638 -- Identifier to initialize the error message stack.
9639 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
9640 -- p_api_version_number IN NUMBER Required
9641 -- To be compliant with Applications API coding standards.
9642 -- p_assignment_in_tbl IN ASSIGNMENT_IN_TBL_TYPE Required
9643 -- Table of assignment records.
9644 --
9645 -- Please see the ASSIGNMENT_IN_TBL_TYPE datatype table.
9646 -- OUT : x_return_status OUT VARCHAR2
9647 -- Indicates the return status of the API.
9648 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
9649 -- x_msg_count OUT NUMBER
9650 -- Indicates the number of error messages in the message stack
9651 -- x_msg_data OUT VARCHAR2
9652 -- Indicates the error message text if only one error exists
9653 -- History :
9654 -- 01-Mar-2006 - vkadimes - Created
9655 -- End of comments
9656 PROCEDURE DELETE_ASSIGNMENTS (
9657 p_commit IN VARCHAR2 := 'F'
9658 , p_init_msg_list IN VARCHAR2 := 'T'
9659 , p_api_version_number IN NUMBER := 1.0
9660 , p_assignment_in_tbl IN ASSIGNMENT_IN_TBL_TYPE
9661 , x_return_status OUT NOCOPY VARCHAR2
9662 , x_msg_count OUT NOCOPY NUMBER
9663 , x_msg_data OUT NOCOPY VARCHAR2
9664 ) IS
9665 -- Debug Params
9666 l_debug_level NUMBER :=3;
9667 l_debug_mode VARCHAR2(1) :='N';
9668 l_module VARCHAR2(255) := 'PA_RES_MANAGEMENT_AMG_PUB.DELETE_ASSIGNMENTS';
9669 --Looping Params
9670 i NUMBER;
9671 -- pa_initialize calling params
9672 l_calling_application VARCHAR2(10) := 'PLSQL';
9673 l_calling_module VARCHAR2(10) := 'AMG';
9674 l_check_id_flag VARCHAR2(1) := 'Y';
9675 l_check_role_security_flag VARCHAR2(1) := 'Y';
9676 l_check_resource_security_flag VARCHAR2(1) := 'Y';
9677 --Loop Params
9678 l_req_rec PA_RES_MANAGEMENT_AMG_PUB.ASSIGNMENT_IN_REC_TYPE;
9679 l_loop_msg_count NUMBER :=0;
9680 l_start_msg_count NUMBER :=0;
9681 l_end_msg_count NUMBER :=0;
9682 l_missing_params VARCHAR2(1000);
9683 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
9684 l_ret_code VARCHAR2(1);
9685 -- Error Flags
9686 l_error_flag VARCHAR2(1) := 'N';
9687 l_error_flag_local VARCHAR2(1) := 'N';
9688
9689 l_assignment_type VARCHAR2(30);
9690 l_status_code VARCHAR2(30);
9691 l_project_id NUMBER;
9692 l_assignment_template_id NUMBER;
9693 l_system_status_code VARCHAR2(30);
9694 l_assignment_row_id ROWID;
9695 l_record_version_number NUMBER;
9696 -- security check
9697 l_privilege VARCHAR2(30);
9698 l_object_name VARCHAR2(30);
9699 l_object_key NUMBER;
9700 l_error_message_code VARCHAR2(30);
9701 l_assignment_number NUMBER;
9702 -- Temp prams
9703 l_commit VARCHAR2(1) := FND_API.G_FALSE;
9704 l_init_msg_list VARCHAR2(1) := FND_API.G_FALSE;
9705 l_validate_only VARCHAR2(1) := FND_API.G_FALSE;
9706 l_msg_count NUMBER;
9707 l_msg_data VARCHAR2(2000);
9708 l_assignment_id NUMBER;
9709 l_data VARCHAR2(2000);
9710 l_msg_index_out NUMBER;
9711 l_resource_id NUMBER;
9712 l_start_date DATE ;
9713 l_mass_wf_in_progress_flag VARCHAR2(1);
9714 l_apprvl_status_code VARCHAR2(30);
9715 l_apprvl_sys_status_code VARCHAR2(30);
9716
9717 CURSOR CUR_ASSIGNMENT_DETAILS(l_assignment_id NUMBER ) IS
9718 SELECT ROWID , assignment_type, status_code, project_id, record_version_number, assignment_number,
9719 resource_id, start_date, mass_wf_in_progress_flag, apprvl_status_code
9720 FROM pa_project_assignments
9721 WHERE assignment_id=l_assignment_id
9722 AND assignment_type <> 'OPEN_ASSIGNMENT' ;
9723
9724 CURSOR cur_get_system_status(l_status_code VARCHAR2 ) IS
9725 SELECT PROJECT_SYSTEM_STATUS_CODE
9726 FROM pa_project_statuses
9727 WHERE project_status_code = l_status_code ;
9728
9729 BEGIN
9730
9731 x_return_status := FND_API.G_RET_STS_SUCCESS;
9732
9733 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE', fnd_global.user_id, fnd_global.login_id, 275, null, null), 'N');
9734
9735 IF l_debug_mode = 'Y' THEN
9736 PA_DEBUG.set_curr_function(p_function => 'DELETE_ASSIGNMENTS', p_debug_mode => l_debug_mode);
9737 END IF;
9738
9739 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list, FND_API.G_TRUE)) THEN
9740 FND_MSG_PUB.initialize;
9741 END IF;
9742
9743 IF p_commit = FND_API.G_TRUE THEN
9744 savepoint DELETE_ASSIGNMENTS_SP;
9745 END IF;
9746
9747 IF l_debug_mode = 'Y' THEN
9748 pa_debug.write(l_module, 'Start of delete_assignments', l_debug_level);
9749 END IF;
9750
9751 IF l_debug_mode = 'Y' THEN
9752 pa_debug.write(l_module, 'Printing Input Parameters......', l_debug_level);
9753 i := p_assignment_in_tbl.first;
9754 WHILE i IS NOT NULL LOOP
9755 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').assignment_id'||p_assignment_in_tbl(i).assignment_id, l_debug_level);
9756 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').assignment_name'||p_assignment_in_tbl(i).assignment_name, l_debug_level);
9757 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').assignment_type'||p_assignment_in_tbl(i).assignment_type, l_debug_level);
9758 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_role_id'||p_assignment_in_tbl(i).project_role_id, l_debug_level);
9759 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_role_name'||p_assignment_in_tbl(i).project_role_name, l_debug_level);
9760 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_id'||p_assignment_in_tbl(i).project_id, l_debug_level);
9761 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_name'||p_assignment_in_tbl(i).project_name, l_debug_level);
9762 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_number'||p_assignment_in_tbl(i).project_number, l_debug_level);
9763 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').resource_id'||p_assignment_in_tbl(i).resource_id, l_debug_level);
9764 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').staffing_owner_person_id'||p_assignment_in_tbl(i).staffing_owner_person_id, l_debug_level);
9765 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').staffing_priority_code'||p_assignment_in_tbl(i).staffing_priority_code, l_debug_level);
9766 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').staffing_priority_name'||p_assignment_in_tbl(i).staffing_priority_name, l_debug_level);
9767 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_subteam_id'||p_assignment_in_tbl(i).project_subteam_id, l_debug_level);
9768 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').project_subteam_name'||p_assignment_in_tbl(i).project_subteam_name, l_debug_level);
9769 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_id'||p_assignment_in_tbl(i).location_id, l_debug_level);
9770 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_country_code'||p_assignment_in_tbl(i).location_country_code, l_debug_level);
9771 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_country_name'||p_assignment_in_tbl(i).location_country_name, l_debug_level);
9772 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_region'||p_assignment_in_tbl(i).location_region, l_debug_level);
9773 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').location_city'||p_assignment_in_tbl(i).location_city, l_debug_level);
9774 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').description'||p_assignment_in_tbl(i).description, l_debug_level);
9775 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').additional_information'||p_assignment_in_tbl(i).additional_information, l_debug_level);
9776 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').start_date'||p_assignment_in_tbl(i).start_date, l_debug_level);
9777 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').end_date'||p_assignment_in_tbl(i).end_date, l_debug_level);
9778 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').status_code'||p_assignment_in_tbl(i).status_code, l_debug_level);
9779 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').status_name'||p_assignment_in_tbl(i).status_name, l_debug_level);
9780 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').calendar_type'||p_assignment_in_tbl(i).calendar_type, l_debug_level);
9781 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').calendar_id'||p_assignment_in_tbl(i).calendar_id, l_debug_level);
9782 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').calendar_name'||p_assignment_in_tbl(i).calendar_name, l_debug_level);
9783 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').resource_calendar_percent'||p_assignment_in_tbl(i).resource_calendar_percent, l_debug_level);
9784 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').expenditure_type_class'||p_assignment_in_tbl(i).expenditure_type_class, l_debug_level);
9785 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').expenditure_type'||p_assignment_in_tbl(i).expenditure_type, l_debug_level);
9786 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').work_type_id'||p_assignment_in_tbl(i).work_type_id, l_debug_level);
9787 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').work_type_name'||p_assignment_in_tbl(i).work_type_name, l_debug_level);
9788 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').bill_rate_option'||p_assignment_in_tbl(i).bill_rate_option, l_debug_level);
9789 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').bill_rate_override'||p_assignment_in_tbl(i).bill_rate_override, l_debug_level);
9790 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').bill_rate_curr_override'||p_assignment_in_tbl(i).bill_rate_curr_override, l_debug_level);
9791 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').markup_percent_override'||p_assignment_in_tbl(i).markup_percent_override, l_debug_level);
9792 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').discount_percentage'||p_assignment_in_tbl(i).discount_percentage, l_debug_level);
9793 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').rate_disc_reason_code'||p_assignment_in_tbl(i).rate_disc_reason_code, l_debug_level);
9794 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_rate_option'||p_assignment_in_tbl(i).tp_rate_option, l_debug_level);
9795 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_rate_override'||p_assignment_in_tbl(i).tp_rate_override, l_debug_level);
9796 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_currency_override'||p_assignment_in_tbl(i).tp_currency_override, l_debug_level);
9797 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_calc_base_code_override'||p_assignment_in_tbl(i).tp_calc_base_code_override, l_debug_level);
9798 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').tp_percent_applied_override'||p_assignment_in_tbl(i).tp_percent_applied_override, l_debug_level);
9799 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').extension_possible'||p_assignment_in_tbl(i).extension_possible, l_debug_level);
9800 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').expense_owner'||p_assignment_in_tbl(i).expense_owner, l_debug_level);
9801 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').expense_limit'||p_assignment_in_tbl(i).expense_limit, l_debug_level);
9802 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').orig_system_code'||p_assignment_in_tbl(i).orig_system_code, l_debug_level);
9803 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').orig_system_reference'||p_assignment_in_tbl(i).orig_system_reference, l_debug_level);
9804 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').record_version_number'||p_assignment_in_tbl(i).record_version_number, l_debug_level);
9805 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute_category'||p_assignment_in_tbl(i).attribute_category, l_debug_level);
9806 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute1'||p_assignment_in_tbl(i).attribute1, l_debug_level);
9807 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute2'||p_assignment_in_tbl(i).attribute2, l_debug_level);
9808 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute3'||p_assignment_in_tbl(i).attribute3, l_debug_level);
9809 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute4'||p_assignment_in_tbl(i).attribute4, l_debug_level);
9810 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute5'||p_assignment_in_tbl(i).attribute5, l_debug_level);
9811 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute6'||p_assignment_in_tbl(i).attribute6, l_debug_level);
9812 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute7'||p_assignment_in_tbl(i).attribute7, l_debug_level);
9813 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute8'||p_assignment_in_tbl(i).attribute8, l_debug_level);
9814 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute9'||p_assignment_in_tbl(i).attribute9, l_debug_level);
9815 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute10'||p_assignment_in_tbl(i).attribute10, l_debug_level);
9816 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute11'||p_assignment_in_tbl(i).attribute11, l_debug_level);
9817 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute12'||p_assignment_in_tbl(i).attribute12, l_debug_level);
9818 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute13'||p_assignment_in_tbl(i).attribute13, l_debug_level);
9819 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute14'||p_assignment_in_tbl(i).attribute14, l_debug_level);
9820 pa_debug.write(l_module, 'p_assignment_in_tbl('||i||').attribute15'||p_assignment_in_tbl(i).attribute15, l_debug_level);
9821 pa_debug.write(l_module, '------------------------------------------------------------------', l_debug_level);
9822 i := p_assignment_in_tbl.next(i);
9823 END LOOP;
9824 END IF;
9825
9826 PA_STARTUP.INITIALIZE(
9827 p_calling_application => l_calling_application
9828 , p_calling_module => l_calling_module
9829 , p_check_id_flag => l_check_id_flag
9830 , p_check_role_security_flag => l_check_role_security_flag
9831 , p_check_resource_security_flag => l_check_resource_security_flag
9832 , p_debug_level => l_debug_level
9833 );
9834
9835 IF l_debug_mode = 'Y' THEN
9836 pa_debug.write(l_module, 'After call of pa_startup.initialize', l_debug_level);
9837 END IF;
9838
9839 i := p_assignment_in_tbl.first;
9840
9841 WHILE i IS NOT NULL LOOP
9842
9843 l_error_flag_local := 'N';
9844 l_missing_params := null;
9845 l_req_rec := null;
9846
9847 l_start_msg_count := FND_MSG_PUB.count_msg;
9848
9849 l_req_rec := p_assignment_in_tbl(i);
9850
9851 IF l_debug_mode = 'Y' THEN
9852 pa_debug.write(l_module, 'Record#'||i, l_debug_level);
9853 pa_debug.write(l_module, '-----------------------------', l_debug_level);
9854 pa_debug.write(l_module, 'NullOut parameters which are not required.', l_debug_level);
9855 END IF;
9856
9857 -- Blank Out Required Parameters if not passed.
9858 IF l_req_rec.assignment_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
9859 l_req_rec.assignment_id := NULL ;
9860 END IF;
9861
9862 IF l_req_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
9863 l_req_rec.record_version_number := NULL ;
9864 END IF;
9865
9866 IF l_debug_mode = 'Y' THEN
9867 pa_debug.write(l_module, 'Requirement_id is ' || l_req_rec.assignment_id,l_debug_level);
9868 pa_debug.write(l_module, 'Record Version Number is ' || l_req_rec.record_version_number, l_debug_level);
9869 END IF;
9870
9871 -- Mandatory Parameters Check
9872 IF l_debug_mode = 'Y' THEN
9873 pa_debug.write(l_module, 'Mandatory Parameter Validation Starts', l_debug_level);
9874 END IF;
9875
9876 IF l_req_rec.assignment_id IS NULL THEN
9877 l_missing_params := l_missing_params ||',ASSIGNMENT_ID';
9878 END IF;
9879
9880 IF l_debug_mode = 'Y' THEN
9881 pa_debug.write(l_module, 'Mandatory Parameter Validation Over. ',l_debug_level);
9882 pa_debug.write(l_module, 'The missing parameters are '||l_missing_params, l_debug_level);
9883 END IF;
9884
9885 IF l_missing_params IS NOT NULL THEN
9886 l_error_flag_local := 'Y';
9887 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
9888 'INVALID_PARAMS', l_missing_params);
9889 END IF;
9890
9891 l_assignment_id := l_req_rec.assignment_id;
9892 IF l_error_flag_local <> 'Y' THEN
9893
9894 OPEN CUR_ASSIGNMENT_DETAILS(l_assignment_id) ;
9895 FETCH CUR_ASSIGNMENT_DETAILS INTO l_assignment_row_id, l_assignment_type, l_status_code, l_project_id,l_record_version_number, l_assignment_number, l_resource_id, l_start_date,l_mass_wf_in_progress_flag, l_apprvl_status_code;
9896
9897 IF CUR_ASSIGNMENT_DETAILS%NOTFOUND THEN
9898 l_error_flag_local := 'Y';
9899 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
9900 'INVALID_PARAMS', 'ASSIGNMENT_ID');
9901 END IF;
9902
9903 CLOSE CUR_ASSIGNMENT_DETAILS;
9904
9905 END IF ;
9906
9907 IF l_error_flag_local <> 'Y' THEN
9908 l_system_status_code := null;
9909 OPEN cur_get_system_status(l_status_code);
9910 FETCH cur_get_system_status INTO l_system_status_code ;
9911 CLOSE cur_get_system_status;
9912
9913 OPEN cur_get_system_status(l_apprvl_status_code);
9914 FETCH cur_get_system_status INTO l_apprvl_sys_status_code;
9915 CLOSE cur_get_system_status;
9916 END IF;
9917
9918 IF l_system_status_code = 'STAFFED_ASGMT_CANCEL'
9919 OR l_apprvl_sys_status_code IN ('ASGMT_APPRVL_SUBMITTED','ASGMT_APPRVL_CANCELED')
9920 OR NVL(l_mass_wf_in_progress_flag,'N') = 'Y' THEN
9921 --- Need more specific Generic Message.
9922 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_STS_ACT_NOT_ALLW');
9923 l_error_flag_local := 'Y';
9924 END IF;
9925
9926 IF l_error_flag_local <> 'Y' THEN
9927
9928 IF l_debug_mode = 'Y' THEN
9929 pa_debug.write(l_module, 'Security check starts', l_debug_level);
9930 END IF;
9931
9932 IF l_project_id IS NOT NULL THEN
9933 IF l_assignment_type = 'STAFFED_ASSIGNMENT' THEN
9934
9935 l_privilege := 'PA_ASN_CR_AND_DL';
9936 l_object_name := 'PA_PROJECTS';
9937 l_object_key := l_project_id ;
9938
9939 l_return_status := FND_API.G_RET_STS_SUCCESS;
9940 l_ret_code := 'T';
9941
9942 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
9943 x_ret_code => l_ret_code
9944 , x_return_status => l_return_status
9945 , x_msg_count => l_msg_count
9946 , x_msg_data => l_msg_data
9947 , p_privilege => l_privilege
9948 , p_object_name => l_object_name
9949 , p_object_key => l_object_key
9950 , p_init_msg_list => FND_API.G_FALSE);
9951
9952 ELSIF l_assignment_type = 'STAFFED_ADMIN_ASSIGNMENT' THEN
9953
9954 l_return_status := FND_API.G_RET_STS_SUCCESS;
9955 l_ret_code := 'T';
9956
9957 PA_SECURITY_PVT.CHECK_CONFIRM_ASMT(
9958 p_project_id => l_project_id
9959 , p_resource_id => l_resource_id
9960 , p_resource_name => null
9961 , p_privilege => 'PA_ADM_ASN_CONFIRM'
9962 , p_start_date => l_start_date
9963 , x_ret_code => l_ret_code
9964 , x_return_status => l_return_status
9965 , x_msg_count => l_msg_count
9966 , x_msg_data => l_msg_data
9967 , p_init_msg_list => FND_API.G_FALSE);
9968 END IF;
9969 ELSE
9970 PA_UTILS.ADD_MESSAGE('PA', 'PA_UNEXPECTED ERROR');
9971 raise FND_API.G_EXC_ERROR;
9972 END IF;
9973
9974 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
9975 -- This message does not have token defined, but intentionally putting token
9976 -- because we still want to show the privilege name which is missing
9977 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_CR_DL'
9978 ,'MISSING_PRIVILEGE', l_privilege);
9979 l_error_flag_local := 'Y';
9980 END IF;
9981 END IF;
9982
9983 IF l_error_flag_local <> 'Y' THEN
9984
9985 l_return_status := FND_API.G_RET_STS_SUCCESS;
9986
9987 IF l_debug_mode = 'Y' THEN
9988 pa_debug.write(l_module, 'Calling PA_ASSIGNMENTS_PUB.DELETE_ASSIGNMENT for record number'||i, l_debug_level);
9989 END IF;
9990
9991 PA_ASSIGNMENTS_PUB.DELETE_ASSIGNMENT (
9992 p_assignment_row_id => l_assignment_row_id
9993 , p_assignment_id => l_assignment_id
9994 , p_record_version_number => l_record_version_number
9995 , p_assignment_type => l_assignment_type
9996 , p_assignment_number => l_assignment_number
9997 , p_commit => l_commit
9998 , p_validate_only => l_validate_only
9999 , x_return_status => l_return_status
10000 , x_msg_count => l_msg_count
10001 , x_msg_data => l_msg_data );
10002
10003 IF l_debug_mode = 'Y' THEN
10004 pa_debug.write(l_module, 'After call PA_ASSIGNMENTS_PUB.DELETE_ASSIGNMENT l_return_status='||l_return_status, l_debug_level);
10005 END IF;
10006
10007 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
10008 l_error_flag_local := 'Y';
10009 END IF;
10010 END IF;
10011
10012 l_end_msg_count := FND_MSG_PUB.count_msg;
10013 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
10014
10015 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
10016 l_error_flag := 'Y';
10017
10018 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
10019 -- Always get from first location in stack i.e. l_start_msg_count+1
10020 -- Because stack moves down after delete
10021 FND_MSG_PUB.get (
10022 p_msg_index => l_start_msg_count+1
10023 , p_encoded => FND_API.G_FALSE
10024 , p_data => l_data
10025 , p_msg_index_out => l_msg_index_out );
10026
10027 -- Always delete at first location in stack i.e. l_start_msg_count+1
10028 -- Because stack moves down after delete
10029 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
10030
10031 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
10032 'RECORD_NO', i,
10033 'MESSAGE', l_data);
10034 END LOOP;
10035 END IF;
10036 i := p_assignment_in_tbl.next(i);
10037 END LOOP;
10038
10039 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
10040 RAISE FND_API.G_EXC_ERROR;
10041 END IF;
10042
10043 IF l_debug_mode = 'Y' THEN
10044 PA_DEBUG.reset_curr_function;
10045 END IF;
10046
10047 IF p_commit = FND_API.G_TRUE THEN
10048 commit;
10049 END IF;
10050
10051 EXCEPTION
10052 WHEN FND_API.G_EXC_ERROR THEN
10053 x_return_status := FND_API.G_RET_STS_ERROR;
10054 l_msg_count := FND_MSG_PUB.count_msg;
10055
10056 IF p_commit = FND_API.G_TRUE THEN
10057 ROLLBACK TO DELETE_ASSIGNMENTS_SP;
10058 END IF;
10059
10060 IF cur_assignment_details%ISOPEN THEN
10061 CLOSE cur_assignment_details ;
10062 END IF;
10063
10064 IF cur_get_system_status%ISOPEN THEN
10065 CLOSE cur_get_system_status ;
10066 END IF;
10067
10068 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
10069 PA_INTERFACE_UTILS_PUB.GET_MESSAGES (
10070 p_encoded => FND_API.G_FALSE
10071 , p_msg_index => 1
10072 , p_msg_count => l_msg_count
10073 , p_msg_data => l_msg_data
10074 , p_data => l_data
10075 , p_msg_index_out => l_msg_index_out);
10076
10077 x_msg_data := l_data;
10078 x_msg_count := l_msg_count;
10079 ELSE
10080 x_msg_count := l_msg_count;
10081 END IF;
10082
10083 IF l_debug_mode = 'Y' THEN
10084 Pa_Debug.reset_curr_function;
10085 END IF;
10086
10087 WHEN OTHERS THEN
10088
10089 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10090 x_msg_data := SUBSTRB(SQLERRM,1,240);
10091
10092 IF p_commit = FND_API.G_TRUE THEN
10093 ROLLBACK TO DELETE_ASSIGNMENTS_SP;
10094 END IF;
10095
10096 IF cur_assignment_details%ISOPEN THEN
10097 CLOSE cur_assignment_details ;
10098 END IF;
10099
10100 IF cur_get_system_status%ISOPEN THEN
10101 CLOSE cur_get_system_status ;
10102 END IF;
10103
10104 FND_MSG_PUB.add_exc_msg (
10105 p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
10106 , p_procedure_name => 'DELETE_REQUIREMENTS'
10107 , p_error_text => x_msg_data);
10108
10109 x_msg_count := FND_MSG_PUB.count_msg;
10110
10111 IF l_debug_mode = 'Y' THEN
10112 PA_DEBUG.reset_curr_function;
10113 END IF;
10114 RAISE;
10115
10116 END DELETE_ASSIGNMENTS;
10117
10118
10119 -- Start of comments
10120 -- API name : SUBMIT_ASSIGNMENTS
10121 -- Type : Public
10122 -- Pre-reqs : None.
10123 -- Function : This is a public API to submit/approve one or more assignments for one or more projects.
10124 -- Usage : This API will be called from AMG.
10125 -- Parameters :
10126 -- IN : p_commit IN VARCHAR2
10127 -- Identifier to commit the transaction.
10128 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
10129 -- p_init_msg_list IN VARCHAR2
10130 -- Identifier to initialize the error message stack.
10131 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
10132 -- p_api_version_number IN NUMBER Required
10133 -- To be compliant with Applications API coding standards.
10134 -- p_submit_assignment_id_tbl IN SUBMIT_ASSIGNMENT_IN_TBL_TYPE Required
10135 -- Table of assignment records. Please see the SUBMIT_ASSIGNMENT_IN_TBL_TYPE
10136 -- datatype table.
10137 -- OUT :
10138 -- x_return_status OUT VARCHAR2
10139 -- Indicates the return status of the API.
10140 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
10141 -- x_msg_count OUT NUMBER
10142 -- Indicates the number of error messages in the message stack
10143 -- x_msg_data OUT VARCHAR2
10144 -- Indicates the error message text if only one error exists
10145 -- History :
10146 --
10147 -- 15-Mar-2006 - avaithia - Created
10148 -- End of comments
10149
10150 PROCEDURE SUBMIT_ASSIGNMENTS
10151 (
10152 p_api_version_number IN NUMBER := 1.0
10153 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
10154 , p_commit IN VARCHAR2 := FND_API.G_FALSE
10155 , p_submit_assignment_in_tbl IN SUBMIT_ASSIGNMENT_IN_TBL_TYPE
10156 , x_return_status OUT NOCOPY VARCHAR2
10157 , x_msg_count OUT NOCOPY NUMBER
10158 , x_msg_data OUT NOCOPY VARCHAR2
10159 )
10160 IS
10161 l_calling_application VARCHAR2(10) := 'PLSQL';
10162 l_calling_module VARCHAR2(10) := 'AMG';
10163 l_check_id_flag VARCHAR2(1) := 'Y';
10164 l_check_role_security_flag VARCHAR2(1) := 'Y';
10165 l_check_resource_security_flag VARCHAR2(1) := 'Y';
10166
10167 l_log_level NUMBER := 3;
10168 l_module VARCHAR2(100) := 'PA_RES_MANAGEMENT_AMG_PUB.SUBMIT_ASSIGNMENTS';
10169 l_commit VARCHAR2(1) := FND_API.G_FALSE;
10170 l_init_msg_list VARCHAR2(1) := FND_API.G_FALSE;
10171
10172 l_msg_count NUMBER;
10173 l_msg_data VARCHAR2(2000);
10174 l_msg_index_out NUMBER;
10175 l_data VARCHAR2(2000);
10176 l_debug_mode VARCHAR2(1);
10177
10178 i NUMBER;
10179
10180 l_asgn_rec SUBMIT_ASSIGNMENT_IN_REC_TYPE;
10181 l_assignment_id NUMBER;
10182 l_auto_approve VARCHAR2(1) := 'N';
10183 l_apr_person_id_1 NUMBER;
10184 l_apr_person_id_2 NUMBER;
10185 l_note_to_approver VARCHAR2(240);
10186 l_record_version_number NUMBER;
10187
10188 l_project_id NUMBER;
10189 l_resource_id NUMBER;
10190 l_start_date DATE;
10191 l_assignment_type VARCHAR2(30);
10192
10193 l_mass_wf_in_progress_flag VARCHAR2(1);
10194 l_apprvl_status_code VARCHAR2(30);
10195 l_apprvl_sys_status_code VARCHAR2(30);
10196
10197 l_out_new_assignment_flag VARCHAR2(1) ;
10198 l_out_approval_required_flag VARCHAR2(1) ;
10199 l_out_record_version_number NUMBER;
10200
10201 l_validate_only VARCHAR2(1) := FND_API.G_FALSE;
10202 l_overcommitment_flag VARCHAR2(1);
10203 l_conflict_group_id NUMBER;
10204
10205 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
10206 l_error_flag VARCHAR2(1) := 'N';
10207 l_error_flag_local VARCHAR2(1) := 'N';
10208
10209 l_loop_msg_count NUMBER :=0;
10210 l_start_msg_count NUMBER :=0;
10211 l_end_msg_count NUMBER :=0;
10212
10213 l_missing_params VARCHAR2(1000);
10214 l_privilege VARCHAR2(30);
10215 l_object_name VARCHAR2(30);
10216 l_object_key NUMBER;
10217 l_error_message_code VARCHAR2(30);
10218 l_ret_code VARCHAR2(1) := FND_API.G_TRUE;
10219
10220 l_before_api_msg_count NUMBER;
10221 l_after_api_msg_count NUMBER;
10222
10223 l_full_name_apr1 VARCHAR2(240);
10224 l_sys_person_type_apr1 VARCHAR2(30);
10225 l_user_person_type_apr1 VARCHAR2(80);
10226
10227 l_full_name_apr2 VARCHAR2(240);
10228 l_sys_person_type_apr2 VARCHAR2(30);
10229 l_user_person_type_apr2 VARCHAR2(80);
10230
10231 l_valid VARCHAR2(1); -- Bug 5175869
10232
10233 CURSOR c_valid_asgn_id(p_assignment_id IN NUMBER) IS
10234 SELECT project_id , resource_id,start_date,assignment_type,mass_wf_in_progress_flag ,apprvl_status_code,record_version_number
10235 FROM pa_project_assignments
10236 WHERE assignment_type <> 'OPEN_ASSIGNMENT'
10237 AND assignment_id = p_assignment_id ;
10238
10239 CURSOR get_person_type(p_person_id IN NUMBER) IS
10240 SELECT per.full_name, ppt.SYSTEM_PERSON_TYPE , ppt.USER_PERSON_TYPE
10241 FROM per_all_people_f per , per_person_types ppt
10242 where per.person_type_id = ppt.person_type_id
10243 AND per.person_id = p_person_id
10244 AND per.effective_end_date = (SELECT MAX(pf.effective_end_date)
10245 FROM per_all_people_f pf
10246 WHERE pf.person_id = p_person_id);
10247
10248 CURSOR c_sys_status_code(l_in_status_code IN VARCHAR2 ) IS
10249 SELECT project_system_status_code
10250 FROM pa_project_statuses
10251 WHERE project_status_code = l_in_status_code
10252 AND status_type= 'ASGMT_APPRVL';
10253
10254 BEGIN
10255 --------------------------------------------------
10256 -- RESET OUT params
10257 --------------------------------------------------
10258 x_return_status := FND_API.G_RET_STS_SUCCESS;
10259 x_msg_count := 0;
10260 x_msg_data := NULL ;
10261
10262 --------------------------------------------------
10263 -- Initialize Current Function and Msg Stack
10264 --------------------------------------------------
10265 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE',fnd_global.user_id,fnd_global.login_id,275,null,null), 'N');
10266
10267 IF l_debug_mode = 'Y' THEN
10268 PA_DEBUG.set_curr_function(p_function => 'SUBMIT_ASSIGNMENTS', p_debug_mode => l_debug_mode);
10269 END IF;
10270
10271 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
10272 FND_MSG_PUB.initialize;
10273 END IF;
10274 --------------------------------------------------
10275 -- Create Savepoint
10276 --------------------------------------------------
10277 IF p_commit = FND_API.G_TRUE THEN
10278 savepoint SUBMIT_ASSIGNMENTS_SP;
10279 END IF;
10280
10281 IF l_debug_mode = 'Y' THEN
10282 pa_debug.write(l_module, 'Start of SUBMIT_ASSIGNMENTS', l_log_level);
10283 END IF;
10284 --------------------------------------------------
10285 -- Start Initialize
10286 --------------------------------------------------
10287 PA_STARTUP.INITIALIZE(
10288 p_calling_application => l_calling_application
10289 , p_calling_module => l_calling_module
10290 , p_check_id_flag => l_check_id_flag
10291 , p_check_role_security_flag => l_check_role_security_flag
10292 , p_check_resource_security_flag => l_check_resource_security_flag
10293 , p_debug_level => l_log_level
10294 );
10295
10296 IF l_debug_mode = 'Y' THEN
10297 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
10298 END IF;
10299 --------------------------------------------------
10300 -- Defaulting Values and Mandatory param validations
10301 -- Security Check
10302 -- Core Logic
10303 --------------------------------------------------
10304 i := p_submit_assignment_in_tbl.first;
10305 WHILE i is not NULL LOOP
10306 l_error_flag_local := 'N';
10307 l_missing_params := null;
10308 l_asgn_rec := NULL ;
10309
10310 l_start_msg_count := FND_MSG_PUB.count_msg;
10311
10312 l_asgn_rec := p_submit_assignment_in_tbl(i);
10313
10314 -- Blank Out Parameters if not passed.
10315
10316 IF l_asgn_rec.assignment_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
10317 l_asgn_rec.assignment_id := NULL ;
10318 END IF;
10319
10320 IF l_asgn_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
10321 l_asgn_rec.record_version_number := NULL ;
10322 END IF;
10323
10324 IF l_asgn_rec.auto_approve = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
10325 l_asgn_rec.auto_approve := NULL ;
10326 END IF;
10327
10328 IF l_asgn_rec.apr_person_id_1 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
10329 l_asgn_rec.apr_person_id_1 := NULL ;
10330 END IF;
10331
10332 IF l_asgn_rec.apr_person_id_2 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
10333 l_asgn_rec.apr_person_id_2 := NULL ;
10334 END IF;
10335
10336 IF l_asgn_rec.note_to_approver = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
10337 l_asgn_rec.note_to_approver := NULL ;
10338 END IF;
10339
10340 l_assignment_id := l_asgn_rec.assignment_id ;
10341 l_record_version_number := l_asgn_rec.record_version_number ;
10342 l_auto_approve := l_asgn_rec.auto_approve;
10343 l_apr_person_id_1 := l_asgn_rec.apr_person_id_1 ;
10344 l_apr_person_id_2 := l_asgn_rec.apr_person_id_2 ;
10345 l_note_to_approver := l_asgn_rec.note_to_approver ;
10346
10347 IF l_debug_mode = 'Y' THEN
10348 pa_debug.write(l_module, 'Assignment Id ' || l_assignment_id,l_log_level);
10349 pa_debug.write(l_module, 'Record Version Number is ' ||l_record_version_number,l_log_level);
10350 pa_debug.write(l_module, 'Auto Approve is ' ||l_auto_approve,l_log_level);
10351 pa_debug.write(l_module, 'Approve Person Id 1 is ' || l_apr_person_id_1,l_log_level);
10352 pa_debug.write(l_module, 'Approve Person Id 2 is ' || l_apr_person_id_2,l_log_level);
10353 pa_debug.write(l_module, 'Note to Approver is ' || l_note_to_approver,l_log_level);
10354 END IF;
10355
10356 -- Mandatory Parameters Check
10357 IF l_debug_mode = 'Y' THEN
10358 pa_debug.write(l_module, 'Mandatory Parameter Validation Starts', l_log_level);
10359 END IF;
10360
10361 IF l_asgn_rec.assignment_id IS NULL THEN
10362 l_missing_params := l_missing_params||'ASSIGNMENT_ID ' ;
10363 END IF;
10364
10365 IF l_asgn_rec.record_version_number IS NULL THEN
10366 l_missing_params := l_missing_params||', RECORD_VERSION_NUMBER ' ;
10367 END IF;
10368
10369 IF l_asgn_rec.auto_approve IS NULL THEN
10370 l_missing_params := l_missing_params||', AUTO_APPROVE ' ;
10371 END IF;
10372
10373 IF l_debug_mode = 'Y' THEN
10374 pa_debug.write(l_module, 'Mandatory Parameter Validation Over. ',l_log_level);
10375 pa_debug.write(l_module, 'The missing parameters are '||l_missing_params, l_log_level);
10376 END IF;
10377
10378 IF l_missing_params IS NOT NULL THEN
10379 l_error_flag_local := 'Y';
10380 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
10381 'INVALID_PARAMS', l_missing_params);
10382 END IF;
10383
10384 IF l_error_flag_local <> 'Y' THEN --------- (1)
10385 l_assignment_id := l_asgn_rec.assignment_id ;
10386
10387 -- Validate whether the passed id is a valid one
10388 OPEN c_valid_asgn_id(l_assignment_id) ;
10389 FETCH c_valid_asgn_id into l_project_id ,l_resource_id,l_start_date,l_assignment_type,l_mass_wf_in_progress_flag ,l_apprvl_status_code,l_record_version_number;
10390 IF c_valid_asgn_id%NOTFOUND THEN
10391 l_missing_params := l_missing_params||' ,ASSIGNMENT_ID' ;
10392 l_error_flag_local := 'Y';
10393 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
10394 'INVALID_PARAMS', l_missing_params);
10395 ELSE -- The passed Id is a valid assignment
10396
10397 IF nvl(l_mass_wf_in_progress_flag,'N') = 'Y' THEN
10398 PA_UTILS.ADD_MESSAGE('PA', 'PA_ASSIGNMENT_WF');
10399 l_error_flag_local := 'Y';
10400 END IF;
10401
10402 OPEN c_sys_status_code(l_apprvl_status_code);
10403 FETCH c_sys_status_code INTO l_apprvl_sys_status_code ;
10404 CLOSE c_sys_status_code ;
10405
10406 IF l_apprvl_sys_status_code in ('ASGMT_APPRVL_CANCELED','ASGMT_APPRVL_SUBMITTED','ASGMT_APPRVL_APPROVED')
10407 THEN
10408 -- We can submit only if the approval status is Working or Requires resubmission
10409 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_STS_ACT_NOT_ALLW');
10410 l_error_flag_local := 'Y'; -- Modify above new err msg for Approved also
10411 END IF;
10412 END IF;
10413 CLOSE c_valid_asgn_id ;
10414
10415 -- Validate the flag value passed for Auto Approve
10416 IF l_asgn_rec.auto_approve not in ('Y','N') THEN
10417 l_error_flag_local := 'Y';
10418 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS','INVALID_PARAMS','AUTO_APPROVE');
10419 END IF;
10420 --------------------------------------------------------
10421 -- Derive x_new_assignment_flag and x_approval_required
10422 --------------------------------------------------------
10423
10424 IF l_error_flag_local <> 'Y' THEN
10425
10426 IF l_debug_mode = 'Y' THEN
10427 pa_debug.write(l_module, 'Before Calling PA_ASSIGNMENT_APPROVAL_PUB.Populate_Changed_Items_Table for record number '||i, l_log_level);
10428 END IF;
10429
10430 l_before_api_msg_count := FND_MSG_PUB.count_msg;
10431 PA_ASSIGNMENT_APPROVAL_PUB.Populate_Changed_Items_Table
10432 (
10433 p_assignment_id => l_assignment_id
10434 ,x_new_assignment_flag => l_out_new_assignment_flag
10435 ,x_approval_required_flag => l_out_approval_required_flag
10436 ,x_record_version_number => l_out_record_version_number
10437 ,x_return_status => l_return_status
10438 ,x_msg_count => l_msg_count
10439 ,x_msg_data => l_msg_data
10440 );
10441
10442 l_after_api_msg_count := FND_MSG_PUB.count_msg;
10443 -- Dont rely on l_return_status as inside above API
10444 -- IF no of msgs in stack is > 0 ,they set it as error
10445 -- So, Just rely on (l_after_api_msg_count - l_before_api_msg_count) value
10446
10447 IF (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
10448 l_error_flag_local := 'Y';
10449 -- PA_UTILS.ADD_MESSAGE('PA', 'PA_UNEXPECTED ERROR');
10450 END IF;
10451
10452 END IF;
10453 ------------------------------------------------------------------
10454 -- If Populate_Changed_Items_Table is successful ,proceed further
10455 ------------------------------------------------------------------
10456 IF l_error_flag_local <> 'Y' THEN --------- (2)
10457
10458 IF l_debug_mode = 'Y' THEN
10459 pa_debug.write(l_module, 'Populate_Changed_Items_Table is successful',l_log_level)
10460 ;
10461 END IF;
10462
10463 IF l_auto_approve = 'Y' THEN
10464 -- Check for resource authority
10465 IF l_assignment_type = 'STAFFED_ASSIGNMENT' THEN
10466
10467 IF l_debug_mode = 'Y' THEN
10468 pa_debug.write(l_module, 'Checking for PA_ASN_CONFIRM privilege',l_log_level);
10469 END IF;
10470
10471 pa_security_pvt.check_confirm_asmt
10472 (p_project_id => l_project_id
10473 ,p_resource_id => l_resource_id
10474 ,p_resource_name => null
10475 ,p_privilege => 'PA_ASN_CONFIRM'
10476 ,p_start_date => l_start_date
10477 ,p_init_msg_list => 'F'
10478 ,x_ret_code => l_ret_code
10479 ,x_return_status => l_return_status
10480 ,x_msg_count => l_msg_count
10481 ,x_msg_data => l_msg_data
10482 );
10483 ELSIF l_assignment_type = 'STAFFED_ADMIN_ASSIGNMENT' THEN
10484
10485 IF l_debug_mode = 'Y' THEN
10486 pa_debug.write(l_module, 'Checking for PA_ADM_ASN_CONFIRM privilege',l_log_level);
10487 END IF;
10488
10489 pa_security_pvt.check_confirm_asmt
10490 (p_project_id => l_project_id
10491 ,p_resource_id => l_resource_id
10492 ,p_resource_name => null
10493 ,p_privilege => 'PA_ADM_ASN_CONFIRM'
10494 ,p_start_date => l_start_date
10495 ,p_init_msg_list => 'F'
10496 ,x_ret_code => l_ret_code
10497 ,x_return_status => l_return_status
10498 ,x_msg_count => l_msg_count
10499 ,x_msg_data => l_msg_data
10500 );
10501 END IF;
10502
10503 IF l_ret_code = FND_API.G_FALSE AND l_out_approval_required_flag = 'N' THEN
10504
10505 IF l_debug_mode = 'Y' THEN
10506 pa_debug.write(l_module, 'Populating PA_ASGN_CONFIRM_NOT_ALLOWED',l_log_level);
10507 END IF;
10508
10509 l_error_flag_local := 'Y';
10510 PA_UTILS.Add_Message ( 'PA','PA_ASGN_CONFIRM_NOT_ALLOWED');
10511 -- Can we use PA_ASGN_CONFIRM_NOT_ALLOWED
10512 -- In TAD its given as PA_NO_RESOURCE_AUTHORITY ,its not appropriate
10513 END IF;
10514
10515 IF l_ret_code = FND_API.G_TRUE OR l_out_approval_required_flag ='Y' THEN
10516
10517 IF l_debug_mode = 'Y' THEN
10518 pa_debug.write(l_module, 'Calling Start_Assignment_Approvals',l_log_level);
10519 END IF;
10520
10521 l_before_api_msg_count := FND_MSG_PUB.count_msg;
10522
10523 -- Call API PA_ASSIGNMENT_APPROVAL_PUB.Start_Assignment_Approvals
10524 PA_ASSIGNMENT_APPROVAL_PUB.Start_Assignment_Approvals
10525 (
10526 p_assignment_id => l_assignment_id
10527 ,p_new_assignment_flag => 'N'
10528 ,p_action_code => 'APPROVE'
10529 ,p_note_to_approver => l_note_to_approver
10530 ,p_record_version_number => l_record_version_number
10531 ,p_validate_only => l_validate_only
10532 ,x_overcommitment_flag => l_overcommitment_flag
10533 ,x_conflict_group_id => l_conflict_group_id
10534 ,x_return_status => l_return_status
10535 ,x_msg_count => l_msg_count
10536 ,x_msg_data => l_msg_data
10537 );
10538 l_after_api_msg_count := FND_MSG_PUB.count_msg;
10539
10540 IF l_debug_mode = 'Y' THEN
10541 pa_debug.write(l_module, 'l_overcommitment_flag ' ||l_overcommitment_flag,l_log_level);
10542 pa_debug.write(l_module, 'l_conflict_group_id ' ||l_conflict_group_id,l_log_level);
10543 pa_debug.write(l_module, 'l_return_status ' ||l_return_status,l_log_level);
10544 END IF;
10545
10546 IF (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
10547 l_error_flag_local := 'Y';
10548 -- Dont check l_return_status as internal API
10549 -- sets return status as E if there are any msgs in stack
10550 -- Even before this API is called.
10551
10552 END IF;
10553 END IF;
10554 ELSE -- Auto Approve Flag is No
10555
10556 OPEN get_person_type(l_apr_person_id_1);
10557 FETCH get_person_type INTO l_full_name_apr1 ,l_sys_person_type_apr1,l_user_person_type_apr1;
10558 IF get_person_type%NOTFOUND THEN
10559 l_full_name_apr1 := NULL;
10560 l_sys_person_type_apr1 := NULL ;
10561 l_user_person_type_apr1 := NULL ;
10562 END IF;
10563 CLOSE get_person_type;
10564
10565 OPEN get_person_type(l_apr_person_id_2);
10566 FETCH get_person_type INTO l_full_name_apr2,l_sys_person_type_apr2,l_user_person_type_apr2;
10567 IF get_person_type%NOTFOUND THEN
10568 l_full_name_apr2 := NULL;
10569 l_sys_person_type_apr2 := NULL ;
10570 l_user_person_type_apr2 := NULL ;
10571 END IF;
10572 CLOSE get_person_type;
10573
10574 -- Populate PA_NO_NON_EXCLUDED_APR if
10575 -- You are going to submit for approval
10576 -- and there are no approvers specified.
10577
10578 IF (l_full_name_apr1 is NULL AND l_full_name_apr2 is NULL)
10579 OR
10580 (l_apr_person_id_1 is NULL AND l_apr_person_id_2 is NULL)
10581 THEN
10582 l_error_flag_local := 'Y';
10583 PA_UTILS.ADD_MESSAGE('PA','PA_NO_NON_EXCLUDED_APR');
10584 END IF;
10585
10586 -- Bug 5175869 : Start
10587 IF l_apr_person_id_1 IS NOT NULL THEN
10588 l_valid := 'N';
10589 l_valid := IS_VALID_APPROVER(l_apr_person_id_1,l_resource_id,l_start_date);
10590 IF l_valid = 'N' THEN
10591 l_error_flag_local := 'Y';
10592 PA_UTILS.ADD_MESSAGE('PA','PA_INVALID_APPRVR'
10593 ,'APPROVER_ID',l_apr_person_id_1);
10594 END IF;
10595 END IF;
10596
10597 IF l_apr_person_id_2 IS NOT NULL THEN
10598 l_valid := 'N';
10599 l_valid := IS_VALID_APPROVER(l_apr_person_id_2,l_resource_id,l_start_date);
10600 IF l_valid = 'N' THEN
10601 l_error_flag_local := 'Y';
10602 PA_UTILS.ADD_MESSAGE('PA','PA_INVALID_APPRVR'
10603 ,'APPROVER_ID',l_apr_person_id_2);
10604 END IF;
10605 END IF;
10606
10607 -- Bug 5175869 : End
10608
10609 IF (l_error_flag_local <> 'Y' AND l_apr_person_id_1 is NOT NULL) THEN
10610
10611 -- Added for Bug 5245870
10612 -- If second approver is present then call the api with validate only parameter.
10613 IF (l_apr_person_id_2 IS NOT NULL) THEN
10614 l_validate_only := FND_API.G_TRUE;
10615 ELSE
10616 l_validate_only := FND_API.G_FALSE;
10617 END IF;
10618
10619 l_before_api_msg_count := FND_MSG_PUB.count_msg;
10620 PA_ASSIGNMENT_APPROVAL_PUB.Start_Assignment_Approvals
10621 (
10622 p_assignment_id => l_assignment_id
10623 ,p_new_assignment_flag => l_out_new_assignment_flag
10624 ,p_action_code => 'SUBMIT'
10625 ,p_note_to_approver => l_note_to_approver
10626 ,p_apr_person_id => l_apr_person_id_1
10627 ,p_apr_person_name => l_full_name_apr1
10628 ,p_apr_person_type => 'RESOURCE_MANAGER' /* Added for bug 9379440 */
10629 ,p_apr_person_order => 1
10630 ,p_apr_person_exclude => 'N'
10631 ,p_record_version_number => l_record_version_number
10632 ,p_validate_only => l_validate_only
10633 ,x_overcommitment_flag => l_overcommitment_flag
10634 ,x_conflict_group_id => l_conflict_group_id
10635 ,x_return_status => l_return_status
10636 ,x_msg_count => l_msg_count
10637 ,x_msg_data => l_msg_data
10638 );
10639 --l_apr_person_name1:= pa_resource_utils.get_person_name_no_date(l_apr_person_id_1);
10640 --l_apr_person_name2:=pa_resource_utils.get_person_name_no_date(l_apr_person_id_2);
10641
10642 l_after_api_msg_count := FND_MSG_PUB.count_msg;
10643
10644 IF l_debug_mode = 'Y' THEN
10645 pa_debug.write(l_module, 'l_overcommitment_flag ' ||l_overcommitment_flag,l_log_level);
10646 pa_debug.write(l_module, 'l_conflict_group_id ' ||l_conflict_group_id,l_log_level);
10647 pa_debug.write(l_module, 'l_return_status ' ||l_return_status,l_log_level);
10648 END IF;
10649
10650 IF (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
10651 l_error_flag_local := 'Y';
10652 -- Dont check l_return_status as internal API
10653 -- sets return status as E if there are any msgs in stack
10654 -- Even before this API is called.
10655 END IF;
10656
10657 END IF; -- If no error and l_apr_person_id_1 is not null
10658
10659 IF (l_error_flag_local <> 'Y' AND l_apr_person_id_2 IS NOT NULL) THEN
10660 -- Call API for Approver 2
10661 l_validate_only := FND_API.G_FALSE; -- Added for Bug 5245870
10662 l_before_api_msg_count := FND_MSG_PUB.count_msg;
10663 PA_ASSIGNMENT_APPROVAL_PUB.Start_Assignment_Approvals
10664 (
10665 p_assignment_id => l_assignment_id
10666 ,p_new_assignment_flag => l_out_new_assignment_flag
10667 ,p_action_code => 'SUBMIT'
10668 ,p_note_to_approver => l_note_to_approver
10669 ,p_apr_person_id => l_apr_person_id_2
10670 ,p_apr_person_name => l_full_name_apr2
10671 ,p_apr_person_type => 'STAFFING_MANAGER' /* Added for bug 9891542 */
10672 ,p_apr_person_order => 2 -- Changed for Bug 5245870 from 1 to 2
10673 ,p_apr_person_exclude => 'N'
10674 ,p_record_version_number => l_record_version_number
10675 ,p_validate_only => l_validate_only
10676 ,x_overcommitment_flag => l_overcommitment_flag
10677 ,x_conflict_group_id => l_conflict_group_id
10678 ,x_return_status => l_return_status
10679 ,x_msg_count => l_msg_count
10680 ,x_msg_data => l_msg_data
10681 );
10682 --l_apr_person_name1:= pa_resource_utils.get_person_name_no_date(l_apr_person_id_1);
10683 --l_apr_person_name2:=pa_resource_utils.get_person_name_no_date(l_apr_person_id_2);
10684
10685 l_after_api_msg_count := FND_MSG_PUB.count_msg;
10686 IF (l_after_api_msg_count - l_before_api_msg_count) > 0 THEN
10687 l_error_flag_local := 'Y';
10688 -- Dont check l_return_status as internal API
10689 -- sets return status as E if there are any msgs in stack
10690 -- Even before this API is called.
10691 END IF;
10692 END IF; -- If no error and l_apr_person_id_2 is not null
10693 END IF; -- End if Auto Approve Flag is Yes .
10694
10695 END IF; -- l_error_flag_local <> Y --------- (2)
10696 END IF; -- l_error_flag_local <> Y --------- (1)
10697
10698 l_end_msg_count := FND_MSG_PUB.count_msg;
10699
10700 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
10701
10702 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
10703 l_error_flag := 'Y';
10704
10705 IF l_debug_mode = 'Y' THEN
10706 pa_debug.write(l_module, 'Repopulating Error Message Stack', l_log_level);
10707 END IF;
10708
10709 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
10710 -- Always get from first location in stack i.e. l_start_msg_count+1
10711 -- Because stack moves down after delete
10712 FND_MSG_PUB.get (
10713 p_msg_index => l_start_msg_count+1,
10714 p_encoded => FND_API.G_FALSE,
10715 p_data => l_data,
10716 p_msg_index_out => l_msg_index_out );
10717
10718 -- Always delete at first location in stack i.e. l_start_msg_count+1
10719 -- Because stack moves down after delete
10720 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
10721
10722 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
10723 'RECORD_NO', i,
10724 'MESSAGE', l_data);
10725 END LOOP;
10726 IF l_debug_mode = 'Y' THEN
10727 pa_debug.write(l_module, 'After Repopulating Error Message Stack', l_log_level);
10728 END IF;
10729 END IF;
10730 i:= p_submit_assignment_in_tbl.next(i);
10731 END LOOP;
10732
10733 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
10734 RAISE FND_API.G_EXC_ERROR;
10735 END IF;
10736
10737 IF l_debug_mode = 'Y' THEN
10738 PA_DEBUG.reset_curr_function;
10739 END IF;
10740
10741 IF p_commit = FND_API.G_TRUE THEN
10742 commit;
10743 END IF;
10744
10745 EXCEPTION
10746 WHEN FND_API.G_EXC_ERROR THEN
10747
10748 x_return_status := FND_API.G_RET_STS_ERROR;
10749 l_msg_count := FND_MSG_PUB.count_msg;
10750
10751 IF c_valid_asgn_id%ISOPEN THEN
10752 CLOSE c_valid_asgn_id ;
10753 END IF;
10754
10755 IF get_person_type%ISOPEN THEN
10756 CLOSE get_person_type;
10757 END IF;
10758
10759 IF p_commit = FND_API.G_TRUE THEN
10760 ROLLBACK TO SUBMIT_ASSIGNMENTS_SP;
10761 END IF;
10762
10763 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
10764 PA_INTERFACE_UTILS_PUB.get_messages
10765 ( p_encoded => FND_API.G_FALSE
10766 , p_msg_index => 1
10767 , p_msg_count => l_msg_count
10768 , p_msg_data => l_msg_data
10769 , p_data => l_data
10770 , p_msg_index_out => l_msg_index_out);
10771
10772 x_msg_data := l_data;
10773 x_msg_count := l_msg_count;
10774 ELSE
10775 x_msg_count := l_msg_count;
10776 END IF;
10777
10778 IF l_debug_mode = 'Y' THEN
10779 Pa_Debug.reset_curr_function;
10780 END IF;
10781
10782 WHEN OTHERS THEN
10783
10784 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10785 x_msg_data := SUBSTRB(SQLERRM,1,240);
10786
10787 IF c_valid_asgn_id%ISOPEN THEN
10788 CLOSE c_valid_asgn_id ;
10789 END IF;
10790
10791 IF get_person_type%ISOPEN THEN
10792 CLOSE get_person_type;
10793 END IF;
10794
10795 IF p_commit = FND_API.G_TRUE THEN
10796 ROLLBACK TO SUBMIT_ASSIGNMENTS_SP;
10797 END IF;
10798
10799 FND_MSG_PUB.add_exc_msg
10800 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
10801 , p_procedure_name => 'SUBMIT_ASSIGNMENTS'
10802 , p_error_text => x_msg_data);
10803
10804 x_msg_count := FND_MSG_PUB.count_msg;
10805
10806 IF l_debug_mode = 'Y' THEN
10807 PA_DEBUG.reset_curr_function;
10808 END IF;
10809 RAISE;
10810
10811 END SUBMIT_ASSIGNMENTS ;
10812
10813 -- Start of comments
10814 -- API name : CREATE_REQUIREMENT_COMPETENCE
10815 -- Type : Public
10816 -- Pre-reqs : None.
10817 -- Function : This is a public API to create one or more competences for one or more project requirements.
10818 -- Usage : This API will be called from AMG.
10819 -- Parameters :
10820 -- IN : p_commit IN VARCHAR2
10821 -- Identifier to commit the transaction.
10822 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
10823 -- p_init_msg_list IN VARCHAR2
10824 -- Identifier to initialize the error message stack.
10825 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
10826 -- p_api_version_number IN NUMBER Required
10827 -- To be compliant with Applications API coding standards.
10828 -- p_competence_in_tbl IN COMPETENCE_IN_TBL Required
10829 -- Table of competence records.
10830 -- Please see the COMPETENCE_IN_TBL_TYPE datatype table.
10831 -- OUT :
10832 -- x_competence_element_id_tbl OUT SYSTEM.PA_NUM_TBL_TYPE
10833 -- Table to store the competence element ids created by the API.
10834 -- Reference: per_comepetence_elements.competence_element_id
10835 -- x_return_status OUT VARCHAR2
10836 -- Indicates the return status of the API.
10837 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
10838 -- x_msg_count OUT NUMBER
10839 -- Indicates the number of error messages in the message stack
10840 -- x_msg_data OUT VARCHAR2
10841 -- Indicates the error message text if only one error exists
10842 -- History :
10843 -- 01-Mar-2006 - vkadimes - Created
10844 -- End of comments
10845 PROCEDURE CREATE_REQUIREMENT_COMPETENCE
10846 (
10847 p_commit IN VARCHAR2 :='F'
10848 , p_init_msg_list IN VARCHAR2 :='T'
10849 , p_api_version_number IN NUMBER :=1.0
10850 , p_competence_in_tbl IN COMPETENCE_IN_TBL_TYPE
10851 , x_competence_element_id_tbl OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE
10852 , x_return_status OUT NOCOPY VARCHAR2
10853 , x_msg_count OUT NOCOPY NUMBER
10854 , x_msg_data OUT NOCOPY VARCHAR2
10855 )
10856 IS
10857 -- Debug level setting Params
10858 l_debug_mode VARCHAR2(1);
10859 l_module VARCHAR2(255) := 'PA_RES_MANAGEMENT_AMG_PUB.CREATE_REQUIREMENT_COMPETENCE';
10860 l_debug_level NUMBER :=3;
10861 -- Params for pa_startup.initialize call
10862 l_calling_application VARCHAR2(10) :='PLSQL';
10863 l_check_id_flag VARCHAR2(1) := 'Y';
10864 l_check_role_security_flag VARCHAR2(1) := 'Y';
10865 l_check_resource_security_flag VARCHAR2(1) := 'Y';
10866 l_calling_module VARCHAR2(10) :='AMG';
10867 --Looping Params
10868 i NUMBER;
10869 -- Record Type
10870 l_competence_in_rec COMPETENCE_IN_REC_TYPE;
10871 -- Error Flags
10872 l_error_flag VARCHAR2(1);
10873 l_local_error_flag VARCHAR2(1);
10874 --Message Counters
10875 l_start_msg_count NUMBER;
10876 l_end_msg_count NUMBER;
10877 l_loop_msg_count NUMBER ;
10878 -- Miss Params List
10879 l_miss_params VARCHAR2(2000);
10880 -- security check Params
10881 l_privilege VARCHAR2(30);
10882 l_object_name VARCHAR2(30);
10883 l_object_key NUMBER;
10884 l_project_id NUMBER;
10885 l_template_id NUMBER;
10886 l_requirement_id NUMBER;
10887 l_ret_code VARCHAR2(1);
10888 l_wf_progress_flag VARCHAR2(1);
10889 l_status_code_num NUMBER ;
10890 -- Internal API calling Params
10891 l_msg_data VARCHAR2(2000);
10892 l_msg_count NUMBER;
10893 l_commit VARCHAR2(1) := FND_API.G_FALSE;
10894 l_return_status VARCHAR2(1);
10895 l_data VARCHAR2(2000);
10896 -- Temp Params
10897 l_req_sys_status_code VARCHAR2(30);
10898 l_status_code VARCHAR2(30);
10899 l_element_row_id ROWID;
10900 l_element_id per_competence_elements.competence_element_id%TYPE;
10901 l_msg_index_out NUMBER;
10902
10903 -- This cursor is used to Retrive the Info Regarding the given Requirement
10904 CURSOR cur_assign_info (l_requirement_id NUMBER ) IS
10905 SELECT project_id,status_code,mass_wf_in_progress_flag
10906 FROM pa_project_assignments
10907 where assignment_id = l_requirement_id
10908 AND assignment_type = 'OPEN_ASSIGNMENT'
10909 AND nvl(template_flag,'N') = 'N';
10910
10911 -- This cursor is used to get the system status code of the Given Requirement
10912 CURSOR cur_status_code(l_status_code VARCHAR2 ) IS
10913 SELECT project_system_status_code
10914 FROM pa_project_statuses
10915 WHERE project_status_code = l_status_code
10916 AND status_type= 'OPEN_ASGMT';
10917
10918 BEGIN
10919 -- Follows which are supported by this API
10920 ------------------------------------------
10921 -- Adding one competence when Requirement_id and competence id
10922 -- or Name or Alias are passsed with Data like
10923 -- Mandatary Flag and Rating level.
10924
10925 x_return_status := FND_API.G_RET_STS_SUCCESS;
10926
10927 x_competence_element_id_tbl := SYSTEM.PA_NUM_TBL_TYPE();
10928
10929 l_debug_mode := NVL(FND_PROFILE.value_specific('PA_DEBUG_MODE',fnd_global.user_id,fnd_global.login_id,275,null,null), 'N');
10930
10931
10932 IF l_debug_mode = 'Y' THEN
10933 PA_DEBUG.set_curr_function(p_function => 'CREATE_REQUIREMENT_COMPETENCE', p_debug_mode => l_debug_mode);
10934 END IF;
10935
10936 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
10937 FND_MSG_PUB.initialize;
10938 END IF;
10939
10940 IF P_COMMIT = FND_API.G_TRUE THEN
10941 SAVEPOINT CREATE_REQU_COMPETENCE_SP;
10942 END IF ;
10943
10944 IF l_debug_mode = 'Y' THEN
10945 pa_debug.write(l_module, 'Save Point create ', l_debug_level);
10946 pa_debug.write(l_module, 'Start of CREATE_REQUIREMENT_COMPETENCE ', l_debug_level);
10947 pa_debug.write(l_module, 'Before calling pa_startup.initialize ', l_debug_level);
10948 END IF ;
10949
10950 PA_STARTUP.INITIALIZE(
10951 p_calling_application => l_calling_application
10952 , p_calling_module => l_calling_module
10953 , p_check_id_flag => l_check_id_flag
10954 , p_check_role_security_flag => l_check_role_security_flag
10955 , p_check_resource_Security_flag => l_check_resource_Security_flag
10956 , p_debug_level => l_debug_level);
10957
10958 IF l_debug_mode = 'Y' THEN
10959 pa_debug.write(l_module, 'After calling pa_startup.initialize ', l_debug_level);
10960 END IF ;
10961
10962
10963 --checking the Input params..
10964 IF l_debug_mode = 'Y' THEN
10965
10966 pa_debug.write(l_module, 'Printing Input Parameters......', l_debug_level);
10967
10968 i := p_competence_in_tbl.first();
10969
10970 WHILE i IS NOT NULL LOOP
10971
10972 l_competence_in_rec := p_competence_in_tbl(i);
10973
10974 pa_debug.write(l_module, 'Values for Record No :'|| i , l_debug_level);
10975 pa_debug.write(l_module, '-----------------------------', l_debug_level);
10976 pa_debug.write(l_module, 'l_competence_in_rec.requirement_id for record ' || i || l_competence_in_rec.requirement_id , l_debug_level);
10977 pa_debug.write(l_module, 'l_competence_in_rec.competence_element_id for record ' || i || l_competence_in_rec.competence_element_id , l_debug_level);
10978 pa_debug.write(l_module, 'l_competence_in_rec.competence_id for record ' || i || l_competence_in_rec.competence_id , l_debug_level);
10979 pa_debug.write(l_module, 'l_competence_in_rec.competence_name for record ' || i || l_competence_in_rec.competence_name , l_debug_level);
10980 pa_debug.write(l_module, 'l_competence_in_rec.competence_alias for record ' || i || l_competence_in_rec.competence_alias , l_debug_level);
10981 pa_debug.write(l_module, 'l_competence_in_rec.rating_level_id for record ' || i || l_competence_in_rec.rating_level_id , l_debug_level);
10982 pa_debug.write(l_module, 'l_competence_in_rec.rating_level_value for record ' || i || l_competence_in_rec.rating_level_value , l_debug_level);
10983 pa_debug.write(l_module, 'l_competence_in_rec.mandatory_flag for record ' || i || l_competence_in_rec.mandatory_flag , l_debug_level);
10984 pa_debug.write(l_module, 'l_competence_in_rec.record_version_number for record ' || i || l_competence_in_rec.record_version_number , l_debug_level);
10985
10986 i :=p_competence_in_tbl.next(i);
10987 END LOOP;
10988
10989 END IF;
10990 -- Starting the Record validationa and API call.
10991
10992 i := p_competence_in_tbl.first();
10993
10994 WHILE i IS NOT NULL LOOP
10995 IF l_debug_mode = 'Y' THEN
10996 pa_debug.write(l_module, 'Inside Loop For Callling Internal API Record '|| i , l_debug_level);
10997 pa_debug.write(l_module, '-------------------------------', l_debug_level);
10998 END IF ;
10999
11000 l_local_error_flag := 'N';
11001 l_start_msg_count := FND_MSG_PUB.count_msg;
11002 l_competence_in_rec:=NULL ;
11003 l_miss_params := NULL;
11004 l_competence_in_rec := p_competence_in_tbl(i);
11005 -- Nulling out unpassed parameters
11006
11007 IF l_debug_mode = 'Y' THEN
11008 pa_debug.write(l_module, 'Start of Nulling out Params which are not passing for Record no '|| i , l_debug_level);
11009 END IF ;
11010 -- Nulling out unpassed params
11011 IF l_competence_in_rec.requirement_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11012 l_competence_in_rec.requirement_id := NULL;
11013 END IF ;
11014
11015 IF l_competence_in_rec.competence_element_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11016 l_competence_in_rec.competence_element_id := NULL;
11017 END IF;
11018
11019 IF l_competence_in_rec.competence_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11020 l_competence_in_rec.competence_id := NULL;
11021 END IF;
11022
11023 IF l_competence_in_rec.competence_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
11024 l_competence_in_rec.competence_name := NULL;
11025 END IF ;
11026
11027 IF l_competence_in_rec.competence_alias = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
11028 l_competence_in_rec.competence_alias := NULL;
11029 END IF;
11030
11031 IF l_competence_in_rec.rating_level_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11032 l_competence_in_rec.rating_level_id := NULL;
11033 END IF;
11034
11035 IF l_competence_in_rec.rating_level_value = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11036 l_competence_in_rec.rating_level_value := NULL;
11037 END IF;
11038
11039 IF l_competence_in_rec.mandatory_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
11040 l_competence_in_rec.mandatory_flag :=NULL;
11041 END IF;
11042
11043 IF l_competence_in_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11044 l_competence_in_rec.record_version_number :=NULL;
11045 END IF;
11046
11047 IF l_debug_mode = 'Y' THEN
11048 pa_debug.write(l_module, 'End of Nulling out Params which are not passing for Record no '|| i , l_debug_level);
11049 pa_debug.write(l_module, 'Start of checking for Missing Params for Record no '|| i , l_debug_level);
11050 END IF ;
11051 -- checking for missing params
11052 IF l_competence_in_rec.requirement_id IS NULL THEN
11053 l_miss_params:= l_miss_params||', REQUIREMENT_ID';
11054 END IF;
11055
11056 IF l_competence_in_rec.competence_id IS NULL AND
11057 l_competence_in_rec.competence_name IS NULL AND
11058 l_competence_in_rec.competence_alias IS NULL THEN
11059 l_miss_params:= l_miss_params||', COMPETANCE_ID, COMPETENCE_NAME, COMPETENCE_ALIAS';
11060 END IF;
11061
11062 IF l_debug_mode = 'Y' THEN
11063 pa_debug.write(l_module, 'After checking for miss Params for Record no '|| i , l_debug_level);
11064 END IF ;
11065
11066 IF l_miss_params IS NOT NULL THEN
11067 l_local_error_flag :='Y';
11068 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
11069 'INVALID_PARAMS', l_miss_params);
11070 END IF ;
11071
11072 IF l_debug_mode = 'Y' THEN
11073 pa_debug.write(l_module, 'Getting Requiremnet Details like project_id ,team_template_id,status_code etc '|| i , l_debug_level);
11074 END IF ;
11075
11076 l_requirement_id := l_competence_in_rec.requirement_id;
11077
11078 -- security check
11079 OPEN cur_assign_info(l_requirement_id);
11080 FETCH cur_assign_info INTO l_project_id,l_status_code,l_wf_progress_flag;
11081 -- checking for the validity of the requirement_id.
11082
11083 IF l_debug_mode = 'Y' THEN
11084 pa_debug.write(l_module, 'Checking for the Validity of the Record.'|| i , l_debug_level);
11085 END IF ;
11086
11087 IF cur_assign_info%NOTFOUND THEN
11088 l_local_error_flag := 'Y';
11089 l_miss_params := l_miss_params||', REQUIREMENT_ID';
11090 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
11091 'INVALID_PARAMS', l_miss_params);
11092 END IF;
11093
11094 CLOSE cur_assign_info;
11095
11096 OPEN cur_status_code(l_status_code);
11097 FETCH cur_status_code INTO l_req_sys_status_code;
11098 CLOSE cur_status_code;
11099
11100 IF l_debug_mode = 'Y' THEN
11101 pa_debug.write(l_module, 'After getting requirement Details for Record '|| i , l_debug_level);
11102 pa_debug.write(l_module, 'l_project_id ' ||l_project_id ||'l_template_id '||l_template_id , l_debug_level);
11103 pa_debug.write(l_module, 'l_req_sys_status_code '|| l_req_sys_status_code || 'l_wf_progress_flag ' || l_wf_progress_flag, l_debug_level);
11104 END IF;
11105
11106 IF l_local_error_flag <> 'Y' THEN
11107
11108 IF l_debug_mode = 'Y' THEN
11109 pa_debug.write(l_module, 'Checking Security for record No'||i, l_debug_level);
11110 END IF;
11111
11112 IF l_project_id IS NOT NULL THEN
11113 l_privilege := 'PA_ASN_BASIC_INFO_ED'; -- Bug#14098023
11114 l_object_name := 'PA_PROJECTS';
11115 l_object_key := l_project_id;
11116 ELSE
11117 -- This should never happen.
11118 PA_UTILS.ADD_MESSAGE('PA', 'PA_UNEXPECTED ERROR');
11119 raise FND_API.G_EXC_ERROR;
11120 END IF;
11121
11122 IF l_debug_mode = 'Y' THEN
11123 pa_debug.write(l_module, 'Calling PA_SECURITY_PVT.CHECK_USER_PRIVILEGE for Record = '||i||' with Following Values', l_debug_level);
11124 pa_debug.write(l_module, 'l_privilege :'|| l_privilege, l_debug_level);
11125 pa_debug.write(l_module, 'l_object_name :'||l_object_name, l_debug_level);
11126 pa_debug.write(l_module, 'l_object_key :'||l_object_key, l_debug_level);
11127 END IF;
11128
11129 l_return_status := FND_API.G_RET_STS_SUCCESS;
11130 l_ret_code := 'T';
11131
11132 -- Checking Security at project level or at Template level
11133 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
11134 x_ret_code => l_ret_code
11135 , x_return_status => l_return_status
11136 , x_msg_count => l_msg_count
11137 , x_msg_data => l_msg_data
11138 , p_privilege => l_privilege
11139 , p_object_name => l_object_name
11140 , p_object_key => l_object_key
11141 , p_init_msg_list => FND_API.G_FALSE);
11142
11143 IF l_debug_mode = 'Y' THEN
11144 pa_debug.write(l_module, 'Return Status from PA_SECURITY_PVT.CHECK_USER_PRIVILEGE for Record '||i||'is l_return_status '|| l_return_status , l_debug_level);
11145 pa_debug.write(l_module, 'l_ret_code ='|| l_ret_code , l_debug_level);
11146 END IF ;
11147
11148 IF (nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS)
11149 AND l_project_id IS NOT NULL THEN
11150 -- If project level security Fails wll call Requirement level Security
11151 IF l_debug_mode = 'Y' THEN
11152 pa_debug.write(l_module, 'No Access Found at Project level checking at Requirement level', l_debug_level);
11153 END IF ;
11154 l_privilege := 'PA_ASN_BASIC_INFO_ED';
11155 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
11156 l_object_key := l_requirement_id;
11157 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
11158 x_ret_code => l_ret_code
11159 , x_return_status => l_return_status
11160 , x_msg_count => l_msg_count
11161 , x_msg_data => l_msg_data
11162 , p_privilege => l_privilege
11163 , p_object_name => l_object_name
11164 , p_object_key => l_object_key
11165 , p_init_msg_list => FND_API.G_FALSE );
11166
11167 IF l_debug_mode = 'Y' THEN
11168 pa_debug.write(l_module, 'Return Status are Requirement level l_date return value l_ret_code'|| l_ret_code, l_debug_level);
11169 END IF ;
11170
11171
11172 END IF;
11173
11174 IF (nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11175 -- This message does not have token defined, but intentionally putting token
11176 -- bcoz we still want to show the privielge name which is missing
11177 IF l_debug_mode = 'Y' THEN
11178 pa_debug.write(l_module, 'User Dont have Privillege to modify this Requirement', l_debug_level);
11179 END IF ;
11180
11181 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_ADD_COMP'
11182 ,'MISSING_PRIVILEGE', l_privilege);
11183 l_local_error_flag := 'Y';
11184 END IF ;
11185 -- checking Requiremnet Status
11186 IF l_req_sys_status_code IN ('ASGMT_APPRVL_SUBMITTED','OPEN_ASGMT_FILLED', 'ASGMT_APPRVL_CANCELED') THEN
11187 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_STS_ACT_NOT_ALLW');
11188 l_local_error_flag := 'Y';
11189 END IF ;
11190 -- Checking WF status..
11191 IF l_wf_progress_flag = 'Y' THEN
11192 PA_UTILS.ADD_MESSAGE('PA', 'PA_ASSIGNMENT_WF');
11193 l_local_error_flag := 'Y';
11194 END IF;
11195
11196 IF l_debug_mode = 'Y' THEN
11197 pa_debug.write(l_module, 'End of Security check '|| l_ret_code, l_debug_level);
11198 END IF ;
11199
11200
11201 END IF;
11202
11203
11204 --- Calling pa_competence_pub.Add_competence_elemets
11205 IF l_local_error_flag <> 'Y' THEN
11206 -- No error occured.ie local error Flag is N
11207 IF l_debug_mode = 'Y' THEN
11208 pa_debug.write(l_module, 'Calling PA_COMPETENCE_PUB.ADD_COMPETENCE_ELEMENT ', l_debug_level);
11209 END IF ;
11210 l_return_status := FND_API.G_RET_STS_SUCCESS;
11211 -- Calling Internal API to Add competence
11212 PA_COMPETENCE_PUB.ADD_COMPETENCE_ELEMENT(
11213 p_object_name => 'OPEN_ASSIGNMENT'
11214 , p_object_id => l_competence_in_rec.requirement_id
11215 , p_competence_id => l_competence_in_rec.competence_id
11216 , p_competence_alias => l_competence_in_rec.competence_alias
11217 , p_competence_name => l_competence_in_rec.competence_name
11218 , p_rating_level_id => l_competence_in_rec.rating_level_id
11219 , p_rating_level_value => l_competence_in_rec.rating_level_value
11220 , p_mandatory_flag => l_competence_in_rec.mandatory_flag
11221 , p_init_msg_list => 'F'
11222 , P_commit => l_commit
11223 , p_validate_only => 'N'
11224 , x_element_id => l_element_id
11225 , x_element_rowid => l_element_row_id
11226 , x_return_status => l_return_status
11227 , x_msg_count => l_msg_count
11228 , x_msg_data => l_msg_data);
11229
11230 IF l_debug_mode = 'Y' THEN
11231 pa_debug.write(l_module, 'After Calling PA_COMPETENCE_PUB.ADD_COMPETENCE_ELEMENT ', l_debug_level);
11232 pa_debug.write(l_module, 'l_return_status '|| l_return_status || 'for record '|| i , l_debug_level);
11233 END IF ;
11234
11235 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
11236 x_competence_element_id_tbl.extend(1);
11237 x_competence_element_id_tbl(x_competence_element_id_tbl.count):= l_element_id;
11238 ELSE
11239 x_competence_element_id_tbl.extend(1);
11240 x_competence_element_id_tbl(x_competence_element_id_tbl.count):= -1;
11241 l_local_error_flag := 'Y';
11242 END IF;
11243 ELSE
11244 -- if local Error Flag is set for missparams or sec.Populating Out table with -1
11245 x_competence_element_id_tbl.extend(1);
11246 x_competence_element_id_tbl(x_competence_element_id_tbl.count):= -1;
11247 END IF ;
11248 -- Taking end count of loop
11249 l_end_msg_count := FND_MSG_PUB.count_msg;
11250 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
11251
11252 IF l_debug_mode = 'Y' THEN
11253 pa_debug.write(l_module, 'Error Flag for Record '|| i || ' is l_local_error_flag '|| l_local_error_flag , l_debug_level);
11254 END IF ;
11255
11256 IF l_local_error_flag = 'Y' OR l_loop_msg_count > 0 THEN
11257 l_error_flag := 'Y';
11258
11259 IF l_debug_mode = 'Y' THEN
11260 pa_debug.write(l_module, 'After Calling PA_COMPETENCE_PUB.ADD_COMPETENCE_ELEMENT ', l_debug_level);
11261 END IF ;
11262
11263 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
11264 FND_MSG_PUB.get (
11265 p_msg_index => l_start_msg_count+1
11266 , p_encoded => FND_API.G_FALSE
11267 , p_data => l_data
11268 , p_msg_index_out => l_msg_index_out );
11269
11270 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
11271 -- Adding Record Number to The Message.
11272 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
11273 'RECORD_NO', i,
11274 'MESSAGE', l_data);
11275 END LOOP;
11276
11277 END IF;
11278 i := P_COMPETENCE_IN_TBL.next(i);
11279 END LOOP;
11280 -- End of Loop(Record Loop)
11281 IF l_debug_mode = 'Y' THEN
11282 pa_debug.write(l_module, 'Out Of PA_COMPETENCE_PUB.ADD_COMPETENCE_ELEMENT API calling Loop', l_debug_level);
11283 END IF ;
11284
11285 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
11286 RAISE FND_API.G_EXC_ERROR;
11287 END IF;
11288
11289 IF l_debug_mode = 'Y' THEN
11290 PA_DEBUG.reset_curr_function;
11291 END IF;
11292
11293 IF p_commit = FND_API.G_TRUE THEN
11294 commit;
11295 END IF;
11296
11297 EXCEPTION
11298 WHEN FND_API.G_EXC_ERROR THEN
11299 x_return_status := FND_API.G_RET_STS_ERROR;
11300 l_msg_count := FND_MSG_PUB.count_msg;
11301
11302 IF l_debug_mode = 'Y' THEN
11303 pa_debug.write(l_module, 'In Side Exception Block FND_API.G_EXC_ERROR', l_debug_level);
11304 pa_debug.write(l_module, 'Closing CURSORS if OPEN', l_debug_level);
11305 END IF ;
11306
11307 IF cur_assign_info%ISOPEN THEN
11308 CLOSE cur_assign_info;
11309 END IF;
11310
11311 IF cur_status_code%ISOPEN THEN
11312 CLOSE cur_status_code;
11313 END IF;
11314
11315 IF p_commit = FND_API.G_TRUE THEN
11316 ROLLBACK TO CREATE_REQU_COMPETENCE_SP;
11317 END IF;
11318
11319 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
11320 PA_INTERFACE_UTILS_PUB.GET_MESSAGES(
11321 p_encoded => FND_API.G_FALSE
11322 , p_msg_index => 1
11323 , p_msg_count => l_msg_count
11324 , p_msg_data => l_msg_data
11325 , p_data => l_data
11326 , p_msg_index_out => l_msg_index_out);
11327
11328 x_msg_data := l_data;
11329 x_msg_count := l_msg_count;
11330 ELSE
11331 x_msg_count := l_msg_count;
11332 END IF;
11333
11334 IF l_debug_mode = 'Y' THEN
11335 Pa_Debug.reset_curr_function;
11336 END IF;
11337
11338 WHEN OTHERS THEN
11339
11340 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11341 x_msg_data := SUBSTRB(SQLERRM,1,240);
11342
11343 IF l_debug_mode = 'Y' THEN
11344 pa_debug.write(l_module, 'In Side Exception Block others ', l_debug_level);
11345 pa_debug.write(l_module, 'Closing CURSORS if OPEN', l_debug_level);
11346 END IF ;
11347
11348 IF cur_assign_info%ISOPEN THEN
11349 CLOSE cur_assign_info;
11350 END IF;
11351
11352 IF cur_status_code%ISOPEN THEN
11353 CLOSE cur_status_code;
11354 END IF;
11355
11356 IF p_commit = FND_API.G_TRUE THEN
11357 ROLLBACK TO CREATE_REQU_COMPETENCE_SP;
11358 END IF;
11359
11360 FND_MSG_PUB.add_exc_msg (
11361 p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
11362 , p_procedure_name => 'CREATE_REQUIREMENT_COMPETENCE'
11363 , p_error_text => x_msg_data);
11364
11365 x_msg_count := FND_MSG_PUB.count_msg;
11366
11367 IF l_debug_mode = 'Y' THEN
11368 PA_DEBUG.reset_curr_function;
11369 END IF;
11370 RAISE;
11371
11372 END CREATE_REQUIREMENT_COMPETENCE;
11373
11374 -- Start of comments
11375 -- API name : UPDATE_REQUIREMENT_COMPETENCE
11376 -- Type : Public
11377 -- Pre-reqs : None.
11378 -- Function : This is a public API to update one or more competences for one or more project requirements.
11379 -- Usage : This API will be called from AMG.
11380 -- Parameters :
11381 -- IN : p_commit IN VARCHAR2
11382 -- Identifier to commit the transaction.
11383 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
11384 -- p_init_msg_list IN VARCHAR2
11385 -- Identifier to initialize the error message stack.
11386 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
11387 -- p_api_version_number IN NUMBER Required
11388 -- To be compliant with Applications API coding standards.
11389 -- p_competence_in_tbl IN COMPETENCE_IN_TBL_TYPE Required
11390 -- Table of competence records. Please see the COMPETENCE_IN_TBL_TYPE datatype table.
11391 -- OUT :
11392 -- x_return_status OUT VARCHAR2
11393 -- Indicates the return status of the API.
11394 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
11395 -- x_msg_count OUT NUMBER
11396 -- Indicates the number of error messages in the message stack
11397 -- x_msg_data OUT VARCHAR2
11398 -- Indicates the error message text if only one error exists
11399 -- History :
11400 -- 01-Mar-2006 - vkadimes - Created
11401 -- End of comments
11402 PROCEDURE UPDATE_REQUIREMENT_COMPETENCE
11403 (
11404 p_commit IN VARCHAR2 := 'F'
11405 , p_init_msg_list IN VARCHAR2 := 'T'
11406 , p_api_version_number IN NUMBER := 1.0
11407 , p_competence_in_tbl IN COMPETENCE_IN_TBL_TYPE
11408 , x_return_status OUT NOCOPY VARCHAR2
11409 , x_msg_count OUT NOCOPY NUMBER
11410 , x_msg_data OUT NOCOPY VARCHAR2
11411 ) IS
11412 -- Debug Level
11413 l_module VARCHAR2(255) := 'PA_RES_MANAGEMENT_AMG_PUB.UPDATE_REQUIREMENT_COMPETENCE';
11414 l_debug_mode VARCHAR2(1);
11415 l_debug_level NUMBER :=3;
11416 -- Params for pa_startup.initialize call
11417 l_calling_application VARCHAR2(10) :='PLSQL';
11418 l_check_id_flag VARCHAR2(1) := 'Y';
11419 l_check_role_security_flag VARCHAR2(1) := 'Y';
11420 l_check_resource_security_flag VARCHAR2(1) := 'Y';
11421 l_calling_module VARCHAR(10) := 'AMG';
11422 --Looping params
11423
11424 i NUMBER;
11425 --Record Type
11426 l_competence_in_rec COMPETENCE_IN_REC_TYPE;
11427 --Loop params
11428 --Error Flags
11429 l_local_error_flag VARCHAR2(1);
11430 l_error_flag VARCHAR2(1);
11431 -- Message Counters
11432 l_start_msg_count NUMBER ;
11433 l_end_msg_count NUMBER ;
11434 l_loop_msg_count NUMBER ;
11435 -- Miss Params List
11436 l_miss_params VARCHAR2(2000);
11437 --temp Params
11438 l_requirement_id NUMBER;
11439 l_dummy NUMBER;
11440 l_competence_element_id NUMBER;
11441 l_competence_id NUMBER;
11442 -- Security check Params
11443 l_project_id NUMBER :=NULL;
11444 l_template_id NUMBER :=NULL;
11445 l_wf_progress_flag VARCHAR2(1);
11446 l_status_code VARCHAR2(10);
11447 l_req_sys_status_code VARCHAR2(30);
11448 l_privilege VARCHAR2(30);
11449 l_object_name VARCHAR2(30);
11450 l_object_key NUMBER;
11451 l_ret_code VARCHAR2(1);
11452
11453 l_msg_index_out NUMBER;
11454 l_msg_data VARCHAR2(2000);
11455 l_msg_count NUMBER;
11456 l_return_status VARCHAR2(1);
11457
11458 --Internal API calling Params
11459 l_commit VARCHAR2(1) := FND_API.G_FALSE;
11460 l_object_version_number NUMBER;
11461 l_data VARCHAR2(2000);
11462
11463 -- Given Competence Element id this cursor is used to get the info about that
11464 -- Perticulat competence
11465 CURSOR cur_competence_details(l_competence_element_id NUMBER) IS
11466 SELECT *
11467 FROM PA_OPEN_ASGMT_COMPETENCES_V
11468 WHERE competence_element_id = l_competence_element_id;
11469
11470 -- For Future developement
11471 /*CURSOR cur_competence_details_alt(l_requirement_id NUMBER, l_competence_id NUMBER ) IS
11472 SELECT *
11473 FROM PA_OPEN_ASGMT_COMPETENCES_V
11474 WHERE assignment_id = l_requirement_id
11475 AND competence_id=l_competence_id;*/
11476
11477
11478 -- This cursor is used to get the information like which Requirement
11479 -- competence belong to and validity .
11480 CURSOR cur_assign_info (l_requirement_id IN NUMBER ) IS
11481 SELECT project_id,assignment_template_id,status_code,mass_wf_in_progress_flag
11482 FROM pa_project_assignments
11483 where assignment_id = l_requirement_id;
11484
11485 -- To get the project system status code for
11486 -- perticular requirement.
11487 CURSOR cur_status_code(l_status_code VARCHAR2 ) IS
11488 SELECT project_system_status_code
11489 FROM pa_project_statuses
11490 WHERE project_status_code = l_status_code;
11491
11492 -- To Hold the values used.
11493 l_cur_competence_in_rec PA_OPEN_ASGMT_COMPETENCES_V%ROWTYPE;
11494
11495 BEGIN
11496 --Flows which are supported by this API
11497 ------------------------------------------------------
11498 -- User MUST PASS P_COMPETENCE_ELEMENT_ID
11499 -- Updating a competence by Passing p_competence_element_id
11500 -- when competence alias is passed it will be replaced with the one from Data base.
11501 -- ie competence name will be ignore and will be replaced with Data base value.
11502 -- Only we will Allow Mandatery Flag and Rating level to be updated.
11503
11504 --Flows which are not supported by this API
11505 ----------------------------------------------------------
11506 -- Updating a Competence by Passing Combination of Requirement_id and one of the
11507 -- competence id or competence alias or competence name
11508
11509
11510 x_return_status := FND_API.G_RET_STS_SUCCESS;
11511
11512 l_debug_mode := NVL(FND_PROFILE.value_specific('PA_DEBUG_MODE', fnd_global.user_id, fnd_global.login_id, 275, null, null), 'N');
11513
11514 IF l_debug_mode = 'Y' THEN
11515 PA_DEBUG.set_curr_function(p_function => 'UPDATE_REQUIREMENT_COMPETENCE', p_debug_mode => l_debug_mode);
11516 END IF;
11517
11518 -- Resetting the Error Stack.
11519 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
11520 FND_MSG_PUB.initialize;
11521 END IF;
11522
11523 IF P_COMMIT = FND_API.G_TRUE THEN
11524 SAVEPOINT UPDATE_REQU_COMPETENCE_SP;
11525 END IF ;
11526
11527 IF l_debug_mode = 'Y' THEN
11528 pa_debug.write(l_module,'Save Point create ', l_debug_level);
11529 END IF ;
11530
11531 IF l_debug_mode = 'Y' THEN
11532 pa_debug.write(l_module,'Start of UPDATE_REQUIREMENT_COMPETENCE ', l_debug_level);
11533 END IF ;
11534
11535 IF l_debug_mode = 'Y' THEN
11536 pa_debug.write(l_module,'Before calling pa_startup.initialize ', l_debug_level);
11537 END IF ;
11538
11539 PA_STARTUP.INITIALIZE(
11540 p_calling_application => l_calling_application
11541 , p_calling_module => l_calling_module
11542 , p_check_id_flag => l_check_id_flag
11543 , p_check_role_security_flag => l_check_role_security_flag
11544 , p_check_resource_Security_flag => l_check_resource_Security_flag
11545 , p_debug_level => l_debug_level);
11546
11547 IF l_debug_mode = 'Y' THEN
11548 pa_debug.write(l_module,'After calling pa_startup.initialize ', l_debug_level);
11549 END IF ;
11550
11551 IF l_debug_mode = 'Y' THEN
11552 pa_debug.write(l_module,'Printing Input Parameters......', l_debug_level);
11553
11554 i := p_competence_in_tbl.first();
11555
11556 WHILE i IS NOT NULL LOOP
11557
11558 l_competence_in_rec := p_competence_in_tbl(i);
11559
11560 pa_debug.write(l_module, 'Values for Record No :'|| i , l_debug_level);
11561 pa_debug.write(l_module, 'l_competence_in_rec.requirement_id for record ' || i || l_competence_in_rec.requirement_id , l_debug_level);
11562 pa_debug.write(l_module, 'l_competence_in_rec.competence_element_id for record ' || i || l_competence_in_rec.competence_element_id , l_debug_level);
11563 pa_debug.write(l_module, 'l_competence_in_rec.competence_id for record ' || i || l_competence_in_rec.competence_id , l_debug_level);
11564 pa_debug.write(l_module, 'l_competence_in_rec.competence_name for record ' || i || l_competence_in_rec.competence_name , l_debug_level);
11565 pa_debug.write(l_module, 'l_competence_in_rec.competence_alias for record ' || i || l_competence_in_rec.competence_alias , l_debug_level);
11566 pa_debug.write(l_module, 'l_competence_in_rec.rating_level_id for record ' || i || l_competence_in_rec.rating_level_id , l_debug_level);
11567 pa_debug.write(l_module, 'l_competence_in_rec.rating_level_value for record ' || i || l_competence_in_rec.rating_level_value , l_debug_level);
11568 pa_debug.write(l_module, 'l_competence_in_rec.mandatory_flag for record ' || i || l_competence_in_rec.mandatory_flag , l_debug_level);
11569 pa_debug.write(l_module, 'l_competence_in_rec.record_version_number for record ' || i || l_competence_in_rec.record_version_number , l_debug_level);
11570
11571 i :=p_competence_in_tbl.next(i);
11572 END LOOP;
11573
11574 END IF;
11575
11576 i := p_competence_in_tbl.first();
11577
11578 WHILE i IS NOT NULL LOOP
11579
11580 IF l_debug_mode = 'Y' THEN
11581 pa_debug.write(l_module, 'Inside Loop For Record '|| i , l_debug_level);
11582 END IF ;
11583 -- setting the Params at the starting of the loop
11584 l_local_error_flag := 'N';
11585 l_start_msg_count := FND_MSG_PUB.count_msg;
11586 l_competence_in_rec := NULL ;
11587 l_miss_params := NULL;
11588 l_competence_in_rec := P_COMPETENCE_IN_TBL(i);
11589
11590 IF l_competence_in_rec.competence_element_id IS NULL
11591 OR l_competence_in_rec.competence_element_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11592 l_miss_params := l_miss_params || 'P_COMPETENCE_ELEMENT_ID';
11593 END IF;
11594
11595 IF l_miss_params IS NOT NULL THEN
11596 l_local_error_flag := 'Y';
11597 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
11598 'INVALID_PARAMS', l_miss_params);
11599 END IF;
11600
11601 IF l_local_error_flag <> 'Y' THEN
11602 -- Getting Requirement competence Details
11603 -- These variables are loaded
11604 l_requirement_id := l_competence_in_rec.requirement_id;
11605 l_competence_id := l_competence_in_rec.competence_id;
11606 l_competence_element_id := l_competence_in_rec.competence_element_id;
11607 -- Getting the Data about competence
11608 IF l_competence_element_id IS NOT NULL
11609 AND l_competence_element_id <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11610
11611 OPEN cur_competence_details(l_competence_element_id);
11612 FETCH cur_competence_details INTO l_cur_competence_in_rec;
11613 -- checking the validity of l_competence_element_id
11614 IF cur_competence_details%NOTFOUND THEN
11615 l_local_error_flag := 'Y';
11616 l_miss_params := l_miss_params || 'P_COMPETENCE_ELEMENT_ID';
11617 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
11618 'INVALID_PARAMS', l_miss_params);
11619 END IF;
11620 -- closing the cursor
11621 CLOSE cur_competence_details;
11622 --Loading the values with the existing Data Base Values
11623 /*for Future Devolopement
11624 ELSE
11625 OPEN cur_competence_details_alt(l_requirement_id,l_competence_id);
11626 FETCH cur_competence_details_alt INTO l_cur_competence_in_rec;
11627 -- checking the validity of l_requirement_id,l_competence_id
11628 IF cur_competence_details_alt%NOTFOUND THEN
11629 l_local_error_flag := 'Y';
11630 PA_UTILS.ADD_MESSAGE('PA', 'PA_INVALID_ASGMT_ID');
11631 END IF;
11632 --Closing the cursor
11633 CLOSE cur_competence_details_alt;
11634 -- Populating the competence element id
11635 l_competence_in_rec.p_competence_element_id := l_cur_competence_in_rec.competence_element_id;
11636 l_competence_element_id := l_cur_competence_in_rec.competence_element_id;*/
11637 END IF;
11638 END IF;
11639
11640 IF l_local_error_flag <> 'Y' THEN
11641 -- Loading the Competence Name and Alias with the Exiting values.
11642 l_requirement_id := l_cur_competence_in_rec.assignment_id;
11643 l_competence_in_rec.requirement_id := l_cur_competence_in_rec.assignment_id;
11644 l_competence_id := l_cur_competence_in_rec.competence_id;
11645 l_competence_in_rec.competence_id := l_cur_competence_in_rec.competence_id;
11646 l_competence_in_rec.competence_name := l_cur_competence_in_rec.competence_name;
11647 l_competence_in_rec.competence_alias := l_cur_competence_in_rec.competence_alias;
11648
11649 IF l_competence_in_rec.record_version_number IS NULL
11650 OR l_competence_in_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11651
11652 l_competence_in_rec.record_version_number := l_cur_competence_in_rec.object_version_number;
11653
11654 END IF;
11655 END IF;
11656 -- Taking care of miss char value..
11657 IF l_competence_in_rec.requirement_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11658 l_competence_in_rec.requirement_id := FND_API.G_MISS_NUM;
11659 END IF ;
11660
11661 IF l_competence_in_rec.competence_element_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11662 l_competence_in_rec.competence_element_id := FND_API.G_MISS_NUM;
11663 END IF;
11664
11665 IF l_competence_in_rec.competence_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11666 l_competence_in_rec.competence_id := FND_API.G_MISS_NUM;
11667 END IF;
11668
11669 IF l_competence_in_rec.competence_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
11670 l_competence_in_rec.competence_name := FND_API.G_MISS_CHAR;
11671 END IF ;
11672
11673 IF l_competence_in_rec.competence_alias = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
11674 l_competence_in_rec.competence_alias := FND_API.G_MISS_CHAR;
11675 END IF;
11676
11677 IF l_competence_in_rec.rating_level_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11678 l_competence_in_rec.rating_level_id := FND_API.G_MISS_NUM;
11679 END IF;
11680
11681 IF l_competence_in_rec.rating_level_value = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11682 l_competence_in_rec.rating_level_value := FND_API.G_MISS_NUM;
11683 END IF;
11684
11685 IF l_competence_in_rec.mandatory_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
11686 l_competence_in_rec.mandatory_flag :=FND_API.G_MISS_CHAR;
11687 END IF;
11688
11689 IF l_competence_in_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
11690 l_competence_in_rec.record_version_number :=FND_API.G_MISS_NUM;
11691 END IF;
11692 --- Security check
11693
11694 IF l_local_error_flag <> 'Y' THEN
11695
11696 OPEN cur_assign_info(l_requirement_id);
11697 FETCH cur_assign_info INTO l_project_id,l_template_id,l_status_code,l_wf_progress_flag;
11698 CLOSE cur_assign_info;
11699
11700 OPEN cur_status_code(l_status_code);
11701 FETCH cur_status_code INTO l_req_sys_status_code;
11702 CLOSE cur_status_code;
11703
11704 IF l_debug_mode = 'Y' THEN
11705 pa_debug.write(l_module, 'Checking Security for record No'||i, l_debug_level);
11706 END IF;
11707
11708 IF l_project_id IS NOT NULL THEN
11709 l_privilege := 'PA_ASN_BASIC_INFO_ED'; -- Bug#14098023
11710 l_object_name := 'PA_PROJECTS';
11711 l_object_key := l_project_id;
11712 ELSIF l_template_id IS NOT NULL THEN
11713 l_privilege := 'PA_PRM_DEFINE_TEAM_TEMPLATE';
11714 l_object_name := null;
11715 l_object_key := null;
11716 ELSE
11717 -- This should never happen.
11718 PA_UTILS.ADD_MESSAGE('PA', 'PA_UNEXPECTED ERROR');
11719 raise FND_API.G_EXC_ERROR;
11720 END IF;
11721
11722 IF l_debug_mode = 'Y' THEN
11723 pa_debug.write(l_module, 'Calling PA_SECURITY_PVT.CHECK_USER_PRIVILEGE for Record '||i||'with Following Values', l_debug_level);
11724 pa_debug.write(l_module, 'l_privilege'|| l_privilege, l_debug_level);
11725 pa_debug.write(l_module, 'l_object_name'||l_object_name, l_debug_level);
11726 pa_debug.write(l_module, 'l_object_key'||l_object_key, l_debug_level);
11727 END IF;
11728
11729 l_return_status := FND_API.G_RET_STS_SUCCESS;
11730 l_ret_code := 'T';
11731
11732 -- Checking Security at project level or at Template level
11733 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
11734 x_ret_code => l_ret_code
11735 , x_return_status => l_return_status
11736 , x_msg_count => l_msg_count
11737 , x_msg_data => l_msg_data
11738 , p_privilege => l_privilege
11739 , p_object_name => l_object_name
11740 , p_object_key => l_object_key
11741 ,p_init_msg_list => FND_API.G_FALSE);
11742 IF l_debug_mode = 'Y' THEN
11743 pa_debug.write(l_module, 'Return Status from PA_SECURITY_PVT.CHECK_USER_PRIVILEGE for Record '||i||'is l_return_status '|| l_return_status , l_debug_level);
11744 pa_debug.write(l_module, 'l_ret_code'|| l_ret_code, l_debug_level);
11745 END IF ;
11746
11747 IF (nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS)
11748 AND l_project_id IS NOT NULL THEN
11749 -- If project level security Fails wll call Requirement level Security
11750 IF l_debug_mode = 'Y' THEN
11751 pa_debug.write(l_module,'No Access Found at Project level checking at Requirement level', l_debug_level);
11752 END IF ;
11753
11754 l_privilege := 'PA_ASN_BASIC_INFO_ED';
11755 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
11756 l_object_key := l_requirement_id;
11757 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
11758 x_ret_code => l_ret_code
11759 , x_return_status => l_return_status
11760 , x_msg_count => l_msg_count
11761 , x_msg_data => l_msg_data
11762 , p_privilege => l_privilege
11763 , p_object_name => l_object_name
11764 , p_object_key => l_object_key
11765 , p_init_msg_list => FND_API.G_FALSE );
11766
11767 IF l_debug_mode = 'Y' THEN
11768 pa_debug.write(l_module,'Return Status are Requirement level l_date return value l_ret_code'|| l_ret_code, l_debug_level);
11769 END IF ;
11770
11771 END IF;
11772
11773 IF (nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11774 -- This message does not have token defined, but intentionally putting token
11775 -- bcoz we still want to show the privielge name which is missing
11776 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_ADD_COMP'
11777 ,'MISSING_PRIVILEGE', l_privilege);
11778 l_local_error_flag := 'Y';
11779 END IF ;
11780 -- checking Assignment Status.
11781 IF l_req_sys_status_code IN ('ASGMT_APPRVL_SUBMITTED', 'OPEN_ASGMT_FILLED', 'ASGMT_APPRVL_CANCELED') THEN
11782 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_STS_ACT_NOT_ALLW');
11783 l_local_error_flag := 'Y';
11784 END IF ;
11785 -- Checking WF status..
11786 IF l_wf_progress_flag = 'Y' THEN
11787 PA_UTILS.ADD_MESSAGE('PA', 'PA_ASSIGNMENT_WF');
11788 l_local_error_flag := 'Y';
11789 END IF;
11790
11791 IF l_debug_mode = 'Y' THEN
11792 pa_debug.write(l_module, 'End of Security check '|| l_ret_code, l_debug_level);
11793 END IF ;
11794 END IF;
11795
11796 IF l_local_error_flag <> 'Y' THEN
11797 -- No error occured.ie local error Flag is N
11798 IF l_debug_mode = 'Y' THEN
11799 pa_debug.write(l_module, 'Calling PA_COMPETENCE_PUB.UPDATE_COMPETENCE_ELEMENT ', l_debug_level);
11800 END IF ;
11801
11802 l_return_status := FND_API.G_RET_STS_SUCCESS;
11803
11804 PA_COMPETENCE_PUB.UPDATE_COMPETENCE_ELEMENT(
11805 p_object_name =>'OPEN_ASSIGNMENT'
11806 , p_object_id => l_competence_in_rec.requirement_id
11807 , p_competence_id => l_competence_in_rec.competence_id
11808 , p_competence_alias => l_competence_in_rec.competence_alias
11809 , p_competence_name => l_competence_in_rec.competence_name
11810 , p_element_id => l_competence_in_rec.competence_element_id
11811 , p_rating_level_id => l_competence_in_rec.rating_level_id
11812 , p_rating_level_value => l_competence_in_rec.rating_level_value
11813 , p_mandatory_flag => l_competence_in_rec.mandatory_flag
11814 , p_init_msg_list => 'F'
11815 , p_element_rowid => l_cur_competence_in_rec.row_id
11816 , p_commit => l_commit
11817 , p_validate_only => 'N'
11818 , p_object_version_number => l_competence_in_rec.record_version_number
11819 , x_object_version_number => l_object_version_number
11820 , x_msg_count => l_msg_count
11821 , x_msg_data => l_msg_data
11822 , x_return_status => l_return_status);
11823
11824 IF l_debug_mode = 'Y' THEN
11825 pa_debug.write(l_module, 'After Calling PA_COMPETENCE_PUB.UPDATE_COMPETENCE_ELEMENT ', l_debug_level);
11826 pa_debug.write(l_module, 'l_return_status '|| l_return_status || 'for record '|| i , l_debug_level);
11827 END IF ;
11828 END IF;-- end of API call..
11829
11830 l_end_msg_count := FND_MSG_PUB.count_msg;
11831 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
11832
11833 IF l_debug_mode = 'Y' THEN
11834 pa_debug.write(l_module, 'Error Flag for Record '|| i || ' is l_local_error_flag '|| l_local_error_flag , l_debug_level);
11835 END IF ;
11836
11837 IF l_local_error_flag = 'Y' OR l_loop_msg_count > 0 THEN
11838 l_error_flag := 'Y';
11839 IF l_debug_mode = 'Y' THEN
11840 pa_debug.write(l_module, 'After Calling PA_COMPETENCE_PUB.UPDATE_COMPETENCE_ELEMENT ', l_debug_level);
11841 END IF ;
11842 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
11843 FND_MSG_PUB.get (
11844 p_msg_index => l_start_msg_count+1
11845 , p_encoded => FND_API.G_FALSE
11846 , p_data => l_data
11847 , p_msg_index_out => l_msg_index_out );
11848
11849 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
11850 -- Adding Record Number to The Message.
11851 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
11852 'RECORD_NO', i,
11853 'MESSAGE', l_data);
11854
11855 END LOOP;
11856 END IF;
11857 i := p_competence_in_tbl.next(i);
11858 END LOOP; -- end if Internal API call Loop
11859
11860 IF l_debug_mode = 'Y' THEN
11861 pa_debug.write(l_module,'Out Of PA_COMPETENCE_PUB.UPDATE_COMPETENCE_ELEMENT API calling Loop', l_debug_level);
11862 END IF ;
11863
11864 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
11865 RAISE FND_API.G_EXC_ERROR;
11866 END IF;
11867
11868 IF l_debug_mode = 'Y' THEN
11869 PA_DEBUG.RESET_CURR_FUNCTION;
11870 END IF;
11871
11872 IF p_commit = FND_API.G_TRUE THEN
11873 commit;
11874 END IF;
11875
11876 EXCEPTION
11877 WHEN FND_API.G_EXC_ERROR THEN
11878 x_return_status := FND_API.G_RET_STS_ERROR;
11879 l_msg_count := FND_MSG_PUB.count_msg;
11880
11881 IF l_debug_mode = 'Y' THEN
11882 pa_debug.write(l_module,'In Side Exception Block FND_API.G_EXC_ERROR', l_debug_level);
11883 pa_debug.write(l_module,'Closing CURSORS if OPEN', l_debug_level);
11884 END IF ;
11885
11886 IF cur_assign_info%ISOPEN THEN
11887 CLOSE cur_assign_info;
11888 END IF;
11889
11890 IF cur_status_code%ISOPEN THEN
11891 CLOSE cur_status_code;
11892 END IF;
11893
11894 IF cur_competence_details%ISOPEN THEN
11895 CLOSE cur_competence_details;
11896 END IF;
11897
11898 IF p_commit = FND_API.G_TRUE THEN
11899 ROLLBACK TO UPDATE_REQU_COMPETENCE_SP;
11900 END IF;
11901
11902 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
11903 PA_INTERFACE_UTILS_PUB.GET_MESSAGES(
11904 p_encoded => FND_API.G_FALSE
11905 , p_msg_index => 1
11906 , p_msg_count => l_msg_count
11907 , p_msg_data => l_msg_data
11908 , p_data => l_data
11909 , p_msg_index_out => l_msg_index_out);
11910
11911 x_msg_data := l_data;
11912 x_msg_count := l_msg_count;
11913 ELSE
11914 x_msg_count := l_msg_count;
11915 END IF;
11916
11917 IF l_debug_mode = 'Y' THEN
11918 PA_DEBUG.reset_curr_function;
11919 END IF;
11920
11921 WHEN OTHERS THEN
11922
11923 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
11924 x_msg_data := SUBSTRB(SQLERRM,1,240);
11925
11926 IF l_debug_mode = 'Y' THEN
11927 pa_debug.write(l_module,'In Side Exception Block others ', l_debug_level);
11928 pa_debug.write(l_module,'Closing CURSORS if OPEN', l_debug_level);
11929 END IF ;
11930
11931 IF cur_assign_info%ISOPEN THEN
11932 CLOSE cur_assign_info;
11933 END IF;
11934
11935 IF cur_status_code%ISOPEN THEN
11936 CLOSE cur_status_code;
11937 END IF;
11938
11939 IF cur_competence_details%ISOPEN THEN
11940 CLOSE cur_competence_details;
11941 END IF;
11942
11943 IF p_commit = FND_API.G_TRUE THEN
11944 ROLLBACK TO UPDATE_REQU_COMPETENCE_SP;
11945 END IF;
11946
11947 FND_MSG_PUB.ADD_EXC_MSG(
11948 p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
11949 , p_procedure_name => 'CREATE_REQUIREMENT_COMPETENCE'
11950 , p_error_text => x_msg_data);
11951
11952 x_msg_count := FND_MSG_PUB.count_msg;
11953
11954 IF l_debug_mode = 'Y' THEN
11955 PA_DEBUG.reset_curr_function;
11956 END IF;
11957 RAISE;
11958 END UPDATE_REQUIREMENT_COMPETENCE;
11959
11960 -- Start of comments
11961 -- API name : DELETE_REQUIREMENT_COMPETENCE
11962 -- Type : Public
11963 -- Pre-reqs : None.
11964 -- Function : This is a public API to create/nominate one or more candidates for
11965 -- project requirements.
11966 -- Usage : This API will be called from AMG.
11967 -- Parameters :
11968 -- IN : p_commit IN VARCHAR2
11969 -- Identifier to commit the transaction.
11970 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
11971 -- p_init_msg_list IN VARCHAR2
11972 -- Identifier to initialize the error message stack.
11973 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
11974 -- p_api_version_number IN NUMBER Required
11975 -- To be compliant with Applications API coding standards.
11976 -- P_COMPETENCE_IN_TBL IN COMPETENCE_IN_TBL_TYPE Required
11977 -- Table of competence records. Please see the COMPETENCE_IN_TBL_TYPE datatype table
11978 -- OUT :
11979 -- x_return_status OUT VARCHAR2
11980 -- Indicates the return status of the API.
11981 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
11982 -- x_msg_count OUT NUMBER
11983 -- Indicates the number of error messages in the message stack
11984 -- x_msg_data OUT VARCHAR2
11985 -- Indicates the error message text if only one error exists
11986 -- History :
11987 -- 01-Mar-2006 - vkadimes - Created
11988 -- End of comments
11989 PROCEDURE DELETE_REQUIREMENT_COMPETENCE (
11990 p_commit IN VARCHAR2 :='F'
11991 , p_init_msg_list IN VARCHAR2 := 'T'
11992 , p_api_version_number IN NUMBER := 1.0
11993 , p_competence_in_tbl IN COMPETENCE_IN_TBL_TYPE
11994 , x_return_status OUT NOCOPY VARCHAR2
11995 , x_msg_count OUT NOCOPY NUMBER
11996 , x_msg_data OUT NOCOPY VARCHAR2
11997 ) IS
11998
11999 -- Debug Level
12000 l_module VARCHAR2(255) := 'PA_RES_MANAGEMENT_AMG_PUB.DELETE_REQUIREMENT_COMPETENCE';
12001 l_debug_mode VARCHAR2(1);
12002 l_debug_level NUMBER :=3;
12003 -- Params for pa_startup.initialize call
12004 l_calling_application VARCHAR2(10) :='PLSQL';
12005 l_check_id_flag VARCHAR2(1) := 'Y';
12006 l_check_role_security_flag VARCHAR2(1) := 'Y';
12007 l_check_resource_security_flag VARCHAR2(1) := 'Y';
12008 l_calling_module VARCHAR2(10) := 'AMG';
12009 --Looping params
12010 i NUMBER;
12011 --Record Type
12012 l_competence_in_rec COMPETENCE_IN_REC_TYPE;
12013 --Error Flags
12014 l_local_error_flag VARCHAR2(1);
12015 l_error_flag VARCHAR2(1);
12016 -- Message Counters
12017 l_start_msg_count NUMBER ;
12018 l_end_msg_count NUMBER ;
12019 l_loop_msg_count NUMBER ;
12020 -- Miss Params List
12021 l_miss_params VARCHAR2(2000);
12022 --temp Params
12023 l_requirement_id NUMBER;
12024 l_dummy NUMBER;
12025 l_competence_element_id NUMBER;
12026 l_competence_id NUMBER;
12027 -- Security check Params
12028 l_project_id NUMBER :=NULL;
12029 l_template_id NUMBER :=NULL;
12030 l_wf_progress_flag VARCHAR2(1);
12031 l_status_code VARCHAR2(10);
12032 l_req_sys_status_code VARCHAR2(30);
12033 l_privilege VARCHAR2(30);
12034 l_object_name VARCHAR2(30);
12035 l_object_key NUMBER;
12036 l_ret_code VARCHAR2(1);
12037 l_msg_index_out NUMBER;
12038 l_msg_data VARCHAR2(2000);
12039 l_msg_count NUMBER;
12040 l_return_status VARCHAR2(1);
12041 --Internal API calling Params
12042 l_commit VARCHAR2(1) := FND_API.G_FALSE;
12043 l_object_version_number NUMBER;
12044 l_data VARCHAR2(2000);
12045
12046 -- Given Competence Element id this cursor is used to get the info about that
12047 -- Perticulat competence
12048 CURSOR cur_competence_details(l_competence_element_id NUMBER) IS
12049 SELECT *
12050 FROM PA_OPEN_ASGMT_COMPETENCES_V
12051 WHERE competence_element_id = l_competence_element_id;
12052
12053
12054 -- This cursor is used to get the information like which Requirement
12055 -- competence belong to and validity .
12056 CURSOR cur_assign_info (l_requirement_id IN NUMBER ) IS
12057 SELECT project_id,assignment_template_id,status_code,mass_wf_in_progress_flag
12058 FROM pa_project_assignments
12059 where assignment_id = l_requirement_id;
12060
12061 -- To get the project system status code for
12062 -- perticular requirement.
12063 CURSOR cur_status_code(l_status_code VARCHAR2 ) IS
12064 SELECT project_system_status_code
12065 FROM pa_project_statuses
12066 WHERE project_status_code = l_status_code
12067 AND status_type= 'OPEN_ASGMT';
12068
12069 -- Record type
12070 l_cur_competence_in_rec PA_OPEN_ASGMT_COMPETENCES_V%ROWTYPE;
12071
12072 BEGIN
12073 -- Flows which are supported by this API
12074 -----------------------------------------
12075 --Deleting one competence from Both Project Requirement and Team Template Requirement by Passing
12076 --Competence_element_id.
12077 --Flows which are not supported by this API
12078 --------------------------------------------
12079 -- Deleting the Requirement by passing Requirement id and one of competence_id or competence alias or
12080 -- competence Name.
12081
12082 x_return_status := FND_API.G_RET_STS_SUCCESS;
12083
12084 l_debug_mode := NVL(FND_PROFILE.value_specific('PA_DEBUG_MODE',fnd_global.user_id,fnd_global.login_id,275,null,null), 'N');
12085
12086 IF l_debug_mode = 'Y' THEN
12087 PA_DEBUG.set_curr_function(p_function => 'DELETE_REQUIREMENT_COMPETENCE', p_debug_mode => l_debug_mode);
12088 END IF;
12089
12090 -- Resetting the Error Stack.
12091 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
12092 FND_MSG_PUB.initialize;
12093 END IF;
12094
12095 IF P_COMMIT = FND_API.G_TRUE THEN
12096 SAVEPOINT DELETE_REQU_COMPETENCE_SP;
12097 END IF ;
12098
12099 IF l_debug_mode = 'Y' THEN
12100 pa_debug.write(l_module,'Save Point create ', l_debug_level);
12101 pa_debug.write(l_module,'Start of DELETE_REQUIREMENT_COMPETENCE ', l_debug_level);
12102 pa_debug.write(l_module,'Before calling pa_startup.initialize ', l_debug_level);
12103 END IF ;
12104
12105 PA_STARTUP.INITIALIZE(
12106 p_calling_application => l_calling_application
12107 , p_calling_module => l_calling_module
12108 , p_check_id_flag => l_check_id_flag
12109 , p_check_role_security_flag => l_check_role_security_flag
12110 , p_check_resource_Security_flag => l_check_resource_Security_flag
12111 , p_debug_level => l_debug_level);
12112
12113 IF l_debug_mode = 'Y' THEN
12114 pa_debug.write(l_module,'After calling pa_startup.initialize ', l_debug_level);
12115 END IF ;
12116
12117 IF l_debug_mode = 'Y' THEN
12118 pa_debug.write(l_module,'Printing Input Parameters......', l_debug_level);
12119
12120 i := p_competence_in_tbl.first();
12121
12122 WHILE i IS NOT NULL LOOP
12123
12124 l_competence_in_rec := p_competence_in_tbl(i);
12125
12126 pa_debug.write(l_module,'Values for Record No :'|| i , l_debug_level);
12127 pa_debug.write(l_module,'l_competence_in_rec.requirement_id for record ' || i || l_competence_in_rec.requirement_id , l_debug_level);
12128 pa_debug.write(l_module, 'l_competence_in_rec.competence_element_id for record ' || i || l_competence_in_rec.competence_element_id , l_debug_level);
12129 pa_debug.write(l_module, 'l_competence_in_rec.competence_id for record ' || i || l_competence_in_rec.competence_id , l_debug_level);
12130 pa_debug.write(l_module, 'l_competence_in_rec.competence_name for record ' || i || l_competence_in_rec.competence_name , l_debug_level);
12131 pa_debug.write(l_module, 'l_competence_in_rec.competence_alias for record ' || i || l_competence_in_rec.competence_alias , l_debug_level);
12132 pa_debug.write(l_module, 'l_competence_in_rec.rating_level_id for record ' || i || l_competence_in_rec.rating_level_id , l_debug_level);
12133 pa_debug.write(l_module, 'l_competence_in_rec.rating_level_value for record ' || i || l_competence_in_rec.rating_level_value , l_debug_level);
12134 pa_debug.write(l_module, 'l_competence_in_rec.mandatory_flag for record ' || i || l_competence_in_rec.mandatory_flag , l_debug_level);
12135 pa_debug.write(l_module, 'l_competence_in_rec.record_version_number for record ' || i || l_competence_in_rec.record_version_number , l_debug_level);
12136
12137 i :=p_competence_in_tbl.next(i);
12138
12139 END LOOP;
12140
12141 END IF;
12142
12143 i := p_competence_in_tbl.first();
12144
12145 WHILE i IS NOT NULL LOOP
12146
12147 IF l_debug_mode = 'Y' THEN
12148 pa_debug.write(l_module,'Inside Loop For Record '|| i , l_debug_level);
12149 END IF ;
12150 -- Initializing the local Params for loop
12151 l_local_error_flag := 'N';
12152 l_start_msg_count := FND_MSG_PUB.count_msg;
12153 l_competence_in_rec := NULL ;
12154 l_miss_params := NULL;
12155 l_competence_in_rec := P_COMPETENCE_IN_TBL(i);
12156 -- check for missparams.......
12157 IF l_competence_in_rec.competence_element_id IS NULL OR
12158 l_competence_in_rec.competence_element_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
12159 l_miss_params := l_miss_params || 'COMPETENCE_ELEMENT_ID';
12160 END IF;
12161
12162 IF l_miss_params IS NOT NULL THEN
12163 l_local_error_flag := 'Y';
12164 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
12165 'INVALID_PARAMS', l_miss_params);
12166 END IF;
12167
12168 IF l_local_error_flag <> 'Y' THEN
12169 OPEN cur_competence_details(l_competence_in_rec.competence_element_id);
12170 FETCH cur_competence_details INTO l_cur_competence_in_rec;
12171 -- Checking for the validity of competence id
12172 IF cur_competence_details%NOTFOUND THEN
12173 l_local_error_flag := 'Y';
12174 l_miss_params := l_miss_params || 'COMPETENCE_ELEMENT_ID';
12175 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
12176 'INVALID_PARAMS', l_miss_params);
12177 END IF;
12178
12179 CLOSE cur_competence_details;
12180 -- Getting the requirement_id for that Record
12181 l_requirement_id := l_cur_competence_in_rec.assignment_id;
12182
12183 END IF;
12184
12185 IF l_local_error_flag <> 'Y' THEN
12186
12187 IF l_competence_in_rec.record_version_number IS NULL
12188 OR l_competence_in_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
12189
12190 l_competence_in_rec.record_version_number :=l_cur_competence_in_rec.object_version_number;
12191
12192 END IF;
12193
12194 OPEN cur_assign_info(l_requirement_id);
12195 FETCH cur_assign_info INTO l_project_id,l_template_id,l_status_code,l_wf_progress_flag;
12196 CLOSE cur_assign_info;
12197
12198 OPEN cur_status_code(l_status_code);
12199 FETCH cur_status_code INTO l_req_sys_status_code;
12200 CLOSE cur_status_code;
12201
12202 IF l_debug_mode = 'Y' THEN
12203 pa_debug.write(l_module, 'Checking Security for record No'||i, l_debug_level);
12204 END IF;
12205
12206 IF l_project_id IS NOT NULL THEN
12207 l_privilege := 'PA_ASN_BASIC_INFO_ED'; --Bug#14098023
12208 l_object_name := 'PA_PROJECTS';
12209 l_object_key := l_project_id;
12210 ELSIF l_template_id IS NOT NULL THEN
12211 l_privilege := 'PA_PRM_DEFINE_TEAM_TEMPLATE';
12212 l_object_name := null;
12213 l_object_key := null;
12214 ELSE
12215 -- This should never happen.
12216 PA_UTILS.ADD_MESSAGE('PA', 'PA_UNEXPECTED ERROR');
12217 raise FND_API.G_EXC_ERROR;
12218 END IF;
12219
12220 IF l_debug_mode = 'Y' THEN
12221 pa_debug.write(l_module, 'Calling PA_SECURITY_PVT.CHECK_USER_PRIVILEGE for Record '||i||'with Following Values', l_debug_level);
12222 pa_debug.write(l_module, 'l_privilege'|| l_privilege, l_debug_level);
12223 pa_debug.write(l_module, 'l_object_name'||l_object_name, l_debug_level);
12224 pa_debug.write(l_module, 'l_object_key'||l_object_key, l_debug_level);
12225 END IF;
12226
12227 l_return_status := FND_API.G_RET_STS_SUCCESS;
12228 l_ret_code := 'T';
12229
12230 -- Checking Security at project level or at Template level
12231 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
12232 x_ret_code => l_ret_code
12233 , x_return_status => l_return_status
12234 , x_msg_count => l_msg_count
12235 , x_msg_data => l_msg_data
12236 , p_privilege => l_privilege
12237 , p_object_name => l_object_name
12238 , p_object_key => l_object_key
12239 ,p_init_msg_list => FND_API.G_FALSE);
12240
12241 IF l_debug_mode = 'Y' THEN
12242 pa_debug.write(l_module, 'Return Status from PA_SECURITY_PVT.CHECK_USER_PRIVILEGE for Record '||i||'is l_return_status '|| l_return_status , l_debug_level);
12243 pa_debug.write(l_module, 'l_ret_code'|| l_ret_code, l_debug_level);
12244 END IF ;
12245
12246 IF (nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS)
12247 AND l_project_id IS NOT NULL THEN
12248 -- If project level security Fails wll call Requirement level Security
12249 IF l_debug_mode = 'Y' THEN
12250 pa_debug.write(l_module,'No Access Found at Project level checking at Requirement level', l_debug_level);
12251 END IF ;
12252
12253 l_privilege := 'PA_ASN_BASIC_INFO_ED';
12254 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
12255 l_object_key := l_requirement_id;
12256 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
12257 x_ret_code => l_ret_code
12258 , x_return_status => l_return_status
12259 , x_msg_count => l_msg_count
12260 , x_msg_data => l_msg_data
12261 , p_privilege => l_privilege
12262 , p_object_name => l_object_name
12263 , p_object_key => l_object_key
12264 , p_init_msg_list => FND_API.G_FALSE );
12265
12266 IF l_debug_mode = 'Y' THEN
12267 pa_debug.write(l_module,'Return Status are Requirement level l_date return value l_ret_code'|| l_ret_code, l_debug_level);
12268 END IF ;
12269
12270 END IF;
12271
12272 IF (nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
12273 -- This message does not have token defined, but intentionally putting token
12274 -- bcoz we still want to show the privielge name which is missing
12275 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_ADD_COMP'
12276 ,'MISSING_PRIVILEGE', l_privilege);
12277 l_local_error_flag := 'Y';
12278 END IF ;
12279 -- checking Assignment Status.
12280 IF l_req_sys_status_code IN ('ASGMT_APPRVL_SUBMITTED','OPEN_ASGMT_FILLED', 'ASGMT_APPRVL_CANCELED') THEN
12281 -- Need more specific message saying.. cant edit assignment.
12282 PA_UTILS.ADD_MESSAGE('PA','PA_ASSIGNMENT_WF');
12283 l_local_error_flag := 'Y';
12284 END IF ;
12285 -- Checking WF status..
12286 IF l_wf_progress_flag = 'Y' THEN
12287 PA_UTILS.ADD_MESSAGE('PA','PA_ASSIGNMENT_WF');
12288 l_local_error_flag := 'Y';
12289 END IF;
12290
12291 IF l_debug_mode = 'Y' THEN
12292 pa_debug.write(l_module, 'End of Security check '|| l_ret_code, l_debug_level);
12293 END IF ;
12294 END IF;
12295 -- Nulling out the Params as they will not be used.
12296 l_competence_in_rec.requirement_id := l_cur_competence_in_rec.assignment_id;
12297 l_competence_in_rec.competence_id := l_cur_competence_in_rec.competence_id;
12298 l_competence_in_rec.competence_alias := NULL;
12299 l_competence_in_rec.competence_name := NULL;
12300 l_competence_in_rec.rating_level_id := NULL;
12301 l_competence_in_rec.rating_level_value := NULL;
12302 l_competence_in_rec.mandatory_flag := NULL;
12303
12304 IF l_local_error_flag <> 'Y' THEN
12305 -- No error occured.ie local error Flag is N
12306 IF l_debug_mode = 'Y' THEN
12307 pa_debug.write(l_module, 'Calling PA_COMPETENCE_PUB.DELETE_COMPETENCE_ELEMENT', l_debug_level);
12308 END IF ;
12309
12310 l_return_status := FND_API.G_RET_STS_SUCCESS;
12311
12312 PA_COMPETENCE_PUB.DELETE_COMPETENCE_ELEMENT(
12313 p_object_name => 'OPEN_ASSIGNMENT'
12314 , p_object_id => l_competence_in_rec.requirement_id
12315 , p_competence_id => l_competence_in_rec.competence_id
12316 , p_competence_alias => l_competence_in_rec.competence_alias
12317 , p_competence_name => l_competence_in_rec.competence_name
12318 , p_element_rowid => l_cur_competence_in_rec.row_id
12319 , p_element_id => l_competence_in_rec.competence_element_id
12320 , p_init_msg_list => 'F'
12321 , p_commit => l_commit
12322 , p_validate_only => 'F'
12323 , p_object_version_number =>l_competence_in_rec.record_version_number
12324 , x_return_status => l_return_status
12325 , x_msg_count => l_msg_count
12326 , x_msg_data => l_msg_data);
12327
12328 IF l_debug_mode = 'Y' THEN
12329 pa_debug.write(l_module,'After Calling PA_COMPETENCE_PUB.DELETE_COMPETENCE_ELEMENT ', l_debug_level);
12330 pa_debug.write(l_module,'l_return_status '|| l_return_status || 'for record '|| i , l_debug_level);
12331 END IF ;
12332
12333 END IF;-- end of API call..
12334
12335 l_end_msg_count := FND_MSG_PUB.count_msg;
12336 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
12337
12338 IF l_debug_mode = 'Y' THEN
12339 pa_debug.write(l_module,'Error Flag for Record '|| i || ' is l_local_error_flag '|| l_local_error_flag , l_debug_level);
12340 END IF ;
12341
12342 IF l_local_error_flag = 'Y' OR l_loop_msg_count > 0 THEN
12343 l_error_flag := 'Y';
12344 IF l_debug_mode = 'Y' THEN
12345 pa_debug.write(l_module,'After Calling PA_COMPETENCE_PUB.DELETE_COMPETENCE_ELEMENT ', l_debug_level);
12346 END IF ;
12347 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
12348 FND_MSG_PUB.GET (
12349 p_msg_index => l_start_msg_count+1
12350 , p_encoded => FND_API.G_FALSE
12351 , p_data => l_data
12352 , p_msg_index_out => l_msg_index_out );
12353
12354 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
12355 -- Adding Record Number to The Message.
12356 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
12357 'RECORD_NO', i,
12358 'MESSAGE', l_data);
12359 END LOOP;
12360 END IF;
12361 i := p_competence_in_tbl.next(i);
12362 END LOOP; -- end if Internal API call Loop
12363
12364 IF l_debug_mode = 'Y' THEN
12365 pa_debug.write(l_module,'Out Of PA_COMPETENCE_PUB.DELETE_COMPETENCE_ELEMENT API calling Loop', l_debug_level);
12366 END IF ;
12367
12368 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
12369 RAISE FND_API.G_EXC_ERROR;
12370 END IF;
12371
12372 IF l_debug_mode = 'Y' THEN
12373 PA_DEBUG.RESET_CURR_FUNCTION;
12374 END IF;
12375
12376 IF p_commit = FND_API.G_TRUE THEN
12377 commit;
12378 END IF;
12379
12380 EXCEPTION
12381 WHEN FND_API.G_EXC_ERROR THEN
12382 x_return_status := FND_API.G_RET_STS_ERROR;
12383 l_msg_count := FND_MSG_PUB.count_msg;
12384
12385 IF l_debug_mode = 'Y' THEN
12386 pa_debug.write(l_module,'In Side Exception Block FND_API.G_EXC_ERROR', l_debug_level);
12387 pa_debug.write(l_module,'Closing CURSORS if OPEN', l_debug_level);
12388 END IF ;
12389
12390 IF cur_assign_info%ISOPEN THEN
12391 CLOSE cur_assign_info;
12392 END IF;
12393
12394 IF cur_status_code%ISOPEN THEN
12395 CLOSE cur_status_code;
12396 END IF;
12397
12398 IF cur_competence_details%ISOPEN THEN
12399 CLOSE cur_competence_details;
12400 END IF;
12401
12402 IF p_commit = FND_API.G_TRUE THEN
12403 ROLLBACK TO DELETE_REQU_COMPETENCE_SP;
12404 END IF;
12405
12406 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
12407 PA_INTERFACE_UTILS_PUB.GET_MESSAGES(
12408 p_encoded => FND_API.G_FALSE
12409 , p_msg_index => 1
12410 , p_msg_count => l_msg_count
12411 , p_msg_data => l_msg_data
12412 , p_data => l_data
12413 , p_msg_index_out => l_msg_index_out);
12414
12415 x_msg_data := l_data;
12416 x_msg_count := l_msg_count;
12417 ELSE
12418 x_msg_count := l_msg_count;
12419 END IF;
12420
12421 IF l_debug_mode = 'Y' THEN
12422 PA_DEBUG.reset_curr_function;
12423 END IF;
12424
12425 WHEN OTHERS THEN
12426
12427 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
12428 x_msg_data := SUBSTRB(SQLERRM,1,240);
12429
12430 IF l_debug_mode = 'Y' THEN
12431 pa_debug.write(l_module,'In Side Exception Block others ', l_debug_level);
12432 pa_debug.write(l_module,'Closing CURSORS if OPEN', l_debug_level);
12433 END IF ;
12434
12435 IF cur_assign_info%ISOPEN THEN
12436 CLOSE cur_assign_info;
12437 END IF;
12438
12439 IF cur_status_code%ISOPEN THEN
12440 CLOSE cur_status_code;
12441 END IF;
12442
12443 IF cur_competence_details%ISOPEN THEN
12444 CLOSE cur_competence_details;
12445 END IF;
12446
12447 IF p_commit = FND_API.G_TRUE THEN
12448 ROLLBACK TO DELETE_REQU_COMPETENCE_SP;
12449 END IF;
12450
12451 FND_MSG_PUB.ADD_EXC_MSG(
12452 p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
12453 , p_procedure_name => 'CREATE_REQUIREMENT_COMPETENCE'
12454 , p_error_text => x_msg_data);
12455
12456 x_msg_count := FND_MSG_PUB.count_msg;
12457
12458 IF l_debug_mode = 'Y' THEN
12459 PA_DEBUG.reset_curr_function;
12460 END IF;
12461
12462 RAISE;
12463
12464 END DELETE_REQUIREMENT_COMPETENCE;
12465
12466 -- Start of comments
12467 -- API name : CREATE_CANDIDATES
12468 -- Type : Public
12469 -- Pre-reqs : None.
12470 -- Function : This is a public API to create/nominate one or more candidates for
12471 -- project requirements.
12472 -- Usage : This API will be called from AMG.
12473 -- Parameters :
12474 -- IN : p_commit IN VARCHAR2
12475 -- Identifier to commit the transaction.
12476 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
12477 -- p_init_msg_list IN VARCHAR2
12478 -- Identifier to initialize the error message stack.
12479 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
12480 -- p_api_version_number IN NUMBER Required
12481 -- To be compliant with Applications API coding standards.
12482 -- p_candidate_in_tbl IN CANDIDATE_IN_TBL_TYPE Required
12483 -- Table of candidate records. Please see the CANDIDATE_IN_TBL_TYPE datatype table.
12484 -- OUT :
12485 -- x_candidate_id_tbl OUT SYSTEM.PA_NUM_TBL_TYPE
12486 -- Table to store the candidate ids created by the API.
12487 -- Reference : pa_candidates.candidate_id
12488 -- x_return_status OUT VARCHAR2
12489 -- Indicates the return status of the API.
12490 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
12491 -- x_msg_count OUT NUMBER
12492 -- Indicates the number of error messages in the message stack
12493 -- x_msg_data OUT VARCHAR2
12494 -- Indicates the error message text if only one error exists
12495 -- History :
12496 -- 01-Mar-2006 - msachan - Created
12497 -- End of comments
12498 PROCEDURE CREATE_CANDIDATES
12499 (
12500 p_commit IN VARCHAR2 := FND_API.G_FALSE
12501 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
12502 , p_api_version_number IN NUMBER := 1.0
12503 , p_candidate_in_tbl IN CANDIDATE_IN_TBL_TYPE
12504 , x_candidate_id_tbl OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE
12505 , x_return_status OUT NOCOPY VARCHAR2
12506 , x_msg_count OUT NOCOPY NUMBER
12507 , x_msg_data OUT NOCOPY VARCHAR2
12508 )
12509 IS
12510 l_debug_mode VARCHAR2(1);
12511 l_module VARCHAR2(100) := 'PA_CANDIDATE_AMG_PUB.CREATE_CANDIDATES';
12512 l_calling_application VARCHAR2(10) := 'PLSQL';
12513 l_calling_module VARCHAR2(10) := 'AMG';
12514 l_check_id_flag VARCHAR2(1) := 'Y';
12515 l_check_role_security_flag VARCHAR2(1) := 'Y';
12516 l_check_resource_security_flag VARCHAR2(1) := 'Y';
12517 l_log_level NUMBER := 3;
12518
12519 i NUMBER;
12520 l_missing_params VARCHAR2(1000);
12521 l_project_system_status_code VARCHAR2(30);
12522 l_error_flag_local VARCHAR2(1) := 'N';
12523 l_error_flag VARCHAR2(1) := 'N';
12524 l_start_msg_count NUMBER := 0;
12525 l_end_msg_count NUMBER := 0;
12526 l_loop_msg_count NUMBER := 0;
12527 l_candidate_in_rec CANDIDATE_IN_REC_TYPE;
12528 l_project_id NUMBER;
12529 l_privilege VARCHAR2(30);
12530 l_object_name VARCHAR2(30);
12531 l_object_key NUMBER;
12532 l_resource_valid VARCHAR2(1) := 'N';
12533 l_privilege_name VARCHAR2(40) := null;
12534 l_project_super_user VARCHAR2(1) := 'N';
12535 l_ret_code VARCHAR2(1);
12536 l_person_id NUMBER;
12537 l_logged_person_id NUMBER;
12538 l_asmt_start_date DATE;
12539 l_resource_start_date DATE;
12540 l_resource_end_date DATE;
12541 l_requirement_start_date DATE;
12542 l_requirement_end_date DATE;
12543 l_status_code VARCHAR2(30);
12544 l_system_status_code VARCHAR2(30);
12545 l_mass_wf_in_progress_flag VARCHAR2(1);
12546 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
12547 l_msg_count NUMBER;
12548 l_msg_data VARCHAR2(2000);
12549 l_msg_index_out NUMBER;
12550 l_data VARCHAR2(2000);
12551
12552 CURSOR c_get_requirement_info(c_assignment_id NUMBER) IS
12553 SELECT project_id, start_date, status_code, mass_wf_in_progress_flag
12554 FROM pa_project_assignments
12555 WHERE assignment_id = c_assignment_id
12556 AND assignment_type = 'OPEN_ASSIGNMENT';
12557
12558 CURSOR c_get_system_status_code(c_status_code VARCHAR2, c_status_type VARCHAR2) IS
12559 SELECT project_system_status_code
12560 FROM pa_project_statuses
12561 WHERE trunc(SYSDATE) BETWEEN start_date_active AND nvl(end_date_active, trunc(SYSDATE))
12562 AND status_type = c_status_type
12563 AND project_status_code = c_status_code;
12564
12565 CURSOR c_get_resource_info(c_resource_id NUMBER) IS
12566 SELECT resource_source_id
12567 FROM pa_c_elig_resource_v
12568 WHERE resource_id = c_resource_id;
12569
12570 CURSOR c_get_person_id(c_user_id NUMBER) IS
12571 SELECT employee_id
12572 FROM fnd_user
12573 WHERE user_id = c_user_id;
12574
12575 CURSOR c_get_candidate_id(c_assignment_id NUMBER, c_resource_id NUMBER) IS
12576 SELECT candidate_id
12577 FROM pa_candidates
12578 WHERE assignment_id = c_assignment_id
12579 AND resource_id = c_resource_id;
12580
12581 BEGIN
12582
12583 --Flows which are supported by this API
12584 ---------------------------------------
12585 --1. Creating candidates for given open requirements.
12586 -- 1.1 Validating requirement_id
12587 -- 1.2 Validating resource_id if it is not null
12588 -- 1.3 Validating status_code to be a valid code
12589 -- 1.3 Given requirement id and either of resource_id or person_id, a candidate is created for that open requirement
12590 -- 1.4 Returning table return the candidate_id of the candidates created.
12591 --Flows which are not supported by this API
12592 -------------------------------------------
12593 --1. Validating person_id is not done in this api. It is handled by the called public api.
12594
12595 x_return_status := FND_API.G_RET_STS_SUCCESS;
12596 x_candidate_id_tbl := SYSTEM.PA_NUM_TBL_TYPE();
12597
12598 l_debug_mode := NVL(FND_PROFILE.value_specific('PA_DEBUG_MODE', fnd_global.user_id, fnd_global.login_id, 275, null, null), 'N');
12599
12600 IF l_debug_mode = 'Y' THEN
12601 PA_DEBUG.set_curr_function(p_function => 'CREATE_CANDIDATES', p_debug_mode => l_debug_mode);
12602 END IF;
12603
12604 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list,FND_API.G_TRUE)) THEN
12605 FND_MSG_PUB.initialize;
12606 END IF;
12607
12608 IF p_commit = FND_API.G_TRUE THEN
12609 savepoint CREATE_CANDIDATES_SP;
12610 END IF;
12611
12612 IF l_debug_mode = 'Y' THEN
12613 pa_debug.write(l_module, 'Start of CREATE_CANDIDATES', l_log_level);
12614 END IF;
12615
12616 IF l_debug_mode = 'Y' THEN
12617 pa_debug.write(l_module, 'Printing Input Parameters......', l_log_level);
12618 pa_debug.write(l_module, 'p_commit '||p_commit, l_log_level);
12619 pa_debug.write(l_module, 'p_init_msg_list '||p_init_msg_list, l_log_level);
12620 pa_debug.write(l_module, 'p_api_version_number '||p_api_version_number, l_log_level);
12621 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
12622 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
12623 i := p_candidate_in_tbl.first;
12624 WHILE i IS NOT NULL LOOP
12625 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').candidate_id '||p_candidate_in_tbl(i).candidate_id, l_log_level);
12626 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').requirement_id '||p_candidate_in_tbl(i).requirement_id, l_log_level);
12627 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').resource_id '||p_candidate_in_tbl(i).resource_id, l_log_level);
12628 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').person_id '||p_candidate_in_tbl(i).person_id, l_log_level);
12629 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').status_code '||p_candidate_in_tbl(i).status_code, l_log_level);
12630 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').nomination_comments '||p_candidate_in_tbl(i).nomination_comments, l_log_level);
12631 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').ranking '||p_candidate_in_tbl(i).ranking, l_log_level);
12632 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').change_reason_code '||p_candidate_in_tbl(i).change_reason_code, l_log_level);
12633 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').record_version_number '||p_candidate_in_tbl(i).record_version_number, l_log_level);
12634 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
12635 i := p_candidate_in_tbl.next(i);
12636 END LOOP;
12637 END IF;
12638
12639 PA_STARTUP.INITIALIZE(
12640 p_calling_application => l_calling_application
12641 , p_calling_module => l_calling_module
12642 , p_check_id_flag => l_check_id_flag
12643 , p_check_role_security_flag => l_check_role_security_flag
12644 , p_check_resource_security_flag => l_check_resource_security_flag
12645 , p_debug_level => l_log_level
12646 );
12647
12648 IF l_debug_mode = 'Y' THEN
12649 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
12650 END IF;
12651
12652 --l_prm_license_flag := nvl(FND_PROFILE.VALUE('PA_PRM_LICENSED'),'N');
12653 --IF l_prm_license_flag <> 'Y' THEN
12654 -- null;
12655 --END IF;
12656
12657 l_project_super_user := FND_PROFILE.value_specific('PA_SUPER_PROJECT',fnd_global.user_id,fnd_global.login_id,275,null,null);
12658
12659 i := p_candidate_in_tbl.first;
12660
12661 WHILE i is not NULL LOOP
12662
12663 l_missing_params := null;
12664 l_error_flag_local := 'N';
12665 l_start_msg_count := FND_MSG_PUB.count_msg;
12666
12667 l_candidate_in_rec := p_candidate_in_tbl(i);
12668
12669 IF l_debug_mode = 'Y' THEN
12670 pa_debug.write(l_module, 'Record#'||i, l_log_level);
12671 pa_debug.write(l_module, '---------------------------------------------------------', l_log_level);
12672 pa_debug.write(l_module, 'Inside while loop. Blanking out the parameters not passed', l_log_level);
12673 END IF;
12674
12675 -- Blank Out Parameters if not passed
12676 -------------------------------------
12677 IF l_candidate_in_rec.requirement_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
12678 l_candidate_in_rec.requirement_id := null;
12679 END IF;
12680
12681 IF l_candidate_in_rec.resource_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
12682 l_candidate_in_rec.resource_id := null;
12683 END IF;
12684
12685 IF l_candidate_in_rec.person_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
12686 l_candidate_in_rec.person_id := null;
12687 END IF;
12688
12689 IF l_candidate_in_rec.status_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
12690 l_candidate_in_rec.status_code := 107; -- Default to Pending Review
12691 END IF;
12692
12693 IF l_candidate_in_rec.nomination_comments = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
12694 l_candidate_in_rec.nomination_comments := null;
12695 END IF;
12696
12697 -- Null out the parameters which are not required in create flow
12698 l_candidate_in_rec.candidate_id := null;
12699 l_candidate_in_rec.ranking := null;
12700 l_candidate_in_rec.change_reason_code := null;
12701 l_candidate_in_rec.record_version_number := null;
12702
12703 IF l_debug_mode = 'Y' THEN
12704 pa_debug.write(l_module, 'Blanking out missing and not required parameters over.', l_log_level);
12705 pa_debug.write(l_module, 'Mandatory parameters validation begin.', l_log_level);
12706 END IF;
12707
12708 -- Mandatory Parameters Check
12709 -----------------------------
12710 IF l_candidate_in_rec.requirement_id IS NULL THEN
12711 l_missing_params := l_missing_params||', REQUIREMENT_ID';
12712 ELSE
12713 -- Check for requirement id valid and assignment type OPEN_ASSIGNMENT
12714 l_status_code := null;
12715 l_mass_wf_in_progress_flag := null;
12716 l_system_status_code := null;
12717
12718 OPEN c_get_requirement_info(l_candidate_in_rec.requirement_id);
12719 FETCH c_get_requirement_info INTO l_project_id, l_requirement_start_date, l_status_code, l_mass_wf_in_progress_flag;
12720 IF c_get_requirement_info%NOTFOUND IS NULL THEN
12721 l_missing_params := l_missing_params||', REQUIREMENT_ID';
12722 ELSE
12723 l_system_status_code := null;
12724 OPEN c_get_system_status_code(l_status_code, 'OPEN_ASGMT');
12725 FETCH c_get_system_status_code INTO l_system_status_code;
12726 CLOSE c_get_system_status_code;
12727
12728 IF l_system_status_code IN ('OPEN_ASGMT_FILLED','OPEN_ASGMT_CANCEL') THEN
12729 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_STS_ACT_NOT_ALLW');
12730 l_error_flag_local := 'Y';
12731 END IF;
12732
12733 IF nvl(l_mass_wf_in_progress_flag, 'N') = 'Y' THEN
12734 PA_UTILS.ADD_MESSAGE('PA', 'PA_ASSIGNMENT_WF');
12735 l_error_flag_local := 'Y';
12736 END IF;
12737 END IF;
12738 CLOSE c_get_requirement_info;
12739 END IF;
12740
12741 IF l_candidate_in_rec.resource_id IS NULL AND l_candidate_in_rec.person_id IS NULL THEN
12742 l_missing_params := l_missing_params||', RESOURCE_ID, PERSON_ID';
12743 END IF;
12744
12745 IF l_candidate_in_rec.status_code IS NOT NULL THEN
12746 l_project_system_status_code := null;
12747 OPEN c_get_system_status_code(l_candidate_in_rec.status_code, 'CANDIDATE');
12748 FETCH c_get_system_status_code INTO l_project_system_status_code;
12749 CLOSE c_get_system_status_code;
12750 IF l_project_system_status_code IS NULL OR l_project_system_status_code NOT IN ('CANDIDATE_PENDING_REVIEW', 'CANDIDATE_UNDER_REVIEW', 'CANDIDATE_SUITABLE') THEN
12751 l_missing_params := l_missing_params||', STATUS_CODE';
12752 END IF;
12753 END IF;
12754
12755 IF l_debug_mode = 'Y' THEN
12756 pa_debug.write(l_module, 'Mandatory parameter validation over. l_missing_params='||l_missing_params, l_log_level);
12757 END IF;
12758
12759 IF l_missing_params IS NOT NULL THEN
12760 l_error_flag_local := 'Y';
12761 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
12762 'INVALID_PARAMS', l_missing_params);
12763 END IF;
12764
12765
12766 -- Validate resource id and/or person id
12767 ----------------------------------------
12768 IF l_error_flag_local <> 'Y' THEN
12769 IF l_candidate_in_rec.resource_id IS NOT NULL THEN
12770 OPEN c_get_resource_info(l_candidate_in_rec.resource_id);
12771 FETCH c_get_resource_info INTO l_person_id;
12772 IF c_get_resource_info%NOTFOUND IS NULL THEN
12773 l_error_flag_local := 'Y';
12774 PA_UTILS.ADD_MESSAGE ( p_app_short_name => 'PA'
12775 ,p_msg_name => 'PA_RESOURCE_INVALID_AMBIGUOUS' );
12776 END IF;
12777 CLOSE c_get_resource_info;
12778 ELSIF l_candidate_in_rec.person_id IS NOT NULL THEN
12779 l_person_id := l_candidate_in_rec.person_id;
12780 ELSE
12781 l_error_flag_local := 'Y';
12782 END IF;
12783 END IF;
12784
12785 -- Security Check
12786 -----------------
12787 -- Check PA_CREATE_CANDIDATES privilege on PA_PROJECTS and PA_PROJECT_ASSIGNMENTS as done in AddCandidatesTopCO.java
12788 IF l_error_flag_local <> 'Y' THEN
12789
12790 IF l_debug_mode = 'Y' THEN
12791 pa_debug.write(l_module, 'Checking PA_CREATE_CANDIDATES privilege on PA_PROJECTS and PA_PROJECT_ASSIGNMENTS for record#'||i, l_log_level);
12792 END IF;
12793
12794 l_privilege := 'PA_CREATE_CANDIDATES';
12795 l_object_name := 'PA_PROJECTS';
12796 l_object_key := l_project_id;
12797
12798 l_return_status := FND_API.G_RET_STS_SUCCESS;
12799 l_ret_code := 'T';
12800
12801 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
12802 x_ret_code => l_ret_code
12803 , x_return_status => l_return_status
12804 , x_msg_count => l_msg_count
12805 , x_msg_data => l_msg_data
12806 , p_privilege => l_privilege
12807 , p_object_name => l_object_name
12808 , p_object_key => l_object_key
12809 , p_init_msg_list => FND_API.G_FALSE);
12810
12811 IF nvl(l_ret_code, 'F') = 'F' AND l_return_status = FND_API.G_RET_STS_SUCCESS THEN
12812 l_privilege := 'PA_CREATE_CANDIDATES';
12813 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
12814 l_object_key := l_candidate_in_rec.requirement_id;
12815
12816 l_return_status := FND_API.G_RET_STS_SUCCESS;
12817 l_ret_code := 'T';
12818
12819 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
12820 x_ret_code => l_ret_code
12821 , x_return_status => l_return_status
12822 , x_msg_count => l_msg_count
12823 , x_msg_data => l_msg_data
12824 , p_privilege => l_privilege
12825 , p_object_name => l_object_name
12826 , p_object_key => l_object_key
12827 , p_init_msg_list => FND_API.G_FALSE);
12828 END IF;
12829 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
12830 -- This message does not have token defined, but intentionally putting token
12831 -- bcoz we still want to show the privielge name which is missing
12832 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_ADD_CAND'
12833 ,'MISSING_PRIVILEGE', l_privilege);
12834 l_error_flag_local := 'Y';
12835 END IF;
12836
12837 IF l_debug_mode = 'Y' THEN
12838 pa_debug.write(l_module, 'Security check complete for record#'||i||' privilege '||l_ret_code, l_log_level);
12839 END IF;
12840
12841 END IF;
12842
12843 -- Check whether the user has resource authority over nominee
12844 -------------------------------------------------------------
12845 IF l_project_super_user <> 'Y' AND l_error_flag_local <> 'Y' AND l_candidate_in_rec.resource_id IS NOT NULL THEN
12846
12847 IF l_debug_mode = 'Y' THEN
12848 pa_debug.write(l_module, 'If not project super user then check for confirmed assignment', l_log_level);
12849 END IF;
12850
12851 OPEN c_get_person_id(FND_GLOBAL.USER_ID);
12852 FETCH c_get_person_id INTO l_logged_person_id;
12853 CLOSE c_get_person_id;
12854
12855 IF l_logged_person_id <> l_person_id THEN
12856 l_privilege_name := 'PA_NOMINATE_CANDIDATES';
12857 ELSE l_privilege_name := 'PA_NOMINATE_SELF_AS_CANDIDATE';
12858 END IF;
12859
12860 PA_SECURITY_PVT.CHECK_CONFIRM_ASMT(p_project_id => -999,
12861 p_resource_id => l_candidate_in_rec.resource_id,
12862 p_resource_name => null,
12863 p_privilege => l_privilege_name,
12864 p_start_date => l_requirement_start_date,
12865 x_ret_code => l_ret_code,
12866 x_return_status => l_return_status,
12867 x_msg_count => l_msg_count,
12868 x_msg_data => l_msg_data);
12869
12870 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
12871 l_error_flag_local := 'Y';
12872 PA_UTILS.ADD_MESSAGE ( p_app_short_name => 'PA'
12873 ,p_msg_name => 'PA_NO_RESOURCE_AUTHORITY' );
12874 END IF;
12875
12876 IF l_debug_mode = 'Y' THEN
12877 pa_debug.write(l_module, 'After call of PA_SECURITY_PVT.CHECK_CONFIRM_ASMT', l_log_level);
12878 END IF;
12879
12880 END IF;
12881
12882 IF l_error_flag_local <> 'Y' THEN
12883 -- Core API call
12884 IF l_debug_mode = 'Y' THEN
12885 pa_debug.write(l_module, 'Calling core API PA_CANDIDATE_PUB.ADD_CANDIDATE', l_log_level);
12886 END IF;
12887
12888 PA_CANDIDATE_PUB.ADD_CANDIDATE(
12889 p_assignment_id => l_candidate_in_rec.requirement_id,
12890 p_resource_name => null,
12891 -- p_resource_id => l_candidate_in_rec.resource_id,
12892 -- for bug#8280206. resource id should be passed as null from create AMG API
12893 p_resource_id => null,
12894 p_status_code => l_candidate_in_rec.status_code,
12895 p_nomination_comments => l_candidate_in_rec.nomination_comments,
12896 p_person_id => l_person_id,
12897 p_privilege_name => l_privilege_name,
12898 p_project_super_user => l_project_super_user,
12899 p_init_msg_list => FND_API.G_FALSE,
12900 -- Added for bug 9187892
12901 p_attribute_category => l_candidate_in_rec.attribute_category,
12902 p_attribute1 => l_candidate_in_rec.attribute1,
12903 p_attribute2 => l_candidate_in_rec.attribute2,
12904 p_attribute3 => l_candidate_in_rec.attribute3,
12905 p_attribute4 => l_candidate_in_rec.attribute4,
12906 p_attribute5 => l_candidate_in_rec.attribute5,
12907 p_attribute6 => l_candidate_in_rec.attribute6,
12908 p_attribute7 => l_candidate_in_rec.attribute7,
12909 p_attribute8 => l_candidate_in_rec.attribute8,
12910 p_attribute9 => l_candidate_in_rec.attribute9,
12911 p_attribute10 => l_candidate_in_rec.attribute10,
12912 p_attribute11 => l_candidate_in_rec.attribute11,
12913 p_attribute12 => l_candidate_in_rec.attribute12,
12914 p_attribute13 => l_candidate_in_rec.attribute13,
12915 p_attribute14 => l_candidate_in_rec.attribute14,
12916 p_attribute15 => l_candidate_in_rec.attribute15,
12917 x_return_status => l_return_status,
12918 x_msg_count => l_msg_count,
12919 x_msg_data => l_msg_data);
12920 IF l_debug_mode = 'Y' THEN
12921 pa_debug.write(l_module, 'After call PA_CANDIDATE_PUB.ADD_CANDIDATE l_return_status='||l_return_status, l_log_level);
12922 END IF;
12923 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
12924 x_candidate_id_tbl.extend(1);
12925 OPEN c_get_candidate_id(l_candidate_in_rec.requirement_id, l_candidate_in_rec.resource_id);
12926 FETCH c_get_candidate_id INTO x_candidate_id_tbl(x_candidate_id_tbl.COUNT);
12927 CLOSE c_get_candidate_id;
12928 ELSE
12929 l_error_flag_local := 'Y';
12930 x_candidate_id_tbl.extend(1);
12931 x_candidate_id_tbl(x_candidate_id_tbl.COUNT) := -1;
12932 END IF;
12933 ELSE
12934 x_candidate_id_tbl.extend(1);
12935 x_candidate_id_tbl(x_candidate_id_tbl.COUNT) := -1;
12936 END IF;
12937
12938 l_end_msg_count := FND_MSG_PUB.count_msg;
12939 IF l_debug_mode = 'Y' THEN
12940 pa_debug.write(l_module, 'l_start_msg_count='||l_start_msg_count, l_log_level);
12941 pa_debug.write(l_module, 'l_end_msg_count='||l_end_msg_count, l_log_level);
12942 END IF;
12943 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
12944
12945 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
12946 l_error_flag := 'Y';
12947
12948 IF l_debug_mode = 'Y' THEN
12949 pa_debug.write(l_module, 'Repopulating Error Message Stack', l_log_level);
12950 END IF;
12951
12952 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
12953 -- Always get from first location in stack i.e. l_start_msg_count+1
12954 -- Because stack moves down after delete
12955 FND_MSG_PUB.get (
12956 p_msg_index => l_start_msg_count+1,
12957 p_encoded => FND_API.G_FALSE,
12958 p_data => l_data,
12959 p_msg_index_out => l_msg_index_out );
12960
12961 -- Always delete at first location in stack i.e. l_start_msg_count+1
12962 -- Because stack moves down after delete
12963 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
12964
12965 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
12966 'RECORD_NO', i,
12967 'MESSAGE', l_data);
12968 END LOOP;
12969
12970 IF l_debug_mode = 'Y' THEN
12971 pa_debug.write(l_module, 'After Repopulating Error Message Stack', l_log_level);
12972 END IF;
12973
12974 END IF;
12975 i := p_candidate_in_tbl.next(i);
12976 END LOOP;
12977
12978 IF l_debug_mode = 'Y' THEN
12979 pa_debug.write(l_module, 'All records are done', l_log_level);
12980 pa_debug.write(l_module, 'l_error_flag='||l_error_flag, l_log_level);
12981 pa_debug.write(l_module, 'FND_MSG_PUB.count_msg='||FND_MSG_PUB.count_msg, l_log_level);
12982 END IF;
12983
12984 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
12985 RAISE FND_API.G_EXC_ERROR;
12986 END IF;
12987
12988 IF l_debug_mode = 'Y' THEN
12989 Pa_Debug.reset_curr_function;
12990 END IF;
12991
12992 IF p_commit = FND_API.G_TRUE THEN
12993 commit;
12994 END IF;
12995
12996 EXCEPTION
12997
12998 WHEN FND_API.G_EXC_ERROR THEN
12999 x_return_status := FND_API.G_RET_STS_ERROR;
13000 l_msg_count := FND_MSG_PUB.count_msg;
13001
13002 IF c_get_requirement_info%ISOPEN THEN
13003 CLOSE c_get_requirement_info;
13004 END IF;
13005
13006 IF c_get_system_status_code%ISOPEN THEN
13007 CLOSE c_get_system_status_code;
13008 END IF;
13009
13010 IF c_get_resource_info%ISOPEN THEN
13011 CLOSE c_get_resource_info;
13012 END IF;
13013
13014 IF c_get_person_id%ISOPEN THEN
13015 CLOSE c_get_person_id;
13016 END IF;
13017
13018 IF c_get_candidate_id%ISOPEN THEN
13019 CLOSE c_get_candidate_id;
13020 END IF;
13021
13022 IF p_commit = FND_API.G_TRUE THEN
13023 ROLLBACK TO CREATE_CANDIDATES_SP;
13024 END IF;
13025
13026 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
13027 PA_INTERFACE_UTILS_PUB.get_messages
13028 ( p_encoded => FND_API.G_FALSE
13029 , p_msg_index => 1
13030 , p_msg_count => l_msg_count
13031 , p_msg_data => l_msg_data
13032 , p_data => l_data
13033 , p_msg_index_out => l_msg_index_out);
13034
13035 x_msg_data := l_data;
13036 x_msg_count := l_msg_count;
13037 ELSE
13038 x_msg_count := l_msg_count;
13039 END IF;
13040
13041 IF l_debug_mode = 'Y' THEN
13042 Pa_Debug.reset_curr_function;
13043 END IF;
13044
13045 WHEN OTHERS THEN
13046
13047 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
13048 x_msg_data := SUBSTRB(SQLERRM,1,240);
13049
13050 IF c_get_requirement_info%ISOPEN THEN
13051 CLOSE c_get_requirement_info;
13052 END IF;
13053
13054 IF c_get_system_status_code%ISOPEN THEN
13055 CLOSE c_get_system_status_code;
13056 END IF;
13057
13058 IF c_get_resource_info%ISOPEN THEN
13059 CLOSE c_get_resource_info;
13060 END IF;
13061
13062 IF c_get_person_id%ISOPEN THEN
13063 CLOSE c_get_person_id;
13064 END IF;
13065
13066 IF c_get_candidate_id%ISOPEN THEN
13067 CLOSE c_get_candidate_id;
13068 END IF;
13069
13070 IF p_commit = FND_API.G_TRUE THEN
13071 ROLLBACK TO CREATE_CANDIDATES_SP;
13072 END IF;
13073
13074 FND_MSG_PUB.add_exc_msg
13075 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
13076 , p_procedure_name => 'CREATE_CANDIDATES'
13077 , p_error_text => x_msg_data);
13078
13079 x_msg_count := FND_MSG_PUB.count_msg;
13080
13081 IF l_debug_mode = 'Y' THEN
13082 PA_DEBUG.reset_curr_function;
13083 END IF;
13084 RAISE;
13085
13086 END CREATE_CANDIDATES;
13087
13088 -- Start of comments
13089 -- API name : UPDATE_CANDIDATES
13090 -- Type : Public
13091 -- Pre-reqs : None.
13092 -- Function : This is a public API to update one or more candidates for project requirements.
13093 -- Usage : This API will be called from AMG.
13094 -- Parameters :
13095 -- IN : p_commit IN VARCHAR2
13096 -- Identifier to commit the transaction.
13097 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
13098 -- p_init_msg_list IN VARCHAR2
13099 -- Identifier to initialize the error message stack.
13100 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
13101 -- p_api_version_number IN NUMBER Required
13102 -- To be compliant with Applications API coding standards.
13103 -- p_candidate_in_tbl IN CANDIDATE_IN_TBL_TYPE Required
13104 -- Table of candidate records. Please see the CANDIDATE_IN_TBL_TYPE datatype table.
13105 -- OUT :
13106 -- x_return_status OUT VARCHAR2
13107 -- Indicates the return status of the API.
13108 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
13109 -- x_msg_count OUT NUMBER
13110 -- Indicates the number of error messages in the message stack
13111 -- x_msg_data OUT VARCHAR2
13112 -- Indicates the error message text if only one error exists
13113 -- History :
13114 -- 01-Mar-2006 - msachan - Created
13115 -- End of comments
13116 PROCEDURE UPDATE_CANDIDATES
13117 (
13118 p_commit IN VARCHAR2 := FND_API.G_FALSE
13119 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
13120 , p_api_version_number IN NUMBER := 1.0
13121 , p_candidate_in_tbl IN CANDIDATE_IN_TBL_TYPE
13122 , x_return_status OUT NOCOPY VARCHAR2
13123 , x_msg_count OUT NOCOPY NUMBER
13124 , x_msg_data OUT NOCOPY VARCHAR2
13125 )
13126 IS
13127 l_debug_mode VARCHAR2(1);
13128 l_module VARCHAR2(100) := 'PA_CANDIDATE_AMG_PUB.UPDATE_CANDIDATES';
13129 l_calling_application VARCHAR2(10) := 'PLSQL';
13130 l_calling_module VARCHAR2(10) := 'AMG';
13131 l_check_id_flag VARCHAR2(1) := 'Y';
13132 l_check_role_security_flag VARCHAR2(1) := 'Y';
13133 l_check_resource_security_flag VARCHAR2(1) := 'Y';
13134 l_log_level NUMBER := 3;
13135 i NUMBER;
13136 l_error_flag VARCHAR2(1) := 'N';
13137 l_error_flag_local VARCHAR2(1) := 'N';
13138 l_missing_params VARCHAR2(1000);
13139 l_candidate_in_rec CANDIDATE_IN_REC_TYPE;
13140 l_project_system_status_code VARCHAR2(30);
13141 l_project_id NUMBER;
13142 l_record_version_number NUMBER;
13143 l_start_msg_count NUMBER := 0;
13144 l_end_msg_count NUMBER := 0;
13145 l_loop_msg_count NUMBER := 0;
13146
13147 l_privilege VARCHAR2(30);
13148 l_object_name VARCHAR2(30);
13149 l_object_key NUMBER;
13150 l_resource_valid VARCHAR2(1) := 'N';
13151 l_privilege_name VARCHAR2(40) := null;
13152 l_ret_code VARCHAR2(1);
13153 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
13154 l_msg_count NUMBER;
13155 l_msg_data VARCHAR2(2000);
13156 l_msg_index_out NUMBER;
13157 l_data VARCHAR2(2000);
13158
13159 CURSOR c_get_system_status_code(c_status_code VARCHAR2) IS
13160 SELECT project_system_status_code FROM pa_project_statuses
13161 WHERE trunc(SYSDATE) BETWEEN start_date_active AND nvl(end_date_active, trunc(SYSDATE))
13162 AND status_type = 'CANDIDATE'
13163 AND project_status_code = c_status_code;
13164
13165 CURSOR c_get_requirement_info(c_assignment_id NUMBER) IS
13166 SELECT project_id
13167 FROM pa_project_assignments
13168 WHERE assignment_id = c_assignment_id
13169 AND assignment_type = 'OPEN_ASSIGNMENT';
13170
13171 CURSOR c_get_candidate_details(c_candidate_id NUMBER) IS
13172 SELECT candidate_id, status_code, candidate_ranking, record_version_number, assignment_id
13173 FROM pa_candidates
13174 WHERE candidate_id = c_candidate_id;
13175
13176 l_cand_rec c_get_candidate_details%ROWTYPE;
13177
13178 BEGIN
13179
13180 --Flows which are supported by this API
13181 ---------------------------------------
13182 --1. Updating candidate information
13183 -- 1.1 Validating candidate_id
13184 -- 1.2 Validating status_code to be a valid code
13185 -- 1.3 Only updatable attributes of candidates once created are status_code, ranking, record_version_number, change_reason_code
13186 --Flows which are not supported by this API
13187 -------------------------------------------
13188 --1. Validations like new status_code acceptable or not are done by underlying called apis.
13189
13190 x_return_status := FND_API.G_RET_STS_SUCCESS;
13191
13192 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE', fnd_global.user_id, fnd_global.login_id, 275, null, null), 'N');
13193
13194 IF l_debug_mode = 'Y' THEN
13195 PA_DEBUG.set_curr_function(p_function => 'UPDATE_CANDIDATES', p_debug_mode => l_debug_mode);
13196 END IF;
13197
13198 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list, FND_API.G_TRUE)) THEN
13199 FND_MSG_PUB.initialize;
13200 END IF;
13201
13202 IF p_commit = FND_API.G_TRUE THEN
13203 savepoint UPDATE_CANDIDATES_SP;
13204 END IF;
13205
13206 IF l_debug_mode = 'Y' THEN
13207 pa_debug.write(l_module, 'Start of UPDATE_CANDIDATES', l_log_level);
13208 pa_debug.write(l_module, 'Printing Input Parameters......', l_log_level);
13209 pa_debug.write(l_module, 'p_commit '||p_commit, l_log_level);
13210 pa_debug.write(l_module, 'p_init_msg_list '||p_init_msg_list, l_log_level);
13211 pa_debug.write(l_module, 'p_api_version_number '||p_api_version_number, l_log_level);
13212 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
13213 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
13214 i := p_candidate_in_tbl.first;
13215 WHILE i IS NOT NULL LOOP
13216 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').candidate_id '||p_candidate_in_tbl(i).candidate_id, l_log_level);
13217 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').requirement_id '||p_candidate_in_tbl(i).requirement_id, l_log_level);
13218 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').resource_id '||p_candidate_in_tbl(i).resource_id, l_log_level);
13219 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').person_id '||p_candidate_in_tbl(i).person_id, l_log_level);
13220 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').status_code '||p_candidate_in_tbl(i).status_code, l_log_level);
13221 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').nomination_comments '||p_candidate_in_tbl(i).nomination_comments, l_log_level);
13222 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').ranking '||p_candidate_in_tbl(i).ranking, l_log_level);
13223 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').change_reason_code '||p_candidate_in_tbl(i).change_reason_code, l_log_level);
13224 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').record_version_number '||p_candidate_in_tbl(i).record_version_number, l_log_level);
13225 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
13226 i := p_candidate_in_tbl.next(i);
13227 END LOOP;
13228 END IF;
13229
13230 PA_STARTUP.INITIALIZE(
13231 p_calling_application => l_calling_application
13232 , p_calling_module => l_calling_module
13233 , p_check_id_flag => l_check_id_flag
13234 , p_check_role_security_flag => l_check_role_security_flag
13235 , p_check_resource_security_flag => l_check_resource_security_flag
13236 , p_debug_level => l_log_level
13237 );
13238
13239 IF l_debug_mode = 'Y' THEN
13240 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
13241 END IF;
13242
13243 --l_prm_license_flag := nvl(FND_PROFILE.VALUE('PA_PRM_LICENSED'),'N');
13244 --IF l_prm_license_flag <> 'Y' THEN
13245 -- null;
13246 --END IF;
13247
13248 i := p_candidate_in_tbl.first;
13249
13250 WHILE i IS NOT NULL LOOP
13251 l_error_flag_local := 'N';
13252 l_missing_params := null;
13253 l_start_msg_count := FND_MSG_PUB.count_msg;
13254
13255 l_candidate_in_rec := p_candidate_in_tbl(i);
13256 l_cand_rec := null;
13257
13258 -- Mandatory Parameters Check
13259 IF l_debug_mode = 'Y' THEN
13260 pa_debug.write(l_module, 'Record#'||i, l_log_level);
13261 pa_debug.write(l_module, '-----------------------------', l_log_level);
13262 pa_debug.write(l_module, 'Inside while loop. Mandatory parameter check.', l_log_level);
13263 END IF;
13264
13265 -- Check on Candidate Id
13266 OPEN c_get_candidate_details(l_candidate_in_rec.candidate_id);
13267 FETCH c_get_candidate_details INTO l_cand_rec;
13268
13269 IF c_get_candidate_details%NOTFOUND THEN
13270 l_missing_params := l_missing_params||', CANDIDATE_ID';
13271 END IF;
13272
13273 CLOSE c_get_candidate_details;
13274
13275 -- Check on Status Code
13276 IF l_candidate_in_rec.status_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
13277 l_candidate_in_rec.status_code := l_cand_rec.status_code;
13278 ELSIF l_candidate_in_rec.status_code IS NOT NULL THEN
13279 l_project_system_status_code := null;
13280
13281 OPEN c_get_system_status_code(l_candidate_in_rec.status_code);
13282 FETCH c_get_system_status_code INTO l_project_system_status_code;
13283 CLOSE c_get_system_status_code;
13284
13285 IF l_project_system_status_code IS NULL OR l_project_system_status_code NOT IN
13286 ('CANDIDATE_DECLINED', 'CANDIDATE_PENDING_REVIEW', 'CANDIDATE_SUITABLE',
13287 'CANDIDATE_SYSTEM_NOMINATED', 'CANDIDATE_UNDER_REVIEW', 'CANDIDATE_WITHDRAWN') THEN
13288 l_missing_params := l_missing_params||', STATUS_CODE';
13289 END IF;
13290 END IF;
13291
13292 IF l_debug_mode = 'Y' THEN
13293 pa_debug.write(l_module, 'Mandatory parameter validation over. List of Missing Parameters='||l_missing_params, l_log_level);
13294 END IF;
13295
13296 IF l_missing_params IS NOT NULL THEN
13297 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
13298 'INVALID_PARAMS', l_missing_params);
13299 l_error_flag_local := 'Y';
13300 END IF;
13301
13302 IF l_error_flag_local <> 'Y' THEN
13303
13304 -- Nulling out the parameters which are not required and defaulting the required parameter from the database.
13305 l_candidate_in_rec.requirement_id := l_cand_rec.assignment_id;
13306 l_candidate_in_rec.resource_id := null;
13307 l_candidate_in_rec.person_id := null;
13308 l_candidate_in_rec.nomination_comments := null;
13309
13310 -- Retrieve values from data base if Parameters are not passed.
13311 IF l_debug_mode = 'Y' THEN
13312 pa_debug.write(l_module, 'Retrieving values from database if parameters are not passed.', l_log_level);
13313 END IF;
13314
13315 IF l_candidate_in_rec.ranking = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
13316 l_candidate_in_rec.ranking := l_cand_rec.candidate_ranking;
13317 END IF;
13318
13319 IF l_candidate_in_rec.record_version_number = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
13320 l_candidate_in_rec.record_version_number := l_cand_rec.record_version_number;
13321 END IF;
13322
13323 -- If Change Reason Code is not passed then use null
13324 IF l_candidate_in_rec.change_reason_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
13325 l_candidate_in_rec.change_reason_code := null;
13326 END IF;
13327
13328 IF l_debug_mode = 'Y' THEN
13329 pa_debug.write(l_module, 'Candidate Id = '||l_candidate_in_rec.candidate_id, l_log_level);
13330 pa_debug.write(l_module, '-----------------------------', l_log_level);
13331 pa_debug.write(l_module, 'Old Status Code = '||l_cand_rec.status_code, l_log_level);
13332 pa_debug.write(l_module, 'Old Ranking = '||l_cand_rec.candidate_ranking, l_log_level);
13333 pa_debug.write(l_module, 'Old Record Version Number = '||l_cand_rec.record_version_number, l_log_level);
13334 pa_debug.write(l_module, '-----------------------------', l_log_level);
13335 pa_debug.write(l_module, 'New Status Code = '||l_candidate_in_rec.status_code, l_log_level);
13336 pa_debug.write(l_module, 'New Ranking = '||l_candidate_in_rec.ranking, l_log_level);
13337 pa_debug.write(l_module, 'New Record Version Number = '||(l_candidate_in_rec.record_version_number+1), l_log_level);
13338 pa_debug.write(l_module, '-----------------------------', l_log_level);
13339 pa_debug.write(l_module, 'Change Reason Code = '||l_candidate_in_rec.change_reason_code, l_log_level);
13340 pa_debug.write(l_module, '-----------------------------', l_log_level);
13341 END IF;
13342
13343 -- Getting Project Id for security check
13344 OPEN c_get_requirement_info(l_candidate_in_rec.requirement_id);
13345 FETCH c_get_requirement_info INTO l_project_id;
13346 CLOSE c_get_requirement_info;
13347
13348 IF l_project_id IS NULL THEN -- Check for requirement id valid and assignment type OPEN_ASSIGNMENT
13349 l_error_flag_local := 'Y';
13350 l_missing_params := l_missing_params||', REQUIREMENT_ID';
13351 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
13352 'INVALID_PARAMS', l_missing_params);
13353 END IF;
13354
13355 END IF;
13356
13357 -- Security Check : Check PA_VIEW_CANDIDATES privilege on PA_PROJECTS and PA_PROJECT_ASSIGNMENTS as done in CandidatesTopCO.java
13358 -------------------
13359
13360 IF l_error_flag_local <> 'Y' THEN
13361
13362 IF l_debug_mode = 'Y' THEN
13363 pa_debug.write(l_module, 'Checking PA_VIEW_CANDIDATES privilege on PA_PROJECTS and PA_PROJECT_ASSIGNMENTS for record#'||i, l_log_level);
13364 END IF;
13365
13366 l_privilege := 'PA_VIEW_CANDIDATES';
13367
13368 l_object_name := 'PA_PROJECTS';
13369 l_object_key := l_project_id;
13370
13371 l_return_status := FND_API.G_RET_STS_SUCCESS;
13372 l_ret_code := 'T';
13373
13374 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
13375 x_ret_code => l_ret_code
13376 , x_return_status => l_return_status
13377 , x_msg_count => l_msg_count
13378 , x_msg_data => l_msg_data
13379 , p_privilege => l_privilege
13380 , p_object_name => l_object_name
13381 , p_object_key => l_object_key
13382 , p_init_msg_list => FND_API.G_FALSE);
13383
13384 IF nvl(l_ret_code, 'F') = 'F' AND l_return_status = FND_API.G_RET_STS_SUCCESS THEN
13385 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
13386 l_object_key := l_candidate_in_rec.requirement_id;
13387
13388 l_return_status := FND_API.G_RET_STS_SUCCESS;
13389 l_ret_code := 'T';
13390
13391 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
13392 x_ret_code => l_ret_code
13393 , x_return_status => l_return_status
13394 , x_msg_count => l_msg_count
13395 , x_msg_data => l_msg_data
13396 , p_privilege => l_privilege
13397 , p_object_name => l_object_name
13398 , p_object_key => l_object_key
13399 , p_init_msg_list => FND_API.G_FALSE);
13400 END IF;
13401 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
13402 -- This message does not have token defined, but intentionally putting token
13403 -- bcoz we still want to show the privielge name which is missing
13404 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_ADD_CAND'
13405 ,'MISSING_PRIVILEGE', l_privilege);
13406 l_error_flag_local := 'Y';
13407 END IF;
13408
13409 IF l_debug_mode = 'Y' THEN
13410 pa_debug.write(l_module, 'Security check complete for record#'||i||' privilege '||l_ret_code, l_log_level);
13411 END IF;
13412
13413 END IF;
13414
13415 -- Call Core Actual API
13416 -----------------------
13417
13418 IF l_error_flag_local <> 'Y' THEN
13419 l_return_status := FND_API.G_RET_STS_SUCCESS;
13420
13421 IF l_debug_mode = 'Y' THEN
13422 pa_debug.write(l_module, 'Calling PA_CANDIDATE_PUB.UPDATE_CANDIDATE for Record#'||i, l_log_level);
13423 END IF;
13424
13425 PA_CANDIDATE_PUB.UPDATE_CANDIDATE
13426 (
13427 p_candidate_id => l_candidate_in_rec.candidate_id
13428 , p_status_code => l_candidate_in_rec.status_code
13429 , p_ranking => l_candidate_in_rec.ranking
13430 , p_change_reason_code => l_candidate_in_rec.change_reason_code
13431 , p_record_version_number => l_candidate_in_rec.record_version_number
13432 , p_init_msg_list => FND_API.G_FALSE
13433 , p_validate_status => FND_API.G_TRUE
13434 -- Added for bug 9187892
13435 , p_attribute_category => l_candidate_in_rec.attribute_category
13436 , p_attribute1 => l_candidate_in_rec.attribute1
13437 , p_attribute2 => l_candidate_in_rec.attribute2
13438 , p_attribute3 => l_candidate_in_rec.attribute3
13439 , p_attribute4 => l_candidate_in_rec.attribute4
13440 , p_attribute5 => l_candidate_in_rec.attribute5
13441 , p_attribute6 => l_candidate_in_rec.attribute6
13442 , p_attribute7 => l_candidate_in_rec.attribute7
13443 , p_attribute8 => l_candidate_in_rec.attribute8
13444 , p_attribute9 => l_candidate_in_rec.attribute9
13445 , p_attribute10 => l_candidate_in_rec.attribute10
13446 , p_attribute11 => l_candidate_in_rec.attribute11
13447 , p_attribute12 => l_candidate_in_rec.attribute12
13448 , p_attribute13 => l_candidate_in_rec.attribute13
13449 , p_attribute14 => l_candidate_in_rec.attribute14
13450 , p_attribute15 => l_candidate_in_rec.attribute15
13451 , x_record_version_number => l_record_version_number
13452 , x_msg_count => l_msg_count
13453 , x_msg_data => l_msg_data
13454 , x_return_status => l_return_status
13455 );
13456
13457 IF l_debug_mode = 'Y' THEN
13458 pa_debug.write(l_module, 'After call PA_CANDIDATE_PUB.UPDATE_CANDIDATE l_return_status='||l_return_status, l_log_level);
13459 END IF;
13460
13461 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
13462 l_error_flag_local := 'Y';
13463 IF l_debug_mode = 'Y' THEN
13464 pa_debug.write(l_module, 'PA_CANDIDATE_PUB.UPDATE_CANDIDATE unsuccessful', l_log_level);
13465 END IF;
13466 ELSE
13467 IF l_debug_mode = 'Y' THEN
13468 pa_debug.write(l_module, 'PA_CANDIDATE_PUB.UPDATE_CANDIDATE successful', l_log_level);
13469 pa_debug.write(l_module, 'Updated record_version_number = '||l_record_version_number, l_log_level);
13470 END IF;
13471 END IF;
13472 END IF;
13473
13474 l_end_msg_count := FND_MSG_PUB.count_msg;
13475 IF l_debug_mode = 'Y' THEN
13476 pa_debug.write(l_module, 'l_start_msg_count='||l_start_msg_count, l_log_level);
13477 pa_debug.write(l_module, 'l_end_msg_count='||l_end_msg_count, l_log_level);
13478 END IF;
13479 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
13480
13481 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
13482 l_error_flag := 'Y';
13483
13484 IF l_debug_mode = 'Y' THEN
13485 pa_debug.write(l_module, 'Repopulating Error Message Stack', l_log_level);
13486 END IF;
13487
13488 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
13489 -- Always get from first location in stack i.e. l_start_msg_count+1
13490 -- Because stack moves down after delete
13491 FND_MSG_PUB.get (
13492 p_msg_index => l_start_msg_count+1,
13493 p_encoded => FND_API.G_FALSE,
13494 p_data => l_data,
13495 p_msg_index_out => l_msg_index_out );
13496
13497 -- Always delete at first location in stack i.e. l_start_msg_count+1
13498 -- Because stack moves down after delete
13499 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
13500
13501 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
13502 'RECORD_NO', i,
13503 'MESSAGE', l_data);
13504 END LOOP;
13505
13506 IF l_debug_mode = 'Y' THEN
13507 pa_debug.write(l_module, 'After Repopulating Error Message Stack', l_log_level);
13508 END IF;
13509
13510 END IF;
13511 i := p_candidate_in_tbl.next(i);
13512 END LOOP;
13513
13514 IF l_debug_mode = 'Y' THEN
13515 pa_debug.write(l_module, 'All records are done', l_log_level);
13516 pa_debug.write(l_module, 'l_error_flag='||l_error_flag, l_log_level);
13517 pa_debug.write(l_module, 'FND_MSG_PUB.count_msg='||FND_MSG_PUB.count_msg, l_log_level);
13518 END IF;
13519
13520 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
13521 RAISE FND_API.G_EXC_ERROR;
13522 END IF;
13523
13524 IF l_debug_mode = 'Y' THEN
13525 PA_DEBUG.reset_curr_function;
13526 END IF;
13527
13528 IF p_commit = FND_API.G_TRUE THEN
13529 commit;
13530 END IF;
13531
13532 EXCEPTION
13533
13534 WHEN FND_API.G_EXC_ERROR THEN
13535
13536 x_return_status := FND_API.G_RET_STS_ERROR;
13537 l_msg_count := FND_MSG_PUB.count_msg;
13538
13539 IF c_get_candidate_details%ISOPEN THEN
13540 CLOSE c_get_candidate_details;
13541 END IF;
13542
13543 IF p_commit = FND_API.G_TRUE THEN
13544 ROLLBACK TO UPDATE_CANDIDATES_SP;
13545 END IF;
13546
13547 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
13548 PA_INTERFACE_UTILS_PUB.get_messages
13549 ( p_encoded => FND_API.G_FALSE
13550 , p_msg_index => 1
13551 , p_msg_count => l_msg_count
13552 , p_msg_data => l_msg_data
13553 , p_data => l_data
13554 , p_msg_index_out => l_msg_index_out);
13555
13556 x_msg_data := l_data;
13557 x_msg_count := l_msg_count;
13558 ELSE
13559 x_msg_count := l_msg_count;
13560 END IF;
13561
13562 IF l_debug_mode = 'Y' THEN
13563 Pa_Debug.reset_curr_function;
13564 END IF;
13565
13566 WHEN OTHERS THEN
13567
13568 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
13569 x_msg_data := SUBSTRB(SQLERRM,1,240);
13570
13571 IF c_get_candidate_details%ISOPEN THEN
13572 CLOSE c_get_candidate_details;
13573 END IF;
13574
13575 IF p_commit = FND_API.G_TRUE THEN
13576 ROLLBACK TO UPDATE_CANDIDATES_SP;
13577 END IF;
13578
13579 FND_MSG_PUB.add_exc_msg
13580 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
13581 , p_procedure_name => 'UPDATE_CANDIDATES'
13582 , p_error_text => x_msg_data);
13583
13584 x_msg_count := FND_MSG_PUB.count_msg;
13585
13586 IF l_debug_mode = 'Y' THEN
13587 PA_DEBUG.reset_curr_function;
13588 END IF;
13589 RAISE;
13590
13591 END UPDATE_CANDIDATES;
13592
13593 -- Start of comments
13594 -- API name : DELETE_CANDIDATES
13595 -- Type : Public
13596 -- Pre-reqs : None.
13597 -- Function : This is a public API to delete one or more candidates for project requirements.
13598 -- Usage : This API will be called from AMG.
13599 -- Parameters :
13600 -- IN : p_commit IN VARCHAR2
13601 -- Identifier to commit the transaction.
13602 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
13603 -- p_init_msg_list IN VARCHAR2
13604 -- Identifier to initialize the error message stack.
13605 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
13606 -- p_api_version_number IN NUMBER Required
13607 -- To be compliant with Applications API coding standards.
13608 -- p_candidate_in_tbl IN CANDIDATE_IN_TBL_TYPE Required
13609 -- Table of candidate records. Please see the CANDIDATE_IN_TBL_TYPE datatype table.
13610 -- OUT :
13611 -- x_return_status OUT VARCHAR2
13612 -- Indicates the return status of the API.
13613 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
13614 -- x_msg_count OUT NUMBER
13615 -- Indicates the number of error messages in the message stack
13616 -- x_msg_data OUT VARCHAR2
13617 -- Indicates the error message text if only one error exists
13618 -- History :
13619 -- 01-Mar-2006 - msachan - Created
13620 -- End of comments
13621 PROCEDURE DELETE_CANDIDATES
13622 (
13623 p_commit IN VARCHAR2 := FND_API.G_FALSE
13624 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
13625 , p_api_version_number IN NUMBER := 1.0
13626 , p_candidate_in_tbl IN CANDIDATE_IN_TBL_TYPE
13627 , x_return_status OUT NOCOPY VARCHAR2
13628 , x_msg_count OUT NOCOPY NUMBER
13629 , x_msg_data OUT NOCOPY VARCHAR2
13630 )
13631 IS
13632 l_debug_mode VARCHAR2(1);
13633 l_module VARCHAR2(100) := 'PA_CANDIDATE_AMG_PUB.DELETE_CANDIDATES';
13634 i NUMBER;
13635 l_log_level NUMBER := 3;
13636 l_calling_application VARCHAR2(10) := 'PLSQL';
13637 l_calling_module VARCHAR2(10) := 'AMG';
13638 l_check_id_flag VARCHAR2(1) := 'Y';
13639 l_check_role_security_flag VARCHAR2(1) := 'Y';
13640 l_check_resource_security_flag VARCHAR2(1) := 'Y';
13641 l_error_flag_local VARCHAR2(1) := 'N';
13642 l_error_flag VARCHAR2(1) := 'N';
13643 l_missing_params VARCHAR2(1000);
13644 l_start_msg_count NUMBER := 0;
13645 l_end_msg_count NUMBER := 0;
13646 l_loop_msg_count NUMBER := 0;
13647
13648 l_candidate_in_rec CANDIDATE_IN_REC_TYPE;
13649 l_project_id NUMBER;
13650 l_record_version_number NUMBER;
13651
13652 l_privilege VARCHAR2(30);
13653 l_object_name VARCHAR2(30);
13654 l_object_key NUMBER;
13655 l_resource_valid VARCHAR2(1) := 'N';
13656 l_privilege_name VARCHAR2(40) := null;
13657 l_ret_code VARCHAR2(1);
13658 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
13659 l_msg_count NUMBER;
13660 l_msg_data VARCHAR2(2000);
13661 l_msg_index_out NUMBER;
13662 l_data VARCHAR2(2000);
13663
13664 CURSOR c_get_requirement_info(c_assignment_id NUMBER) IS
13665 SELECT project_id, record_version_number
13666 FROM pa_project_assignments
13667 WHERE assignment_id = c_assignment_id
13668 AND assignment_type = 'OPEN_ASSIGNMENT';
13669
13670 BEGIN
13671
13672 --Flows which are supported by this API
13673 ---------------------------------------
13674 --1. Deleting all the candidates for a given open requirement
13675 -- 1.1 Validating requirement_id
13676 -- 1.2 Deleting all candidates for the given requirement_id
13677 -- 1.3 Changing no_of_active_candidates for the given requirement_id to zero after deleting all the candidates.
13678 --Flows which are not supported by this API
13679 -------------------------------------------
13680 --1. Validations like whether candidates can be deleted after once being confirmed are left for the underlying apis to handle.
13681 --2. Either all or none of the candidates would be deleted for the specified requirement_id.
13682
13683 x_return_status := FND_API.G_RET_STS_SUCCESS;
13684
13685 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE', fnd_global.user_id, fnd_global.login_id, 275, null, null), 'N');
13686
13687 IF l_debug_mode = 'Y' THEN
13688 PA_DEBUG.set_curr_function(p_function => 'DELETE_CANDIDATES', p_debug_mode => l_debug_mode);
13689 END IF;
13690
13691 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list, FND_API.G_TRUE)) THEN
13692 FND_MSG_PUB.initialize;
13693 END IF;
13694
13695 IF p_commit = FND_API.G_TRUE THEN
13696 savepoint DELETE_CANDIDATES_SP;
13697 END IF;
13698
13699 IF l_debug_mode = 'Y' THEN
13700 pa_debug.write(l_module, 'Start of DELETE_CANDIDATES', l_log_level);
13701 pa_debug.write(l_module, 'Printing Input Parameters......', l_log_level);
13702 pa_debug.write(l_module, 'p_commit '||p_commit, l_log_level);
13703 pa_debug.write(l_module, 'p_init_msg_list '||p_init_msg_list, l_log_level);
13704 pa_debug.write(l_module, 'p_api_version_number '||p_api_version_number, l_log_level);
13705 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
13706 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
13707 i := p_candidate_in_tbl.first;
13708 WHILE i IS NOT NULL LOOP
13709 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').candidate_id '||p_candidate_in_tbl(i).candidate_id, l_log_level);
13710 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').requirement_id '||p_candidate_in_tbl(i).requirement_id, l_log_level);
13711 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').resource_id '||p_candidate_in_tbl(i).resource_id, l_log_level);
13712 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').person_id '||p_candidate_in_tbl(i).person_id, l_log_level);
13713 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').status_code '||p_candidate_in_tbl(i).status_code, l_log_level);
13714 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').nomination_comments '||p_candidate_in_tbl(i).nomination_comments, l_log_level);
13715 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').ranking '||p_candidate_in_tbl(i).ranking, l_log_level);
13716 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').change_reason_code '||p_candidate_in_tbl(i).change_reason_code, l_log_level);
13717 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').record_version_number '||p_candidate_in_tbl(i).record_version_number, l_log_level);
13718 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
13719 i := p_candidate_in_tbl.next(i);
13720 END LOOP;
13721 END IF;
13722
13723 PA_STARTUP.INITIALIZE(
13724 p_calling_application => l_calling_application
13725 , p_calling_module => l_calling_module
13726 , p_check_id_flag => l_check_id_flag
13727 , p_check_role_security_flag => l_check_role_security_flag
13728 , p_check_resource_security_flag => l_check_resource_security_flag
13729 , p_debug_level => l_log_level
13730 );
13731
13732 IF l_debug_mode = 'Y' THEN
13733 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
13734 END IF;
13735
13736 --l_prm_license_flag := nvl(FND_PROFILE.VALUE('PA_PRM_LICENSED'),'N');
13737 --IF l_prm_license_flag <> 'Y' THEN
13738 -- null;
13739 --END IF;
13740
13741 i := p_candidate_in_tbl.first;
13742
13743 WHILE i IS NOT NULL LOOP
13744 l_error_flag_local := 'N';
13745 l_missing_params := null;
13746 l_start_msg_count := FND_MSG_PUB.count_msg;
13747
13748 l_candidate_in_rec := p_candidate_in_tbl(i);
13749 l_record_version_number := 0;
13750 l_project_id := 0;
13751
13752 -- Mandatory Parameters Check
13753 IF l_debug_mode = 'Y' THEN
13754 pa_debug.write(l_module, 'Record#'||i, l_log_level);
13755 pa_debug.write(l_module, '-----------------------------', l_log_level);
13756 pa_debug.write(l_module, 'Inside while loop. Mandatory parameter check.', l_log_level);
13757 END IF;
13758
13759 IF l_candidate_in_rec.requirement_id IS NULL THEN
13760 l_missing_params := l_missing_params||', REQUIREMENT_ID';
13761 END IF;
13762
13763 IF l_debug_mode = 'Y' THEN
13764 pa_debug.write(l_module, 'Mandatory parameter validation over. l_missing_params='||l_missing_params, l_log_level);
13765 END IF;
13766
13767 IF l_missing_params IS NOT NULL THEN
13768 l_error_flag_local := 'Y';
13769 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
13770 'INVALID_PARAMS', l_missing_params);
13771 END IF;
13772
13773 IF l_error_flag_local <> 'Y' THEN
13774
13775 OPEN c_get_requirement_info(l_candidate_in_rec.requirement_id);
13776 FETCH c_get_requirement_info INTO l_project_id, l_record_version_number;
13777 -- CLOSE c_get_requirement_info; -- Commented for Bug 5178399
13778
13779 -- IF l_project_id IS NULL THEN -- Check for requirement id valid and assignment type OPEN_ASSIGNMENT -- Commented for Bug 5178399
13780 IF c_get_requirement_info%NOTFOUND THEN -- Check for requirement id valid and assignment type OPEN_ASSIGNMENT -- Added for Bug 5178399
13781 l_error_flag_local := 'Y';
13782 l_missing_params := l_missing_params||', REQUIREMENT_ID';
13783 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
13784 'INVALID_PARAMS', l_missing_params);
13785 END IF;
13786
13787 CLOSE c_get_requirement_info; -- Added for Bug 5178399
13788
13789 -- Nulling out the parameters which are not required.
13790 l_candidate_in_rec.candidate_id := null;
13791 l_candidate_in_rec.resource_id := null;
13792 l_candidate_in_rec.person_id := null;
13793 l_candidate_in_rec.status_code := null;
13794 l_candidate_in_rec.nomination_comments := null;
13795 l_candidate_in_rec.ranking := null;
13796 l_candidate_in_rec.change_reason_code := null;
13797 l_candidate_in_rec.record_version_number := null;
13798
13799 END IF;
13800
13801 -- Security Check : Check PA_CREATE_CANDIDATES privilege on PA_PROJECTS and PA_PROJECT_ASSIGNMENTS as done in AddCandidatesTopCO.java
13802 -------------------
13803
13804 IF l_error_flag_local <> 'Y' THEN
13805
13806 IF l_debug_mode = 'Y' THEN
13807 pa_debug.write(l_module, 'Checking PA_CREATE_CANDIDATES privilege on PA_PROJECTS and PA_PROJECT_ASSIGNMENTS for record#'||i, l_log_level);
13808 END IF;
13809
13810 l_privilege := 'PA_CREATE_CANDIDATES';
13811
13812 l_object_name := 'PA_PROJECTS';
13813 l_object_key := l_project_id;
13814
13815 l_return_status := FND_API.G_RET_STS_SUCCESS;
13816 l_ret_code := 'T';
13817
13818 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
13819 x_ret_code => l_ret_code
13820 , x_return_status => l_return_status
13821 , x_msg_count => l_msg_count
13822 , x_msg_data => l_msg_data
13823 , p_privilege => l_privilege
13824 , p_object_name => l_object_name
13825 , p_object_key => l_object_key
13826 , p_init_msg_list => FND_API.G_FALSE);
13827
13828 IF nvl(l_ret_code, 'F') = 'F' AND l_return_status = FND_API.G_RET_STS_SUCCESS THEN
13829 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
13830 l_object_key := l_candidate_in_rec.requirement_id;
13831
13832 l_return_status := FND_API.G_RET_STS_SUCCESS;
13833 l_ret_code := 'T';
13834
13835 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
13836 x_ret_code => l_ret_code
13837 , x_return_status => l_return_status
13838 , x_msg_count => l_msg_count
13839 , x_msg_data => l_msg_data
13840 , p_privilege => l_privilege
13841 , p_object_name => l_object_name
13842 , p_object_key => l_object_key
13843 , p_init_msg_list => FND_API.G_FALSE);
13844 END IF;
13845 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
13846 -- This message does not have token defined, but intentionally putting token
13847 -- bcoz we still want to show the privielge name which is missing
13848 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_ADD_CAND'
13849 ,'MISSING_PRIVILEGE', l_privilege);
13850 l_error_flag_local := 'Y';
13851 END IF;
13852
13853 IF l_debug_mode = 'Y' THEN
13854 pa_debug.write(l_module, 'Security check complete for record#'||i||' privilege '||l_ret_code, l_log_level);
13855 END IF;
13856
13857 END IF;
13858
13859 -- Call Core Actual API
13860 -----------------------
13861
13862 IF l_error_flag_local <> 'Y' THEN
13863 l_return_status := FND_API.G_RET_STS_SUCCESS;
13864
13865 IF l_debug_mode = 'Y' THEN
13866 pa_debug.write(l_module, 'Calling PA_CANDIDATE_PUB.DELETE_CANDIDATES for Record#'||i, l_log_level);
13867 END IF;
13868
13869 PA_CANDIDATE_PUB.DELETE_CANDIDATES
13870 (
13871 p_assignment_id => l_candidate_in_rec.requirement_id
13872 , p_status_code => null
13873 , x_return_status => l_return_status
13874 , x_msg_count => l_msg_count
13875 , x_msg_data => l_msg_data
13876 );
13877
13878 IF l_debug_mode = 'Y' THEN
13879 pa_debug.write(l_module, 'After call PA_CANDIDATE_PUB.DELETE_CANDIDATES l_return_status='||l_return_status, l_log_level);
13880 END IF;
13881
13882 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
13883 l_error_flag_local := 'Y';
13884 IF l_debug_mode = 'Y' THEN
13885 pa_debug.write(l_module, 'PA_CANDIDATE_PUB.DELETE_CANDIDATES unsuccessful', l_log_level);
13886 END IF;
13887 ELSE
13888 IF l_debug_mode = 'Y' THEN
13889 pa_debug.write(l_module, 'Calling PA_PROJECT_ASSIGNMENTS_PKG.UPDATE_ROW for Record#'||i, l_log_level);
13890 END IF;
13891 -- Set the number of active candidates to zero
13892 PA_PROJECT_ASSIGNMENTS_PKG.UPDATE_ROW
13893 (
13894 p_assignment_id => l_candidate_in_rec.requirement_id
13895 , p_no_of_active_candidates => 0
13896 , p_record_version_number => l_record_version_number
13897 , x_return_status => l_return_status
13898 );
13899 IF l_debug_mode = 'Y' THEN
13900 pa_debug.write(l_module, 'After call PA_PROJECT_ASSIGNMENTS_PKG.UPDATE_ROW l_return_status='||l_return_status, l_log_level);
13901 END IF;
13902 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
13903 l_error_flag_local := 'Y';
13904 IF l_debug_mode = 'Y' THEN
13905 pa_debug.write(l_module, 'PA_PROJECT_ASSIGNMENTS_PKG.UPDATE_ROW unsuccessful', l_log_level);
13906 END IF;
13907 ELSE
13908 IF l_debug_mode = 'Y' THEN
13909 pa_debug.write(l_module, 'PA_PROJECT_ASSIGNMENTS_PKG.UPDATE_ROW and PA_CANDIDATE_PUB.DELETE_CANDIDATES successful', l_log_level);
13910 END IF;
13911 END IF;
13912 END IF;
13913 END IF;
13914
13915 l_end_msg_count := FND_MSG_PUB.count_msg;
13916 IF l_debug_mode = 'Y' THEN
13917 pa_debug.write(l_module, 'l_start_msg_count='||l_start_msg_count, l_log_level);
13918 pa_debug.write(l_module, 'l_end_msg_count='||l_end_msg_count, l_log_level);
13919 END IF;
13920 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
13921
13922 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
13923 l_error_flag := 'Y';
13924
13925 IF l_debug_mode = 'Y' THEN
13926 pa_debug.write(l_module, 'Repopulating Error Message Stack', l_log_level);
13927 END IF;
13928
13929 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
13930 -- Always get from first location in stack i.e. l_start_msg_count+1
13931 -- Because stack moves down after delete
13932 FND_MSG_PUB.get (
13933 p_msg_index => l_start_msg_count+1,
13934 p_encoded => FND_API.G_FALSE,
13935 p_data => l_data,
13936 p_msg_index_out => l_msg_index_out );
13937
13938 -- Always delete at first location in stack i.e. l_start_msg_count+1
13939 -- Because stack moves down after delete
13940 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
13941
13942 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
13943 'RECORD_NO', i,
13944 'MESSAGE', l_data);
13945 END LOOP;
13946
13947 IF l_debug_mode = 'Y' THEN
13948 pa_debug.write(l_module, 'After Repopulating Error Message Stack', l_log_level);
13949 END IF;
13950
13951 END IF;
13952 i := p_candidate_in_tbl.next(i);
13953 END LOOP;
13954
13955 IF l_debug_mode = 'Y' THEN
13956 pa_debug.write(l_module, 'All records are done', l_log_level);
13957 pa_debug.write(l_module, 'l_error_flag='||l_error_flag, l_log_level);
13958 pa_debug.write(l_module, 'FND_MSG_PUB.count_msg='||FND_MSG_PUB.count_msg, l_log_level);
13959 END IF;
13960
13961 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
13962 RAISE FND_API.G_EXC_ERROR;
13963 END IF;
13964
13965 IF l_debug_mode = 'Y' THEN
13966 PA_DEBUG.reset_curr_function;
13967 END IF;
13968
13969 IF p_commit = FND_API.G_TRUE THEN
13970 commit;
13971 END IF;
13972
13973 EXCEPTION
13974
13975 WHEN FND_API.G_EXC_ERROR THEN
13976
13977 x_return_status := FND_API.G_RET_STS_ERROR;
13978 l_msg_count := FND_MSG_PUB.count_msg;
13979
13980 IF c_get_requirement_info%ISOPEN THEN
13981 CLOSE c_get_requirement_info;
13982 END IF;
13983
13984 IF p_commit = FND_API.G_TRUE THEN
13985 ROLLBACK TO DELETE_CANDIDATES_SP;
13986 END IF;
13987
13988 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
13989 PA_INTERFACE_UTILS_PUB.get_messages
13990 ( p_encoded => FND_API.G_FALSE
13991 , p_msg_index => 1
13992 , p_msg_count => l_msg_count
13993 , p_msg_data => l_msg_data
13994 , p_data => l_data
13995 , p_msg_index_out => l_msg_index_out);
13996
13997 x_msg_data := l_data;
13998 x_msg_count := l_msg_count;
13999 ELSE
14000 x_msg_count := l_msg_count;
14001 END IF;
14002
14003 IF l_debug_mode = 'Y' THEN
14004 Pa_Debug.reset_curr_function;
14005 END IF;
14006
14007 WHEN OTHERS THEN
14008
14009 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
14010 x_msg_data := SUBSTRB(SQLERRM,1,240);
14011
14012 IF c_get_requirement_info%ISOPEN THEN
14013 CLOSE c_get_requirement_info;
14014 END IF;
14015
14016 IF p_commit = FND_API.G_TRUE THEN
14017 ROLLBACK TO DELETE_CANDIDATES_SP;
14018 END IF;
14019
14020 FND_MSG_PUB.add_exc_msg
14021 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
14022 , p_procedure_name => 'DELETE_CANDIDATES'
14023 , p_error_text => x_msg_data);
14024
14025 x_msg_count := FND_MSG_PUB.count_msg;
14026
14027 IF l_debug_mode = 'Y' THEN
14028 PA_DEBUG.reset_curr_function;
14029 END IF;
14030 RAISE;
14031
14032 END DELETE_CANDIDATES;
14033
14034 -- Start of comments
14035 -- API name : CREATE_CANDIDATE_LOG
14036 -- Type : Public
14037 -- Pre-reqs : None.
14038 -- Function : This is a public API to create log for one or more candidates for project requirements.
14039 -- Usage : This API will be called from AMG.
14040 -- Parameters :
14041 -- IN : p_commit IN VARCHAR2
14042 -- Identifier to commit the transaction.
14043 -- Valid values are: FND_API.G_FALSE for FALSE and FND_API.G_TRUE for TRUE
14044 -- p_init_msg_list IN VARCHAR2
14045 -- Identifier to initialize the error message stack.
14046 -- Valid values are: FND_API.G_FALSE for FALSE amd FND_API.G_TRUE for TRUE
14047 -- p_api_version_number IN NUMBER Required
14048 -- To be compliant with Applications API coding standards.
14049 -- p_candidate_log_tbl IN CANDIDATE_LOG_TBL_TYPE Required
14050 -- Table of candidate review records. Please see the CANDIDATE_LOG_TBL_TYPE datatype table.
14051 -- OUT :
14052 -- x_candidate_review_id_tbl OUT SYSTEM.PA_NUM_TBL_TYPE
14053 -- Table to store the candidate review ids created by the API.
14054 -- Reference : pa_candidate_reviews.candidate_review_id
14055 -- x_return_status OUT VARCHAR2
14056 -- Indicates the return status of the API.
14057 -- Valid values are: 'S' for Success, 'E' for Error, 'U' for Unexpected Error
14058 -- x_msg_count OUT NUMBER
14059 -- Indicates the number of error messages in the message stack
14060 -- x_msg_data OUT VARCHAR2
14061 -- Indicates the error message text if only one error exists
14062 -- History :
14063 -- 01-Mar-2006 - msachan - Created
14064 -- End of comments
14065 PROCEDURE CREATE_CANDIDATE_LOG
14066 (
14067 p_commit IN VARCHAR2 := FND_API.G_FALSE
14068 , p_init_msg_list IN VARCHAR2 := FND_API.G_TRUE
14069 , p_api_version_number IN NUMBER := 1.0
14070 , p_candidate_log_tbl IN CANDIDATE_LOG_TBL_TYPE
14071 , x_candidate_review_id_tbl OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE
14072 , x_return_status OUT NOCOPY VARCHAR2
14073 , x_msg_count OUT NOCOPY NUMBER
14074 , x_msg_data OUT NOCOPY VARCHAR2
14075 )
14076 IS
14077 l_debug_mode VARCHAR2(1);
14078 l_module VARCHAR2(100) := 'PA_CANDIDATE_AMG_PUB.CREATE_CANDIDATE_LOG';
14079 i NUMBER;
14080 l_log_level NUMBER := 3;
14081 l_calling_application VARCHAR2(10) := 'PLSQL';
14082 l_calling_module VARCHAR2(10) := 'AMG';
14083 l_check_id_flag VARCHAR2(1) := 'Y';
14084 l_check_role_security_flag VARCHAR2(1) := 'Y';
14085 l_check_resource_security_flag VARCHAR2(1) := 'Y';
14086 l_error_flag_local VARCHAR2(1) := 'N';
14087 l_error_flag VARCHAR2(1) := 'N';
14088 l_missing_params VARCHAR2(1000);
14089 l_start_msg_count NUMBER := 0;
14090 l_end_msg_count NUMBER := 0;
14091 l_loop_msg_count NUMBER := 0;
14092
14093 l_candidate_log_tbl CANDIDATE_LOG_REC_TYPE;
14094 l_project_system_status_code VARCHAR2(30);
14095 l_cand_record_version_number NUMBER;
14096 l_lookup_code VARCHAR2(20);
14097
14098 l_privilege VARCHAR2(30);
14099 l_object_name VARCHAR2(30);
14100 l_object_key NUMBER;
14101 l_resource_valid VARCHAR2(1) := 'N';
14102 l_privilege_name VARCHAR2(40) := null;
14103 l_ret_code VARCHAR2(1);
14104 l_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
14105 l_msg_count NUMBER;
14106 l_msg_data VARCHAR2(2000);
14107 l_msg_index_out NUMBER;
14108 l_data VARCHAR2(2000);
14109
14110 CURSOR c_get_valid_lookup_code(c_change_reason_code VARCHAR2) IS
14111 SELECT lookup_code
14112 FROM pa_lookups
14113 WHERE lookup_type = 'CANDIDATE_STS_CHANGE_REASON'
14114 AND lookup_code = c_change_reason_code;
14115
14116 CURSOR c_get_candidate_details(c_candidate_id NUMBER) IS
14117 SELECT pcv.project_id, pc.assignment_id, pc.record_version_number
14118 FROM pa_candidates pc, pa_candidates_v pcv
14119 WHERE pc.candidate_id = c_candidate_id
14120 AND pcv.candidate_number = c_candidate_id;
14121
14122 CURSOR c_get_system_status_code(c_status_code VARCHAR2) IS
14123 SELECT project_system_status_code FROM pa_project_statuses
14124 WHERE trunc(SYSDATE) BETWEEN start_date_active AND nvl(end_date_active, trunc(SYSDATE))
14125 AND status_type = 'CANDIDATE'
14126 AND project_status_code = c_status_code;
14127
14128 l_cand_rec c_get_candidate_details%ROWTYPE;
14129
14130 BEGIN
14131
14132 --Flows which are supported by this API
14133 ---------------------------------------
14134 --1. Creating a log of candidate when the status is changed.
14135 -- 1.1 Validating candidate_id
14136 -- 1.2 Validating for valid status_code
14137 -- 1.3 validating change_reason_status
14138 -- 1.4 Creating a entry in pa_candidate_reviews if the status is changed.
14139 --Flows which are not supported by this API
14140 -------------------------------------------
14141 --1. Validations like status_code change allowed or not are handled by the underlying apis.
14142
14143 x_return_status := FND_API.G_RET_STS_SUCCESS;
14144 x_candidate_review_id_tbl := SYSTEM.PA_NUM_TBL_TYPE();
14145
14146 l_debug_mode := NVL(FND_PROFILE.VALUE_SPECIFIC('PA_DEBUG_MODE', fnd_global.user_id, fnd_global.login_id, 275, null, null), 'N');
14147
14148 IF l_debug_mode = 'Y' THEN
14149 PA_DEBUG.set_curr_function(p_function => 'CREATE_CANDIDATE_LOG', p_debug_mode => l_debug_mode);
14150 END IF;
14151
14152 IF FND_API.TO_BOOLEAN(nvl(p_init_msg_list, FND_API.G_TRUE)) THEN
14153 FND_MSG_PUB.initialize;
14154 END IF;
14155
14156 IF p_commit = FND_API.G_TRUE THEN
14157 savepoint CREATE_CANDIDATE_LOG_SP;
14158 END IF;
14159
14160 IF l_debug_mode = 'Y' THEN
14161 pa_debug.write(l_module, 'Start of CREATE_CANDIDATE_LOG', l_log_level);
14162 pa_debug.write(l_module, 'Printing Input Parameters......', l_log_level);
14163 pa_debug.write(l_module, 'p_commit '||p_commit, l_log_level);
14164 pa_debug.write(l_module, 'p_init_msg_list '||p_init_msg_list, l_log_level);
14165 pa_debug.write(l_module, 'p_api_version_number '||p_api_version_number, l_log_level);
14166 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
14167 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
14168 i := p_candidate_log_tbl.first;
14169 WHILE i IS NOT NULL LOOP
14170 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').candidate_id '||p_candidate_log_tbl(i).candidate_id, l_log_level);
14171 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').status_code '||p_candidate_log_tbl(i).status_code, l_log_level);
14172 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').change_reason_code '||p_candidate_log_tbl(i).change_reason_code, l_log_level);
14173 pa_debug.write(l_module, 'p_candidate_in_tbl('||i||').review_comments '||p_candidate_log_tbl(i).review_comments, l_log_level);
14174 pa_debug.write(l_module, '------------------------------------------------------------------', l_log_level);
14175 i := p_candidate_log_tbl.next(i);
14176 END LOOP;
14177 END IF;
14178
14179 PA_STARTUP.INITIALIZE(
14180 p_calling_application => l_calling_application
14181 , p_calling_module => l_calling_module
14182 , p_check_id_flag => l_check_id_flag
14183 , p_check_role_security_flag => l_check_role_security_flag
14184 , p_check_resource_security_flag => l_check_resource_security_flag
14185 , p_debug_level => l_log_level
14186 );
14187
14188 IF l_debug_mode = 'Y' THEN
14189 pa_debug.write(l_module, 'After call of PA_STARTUP.INITIALIZE', l_log_level);
14190 END IF;
14191
14192 --l_prm_license_flag := nvl(FND_PROFILE.VALUE('PA_PRM_LICENSED'),'N');
14193 --IF l_prm_license_flag <> 'Y' THEN
14194 -- null;
14195 --END IF;
14196
14197 i := p_candidate_log_tbl.first;
14198
14199 WHILE i IS NOT NULL LOOP
14200 l_error_flag_local := 'N';
14201 l_missing_params := null;
14202 l_start_msg_count := FND_MSG_PUB.count_msg;
14203
14204 l_candidate_log_tbl := p_candidate_log_tbl(i);
14205 l_cand_rec := null;
14206
14207 -- Mandatory Parameters Check
14208 IF l_debug_mode = 'Y' THEN
14209 pa_debug.write(l_module, 'Record#'||i, l_log_level);
14210 pa_debug.write(l_module, '-----------------------------', l_log_level);
14211 pa_debug.write(l_module, 'Inside while loop. Mandatory parameter check.', l_log_level);
14212 END IF;
14213
14214 -- Check on Candidate Id
14215 OPEN c_get_candidate_details(l_candidate_log_tbl.candidate_id);
14216 FETCH c_get_candidate_details INTO l_cand_rec;
14217
14218 IF c_get_candidate_details%NOTFOUND THEN
14219 l_missing_params := l_missing_params||', CANDIDATE_ID';
14220 END IF;
14221
14222 CLOSE c_get_candidate_details;
14223
14224 -- Check on Status Code
14225 IF l_candidate_log_tbl.status_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
14226 l_candidate_log_tbl.status_code := null;
14227 ELSIF l_candidate_log_tbl.status_code IS NOT NULL THEN
14228 l_project_system_status_code := null;
14229
14230 OPEN c_get_system_status_code(l_candidate_log_tbl.status_code);
14231 FETCH c_get_system_status_code INTO l_project_system_status_code;
14232 CLOSE c_get_system_status_code;
14233
14234 IF l_project_system_status_code IS NULL OR l_project_system_status_code NOT IN
14235 ('CANDIDATE_DECLINED', 'CANDIDATE_PENDING_REVIEW', 'CANDIDATE_SUITABLE',
14236 'CANDIDATE_SYSTEM_NOMINATED', 'CANDIDATE_UNDER_REVIEW', 'CANDIDATE_WITHDRAWN') THEN
14237 l_missing_params := l_missing_params||', STATUS_CODE';
14238 END IF;
14239 END IF;
14240
14241 -- Check for Change Reason Code
14242 IF l_candidate_log_tbl.change_reason_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
14243 l_candidate_log_tbl.change_reason_code := null;
14244 ELSIF l_candidate_log_tbl.change_reason_code IS NOT NULL THEN
14245
14246 OPEN c_get_valid_lookup_code(l_candidate_log_tbl.change_reason_code);
14247 FETCH c_get_valid_lookup_code INTO l_lookup_code;
14248
14249 IF c_get_valid_lookup_code%NOTFOUND THEN
14250 l_missing_params := l_missing_params||', CHANGE_REASON_CODE';
14251 END IF;
14252
14253 CLOSE c_get_valid_lookup_code;
14254
14255 END IF;
14256
14257 IF l_debug_mode = 'Y' THEN
14258 pa_debug.write(l_module, 'Mandatory parameter validation over. List of Missing Parameters='||l_missing_params, l_log_level);
14259 END IF;
14260
14261 IF l_missing_params IS NOT NULL THEN
14262 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_INV_PARAMS',
14263 'INVALID_PARAMS', l_missing_params);
14264 l_error_flag_local := 'Y';
14265 END IF;
14266
14267 IF l_error_flag_local <> 'Y' THEN
14268
14269
14270 -- Check for Review Comments
14271 IF l_candidate_log_tbl.review_comments = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
14272 l_candidate_log_tbl.review_comments := null;
14273 END IF;
14274
14275 -- Security Check : Check PA_REVIEW_CANDIDATE_LOG privilege on PA_PROJECTS and PA_PROJECT_ASSIGNMENTS as done in CandRevwLogTopCO.java
14276 -------------------
14277
14278 IF l_debug_mode = 'Y' THEN
14279 pa_debug.write(l_module, 'Checking PA_REVIEW_CANDIDATE_LOG privilege on PA_PROJECTS and PA_PROJECT_ASSIGNMENTS for record#'||i, l_log_level);
14280 END IF;
14281
14282 l_privilege := 'PA_REVIEW_CANDIDATE_LOG';
14283
14284 l_object_name := 'PA_PROJECTS';
14285 l_object_key := l_cand_rec.project_id;
14286
14287 l_return_status := FND_API.G_RET_STS_SUCCESS;
14288 l_ret_code := 'T';
14289
14290 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
14291 x_ret_code => l_ret_code
14292 , x_return_status => l_return_status
14293 , x_msg_count => l_msg_count
14294 , x_msg_data => l_msg_data
14295 , p_privilege => l_privilege
14296 , p_object_name => l_object_name
14297 , p_object_key => l_object_key
14298 , p_init_msg_list => FND_API.G_FALSE);
14299
14300 IF nvl(l_ret_code, 'F') = 'F' AND l_return_status = FND_API.G_RET_STS_SUCCESS THEN
14301 l_object_name := 'PA_PROJECT_ASSIGNMENTS';
14302 l_object_key := l_cand_rec.assignment_id;
14303
14304 l_return_status := FND_API.G_RET_STS_SUCCESS;
14305 l_ret_code := 'T';
14306
14307 PA_SECURITY_PVT.CHECK_USER_PRIVILEGE(
14308 x_ret_code => l_ret_code
14309 , x_return_status => l_return_status
14310 , x_msg_count => l_msg_count
14311 , x_msg_data => l_msg_data
14312 , p_privilege => l_privilege
14313 , p_object_name => l_object_name
14314 , p_object_key => l_object_key
14315 , p_init_msg_list => FND_API.G_FALSE);
14316 END IF;
14317 IF nvl(l_ret_code, 'F') = 'F' OR l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
14318 -- This message does not have token defined, but intentionally putting token
14319 -- bcoz we still want to show the privielge name which is missing
14320 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_REQ_ADD_CAND_LOG'
14321 ,'MISSING_PRIVILEGE', l_privilege);
14322 l_error_flag_local := 'Y';
14323 END IF;
14324
14325 IF l_debug_mode = 'Y' THEN
14326 pa_debug.write(l_module, 'Security check complete for record#'||i||' privilege '||l_ret_code, l_log_level);
14327 END IF;
14328
14329 END IF;
14330
14331 -- Call Core Actual API
14332 -----------------------
14333
14334 IF l_error_flag_local <> 'Y' THEN
14335 l_return_status := FND_API.G_RET_STS_SUCCESS;
14336
14337 IF l_debug_mode = 'Y' THEN
14338 pa_debug.write(l_module, 'Calling PA_CANDIDATE_PUB.ADD_CANDIDATE_LOG for Record#'||i, l_log_level);
14339 END IF;
14340
14341 PA_CANDIDATE_PUB.ADD_CANDIDATE_LOG
14342 (
14343 p_candidate_id => l_candidate_log_tbl.candidate_id
14344 , p_status_code => l_candidate_log_tbl.status_code
14345 , p_change_reason_code => l_candidate_log_tbl.change_reason_code
14346 , p_review_comments => l_candidate_log_tbl.review_comments
14347 , p_cand_record_version_number => l_cand_rec.record_version_number
14348 , x_cand_record_version_number => l_cand_record_version_number
14349 , p_init_msg_list => FND_API.G_FALSE
14350 -- Added for bug 9187892
14351 , p_attribute_category => l_candidate_log_tbl.attribute_category
14352 , p_attribute1 => l_candidate_log_tbl.attribute1
14353 , p_attribute2 => l_candidate_log_tbl.attribute2
14354 , p_attribute3 => l_candidate_log_tbl.attribute3
14355 , p_attribute4 => l_candidate_log_tbl.attribute4
14356 , p_attribute5 => l_candidate_log_tbl.attribute5
14357 , p_attribute6 => l_candidate_log_tbl.attribute6
14358 , p_attribute7 => l_candidate_log_tbl.attribute7
14359 , p_attribute8 => l_candidate_log_tbl.attribute8
14360 , p_attribute9 => l_candidate_log_tbl.attribute9
14361 , p_attribute10 => l_candidate_log_tbl.attribute10
14362 , p_attribute11 => l_candidate_log_tbl.attribute11
14363 , p_attribute12 => l_candidate_log_tbl.attribute12
14364 , p_attribute13 => l_candidate_log_tbl.attribute13
14365 , p_attribute14 => l_candidate_log_tbl.attribute14
14366 , p_attribute15 => l_candidate_log_tbl.attribute15
14367 , x_return_status => l_return_status
14368 , x_msg_count => l_msg_count
14369 , x_msg_data => l_msg_data
14370 );
14371
14372 IF l_debug_mode = 'Y' THEN
14373 pa_debug.write(l_module, 'After call PA_CANDIDATE_PUB.ADD_CANDIDATE_LOG l_return_status='||l_return_status, l_log_level);
14374 END IF;
14375
14376 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
14377 x_candidate_review_id_tbl.extend(1);
14378 x_candidate_review_id_tbl(x_candidate_review_id_tbl.COUNT) := l_cand_record_version_number;
14379 IF l_debug_mode = 'Y' THEN
14380 pa_debug.write(l_module, 'PA_CANDIDATE_PUB.ADD_CANDIDATE_LOG successful', l_log_level);
14381 END IF;
14382 ELSE
14383 l_error_flag_local := 'Y';
14384 x_candidate_review_id_tbl.extend(1);
14385 x_candidate_review_id_tbl(x_candidate_review_id_tbl.COUNT) := -1;
14386 IF l_debug_mode = 'Y' THEN
14387 pa_debug.write(l_module, 'PA_CANDIDATE_PUB.ADD_CANDIDATE_LOG unsuccessful', l_log_level);
14388 END IF;
14389 END IF;
14390 ELSE
14391 x_candidate_review_id_tbl.extend(1);
14392 x_candidate_review_id_tbl(x_candidate_review_id_tbl.COUNT) := -1;
14393 END IF;
14394
14395 l_end_msg_count := FND_MSG_PUB.count_msg;
14396 IF l_debug_mode = 'Y' THEN
14397 pa_debug.write(l_module, 'l_start_msg_count='||l_start_msg_count, l_log_level);
14398 pa_debug.write(l_module, 'l_end_msg_count='||l_end_msg_count, l_log_level);
14399 END IF;
14400 l_loop_msg_count := l_end_msg_count - l_start_msg_count;
14401
14402 IF l_error_flag_local = 'Y' OR l_loop_msg_count > 0 THEN
14403 l_error_flag := 'Y';
14404
14405 IF l_debug_mode = 'Y' THEN
14406 pa_debug.write(l_module, 'Repopulating Error Message Stack', l_log_level);
14407 END IF;
14408
14409 FOR j in l_start_msg_count+1..l_end_msg_count LOOP
14410 -- Always get from first location in stack i.e. l_start_msg_count+1
14411 -- Because stack moves down after delete
14412 FND_MSG_PUB.get (
14413 p_msg_index => l_start_msg_count+1,
14414 p_encoded => FND_API.G_FALSE,
14415 p_data => l_data,
14416 p_msg_index_out => l_msg_index_out );
14417
14418 -- Always delete at first location in stack i.e. l_start_msg_count+1
14419 -- Because stack moves down after delete
14420 FND_MSG_PUB.DELETE_MSG(p_msg_index => l_start_msg_count+1);
14421
14422 PA_UTILS.ADD_MESSAGE('PA', 'PA_AMG_RES_ERROR_MSG',
14423 'RECORD_NO', i,
14424 'MESSAGE', l_data);
14425 END LOOP;
14426
14427 IF l_debug_mode = 'Y' THEN
14428 pa_debug.write(l_module, 'After Repopulating Error Message Stack', l_log_level);
14429 pa_debug.write(l_module, 'l_cand_record_version_number = '||l_cand_record_version_number, l_log_level);
14430 END IF;
14431
14432 END IF;
14433 i := p_candidate_log_tbl.next(i);
14434 END LOOP;
14435
14436 IF l_debug_mode = 'Y' THEN
14437 pa_debug.write(l_module, 'All records are done', l_log_level);
14438 pa_debug.write(l_module, 'l_error_flag='||l_error_flag, l_log_level);
14439 pa_debug.write(l_module, 'FND_MSG_PUB.count_msg='||FND_MSG_PUB.count_msg, l_log_level);
14440 END IF;
14441
14442 IF l_error_flag = 'Y' OR FND_MSG_PUB.count_msg > 0 THEN
14443 RAISE FND_API.G_EXC_ERROR;
14444 END IF;
14445
14446 IF l_debug_mode = 'Y' THEN
14447 PA_DEBUG.reset_curr_function;
14448 END IF;
14449
14450 IF p_commit = FND_API.G_TRUE THEN
14451 commit;
14452 END IF;
14453
14454 EXCEPTION
14455
14456 WHEN FND_API.G_EXC_ERROR THEN
14457
14458 x_return_status := FND_API.G_RET_STS_ERROR;
14459 l_msg_count := FND_MSG_PUB.count_msg;
14460
14461 IF c_get_candidate_details%ISOPEN THEN
14462 CLOSE c_get_candidate_details;
14463 END IF;
14464
14465 IF c_get_system_status_code%ISOPEN THEN
14466 CLOSE c_get_system_status_code;
14467 END IF;
14468
14469 IF p_commit = FND_API.G_TRUE THEN
14470 ROLLBACK TO CREATE_CANDIDATE_LOG_SP;
14471 END IF;
14472
14473 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
14474 PA_INTERFACE_UTILS_PUB.get_messages
14475 ( p_encoded => FND_API.G_FALSE
14476 , p_msg_index => 1
14477 , p_msg_count => l_msg_count
14478 , p_msg_data => l_msg_data
14479 , p_data => l_data
14480 , p_msg_index_out => l_msg_index_out);
14481
14482 x_msg_data := l_data;
14483 x_msg_count := l_msg_count;
14484 ELSE
14485 x_msg_count := l_msg_count;
14486 END IF;
14487
14488 IF l_debug_mode = 'Y' THEN
14489 Pa_Debug.reset_curr_function;
14490 END IF;
14491
14492 WHEN OTHERS THEN
14493
14494 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
14495 x_msg_data := SUBSTRB(SQLERRM,1,240);
14496
14497 IF c_get_candidate_details%ISOPEN THEN
14498 CLOSE c_get_candidate_details;
14499 END IF;
14500
14501 IF c_get_system_status_code%ISOPEN THEN
14502 CLOSE c_get_system_status_code;
14503 END IF;
14504
14505 IF p_commit = FND_API.G_TRUE THEN
14506 ROLLBACK TO CREATE_CANDIDATE_LOG_SP;
14507 END IF;
14508
14509 FND_MSG_PUB.add_exc_msg
14510 ( p_pkg_name => 'PA_RES_MANAGEMENT_AMG_PUB'
14511 , p_procedure_name => 'CREATE_CANDIDATE_LOG'
14512 , p_error_text => x_msg_data);
14513
14514 x_msg_count := FND_MSG_PUB.count_msg;
14515
14516 IF l_debug_mode = 'Y' THEN
14517 PA_DEBUG.reset_curr_function;
14518 END IF;
14519 RAISE;
14520
14521 END CREATE_CANDIDATE_LOG;
14522
14523 END PA_RES_MANAGEMENT_AMG_PUB;