1 PACKAGE BODY PA_PLANNING_RESOURCE_UTILS AS
2 /* $Header: PARPRLUB.pls 120.29 2012/02/01 13:05:24 djambhek ship $ */
3
4 P_PA_DEBUG_MODE varchar2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N');
5 g_module_name VARCHAR2(100) := 'pa.plsql.PA_PLANNING_RESOURCE_UTILS';
6 g_job_group_id NUMBER;
7 /********************************************************
8 * Check whether any planning resources or class defaults for the spread
9 * curve exist.
10 *******************************************************/
11
12
13 FUNCTION chk_spread_curve_in_use(p_spread_curve_id IN NUMBER) return BOOLEAN
14 IS
15
16 CURSOR chk_if_exists IS
17 select 'Y'
18 from dual
19 where ((exists (select 'Y'
20 from pa_resource_list_members
21 where spread_curve_id = p_spread_curve_id))
22 OR (exists (select 'Y'
23 from pa_plan_res_defaults
24 where spread_curve_id = p_spread_curve_id)));
25
26 l_exists VARCHAR2(1) := 'N';
27 l_return BOOLEAN := FALSE;
28 BEGIN
29 open chk_if_exists;
30 fetch chk_if_exists into l_exists;
31 IF chk_if_exists%FOUND THEN
32 l_return := TRUE;
33 ELSE
34 l_return := FALSE;
35 END IF;
36
37 close chk_if_exists;
38 RETURN l_return;
39
40 END chk_spread_curve_in_use;
41
42 /********************************************************
43 * Check whether any planning resources with NLR exist
44 * ******************************************************/
45 FUNCTION chk_nlr_resource_exists(p_non_labor_resource IN Varchar2) return
46 BOOLEAN
47 IS
48 CURSOR chk_nlr_resource IS
49 select 'Y'
50 from pa_resource_list_members
51 where non_labor_resource = p_non_labor_resource
52 and migration_code = 'N';
53
54 l_exists VARCHAR2(1) := 'N';
55 l_return BOOLEAN := FALSE;
56 BEGIN
57 open chk_nlr_resource;
58 fetch chk_nlr_resource into l_exists;
59 IF chk_nlr_resource%FOUND THEN
60 l_return := TRUE;
61 ELSE
62 l_return := FALSE;
63 END IF;
64
65 close chk_nlr_resource;
66 RETURN l_return;
67
68 END chk_nlr_resource_exists;
69
70
71 /*******************************************************************
72 * Function : Get_res_member_code
73 * Description : The purpose of this function is to return the resource
74 * code for a given resource list member id.
75 * Takes in parameter - p_resource_list_member_id
76 * Returns - l_resource_code
77 *******************************************************************/
78 FUNCTION Get_res_member_code(p_resource_list_member_id IN NUMBER)
79 return VARCHAR2
80 IS
81 -- Decl of local variables
82 l_res_type_code VARCHAR2(30):= NULL;
83 l_resource_code VARCHAR2(30):= NULL;
84 BEGIN
85 /* The purpose of this function is to return the resource code for a
86 * given planning resource.*/
87 IF p_resource_list_member_id IS NOT NULL THEN
88 BEGIN
89 SELECT typ.res_type_code
90 INTO l_res_type_code
91 FROM pa_res_types_b typ,
92 pa_resource_list_members rlm,
93 pa_res_formats_b fmt
94 WHERE rlm.resource_list_member_id = p_resource_list_member_id
95 AND rlm.res_format_id = fmt.res_format_id
96 AND fmt.res_type_enabled_flag = 'Y'
97 AND fmt.res_type_id = typ.res_type_id;
98 EXCEPTION
99 WHEN NO_DATA_FOUND THEN
100 l_res_type_code := NULL;
101 RETURN NULL;
102 END;
103
104 IF l_res_type_code IS NOT NULL THEN
105 Select DECODE(incurred_by_res_flag, 'Y','',
106 DECODE(l_res_type_code,
107 'NAMED_PERSON',to_char(person_id),
108 'PERSON_TYPE', person_type_code,
109 'JOB', to_char(job_id),
110 'BOM_LABOR', to_char(bom_resource_id),
111 'RESOURCE_CLASS',resource_class_code,
112 'NON_LABOR_RESOURCE',non_labor_resource,
113 'BOM_EQUIPMENT',to_char(bom_resource_id),
114 'INVENTORY_ITEM',to_char(inventory_item_id),
115 'ITEM_CATEGORY',to_char(item_category_id)))
116 INTO l_resource_code
117 FROM pa_resource_list_members
118 WHERE resource_list_member_id = p_resource_list_member_id;
119
120 Return l_resource_code;
121 ELSE
122 Return Null;
123 END IF;
124 ELSE
125 Return Null;
126 END IF;
127 EXCEPTION
128 WHEN NO_DATA_FOUND THEN
129 Return l_resource_code;
130 WHEN OTHERS THEN
131 Return Null;
132 END Get_res_member_code;
133 /*************************************/
134 /*****************************************************************
135 * Function : Get_member_Fin_Cat_Code
136 * Description : The purpose of this function is to return the Financial
137 * category code for a given planning resource.
138 * Takes in Parameter - p_resource_member_id
139 * Returns - l_fin_category_code
140 *******************************************************************/
141 FUNCTION Get_member_Fin_Cat_Code(p_resource_list_member_id IN NUMBER) return
142 VARCHAR2
143 IS
144 l_fin_category_code pa_resource_list_members.FC_RES_TYPE_CODE%TYPE := NULL;
145 BEGIN
146 IF p_resource_list_member_id IS NOT NULL THEN
147 SELECT DECODE(fc_res_type_code,
148 'EXPENDITURE_TYPE',expenditure_type,
149 'EXPENDITURE_CATEGORY',expenditure_category,
150 'EVENT_TYPE',event_type,
151 'REVENUE_CATEGORY',revenue_category)
152 INTO l_fin_category_code
153 FROM pa_resource_list_members
154 WHERE RESOURCE_LIST_MEMBER_ID = p_resource_list_member_id;
155
156 Return l_fin_category_code;
157 ELSE
158 Return Null;
159 END IF;
160 EXCEPTION
161 WHEN NO_DATA_FOUND THEN
162 Return l_fin_category_code;
163 WHEN OTHERS THEN
164 Return Null;
165 END Get_member_Fin_Cat_Code;
166 /***********************************/
167 /***********************************************************************
168 * Function : Get_member_incur_by_res_code
169 * Description : The purpose of this function is to return the incurred by
170 * resource code for a given resource_list member.
171 * Takes in parameter - p_resource_list_member_id
172 * Returns - l_incur_by_res_code
173 ***********************************************************************/
174 FUNCTION Get_member_Incur_by_Res_Code(p_resource_list_member_id IN NUMBER)
175 return VARCHAR2
176 IS
177 --Decl of Local Var
178 l_incur_by_res_code VARCHAR2(30) := NULL;
179 BEGIN
180 IF p_resource_list_member_id IS NOT NULL THEN
181 SELECT DECODE(incurred_by_res_flag,'N','',
182 nvl(to_char(person_id),nvl(to_char(job_id),
183 nvl(person_type_code,
184 nvl(to_char(incur_by_role_id),
185 nvl(incur_by_res_class_code, 'ERROR'))))))
186 INTO l_incur_by_res_code
187 FROM pa_resource_list_members
188 WHERE resource_list_member_id = p_resource_list_member_id;
189
190 Return l_incur_by_res_code;
191 ELSE
192 Return NULL;
193 END IF;
194
195 EXCEPTION
196 WHEN NO_DATA_FOUND THEN
197 Return l_incur_by_res_code;
198 WHEN OTHERS THEN
199 Return null;
200 END Get_member_Incur_By_Res_Code;
201 /****************************************************************/
202 /**************************************************************
203 * FUNCTION : Get_res_type_code
204 *************************************************************/
205 FUNCTION Get_res_type_code(p_res_format_id IN NUMBER)
206 RETURN VARCHAR2
207 IS
208 l_res_type_code pa_res_types_b.RES_TYPE_CODE%TYPE := null;
209 BEGIN
210 IF p_res_format_id IS NOT NULL THEN
211 SELECT b.res_type_code
212 INTO l_res_type_code
213 FROM pa_res_formats_b a, pa_res_types_b b
214 WHERE a.RES_TYPE_ID = b.RES_TYPE_ID
215 AND a.RES_TYPE_ENABLED_FLAG = 'Y'
216 AND a.res_format_id = p_res_format_id;
217 Return l_res_type_code;
218 ELSE
219 Return Null;
220 END IF;
221 EXCEPTION
222 WHEN OTHERS THEN
223 Return Null;
224 END Get_res_type_code;
225
226 /*******************************************************************
227 * Function : Get_Resource_Code
228 * Description : The purpose of this function is to return the resource
229 * code for a given resource assignment.
230 * Takes in parameter - p_resource_assignment_id
231 * Returns - l_resource_code
232 *******************************************************************/
233 FUNCTION Get_resource_Code(p_resource_assignment_id IN NUMBER) return VARCHAR2
234 IS
235 -- Decl of local variables
236 l_resource_code pa_resource_assignments.res_type_code%TYPE := NULL;
237 BEGIN
238 /* The purpose of this function is to return the resource code for a given resource assignment.*/
239 IF p_resource_assignment_id IS NOT NULL THEN
240 Select DECODE(incurred_by_res_flag, 'Y','',
241 DECODE(res_type_code,
242 'NAMED_PERSON',to_char(person_id),
243 'PERSON_TYPE', person_type_code,
244 'JOB', to_char(job_id),
245 'BOM_LABOR', to_char(bom_resource_id),
246 'RESOURCE_CLASS',resource_class_code,
247 'NON_LABOR_RESOURCE',non_labor_resource,
248 'BOM_EQUIPMENT',to_char(bom_resource_id),
249 'INVENTORY_ITEM',to_char(inventory_item_id),
250 'ITEM_CATEGORY',to_char(item_category_id)))
251 INTO l_resource_code
252 FROM pa_resource_assignments
253 WHERE resource_assignment_id = p_resource_assignment_id;
254
255 Return l_resource_code;
256 ELSE
257 Return Null;
258 END IF;
259 EXCEPTION
260 WHEN NO_DATA_FOUND THEN
261 Return l_resource_code;
262 WHEN OTHERS THEN
263 Return Null;
264 END Get_resource_Code;
265 /*********************************************************************/
266
267 /***********************************************************************
268 * Function : Get_Incur_By_Res_Code
269 * Description : The purpose of this function is to return the incurred by
270 * resource code for a given resource assignment.
271 * Takes in parameter - p_resource_assignment_id
272 * Returns - l_incur_by_res_code
273 ***********************************************************************/
274
275 FUNCTION Get_Incur_by_Res_Code(p_resource_assignment_id IN NUMBER)
276 return VARCHAR2
277 IS
278 --Decl of Local Var
279 l_incur_by_res_code VARCHAR2(30) := NULL;
280 BEGIN
281 IF p_resource_assignment_id IS NOT NULL THEN
282 SELECT DECODE(incurred_by_res_flag,'N','',
283 nvl(to_char(person_id),nvl(to_char(job_id), nvl(person_type_code,
284 nvl(to_char(incur_by_role_id),
285 nvl(incur_by_res_class_code, NULL))))))
286 INTO l_incur_by_res_code
287 FROM pa_resource_assignments
288 WHERE resource_assignment_id = p_resource_assignment_id;
289
290 Return l_incur_by_res_code;
291 ELSE
292 Return NULL;
293 END IF;
294
295 EXCEPTION
296 WHEN NO_DATA_FOUND THEN
297 Return l_incur_by_res_code;
298 WHEN OTHERS THEN
299 Return null;
300 END Get_Incur_By_Res_Code;
301 /****************************************************************/
302
303 /*****************************************************************
304 * Function : Get_Fin_Category_Code
305 * Description : The purpose of this function is to return the Financial
306 * category code for a given resource assignment.
307 * Takes in Parameter - p_resource_assignment_id
308 * Returns - l_fin_category_code
309 *******************************************************************/
310 FUNCTION Get_Fin_Category_Code(p_resource_assignment_id IN NUMBER) return
311 VARCHAR2
312 IS
313 l_fin_category_code pa_resource_assignments.FC_RES_TYPE_CODE%TYPE := NULL;
314 BEGIN
315 IF p_resource_assignment_id IS NOT NULL THEN
316 SELECT DECODE(fc_res_type_code,
317 'EXPENDITURE_TYPE',expenditure_type,
318 'EXPENDITURE_CATEGORY',expenditure_category,
319 'EVENT_TYPE',event_type,
320 'REVENUE_CATEGORY',revenue_category_code)
321 INTO l_fin_category_code
322 FROM pa_resource_assignments
323 WHERE resource_assignment_id = p_resource_assignment_id;
324
325 Return l_fin_category_code;
326 ELSE
327 Return Null;
328 END IF;
329 EXCEPTION
330 WHEN NO_DATA_FOUND THEN
331 Return l_fin_category_code;
332 WHEN OTHERS THEN
333 Return Null;
334 END Get_Fin_Category_Code;
335 /**********************************************************************/
336
337 /****************************************************************************
338 * Procedure : Validate_Organization
339 * Description : This procedure validates the organization for a
340 * planning. It first validates the name and id, of
341 * the organization and then checks if the organization
342 * is an expenditure organization or a project owning
343 * organization.
344 * The organization on a planning resource can
345 * be an expenditure organization since the resource
346 * could be a person.
347 * The organization on the planning resource can be a project
348 * owning organization since the resource could an expense which
349 * is incurred by the project organization.
350 * Hence, we are checking for both.
351 * Called By :
352 * Calls Prog : PA_HR_ORG_UTILS.Check_OrgName_Or_Id
353 *****************************************************************************/
354 PROCEDURE Validate_Organization
355 (p_organization_name IN VARCHAR2,
356 p_organization_id IN NUMBER,
357 x_organization_id OUT NOCOPY NUMBER,
358 x_return_status OUT NOCOPY VARCHAR2,
359 x_error_msg_code OUT NOCOPY VARCHAR2)
360 IS
361 --Declaration of Local variables
362 -- l_return_status VARCHAR2(1);
363 l_organization_id NUMBER := null;
364 -- l_error_msg_data fnd_new_messages.message_name%TYPE;
365 BEGIN
366 x_return_status := FND_API.G_RET_STS_SUCCESS;
367 x_error_msg_code := Null;
368 -- validate the organization and assign the id to the global record.
369 /*****************************************************************
370 * We are going to make use of an existing procedure
371 * PA_HR_ORG_UTILS.Check_OrgName_Or_Id, which will take in the
372 * Organization ID and organization name and will check for null
373 * for either of the fields and will accordingly derive the Organization_id.
374 ********************************************************************/
375 IF (p_organization_id IS NOT NULL) OR
376 ( p_organization_name IS NOT NULL)
377 THEN
378 PA_HR_ORG_UTILS.Check_OrgName_Or_Id(
379 p_organization_id,
380 p_organization_name,
381 PA_STARTUP.G_Check_ID_Flag,
382 l_organization_id,
383 x_return_status,
384 x_error_msg_code);
385
386 /*******************************************************************
387 * If the call to the procedure Check_OrgName_Or_Id, returns an error then
388 * call the package PA_UTILS and pass the error message.
389 ********************************************************************/
390 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
391 IF x_error_msg_code = 'PA_INVALID_ORG' THEN
392 PA_UTILS.Add_Message('PA', 'PA_INVALID_ORG_PLAN_RES', 'PLAN_RES',
393 Pa_Planning_Resource_Pvt.g_token);
394 Return;
395 ELSIF x_error_msg_code = 'PA_ORG_NOT_UNIQUE' THEN
396 PA_UTILS.Add_Message('PA', 'PA_ORG_NOT_UNIQUE_PLAN_RES',
397 'PLAN_RES',Pa_Planning_Resource_Pvt.g_token);
398 Return;
399 ELSE
400 Return;
401 END IF;
402 END IF;
403 /*******************************************************************
404 * If the call to the procedure Check_OrgName_Or_Id, completes successfully,
405 * then we need validate that the organization is a valid expenditure and
406 * project organization in the system.
407 ***********************************************************************/
408 BEGIN
409 SELECT distinct ORGANIZATION_ID
410 INTO x_organization_id
411 FROM pa_all_organizations
412 WHERE INACTIVE_DATE IS NULL
413 AND PA_ORG_USE_TYPE in ('EXPENDITURES', 'PROJECTS')
414 AND ORGANIZATION_ID = l_organization_id;
415 EXCEPTION
416 WHEN OTHERS THEN
417 x_organization_id := NULL;
418 x_return_status:= FND_API.G_RET_STS_ERROR;
419 x_error_msg_code:= 'PA_ORG_INVALID_PROJ_EXP';
420 /* We will be adding a new message which reads
421 Organization is an Invalid Expenditure or Project
422 Organization.*/
423 PA_UTILS.Add_Message('PA', x_error_msg_code, 'PLAN_RES',
424 Pa_Planning_Resource_Pvt.g_token);
425 Return;
426 END;
427
428 END IF;
429
430 END VALIDATE_ORGANIZATION;
431 /*******************************************************************/
432
433 /************************************************************************
434 * Procedure : Check_SupplierName_Or_Id
435 * Description : This Subprog validates the supplier name
436 * and ID combination
437 *********************************************************************/
438
439 PROCEDURE Check_SupplierName_Or_Id
440 ( p_supplier_id IN NUMBER
441 ,p_supplier_name IN VARCHAR2
442 ,p_check_id_flag IN VARCHAR2
443 ,x_supplier_id OUT NOCOPY NUMBER
444 ,x_return_status OUT NOCOPY VARCHAR2
445 ,x_error_msg_code OUT NOCOPY VARCHAR2 ) IS
446
447 l_current_id NUMBER := NULL;
448 l_num_ids NUMBER := 0;
449 l_id_found_flag VARCHAR(1) := 'N';
450
451 CURSOR c_ids IS
452 SELECT vendor_id
453 FROM po_vendors
454 WHERE vendor_name = p_supplier_name;
455 BEGIN
456 IF (p_supplier_id IS NOT NULL)
457 THEN
458 IF (p_check_id_flag = 'Y') THEN
459 BEGIN
460 SELECT vendor_id
461 INTO x_supplier_id
462 FROM PO_Vendors
463 WHERE vendor_id = p_supplier_id;
464 EXCEPTION
465 WHEN OTHERS THEN
466 x_supplier_id := NULL;
467 x_return_status:= FND_API.G_RET_STS_ERROR;
468 --Need to get a proper message
469 x_error_msg_code:= 'PA_INVALID_SUPPLIER';
470 RETURN;
471 END;
472 ELSIF (p_check_id_flag='N') THEN
473 x_supplier_id := p_supplier_id;
474 ELSIF (p_check_id_flag = 'A') THEN
475 /******************************************************************
476 * The Check_id_flag of 'A' indicates that this validation is coming from Java
477 * front end, and hence the Id and Name Combination needs to be
478 * validated in the database.
479 * *****************************************************************/
480 IF (p_supplier_name IS NULL) THEN
481 -- Return a null ID since the name is null.
482 x_supplier_id := NULL;
483 ELSE
484 OPEN c_ids;
485 LOOP
486 FETCH c_ids INTO l_current_id;
487 EXIT WHEN c_ids%NOTFOUND;
488 IF (l_current_id = p_supplier_id) THEN
489 l_id_found_flag := 'Y';
490 x_supplier_id := p_supplier_id;
491 END IF;
492 END LOOP;
493 l_num_ids := c_ids%ROWCOUNT;
494 CLOSE c_ids;
495
496 IF (l_num_ids = 0) THEN
497 -- No IDs for name
498 RAISE NO_DATA_FOUND;
499 ELSIF (l_num_ids = 1) THEN
500 -- Since there is only one ID for the name use it.
501 x_supplier_id := l_current_id;
502 ELSIF (l_num_ids > 1) THEN
503 --More than one ID for the name
504 RAISE TOO_MANY_ROWS;
505 END IF;
506 END IF;
507 ELSE
508 x_supplier_id := NULL;
509 END IF;
510 ELSE
511 IF (p_supplier_name IS NOT NULL) THEN
512 BEGIN
513 SELECT vendor_id
514 INTO x_supplier_id
515 FROM po_vendors
516 WHERE vendor_name = p_supplier_name;
517 EXCEPTION
518 WHEN OTHERS THEN
519 x_supplier_id := NULL;
520 x_return_status:= FND_API.G_RET_STS_ERROR;
521 --Need to get a proper message
522 x_error_msg_code:= 'PA_INVALID_SUPPLIER_NAME';
523 Return;
524 END;
525 ELSE
526 x_supplier_id := NULL;
527 END IF;
528 END IF;
529 x_return_status:= FND_API.G_RET_STS_SUCCESS;
530 EXCEPTION
531 WHEN OTHERS THEN
532 x_supplier_id := NULL;
533 x_return_status:= FND_API.G_RET_STS_ERROR;
534 --Need to get a proper message
535 x_error_msg_code:= 'PA_INVALID_SUPPLIER';
536 RETURN;
537 END Check_SupplierName_Or_Id;
538 /******************************************************************
539 * Procedure : Validate Supplier
540 * Description : The Purpose of this procedure is to Validate if the
541 * Supplier is valid in the system or not. Validation done
542 * as follows:-
543 * 1. If the Resource_class_code passed as IN parameter = 'PEOPLE'
544 * Then we call sub-Function Is_Contingent_Worker which checks if
545 * the person is a contingent worker. if not then an error message
546 * is displayed.
547 * 2. Next the Supplier ID/Name validity check needs to be done
548 * Hence the main prog calls subprog Check_SupplierName_Or_Id
549 * to do the check.
550 **********************************************************************/
551 PROCEDURE Validate_Supplier(
552 p_resource_class_code IN VARCHAR2,
553 p_person_id IN NUMBER,
554 p_supplier_id IN NUMBER DEFAULT NULL,
555 p_supplier_name IN VARCHAR2 DEFAULT NULL,
556 x_supplier_id OUT NOCOPY NUMBER,
557 x_return_status OUT NOCOPY VARCHAR2,
558 x_error_msg_code OUT NOCOPY VARCHAR2)
559
560 IS
561 l_return_status VARCHAR2(1);
562 l_error_msg_code fnd_new_messages.message_name%TYPE;
563 l_supplier_id PO_VENDORS.vendor_id%TYPE := NULL;
564 l_err_status VARCHAR2(30) := 'N';
565 /************************************************************************
566 * Sub-function : Is_Contingent_Worker
567 * Description : This Subprog checks if the resource is a contingent
568 * worker or not, If it is a contingent worker Then
569 * then it returns 'Y' Else returns 'N'. To Check
570 * for Contingent worker we are directly looking it up
571 * from the per_people_x view as it filters those where
572 * sysdate between effective start and end date.
573 * Also checks to see if the current_npw_flag = 'Y'
574 ************************************************************************/
575 Function Is_Contingent_Worker(p_person_id IN VARCHAR2) Return VARCHAR2
576 IS
577 l_cwk_flag VARCHAR2(30) := null;
578 BEGIN
579 SELECT 'Y'
580 INTO l_cwk_flag
581 --FROM per_people_x
582 FROM per_all_people_f
583 WHERE person_id = p_person_id
584 AND current_npw_flag = 'Y'
585 AND trunc(sysdate) between trunc(effective_start_date) AND
586 trunc(effective_end_date);
587
588 Return l_cwk_flag;
589 EXCEPTION
590 WHEN OTHERS THEN
591 -- This status will indicate not a contingent worker.
592 Return 'N';
593 END Is_Contingent_Worker;
594 /*******************/
595
596 /************************************
597 * Main Body *
598 ************************************/
599
600 BEGIN
601 x_return_status := FND_API.G_RET_STS_SUCCESS;
602 IF p_resource_class_code = 'PEOPLE' and p_person_id IS NOT NULL THEN
603 /* If the p_resource_class_code is 'People' then we need to check if
604 * the resource is a contingent
605 * worker. This is done by call to the subprog Check_contingent which
606 * will return the status. */
607 IF Is_Contingent_Worker(p_person_id) = 'N' THEN
608 x_supplier_id := NULL;
609 l_err_status := 'Y';
610 x_return_status := FND_API.G_RET_STS_ERROR;
611 x_error_msg_code:= 'PA_IS_NOT_CONTINGENT';
612 PA_UTILS.Add_Message('PA', x_error_msg_code, 'PLAN_RES',
613 Pa_Planning_Resource_Pvt.g_token);
614 Return;
615 END IF;
616 END IF;
617
618 IF p_resource_class_code <> 'PEOPLE' OR
619 l_err_status = 'N'
620 THEN
621 IF (p_supplier_id IS NOT NULL) OR
622 (p_supplier_name IS NOT NULL)
623 THEN
624 -- dbms_output.put_line('- IN Validate Supp ');
625 /* We call the Procedure Check_SupplierName_Or_Id to validate the
626 * Supplier ID and Name combination. */
627 Check_SupplierName_Or_Id(
628 p_supplier_id,
629 p_supplier_name,
630 PA_STARTUP.G_Check_ID_Flag,
631 l_supplier_id,
632 l_return_status,
633 l_error_msg_code);
634
635 -- dbms_output.put_line('- After Check_SupplierName_Or_Id p_supplier_name IS : '|| p_supplier_name);
636 -- dbms_output.put_line('- After Check_SupplierName_Or_Id p_supplier_id IS : '|| p_supplier_id);
637 -- dbms_output.put_line('- After Check_SupplierName_Or_Id l_supplier_id IS : '|| l_supplier_id);
638 -- dbms_output.put_line('- After Check_SupplierName_Or_Id l_return_status IS : '|| l_return_status);
639 x_supplier_id := l_supplier_id;
640 x_return_status := l_return_status;
641 x_error_msg_code := l_error_msg_code;
642
643 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
644 PA_UTILS.Add_Message('PA', l_error_msg_code, 'PLAN_RES',
645 Pa_Planning_Resource_Pvt.g_token);
646 Return;
647 END IF;
648 ELSE
649 x_supplier_id := NULL;
650 x_return_status := FND_API.G_RET_STS_ERROR;
651 x_error_msg_code:= 'PA_PLN_RL_NO_SUPPLIER';
652 PA_UTILS.Add_Message('PA', x_error_msg_code, 'PLAN_RES',
653 Pa_Planning_Resource_Pvt.g_token);
654 Return;
655 END IF;
656 END IF;
657 END Validate_Supplier;
658 /************************************************************************/
659
660 /*******************************
661 * Procedure : Check_PersonName_or_ID
662 * Description : Used to validate the Person ID
663 * Name combination.
664 ************************************/
665 PROCEDURE Check_PersonName_or_ID(
666 p_person_id IN VARCHAR2,
667 p_person_name IN VARCHAR2,
668 p_check_id_flag IN VARCHAR2,
669 x_person_id OUT NOCOPY NUMBER,
670 x_return_status OUT NOCOPY VARCHAR2,
671 x_error_msg_code OUT NOCOPY VARCHAR2)
672 IS
673 l_current_id NUMBER := NULL;
674 l_person_id NUMBER;
675 l_num_ids NUMBER := 0;
676
677 /****************************************************
678 * Bug - 3523947
679 * Desc - Modified the cursor c_ids. Removed the check
680 * where sysdate between eff start and end date.
681 * And selecting from per_people_x to keep it
682 * consistent with the other selects.
683 ***************************************************/
684 Cursor c_ids IS
685 SELECT person_id
686 --FROM per_all_people_f
687 FROM per_people_x
688 WHERE full_name = p_person_name;
689 --AND trunc(sysdate) between trunc(effective_start_date) AND
690 --trunc(effective_end_date);
691 BEGIN
692 x_return_status:= FND_API.G_RET_STS_SUCCESS;
693 IF (p_person_id IS NOT NULL)
694 THEN
695 IF (p_check_id_flag = 'Y') THEN
696 BEGIN
697 SELECT person_id
698 INTO l_person_id
699 FROM per_people_x
700 WHERE person_id = p_person_id;
701 x_person_id := l_person_id;
702 EXCEPTION
703 WHEN OTHERS THEN
704 x_person_id := NULL;
705 x_return_status:= FND_API.G_RET_STS_ERROR;
706 --Need to get a proper message
707 x_error_msg_code:= 'PA_INVALID_PERSON_ID';
708 Return;
709 END;
710 ELSIF (p_check_id_flag='N') THEN
711 l_person_id := p_person_id;
712 x_person_id := l_person_id;
713 ELSIF (p_check_id_flag = 'A') THEN
714 /******************************************************
715 * The Check_id_flag of 'A' indicates that this validation is
716 * coming from Java front end, and hence the id and Name combination
717 * needs to be validated in the database.
718 * ****************************************************/
719 IF (p_person_name IS NULL) THEN
720 -- Return a null ID since the name is
721 x_person_id := NULL;
722 l_person_id := NULL;
723 ELSE
724 OPEN c_ids;
725 LOOP
726 FETCH c_ids INTO l_current_id;
727 EXIT WHEN c_ids%NOTFOUND;
728 IF (l_current_id = p_person_id) THEN
729 l_person_id := p_person_id;
730 x_person_id := l_person_id;
731 END IF;
732 END LOOP;
733 l_num_ids := c_ids%ROWCOUNT;
734 CLOSE c_ids;
735
736 IF (l_num_ids = 0) THEN
737 -- No IDs for name
738 RAISE NO_DATA_FOUND;
739 ELSIF (l_num_ids = 1) THEN
740 -- Since there is only one ID for the name use it.
741 l_person_id := l_current_id;
742 x_person_id := l_person_id;
743 ELSIF (l_num_ids > 1) THEN
744 --More than one ID for the Name
745 RAISE TOO_MANY_ROWS;
746 END IF;
747 END IF;
748 ELSE
749 l_person_id := NULL;
750 x_person_id := l_person_id;
751 END IF;
752 ELSE
753 IF (p_person_name IS NOT NULL) THEN
754 BEGIN
755 SELECT person_id
756 INTO l_person_id
757 FROM per_people_x
758 WHERE full_name = p_person_name;
759 x_person_id := l_person_id;
760 EXCEPTION
761 WHEN OTHERS THEN
762 x_person_id := NULL;
763 x_return_status:= FND_API.G_RET_STS_ERROR;
764 --Need to get a proper message
765 x_error_msg_code:= 'PA_INVALID_PERSON_NAME';
766 Return;
767 END;
768 ELSE
769 l_person_id := NULL;
770 x_person_id := l_person_id;
771 END IF;
772 END IF;
773 /***************************************************
774 * This Select has been moved from the Main Body to this
775 * Procedure. As any other Prog's calling the Check_
776 * PersonName_or_id check would need this cond to be present.
777 * *****************************************************/
778 /******************************************************
779 * Bug - 3523947
780 * Desc - Modified the below select. We no longer need the
781 * check where sysdate between effective start and
782 * end date.
783 *****************************************************/
784 BEGIN
785 SELECT person_id
786 INTO x_person_id
787 FROM per_all_people_f per
788 WHERE
789 --sysdate BETWEEN effective_start_date AND effective_end_date
790 (current_employee_flag = 'Y' or CURRENT_NPW_FLAG = 'Y')
791 AND ((PA_CROSS_BUSINESS_GRP.IsCrossBGProfile = 'Y') OR
792 ((PA_CROSS_BUSINESS_GRP.IsCrossBGProfile = 'N') AND
793 fnd_profile.value('PER_BUSINESS_GROUP_ID') =
794 BUSINESS_GROUP_ID))
795 AND person_id = l_person_id
796 and rownum = 1;
797 EXCEPTION
798 WHEN OTHERS THEN
799 x_return_status := FND_API.G_RET_STS_ERROR;
800 --Need to get message for this.
801 x_error_msg_code:= 'PA_INVALID_PERSON_ID';
802 PA_UTILS.Add_Message('PA', x_error_msg_code, 'PLAN_RES',
803 Pa_Planning_Resource_Pvt.g_token);
804 Return;
805 END;
806
807 x_return_status:= FND_API.G_RET_STS_SUCCESS;
808
809 EXCEPTION
810 WHEN OTHERS THEN
811 x_person_id := NULL;
812 x_return_status:= FND_API.G_RET_STS_ERROR;
813 --Need to get a proper message
814 x_error_msg_code:= 'PA_INVALID_PERSON_ID';
815 Return;
816 END Check_PersonName_Or_Id;
817 /***************************/
818
819 /*******************************
820 * * Procedure : Check_JobName_or_ID
821 * * Description : Used to validate the Job ID
822 * * Name combination. -- NOT USED ANYMORE
823 * *******************************************/
824 PROCEDURE Check_JobName_or_ID(
825 p_job_id IN VARCHAR2,
826 p_job_name IN VARCHAR2,
827 p_check_id_flag IN VARCHAR2,
828 x_job_id OUT NOCOPY NUMBER,
829 x_return_status OUT NOCOPY VARCHAR2,
830 x_error_msg_code OUT NOCOPY VARCHAR2)
831 IS
832 BEGIN
833 NULL;
834 END Check_JobName_or_ID;
835
836 /*******************************
837 * Procedure : Check_JG_JobName_or_ID
838 * Description : Used to validate the Job ID
839 * Name combination in the context of Job Group.
840 *******************************************/
841 PROCEDURE Check_JG_JobName_or_ID(
842 p_job_id IN NUMBER,
843 p_job_name IN VARCHAR2,
844 p_job_group_id IN NUMBER,
845 p_check_id_flag IN VARCHAR2,
846 x_job_id OUT NOCOPY NUMBER,
847 x_return_status OUT NOCOPY VARCHAR2,
848 x_error_msg_code OUT NOCOPY VARCHAR2)
849 IS
850 l_current_id NUMBER := NULL;
851 l_num_ids NUMBER := 0;
852
853 Cursor c_ids IS
854 SELECT job_id
855 FROM per_jobs
856 WHERE name = p_job_name
857 AND job_group_id = p_job_group_id;
858 BEGIN
859 x_return_status:= FND_API.G_RET_STS_SUCCESS;
860 --4461039 : Added check for p_job_group_id
861 IF p_job_group_id IS NULL THEN
862 x_job_id := NULL;
863 x_return_status:= FND_API.G_RET_STS_ERROR;
864 x_error_msg_code:= 'PA_PL_RES_INVALID_JOB_GROUP';
865 Return;
866 END IF;
867
868 IF (p_job_id IS NOT NULL)
869 THEN
870 -- Added for bug 4025261 - need to ensure the given job_id is
871 -- in the job group even if check_id_flag is N.
872 IF (p_check_id_flag = 'Y' OR p_check_id_flag='N') THEN
873 BEGIN
874 SELECT job_id
875 INTO x_job_id
876 FROM per_jobs
877 WHERE job_id = p_job_id
878 AND job_group_id = p_job_group_id;
879 EXCEPTION
880 WHEN OTHERS THEN
881 x_job_id := NULL;
882 x_return_status:= FND_API.G_RET_STS_ERROR;
883 --Need to get a proper message
884 x_error_msg_code:= 'PA_INVALID_JOB_ID';
885 Return;
886 END;
887 -- ELSIF (p_check_id_flag='N') THEN
888 -- x_job_id := p_job_id;
889 ELSIF (p_check_id_flag = 'A') THEN
890 /******************************************************
891 * The Check_id_flag of 'A' indicates that this validation is
892 * coming from Java front end,
893 * and hence the Id and Name combination needs to be validated
894 * in the database.
895 *******************************************************/
896 IF (p_job_name IS NULL) THEN
897 -- Return a null ID since the name is
898 x_job_id := NULL;
899 ELSE
900 OPEN c_ids;
901 LOOP
902 FETCH c_ids INTO l_current_id;
903 EXIT WHEN c_ids%NOTFOUND;
904 IF (l_current_id = p_job_id) THEN
905 x_job_id := p_job_id;
906 END IF;
907 END LOOP;
908 l_num_ids := c_ids%ROWCOUNT;
909 CLOSE c_ids;
910
911 IF (l_num_ids = 0) THEN
912 -- No IDs for name
913 RAISE NO_DATA_FOUND;
914 ELSIF (l_num_ids = 1) THEN
915 -- Since there is only one ID for the name use it.
916 x_job_id := l_current_id;
917 ELSIF (l_num_ids > 1) THEN
918 --More than one ID for the Name
919 RAISE TOO_MANY_ROWS;
920 END IF;
921 END IF;
922 ELSE
923 x_job_id := NULL;
924 END IF;
925 ELSE
926 IF (p_job_name IS NOT NULL) THEN
927 BEGIN
928 SELECT job_id
929 INTO x_job_id
930 FROM per_jobs
931 WHERE name = p_job_name
932 AND job_group_id = p_job_group_id;
933 EXCEPTION
934 WHEN OTHERS THEN
935 x_job_id := NULL;
936 x_return_status:= FND_API.G_RET_STS_ERROR;
937 --Need to get a proper message
938 x_error_msg_code:= 'PA_INVALID_JOB_NAME';
939 Return;
940 END;
941 ELSE
942 x_job_id := NULL;
943 END IF;
944 END IF;
945 x_return_status:= FND_API.G_RET_STS_SUCCESS;
946
947 EXCEPTION
948 WHEN OTHERS THEN
949 x_job_id := NULL;
950 x_return_status:= FND_API.G_RET_STS_ERROR;
951 --Need to get a proper message
952 x_error_msg_code:= 'PA_INVALID_JOB';
953 Return;
954 END Check_JG_JobName_Or_Id;
955 /**********************************/
956 /********************************************
957 * Procedure : Check_BOM_EqLabor_or_ID
958 * Description : This Procedure can be called
959 * when the res_type_code is 'BOM_LABOR'
960 * or 'BOM_EQUIPMENT'(determined by the p_res_type_code)
961 * It validates the p_bom_eqlabor_id and p_bom_eqlabor_name
962 * and returns the x_bom_resource_id.
963 *******************************************/
964 PROCEDURE Check_BOM_EqLabor_or_ID
965 ( p_bom_eqlabor_id IN NUMBER
966 , p_bom_eqlabor_name IN VARCHAR2
967 , p_res_type_code IN VARCHAR2
968 , p_check_id_flag IN VARCHAR2
969 , x_bom_resource_id OUT NOCOPY NUMBER
970 , x_return_status OUT NOCOPY VARCHAR2
971 , x_error_msg_code OUT NOCOPY VARCHAR2 )
972 IS
973 l_current_id NUMBER := NULL;
974 l_num_ids NUMBER := 0;
975 l_id_found_flag VARCHAR(1) := 'N';
976 l_return_status VARCHAR2(1);
977 l_error_msg_data fnd_new_messages.message_name%TYPE;
978
979 CURSOR c_ids IS
980 SELECT b.resource_id
981 FROM bom_resources b
982 WHERE b.resource_type = p_res_type_code
983 and NVL(b.disable_date,SYSDATE) >= SYSDATE
984 and b.expenditure_type is NOT NULL
985 and b.resource_code = p_bom_eqlabor_name;
986
987 BEGIN
988 x_return_status:= FND_API.G_RET_STS_SUCCESS;
989
990
991 IF(p_bom_eqlabor_id IS NOT NULL)
992 THEN
993
994 IF (p_check_id_flag = 'Y') THEN
995
996 BEGIN
997 SELECT b.resource_id
998 INTO x_bom_resource_id
999 FROM bom_resources b
1000 WHERE b.resource_type = p_res_type_code
1001 AND nvl(b.disable_date,SYSDATE) >= SYSDATE
1002 AND b.expenditure_type IS NOT NULL
1003 AND b.resource_id = p_bom_eqlabor_id;
1004
1005 EXCEPTION
1006 WHEN OTHERS THEN
1007
1008 x_bom_resource_id := NULL;
1009 x_return_status:= FND_API.G_RET_STS_ERROR;
1010 --Need to get a proper message
1011 x_error_msg_code:= 'PA_INVALID_BOM_ID';
1012 -- RAISE; --commented for bug 3947006
1013 Return ;
1014 END;
1015 ELSIF (p_check_id_flag='N') THEN
1016
1017 x_bom_resource_id := p_bom_eqlabor_id;
1018 ELSIF (p_check_id_flag = 'A') THEN
1019
1020 /*********************************************************
1021 * The Check_id_flag of 'A' indicates that this validation is
1022 * coming from Java front end and hence the ID and name combination
1023 * needs to be validated in the database.
1024 * *************************************************/
1025
1026 IF (p_bom_eqlabor_name IS NULL) THEN
1027 -- Return a null ID since the name is null.
1028 x_bom_resource_id := NULL;
1029 ELSE
1030 OPEN c_ids;
1031 LOOP
1032 FETCH c_ids INTO l_current_id;
1033 EXIT WHEN c_ids%NOTFOUND;
1034 IF (l_current_id = p_bom_eqlabor_id) THEN
1035 l_id_found_flag := 'Y';
1036 x_bom_resource_id := p_bom_eqlabor_id;
1037 END IF;
1038 END LOOP;
1039 l_num_ids := c_ids%ROWCOUNT;
1040 CLOSE c_ids;
1041
1042 IF (l_num_ids = 0) THEN
1043 -- No IDs for name
1044 RAISE NO_DATA_FOUND;
1045 ELSIF (l_num_ids = 1) THEN
1046 -- Since there is only one ID for the name use it.
1047 x_bom_resource_id := l_current_id;
1048 ELSIF (l_num_ids > 1) THEN
1049 --More than one ID for Name
1050 RAISE TOO_MANY_ROWS;
1051 END IF;
1052 END IF;
1053 ELSE
1054 x_bom_resource_id := NULL;
1055 END IF;
1056 ELSE
1057
1058 IF (p_bom_eqlabor_name IS NOT NULL) THEN
1059
1060 BEGIN
1061 SELECT b.resource_id
1062 INTO x_bom_resource_id
1063 FROM bom_resources b
1064 WHERE b.resource_type = p_res_type_code --2
1065 AND NVL(b.disable_date,SYSDATE) >= SYSDATE
1066 AND b.expenditure_type IS NOT NULL
1067 AND b.resource_code = p_bom_eqlabor_name;
1068 EXCEPTION
1069 WHEN OTHERS THEN
1070 x_bom_resource_id := NULL;
1071 x_return_status:= FND_API.G_RET_STS_ERROR;
1072 --Need to get a proper message
1073 x_error_msg_code:= 'PA_INVALID_BOM_NAME';
1074 --RAISE; --commented for bug 3817916
1075 Return;--Added for bug 3817916
1076 END;
1077 ELSE
1078 x_bom_resource_id := NULL;
1079 END IF;
1080 END IF;
1081 x_return_status:= FND_API.G_RET_STS_SUCCESS;
1082 EXCEPTION
1083 WHEN OTHERS THEN
1084 x_bom_resource_id := NULL;
1085 x_return_status:= FND_API.G_RET_STS_ERROR;
1086 --Need to get a proper message
1087 x_error_msg_code:= 'PA_INVALID_BOM_ID';
1088 RAISE;
1089 END Check_BOM_EqLabor_or_ID;
1090 /*******************************/
1091 /********************************************
1092 * Procedure : Check_ItemCat_or_ID
1093 * Description : This Procedure can be called
1094 * when the res_type_code is 'ITEM_CATEGORY'
1095 * It validates the p_item_cat_id and p_item_cat_name
1096 * and returns the x_item_category_id.
1097 *******************************************/
1098 PROCEDURE Check_ItemCat_or_ID
1099 ( p_item_cat_id IN NUMBER
1100 ,p_item_cat_name IN VARCHAR2
1101 , P_item_category_set_id IN NUMBER
1102 , p_check_id_flag IN VARCHAR2
1103 , x_item_category_id OUT NOCOPY NUMBER
1104 , x_return_status OUT NOCOPY VARCHAR2
1105 , x_error_msg_code OUT NOCOPY VARCHAR2 )
1106 IS
1107 l_current_id NUMBER := NULL;
1108 l_num_ids NUMBER := 0;
1109 l_id_found_flag VARCHAR(1) := 'N';
1110 l_return_status VARCHAR2(1);
1111 l_error_msg_data fnd_new_messages.message_name%TYPE;
1112
1113 CURSOR c_ids IS
1114 SELECT c.category_id
1115 FROM mtl_categories_b c, mtl_category_set_valid_cats I
1116 WHERE i.category_set_id = p_item_category_set_id
1117 AND i.category_id = c.category_id
1118 AND nvl(c.disable_date,sysdate) >= sysdate
1119 AND fnd_Flex_ext.GET_SEGS('INV', 'MCAT', c.structure_id, c.category_id) =
1120 p_item_cat_name;
1121 --AND c.description = p_item_cat_name;
1122
1123 BEGIN
1124 x_return_status:= FND_API.G_RET_STS_SUCCESS;
1125 IF (p_item_cat_id IS NOT NULL)
1126 THEN
1127 IF (p_check_id_flag = 'Y') THEN
1128 BEGIN
1129 SELECT c.category_id
1130 INTO x_item_category_id
1131 FROM mtl_categories_b c, mtl_category_set_valid_cats I
1132 WHERE i.category_set_id = p_item_category_set_id
1133 AND i.category_id = c.category_id
1134 AND NVL(c.disable_date,sysdate) >= sysdate
1135 AND c.category_id = p_item_cat_id;
1136
1137 EXCEPTION
1138 WHEN OTHERS THEN
1139 x_item_category_id := NULL;
1140 x_return_status:= FND_API.G_RET_STS_ERROR;
1141 --Need to get a proper message
1142 x_error_msg_code:= 'PA_INVALID_ITEM_CAT_ID';
1143 RAISE;
1144 END;
1145 ELSIF (p_check_id_flag='N') THEN
1146 x_item_category_id := p_item_cat_id;
1147 ELSIF (p_check_id_flag = 'A') THEN
1148 /***********************************************************
1149 * The Check_id_flag of 'A' indicates that this validation is
1150 * coming from Java front end,
1151 * and hence the Id and Name combination needs to be validated
1152 * in the database.
1153 *********************************************************/
1154 IF (p_item_cat_name IS NULL) THEN
1155 -- Return a null ID since the name is null.
1156 x_item_category_id := NULL;
1157 ELSE
1158 OPEN c_ids;
1159 LOOP
1160 FETCH c_ids INTO l_current_id;
1161 EXIT WHEN c_ids%NOTFOUND;
1162 IF (l_current_id = p_item_cat_id) THEN
1163 l_id_found_flag := 'Y';
1164 x_item_category_id := p_item_cat_id;
1165 END IF;
1166 END LOOP;
1167 l_num_ids := c_ids%ROWCOUNT;
1168 CLOSE c_ids;
1169 IF (l_num_ids = 0) THEN
1170 -- No IDs for name
1171 RAISE NO_DATA_FOUND;
1172 ELSIF (l_num_ids = 1) THEN
1173 -- Since there is only one ID for the name use it.
1174 x_item_category_id := l_current_id;
1175 ELSIF (l_num_ids > 1) THEN
1176 --More than one ID for the Name
1177 RAISE TOO_MANY_ROWS;
1178 END IF;
1179 END IF;
1180 ELSE
1181 x_item_category_id := NULL;
1182 END IF;
1183 ELSE
1184 IF (p_item_cat_name IS NOT NULL) THEN
1185 BEGIN
1186 SELECT c.category_id
1187 INTO x_item_category_id
1188 FROM mtl_categories_b c, mtl_category_set_valid_cats I
1189 WHERE i.category_set_id = p_item_category_set_id
1190 AND i.category_id = c.category_id
1191 AND nvl(c.disable_date,sysdate) >= sysdate
1192 AND fnd_Flex_ext.GET_SEGS('INV', 'MCAT', c.structure_id, c.category_id) = p_item_cat_name;
1193 -- AND c.description = p_item_cat_name;
1194 EXCEPTION
1195 WHEN OTHERS THEN
1196 x_item_category_id := NULL;
1197 x_return_status:= FND_API.G_RET_STS_ERROR;
1198 --Need to get a proper message
1199 x_error_msg_code:= 'PA_INVALID_ITEM_CAT_NAME';
1200 Return;
1201 END;
1202 ELSE
1203 x_item_category_id := NULL;
1204 END IF;
1205 END IF;
1206 EXCEPTION
1207 WHEN OTHERS THEN
1208 x_item_category_id := NULL;
1209 x_return_status:= FND_API.G_RET_STS_ERROR;
1210 --Need to get a proper message
1211 x_error_msg_code:= 'PA_INVALID_ITEM_CAT_ID';
1212 Return;
1213 END Check_ItemCat_or_ID;
1214 /********************************/
1215 /********************************************
1216 * Procedure : Check_InventoryItem_or_ID
1217 * Description : This Procedure can be called
1218 * when the res_type_code is 'INVENTORY_ITEM'
1219 * It validates the p_item_id and p_item_name
1220 * and returns the x_item_id.
1221 *******************************************/
1222 PROCEDURE Check_InventoryItem_or_ID
1223 ( p_item_id IN NUMBER
1224 , p_item_name IN VARCHAR2
1225 , P_item_master_id IN NUMBER
1226 , p_check_id_flag IN VARCHAR2
1227 , x_item_id OUT NOCOPY NUMBER
1228 , x_return_status OUT NOCOPY VARCHAR2
1229 , x_error_msg_code OUT NOCOPY VARCHAR2 )
1230 IS
1231 l_current_id NUMBER := NULL;
1232 l_num_ids NUMBER := 0;
1233 l_id_found_flag VARCHAR(1) := 'N';
1234 l_return_status VARCHAR2(1);
1235 l_error_msg_data fnd_new_messages.message_name%TYPE;
1236
1237 /********************************************
1238 * Bug - 3566965
1239 * Desc - Modified the cursor to select based on
1240 * the segment1 field instead of the
1241 * description field. Also we dont need a join
1242 * with the MTL_SYSTEM_ITEMS_tl table.
1243 *******************************************/
1244 CURSOR c_ids IS
1245 SELECT b.INVENTORY_ITEM_ID
1246 FROM MTL_SYSTEM_ITEMS_b b
1247 WHERE b.organization_id = p_item_master_id
1248 AND b.ENABLED_FLAG = 'Y'
1249 --AND b.INVENTORY_ITEM_ID = t.INVENTORY_ITEM_ID
1250 --AND b.organization_id = t.organization_id
1251 --AND t.language = userenv('LANG')
1252 AND b.segment1 = p_item_name;
1253
1254 BEGIN
1255 x_return_status:= FND_API.G_RET_STS_SUCCESS;
1256 IF (p_item_id IS NOT NULL)
1257 THEN
1258 IF (p_check_id_flag = 'Y') THEN
1259 BEGIN
1260 /********************************************
1261 * Bug - 3566965
1262 * Desc - Modified the below select. We dont need
1263 * a join to the mtl_system_items_tl
1264 * table.
1265 *******************************************/
1266 SELECT b.INVENTORY_ITEM_ID
1267 INTO x_item_id
1268 FROM MTL_SYSTEM_ITEMS_b b
1269 WHERE b.organization_id = p_item_master_id
1270 AND b.ENABLED_FLAG = 'Y'
1271 --AND b.INVENTORY_ITEM_ID = t.INVENTORY_ITEM_ID
1272 --AND b.organization_id = t.organization_id
1273 --AND t.language = userenv('LANG')
1274 AND b.inventory_item_id = p_item_id;
1275 EXCEPTION
1276 WHEN OTHERS THEN
1277 x_item_id := NULL;
1278 x_return_status:= FND_API.G_RET_STS_ERROR;
1279 --Need to get a proper message
1280 x_error_msg_code:= 'PA_INVALID_INV_ID';
1281 RAISE;
1282 END;
1283 ELSIF (p_check_id_flag='N') THEN
1284 x_item_id := p_item_id;
1285 ELSIF (p_check_id_flag = 'A') THEN
1286 /***********************************************************
1287 * The Check_id_flag of 'A' indicates that this validation is
1288 * coming from Java front end,
1289 * and hence the Id and Name combination needs to be validated
1290 * in the database.
1291 *********************************************************/
1292 IF (p_item_name IS NULL) THEN
1293 -- Return a null ID since the name is null.
1294 x_item_id := NULL;
1295 ELSE
1296 OPEN c_ids;
1297 LOOP
1298 FETCH c_ids INTO l_current_id;
1299 EXIT WHEN c_ids%NOTFOUND;
1300 IF (l_current_id = p_item_id) THEN
1301 l_id_found_flag := 'Y';
1302 x_item_id := p_item_id;
1303 END IF;
1304 END LOOP;
1305 l_num_ids := c_ids%ROWCOUNT;
1306 CLOSE c_ids;
1307 IF (l_num_ids = 0) THEN
1308 -- No IDs for name
1309 RAISE NO_DATA_FOUND;
1310 ELSIF (l_num_ids = 1) THEN
1311 -- Since there is only one ID for the name use it.
1312 x_item_id := l_current_id;
1313 ELSIF (l_num_ids > 1) THEN
1314 --More than one ID for the Name
1315 RAISE TOO_MANY_ROWS;
1316 END IF;
1317 END IF;
1318 ELSE
1319 x_item_id := NULL;
1320 END IF;
1321 ELSE
1322 IF (p_item_name IS NOT NULL) THEN
1323 BEGIN
1324 /********************************************
1325 * Bug - 3566965
1326 * Desc - Modified the below select to be based on
1327 * the segment1 field instead of the
1328 * description field. Also we dont need a join
1329 * with the MTL_SYSTEM_ITEMS_tl table.
1330 *******************************************/
1331 SELECT b.INVENTORY_ITEM_ID
1332 INTO x_item_id
1333 FROM MTL_SYSTEM_ITEMS_b b
1334 WHERE b.organization_id = p_item_master_id
1335 AND b.ENABLED_FLAG = 'Y'
1336 --AND b.INVENTORY_ITEM_ID = t.INVENTORY_ITEM_ID
1337 --AND b.organization_id = t.organization_id
1338 --AND t.language = userenv('LANG')
1339 AND b.segment1 = p_item_name;
1340 EXCEPTION
1341 WHEN OTHERS THEN
1342 x_item_id := NULL;
1343 x_return_status:= FND_API.G_RET_STS_ERROR;
1344 --Need to get a proper message
1345 x_error_msg_code:= 'PA_INVALID_INV_NAME';
1346 Return;
1347 END;
1348 ELSE
1349 x_item_id := NULL;
1350 END IF;
1351 END IF;
1352 EXCEPTION
1353 WHEN OTHERS THEN
1354 x_item_id := NULL;
1355 x_return_status:= FND_API.G_RET_STS_ERROR;
1356 --Need to get a proper message
1357 x_error_msg_code:= 'PA_INVALID_INV_ID';
1358 Return;
1359 END Check_InventoryItem_or_Id;
1360 /******************************************************************
1361 * Procedure : Validate_Resource
1362 * Description :The purpose of this procedure is to validate the resource
1363 * per resource class.
1364 * The IN Parameters to the procedure are:
1365 * p_resource_code,p_resource_name,p_resource_class_code,
1366 * p_res_type_code.
1367 * The OUT Parameters are :
1368 * x_person_id,x_bom_resource_id,x_job_id,x_person_type_code,
1369 * x_non_labor_resource,x_inventory_item_id,x_item_category_id,
1370 * x_resource_class_code,x_resource_class_flag,x_return_status,
1371 * x_error_message_code.
1372 **********************************************************************/
1373
1374 PROCEDURE Validate_Resource(
1375 p_resource_code IN VARCHAR2 DEFAULT NULL,
1376 p_resource_name IN VARCHAR2 DEFAULT NULL,
1377 p_resource_class_code IN VARCHAR2,
1378 p_res_type_code IN VARCHAR2 DEFAULT NULL,
1379 x_person_id OUT NOCOPY NUMBER,
1380 x_bom_resource_id OUT NOCOPY NUMBER,
1381 x_job_id OUT NOCOPY NUMBER,
1382 x_person_type_code OUT NOCOPY VARCHAR2,
1383 x_non_labor_resource OUT NOCOPY VARCHAR2,
1384 x_inventory_item_id OUT NOCOPY NUMBER,
1385 x_item_category_id OUT NOCOPY NUMBER,
1386 x_resource_class_code OUT NOCOPY VARCHAR2,
1387 x_resource_class_flag OUT NOCOPY VARCHAR2,
1388 x_return_status OUT NOCOPY VARCHAR2,
1389 x_error_msg_code OUT NOCOPY VARCHAR2)
1390
1391 IS
1392 --Declaration of Local Variabled
1393 l_job_id NUMBER;
1394 l_person_id NUMBER;
1395 l_bom_resource_id NUMBER;
1396 l_return_status VARCHAR2(30);
1397 l_error_msg_code VARCHAR2(30);
1398 l_item_category_set_id NUMBER;
1399 l_item_master_id NUMBER;
1400 l_item_category_id NUMBER;
1401 l_inventory_item_id NUMBER;
1402 /*********************************************
1403 * Subfunction : Check_Res_Null
1404 * Description : The Purpose of this function is to verify
1405 * For Null condition in the fields
1406 * p_resource_code,p_resource_name,
1407 * p_resource_class_code and p_res_type_code
1408 * If the condition fails 'Y' is returned
1409 * else the value remains as 'N'.
1410 *************************************************/
1411 FUNCTION Check_Res_Null(
1412 p_resource_code IN VARCHAR2 DEFAULT NULL,
1413 p_resource_name IN VARCHAR2 DEFAULT NULL,
1414 p_resource_class_code IN VARCHAR2,
1415 p_res_type_code IN VARCHAR2 DEFAULT NULL)
1416 RETURN VARCHAR2
1417 IS
1418 l_check_null_flag VARCHAR2(30) := 'N';
1419 BEGIN
1420 IF p_res_type_code IS NULL THEN
1421 l_check_null_flag := 'Y';
1422 END IF;
1423 IF p_resource_class_code IS NULL THEN
1424 l_check_null_flag := 'Y';
1425 END IF;
1426 IF (p_resource_code IS NULL AND p_resource_name IS NULL)
1427 THEN
1428 l_check_null_flag := 'Y';
1429 END IF;
1430 Return l_Check_Null_Flag;
1431 END Check_Res_Null;
1432 /************************************/
1433
1434 /*********************************************
1435 * Subfunction : Match_classcode_Type
1436 * Description : The Purpose of this function is to verify
1437 * that the p_res_type_code is a valid resource type
1438 * in the given p_resource_class_code.
1439 * It will return 'N' if it is not valid
1440 * and 'Y' otherwise.
1441 *******************************************************/
1442 Function Match_classcode_Type(
1443 p_resource_class_code IN VARCHAR2,
1444 p_res_type_code IN VARCHAR2)
1445 RETURN VARCHAR2
1446 IS
1447 l_check_match_flag VARCHAR2(30) := 'Y';
1448 BEGIN
1449 /*********************************************************
1450 * Outer IF to validate that the resource_class_code passed
1451 * is a valid resource_class_code. If not it would go to
1452 * the Else.
1453 * ********************************************************/
1454 IF p_resource_class_code IN ('PEOPLE','EQUIPMENT','MATERIAL_ITEMS',
1455 'FINANCIAL_ELEMENTS')
1456 THEN
1457 IF p_resource_class_code = 'PEOPLE'
1458 THEN
1459 /********************************************************
1460 * IF p_resource_class_code = 'PEOPLE'
1461 * then the res_type_code should be one of
1462 * 'NAMED_PERSON','BOM_LABOR','NAMED_ROLE',
1463 * 'JOB','PERSON_TYPE','RESOURCE_CLASS'
1464 ************************************************************/
1465 IF p_res_type_code IN ('NAMED_PERSON','BOM_LABOR','NAMED_ROLE',
1466 'JOB','PERSON_TYPE','RESOURCE_CLASS')
1467 THEN
1468 l_check_match_flag := 'Y';
1469 ELSE
1470 l_check_match_flag := 'N';
1471 END IF;
1472
1473 ELSIF p_resource_class_code = 'EQUIPMENT'
1474 THEN
1475 /********************************************************
1476 * IF p_resource_class_code = 'EQUIPMENT'
1477 * then the res_type_code should be one of
1478 * 'NON_LABOR_RESOURCE','BOM_EQUIPMENT',
1479 * 'RESOURCE_CLASS'
1480 ************************************************************/
1481 IF p_res_type_code IN ('NON_LABOR_RESOURCE','BOM_EQUIPMENT',
1482 'RESOURCE_CLASS')
1483 THEN
1484 l_check_match_flag := 'Y';
1485 ELSE
1486 l_check_match_flag := 'N';
1487 END IF;
1488
1489 ELSIF p_resource_class_code = 'MATERIAL_ITEMS'
1490 THEN
1491 /********************************************************
1492 * IF p_resource_class_code = 'MATERIAL_ITEMS'
1493 * then the res_type_code should be one of
1494 * 'INVENTORY_ITEM',
1495 * 'ITEM_CATEGORY','RESOURCE_CLASS'
1496 ************************************************************/
1497 IF p_res_type_code IN ('INVENTORY_ITEM',
1498 'ITEM_CATEGORY','RESOURCE_CLASS')
1499 THEN
1500 l_check_match_flag := 'Y';
1501 ELSE
1502 l_check_match_flag := 'N';
1503 END IF;
1504
1505 ELSIF p_resource_class_code = 'FINANCIAL_ELEMENTS' THEN
1506 IF p_res_type_code IN ('RESOURCE_CLASS')
1507 THEN
1508 l_check_match_flag := 'Y';
1509 ELSE
1510 l_check_match_flag := 'N';
1511 END IF;
1512
1513 END IF;
1514 ELSE
1515 /*******************************************
1516 * If the resource_class_code is not Valid.
1517 * *****************************************/
1518 l_check_match_flag := 'N';
1519 END IF;
1520 Return l_Check_Match_Flag;
1521 END Match_classcode_Type;
1522 /*************************/
1523
1524 /*************************
1525 * Main Body *
1526 ************************/
1527 BEGIN
1528 -- hr_utility.trace('Start Validate_Resource');
1529 x_return_status:= FND_API.G_RET_STS_SUCCESS;
1530 x_resource_class_flag := 'N';
1531 /* Call to the Function check_null_flag to check for the null conditions*/
1532 IF P_PA_DEBUG_MODE = 'Y' THEN
1533 pa_debug.write('Validate_Resource: ' || g_module_name,'p_resource_code '|| p_resource_code ,1);
1534 pa_debug.write('Validate_Resource: ' || g_module_name,'p_resource_name '|| p_resource_name ,1);
1535 pa_debug.write('Validate_Resource: ' || g_module_name,'p_resource_class_code '|| p_resource_class_code ,1);
1536 pa_debug.write('Validate_Resource: ' || g_module_name,'p_res_type_code '|| p_res_type_code ,1);
1537 END IF;
1538
1539 IF Check_Res_Null(p_resource_code,p_resource_name,
1540 p_resource_class_code,p_res_type_code) = 'Y'
1541 THEN
1542 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1543 Return;
1544 ELSE
1545
1546 IF Match_classcode_Type(p_resource_class_code,p_res_type_code) = 'N'
1547 THEN
1548 x_return_status := FND_API.G_RET_STS_ERROR;
1549 --Need to get message for this.
1550 x_error_msg_code:= 'PA_RESOURCE_NO_MATCH';
1551 PA_UTILS.Add_Message('PA', x_error_msg_code, 'PLAN_RES',
1552 Pa_Planning_Resource_Pvt.g_token);
1553 ELSE
1554
1555 IF p_res_type_code = 'RESOURCE_CLASS' THEN
1556 IF p_resource_code = p_resource_class_code THEN
1557 x_resource_class_code := p_resource_class_code;
1558 x_resource_class_flag := 'Y';
1559 ELSE
1560 IF P_PA_DEBUG_MODE = 'Y' THEN
1561 pa_debug.write('Validate_Resource: ' || g_module_name,'RESOURCE_CLASS error' ,1);
1562 END IF;
1563 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1564 Return;
1565 END IF;
1566 ELSIF p_res_type_code = 'PERSON_TYPE' THEN
1567 BEGIN
1568 SELECT lookup_code
1569 INTO x_person_type_code
1570 FROM pa_lookups
1571 WHERE lookup_type = 'PA_PERSON_TYPE'
1572 AND lookup_code = p_resource_code;
1573 EXCEPTION
1574 WHEN OTHERS THEN
1575 x_return_status := FND_API.G_RET_STS_ERROR;
1576 --Need to get message for this.
1577 x_error_msg_code:= 'PA_PERSON_TYPE_CODE_INVALID';
1578 PA_UTILS.Add_Message('PA', x_error_msg_code, 'PLAN_RES',
1579 Pa_Planning_Resource_Pvt.g_token);
1580 END;
1581 ELSIF p_res_type_code = 'NON_LABOR_RESOURCE' THEN
1582 BEGIN
1583 SELECT non_labor_resource
1584 INTO x_non_labor_resource
1585 FROM pa_non_labor_resources
1586 WHERE non_labor_resource = p_resource_name;
1587 EXCEPTION
1588 WHEN OTHERS THEN
1589 x_return_status := FND_API.G_RET_STS_ERROR;
1590 --Need to get message for this.
1591 x_error_msg_code:= 'PA_NON_LABOR_CODE_INVALID';
1592 PA_UTILS.Add_Message('PA', x_error_msg_code, 'PLAN_RES',
1593 Pa_Planning_Resource_Pvt.g_token);
1594 END;
1595 ELSIF p_res_type_code = 'NAMED_PERSON' THEN
1596
1597 pa_planning_resource_utils.Check_PersonName_or_ID(
1598 p_person_id => p_resource_code,
1599 p_person_name => p_resource_name,
1600 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1601 x_person_id => l_person_id,
1602 x_return_status => l_return_status,
1603 x_error_msg_code => l_error_msg_code);
1604
1605 x_person_id := l_person_id;
1606 x_return_status := l_return_status;
1607 x_error_msg_code := l_error_msg_code;
1608
1609 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1610 PA_UTILS.Add_Message('PA', l_error_msg_code, 'PLAN_RES',
1611 Pa_Planning_Resource_Pvt.g_token);
1612 Return;
1613 END IF;
1614 /***************************************
1615 * Rest of code goes here all the ELSIF
1616 * ***************************************/
1617 ELSIF p_res_type_code = 'JOB' THEN
1618
1619 -- hr_utility.trace('p_res_type_code IS : ' || p_res_type_code);
1620 -- hr_utility.trace('Before Check_JG_JobName_or_ID');
1621 -- hr_utility.trace('p_resource_code IS : ' || p_resource_code);
1622 -- hr_utility.trace('p_resource_name IS : ' || p_resource_name);
1623 -- hr_utility.trace('g_job_group_id IS : ' || g_job_group_id);
1624 -- hr_utility.trace('PA_STARTUP.G_Check_ID_Flag IS : ' || PA_STARTUP.G_Check_ID_Flag);
1625 Check_JG_JobName_or_ID(
1626 P_job_id => p_resource_code,
1627 p_job_name => p_resource_name,
1628 p_job_group_id => g_job_group_id,
1629 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1630 x_job_id => l_job_id,
1631 x_return_status => l_return_status,
1632 x_error_msg_code => l_error_msg_code);
1633
1634 x_job_id := l_job_id;
1635 x_return_status := l_return_status;
1636 x_error_msg_code := l_error_msg_code;
1637
1638 -- hr_utility.trace('after Check_JG_JobName_or_ID');
1639 -- hr_utility.trace('x_return_status IS : ' || x_return_status);
1640 -- hr_utility.trace('x_error_msg_code IS : ' || x_error_msg_code);
1641 -- hr_utility.trace('x_job_id IS : ' || x_job_id);
1642 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1643 PA_UTILS.Add_Message('PA', l_error_msg_code, 'PLAN_RES',
1644 Pa_Planning_Resource_Pvt.g_token);
1645 Return;
1646 END IF;
1647 ELSIF p_res_type_code = 'BOM_LABOR' THEN
1648
1649 pa_planning_resource_utils.Check_BOM_EqLabor_or_ID(
1650 p_bom_eqlabor_id => p_resource_code,
1651 p_bom_eqlabor_name => p_resource_name,
1652 p_res_type_code => 2,
1653 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1654 x_bom_resource_id => l_bom_resource_id,
1655 x_return_status => l_return_status,
1656 x_error_msg_code => l_error_msg_code);
1657
1658
1659 x_bom_resource_id := l_bom_resource_id;
1660 x_return_status := l_return_status;
1661 x_error_msg_code := l_error_msg_code;
1662 --Added for bug 3947006
1663 IF x_return_status = Fnd_Api.G_Ret_Sts_Error THEN
1664
1665 Return;
1666 END IF;
1667
1668 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1669 PA_UTILS.Add_Message('PA', l_error_msg_code, 'PLAN_RES',
1670 Pa_Planning_Resource_Pvt.g_token);
1671 Return;
1672 END IF;
1673 ELSIF p_res_type_code = 'BOM_EQUIPMENT' THEN
1674
1675 pa_planning_resource_utils.Check_BOM_EqLabor_or_ID(
1676 p_bom_eqlabor_id => p_resource_code,
1677 p_bom_eqlabor_name => p_resource_name,
1678 p_res_type_code => 1,
1679 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1680 x_bom_resource_id => l_bom_resource_id,
1681 x_return_status => l_return_status,
1682 x_error_msg_code => l_error_msg_code);
1683
1684 x_bom_resource_id := l_bom_resource_id;
1685 x_return_status := l_return_status;
1686 x_error_msg_code := l_error_msg_code;
1687
1688 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1689 PA_UTILS.Add_Message('PA', l_error_msg_code, 'PLAN_RES',
1690 Pa_Planning_Resource_Pvt.g_token);
1691 Return;
1692 END IF;
1693
1694 ELSIF p_res_type_code = 'ITEM_CATEGORY' THEN
1695
1696 BEGIN
1697 SELECT def.item_category_set_id
1698 INTO l_item_category_set_id
1699 FROM pa_plan_res_defaults def
1700 -- , pa_resource_classes_b cl
1701 WHERE def.resource_class_id = 3
1702 AND def.object_type ='CLASS';
1703 --AND cl.resource_class_id = def.resource_class_id
1704 --AND cl.resource_class_id = 3;
1705 --AND cl.resource_class_code = 'MATERIAL_ITEMS';
1706 EXCEPTION
1707 WHEN NO_DATA_FOUND THEN
1708 x_item_category_id := NULL;
1709 x_return_status:= FND_API.G_RET_STS_ERROR;
1710 --Need to get a proper message
1711 x_error_msg_code:= 'PA_NO_ITEM_CATEGORY_SET';
1712 Return;
1713 WHEN OTHERS THEN
1714 x_item_category_id := NULL;
1715 x_return_status:= FND_API.G_RET_STS_ERROR;
1716 --Need to get a proper message
1717 x_error_msg_code:= 'PA_NO_ITEM_CATEGORY_SET';
1718 Return;
1719 END;
1720
1721 Pa_planning_resource_utils.Check_ItemCat_or_ID(
1722 P_item_cat_id => p_resource_code,
1723 P_item_cat_name => p_resource_name,
1724 P_item_category_set_id => l_item_category_set_id,
1725 P_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1726 X_item_category_id => l_item_category_id,
1727 X_return_status => l_return_status,
1728 X_error_msg_code => l_error_msg_code);
1729
1730 x_item_category_id := l_item_category_id;
1731 x_return_status := l_return_status;
1732 x_error_msg_code := l_error_msg_code;
1733 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1734 PA_UTILS.Add_Message('PA', l_error_msg_code, 'PLAN_RES',
1735 Pa_Planning_Resource_Pvt.g_token);
1736 END IF;
1737 ELSIF p_res_type_code = 'INVENTORY_ITEM' THEN
1738 BEGIN
1739 SELECT def.item_master_id
1740 INTO l_item_master_id
1741 FROM pa_plan_res_defaults def
1742 -- , pa_resource_classes_b cl
1743 WHERE def.resource_class_id = 3
1744 AND def.object_type ='CLASS';
1745 --AND cl.resource_class_id = def.resource_class_id
1746 --AND cl.resource_class_id = 3;
1747 --AND cl.resource_class_code = 'MATERIAL_ITEMS';
1748 EXCEPTION
1749 WHEN NO_DATA_FOUND THEN
1750 x_inventory_item_id := NULL;
1751 x_return_status:= FND_API.G_RET_STS_ERROR;
1752 --Need to get a proper message
1753 x_error_msg_code:= 'PA_NO_MAT_ITEM_ID';
1754 Return;
1755 WHEN OTHERS THEN
1756 x_inventory_item_id := NULL;
1757 x_return_status:= FND_API.G_RET_STS_ERROR;
1758 --Need to get a proper message
1759 x_error_msg_code:= 'PA_NO_MAT_ITEM_ID';
1760 Return;
1761 END;
1762 Pa_planning_resource_utils.Check_InventoryItem_or_ID(
1763 P_item_id => p_resource_code,
1764 P_item_name => p_resource_name,
1765 P_item_master_id => l_item_master_id,
1766 P_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
1767 X_item_id => l_inventory_item_id,
1768 X_return_status => l_return_status,
1769 X_error_msg_code => l_error_msg_code);
1770
1771 X_inventory_item_id := l_inventory_item_id;
1772 x_return_status := l_return_status;
1773 x_error_msg_code := l_error_msg_code;
1774 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1775 PA_UTILS.Add_Message('PA', l_error_msg_code, 'PLAN_RES',
1776 Pa_Planning_Resource_Pvt.g_token);
1777 Return;
1778 END IF;
1779 /******ELSIF*******/
1780 END IF;
1781 /*************/
1782 END IF;
1783 END IF;
1784
1785 IF P_PA_DEBUG_MODE = 'Y' THEN
1786 pa_debug.write('Validate_Resource: ' || g_module_name,'End Validate_Resource' ,1);
1787 END IF;
1788 END Validate_Resource;
1789 /***************************************************/
1790
1791 /*******************************************************
1792 * Procedure : Default_Expenditure_Type
1793 * 1. If Expenditure Type is available on the planning resource,
1794 * leave as is.
1795 * 2. If Exp Type is null:
1796 * i. Derive from BOM Resources, if the planning resource has one.
1797 * ii. Derive from Non-Labor Resource, if the planning resource has one.
1798 * iii. Derive from item if planning resource has one.
1799 * We could pass back null for the Expenditure type for the planning resource,
1800 * if none of the above yields a value.
1801 * *******************************************************/
1802 /**********************************************************
1803 * Bug - 3615477
1804 * Desc - In this proc we are going to be updating the value of
1805 * res_temp.expenditure_type and the final update is not
1806 * required while updating the expenditure_type value.
1807 * Also in the where clause we are checking for
1808 * res_temp.expenditure_type IS NULL
1809 **********************************************************/
1810 PROCEDURE Default_Expenditure_Type
1811 IS
1812 BEGIN
1813
1814 /*************************************************
1815 * Update to use when the expenditure_type is null
1816 * and bom_resource_id is not null. We use the below
1817 * Update to set the value for expenditure_type
1818 * ************************************************/
1819 --Bug 3615477
1820 --Also updating the value of fc_res_type_code.
1821 --Bug 3628429
1822 --Join to the pa_expenditure_types table.
1823 -- Fixed bug 3962699 - Removed the setting of fc_res_type_code from
1824 -- all the below selects. No need to set fc res type code - only
1825 -- need to set Exp Type.
1826 UPDATE pa_res_members_temp res_temp
1827 SET res_temp.expenditure_type =
1828 (SELECT exp.expenditure_type
1829 FROM bom_resources bom, pa_expenditure_types exp
1830 WHERE bom.resource_id = res_temp.bom_resource_id
1831 AND exp.expenditure_type = bom.expenditure_type
1832 AND exp.UNIT_OF_MEASURE = 'HOURS'
1833 AND ROWNUM = 1)
1834 WHERE res_temp.expenditure_type IS NULL
1835 AND res_temp.bom_resource_id IS NOT NULL;
1836
1837 /*************************************************
1838 * Update to use when the expenditure_type is null
1839 * and non_labor_resource is not null. We use the below
1840 * Update to set the value for expenditure_type
1841 *************************************************/
1842 --Bug 3615477
1843 --Also updating the value of fc_res_type_code.
1844 UPDATE pa_res_members_temp res_temp
1845 SET res_temp.expenditure_type =
1846 (SELECT n.expenditure_type
1847 FROM pa_non_labor_resources n
1848 WHERE n.non_labor_resource =
1849 res_temp.non_labor_resource
1850 AND ROWNUM = 1)
1851 WHERE res_temp.expenditure_type IS NULL
1852 AND res_temp.non_labor_resource IS NOT NULL;
1853
1854 -- Get the item's exp type if it exists
1855
1856 --Bug 3615477
1857 --Also updating the value of fc_res_type_code.
1858 UPDATE pa_res_members_temp res_temp
1859 SET res_temp.expenditure_type =
1860 PJM_COMMITMENT_UTILS.MTL_EXPENDITURE_TYPE(
1861 res_temp.organization_id, res_temp.inventory_item_id)
1862 WHERE res_temp.organization_id IS NOT NULL
1863 AND res_temp.inventory_item_id IS NOT NULL
1864 AND res_temp.expenditure_type IS NULL;
1865
1866 EXCEPTION
1867 WHEN OTHERS THEN
1868 RAISE;
1869 END Default_Expenditure_Type;
1870 /******************************************/
1871 /*******************************************************
1872 * Procedure : Default_Rate_Expenditure_Type
1873 * i. Derive from BOM Resources, if the planning resource has one.
1874 * ii. Derive from Non-Labor Resource, if the planning resource has one.
1875 * iii. Derive from item if planning resource has one.
1876 * iv. Derive from class
1877 * We could pass back null for the Rate Expenditure type for the planning
1878 * resource, if none of the above yields a value.
1879 * *******************************************************/
1880 /**********************************************************
1881 * Bug - 3615477
1882 * Desc - In this proc we are going to be updating the value of
1883 * res_temp.rate_expenditure_type and the final update is
1884 * required while updating the rate_expenditure_type value.
1885 * Also in the where condition we are checking for
1886 * res_temp.rate_expenditure_type IS NULL
1887 **********************************************************/
1888 PROCEDURE Default_Rate_Expenditure_Type
1889 IS
1890 l_resource_class_flag PA_RESOURCE_LISTS_ALL_BG.resource_class_flag%TYPE := 'Y'; --CBS
1891 BEGIN
1892 /*************************************************
1893 * Update to use when the rate_expenditure_type is null
1894 * and bom_resource_id is not null. We use the below
1895 * Update to set the value for rate_expenditure_type
1896 * ************************************************/
1897 --Bug 3628429
1898 --Join to the pa_expenditure_types table.
1899 UPDATE pa_res_members_temp res_temp
1900 SET res_temp.rate_expenditure_type =
1901 (SELECT exp.expenditure_type
1902 FROM bom_resources bom,pa_expenditure_types exp
1903 WHERE bom.resource_id = res_temp.bom_resource_id
1904 AND exp.expenditure_type = bom.expenditure_type
1905 AND exp.UNIT_OF_MEASURE = 'HOURS'
1906 AND ROWNUM = 1)
1907 WHERE res_temp.rate_expenditure_type IS NULL
1908 AND res_temp.bom_resource_id IS NOT NULL;
1909 /*************************************************
1910 * Update to use when the rate_expenditure_type is null
1911 * and non_labor_resource is not null. We use the below
1912 * Update to set the value for rate_expenditure_type
1913 *************************************************/
1914 UPDATE pa_res_members_temp res_temp
1915 SET res_temp.rate_expenditure_type =
1916 (SELECT n.expenditure_type
1917 FROM pa_non_labor_resources n
1918 WHERE n.non_labor_resource =
1919 res_temp.non_labor_resource
1920 AND ROWNUM = 1)
1921 WHERE res_temp.rate_expenditure_type IS NULL
1922 AND res_temp.non_labor_resource IS NOT NULL;
1923
1924 -- Get the item's exp type if it exists
1925
1926 UPDATE pa_res_members_temp res_temp
1927 SET res_temp.rate_expenditure_type =
1928 PJM_COMMITMENT_UTILS.MTL_EXPENDITURE_TYPE(
1929 res_temp.organization_id, res_temp.inventory_item_id)
1930 WHERE res_temp.organization_id IS NOT NULL
1931 AND res_temp.inventory_item_id IS NOT NULL
1932 AND res_temp.rate_expenditure_type IS NULL;
1933
1934 /**************************************************
1935 * Final Update which will default the value of
1936 * rate_expenditure_type based on the resource class id
1937 * **************************************************/
1938 --CBS Changes Start here
1939 begin
1940 select nvl(prlab.resource_class_flag,'Y') into l_resource_class_flag
1941 from PA_RESOURCE_LISTS_ALL_BG prlab,
1942 PA_RESOURCE_LIST_MEMBERS prlm,
1943 pa_res_members_temp prmt
1944 where prlab.resource_list_id = prlm.resource_list_id and
1945 prlm.resource_list_member_id = prmt.resource_list_member_id and
1946 rownum = 1;
1947 exception
1948 when others then
1949 l_resource_class_flag := 'Y';
1950 end;
1951 if l_resource_class_flag = 'N' then
1952 UPDATE pa_res_members_temp res_temp
1953 SET res_temp.rate_expenditure_type = (select expenditure_type_2
1954 from PA_RESOURCE_LIST_MEMBERS where
1955 resource_list_member_id = res_temp.resource_list_member_id)
1956 WHERE (res_temp.rate_expenditure_type IS NULL OR
1957 (res_temp.rate_expenditure_type = 'NO Val'));
1958 else
1959 UPDATE pa_res_members_temp res_temp
1960 SET res_temp.rate_expenditure_type =
1961 (SELECT expenditure_type
1962 FROM pa_plan_res_defaults
1963 WHERE resource_class_id =
1964 res_temp.resource_class_id
1965 AND ROWNUM = 1
1966 AND object_type = 'CLASS')
1967 WHERE (res_temp.rate_expenditure_type IS NULL OR
1968 (res_temp.rate_expenditure_type = 'NO Val'))
1969 AND res_temp.resource_class_id IS NOT NULL;
1970 end if;
1971 --CBS Changes End here
1972 EXCEPTION
1973 WHEN OTHERS THEN
1974 RAISE;
1975 END Default_Rate_Expenditure_Type;
1976 /******************************************/
1977
1978 /*********************************************************
1979 * Procedure : Default_OU
1980 * Description : To derive the default Org ID
1981 * First it will try to derive it from hr_organization_information
1982 * based on the organization_id.
1983 * If the Org_id is still null then we will get it based on the p_project_id
1984 * passed from pa_projects_all table.
1985 * ******************************************************/
1986 PROCEDURE default_ou(p_project_id IN PA_PROJECTS_ALL.PROJECT_ID%TYPE)
1987 IS
1988 l_proj_ou NUMBER;
1989 BEGIN
1990 UPDATE pa_res_members_temp res_temp
1991 SET org_id = (SELECT to_number(org_information1)
1992 FROM hr_organization_information
1993 WHERE org_information_context = 'Exp Organization Defaults'
1994 AND organization_id = res_temp.organization_id
1995 AND rownum = 1)
1996 WHERE res_temp.organization_id IS NOT NULL
1997 AND res_temp.org_id IS NULL;
1998
1999 BEGIN
2000 SELECT org_id
2001 INTO l_proj_ou
2002 FROM pa_projects_all
2003 WHERE project_id = p_project_id
2004 AND rownum = 1;
2005
2006 EXCEPTION WHEN NO_DATA_FOUND THEN
2007 l_proj_ou := NULL;
2008 END;
2009
2010 UPDATE pa_res_members_temp res_temp
2011 SET org_id = l_proj_ou
2012 WHERE res_temp.org_id IS NULL;
2013
2014 EXCEPTION
2015 WHEN OTHERS THEN
2016 RAISE;
2017 END default_ou;
2018 /************************************************/
2019
2020 /*********************************************************
2021 * Procedure : Default_UOM
2022 * Description : To derive the Unit of Measure based on the
2023 * resource_class_code. Update the UOM in the table with the appr
2024 * value.
2025 * ******************************************************/
2026 PROCEDURE Default_UOM
2027 IS
2028 BEGIN
2029 /*********************************************************
2030 * If the resource_class code in the table is 'PEOPLE' or EQUIPMENT
2031 * Then by default the Unit of measure should only be 'HOURS'
2032 *************************************************************/
2033 UPDATE pa_res_members_temp res_temp
2034 SET unit_of_measure = 'HOURS'
2035 WHERE res_temp.resource_class_code IN ('PEOPLE', 'EQUIPMENT')
2036 AND res_temp.unit_of_measure IS NULL;
2037
2038 /***********************************************************
2039 * If the resource class code is 'MATERIAL_ITEMS' and the
2040 * Inventory_item_id is not null then we need to derive the
2041 * Unit of measure from MTL_SYSTEM_ITEMS_b based on the inventory_item
2042 * And Organization id that matches the master_item_id in
2043 * pa_plan_res_defaults. If the planning resource has an organization,
2044 * use that; if not, use item master.
2045 ***************************************************************/
2046 UPDATE pa_res_members_temp res_temp
2047 SET unit_of_measure = (SELECT primary_uom_code
2048 FROM mtl_system_items_b items
2049 WHERE items.inventory_item_id =
2050 res_temp.inventory_item_id
2051 AND items.organization_id =
2052 res_temp.organization_id
2053 AND ROWNUM = 1)
2054 WHERE res_temp.resource_class_code = 'MATERIAL_ITEMS'
2055 AND res_temp.unit_of_measure IS NULL
2056 AND res_temp.organization_id IS NOT NULL
2057 AND res_temp.inventory_item_id IS NOT NULL;
2058
2059 UPDATE pa_res_members_temp res_temp
2060 SET unit_of_measure = (SELECT primary_uom_code
2061 FROM mtl_system_items_b items
2062 WHERE items.inventory_item_id =
2063 res_temp.inventory_item_id
2064 AND items.organization_id =
2065 (SELECT def.item_master_id
2066 FROM pa_resource_classes_b cls,
2067 pa_plan_res_defaults def
2068 WHERE cls.resource_class_code = 'MATERIAL_ITEMS'
2069 AND cls.resource_class_id = def.resource_class_id
2070 AND def.object_type = 'CLASS')
2071 AND ROWNUM = 1)
2072 WHERE res_temp.resource_class_code = 'MATERIAL_ITEMS'
2073 AND res_temp.unit_of_measure IS NULL
2074 AND res_temp.inventory_item_id IS NOT NULL;
2075
2076 /************************************************************
2077 * If the class is Financial Elements , or it is Material
2078 * Items but there is no item in the planning resource,
2079 * and there is an expenditure type, then take the UOM of
2080 * the expenditure type.
2081 ***************************************************************/
2082 UPDATE pa_res_members_temp res_temp
2083 SET res_temp.unit_of_measure = (SELECT unit_of_measure
2084 FROM pa_expenditure_types et
2085 WHERE et.expenditure_type = res_temp.expenditure_type
2086 AND ROWNUM = 1)
2087 WHERE res_temp.resource_class_code IN
2088 ('MATERIAL_ITEMS', 'FINANCIAL_ELEMENTS')
2089 AND res_temp.inventory_item_id IS NULL
2090 AND res_temp.unit_of_measure IS NULL
2091 AND res_temp.expenditure_type IS NOT NULL;
2092
2093 /******************************************************
2094 * If the Unit of measure column is still null, then
2095 * Default it to 'DOLLARS'
2096 *********************************************************/
2097 UPDATE pa_res_members_temp res_temp
2098 SET res_temp.unit_of_measure = 'DOLLARS'
2099 WHERE res_temp.unit_of_measure IS NULL;
2100
2101 EXCEPTION
2102 WHEN OTHERS THEN
2103 RAISE;
2104 END Default_UOM;
2105
2106 /*********************************************************
2107 * Procedure Default_Supplier
2108 * If Supplier is not null, pass it back.
2109 * 1. Code to get from per_cont_workers_current_x if
2110 * incurred_by_res_flag is 'N' - AI: need to revisit if we need to do it
2111 * for incurred by resources also
2112 * ******************************************************/
2113 PROCEDURE Default_Supplier
2114 IS
2115 BEGIN
2116 UPDATE pa_res_members_temp res_temp
2117 SET res_temp.vendor_id =
2118 (SELECT asgn.vendor_id
2119 FROM per_all_assignments_f asgn
2120 WHERE asgn.person_id = res_temp.person_id
2121 AND asgn.primary_flag = 'Y'
2122 AND asgn.assignment_type = 'C'
2123 AND trunc(sysdate) BETWEEN
2124 asgn.effective_start_date AND
2125 asgn.effective_end_date
2126 AND ROWNUM = 1)
2127 WHERE res_temp.vendor_id IS NULL
2128 -- Fix for bug 3940856 - get supplier for all cwk
2129 -- AND res_temp.incurred_by_res_flag = 'N'
2130 AND res_temp.person_id IS NOT NULL;
2131 EXCEPTION
2132 WHEN OTHERS THEN
2133 RAISE;
2134 END Default_Supplier;
2135
2136 /*********************************************************
2137 * Procedure Default_Currency_Code
2138 * ******************************************************/
2139 PROCEDURE Default_Currency_Code
2140 IS
2141
2142 BEGIN
2143 UPDATE pa_res_members_temp res_temp
2144 SET rate_func_curr_code = (
2145 SELECT FC.Currency_Code
2146 FROM FND_CURRENCIES FC,
2147 GL_SETS_OF_BOOKS GB,
2148 PA_IMPLEMENTATIONS_all IMP
2149 -- Bug 4656920 - removed nvl on imp.org_id for R12 MOAC
2150 WHERE imp.org_id = nvl(res_temp.org_id, -99)
2151 AND IMP.Set_Of_Books_ID = GB.Set_Of_Books_ID
2152 AND FC.Currency_Code =
2153 DECODE(IMP.Set_Of_Books_ID, NULL,NULL,GB.CURRENCY_CODE));
2154
2155 UPDATE pa_res_members_temp res_temp
2156 SET rate_func_curr_code = unit_of_measure
2157 WHERE inventory_item_id IS NOT NULL
2158 AND rate_based_flag = 'N';
2159
2160 -- Added for bug 3841920 - The UOM for all non-rate based
2161 -- transactions should be 'Currency'
2162 UPDATE pa_res_members_temp res_temp
2163 SET unit_of_measure = 'DOLLARS'
2164 WHERE inventory_item_id IS NOT NULL
2165 AND rate_based_flag = 'N';
2166
2167 EXCEPTION
2168 WHEN OTHERS THEN
2169 RAISE;
2170 END Default_Currency_Code;
2171 /**************************************************/
2172 /*********************************************************
2173 * Procedure : default_job
2174 * If job is not null, then leave as is
2175 * i. Default from person's HR Job if planning resource has a person
2176 * and the person is not the incurred by resource.
2177 * If we cannot default job, we will pass back null.
2178 * ******************************************************/
2179 PROCEDURE default_job
2180 IS
2181 BEGIN
2182 UPDATE pa_res_members_temp res_temp
2183 SET job_id = (SELECT job_id
2184 FROM per_all_assignments_f assn
2185 WHERE assn.person_id = res_temp.person_id
2186 AND SYSDATE BETWEEN assn.effective_start_date
2187 AND assn.effective_end_date
2188 AND assn.assignment_type in ('C','E')
2189 AND assn.primary_flag = 'Y'
2190 AND ROWNUM = 1)
2191 WHERE res_temp.job_id IS NULL
2192 AND res_temp.person_id IS NOT NULL;
2193
2194 UPDATE pa_res_members_temp res_temp
2195 SET job_id = (SELECT default_job_id
2196 FROM pa_project_role_types_vl role
2197 WHERE role.project_role_id = res_temp.project_role_id
2198 AND ROWNUM = 1)
2199 WHERE res_temp.job_id IS NULL
2200 AND res_temp.project_role_id IS NOT NULL;
2201
2202 EXCEPTION
2203 WHEN OTHERS THEN
2204 RAISE;
2205 END default_job;
2206
2207 /**************************************************/
2208 /*********************************************************
2209 * Procedure : default_person_type
2210 * If person_type is not null, then leave as is
2211 * i. Get from person's HR person record if planning resource has a person
2212 * and the person is not the incurred by resource.
2213 * Now, doing it for incurred by resource also, if inc by is a person
2214 * If we cannot default person_type, we will pass back null.
2215 * ******************************************************/
2216 PROCEDURE default_person_type
2217 IS
2218 BEGIN
2219 -- Issue with future dated or terminated employees/contingent workers?
2220
2221 UPDATE pa_res_members_temp res_temp
2222 SET person_type_code = (SELECT
2223 decode(peo.current_employee_flag, 'Y', 'EMP', 'CWK')
2224 FROM per_all_people_f peo
2225 WHERE peo.person_id = res_temp.person_id
2226 AND SYSDATE BETWEEN peo.effective_start_date
2227 AND peo.effective_end_date
2228 AND ROWNUM = 1)
2229 WHERE res_temp.person_type_code IS NULL
2230 -- AND res_temp.incurred_by_res_flag = 'N' -- Bug 3827566
2231 AND res_temp.person_id IS NOT NULL;
2232 EXCEPTION
2233 WHEN OTHERS THEN
2234 RAISE;
2235 END default_person_type;
2236
2237 /*******************************************************/
2238
2239 /*********************************************************
2240 * Procedure Default_Organization
2241 * If Organization is not null, then leave as is
2242 * i. Default from person's HR organization if planning resource has a person
2243 * and the person is not the incurred by resource.
2244 * ii. Default from bom resource, id planning resource has one.
2245 * iii. Default from item, if planning resource has one
2246 * If we cannot default organization, we will pass back null.
2247 * ******************************************************/
2248 PROCEDURE Default_Organization (p_project_id IN PA_PROJECTS_ALL.PROJECT_ID%TYPE)
2249 IS
2250
2251 l_organization_id NUMBER := NULL;
2252 BEGIN
2253
2254 /***************************************************
2255 * All of the below updates will only fire for
2256 * organization_id being null in the temp table.
2257 * If it is not null....then dont do anything.
2258 * ****************************************************/
2259
2260 /**************************************************
2261 * This Update will fire when the incurred_by_res_flag is Yes or No
2262 * and person_id IS NOT NULL.
2263 * We are updating the value for organization_id = derived value
2264 * based on person's HR org.
2265 * ***************************************************/
2266 UPDATE pa_res_members_temp res_temp
2267 SET organization_id = (SELECT a.organization_id
2268 FROM per_assignments_x a,
2269 pa_all_organizations org
2270 WHERE a.person_id = res_temp.person_id
2271 AND a.organization_id = org.organization_id
2272 AND org.inactive_date is null
2273 AND org.pa_org_use_type = 'EXPENDITURES'
2274 AND a.assignment_type in ('C','E')
2275 AND a.primary_flag = 'Y'
2276 AND ROWNUM = 1)
2277 WHERE res_temp.person_id IS NOT NULL
2278 AND res_temp.organization_id IS NULL;
2279
2280 /**************************************************
2281 * This Update will fire when the incurred_by_res_flag = 'N'
2282 * and bom_resource_id IS NOT NULL and organization_id IS NULL.
2283 * We are deriving the value for organization_id
2284 * ***************************************************/
2285 UPDATE pa_res_members_temp res_temp
2286 SET organization_id = (SELECT b.organization_id
2287 FROM bom_resources b
2288 WHERE b.resource_id = res_temp.bom_resource_id
2289 AND ROWNUM = 1)
2290 WHERE res_temp.incurred_by_res_flag = 'N'
2291 AND res_temp.bom_resource_id IS NOT NULL
2292 AND res_temp.organization_id IS NULL;
2293
2294 /**************************************************
2295 * This Update will fire when the incurred_by_res_flag = 'N'
2296 * and inventory_item_id IS NOT NULL and organization_id IS NULL.
2297 * We are deriving the value for organization_id
2298 * ***************************************************/
2299 UPDATE pa_res_members_temp res_temp
2300 SET organization_id = (SELECT i.organization_id
2301 FROM mtl_system_items_b i
2302 WHERE i.inventory_item_id = res_temp.inventory_item_id
2303 AND i.organization_id =
2304 (SELECT def.item_master_id
2305 FROM pa_resource_classes_b cls,
2306 pa_plan_res_defaults def
2307 WHERE cls.resource_class_code = 'MATERIAL_ITEMS'
2308 AND cls.resource_class_id = def.resource_class_id
2309 AND def.object_type = 'CLASS')
2310 AND ROWNUM = 1)
2311 WHERE res_temp.incurred_by_res_flag = 'N'
2312 AND res_temp.inventory_item_id IS NOT NULL
2313 AND res_temp.organization_id IS NULL;
2314
2315 /**************************************************
2316 * This Update will fire for all resources if the organization_id is null
2317 * We are deriving the value for organization_id from the project
2318 * ***************************************************/
2319
2320 BEGIN
2321 SELECT proj.carrying_out_organization_id
2322 INTO l_organization_id
2323 FROM pa_projects_all proj,
2324 pa_all_organizations org
2325 WHERE proj.project_id = p_project_id
2326 AND proj.carrying_out_organization_id = org.organization_id
2327 AND org.inactive_date is null
2328 AND org.pa_org_use_type = 'EXPENDITURES'
2329 AND ROWNUM = 1;
2330 EXCEPTION
2331 WHEN NO_DATA_FOUND THEN
2332 l_organization_id := NULL;
2333 WHEN OTHERS THEN
2334 l_organization_id := NULL;
2335 END;
2336
2337 IF l_organization_id IS NOT NULL THEN
2338 UPDATE pa_res_members_temp res_temp
2339 SET organization_id = l_organization_id
2340 WHERE res_temp.organization_id IS NULL;
2341 END IF;
2342
2343
2344 EXCEPTION
2345 WHEN OTHERS THEN
2346 RAISE;
2347
2348 END Default_Organization;
2349 /*************************************/
2350
2351 /***********************************************************
2352 * Function : Default_Rate_Based
2353 * Description : Function takes in resource_class_code,
2354 * inventory_item_id, expenditure_type,
2355 * and returns rate_based_flag.
2356 ***********************************************************/
2357 PROCEDURE default_rate_based
2358 IS
2359 BEGIN
2360 /****************************************
2361 * First Update all the rows no 'N' as by
2362 * default it should be N and not null.
2363 ******************************************/
2364 UPDATE pa_res_members_temp res_temp
2365 SET rate_based_flag = 'N';
2366
2367 /********************************************
2368 * Update it to 'Y' for resource_class_code
2369 * in 'PEOPLE' or 'EQUIPMENT'
2370 ***********************************************/
2371 UPDATE pa_res_members_temp res_temp
2372 SET rate_based_flag = 'Y'
2373 WHERE res_temp.resource_class_code in ('PEOPLE','EQUIPMENT');
2374
2375 UPDATE pa_res_members_temp res_temp
2376 SET rate_based_flag = 'Y'
2377 WHERE res_temp.resource_class_code
2378 = 'MATERIAL_ITEMS'
2379 AND res_temp.inventory_item_id IS NOT NULL
2380 AND NOT EXISTS (select 'Y'
2381 from mtl_system_items_b item,
2382 mtl_units_of_measure meas
2383 where item.inventory_item_id =
2384 res_temp.inventory_item_id
2385 and item.organization_id = res_temp.organization_id -- bug 10121923
2386 and item.primary_uom_code = meas.uom_code
2387 and meas.uom_class = 'Currency');
2388
2389 /**********************************************************
2390 * If the x_rate_exp_type is not null but exp_type is null
2391 * then use x_rate_exp_type to derive rate_based_flag.
2392 * Modified the existing update statement to include the foll:
2393 * - 'MATERIAL_ITEMS' in res_class_code.
2394 * - Added an nvl condition to derive based on the
2395 * rate expenditure type if the expenditure type is null
2396 * - added an extra condition to check that either one of
2397 * expenditure type or rate expenditure type should not be null.
2398 * ********************************************************/
2399 UPDATE pa_res_members_temp res_temp
2400 SET rate_based_flag =
2401 (SELECT c.cost_rate_flag
2402 FROM pa_expenditure_types c
2403 WHERE c.expenditure_type = res_temp.expenditure_type)
2404 -- nvl(res_temp.expenditure_type, Bug 3586021
2405 -- res_temp.rate_expenditure_type))
2406 WHERE res_temp.resource_class_code
2407 in ('MATERIAL_ITEMS', 'FINANCIAL_ELEMENTS')
2408 --Added the below cond so that it does not override prev upd.
2409 AND res_temp.inventory_item_id IS NULL
2410 AND res_temp.expenditure_type IS NOT NULL;
2411 -- AND (res_temp.expenditure_type IS NOT NULL OR
2412 -- res_temp.rate_expenditure_type is not null); -- Bug 3586021
2413 EXCEPTION
2414 WHEN OTHERS THEN
2415 RAISE;
2416 END Default_rate_based;
2417 /*******************************************************/
2418
2419 /*************************************************************
2420 * Procedure : get_resource_defaults
2421 * ***********************************************************/
2422 /************************************************************
2423 * Bug - 3473324
2424 * Added parameter x_incur_by_res_type, to get the res_type_code
2425 * for incur by resource.
2426 **********************************************************/
2427 PROCEDURE get_resource_defaults (
2428 P_resource_list_members IN SYSTEM.PA_NUM_TBL_TYPE,
2429 P_project_id IN PA_PROJECTS_ALL.PROJECT_ID%TYPE,
2430 X_resource_class_flag OUT NOCOPY SYSTEM.PA_VARCHAR2_1_TBL_TYPE,
2431 X_resource_class_code OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2432 X_resource_class_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2433 X_res_type_code OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2434 X_incur_by_res_type OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2435 X_person_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2436 X_job_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2437 X_person_type_code OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2438 X_named_role OUT NOCOPY SYSTEM.PA_VARCHAR2_80_TBL_TYPE,
2439 X_bom_resource_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2440 X_non_labor_resource OUT NOCOPY SYSTEM.PA_VARCHAR2_20_TBL_TYPE,
2441 X_inventory_item_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2442 X_item_category_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2443 X_project_role_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2444 X_organization_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2445 X_fc_res_type_code OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2446 X_expenditure_type OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2447 X_expenditure_category OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2448 X_event_type OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2449 X_revenue_category_code OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2450 X_supplier_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2451 X_spread_curve_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2452 X_etc_method_code OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2453 X_mfc_cost_type_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2454 X_incurred_by_res_flag OUT NOCOPY SYSTEM.PA_VARCHAR2_1_TBL_TYPE,
2455 X_incur_by_res_class_code OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2456 X_incur_by_role_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2457 X_unit_of_measure OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2458 X_org_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2459 X_rate_based_flag OUT NOCOPY SYSTEM.PA_VARCHAR2_1_TBL_TYPE,
2460 X_rate_expenditure_type OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2461 X_rate_func_curr_code OUT NOCOPY SYSTEM.PA_VARCHAR2_30_TBL_TYPE,
2462 -- X_rate_incurred_by_org_id OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE,
2463 X_msg_data OUT NOCOPY VARCHAR2,
2464 X_msg_count OUT NOCOPY NUMBER,
2465 X_return_status OUT NOCOPY VARCHAR2)
2466 IS
2467 --Declaration of Tables used for Bulk Fetch
2468 l_resource_list_member_id SYSTEM.PA_NUM_TBL_TYPE;
2469 l_resource_class_flag SYSTEM.PA_VARCHAR2_1_TBL_TYPE;
2470 l_resource_class_code SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2471 l_resource_class_id SYSTEM.PA_NUM_TBL_TYPE;
2472 l_person_id SYSTEM.PA_NUM_TBL_TYPE;
2473 l_job_id SYSTEM.PA_NUM_TBL_TYPE;
2474 l_person_type_code SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2475 l_named_role SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2476 l_bom_resource_id SYSTEM.PA_NUM_TBL_TYPE;
2477 l_non_labor_resource SYSTEM.PA_VARCHAR2_20_TBL_TYPE;
2478 l_inventory_item_id SYSTEM.PA_NUM_TBL_TYPE;
2479 l_item_category_id SYSTEM.PA_NUM_TBL_TYPE;
2480 l_project_role_id SYSTEM.PA_NUM_TBL_TYPE;
2481 l_organization_id SYSTEM.PA_NUM_TBL_TYPE;
2482 l_fc_res_type_code SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2483 l_expenditure_type SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2484 l_expenditure_category SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2485 l_event_type SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2486 l_revenue_category_code SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2487 l_supplier_id SYSTEM.PA_NUM_TBL_TYPE;
2488 l_spread_curve_id SYSTEM.PA_NUM_TBL_TYPE;
2489 l_etc_method_code SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2490 l_mfc_cost_type_id SYSTEM.PA_NUM_TBL_TYPE;
2491 l_incurred_by_res_flag SYSTEM.PA_VARCHAR2_1_TBL_TYPE;
2492 l_incur_by_res_class_code SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2493 l_incur_by_role_id SYSTEM.PA_NUM_TBL_TYPE;
2494 l_rate_expenditure_type SYSTEM.PA_VARCHAR2_30_TBL_TYPE;
2495 l_rate_incurred_by_org_id SYSTEM.PA_NUM_TBL_TYPE;
2496 l_rate_based_flag SYSTEM.PA_VARCHAR2_1_TBL_TYPE;
2497 l_exception EXCEPTION;
2498 l_last_analyzed all_tables.last_analyzed%TYPE;
2499 l_pa_schema VARCHAR2(30);
2500 /*********************************************
2501 * * Main Block
2502 * ***********************************************/
2503 BEGIN
2504 --Initialize the x_return_status
2505 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
2506
2507 --For bug 4039707, 4887312
2508
2509 -- Commenting out for TEMP fix to bug 4887312 - proper fix will be done soon.
2510 /*
2511 FND_STATS.SET_TABLE_STATS('PA',
2512 'PA_RES_MEMBERS_TEMP',
2513 100,
2514 10,
2515 100);
2516
2517 FND_STATS.SET_TABLE_STATS('PA',
2518 'PA_RES_MEMBER_ID_TEMP',
2519 100,
2520 10,
2521 100);
2522 */
2523 --End of bug 4039707, 4887312
2524
2525 -- Proper Fix for 4887312 *** RAMURTHY 03/01/06 02:33 pm ***
2526 -- It solves the issue above wrt commit by the FND_STATS.SET_TABLE_STATS call
2527 -- Bug 12533202: Replaced 'PA' by PJI_UTILS.GET_PA_SCHEMA_NAME
2528 PA_TASK_ASSIGNMENT_UTILS.set_table_stats(PJI_UTILS.GET_PA_SCHEMA_NAME,'PA_RES_MEMBERS_TEMP',100,10,100);
2529 PA_TASK_ASSIGNMENT_UTILS.set_table_stats(PJI_UTILS.GET_PA_SCHEMA_NAME,'PA_RES_MEMBER_ID_TEMP',100,10,100);
2530
2531 -- End Bug fix 4887312
2532
2533 /***********************************************
2534 * Deleting from the temp tables in the beginning as well
2535 * to be on the safe side.
2536 ***********************************************/
2537 DELETE FROM pa_res_members_temp;
2538
2539 DELETE FROM pa_res_member_id_temp;
2540 /************************************************************
2541 * Created a script to create 2 tables in the DB
2542 * 1. pa_res_member_id_temp which would only hold the
2543 * resource_list_member_id
2544 * 2. pa_res_members_temp which would hold the
2545 * resource_list_member_id and all the other attributes
2546 * which need to be defaulted
2547 *************************************************************/
2548
2549 /***************************************************************
2550 * First insert into the pa_res_member_id_temp table just the
2551 * resource_list_member_id which have been passed as IN param's
2552 **************************************************************/
2553 FOR i in p_resource_list_members.first..p_resource_list_members.last
2554 LOOP
2555 INSERT INTO pa_res_member_id_temp
2556 (resource_list_member_id,
2557 order_id)
2558 VALUES(p_resource_list_members(i),
2559 i);
2560 END LOOP;
2561
2562 /********************************************************
2563 * Bug : 3473425
2564 * Description : When Duplicate resource list member ID's
2565 * were passed as IN parameters into the PL/SQL
2566 * table, this proc was failing. To rectify that
2567 * we have now induded a column order_id in the
2568 * pa_res_members_temp table. And in the below insert
2569 * we are populating value into it, same as the order
2570 * id in pa_res_members_id_temp.
2571 *********************************************************/
2572 INSERT INTO pa_res_members_temp
2573 (resource_list_member_id,
2574 order_id,
2575 resource_class_flag ,
2576 resource_class_code ,
2577 resource_class_id ,
2578 --Added column newly
2579 res_type_code ,
2580 person_id ,
2581 job_id ,
2582 person_type_code ,
2583 named_role ,
2584 bom_resource_id ,
2585 non_labor_resource ,
2586 inventory_item_id ,
2587 item_category_id ,
2588 project_role_id ,
2589 organization_id ,
2590 fc_res_type_code ,
2591 expenditure_type ,
2592 expenditure_category ,
2593 Event_type ,
2594 revenue_category ,
2595 vendor_id ,
2596 spread_curve_id ,
2597 etc_method_code ,
2598 mfc_cost_type_id ,
2599 incurred_by_res_flag ,
2600 incur_by_res_class_code ,
2601 incur_by_role_id ,
2602 unit_of_measure ,
2603 org_id ,
2604 rate_based_flag ,
2605 rate_expenditure_type ,
2606 rate_func_curr_code ,
2607 rate_incurred_by_org_id )
2608 SELECT /*+ ORDERED */
2609 a.resource_list_member_id ,
2610 b.order_id,
2611 a.resource_class_flag ,
2612 a.resource_class_code ,
2613 a.resource_class_id ,
2614 typ.res_type_code ,
2615 a.person_id ,
2616 a.job_id ,
2617 a.person_type_code ,
2618 a.team_role ,
2619 a.bom_resource_id ,
2620 a.non_labor_resource ,
2621 a.inventory_item_id ,
2622 a.item_category_id ,
2623 a.project_role_id ,
2624 a.organization_id ,
2625 a.fc_res_type_code ,
2626 a.expenditure_type ,
2627 a.expenditure_category ,
2628 a.Event_type ,
2629 a.revenue_category ,
2630 a.vendor_id ,
2631 a.spread_curve_id ,
2632 a.etc_method_code ,
2633 a.mfc_cost_type_id ,
2634 a.incurred_by_res_flag ,
2635 a.incur_by_res_class_code ,
2636 a.incur_by_role_id ,
2637 NULL ,
2638 NULL ,
2639 NULL ,
2640 NULL ,
2641 NULL ,
2642 NULL
2643 FROM pa_res_member_id_temp b,
2644 pa_resource_list_members a,
2645 pa_res_formats_b fmt,
2646 pa_res_types_b typ
2647 WHERE a.resource_list_member_id = b.resource_list_member_id
2648 AND a.res_format_id = fmt.res_format_id
2649 AND fmt.res_type_id = typ.res_type_id(+);
2650
2651 /************************************************************
2652 * Bug 3466920
2653 * Bug Fix - Earlier we were not updating the res_type_code
2654 * for an incurred by resource. Hence it was always getting passed
2655 * as Null. We have however fixed the issue with the below Update.
2656 * This Update will fire when if the res_type_code is still null
2657 * and the incurred_by_res_flag='Y'
2658 ****************************************************************/
2659 UPDATE pa_res_members_temp res_temp
2660 SET res_type_code = DECODE(res_temp.person_id, NULL,
2661 DECODE(res_temp.job_id, NULL,
2662 DECODE(res_temp.person_type_code, NULL,
2663 DECODE(res_temp.incur_by_role_id, NULL,
2664 DECODE(res_temp.incur_by_res_class_code, NULL,
2665 NULL, 'RESOURCE_CLASS'),
2666 'ROLE'),
2667 'PERSON_TYPE'),
2668 'JOB'),
2669 'NAMED_PERSON')
2670 WHERE incurred_by_res_flag = 'Y'
2671 AND res_type_code IS NULL;
2672
2673 /******************************************************************
2674 * Call the Procedure Default_job which will Update the Job ID
2675 * in the temp table pa_res_members_temp with the correct
2676 * value.
2677 * *****************************************************************/
2678 pa_planning_resource_utils.default_job;
2679
2680 /******************************************************************
2681 * Call the Procedure default_person_type which will Update the
2682 * person_type_code in the temp table pa_res_members_temp with the correct
2683 * value.
2684 * *****************************************************************/
2685 pa_planning_resource_utils.default_person_type;
2686
2687 /******************************************************************
2688 * Call the Procedure Default_Organization which will
2689 * Update the organization_id and rate_incurred_by_org_id
2690 * in the temp table pa_res_members_temp with the correct
2691 * values.
2692 * *****************************************************************/
2693 pa_planning_resource_utils.default_organization(
2694 p_project_id => p_project_id);
2695
2696 /******************************************************************
2697 * Call the Procedure Default_Expenditure_Type which will
2698 * Update the expenditure_type
2699 * in the temp table pa_res_members_temp with the correct
2700 * values.
2701 * *****************************************************************/
2702 pa_planning_resource_utils.default_expenditure_type;
2703
2704 /******************************************************************
2705 * Call the Procedure Default_Rate_Expenditure_Type which will
2706 * Update the rate_expenditure_type
2707 * in the temp table pa_res_members_temp with the correct
2708 * values.
2709 * *****************************************************************/
2710 pa_planning_resource_utils.default_rate_expenditure_type;
2711
2712 /******************************************************************
2713 * Call the Procedure Default_Supplier which will
2714 * Update the vendor_id
2715 * in the temp table pa_res_members_temp with the correct
2716 * values.
2717 * *****************************************************************/
2718 pa_planning_resource_utils.default_supplier;
2719
2720 /******************************************************************
2721 * Call the Procedure Default_rate_based which will
2722 * Update the Rate_based_flag
2723 * in the temp table pa_res_members_temp with the correct
2724 * values.
2725 * *****************************************************************/
2726 pa_planning_resource_utils.default_rate_based;
2727
2728 /******************************************************************
2729 * Call the Procedure Default_OU which will
2730 * Update the OU
2731 * in the temp table pa_res_members_temp with the correct
2732 * values.
2733 *****************************************************************/
2734 pa_planning_resource_utils.default_ou(p_project_id);
2735
2736 /******************************************************************
2737 * Call the Procedure Default_UOM which will
2738 * Update the Unit_of_measure
2739 * in the temp table pa_res_members_temp with the correct
2740 * values.
2741 *****************************************************************/
2742 pa_planning_resource_utils.default_uom;
2743
2744 /******************************************************************
2745 * Call the Procedure Default_Currency_Code which will
2746 * Update the Rate_Func_Curr_Code
2747 * in the temp table pa_res_members_temp with the correct
2748 * values.
2749 *****************************************************************/
2750 pa_planning_resource_utils.default_currency_code;
2751
2752 /*****************************************************************
2753 * Fetch the values that are currently there in the pa_res_members_temp
2754 * table into the out var's. Select it from the Temp table
2755 * pa_res_members_temp and Bulk collect it into the OUT var's.
2756 *********************************************************************/
2757 /**********************************************************
2758 * Added an extra order ID join between the pa_res_members_temp
2759 * and pa_res_member_id_temp table to keep in sync.
2760 * Bug - 3473425
2761 **********************************************************/
2762 /*********************************************************
2763 * Bug - 3473324
2764 * Desc - If the incurred_by res_flag was 'N' or Null then we would
2765 * populate the res_type_code into the x_res_type_code parameter.
2766 * If the incur_by_res_flag was 'Y' then we would populate the
2767 * res_type_code into the x_incur_by_res_type parameter.
2768 ********************************************************/
2769 SELECT
2770 a.RESOURCE_CLASS_FLAG,
2771 a.RESOURCE_CLASS_CODE,
2772 a.RESOURCE_CLASS_ID,
2773 decode(a.incurred_by_res_flag,'Y',Null,a.RES_TYPE_CODE),
2774 decode(a.incurred_by_res_flag,'Y',a.RES_TYPE_CODE,Null),
2775 a.PERSON_ID,
2776 a.JOB_ID,
2777 a.PERSON_TYPE_CODE,
2778 a.NAMED_ROLE ,
2779 a.BOM_RESOURCE_ID,
2780 a.NON_LABOR_RESOURCE,
2781 a.INVENTORY_ITEM_ID,
2782 a.ITEM_CATEGORY_ID,
2783 a.PROJECT_ROLE_ID,
2784 a.ORGANIZATION_ID,
2785 a.FC_RES_TYPE_CODE,
2786 a.EXPENDITURE_TYPE,
2787 a.EXPENDITURE_CATEGORY,
2788 a.EVENT_TYPE,
2789 a.REVENUE_CATEGORY,
2790 a.VENDOR_ID,
2791 a.SPREAD_CURVE_ID,
2792 a.ETC_METHOD_CODE,
2793 a.MFC_COST_TYPE_ID,
2794 a.INCURRED_BY_RES_FLAG,
2795 a.INCUR_BY_RES_CLASS_CODE,
2796 a.INCUR_BY_ROLE_ID,
2797 a.UNIT_OF_MEASURE,
2798 a.ORG_ID,
2799 a.RATE_BASED_FLAG,
2800 a.RATE_EXPENDITURE_TYPE,
2801 a.RATE_FUNC_CURR_CODE
2802 --a.RATE_INCURRED_BY_ORG_ID
2803 BULK COLLECT INTO
2804 x_resource_class_flag ,
2805 x_resource_class_code ,
2806 x_resource_class_id ,
2807 x_res_type_code ,
2808 x_incur_by_res_type ,
2809 x_person_id ,
2810 x_job_id ,
2811 x_person_type_code ,
2812 x_named_role ,
2813 x_bom_resource_id ,
2814 x_non_labor_resource ,
2815 x_inventory_item_id ,
2816 x_item_category_id ,
2817 x_project_role_id ,
2818 x_organization_id ,
2819 x_fc_res_type_code ,
2820 x_expenditure_type ,
2821 x_expenditure_category ,
2822 x_event_type ,
2823 x_revenue_category_code ,
2824 x_supplier_id ,
2825 x_spread_curve_id ,
2826 x_etc_method_code ,
2827 x_mfc_cost_type_id ,
2828 x_incurred_by_res_flag ,
2829 x_incur_by_res_class_code ,
2830 x_incur_by_role_id ,
2831 x_unit_of_measure ,
2832 x_org_id ,
2833 x_rate_based_flag ,
2834 x_rate_expenditure_type ,
2835 x_rate_func_curr_code
2836 -- x_rate_incurred_by_org_id
2837 FROM pa_res_members_temp a,
2838 pa_res_member_id_temp b
2839 WHERE a.resource_list_member_id = b.resource_list_member_id
2840 AND a.order_id = b.order_id
2841 ORDER BY b.order_id;
2842
2843 IF x_resource_class_id.COUNT <> p_resource_list_members.COUNT then
2844 X_Return_Status := Fnd_Api.G_RET_STS_UNEXP_ERROR;
2845 RAISE l_exception;
2846 END IF;
2847
2848 DELETE FROM pa_res_members_temp;
2849
2850 DELETE FROM pa_res_member_id_temp;
2851
2852 EXCEPTION
2853 WHEN l_exception THEN
2854 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2855 Return;
2856 WHEN OTHERS THEN
2857 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2858 Return;
2859 END Get_Resource_defaults;
2860
2861
2862 /*********************************************************
2863 * Eugene's code
2864 ********************************************************/
2865
2866 /*********************************************************
2867 *Type (Procedure or Procedure): Function
2868 *Package Object Name : Ret_Resource_Name
2869 *Purpose: Return the resource name from a given
2870 * resource type code and id.
2871 * Public or Private API? Public
2872 * *******************************************************/
2873 Function Ret_Resource_Name (P_Res_Type_Code IN Varchar2,
2874 P_Person_Id IN Number,
2875 P_Bom_Resource_Id IN Number,
2876 P_Job_Id IN Number,
2877 P_Person_Type_Code IN Varchar2,
2878 P_Non_Labor_Resource IN Varchar2,
2879 P_Inventory_Item_Id IN Number,
2880 P_Resource_Class_Id IN Number,
2881 P_Item_Category_Id IN Number,
2882 p_res_assignment_id IN NUMBER default null ) Return Varchar2
2883
2884 Is
2885
2886 l_Return_Status Varchar2(1) := Null;
2887 l_Msg_Data Varchar2(30) := Null;
2888 l_Resource_Name Varchar2(1000) := Null;
2889
2890 Begin
2891
2892 pa_planning_resource_utils.Get_Resource_Name (
2893 P_Res_Type_Code => P_Res_Type_Code,
2894 P_Person_Id => P_Person_Id,
2895 P_Bom_Resource_Id => P_Bom_Resource_Id,
2896 P_Job_Id => P_Job_Id,
2897 P_Person_Type_Code => P_Person_Type_Code,
2898 P_Non_Labor_Resource => P_Non_Labor_Resource,
2899 P_Inventory_Item_Id => P_Inventory_Item_id,
2900 P_Item_Category_Id => P_Item_Category_Id,
2901 P_Resource_Class_Id => P_Resource_Class_Id,
2902 P_Proc_Func_Flag => 'F',
2903 p_res_assignment_id => p_res_assignment_id,
2904 X_Resource_Displayed => l_Resource_Name,
2905 X_Return_Status => l_Return_Status,
2906 X_Msg_Data => l_Msg_Data );
2907
2908 Return l_Resource_Name;
2909
2910 Exception
2911 When Others Then
2912 Raise;
2913
2914 End Ret_Resource_Name;
2915 /*****************************************/
2916
2917 /***************************************************************
2918 * Type (Procedure or Procedure): Procedure
2919 * Package Object Name: Get_Resource_Name
2920 **************************************************************/
2921 Procedure Get_Resource_Name ( P_Res_Type_Code IN Varchar2,
2922 P_Person_Id IN Number,
2923 P_Bom_Resource_Id IN Number,
2924 P_Job_Id IN Number,
2925 P_Person_Type_Code IN Varchar2,
2926 P_Non_Labor_Resource IN Varchar2,
2927 P_Inventory_Item_Id IN Number,
2928 P_Item_Category_Id IN Number,
2929 P_Resource_Class_Id IN Number,
2930 P_Proc_Func_Flag IN Varchar2,
2931 P_Res_Assignment_Id IN NUMBER,
2932 X_Resource_Displayed OUT NOCOPY Varchar2,
2933 X_Return_Status OUT NOCOPY Varchar2,
2934 X_Msg_Data OUT NOCOPY Varchar2 )
2935
2936 Is
2937
2938 l_Res_Type_Displayed Varchar2(1000) := Null;
2939
2940 --BAD_PER_IN_RES_LIST_MEM Exception;
2941 --NULL_PER_IN_RES_LIST_MEM Exception;
2942 --BAD_JOB_IN_RES_LIST_MEM Exception;
2943 --NULL_JOB_IN_RES_LIST_MEM Exception;
2944 --BAD_PER_TYPE_IN_LIST_MEM Exception;
2945 --NULL_PER_TYPE_IN_LIST_MEM Exception;
2946 BAD_BOM_LABOR_RES_IN_LST_MEM Exception;
2947 NULL_BOM_LABOR_RES_IN_LST_MEM Exception;
2948 BAD_BOM_EQUIP_RES_IN_LST_MEM Exception;
2949 NULL_BOM_EQUIP_RES_IN_LST_MEM Exception;
2950 BAD_ITEM_CAT_IN_LST_MEM Exception;
2951 NULL_ITEM_CAT_IN_LST_MEM Exception;
2952 BAD_INVEN_ITEM_IN_LST_MEM Exception;
2953 NULL_INVEN_ITEM_IN_LST_MEM Exception;
2954 --NULL_NLR_IN_LIST_MEM Exception;
2955 --BAD_RESCLASS_IN_LIST_MEM Exception;
2956 --NULL_RESCLASS_IN_LIST_MEM Exception;
2957 UNEXPEC_ERROR Exception;
2958 /*************************************************
2959 * Bug - 3485392
2960 * Description - Using the Known_as field from the
2961 * Per_people_x table to derive the
2962 * resource_name. If the known_as field is
2963 * Null then select the full_name.
2964 *************************************************/
2965 Cursor c_People (P_Person_Id IN Number) is
2966 Select
2967 --nvl(known_as,Full_Name)
2968 --Bug 3485392
2969 Full_Name
2970 From
2971 Per_People_X
2972 Where
2973 Person_Id = P_Person_Id
2974 And ( (Pa_Cross_Business_Grp.IsCrossBGProfile = 'N' AND
2975 Fnd_Profile.Value('PER_BUSINESS_GROUP_ID') = Business_Group_Id)
2976 OR Pa_Cross_Business_Grp.IsCrossBGProfile = 'Y');
2977
2978 Cursor c_Job (P_Job_Id In Number) Is
2979 Select
2980 Name
2981 From
2982 Per_Jobs
2983 Where
2984 Job_Id = P_Job_Id
2985 And ( (Pa_Cross_Business_Grp.IsCrossBGProfile = 'N' AND
2986 Fnd_Profile.Value('PER_BUSINESS_GROUP_ID') = Per_Jobs.Business_Group_Id )
2987 OR Pa_Cross_Business_Grp.IsCrossBGProfile = 'Y');
2988
2989 Cursor c_PersonType (P_Person_Type IN Varchar2) Is
2990 Select
2991 Meaning
2992 From
2993 pa_lookups
2994 Where
2995 Lookup_Type = 'PA_PERSON_TYPE'
2996 And Lookup_Code = P_Person_Type;
2997
2998 /*************************************************
2999 * Bug - 3461494
3000 * Description - Using the Resource code field from the
3001 * Bom_Resources table to derive the
3002 * resource_name instead of using the
3003 * description.
3004 *************************************************/
3005 Cursor c_BOM (P_BOM_Res_Id IN Number) Is
3006 Select
3007 Resource_code
3008 From
3009 Bom_Resources
3010 Where
3011 Resource_Id = P_BOM_Res_Id;
3012
3013 Cursor c_Item_Cat ( P_Item_Cat_Id IN Number ) Is
3014 Select fnd_Flex_ext.GET_SEGS('INV', 'MCAT', c.structure_id, c.category_id)
3015 From mtl_categories_v c
3016 Where c.Category_Id = P_Item_Cat_Id;
3017
3018 /**********************************************************
3019 * Bug - 3566965
3020 * Desc - Instead of the description we are now selecting the
3021 * segment1 field from Mtl_System_Items_b table as the
3022 * resource name.
3023 **********************************************************/
3024 Cursor c_Inven_Item (P_Inven_Item_Id IN Number ) Is
3025 Select
3026 segment1
3027 From
3028 Mtl_System_Items_b
3029 Where
3030 --Language = USERENV('LANG')
3031 Inventory_Item_Id = P_Inven_Item_Id
3032 and organization_id =
3033 (select
3034 item_master_id
3035 from
3036 pa_resource_classes_b cls,
3037 pa_plan_res_defaults def
3038 where
3039 def.resource_class_id = cls.resource_class_id
3040 and cls.resource_class_code = 'MATERIAL_ITEMS'
3041 and def.object_type = 'CLASS');
3042
3043 Cursor c_ResClass (P_Res_Class_Id IN Number) Is
3044 Select
3045 Name
3046 From
3047 Pa_Resource_Classes_Vl
3048 Where
3049 Resource_Class_Id = P_Res_Class_Id;
3050
3051 Cursor c_PrjRoles (P_Prj_Role_Id IN Number) Is
3052 Select
3053 Meaning
3054 From
3055 Pa_Project_Role_Types_vl
3056 Where
3057 Project_Role_Id = P_Prj_Role_Id;
3058
3059 Cursor c_Res_Attributes Is
3060 Select
3061 a.Res_Type_Code Res_Type_Code,
3062 a.Person_Id Person_Id,
3063 a.Job_Id Job_Id,
3064 a.Bom_Resource_Id Bom_Resource_Id,
3065 a.Inventory_Item_Id Inventory_Item_Id,
3066 a.Item_Category_Id Item_Category_Id,
3067 a.Person_Type_Code Person_Type_Code,
3068 a.Non_Labor_Resource Non_Labor_Resource,
3069 a.incurred_by_res_flag incurred_by_res_flag,
3070 c.Resource_Class_Id
3071 From
3072 Pa_Resource_Assignments a
3073 ,Pa_Resource_Classes_b c
3074 Where
3075 c.Resource_Class_Code = a.Resource_Class_Code
3076 And a.Resource_Assignment_Id = P_Res_Assignment_Id;
3077
3078
3079 l_Res_Attributes c_Res_Attributes%RowType;
3080 l_Person_Id Number;
3081 l_Job_Id Number;
3082 l_Inventory_Item_Id Number;
3083 l_Item_Category_Id Number;
3084 l_Non_Labor_Resource Varchar2(20);
3085 l_Bom_Resource_Id Number;
3086 l_Resource_Class_Id Number;
3087 l_Person_Type_Code Varchar2(30);
3088 l_Res_Type_Code Varchar2(30);
3089
3090 Begin
3091
3092 If P_Res_Assignment_Id Is Not Null Then
3093
3094 Open c_Res_Attributes;
3095 Fetch c_Res_Attributes Into l_Res_Attributes;
3096 Close c_Res_Attributes;
3097
3098 IF l_Res_Attributes.incurred_by_res_flag <> 'Y' THEN
3099 l_Person_Id := l_Res_Attributes.Person_Id;
3100 l_Job_Id := l_Res_Attributes.Job_Id;
3101 l_Inventory_Item_Id := l_Res_Attributes.Inventory_Item_Id;
3102 l_Item_Category_Id := l_Res_Attributes.Item_Category_Id;
3103 l_Bom_Resource_Id := l_Res_Attributes.Bom_Resource_Id;
3104 l_Resource_Class_Id := l_Res_Attributes.Resource_Class_Id;
3105 l_Non_Labor_Resource := l_Res_Attributes.Non_Labor_Resource;
3106 l_Person_Type_Code := l_Res_Attributes.Person_Type_Code;
3107 l_Res_Type_Code := l_Res_Attributes.Res_Type_Code;
3108 ELSE
3109 X_Resource_Displayed := NULL;
3110 RETURN; -- added to not do anything for incurred by resources
3111 END IF;
3112
3113 Else
3114
3115 l_Person_Id := P_Person_Id;
3116 l_Job_Id := P_Job_Id;
3117 l_Inventory_Item_Id := P_Inventory_Item_Id;
3118 l_Item_Category_Id := P_Item_Category_Id;
3119 l_Bom_Resource_Id := P_Bom_Resource_Id;
3120 l_Resource_Class_Id := P_Resource_Class_Id;
3121 l_Non_Labor_Resource := P_Non_Labor_Resource;
3122 l_Person_Type_Code := P_Person_Type_Code;
3123 l_Res_Type_Code := P_Res_Type_Code;
3124
3125 End If;
3126
3127 If l_Res_Type_Code = 'NAMED_PERSON' Then
3128
3129 If l_Person_Id is Not Null Then
3130
3131 Open c_People(P_Person_Id => l_Person_Id);
3132 Fetch c_People Into l_Res_Type_Displayed;
3133 If c_People%NotFound Then
3134 Close c_People;
3135 --Raise BAD_PER_IN_RES_LIST_MEM;
3136 Raise UNEXPEC_ERROR;
3137 End If;
3138 Close c_People;
3139
3140 Else
3141
3142 --Raise NULL_PER_IN_RES_LIST_MEM;
3143 Raise UNEXPEC_ERROR;
3144
3145 End If;
3146
3147 ElsIf l_Res_Type_Code = 'JOB' Then
3148
3149 If l_Job_Id is Not Null Then
3150
3151 Open c_Job(P_Job_Id => l_Job_Id);
3152 Fetch c_Job Into l_Res_Type_Displayed;
3153 If c_Job%NOTFOUND Then
3154 Close c_job;
3155 --Raise BAD_JOB_IN_RES_LIST_MEM;
3156 Raise UNEXPEC_ERROR;
3157 End If;
3158 Close c_Job;
3159
3160 Else
3161
3162 --Raise NULL_JOB_IN_RES_LIST_MEM;
3163 Raise UNEXPEC_ERROR;
3164
3165 End If;
3166
3167 ElsIf l_Res_Type_Code = 'PERSON_TYPE' Then
3168
3169 If l_Person_Type_Code is Not Null Then
3170
3171 -- CWK, EMP
3172 -- Get meaning from fnd_common_lookups
3173 Open c_PersonType(P_Person_Type => l_Person_Type_Code);
3174 Fetch c_PersonType Into l_Res_Type_Displayed;
3175 If c_PersonType%NOTFOUND Then
3176 Close c_PersonType;
3177 --Raise BAD_PER_TYPE_IN_LIST_MEM;
3178 Raise UNEXPEC_ERROR;
3179 End If;
3180 Close c_PersonType;
3181
3182 Else
3183
3184 --Raise NULL_PER_TYPE_IN_LIST_MEM;
3185 Raise UNEXPEC_ERROR;
3186
3187 End If;
3188
3189 ElsIf l_Res_Type_Code = 'BOM_LABOR' Then
3190
3191 If l_Bom_Resource_Id is Not Null Then
3192
3193 Open c_BOM(P_BOM_Res_Id => l_Bom_Resource_Id);
3194 Fetch c_BOM into l_Res_Type_Displayed;
3195
3196 If c_BOM%NotFound Then
3197
3198 Close c_BOM;
3199 Raise BAD_BOM_LABOR_RES_IN_LST_MEM;
3200
3201 End If;
3202
3203 Close c_BOM;
3204
3205 Else
3206
3207 Raise NULL_BOM_LABOR_RES_IN_LST_MEM;
3208
3209 End If;
3210
3211
3212 ElsIf l_Res_Type_Code = 'BOM_EQUIPMENT' Then
3213
3214 If l_Bom_Resource_Id is Not Null Then
3215
3216 Open c_BOM(P_BOM_Res_Id => l_Bom_Resource_Id);
3217 Fetch c_BOM into l_Res_Type_Displayed;
3218
3219 If c_BOM%NotFound Then
3220
3221 Close c_BOM;
3222 Raise BAD_BOM_EQUIP_RES_IN_LST_MEM;
3223
3224 End If;
3225
3226 Close c_BOM;
3227
3228 Else
3229
3230 Raise NULL_BOM_EQUIP_RES_IN_LST_MEM;
3231
3232 End If;
3233
3234 ElsIf l_Res_Type_Code = 'ITEM_CATEGORY' Then
3235
3236 If l_Item_Category_Id is Not Null Then
3237
3238 Open c_Item_Cat(P_Item_Cat_Id => l_Item_Category_Id);
3239 Fetch c_Item_Cat into l_Res_Type_Displayed;
3240
3241 If c_Item_Cat%NotFound Then
3242
3243 Close c_Item_Cat;
3244 Raise BAD_ITEM_CAT_IN_LST_MEM;
3245
3246 End If;
3247
3248 Close c_Item_Cat;
3249
3250 Else
3251
3252 Raise NULL_ITEM_CAT_IN_LST_MEM;
3253
3254 End If;
3255
3256 ElsIf l_Res_Type_Code = 'INVENTORY_ITEM' Then
3257
3258 If l_Inventory_Item_Id is Not Null Then
3259
3260 Open c_Inven_Item(P_Inven_Item_Id => l_Inventory_Item_Id);
3261 Fetch c_Inven_Item into l_Res_Type_Displayed;
3262
3263 If c_Inven_Item%NotFound Then
3264
3265 Close c_Inven_Item;
3266 Raise BAD_INVEN_ITEM_IN_LST_MEM;
3267
3268 End If;
3269
3270 Close c_Inven_Item;
3271
3272 Else
3273
3274 Raise NULL_INVEN_ITEM_IN_LST_MEM;
3275
3276 End If;
3277
3278 ElsIf l_Res_Type_Code = 'NON_LABOR_RESOURCE' Then
3279
3280 If l_Non_Labor_Resource is Not Null Then
3281
3282 l_Res_Type_Displayed := l_Non_Labor_Resource;
3283
3284 Else
3285
3286 --Raise NULL_NLR_IN_LIST_MEM;
3287 Raise UNEXPEC_ERROR;
3288
3289 End If;
3290
3291 ElsIf l_Res_Type_Code = 'RESOURCE_CLASS' Then
3292
3293 If l_Resource_Class_Id is Not Null Then
3294
3295 -- get name from pa_resource_classes_vl
3296 Open c_ResClass(P_Res_Class_Id => l_Resource_Class_Id);
3297 Fetch c_ResClass into l_Res_Type_Displayed;
3298 If c_ResClass%NOTFOUND Then
3299
3300 Close c_ResClass;
3301 --Raise BAD_RESCLASS_IN_LIST_MEM;
3302 Raise UNEXPEC_ERROR;
3303
3304 End If;
3305 Close c_ResClass;
3306
3307 Else
3308
3309 --Raise NULL_RESCLASS_IN_LIST_MEM;
3310 Raise UNEXPEC_ERROR;
3311
3312 End If;
3313
3314 End If;
3315
3316 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
3317 X_Msg_Data := Null;
3318 X_Resource_Displayed := l_Res_Type_Displayed;
3319
3320 Exception
3321 When UNEXPEC_ERROR THEN
3322 X_Return_Status := Fnd_Api.G_Ret_Sts_UnExp_Error;
3323 --x_msg_count := x_msg_count + 1;
3324 x_msg_data := Null;
3325 Fnd_Msg_Pub.Add_Exc_Msg(
3326 P_Pkg_Name => 'PA_PLANNING_RESOURCE_UTILS',
3327 P_Procedure_Name => 'Get_Resource_Name');
3328
3329 Return;
3330 /* When NULL_PER_IN_RES_LIST_MEM Then
3331 If P_Proc_Func_Flag = 'P' Then
3332 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3333 X_Msg_Data := 'PA_NULL_PER_IN_RES_LIST_MEM';
3334 Pa_Utils.Add_Message
3335 (P_App_Short_Name => 'PA',
3336 P_Msg_Name => 'PA_NULL_PER_IN_RES_LIST_MEM');
3337 Else
3338
3339 X_Resource_Displayed := Null;
3340
3341 End If;*/
3342 /*When BAD_PER_IN_RES_LIST_MEM Then
3343 If P_Proc_Func_Flag = 'P' Then
3344 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3345 X_Msg_Data := 'PA_BAD_PER_IN_RES_LIST_MEM';
3346 Pa_Utils.Add_Message
3347 (P_App_Short_Name => 'PA',
3348 P_Msg_Name => 'PA_BAD_PER_IN_RES_LIST_MEM');
3349 Else
3350
3351 X_Resource_Displayed := Null;
3352
3353 End If;*/
3354
3355 /*When NULL_JOB_IN_RES_LIST_MEM Then
3356 If P_Proc_Func_Flag = 'P' Then
3357 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3358 X_Msg_Data := 'PA_NULL_JOB_IN_RES_LIST_MEM';
3359 Pa_Utils.Add_Message
3360 (P_App_Short_Name => 'PA',
3361 P_Msg_Name => 'PA_NULL_JOB_IN_RES_LIST_MEM');
3362 Else
3363 X_Resource_Displayed := Null;
3364 End If;*/
3365 /*When BAD_JOB_IN_RES_LIST_MEM Then
3366 If P_Proc_Func_Flag = 'P' Then
3367 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3368 X_Msg_Data := 'PA_BAD_JOB_IN_RES_LIST_MEM';
3369 Pa_Utils.Add_Message
3370 (P_App_Short_Name => 'PA',
3371 P_Msg_Name => 'PA_BAD_JOB_IN_RES_LIST_MEM');
3372 Else
3373 X_Resource_Displayed := Null;
3374 End If;*/
3375 /*When NULL_PER_TYPE_IN_LIST_MEM Then
3376 If P_Proc_Func_Flag = 'P' Then
3377 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3378 X_Msg_Data := 'PA_NULL_PER_TYPE_IN_LIST_MEM';
3379 Pa_Utils.Add_Message
3380 (P_App_Short_Name => 'PA',
3381 P_Msg_Name => 'PA_NULL_PER_TYPE_IN_LIST_MEM');
3382 Else
3383 X_Resource_Displayed := Null;
3384 End If;*/
3385 /*When BAD_PER_TYPE_IN_LIST_MEM Then
3386 If P_Proc_Func_Flag = 'P' Then
3387 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3388 X_Msg_Data := 'PA_BAD_PER_TYPE_IN_LIST_MEM';
3389 Pa_Utils.Add_Message
3390 (P_App_Short_Name => 'PA',
3391 P_Msg_Name => 'PA_BAD_PER_TYPE_IN_LIST_MEM');
3392 Else
3393 X_Resource_Displayed := Null;
3394 End If;*/
3395 When BAD_BOM_LABOR_RES_IN_LST_MEM Then
3396 If P_Proc_Func_Flag = 'P' Then
3397 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3398 X_Msg_Data := 'PA_BAD_BOM_LABOR_RES_LIST_MEM';
3399 Pa_Utils.Add_Message
3400 (P_App_Short_Name => 'PA',
3401 P_Msg_Name => 'PA_BAD_BOM_LABOR_RES_LIST_MEM');
3402 Else
3403 X_Resource_Displayed := Null;
3404 End If;
3405 When NULL_BOM_LABOR_RES_IN_LST_MEM Then
3406 If P_Proc_Func_Flag = 'P' Then
3407 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3408 X_Msg_Data := 'PA_NULL_BOM_LABOR_RES_LIST_MEM';
3409 Pa_Utils.Add_Message
3410 (P_App_Short_Name => 'PA',
3411 P_Msg_Name => 'PA_NULL_BOM_LABOR_RES_LIST_MEM');
3412 Else
3413 X_Resource_Displayed := Null;
3414 End If;
3415 When BAD_BOM_EQUIP_RES_IN_LST_MEM Then
3416 If P_Proc_Func_Flag = 'P' Then
3417 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3418 X_Msg_Data := 'PA_BAD_BOMEQUIP_RES_IN_LST_MEM';
3419 Pa_Utils.Add_Message
3420 (P_App_Short_Name => 'PA',
3421 P_Msg_Name => 'PA_BAD_BOMEQUIP_RES_IN_LST_MEM');
3422 Else
3423 X_Resource_Displayed := Null;
3424 End If;
3425 When NULL_BOM_EQUIP_RES_IN_LST_MEM Then
3426 If P_Proc_Func_Flag = 'P' Then
3427 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3428 X_Msg_Data := 'PA_NULL_BOM_EQUIP_RES_LIST_MEM';
3429 Pa_Utils.Add_Message
3430 (P_App_Short_Name => 'PA',
3431 P_Msg_Name => 'PA_NULL_BOM_EQUIP_RES_LIST_MEM');
3432 Else
3433 X_Resource_Displayed := Null;
3434 End If;
3435 When BAD_ITEM_CAT_IN_LST_MEM Then
3436 If P_Proc_Func_Flag = 'P' Then
3437 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3438 X_Msg_Data := 'PA_BAD_ITEM_CAT_IN_LST_MEM';
3439 Pa_Utils.Add_Message
3440 (P_App_Short_Name => 'PA',
3441 P_Msg_Name => 'PA_BAD_ITEM_CAT_IN_LST_MEM');
3442 Else
3443 X_Resource_Displayed := Null;
3444 End If;
3445 When NULL_ITEM_CAT_IN_LST_MEM Then
3446 If P_Proc_Func_Flag = 'P' Then
3447 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3448 X_Msg_Data := 'PA_NULL_ITEM_CAT_IN_LST_MEM';
3449 Pa_Utils.Add_Message
3450 (P_App_Short_Name => 'PA',
3451 P_Msg_Name => 'PA_NULL_ITEM_CAT_IN_LST_MEM');
3452 Else
3453 X_Resource_Displayed := Null;
3454 End If;
3455 When BAD_INVEN_ITEM_IN_LST_MEM Then
3456 If P_Proc_Func_Flag = 'P' Then
3457 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3458 X_Msg_Data := 'PA_BAD_INVEN_ITEM_IN_LST_MEM';
3459 Pa_Utils.Add_Message
3460 (P_App_Short_Name => 'PA',
3461 P_Msg_Name => 'PA_BAD_INVEN_ITEM_IN_LST_MEM');
3462 Else
3463 X_Resource_Displayed := Null;
3464 End If;
3465 When NULL_INVEN_ITEM_IN_LST_MEM Then
3466 If P_Proc_Func_Flag = 'P' Then
3467 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3468 X_Msg_Data := 'PA_NULL_INVEN_ITEM_IN_LST_MEM';
3469 Pa_Utils.Add_Message
3470 (P_App_Short_Name => 'PA',
3471 P_Msg_Name => 'PA_NULL_INVEN_ITEM_IN_LST_MEM');
3472 Else
3473 X_Resource_Displayed := Null;
3474 End If;
3475 /*When NULL_NLR_IN_LIST_MEM Then
3476 If P_Proc_Func_Flag = 'P' Then
3477 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3478 X_Msg_Data := 'PA_NULL_NLR_IN_LIST_MEM';
3479 Pa_Utils.Add_Message
3480 (P_App_Short_Name => 'PA',
3481 P_Msg_Name => 'PA_NULL_NLR_IN_LIST_MEM');
3482 Else
3483 X_Resource_Displayed := Null;
3484 End If;*/
3485 /*When NULL_RESCLASS_IN_LIST_MEM Then
3486 If P_Proc_Func_Flag = 'P' Then
3487 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3488 X_Msg_Data := 'PA_NULL_RESCLASS_IN_LIST_MEM';
3489 Pa_Utils.Add_Message
3490 (P_App_Short_Name => 'PA',
3491 P_Msg_Name => 'PA_NULL_RESCLASS_IN_LIST_MEM');
3492 Else
3493 X_Resource_Displayed := Null;
3494 End If;*/
3495 /*When BAD_RESCLASS_IN_LIST_MEM Then
3496 If P_Proc_Func_Flag = 'P' Then
3497 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3498 X_Msg_Data := 'PA_BAD_RESCLASS_IN_LIST_MEM';
3499 Pa_Utils.Add_Message
3500 (P_App_Short_Name => 'PA',
3501 P_Msg_Name => 'PA_BAD_RESCLASS_IN_LIST_MEM');
3502 Else
3503 X_Resource_Displayed := Null;
3504 End If;*/
3505 When Others Then
3506 Raise;
3507
3508 End Get_Resource_Name;
3509 /**************************************************/
3510 /***********************************************************
3511 *Type (Procedure or Procedure): Function
3512 *Package Object Name: Ret_Fin_Category_Name
3513 *Purpose: Return the resource name from a given
3514 * resource type code.
3515 *Public or Private API?
3516 **************************************************************/
3517 Function Ret_Fin_Category_Name ( P_FC_Res_Type_Code IN Varchar2,
3518 P_Expenditure_Type IN Varchar2,
3519 P_Expenditure_Category IN Varchar2,
3520 P_Event_Type IN Varchar2,
3521 P_Revenue_Category_Code IN Varchar2,
3522 p_res_assignment_id IN NUMBER default null) Return Varchar2
3523 Is
3524
3525 l_Return_Status Varchar2(1) := Null;
3526 l_Msg_Data Varchar2(30) := Null;
3527 l_Fin_Cat_Displayed Varchar2(80) := Null;
3528
3529 Begin
3530
3531 Pa_Planning_Resource_Utils.Get_Fin_Category_Name (
3532 P_FC_Res_Type_Code => P_FC_Res_Type_Code,
3533 P_Expenditure_Type => P_Expenditure_Type,
3534 P_Expenditure_Category => P_Expenditure_Category,
3535 P_Event_Type => P_Event_Type,
3536 P_Revenue_Category_Code => P_Revenue_Category_Code,
3537 P_Proc_Func_Flag => 'F',
3538 p_res_assignment_id => p_res_assignment_id,
3539 X_Fin_Cat_Displayed => l_Fin_Cat_Displayed,
3540 X_Return_Status => l_Return_Status,
3541 X_Msg_Data => l_Msg_Data );
3542
3543 Return l_Fin_Cat_Displayed;
3544
3545 Exception
3546 When Others Then
3547 Raise;
3548
3549 End Ret_Fin_Category_Name;
3550
3551
3552 /**************************************************************
3553 * Procedure : Get_Fin_Category_Name
3554 * ***********************************************************/
3555
3556 Procedure Get_Fin_Category_Name ( P_FC_Res_Type_Code IN Varchar2,
3557 P_Expenditure_Type IN Varchar2,
3558 P_Expenditure_Category IN Varchar2,
3559 P_Event_Type IN Varchar2,
3560 P_Revenue_Category_Code IN Varchar2,
3561 P_Proc_Func_Flag IN Varchar2,
3562 P_Res_Assignment_Id IN NUMBER default null,
3563 X_Fin_Cat_Displayed OUT NOCOPY Varchar2,
3564 X_Return_Status OUT NOCOPY Varchar2,
3565 X_Msg_Data OUT NOCOPY Varchar2 )
3566
3567 Is
3568
3569 l_Fin_Cat_Displayed Varchar2(80) := Null;
3570
3571 --NULL_EXP_TYPE_IN_LIST_MEM Exception;
3572 --NULL_EXP_CAT_IN_LIST_MEM Exception;
3573 --NULL_EVENT_TYPE_IN_LIST_MEM Exception;
3574 --NULL_REV_CAT_IN_LIST_MEM Exception;
3575 --NULL_FC_RES_TYPE_IN_LIST_MEM Exception;
3576 INV_FC_RES_TYPE_IN_LIST_MEM Exception;
3577 UNEXPEC_ERROR Exception;
3578
3579 Cursor c_Res_Attributes
3580 Is
3581 Select
3582 Fc_Res_Type_Code,
3583 Expenditure_Type,
3584 Expenditure_Category,
3585 Event_Type,
3586 Revenue_Category_Code
3587 From
3588 Pa_Resource_Assignments
3589 Where
3590 Resource_Assignment_Id = P_Res_Assignment_Id;
3591
3592 l_Res_Attributes c_Res_Attributes%RowType;
3593 l_Fc_Res_Type_Code Varchar2(30);
3594 l_Expenditure_Type Varchar2(30);
3595 l_Expenditure_Category Varchar2(30);
3596 l_Event_Type Varchar2(30);
3597 l_Revenue_Category_Code Varchar2(30);
3598
3599 Begin
3600
3601 If P_Res_Assignment_Id Is Not Null Then
3602
3603 Open c_Res_Attributes;
3604 Fetch c_Res_Attributes Into l_Res_Attributes;
3605 Close c_Res_Attributes;
3606
3607 l_Fc_Res_Type_Code := l_Res_Attributes.Fc_Res_Type_Code;
3608 l_Expenditure_Type := l_Res_Attributes.Expenditure_Type;
3609 l_Expenditure_Category := l_Res_Attributes.Expenditure_Category;
3610 l_Event_Type := l_Res_Attributes.Event_Type;
3611 l_Revenue_Category_Code := l_Res_Attributes.Revenue_Category_Code;
3612
3613 Else
3614
3615 l_Fc_Res_Type_Code := P_Fc_Res_Type_Code;
3616 l_Expenditure_Type := P_Expenditure_Type;
3617 l_Expenditure_Category := P_Expenditure_Category;
3618 l_Event_Type := P_Event_Type;
3619 l_Revenue_Category_Code := P_Revenue_Category_Code;
3620
3621 End If;
3622
3623 If l_FC_Res_Type_Code is Not Null Then
3624
3625 If l_FC_Res_Type_Code = 'EXPENDITURE_TYPE' Then
3626
3627 If l_Expenditure_Type is Not Null Then
3628
3629 l_Fin_Cat_Displayed := l_Expenditure_Type;
3630
3631 Else
3632
3633 --Raise NULL_EXP_TYPE_IN_LIST_MEM;
3634 Raise UNEXPEC_ERROR;
3635
3636 End If;
3637
3638 ElsIf l_FC_Res_Type_Code = 'EXPENDITURE_CATEGORY' Then
3639
3640 If l_Expenditure_Category is Not Null Then
3641
3642 l_Fin_Cat_Displayed := l_Expenditure_Category;
3643
3644 Else
3645
3646 --Raise NULL_EXP_CAT_IN_LIST_MEM;
3647 Raise UNEXPEC_ERROR;
3648
3649 End If;
3650
3651 ElsIf l_FC_Res_Type_Code = 'EVENT_TYPE' Then
3652
3653 If l_Event_Type is Not Null Then
3654
3655 l_Fin_Cat_Displayed := l_Event_Type;
3656
3657 Else
3658
3659 --Raise NULL_EVENT_TYPE_IN_LIST_MEM;
3660 Raise UNEXPEC_ERROR;
3661
3662 End If;
3663
3664 ElsIf l_FC_Res_Type_Code = 'REVENUE_CATEGORY' Then
3665
3666 If l_Revenue_Category_Code is Not Null Then
3667
3668 BEGIN
3669
3670 SELECT lk.Meaning
3671 INTO l_Fin_Cat_Displayed
3672 FROM PA_LOOKUPS lk
3673 WHERE lk.Lookup_Type = 'REVENUE CATEGORY'
3674 and lk.lookup_code = l_revenue_category_code;
3675
3676 EXCEPTION
3677 WHEN OTHERS THEN
3678 l_Fin_Cat_Displayed := NULL;
3679 --Raise NULL_REV_CAT_IN_LIST_MEM;
3680 Raise UNEXPEC_ERROR;
3681
3682 END;
3683
3684 Else
3685
3686 --Raise NULL_REV_CAT_IN_LIST_MEM;
3687 Raise UNEXPEC_ERROR;
3688
3689 End If;
3690
3691 Else
3692
3693 Raise INV_FC_RES_TYPE_IN_LIST_MEM;
3694
3695 End If;
3696
3697 Else
3698
3699 --Raise NULL_FC_RES_TYPE_IN_LIST_MEM;
3700 -- Raise UNEXPEC_ERROR;
3701 -- Return null if resource/assignment does not have fin cat
3702 l_Fin_Cat_Displayed := NULL;
3703
3704 End If; -- P_FC_Res_Type_Code is not null
3705
3706 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
3707 X_Msg_Data := Null;
3708 X_Fin_Cat_Displayed := l_Fin_Cat_Displayed;
3709
3710 Exception
3711 When UNEXPEC_ERROR THEN
3712 X_Return_Status := Fnd_Api.G_Ret_Sts_UnExp_Error;
3713 --x_msg_count := x_msg_count + 1;
3714 x_msg_data := Null;
3715 Fnd_Msg_Pub.Add_Exc_Msg(
3716 P_Pkg_Name => 'PA_PLANNING_RESOURCE_UTILS',
3717 P_Procedure_Name => 'Get_Fin_Category_Name');
3718 Return;
3719 /*When NULL_FC_RES_TYPE_IN_LIST_MEM Then
3720
3721 If P_Proc_Func_Flag = 'P' Then
3722
3723 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3724 X_Msg_Data := 'PA_NULL_FC_RESTYPE_IN_LIST_MEM';
3725 Pa_Utils.Add_Message
3726 (P_App_Short_Name => 'PA',
3727 P_Msg_Name => 'PA_NULL_FC_RESTYPE_IN_LIST_MEM');
3728 Else
3729
3730 X_Fin_Cat_Displayed := Null;
3731
3732 End If;*/
3733
3734 /*When NULL_EXP_TYPE_IN_LIST_MEM Then
3735
3736 If P_Proc_Func_Flag = 'P' Then
3737
3738 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3739 X_Msg_Data := 'PA_NULL_EXP_TYPE_IN_LIST_MEM';
3740 Pa_Utils.Add_Message
3741 (P_App_Short_Name => 'PA',
3742 P_Msg_Name => 'PA_NULL_EXP_TYPE_IN_LIST_MEM');
3743
3744 Else
3745
3746 X_Fin_Cat_Displayed := Null;
3747
3748 End If;*/
3749
3750 /*When NULL_EXP_CAT_IN_LIST_MEM Then
3751
3752 If P_Proc_Func_Flag = 'P' Then
3753
3754 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3755 X_Msg_Data := 'PA_NULL_EXP_CAT_IN_LIST_MEM';
3756 Pa_Utils.Add_Message
3757 (P_App_Short_Name => 'PA',
3758 P_Msg_Name => 'PA_NULL_EXP_CAT_IN_LIST_MEM');
3759
3760 Else
3761
3762 X_Fin_Cat_Displayed := Null;
3763
3764 End If;*/
3765
3766 /*When NULL_EVENT_TYPE_IN_LIST_MEM Then
3767
3768 If P_Proc_Func_Flag = 'P' Then
3769
3770 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3771 X_Msg_Data := 'PA_NULL_EVENT_TYPE_IN_LIST_MEM';
3772 Pa_Utils.Add_Message
3773 (P_App_Short_Name => 'PA',
3774 P_Msg_Name => 'PA_NULL_EVENT_TYPE_IN_LIST_MEM');
3775
3776 Else
3777
3778 X_Fin_Cat_Displayed := Null;
3779
3780 End If;*/
3781
3782 /*When NULL_REV_CAT_IN_LIST_MEM Then
3783
3784 If P_Proc_Func_Flag = 'P' Then
3785
3786 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3787 X_Msg_Data := 'PA_NULL_REV_CAT_IN_LIST_MEM';
3788 Pa_Utils.Add_Message
3789 (P_App_Short_Name => 'PA',
3790 P_Msg_Name => 'PA_NULL_REV_CAT_IN_LIST_MEM');
3791
3792 Else
3793
3794 X_Fin_Cat_Displayed := Null;
3795
3796 End If;*/
3797
3798 When INV_FC_RES_TYPE_IN_LIST_MEM Then
3799
3800 If P_Proc_Func_Flag = 'P' Then
3801
3802 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3803 X_Msg_Data := 'PA_INV_FC_RESTYPE_IN_LIST_MEM';
3804 Pa_Utils.Add_Message
3805 (P_App_Short_Name => 'PA',
3806 P_Msg_Name => 'PA_INV_FC_RESTYPE_IN_LIST_MEM');
3807
3808 Else
3809
3810 X_Fin_Cat_Displayed := Null;
3811
3812 End If;
3813
3814 When Others Then
3815 Raise;
3816
3817 End Get_Fin_Category_Name;
3818
3819 /**************************************************/
3820
3821 /********************************************************
3822 * Function : Ret_Organization_Name
3823 * ********************************************************/
3824 Function Ret_Organization_Name ( P_Organization_Id IN Number ) Return Varchar2
3825
3826 Is
3827
3828 l_Return_Status Varchar2(1) := Null;
3829 l_Msg_Data Varchar2(30) := Null;
3830 l_Organization_Name Varchar2(240) := Null;
3831
3832 Begin
3833
3834 pa_planning_resource_utils.Get_Organization_Name (
3835 P_Organization_Id => P_Organization_Id,
3836 P_Proc_Func_Flag => 'F',
3837 X_Org_Displayed => l_Organization_Name,
3838 X_Return_Status => l_Return_Status,
3839 X_Msg_Data => l_Msg_Data );
3840
3841 Return l_Organization_Name;
3842
3843 Exception
3844 When Others Then
3845 Raise;
3846
3847 End Ret_Organization_Name;
3848 /*************************************/
3849 /********************************************************
3850 * Procedure : Get_Organization_name
3851 * *****************************************************/
3852 Procedure Get_Organization_Name ( P_Organization_Id IN Number,
3853 P_Proc_Func_Flag IN Varchar2,
3854 X_Org_Displayed OUT NOCOPY Varchar2,
3855 X_Return_Status OUT NOCOPY Varchar2,
3856 X_Msg_Data OUT NOCOPY Varchar2 )
3857
3858 Is
3859
3860 l_Org_Displayed Varchar2(240) := Null;
3861
3862 --BAD_ORG_ID_IN_LIST_MEM Exception;
3863 --NULL_ORG_ID_IN_LIST_MEM Exception;
3864 UNEXPEC_ERROR Exception;
3865
3866 Begin
3867
3868 If P_Organization_Id is Not Null Then
3869
3870 -- Get organization name from hr_all_organization_units_tl
3871 Begin
3872
3873 l_Org_Displayed := Pa_Expenditures_Utils.GetOrgTlName(P_Organization_Id);
3874
3875 Exception
3876 When Others Then
3877 --Raise BAD_ORG_ID_IN_LIST_MEM;
3878 Raise UNEXPEC_ERROR;
3879 End;
3880
3881 Else
3882
3883 --Raise NULL_ORG_ID_IN_LIST_MEM;
3884 -- Raise UNEXPEC_ERROR;
3885 l_Org_Displayed := NULL;
3886
3887 End If;
3888
3889 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
3890 X_Msg_Data := Null;
3891 X_Org_Displayed := l_Org_Displayed;
3892
3893 Exception
3894 When UNEXPEC_ERROR THEN
3895 X_Return_Status := Fnd_Api.G_Ret_Sts_UnExp_Error;
3896 --x_msg_count := x_msg_count + 1;
3897 x_msg_data := Null;
3898 Fnd_Msg_Pub.Add_Exc_Msg(
3899 P_Pkg_Name => 'PA_PLANNING_RESOURCE_UTILS',
3900 P_Procedure_Name => 'Get_Organization_Name');
3901 Return;
3902 /*When NULL_ORG_ID_IN_LIST_MEM Then
3903
3904 If P_Proc_Func_Flag = 'P' Then
3905
3906 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3907 X_Msg_Data := 'PA_NULL_ORG_ID_IN_LIST_MEM';
3908 Pa_Utils.Add_Message
3909 (P_App_Short_Name => 'PA',
3910 P_Msg_Name => 'PA_NULL_ORG_ID_IN_LIST_MEM');
3911
3912 Else
3913
3914 X_Org_Displayed := Null;
3915
3916 End If;*/
3917
3918 /*When BAD_ORG_ID_IN_LIST_MEM Then
3919
3920 If P_Proc_Func_Flag = 'P' Then
3921
3922 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
3923 X_Msg_Data := 'PA_BAD_ORG_ID_IN_LIST_MEM';
3924 Pa_Utils.Add_Message
3925 (P_App_Short_Name => 'PA',
3926 P_Msg_Name => 'PA_BAD_ORG_ID_IN_LIST_MEM');
3927
3928 Else
3929
3930 X_Org_Displayed := Null;
3931
3932 End If;*/
3933
3934 When Others Then
3935 Raise;
3936
3937 End Get_Organization_Name;
3938 /***************************************/
3939
3940 /******************************************************************
3941 * Function : Ret_Supplier_Name
3942 * ****************************************************************/
3943
3944 Function Ret_Supplier_Name ( P_Supplier_Id IN Number ) Return Varchar2
3945
3946 Is
3947
3948 l_Return_Status Varchar2(1) := Null;
3949 l_Msg_Data Varchar2(30) := Null;
3950 l_Supplier_Name Varchar2(240) := Null;
3951
3952 Begin
3953
3954 Pa_Planning_Resource_Utils.Get_Supplier_Name(
3955 P_Supplier_Id => P_Supplier_Id,
3956 P_Proc_Func_Flag => 'F',
3957 X_Supplier_Displayed => l_Supplier_Name,
3958 X_Return_Status => l_Return_Status,
3959 X_Msg_Data => l_Msg_Data );
3960
3961
3962 Return l_Supplier_Name;
3963
3964 Exception
3965 When Others Then
3966 Raise;
3967
3968 End Ret_Supplier_Name;
3969 /*********************************/
3970
3971 /***************************************************
3972 * Procedure : Get_Supplier_Name
3973 * *************************************************/
3974 Procedure Get_Supplier_Name ( P_Supplier_Id IN Number,
3975 P_Proc_Func_Flag IN Varchar2,
3976 X_Supplier_Displayed OUT NOCOPY Varchar2,
3977 X_Return_Status OUT NOCOPY Varchar2,
3978 X_Msg_Data OUT NOCOPY Varchar2 )
3979
3980 Is
3981
3982 l_Supplier_Displayed Varchar2(240) := Null;
3983
3984 --BAD_VEND_IN_LIST_MEM Exception;
3985 --NULL_VEND_IN_LIST_MEM Exception;
3986 UNEXPEC_ERROR Exception;
3987
3988 Cursor c_Supplier (P_Vendor_Id IN Number) Is
3989 Select
3990 Vendor_Name
3991 From
3992 Po_Vendors
3993 Where
3994 Vendor_id = P_Vendor_Id;
3995
3996 Begin
3997
3998 If P_Supplier_Id is Not Null Then
3999
4000 Open c_Supplier(P_Vendor_Id => P_Supplier_Id);
4001 Fetch c_Supplier Into l_Supplier_Displayed;
4002 If c_Supplier%NOTFOUND Then
4003
4004 Close c_Supplier;
4005 --Raise BAD_VEND_IN_LIST_MEM;
4006 Raise UNEXPEC_ERROR;
4007
4008 End If;
4009 Close c_Supplier;
4010
4011 Else
4012
4013 --Raise NULL_VEND_IN_LIST_MEM;
4014 --Raise UNEXPEC_ERROR;
4015 l_Supplier_Displayed := NULL;
4016
4017 End If;
4018
4019 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
4020 X_Msg_Data := Null;
4021 X_Supplier_Displayed := l_Supplier_Displayed;
4022
4023 Exception
4024 When UNEXPEC_ERROR THEN
4025 X_Return_Status := Fnd_Api.G_Ret_Sts_UnExp_Error;
4026 --x_msg_count := x_msg_count + 1;
4027 x_msg_data := Null;
4028 Fnd_Msg_Pub.Add_Exc_Msg(
4029 P_Pkg_Name => 'PA_PLANNING_RESOURCE_UTILS',
4030 P_Procedure_Name => 'Get_Supplier_Name');
4031 Return;
4032 /*When NULL_VEND_IN_LIST_MEM Then
4033
4034 If P_Proc_Func_Flag = 'P' Then
4035
4036 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4037 X_Msg_Data := 'PA_NULL_VEND_IN_LIST_MEM';
4038 Pa_Utils.Add_Message
4039 (P_App_Short_Name => 'PA',
4040 P_Msg_Name => 'PA_NULL_VEND_IN_LIST_MEM');
4041
4042 Else
4043
4044 X_Supplier_Displayed := Null;
4045
4046 End If;*/
4047
4048 /*When BAD_VEND_IN_LIST_MEM Then
4049
4050 If P_Proc_Func_Flag = 'P' Then
4051
4052 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4053 X_Msg_Data := 'PA_BAD_VEND_IN_LIST_MEM';
4054 Pa_Utils.Add_Message
4055 (P_App_Short_Name => 'PA',
4056 P_Msg_Name => 'PA_BAD_VEND_IN_LIST_MEM');
4057
4058 Else
4059
4060 X_Supplier_Displayed := Null;
4061
4062 End If;*/
4063
4064 When Others Then
4065 Raise;
4066
4067 End Get_Supplier_Name;
4068 /******************************************/
4069
4070 /***********************************************************
4071 * Function : Ret_Role_Name
4072 * *********************************************************/
4073 Function Ret_Role_Name ( P_Role_Id IN Number ) Return Varchar2
4074
4075 Is
4076
4077 l_Return_Status Varchar2(1) := Null;
4078 l_Msg_Data Varchar2(30) := Null;
4079 l_Role_Name Varchar2(80) := Null;
4080
4081 Begin
4082
4083 Pa_Planning_Resource_Utils.Get_Role_Name(
4084 P_Role_Id => P_Role_Id,
4085 P_Proc_Func_Flag => 'F',
4086 X_Role_Displayed => l_Role_Name,
4087 X_Return_Status => l_Return_Status,
4088 X_Msg_Data => l_Msg_Data );
4089
4090
4091 Return l_Role_Name;
4092
4093 Exception
4094 When Others Then
4095 Raise;
4096
4097 End Ret_Role_Name;
4098 /******************************************/
4099
4100 /******************************************************
4101 * Procedure : Get_Role_Name
4102 * ****************************************************/
4103 Procedure Get_Role_Name ( P_Role_Id IN Number,
4104 P_Proc_Func_Flag IN Varchar2,
4105 X_Role_Displayed OUT NOCOPY Varchar2,
4106 X_Return_Status OUT NOCOPY Varchar2,
4107 X_Msg_Data OUT NOCOPY Varchar2 )
4108 Is
4109
4110 l_Role_Displayed Varchar2(80);
4111
4112 --BAD_ROLE_IN_LIST_MEM Exception;
4113 --NULL_ROLE_IN_LIST_MEM Exception;
4114 UNEXPEC_ERROR Exception;
4115
4116 Cursor c_PrjRoles (P_Prj_Role_Id IN Number) Is
4117 Select
4118 Meaning
4119 From
4120 Pa_Project_Role_Types_vl
4121 Where
4122 Project_Role_Id = P_Prj_Role_Id;
4123
4124 Begin
4125
4126 If P_Role_Id is Not Null Then
4127
4128 -- Get role from pa_project_role_types_vl
4129 Open c_PrjRoles(P_Prj_Role_Id => P_Role_Id);
4130 Fetch c_PrjRoles Into l_Role_Displayed;
4131
4132 If c_PrjRoles%NOTFOUND Then
4133
4134 Close c_PrjRoles;
4135 --Raise BAD_ROLE_IN_LIST_MEM;
4136 Raise UNEXPEC_ERROR;
4137
4138 End If;
4139
4140 Close c_PrjRoles;
4141
4142 Else
4143
4144 --Raise NULL_ROLE_IN_LIST_MEM;
4145 --Raise UNEXPEC_ERROR;
4146 l_Role_Displayed := NULL;
4147
4148 End If;
4149
4150 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
4151 X_Msg_Data := Null;
4152 X_Role_Displayed := l_Role_Displayed;
4153
4154 Exception
4155 When UNEXPEC_ERROR THEN
4156 X_Return_Status := Fnd_Api.G_Ret_Sts_UnExp_Error;
4157 --x_msg_count := x_msg_count + 1;
4158 x_msg_data := Null;
4159 Fnd_Msg_Pub.Add_Exc_Msg(
4160 P_Pkg_Name => 'PA_PLANNING_RESOURCE_UTILS',
4161 P_Procedure_Name => 'Get_Role_Name');
4162 Return;
4163 /*When NULL_ROLE_IN_LIST_MEM Then
4164
4165 If P_Proc_Func_Flag = 'P' Then
4166
4167 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4168 X_Msg_Data := 'PA_NULL_ROLE_IN_LIST_MEM';
4169 Pa_Utils.Add_Message
4170 (P_App_Short_Name => 'PA',
4171 P_Msg_Name => 'PA_NULL_ROLE_IN_LIST_MEM');
4172
4173 Else
4174
4175 X_Role_Displayed := Null;
4176
4177 End If;*/
4178
4179 /*When BAD_ROLE_IN_LIST_MEM Then
4180
4181 If P_Proc_Func_Flag = 'P' Then
4182
4183 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4184 X_Msg_Data := 'PA_BAD_ROLE_IN_LIST_MEM';
4185 Pa_Utils.Add_Message
4186 (P_App_Short_Name => 'PA',
4187 P_Msg_Name => 'PA_BAD_ROLE_IN_LIST_MEM');
4188
4189 Else
4190
4191 X_Role_Displayed := Null;
4192
4193 End If;*/
4194
4195 When Others Then
4196 Raise;
4197
4198 End Get_Role_Name;
4199 /***********************************************/
4200
4201 /**********************************************************
4202 * Function : Ret_Incur_By_Res_Name
4203 * *********************************************************/
4204 Function Ret_Incur_By_Res_Name ( P_Person_Id IN Number,
4205 P_Job_Id IN Number,
4206 P_Incur_By_Role_Id IN Number,
4207 P_Person_Type_Code IN Varchar2,
4208 P_Inc_By_Res_Class_Code IN Varchar2,
4209 P_Res_Assignment_Id IN NUMBER default null) Return varchar2
4210 Is
4211
4212 l_Return_Status Varchar2(1) := Null;
4213 l_Msg_Data Varchar2(30) := Null;
4214 l_Inc_By_Name Varchar2(1000) := Null;
4215
4216 Begin
4217
4218 Pa_Planning_Resource_Utils.Get_Incur_By_Res_Name(
4219 P_Person_Id => P_Person_Id,
4220 P_Job_Id => P_Job_Id,
4221 P_Incur_By_Role_Id => P_Incur_By_Role_Id,
4222 P_Person_Type_Code => P_Person_Type_Code,
4223 P_Inc_By_Res_Class_Code => P_Inc_By_Res_Class_Code,
4224 P_Proc_Func_Flag => 'F',
4225 P_Res_Assignment_Id => P_Res_Assignment_Id,
4226 X_Inc_By_Displayed => l_Inc_By_Name,
4227 X_Return_Status => l_Return_Status,
4228 X_Msg_Data => l_Msg_Data );
4229
4230 Return l_Inc_By_Name;
4231
4232 Exception
4233 When Others Then
4234 Raise;
4235
4236 End Ret_Incur_By_Res_Name;
4237 /******************************************/
4238
4239 /****************************************************************
4240 * Procedure : Get_Incur_By_Res_Name
4241 * **************************************************************/
4242 Procedure Get_Incur_By_Res_Name ( P_Person_Id IN Number,
4243 P_Job_Id IN Number,
4244 P_Incur_By_Role_Id IN Number,
4245 P_Person_Type_Code IN Varchar2,
4246 P_Inc_By_Res_Class_Code IN Varchar2,
4247 P_Proc_Func_Flag IN Varchar2,
4248 P_Res_Assignment_Id IN NUMBER default null,
4249 X_Inc_By_Displayed OUT NOCOPY Varchar2,
4250 X_Return_Status OUT NOCOPY Varchar2,
4251 X_Msg_Data OUT NOCOPY Varchar2)
4252
4253 Is
4254
4255 l_Inc_By_Displayed Varchar2(1000);
4256
4257 --BAD_PER_IN_RES_LIST_MEM Exception;
4258 --BAD_JOB_IN_RES_LIST_MEM Exception;
4259 --BAD_INCUR_ROLE_IN_LIST_MEM Exception;
4260 --BAD_PER_TYPE_IN_LIST_MEM Exception;
4261 --BAD_INCUR_RESCLASS_IN_LIST_MEM Exception;
4262 --INV_INCUR_BY_IN_LIST_MEM Exception;
4263 UNEXPEC_ERROR Exception;
4264
4265 Cursor c_People (P_Person_Id IN Number) is
4266 Select
4267 Full_Name
4268 From
4269 Per_People_X
4270 Where
4271 Person_Id = P_Person_Id
4272 And ( (Pa_Cross_Business_Grp.IsCrossBGProfile = 'N' AND
4273 Fnd_Profile.Value('PER_BUSINESS_GROUP_ID') = Business_Group_Id)
4274 OR Pa_Cross_Business_Grp.IsCrossBGProfile = 'Y');
4275
4276 Cursor c_Job (P_Job_Id In Number) Is
4277 Select
4278 Name
4279 From
4280 Per_Jobs
4281 Where
4282 Job_Id = P_Job_Id
4283 And ( (Pa_Cross_Business_Grp.IsCrossBGProfile = 'N' AND
4284 Fnd_Profile.Value('PER_BUSINESS_GROUP_ID') = Business_Group_Id )
4285 OR Pa_Cross_Business_Grp.IsCrossBGProfile = 'Y');
4286
4287 Cursor c_PersonType (P_Person_Type IN Varchar2) Is
4288 Select
4289 Meaning
4290 From
4291 hr_lookups
4292 Where
4293 Lookup_Type = 'PERSON_TYPE'
4294 And Lookup_Code = P_Person_Type;
4295
4296 Cursor c_ResClass2 (P_Resource_Class_Code IN Varchar2) Is
4297 Select
4298 Name
4299 From
4300 Pa_Resource_Classes_Vl
4301 Where
4302 Resource_Class_Code = P_Resource_Class_Code;
4303
4304 Cursor c_PrjRoles (P_Prj_Role_Id IN Number) Is
4305 Select
4306 Meaning
4307 From
4308 Pa_Project_Role_Types_vl
4309 Where
4310 Project_Role_Id = P_Prj_Role_Id;
4311
4312 Cursor c_Res_Attributes
4313 Is
4314 Select
4315 Person_Id,
4316 Job_Id,
4317 Incur_By_Role_Id,
4318 Person_Type_Code,
4319 Incur_By_Res_Class_Code
4320 From
4321 Pa_Resource_Assignments
4322 Where
4323 Resource_Assignment_Id = P_Res_Assignment_Id;
4324
4325 l_Res_Attributes c_Res_Attributes%RowType;
4326
4327 Cursor Get_Inc_By_Flag Is
4328 Select
4329 Incurred_By_Res_Flag
4330 From
4331 Pa_Resource_Assignments
4332 Where
4333 Resource_Assignment_Id = P_Res_Assignment_Id;
4334
4335 l_Person_Id Number;
4336 l_Job_Id Number;
4337 l_Incur_By_Role_Id Number;
4338 l_Person_Type_Code Varchar2(30);
4339 l_Inc_By_Res_Class_Code Varchar2(30);
4340 l_Inc_By_Flag Varchar2(1) := 'N';
4341
4342 Begin
4343
4344 If P_Res_Assignment_Id Is Not Null Then
4345
4346 Open Get_inc_By_Flag;
4347 Fetch Get_Inc_By_Flag Into l_Inc_By_Flag;
4348 Close Get_Inc_By_Flag;
4349
4350 End If;
4351
4352 If l_Inc_By_Flag = 'Y' Then
4353
4354 Open c_Res_Attributes;
4355 Fetch c_Res_Attributes Into l_Res_Attributes;
4356 Close c_Res_Attributes;
4357
4358 l_person_id := l_res_attributes.person_id;
4359 l_job_id := l_res_attributes.job_id;
4360 l_incur_by_role_id := l_res_attributes.incur_by_role_id;
4361 l_person_type_code := l_res_attributes.person_type_code;
4362 l_inc_by_res_class_code := l_res_attributes.incur_by_res_class_code;
4363
4364 Else
4365
4366 l_person_id := p_person_id;
4367 l_job_id := p_job_id;
4368 l_incur_by_role_id := p_incur_by_role_id;
4369 l_person_type_code := p_person_type_code;
4370 l_inc_by_res_class_code := p_inc_by_res_class_code;
4371
4372 End If;
4373
4374 -- Check in this order:
4375 -- Named Person, job, role, person type, Financial Elements Resource class
4376 If l_Person_Id is Not Null Then
4377
4378 Open c_People(P_Person_Id => l_Person_Id);
4379 Fetch c_People Into l_Inc_By_Displayed;
4380 If c_People%NotFound Then
4381 Close c_People;
4382 --Raise BAD_PER_IN_RES_LIST_MEM;
4383 Raise UNEXPEC_ERROR;
4384 End If;
4385 Close c_People;
4386
4387 ElsIf l_Job_Id is Not Null Then
4388
4389 Open c_Job(P_Job_Id => l_Job_Id);
4390 Fetch c_Job Into l_Inc_By_Displayed;
4391 If c_Job%NOTFOUND Then
4392 Close c_job;
4393 --Raise BAD_JOB_IN_RES_LIST_MEM;
4394 Raise UNEXPEC_ERROR;
4395 End If;
4396 Close c_Job;
4397
4398 ElsIf l_Incur_By_Role_Id is Not Null Then
4399
4400 Open c_PrjRoles(P_Prj_Role_Id => l_Incur_By_Role_Id);
4401 Fetch c_PrjRoles Into l_Inc_By_Displayed;
4402 If c_PrjRoles%NOTFOUND Then
4403 Close c_PrjRoles;
4404 --Raise BAD_INCUR_ROLE_IN_LIST_MEM;
4405 Raise UNEXPEC_ERROR;
4406 End If;
4407 Close c_PrjRoles;
4408
4409 ElsIf l_Person_Type_Code is Not Null Then
4410
4411 -- CWK, EMP
4412 -- Get meaning from fnd_common_lookups
4413 Open c_PersonType(P_Person_Type => l_Person_Type_Code);
4414 Fetch c_PersonType Into l_Inc_By_Displayed;
4415 If c_PersonType%NOTFOUND Then
4416 Close c_PersonType;
4417 --Raise BAD_PER_TYPE_IN_LIST_MEM;
4418 Raise UNEXPEC_ERROR;
4419 End If;
4420 Close c_PersonType;
4421
4422 ElsIf l_Inc_By_Res_Class_Code is Not Null Then
4423
4424 Open c_ResClass2(P_Resource_Class_Code => l_Inc_By_Res_Class_Code);
4425 Fetch c_ResClass2 into l_Inc_By_Displayed;
4426 If c_ResClass2%NOTFOUND Then
4427
4428 Close c_ResClass2;
4429 --Raise BAD_INCUR_RESCLASS_IN_LIST_MEM;
4430 Raise UNEXPEC_ERROR;
4431
4432 End If;
4433 Close c_ResClass2;
4434
4435 Else
4436
4437 --Raise INV_INCUR_BY_IN_LIST_MEM;
4438 --Raise UNEXPEC_ERROR;
4439 -- Return Null if resource or assignment is not
4440 -- an incurred by resource.
4441 l_Inc_By_Displayed := NULL;
4442
4443 End If;
4444
4445 X_Inc_By_Displayed := l_Inc_By_Displayed;
4446 X_Msg_Data := Null;
4447 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
4448
4449 Exception
4450 When UNEXPEC_ERROR THEN
4451 X_Return_Status := Fnd_Api.G_Ret_Sts_UnExp_Error;
4452 --x_msg_count := x_msg_count + 1;
4453 x_msg_data := Null;
4454 Fnd_Msg_Pub.Add_Exc_Msg(
4455 P_Pkg_Name => 'PA_PLANNING_RESOURCE_UTILS',
4456 P_Procedure_Name => 'Get_Incur_By_Res_Name');
4457 Return;
4458 /*When BAD_PER_IN_RES_LIST_MEM Then
4459
4460 If P_Proc_Func_Flag = 'P' Then
4461
4462 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4463 X_Msg_Data := 'PA_BAD_PER_IN_RES_LIST_MEM';
4464 Pa_Utils.Add_Message
4465 (P_App_Short_Name => 'PA',
4466 P_Msg_Name => 'PA_BAD_PER_IN_RES_LIST_MEM');
4467
4468 Else
4469
4470 X_Inc_By_Displayed := Null;
4471
4472 End If;*/
4473
4474 /*When BAD_JOB_IN_RES_LIST_MEM Then
4475
4476 If P_Proc_Func_Flag = 'P' Then
4477
4478 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4479 X_Msg_Data := 'PA_BAD_JOB_IN_RES_LIST_MEM';
4480 Pa_Utils.Add_Message
4481 (P_App_Short_Name => 'PA',
4482 P_Msg_Name => 'PA_BAD_JOB_IN_RES_LIST_MEM');
4483
4484 Else
4485
4486 X_Inc_By_Displayed := Null;
4487
4488 End If;*/
4489
4490 /*When BAD_INCUR_ROLE_IN_LIST_MEM Then
4491
4492 If P_Proc_Func_Flag = 'P' Then
4493
4494 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4495 X_Msg_Data := 'PA_BAD_INCUR_ROLE_IN_LIST_MEM';
4496 Pa_Utils.Add_Message
4497 (P_App_Short_Name => 'PA',
4498 P_Msg_Name => 'PA_BAD_INCUR_ROLE_IN_LIST_MEM');
4499
4500 Else
4501
4502 X_Inc_By_Displayed := Null;
4503
4504 End If;*/
4505
4506 /*When BAD_PER_TYPE_IN_LIST_MEM Then
4507
4508 If P_Proc_Func_Flag = 'P' Then
4509
4510 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4511 X_Msg_Data := 'PA_BAD_PER_TYPE_IN_LIST_MEM';
4512 Pa_Utils.Add_Message
4513 (P_App_Short_Name => 'PA',
4514 P_Msg_Name => 'PA_BAD_PER_TYPE_IN_LIST_MEM');
4515
4516 Else
4517
4518 X_Inc_By_Displayed := Null;
4519
4520 End If;*/
4521
4522 /*When BAD_INCUR_RESCLASS_IN_LIST_MEM Then
4523
4524 If P_Proc_Func_Flag = 'P' Then
4525
4526 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4527 X_Msg_Data := 'PA_BAD_INC_RESCLASS_IN_LST_MEM';
4528 Pa_Utils.Add_Message
4529 (P_App_Short_Name => 'PA',
4530 P_Msg_Name => 'PA_BAD_INC_RESCLASS_IN_LST_MEM');
4531
4532 Else
4533
4534 X_Inc_By_Displayed := Null;
4535
4536 End If;*/
4537
4538 /*When INV_INCUR_BY_IN_LIST_MEM Then
4539
4540 If P_Proc_Func_Flag = 'P' Then
4541
4542 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4543 X_Msg_Data := 'PA_INV_INCUR_BY_IN_LIST_MEM';
4544 Pa_Utils.Add_Message
4545 (P_App_Short_Name => 'PA',
4546 P_Msg_Name => 'PA_INV_INCUR_BY_IN_LIST_MEM');
4547
4548 Else
4549
4550 X_Inc_By_Displayed := Null;
4551
4552 End If;*/
4553
4554 When Others Then
4555 Raise;
4556
4557 End Get_Incur_By_Res_Name;
4558 /**************************************************/
4559
4560 /********************************************************
4561 * Procedure : Get_Plan_Res_Combination.
4562 *****************************************************/
4563
4564 Procedure Get_Plan_Res_Combination(
4565 P_Resource_List_Member_Id IN Number,
4566 X_Resource_Alias OUT NOCOPY Varchar2,
4567 X_Plan_Res_Combination OUT NOCOPY Varchar2,
4568 X_Return_Status OUT NOCOPY Varchar2,
4569 X_Msg_Count OUT NOCOPY Number,
4570 X_Msg_Data OUT NOCOPY Varchar2)
4571
4572 Is
4573
4574 l_Res_Type_displayed Varchar2(1000) := Null;
4575 l_FC_Displayed Varchar2(80) := Null;
4576 l_Orgn_Displayed Varchar2(240) := Null;
4577 l_Supplier_Displayed Varchar2(240) := Null;
4578 l_Role_Displayed Varchar2(80) := Null;
4579 l_Res_Incur_By_displayed Varchar2(1000) := Null;
4580 l_Res_Incur_By_alias Varchar2(1000) := Null;
4581
4582 Cursor c_Enabled_Flags (P_Res_Format_Id IN Number) is
4583 Select
4584 f.Res_Type_Enabled_Flag,
4585 f.Orgn_Enabled_Flag,
4586 f.Fin_Cat_Enabled_Flag,
4587 f.Incurred_By_Enabled_Flag,
4588 f.Supplier_Enabled_Flag,
4589 f.Role_Enabled_Flag,
4590 f.Resource_Class_Flag,
4591 f.Res_Type_Id,
4592 f.Resource_Type_Disp_Chars,
4593 f.Orgn_Disp_Chars,
4594 f.Fin_Cat_Disp_Chars,
4595 f.Incurred_By_Disp_Chars,
4596 f.Supplier_Disp_Chars,
4597 f.Role_Disp_Chars,
4598 t.Res_Type_Code
4599 From
4600 Pa_Res_Formats_B f,
4601 Pa_Res_Types_B t
4602 Where
4603 f.Res_Type_Id = t.Res_Type_Id(+)
4604 And f.Res_Format_Id = P_Res_Format_Id;
4605
4606 Cursor c_Res_List (P_Res_List_Member_Id IN Number) is
4607 Select
4608 Res_Format_Id,
4609 Person_Id,
4610 Job_Id,
4611 Organization_Id,
4612 Vendor_Id,
4613 Expenditure_Type,
4614 Event_Type,
4615 Non_Labor_Resource,
4616 Expenditure_Category,
4617 Revenue_Category,
4618 Non_Labor_Resource_Org_Id,
4619 Project_Role_Id,
4620 Resource_Format_Id,
4621 Resource_Class_Id,
4622 Mfc_Cost_Type_Id,
4623 Resource_Class_Flag,
4624 Fc_Res_Type_Code,
4625 Bom_Resource_Id,
4626 Inventory_Item_Id,
4627 Item_Category_Id,
4628 Person_Type_Code,
4629 team_role ,
4630 Incurred_By_Res_Flag,
4631 Incur_By_Res_Class_Code,
4632 Incur_By_Role_Id
4633 From
4634 Pa_Resource_List_Members
4635 Where
4636 Resource_List_Member_Id = P_Res_List_Member_Id;
4637
4638 Res_List_Member_Rec c_Res_List%RowType;
4639 Res_Format_Rec c_Enabled_Flags%RowType;
4640
4641 -- User Exception Definitions
4642 INVALID_RES_LIST_MEM_ID Exception;
4643 NULL_MEM_LIST_RES_FORMAT Exception;
4644 INVALID_MEM_LIST_RES_FORMAT Exception;
4645 --BAD_RES_TYPE_CODE Exception;
4646 FAIL_GET_NAME Exception;
4647
4648 Begin
4649
4650 -- We always display the combination in the following order
4651 -- Resource
4652 -- Financial Category
4653 -- Organization
4654 -- Supplier
4655 -- Role
4656 -- Incurred By
4657
4658 -- Initialize values
4659 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
4660 X_Msg_Count := 0;
4661 X_Msg_Data := Null;
4662 /***************************************************
4663 * Bug - 3591595
4664 * Desc - If the P_Resource_List_Member_Id is passed in as Null
4665 * then set the x_resource_alias and X_Plan_Res_Combination
4666 * as Null and Return.
4667 ******************************************************/
4668 IF P_Resource_List_Member_Id IS NULL THEN
4669 X_Resource_Alias := Null;
4670 X_Plan_Res_Combination := Null;
4671 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
4672 Return;
4673 END IF;
4674
4675 Open c_Res_List(P_Res_List_Member_Id => P_Resource_List_Member_Id);
4676 Fetch c_Res_List into Res_List_Member_Rec;
4677 If c_Res_List%NotFound Then
4678 Close c_Res_List;
4679 Raise INVALID_RES_LIST_MEM_ID;
4680 End If;
4681 Close c_Res_List;
4682
4683 If Res_List_Member_Rec.Res_Format_Id is Not Null Then
4684
4685 Open c_Enabled_Flags(P_Res_Format_Id => Res_List_Member_Rec.Res_Format_Id);
4686 Fetch c_Enabled_Flags into Res_Format_Rec;
4687 If c_Enabled_Flags%NotFound Then
4688 Close c_Enabled_Flags;
4689 Raise INVALID_MEM_LIST_RES_FORMAT;
4690 End If;
4691 Close c_Enabled_Flags;
4692
4693 Else
4694
4695 Raise NULL_MEM_LIST_RES_FORMAT;
4696
4697 End If;
4698
4699
4700 -- An Assumption is that there will never be more that 3 segments to the format
4701 -- So therefore will not count the number of segments with enabled_flag = 'Y'
4702
4703 -- Check res_type_enabled_flag = 'Y'
4704 If Res_Format_Rec.Res_Type_Enabled_Flag = 'Y' Then
4705
4706 Pa_Planning_Resource_Utils.Get_Resource_Name (
4707 P_Res_Type_Code => Res_Format_Rec.Res_Type_Code,
4708 P_Person_Id => Res_List_Member_Rec.Person_Id,
4709 P_Bom_Resource_Id => Res_List_Member_Rec.BOM_Resource_Id,
4710 P_Job_Id => Res_List_Member_Rec.Job_Id,
4711 P_Person_Type_Code => Res_List_Member_Rec.Person_Type_Code,
4712 P_Non_Labor_Resource => Res_List_Member_Rec.Non_Labor_Resource,
4713 P_Inventory_Item_Id => Res_List_Member_Rec.Inventory_Item_Id,
4714 P_Item_Category_Id => Res_List_Member_Rec.Item_Category_Id,
4715 P_Resource_Class_Id => Res_List_Member_Rec.Resource_Class_Id,
4716 P_Proc_Func_Flag => 'P',
4717 X_Resource_Displayed => l_Res_Type_Displayed,
4718 X_Return_Status => X_Return_Status,
4719 X_Msg_Data => X_Msg_Data);
4720
4721 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
4722
4723 Raise FAIL_GET_NAME;
4724
4725 End If;
4726
4727 If l_Res_Type_Displayed is Not Null Then
4728
4729 X_Plan_Res_Combination := l_Res_Type_Displayed;
4730 --Bug 3485392
4731 IF Res_Format_Rec.Res_Type_Code = 'NAMED_PERSON' THEN
4732 BEGIN
4733 --Select nvl(known_as,Full_Name)
4734 --Bug 8296696
4735 --Select decode(known_as,null,full_name,known_as||' ('||last_name||')')
4736 --Bug 10327524
4737 Select Full_Name
4738 INTO l_Res_Type_Displayed
4739 From Per_People_X
4740 Where Person_Id = Res_List_Member_Rec.Person_Id;
4741 END;
4742 END IF;
4743 X_Resource_Alias := substr(l_Res_Type_Displayed,1,Res_Format_Rec.Resource_Type_Disp_Chars);
4744
4745 --Else
4746
4747 --Raise BAD_RES_TYPE_CODE;
4748
4749 End If;
4750
4751 End If;
4752
4753 -- Check fin_cat_enabled_flag = 'Y'
4754 If Res_Format_Rec.Fin_Cat_Enabled_Flag = 'Y' Then
4755
4756 Pa_Planning_Resource_Utils.Get_Fin_Category_Name (
4757 P_FC_Res_Type_Code => Res_List_Member_Rec.Fc_Res_Type_Code,
4758 P_Expenditure_Type => Res_List_Member_Rec.Expenditure_Type,
4759 P_Expenditure_Category => Res_List_Member_Rec.Expenditure_Category,
4760 P_Event_Type => Res_List_Member_Rec.Event_Type,
4761 P_Revenue_Category_Code => Res_List_Member_Rec.Revenue_Category,
4762 P_Proc_Func_Flag => 'P',
4763 P_Res_Assignment_Id => NULL,
4764 X_Fin_Cat_Displayed => l_FC_Displayed,
4765 X_Return_Status => X_Return_Status,
4766 X_Msg_Data => X_Msg_Data);
4767
4768 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
4769
4770 Raise FAIL_GET_NAME;
4771
4772 End If;
4773
4774 If X_Plan_Res_Combination is Not Null Then
4775
4776 X_Plan_Res_Combination := X_Plan_Res_Combination || ' - ' || l_FC_Displayed;
4777 X_Resource_Alias := substr(X_Resource_Alias || ' - ' ||
4778 substr(l_FC_Displayed,1,Res_Format_Rec.Fin_Cat_Disp_Chars), 1, 80);
4779
4780 Else
4781
4782 X_Plan_Res_Combination := l_FC_Displayed;
4783 X_Resource_Alias := substr(l_FC_Displayed,1,Res_Format_Rec.Fin_Cat_Disp_Chars);
4784
4785 End If;
4786
4787 End If;
4788
4789 -- Check orgn_enabled_flag = 'Y'
4790 If Res_Format_Rec.Orgn_Enabled_Flag = 'Y' Then
4791
4792 Pa_Planning_Resource_Utils.Get_Organization_Name (
4793 P_Organization_Id => Res_List_Member_Rec.Organization_Id,
4794 P_Proc_Func_Flag => 'P',
4795 X_Org_Displayed => l_Orgn_Displayed,
4796 X_Return_Status => X_Return_Status,
4797 X_Msg_Data => X_Msg_Data);
4798
4799 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
4800
4801 Raise FAIL_GET_NAME;
4802
4803 End If;
4804
4805 If X_Plan_Res_Combination is Not Null Then
4806
4807 X_Plan_Res_Combination := X_Plan_Res_Combination || ' - ' || l_Orgn_Displayed;
4808 X_Resource_Alias := substr(X_Resource_Alias || ' - ' ||
4809 substr(l_Orgn_Displayed,1,Res_Format_Rec.Orgn_Disp_Chars), 1, 80);
4810
4811 Else
4812
4813 X_Plan_Res_Combination := l_Orgn_Displayed;
4814 X_Resource_Alias := substr(l_Orgn_Displayed,1,Res_Format_Rec.Orgn_Disp_Chars);
4815
4816 End If;
4817
4818 End If;
4819
4820 -- Check supplier_enabled_flag = 'Y'
4821 If Res_Format_Rec.Supplier_Enabled_Flag = 'Y' Then
4822
4823 Pa_Planning_Resource_Utils.Get_Supplier_Name (
4824 P_Supplier_Id => Res_List_Member_Rec.Vendor_Id,
4825 P_Proc_Func_Flag => 'P',
4826 X_Supplier_Displayed => l_Supplier_Displayed,
4827 X_Return_Status => X_Return_Status,
4828 X_Msg_Data => X_Msg_Data);
4829
4830 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
4831
4832 Raise FAIL_GET_NAME;
4833
4834 End If;
4835
4836 If X_Plan_Res_Combination is Not Null Then
4837
4838 X_Plan_Res_Combination := X_Plan_Res_Combination || ' - ' || l_Supplier_Displayed;
4839 X_Resource_Alias := substr(X_Resource_Alias || ' - ' ||
4840 substr(l_Supplier_Displayed,1,Res_Format_Rec.Supplier_Disp_Chars), 1, 80);
4841
4842 Else
4843
4844 X_Plan_Res_Combination := l_Supplier_Displayed;
4845 X_Resource_Alias := substr(l_Supplier_Displayed,1,Res_Format_Rec.Supplier_Disp_Chars);
4846
4847 End If;
4848
4849 End If;
4850
4851 -- Check role_enabled_flag = 'Y'
4852 If Res_Format_Rec.Role_Enabled_Flag = 'Y' Then
4853 -- Team Role Changes
4854 /*Pa_Planning_Resource_Utils.Get_Role_Name (
4855 P_Role_Id => Res_List_Member_Rec.Project_Role_Id,
4856 P_Proc_Func_Flag => 'P',
4857 X_Role_Displayed => l_Role_Displayed,
4858 X_Return_Status => X_Return_Status,
4859 X_Msg_Data => X_Msg_Data);
4860
4861
4862 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
4863
4864 Raise FAIL_GET_NAME;
4865
4866 End If;*/
4867 -- Team Role Changes
4868 l_Role_Displayed := Res_List_Member_Rec.Team_Role;
4869
4870 If X_Plan_Res_Combination is Not Null Then
4871
4872 X_Plan_Res_Combination := X_Plan_Res_Combination || ' - ' || l_Role_Displayed;
4873 X_Resource_Alias := substr(X_Resource_Alias || ' - ' ||
4874 substr(l_Role_Displayed,1,Res_Format_Rec.Role_Disp_Chars), 1, 80);
4875
4876 Else
4877
4878 X_Plan_Res_Combination := l_Role_Displayed;
4879 X_Resource_Alias := substr(l_Role_Displayed,1,Res_Format_Rec.Role_Disp_Chars);
4880
4881 End If;
4882
4883 End If;
4884
4885 -- Check incurred_by_enabled_flag = 'Y'
4886 If Res_Format_Rec.Incurred_By_Enabled_Flag = 'Y' and
4887 Res_List_Member_Rec.Incurred_By_Res_Flag = 'Y' Then
4888
4889 Pa_Planning_Resource_Utils.Get_Incur_By_Res_Name (
4890 P_Person_Id => Res_List_Member_Rec.Person_Id,
4891 P_Job_Id => Res_List_Member_Rec.Job_Id,
4892 P_Incur_By_Role_Id => Res_List_Member_Rec.Incur_By_Role_Id,
4893 P_Person_Type_Code => Res_List_Member_Rec.Person_Type_Code,
4894 P_Inc_By_Res_Class_Code => Res_List_Member_Rec.Incur_By_Res_Class_Code,
4895 P_Proc_Func_Flag => 'P',
4896 P_Res_Assignment_Id => null,
4897 X_Inc_By_Displayed => l_Res_Incur_By_displayed,
4898 X_Return_Status => X_Return_Status,
4899 X_Msg_Data => X_Msg_Data);
4900
4901 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
4902
4903 Raise FAIL_GET_NAME;
4904
4905 End If;
4906
4907 If l_Res_Incur_By_displayed is Not Null Then
4908
4909 l_Res_Incur_By_alias := l_Res_Incur_By_displayed;
4910 --Bug 3940932
4911 IF Res_List_Member_Rec.Person_Id IS NOT NULL THEN
4912 BEGIN
4913 SELECT nvl(known_as,Full_Name)
4914 INTO l_Res_Incur_By_alias
4915 FROM Per_People_X
4916 WHERE Person_Id = Res_List_Member_Rec.Person_Id;
4917 END;
4918 END IF;
4919 End If;
4920
4921 If X_Plan_Res_Combination is Not Null Then
4922
4923 X_Plan_Res_Combination := X_Plan_Res_Combination || ' - ' ||
4924 l_Res_Incur_By_displayed;
4925 X_Resource_Alias := substr(X_Resource_Alias || ' - ' ||
4926 substr(l_Res_Incur_By_alias,1,Res_Format_Rec.Incurred_By_Disp_Chars), 1, 80);
4927
4928 Else
4929 X_Plan_Res_Combination := l_Res_Incur_By_displayed;
4930 X_Resource_Alias := substr(l_Res_Incur_By_alias,1,Res_Format_Rec.Incurred_By_Disp_Chars);
4931
4932 End If;
4933
4934 End If; -- Check incurred_by_enabled_flag = 'Y'
4935
4936 Exception
4937 When INVALID_RES_LIST_MEM_ID Then
4938 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4939 X_Msg_Count := 1;
4940 X_Msg_Data := 'PA_INVALID_RES_LIST_MEM_ID';
4941 Pa_Utils.Add_Message
4942 (P_App_Short_Name => 'PA',
4943 P_Msg_Name => 'PA_INVALID_RES_LIST_MEM_ID');
4944 When NULL_MEM_LIST_RES_FORMAT Then
4945 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4946 X_Msg_Count := 1;
4947 X_Msg_Data := 'PA_NULL_MEM_LIST_RES_FRM';
4948 Pa_Utils.Add_Message
4949 (P_App_Short_Name => 'PA',
4950 P_Msg_Name => 'PA_NULL_MEM_LIST_RES_FRM');
4951 When INVALID_MEM_LIST_RES_FORMAT Then
4952 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4953 X_Msg_Count := 1;
4954 X_Msg_Data := 'PA_INVALID_MEM_LIST_RES_FRM';
4955 Pa_Utils.Add_Message
4956 (P_App_Short_Name => 'PA',
4957 P_Msg_Name => 'PA_INVALID_MEM_LIST_RES_FRM');
4958 /*When BAD_RES_TYPE_CODE Then
4959 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
4960 X_Msg_Count := 1;
4961 X_Msg_Data := 'PA_BAD_RES_TYPE_CODE';
4962 Pa_Utils.Add_Message
4963 (P_App_Short_Name => 'PA',
4964 P_Msg_Name => 'PA_BAD_RES_TYPE_CODE');*/
4965 When FAIL_GET_NAME Then
4966 X_Msg_Count := 1;
4967 -- Assumes that the called procedure populates the
4968 -- out parameters with the rest of the needed values
4969 -- and executes pa_utils.add_message()
4970 When Others Then
4971 Raise;
4972
4973 End Get_Plan_Res_Combination;
4974 /****************************************************/
4975
4976
4977 /******Eugene*******************************************/
4978 Function Get_Plan_Res_Combination( P_Resource_List_Member_Id IN Number) Return Varchar2
4979 IS
4980
4981 l_Plan_Res_Combination Varchar2(2000);
4982 l_Return_Status Varchar2(1);
4983 l_Res_List_Member_Alias Varchar2(2000);
4984 l_Error_Msg_Data Varchar2(30);
4985 l_Error_Count Number;
4986 l_resource_class_flag PA_RESOURCE_LISTS_ALL_BG.resource_class_flag%TYPE := 'Y';
4987 BEGIN
4988
4989 Pa_Planning_Resource_Utils.Get_Plan_Res_Combination(
4990 P_Resource_List_Member_Id => P_Resource_List_Member_Id,
4991 X_Resource_Alias => l_Res_List_Member_Alias,
4992 X_Plan_Res_Combination => l_Plan_Res_Combination,
4993 X_Return_Status => l_Return_Status,
4994 X_Msg_Count => l_Error_Count,
4995 X_Msg_Data => l_Error_Msg_Data);
4996
4997 If l_Return_Status <> Fnd_Api.G_Ret_Sts_Success Then
4998
4999 -- Since this function calls the procedure get_plan_res_combination
5000 -- then the message is populated already using pa_utils.add_message()
5001 -- so just return 'ERROR'
5002 -- The message stack is already populated.
5003 Return 'ERROR';
5004
5005 Else
5006 /*CBS Changes Start*/
5007 begin
5008 select nvl(prlab.resource_class_flag,'Y') INTO l_resource_class_flag from
5009 PA_RESOURCE_LIST_MEMBERS prlm, PA_RESOURCE_LISTS_ALL_BG prlab
5010 where prlm.resource_list_member_id = P_Resource_List_Member_Id and
5011 prlm.resource_list_id = prlab.resource_list_id;
5012 EXCEPTION WHEN OTHERS then
5013 l_resource_class_flag := 'Y';
5014 end;
5015 IF l_resource_class_flag = 'N' AND l_Plan_Res_Combination = 'People' then
5016 l_Plan_Res_Combination := 'Unclassified';
5017 END if;
5018 /*CBS Chnages End here*/
5019 Return l_Plan_Res_Combination;
5020
5021 End If;
5022
5023
5024 END Get_Plan_Res_Combination;
5025 /**************************************/
5026
5027 /*************************************************/
5028 Procedure Validate_Fin_Category(
5029 P_FC_Res_Type_Code IN Varchar2,
5030 P_Resource_Class_Code IN Varchar2,
5031 P_Fin_Category_Name IN Varchar2,
5032 P_migration_code IN Varchar2,
5033 P_Resource_Class_Flag IN Varchar2 default 'Y', --Added for CBS::13535688
5034 X_Expenditure_Type OUT NOCOPY Varchar2,
5035 x_Expenditure_Category OUT NOCOPY Varchar2,
5036 X_Event_Type OUT NOCOPY Varchar2,
5037 X_Revenue_Category OUT NOCOPY Varchar2,
5038 X_Return_Status OUT NOCOPY Varchar2,
5039 X_Error_Message_Code OUT NOCOPY Varchar2)
5040
5041 Is
5042
5043 Cursor c_Event_Type ( P_Fin_Cat_Name IN Varchar2 ) Is
5044 Select
5045 'Y'
5046 From
5047 Pa_Event_Types
5048 Where
5049 Event_Type = P_Fin_Cat_Name
5050 And Event_Type_Classification IN ('AUTOMATIC','MANUAL','WRITE OFF','WRITE ON')
5051 And Decode(Pa_Get_Resource.Include_Inactive_Resources,
5052 'Y',Start_Date_Active,
5053 Trunc(SysDate)) Between Start_Date_Active
5054 And Nvl(End_Date_Active,Trunc(SysDate));
5055
5056 Cursor c_Exp_Type ( P_Fin_Cat_Name IN Varchar2) Is
5057 Select
5058 'Y'
5059 From
5060 Pa_Expenditure_Types
5061 Where
5062 lower(Expenditure_Type) = lower(P_Fin_Cat_Name)
5063 And Decode(Pa_Get_Resource.Include_Inactive_Resources,
5064 'Y',Start_Date_Active,
5065 Trunc(SysDate)) Between Start_Date_Active
5066 And Nvl(End_Date_Active,Trunc(SysDate));
5067
5068 Cursor c_Exp_Cat ( P_Fin_Cat_Name IN Varchar2) Is
5069 Select
5070 'Y'
5071 From
5072 Pa_Expenditure_Categories
5073 Where
5074 lower(Expenditure_Category) = lower(P_Fin_Cat_Name)
5075 And Decode(Pa_Get_Resource.Include_Inactive_Resources,
5076 'Y',Start_Date_Active,
5077 Trunc(SysDate)) Between Start_Date_Active
5078 And Nvl(End_Date_Active,Trunc(SysDate));
5079
5080
5081 Cursor c_Rev_Cat_Code ( P_Fin_Cat_Code IN Varchar2) Is
5082 Select
5083 Meaning
5084 From
5085 Pa_Lookups
5086 Where
5087 Lookup_Code = P_Fin_Cat_Code
5088 And Lookup_Type = 'REVENUE CATEGORY';
5089
5090 Cursor c_Rev_Cat_Meaning ( P_Fin_Cat_Meaning IN Varchar2) Is
5091 Select
5092 lookup_code
5093 From
5094 Pa_Lookups
5095 Where
5096 Meaning = P_Fin_Cat_Meaning
5097 And Lookup_Type = 'REVENUE CATEGORY';
5098
5099 Cursor c_UOM ( P_Fin_Cat_Name IN Varchar2 ) Is
5100 Select
5101 'Y'
5102 From
5103 Pa_Expenditure_Types
5104 Where
5105 Unit_Of_Measure = 'HOURS'
5106 And Expenditure_Type = P_Fin_Cat_Name;
5107
5108 MAN_PARAMS_NULL Exception;
5109 BAD_FIN_CAT_FOR_EVENT_TYPE Exception;
5110 BAD_FIN_CAT_FOR_EXP_TYPE Exception;
5111 BAD_FIN_CAT_FOR_EXP_CAT Exception;
5112 BAD_FIN_CAT_FOR_REV_CAT Exception;
5113 INVALID_VAL_FC_RES_TYPE Exception;
5114 BAD_FIN_CAT_UOM Exception;
5115 UNEXPEC_ERROR Exception;
5116 INVALID_FIN_CAT_CODE Exception;
5117 l_Dummy Varchar2(1) := Null;
5118 l_rev_meaning Varchar2(80) := Null;
5119 l_rev_code Varchar2(30) := Null;
5120
5121 Begin
5122 -- Initialize values
5123 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
5124 X_Error_Message_Code := Null;
5125
5126 If P_FC_Res_Type_Code is Null or
5127 P_Fin_Category_Name is Null or
5128 P_Resource_Class_Code is Null Then
5129
5130 Raise MAN_PARAMS_NULL;
5131 --Raise UNEXPEC_ERROR;
5132
5133 End If;
5134
5135 If P_FC_Res_Type_Code = 'EVENT_TYPE' Then
5136
5137 Open c_Event_Type(P_Fin_Cat_Name => P_Fin_Category_Name);
5138 Fetch c_Event_Type Into l_Dummy;
5139 If c_Event_Type%NotFound Then
5140
5141 Close c_Event_Type;
5142 Raise BAD_FIN_CAT_FOR_EVENT_TYPE;
5143 --Raise UNEXPEC_ERROR;
5144
5145 End If;
5146 X_Event_Type := P_Fin_Category_Name;
5147 Close c_Event_Type;
5148
5149 ElsIf P_FC_Res_Type_Code = 'EXPENDITURE_TYPE' Then
5150
5151 Open c_Exp_Type(P_Fin_Cat_Name => P_Fin_Category_Name);
5152 Fetch c_Exp_Type Into l_Dummy;
5153 If c_Exp_Type%NotFound Then
5154
5155 Close c_Exp_Type;
5156 Raise BAD_FIN_CAT_FOR_EXP_TYPE;
5157 --Raise UNEXPEC_ERROR;
5158
5159 End If;
5160 X_Expenditure_Type := P_Fin_Category_Name;
5161 Close c_Exp_Type;
5162
5163 ElsIf P_FC_Res_Type_Code = 'EXPENDITURE_CATEGORY' Then
5164
5165 Open c_Exp_Cat(P_Fin_Cat_Name => P_Fin_Category_Name);
5166 Fetch c_Exp_Cat Into l_Dummy;
5167 If c_Exp_Cat%NotFound Then
5168
5169
5170 Close c_Exp_Cat;
5171 Raise BAD_FIN_CAT_FOR_EXP_CAT;
5172 --Raise UNEXPEC_ERROR;
5173
5174 End If;
5175 X_Expenditure_Category := P_Fin_Category_Name;
5176 Close c_Exp_Cat;
5177
5178 ElsIf P_FC_Res_Type_Code = 'REVENUE_CATEGORY' Then
5179
5180 -- First check to see if the P_Fin_Category_Name is the
5181 -- Rev Cat Code
5182 Open c_Rev_Cat_Code(P_Fin_Cat_Code => P_Fin_Category_Name);
5183 Fetch c_Rev_Cat_Code Into l_rev_meaning;
5184 If c_Rev_Cat_Code%NotFound Then
5185 -- Check to see if it is the Meaning
5186
5187 Open c_Rev_Cat_Meaning(P_Fin_Cat_Meaning => P_Fin_Category_Name);
5188 Fetch c_Rev_Cat_Meaning Into l_rev_code;
5189 If c_Rev_Cat_Meaning%NotFound Then
5190 Close c_Rev_Cat_Meaning;
5191 Raise BAD_FIN_CAT_FOR_REV_CAT;
5192 --Raise UNEXPEC_ERROR;
5193 Else
5194 X_Revenue_Category := l_rev_code;
5195 Close c_Rev_Cat_Meaning;
5196 End If;
5197 Else
5198 X_Revenue_Category := P_Fin_Category_Name;
5199 End If;
5200 Close c_Rev_Cat_Code;
5201 Else
5202 RAISE INVALID_FIN_CAT_CODE;
5203
5204 End If;
5205
5206
5207 if P_Resource_Class_Flag = 'Y' Then --Added for CBS::13535688
5208 If P_Resource_Class_Code in ('PEOPLE','EQUIPMENT') And
5209 P_FC_Res_Type_Code = 'EXPENDITURE_TYPE' And
5210 P_migration_code = 'N' Then
5211
5212 Open c_UOM(P_Fin_Cat_Name => P_Fin_Category_Name);
5213 Fetch c_UOM Into l_Dummy;
5214 If c_UOM%NotFound Then
5215
5216 Close c_UOM;
5217 Raise BAD_FIN_CAT_UOM;
5218
5219 End If;
5220 Close c_UOM;
5221
5222 End If;
5223 END IF; --Added for CBS::13535688
5224
5225 Exception
5226 When UNEXPEC_ERROR THEN
5227 X_Return_Status := Fnd_Api.G_Ret_Sts_UnExp_Error;
5228 --x_msg_count := x_msg_count + 1;
5229 x_error_message_code := Null;
5230 Fnd_Msg_Pub.Add_Exc_Msg(
5231 P_Pkg_Name => 'PA_PLANNING_RESOURCE_UTILS',
5232 P_Procedure_Name => 'Validate_Fin_Category');
5233 When INVALID_FIN_CAT_CODE Then
5234 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5235 X_Error_Message_Code := 'PA_VFC_INVALID_FIN_CAT_CODE';
5236 Pa_Utils.Add_Message
5237 (P_App_Short_Name => 'PA',
5238 P_Msg_Name => 'PA_VFC_INVALID_FIN_CAT_CODE',
5239 p_token1 => 'PLAN_RES',
5240 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5241 When MAN_PARAMS_NULL Then
5242 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5243 X_Error_Message_Code := 'PA_VFC_MAN_PARAMS_NULL';
5244 Pa_Utils.Add_Message
5245 (P_App_Short_Name => 'PA',
5246 P_Msg_Name => 'PA_VFC_MAN_PARAMS_NULL',
5247 p_token1 => 'PLAN_RES',
5248 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5249 When BAD_FIN_CAT_FOR_EVENT_TYPE Then
5250 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5251 X_Error_Message_Code := 'PA_VFC_BAD_FINCAT_FOR_EVT_TYPE';
5252 Pa_Utils.Add_Message
5253 (P_App_Short_Name => 'PA',
5254 P_Msg_Name => 'PA_VFC_BAD_FINCAT_FOR_EVT_TYPE',
5255 p_token1 => 'PLAN_RES',
5256 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5257 When BAD_FIN_CAT_FOR_EXP_TYPE Then
5258 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5259 X_Error_Message_Code := 'PA_VFC_BAD_FIN_CAT_FOR_EXP_TYP';
5260 Pa_Utils.Add_Message
5261 (P_App_Short_Name => 'PA',
5262 P_Msg_Name => 'PA_VFC_BAD_FIN_CAT_FOR_EXP_TYP',
5263 p_token1 => 'PLAN_RES',
5264 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5265 When BAD_FIN_CAT_FOR_EXP_CAT Then
5266 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5267 X_Error_Message_Code := 'PA_VFC_BAD_FIN_CAT_FOR_EXP_CAT';
5268 Pa_Utils.Add_Message
5269 (P_App_Short_Name => 'PA',
5270 P_Msg_Name => 'PA_VFC_BAD_FIN_CAT_FOR_EXP_CAT',
5271 p_token1 => 'PLAN_RES',
5272 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5273 When BAD_FIN_CAT_FOR_REV_CAT Then
5274 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5275 X_Error_Message_Code := 'PA_VFC_BAD_FIN_CAT_FOR_REV_CAT';
5276 Pa_Utils.Add_Message
5277 (P_App_Short_Name => 'PA',
5278 P_Msg_Name => 'PA_VFC_BAD_FIN_CAT_FOR_REV_CAT',
5279 p_token1 => 'PLAN_RES',
5280 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5281 When BAD_FIN_CAT_UOM Then
5282 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5283 X_Error_Message_Code := 'PA_VFC_BAD_FIN_CAT_UOM';
5284 Pa_Utils.Add_Message
5285 (P_App_Short_Name => 'PA',
5286 P_Msg_Name => 'PA_VFC_BAD_FIN_CAT_UOM',
5287 p_token1 => 'PLAN_RES',
5288 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5289 When Others Then
5290 Raise;
5291
5292 End Validate_Fin_Category;
5293
5294 /*----------------------------------------------------------------------------*/
5295 -- Start of Comments
5296 -- API name : Get_Resource_Cost_Rate
5297 -- Type : Procedure
5298 -- Pre-reqs : None
5299 -- Function : To get the Resource Rate and Currency attributes.
5300 -- Prameters
5301 -- P_eligible_rlm_id_tbl IN SYSTEM.PA_NUM_TBL_TYPE REQUIRED --Resource List Member Id
5302 -- P_project_id IN NUMBER REQUIRED
5303 -- History
5304 -- 05-MAR-04 Vgade -Created
5305 --
5306 /*----------------------------------------------------------------------------*/
5307 Procedure Get_Resource_Cost_Rate(
5308 P_eligible_rlm_id_tbl IN SYSTEM.PA_NUM_TBL_TYPE
5309 ,P_project_id IN pa_projects_all.project_id%type
5310 ,p_structure_type IN VARCHAR2
5311 ,p_fin_plan_type_id IN NUMBER DEFAULT NULL
5312 ,P_resource_curr_code_tbl OUT NOCOPY SYSTEM.PA_VARCHAR2_15_TBL_TYPE
5313 ,P_resource_raw_rate_tbl OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE
5314 ,P_resource_burden_rate_tbl OUT NOCOPY SYSTEM.PA_NUM_TBL_TYPE
5315 ) AS
5316 --Start of variables used for debugging
5317 l_msg_count NUMBER :=0;
5318 l_data VARCHAR2(2000);
5319 l_msg_data VARCHAR2(2000);
5320 l_error_msg_code VARCHAR2(30);
5321 l_msg_index_out NUMBER;
5322 l_return_status VARCHAR2(2000);
5323 l_debug_mode VARCHAR2(30);
5324 --End of variables used for debugging
5325
5326 l_task_id pa_tasks.task_id%TYPE;
5327 l_top_task_id pa_tasks.task_id%TYPE;
5328 l_bill_job_group_id pa_projects_all.bill_job_group_id%TYPE;
5329 l_project_type pa_projects_all.project_type%TYPE;
5330 l_expenditure_type pa_resource_assignments.expenditure_type%TYPE;
5331 l_org_id pa_projects_all.org_id%TYPE;
5332 l_expenditure_OU pa_projects_all.org_id%TYPE;
5333 l_txn_currency_code_override pa_fp_res_assignments_tmp.txn_currency_code_override%TYPE;
5334 l_cost_rate_multiplier CONSTANT pa_labor_cost_multipliers.multiplier%TYPE := 1;
5335 -- l_burden_override_multiplier pa_fp_res_assignments_tmp.b_multiplier_override%TYPE;
5336 l_burden_override_multiplier Number;
5337 l_cost_override_rate pa_fp_res_assignments_tmp.rw_cost_rate_override%TYPE;
5338 l_raw_cost pa_fp_res_assignments_tmp.txn_raw_cost%TYPE;
5339 l_raw_cost_rate pa_fp_res_assignments_tmp.raw_cost_rate%TYPE;
5340 l_burden_cost pa_fp_res_assignments_tmp.txn_burdened_cost%TYPE;
5341 l_mfc_cost_type_id pa_resource_assignments.mfc_cost_type_id%TYPE;
5342 l_mfc_cost_source CONSTANT NUMBER := 2;
5343
5344 --Out variables
5345 l_txn_raw_cost number;
5346 l_txn_cost_rate number;
5347 l_txn_burden_cost number;
5348 l_txn_burden_cost_rate number;
5349 l_burden_multiplier number;
5350 l_cost_ind_compiled_set_id number;
5351 l_raw_cost_rejection_code varchar2(1000);
5352 l_burden_cost_rejection_code varchar2(1000);
5353 -- Changes for PFC
5354 l_func_currency_code varchar2(15);
5355 l_dummy_rate_date Date;
5356 l_dummy_rate_type Varchar2(100);
5357 l_dummy_exch_rate Number;
5358 l_dummy_cost Number;
5359 l_final_txn_rate_date Date;
5360 l_final_txn_rate_type Varchar2(100);
5361 l_final_txn_exch_rate Number;
5362 l_final_txn_burden_cost Number;
5363 l_status Varchar2(100);
5364 l_stage Number;
5365
5366 l_wp_versioning Varchar2(1);
5367 l_wp_vers_id Number;
5368 l_budget_version_id Number;
5369
5370 l_resource_list_member_Id_tab SYSTEM.PA_NUM_TBL_TYPE := SYSTEM.PA_NUM_TBL_TYPE();
5371 l_resource_assignment_id_tab SYSTEM.PA_NUM_TBL_TYPE := SYSTEM.PA_NUM_TBL_TYPE();
5372 l_expenditure_ou_tbl SYSTEM.PA_NUM_TBL_TYPE := SYSTEM.PA_NUM_TBL_TYPE();
5373
5374 l_burden_multiplier_tab SYSTEM.PA_NUM_TBL_TYPE :=SYSTEM.PA_NUM_TBL_TYPE();
5375 l_ind_compiled_set_id_tab SYSTEM.PA_NUM_TBL_TYPE :=SYSTEM.PA_NUM_TBL_TYPE();
5376 l_bill_rate_tab SYSTEM.PA_NUM_TBL_TYPE :=SYSTEM.PA_NUM_TBL_TYPE();
5377 l_markup_percent_tab SYSTEM.PA_NUM_TBL_TYPE :=SYSTEM.PA_NUM_TBL_TYPE();
5378 l_txn_currency_code_tab SYSTEM.PA_VARCHAR2_15_TBL_TYPE := SYSTEM.PA_VARCHAR2_15_TBL_TYPE();
5379 l_rev_txn_curr_code_tab SYSTEM.PA_VARCHAR2_15_TBL_TYPE := SYSTEM.PA_VARCHAR2_15_TBL_TYPE();
5380 l_cost_rejection_code_tab SYSTEM.PA_VARCHAR2_30_TBL_TYPE := SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
5381 l_burden_rejection_code_tab SYSTEM.PA_VARCHAR2_30_TBL_TYPE := SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
5382 l_revenue_rejection_code_tab SYSTEM.PA_VARCHAR2_30_TBL_TYPE := SYSTEM.PA_VARCHAR2_30_TBL_TYPE();
5383
5384 -- Bug 7457385
5385 CURSOR cur_proj_is_template(c_project_id NUMBER)
5386 IS
5387 SELECT 'Y'
5388 FROM pa_projects_all
5389 WHERE project_id = c_project_id
5390 AND template_flag = 'Y';
5391
5392 l_template_flag VARCHAR2(1);
5393
5394 Begin
5395 IF p_structure_type = 'WORKPLAN' THEN
5396
5397 -- Bug 7457385
5398 OPEN cur_proj_is_template(p_project_id);
5399 FETCH cur_proj_is_template into l_template_flag;
5400 IF cur_proj_is_template%NOTFOUND THEN
5401 l_template_flag := 'N';
5402 END IF;
5403 CLOSE cur_proj_is_template;
5404
5405 -- Bug 7457385 - In case of templates, you have a working workplan version
5406 -- with status code as structure_working and current_working_flag as Y
5407 IF l_template_flag = 'Y' THEN
5408 l_wp_vers_id := PA_PROJECT_STRUCTURE_UTILS.get_current_working_ver_id(
5409 p_project_id => p_project_id);
5410 ELSE
5411 l_wp_versioning := PA_WORKPLAN_ATTR_UTILS.CHECK_WP_VERSIONING_ENABLED(
5412 p_project_id => p_project_id);
5413 IF l_wp_versioning = 'Y' THEN
5414 l_wp_vers_id := PA_PROJECT_STRUCTURE_UTILS.get_current_working_ver_id(
5415 p_project_id => p_project_id);
5416 IF l_wp_vers_id IS NULL THEN
5417 l_wp_vers_id := PA_PROJECT_STRUCTURE_UTILS.get_latest_wp_version(
5418 p_project_id => p_project_id);
5419 END IF;
5420 ELSE
5421 l_wp_vers_id := PA_PROJECT_STRUCTURE_UTILS.get_latest_wp_version(
5422 p_project_id => p_project_id);
5423 END IF;
5424 END IF;
5425
5426 IF l_wp_vers_id IS NOT NULL THEN
5427 SELECT budget_version_id
5428 INTO l_budget_version_id
5429 FROM pa_budget_versions
5430 WHERE project_structure_version_id = l_wp_vers_id
5431 AND wp_version_flag = 'Y';
5432 END IF;
5433
5434 ELSE
5435 -- Bug 4779037 - added in Financial plan case.
5436 SELECT MAX(bv.budget_version_id)
5437 INTO l_budget_version_id
5438 FROM pa_budget_versions bv
5439 WHERE bv.fin_plan_type_id = p_fin_plan_type_id
5440 AND bv.project_id = p_project_id
5441 AND NVL(wp_version_flag,'N') = 'N'
5442 AND NVL(bv.budget_status_code,'W') IN ('W','S');
5443 END IF;
5444
5445 PA_FIN_PLAN_UTILS2.Get_Resource_Rates
5446 ( p_calling_module => 'MSP'
5447 ,p_source_context => 'RLMI'
5448 ,p_project_id => p_project_id
5449 ,p_budget_version_id => l_budget_version_id
5450 ,p_resource_list_member_Id_tab => p_eligible_rlm_id_tbl
5451 ,x_cost_txn_curr_code_tab => P_resource_curr_code_tbl
5452 ,x_raw_cost_rate_tab => P_resource_raw_rate_tbl
5453 ,x_burden_cost_rate_tab => P_resource_burden_rate_tbl
5454 ,x_expenditure_ou_tab => l_expenditure_ou_tbl
5455 ,x_resource_assignment_id_tab => l_resource_assignment_id_tab
5456 ,x_resource_list_member_Id_tab => l_resource_list_member_Id_tab
5457 ,x_burden_multiplier_tab => l_burden_multiplier_tab
5458 ,x_ind_compiled_set_id_tab => l_ind_compiled_set_id_tab
5459 ,x_bill_rate_tab => l_bill_rate_tab
5460 ,x_markup_percent_tab => l_markup_percent_tab
5461 ,x_txn_currency_code_tab => l_txn_currency_code_tab
5462 ,x_rev_txn_curr_code_tab => l_rev_txn_curr_code_tab
5463 ,x_cost_rejection_code_tab => l_cost_rejection_code_tab
5464 ,x_burden_rejection_code_tab => l_burden_rejection_code_tab
5465 ,x_revenue_rejection_code_tab => l_revenue_rejection_code_tab
5466 ,x_return_status => l_return_status
5467 ,x_msg_data => l_msg_data
5468 ,x_msg_count => l_msg_count
5469 );
5470
5471 -- If the currency code of the transaction is not the same as
5472 -- the project functional currency code, then convert it to the PFC.
5473 l_func_currency_code := PA_CURRENCY.get_currency_code;
5474 FOR i IN p_eligible_rlm_id_tbl.FIRST .. p_eligible_rlm_id_tbl.LAST LOOP
5475
5476 IF P_resource_curr_code_tbl(i) <> l_func_currency_code THEN
5477
5478 pa_multi_currency_txn.get_currency_amounts (
5479 p_project_id => p_project_id
5480 ,p_exp_org_id => l_expenditure_ou_tbl(i)
5481 ,p_calling_module => 'WORKPLAN'
5482 ,p_task_id => null
5483 ,p_ei_date => SYSDATE
5484 ,p_denom_raw_cost => 1
5485 ,p_denom_curr_code => P_resource_curr_code_tbl(i)
5486 ,p_acct_curr_code => l_func_currency_code
5487 ,p_accounted_flag => 'N'
5488 ,p_acct_rate_date => l_dummy_rate_date -- NA
5489 ,p_acct_rate_type => l_dummy_rate_type -- NA
5490 ,p_acct_exch_rate => l_dummy_exch_rate -- NA
5491 ,p_acct_raw_cost => l_dummy_cost -- NA
5492 ,p_project_curr_code => l_func_currency_code
5493 ,p_project_rate_type => l_dummy_rate_type -- NA
5494 ,p_project_rate_date => l_dummy_rate_date -- NA
5495 ,p_project_exch_rate => l_dummy_exch_rate -- NA
5496 ,p_project_raw_cost => l_dummy_cost -- NA
5497 ,p_projfunc_curr_code => l_func_currency_code
5498 ,p_projfunc_cost_rate_type => l_final_txn_rate_type
5499 ,p_projfunc_cost_rate_date => l_final_txn_rate_date
5500 ,p_projfunc_cost_exch_rate => l_final_txn_exch_rate
5501 ,p_projfunc_raw_cost => l_final_txn_burden_cost
5502 ,p_system_linkage => 'NER'
5503 ,p_status => l_status
5504 ,p_stage => l_stage);
5505
5506 P_resource_raw_rate_tbl(i) := nvl(l_final_txn_exch_rate,0) * NVL(P_resource_raw_rate_tbl(i),0);
5507 P_resource_burden_rate_tbl(i) := nvl(l_final_txn_exch_rate,0) * NVL(P_resource_burden_rate_tbl(i),0);
5508 P_resource_curr_code_tbl(i) := l_func_currency_code;
5509 END IF;
5510 END LOOP;
5511
5512 Exception
5513 When Others Then
5514 null;
5515 -- END IF; ------------------------------------------------------------}
5516 end Get_Resource_Cost_Rate;
5517 /*********************Eugene*******************/
5518
5519 Procedure Validate_Incur_by_Resource(
5520 P_Resource_Class_Code IN Varchar2,
5521 P_Res_Type_Code IN Varchar2 Default Null,
5522 P_Incur_By_Res_Code IN varchar2 Default Null,
5523 X_Person_Id OUT NOCOPY Number,
5524 X_Incur_By_Role_Id OUT NOCOPY Number,
5525 X_Job_Id OUT NOCOPY Number,
5526 X_Person_Type_Code OUT NOCOPY varchar2,
5527 X_Incur_By_Res_Class_Code OUT NOCOPY varchar2,
5528 X_Return_Status OUT NOCOPY Varchar2,
5529 X_Error_Message_Code OUT NOCOPY Varchar2)
5530
5531 Is
5532
5533 MAN_PARAMS_NULL Exception;
5534 INVAL_RES_CLSS_CODE Exception;
5535 INVAL_RES_TYPE_CODE Exception;
5536 UNEXPEC_ERROR Exception;
5537
5538 Begin
5539
5540 -- Initialize values
5541 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
5542 X_Error_Message_Code := Null;
5543
5544 If P_Incur_By_Res_Code is Null Or
5545 P_Res_Type_Code is NUll Then
5546
5547 Raise MAN_PARAMS_NULL;
5548 --Raise UNEXPEC_ERROR;
5549
5550 End If;
5551
5552 If P_Resource_Class_Code <> 'FINANCIAL_ELEMENTS' Then
5553
5554 Raise INVAL_RES_CLSS_CODE;
5555
5556 End If;
5557
5558 If P_Res_Type_Code = 'NAMED_PERSON' Then
5559
5560 X_Person_Id := P_Incur_By_Res_Code;
5561
5562 ElsIf P_Res_Type_Code = 'JOB' Then
5563
5564 X_Job_Id := P_Incur_By_Res_Code;
5565
5566 ElsIf P_Res_Type_Code = 'PERSON_TYPE' Then
5567
5568 X_Person_Type_Code := P_Incur_By_Res_Code;
5569
5570 ElsIf P_Res_Type_Code = 'RESOURCE_CLASS' Then
5571
5572 X_Incur_By_Res_Class_Code := P_Incur_By_Res_Code;
5573
5574 ElsIf P_Res_Type_Code = 'ROLE' Then
5575
5576 X_Incur_By_Role_Id := P_Incur_By_Res_Code;
5577
5578 Else
5579
5580 Raise INVAL_RES_TYPE_CODE;
5581
5582 End If;
5583
5584 Exception
5585 When UNEXPEC_ERROR THEN
5586 X_Return_Status := Fnd_Api.G_Ret_Sts_UnExp_Error;
5587 --x_msg_count := x_msg_count + 1;
5588 x_error_message_code := Null;
5589 Fnd_Msg_Pub.Add_Exc_Msg(
5590 P_Pkg_Name => 'PA_PLANNING_RESOURCE_UTILS',
5591 P_Procedure_Name => 'Validate_Incur_by_Resource');
5592
5593 When MAN_PARAMS_NULL Then
5594 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5595 X_Error_Message_Code := 'PA_VIR_MAN_PARAMS_NULL';
5596 Pa_Utils.Add_Message
5597 (P_App_Short_Name => 'PA',
5598 P_Msg_Name => 'PA_VIR_MAN_PARAMS_NULL',
5599 p_token1 => 'PLAN_RES',
5600 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5601 When INVAL_RES_CLSS_CODE Then
5602 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5603 X_Error_Message_Code := 'PA_VIR_INVAL_RES_CLSS_CODE';
5604 Pa_Utils.Add_Message
5605 (P_App_Short_Name => 'PA',
5606 P_Msg_Name => 'PA_VIR_INVAL_RES_CLSS_CODE',
5607 p_token1 => 'PLAN_RES',
5608 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5609 When INVAL_RES_TYPE_CODE Then
5610 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
5611 X_Error_Message_Code := 'PA_VIR_INVAL_RES_TYPE_CODE';
5612 Pa_Utils.Add_Message
5613 (P_App_Short_Name => 'PA',
5614 P_Msg_Name => 'PA_VIR_INVAL_RES_TYPE_CODE',
5615 p_token1 => 'PLAN_RES',
5616 p_value1 => Pa_Planning_Resource_Pvt.g_token);
5617 When Others Then
5618 Raise;
5619
5620 End Validate_Incur_by_Resource;
5621 /***********Eugene**************/
5622
5623 Procedure Validate_Planning_Resource(
5624 P_Task_Name IN VARCHAR2 Default Null,
5625 P_Task_Number IN Varchar2 Default Null,
5626 P_Planning_Resource_Alias IN Varchar2 Default Null,
5627 P_Resource_List_Member_Id IN Number Default Null,
5628 P_resource_list_id IN Number Default Null,
5629 P_Res_Format_Id IN Number Default Null,
5630 P_Resource_Class_Code IN Varchar2,
5631 P_Res_Type_Code IN Varchar2 Default Null,
5632 P_Resource_Code IN Varchar2 Default Null,
5633 P_Resource_Name IN Varchar2 Default Null,
5634 P_Project_Role_Id IN Number Default Null,
5635 P_Project_Role_Name IN Varchar2 Default Null,
5636 P_Team_Role IN Varchar2 Default Null,
5637 P_Organization_Id IN Number Default Null,
5638 P_Organization_Name IN Varchar2 Default Null,
5639 P_FC_Res_Type_Code IN Varchar2 Default Null,
5640 P_Fin_Category_Name IN Varchar2 Default Null,
5641 P_Supplier_Id IN Number Default Null,
5642 P_Supplier_Name IN Varchar2 Default Null,
5643 P_Incur_By_Resource_Code IN varchar2 Default Null,
5644 P_Incur_By_Resource_Type IN Varchar2 Default Null,
5645 X_Resource_List_Member_Id OUT NOCOPY Number,
5646 X_Person_Id OUT NOCOPY Number,
5647 X_Bom_Resource_Id OUT NOCOPY Number,
5648 X_Job_Id OUT NOCOPY Number,
5649 X_Person_Type_Code OUT NOCOPY varchar2,
5650 X_Non_Labor_Resource OUT NOCOPY varchar2,
5651 X_Inventory_Item_Id OUT NOCOPY Number,
5652 X_Item_Category_Id OUT NOCOPY Number,
5653 X_Project_Role_Id OUT NOCOPY Number,
5654 X_Team_Role OUT NOCOPY Varchar2,
5655 X_Organization_Id OUT NOCOPY Number,
5656 X_Expenditure_Type OUT NOCOPY Varchar2,
5657 X_Expenditure_Category OUT NOCOPY Varchar2,
5658 X_Event_Type OUT NOCOPY Varchar2,
5659 X_Revenue_Category_Code OUT NOCOPY Varchar2,
5660 X_Supplier_Id OUT NOCOPY Number,
5661 X_Resource_Class_Id OUT NOCOPY Number,
5662 X_resource_class_flag OUT NOCOPY varchar2,
5663 X_Incur_By_Role_Id OUT NOCOPY Number,
5664 X_Incur_By_Res_Class_Code OUT NOCOPY varchar2,
5665 X_Incur_By_Res_Flag OUT NOCOPY varchar2,
5666 X_Return_Status OUT NOCOPY Varchar2,
5667 X_Msg_Data OUT NOCOPY Varchar2,
5668 X_Msg_Count OUT NOCOPY Number)
5669
5670
5671 Is
5672
5673 Cursor c_Res_List_Mem (P_Plan_Res_List_Mem_Id In Number Default Null)
5674 Is
5675 Select
5676 Resource_List_Member_Id,
5677 Res_Format_Id
5678 From
5679 Pa_Resource_List_Members
5680 Where (P_Plan_Res_List_Mem_Id is Not Null and
5681 Resource_List_Member_Id = P_Plan_Res_List_Mem_Id) ;
5682
5683 Cursor c_get_migration_code (P_Res_List_Mem_Id In Number) Is
5684 Select migration_code
5685 From Pa_Resource_List_Members
5686 Where Resource_List_Member_Id = P_Res_List_Mem_Id;
5687
5688 Cursor c_Get_Fmt_Details (P_Res_Format_Id IN Number ) is
5689 Select
5690 Res_Type_Id,
5691 Res_Type_Enabled_Flag,
5692 Orgn_Enabled_Flag,
5693 Fin_Cat_Enabled_Flag,
5694 Incurred_By_Enabled_Flag,
5695 Supplier_Enabled_Flag,
5696 Role_Enabled_flag,
5697 Resource_Class_Flag
5698 From
5699 Pa_Res_Formats_B
5700 Where
5701 Res_Format_Id = P_Res_Format_Id;
5702
5703 CURSOR get_job_group_id(p_res_list_id in NUMBER) is
5704 select job_group_id
5705 from pa_resource_lists_all_bg
5706 where resource_list_id = p_res_list_id;
5707
5708 CURSOR chk_job_in_job_group(p_job_group_id IN NUMBER,
5709 p_Job_ID in NUMBER) IS
5710 select 'Y'
5711 from per_jobs
5712 where job_group_id = p_job_group_id
5713 and Job_ID = p_Job_ID;
5714
5715 CURSOR get_res_list_id(p_res_member_id in NUMBER) is
5716 select resource_list_id
5717 from pa_resource_list_members
5718 where resource_list_member_id = p_res_member_id;
5719 --Added for CBS::13535688
5720 CURSOR get_resource_class_flag(x_p_resource_list_id in NUMBER) is
5721 select NVL(resource_class_flag,'Y') resource_class_flag
5722 from pa_resource_lists_all_bg
5723 where resource_list_id = x_p_resource_list_id;
5724 --Added for CBS::13535688
5725
5726
5727 l_Resource_List_Member_Id Number := Null;
5728 l_Res_Format_Id Number := Null;
5729 l_Person_Id Number := Null;
5730 l_Incur_By_Role_Id Number := Null;
5731 l_Job_Id Number := Null;
5732 l_Person_Type_Code varchar2(30) := Null;
5733 l_Incur_By_Res_Class_Code varchar2(30) := Null;
5734 -- l_dummy_Res_Class_Flag Varchar2(30) := Null;
5735 l_dummy_Res_Class_Code Varchar2(30) := Null;
5736 l_bom_combo_exists Varchar2(1) := 'N';
5737 l_jg_valid Varchar2(1) := 'Y';
5738 l_job_group_id Number := Null;
5739 l_resource_list_id Number := Null;
5740 l_team_role Varchar2(80);
5741 l_migration_code Varchar2(1) := 'N';
5742 --PARAMS_ALL_NULL Exception;
5743 --BAD_PLAN_RES_LIST_ALIAS Exception;
5744 --BAD_PLAN_RES_LIST_MEM_ID Exception;
5745 --PLN_RL_FORMAT_BAD_FMT_ID Exception;
5746 INVALID_BOM_COMBO Exception;
5747 BAD_FC_PARAM_COMBO Exception;
5748 BAD_INCUR_PARAM_COMBO Exception;
5749 MISSING_RES_TYPE_VALUES Exception;
5750 MISSING_ORG_VALUES Exception;
5751 MISSING_FC_VALUES Exception;
5752 MISSING_INCUR_BY_VALUES Exception;
5753 MISSING_SUPPLIER_VALUES Exception;
5754 MISSING_ROLE_VALUES Exception;
5755 MISSING_TEAM_ROLE Exception;
5756 FAIL_VALIDATION Exception;
5757 -- JOB_GROUP_ERROR Exception;
5758 UNEXPEC_ERROR Exception;
5759
5760 l_List_Mem_Rec c_Res_List_Mem%RowType;
5761 l_fmt_details c_Get_Fmt_Details%RowType;
5762
5763 --Added for CBS changes
5764 l_resource_class_flag Varchar2(1) := 'Y';
5765
5766 Function AddTaskAlias(P_Error_Code IN Varchar2,
5767 P_Task_Number IN Varchar2,
5768 P_Task_Name IN Varchar2,
5769 P_Alias IN Varchar2) Return Varchar2
5770
5771 Is
5772
5773 l_Return_Value Varchar2(2000) := Null;
5774
5775 Begin
5776
5777 If P_Task_Number is not null and P_Task_Name is Not Null and P_Alias is Not Null Then
5778
5779 l_Return_Value := P_Error_Code || P_Task_Number || P_Task_Name || P_Alias;
5780
5781 ElsIf P_Task_Number is not null and P_Task_Name is Not Null Then
5782
5783 l_Return_Value := P_Error_Code || P_Task_Number || P_Task_Name;
5784
5785 Else
5786
5787 l_Return_Value := P_Error_Code;
5788
5789 End If;
5790
5791 Return l_Return_Value;
5792
5793 End AddTaskAlias;
5794
5795 Begin
5796
5797 -- Initialize Values
5798 X_Return_Status := Fnd_Api.G_Ret_Sts_Success;
5799 X_Msg_Count := 0;
5800 X_Msg_Data := Null;
5801
5802 X_Incur_By_Res_Flag := 'N'; -- set it to Yes when checking if
5803 -- incurred by resource exists.
5804
5805 /* bug 3436074
5806 If P_Resource_List_Member_Id is Null and
5807 P_Planning_Resource_Alias is Null and
5808 P_Res_Format_Id is Null Then
5809 */
5810
5811 If P_Resource_List_Member_Id is Null and
5812 P_Res_Format_Id is Null Then
5813
5814 --Raise PARAMS_ALL_NULL;
5815 Raise UNEXPEC_ERROR;
5816
5817 End If;
5818
5819 -- Added to ensure UOM validation for migrated resources
5820 -- is not done because of a corner case where it is possible
5821 -- (in the old model) to have an expenditure type of UOM <> Hours
5822 -- but track as labor as 'Y', which will be upgraded to PEOPLE
5823 -- resource class.
5824 l_migration_code := 'N';
5825
5826 If P_Resource_List_Member_Id is not Null Then
5827
5828 X_Resource_List_Member_Id := P_Resource_List_Member_Id;
5829 OPEN c_get_migration_code(P_Res_List_Mem_Id =>
5830 P_Resource_List_Member_Id);
5831 FETCH c_get_migration_code INTO l_migration_code;
5832 CLOSE c_get_migration_code;
5833
5834 /* bug 3436074 with the change update top this code is not needed.
5835 Else
5836
5837 If P_Planning_Resource_Alias is Not Null Then
5838
5839 Open c_Res_List_Mem (P_Plan_Res_Alias => P_Planning_Resource_Alias);
5840 Fetch c_Res_List_Mem Into l_List_Mem_Rec;
5841 If c_Res_List_Mem%NotFound Then
5842
5843 Close c_Res_List_Mem;
5844 Raise BAD_PLAN_RES_LIST_ALIAS;
5845
5846 End If;
5847 Close c_Res_List_Mem;
5848
5849 X_Resource_List_Member_Id := l_List_Mem_Rec.Resource_List_Member_Id;
5850
5851 End If;
5852 */
5853
5854 End If;
5855
5856 If P_Res_Format_Id Is Null Then
5857
5858 If x_Resource_List_Member_Id is Not Null Then
5859
5860 Open c_Res_List_Mem (P_Plan_Res_List_Mem_Id => x_Resource_List_Member_Id);
5861 Fetch c_Res_List_Mem Into l_List_Mem_Rec;
5862 If c_Res_List_Mem%NotFound Then
5863
5864 Close c_Res_List_Mem;
5865 --Raise BAD_PLAN_RES_LIST_MEM_ID;
5866 Raise UNEXPEC_ERROR;
5867
5868 End If;
5869 Close c_Res_List_Mem;
5870
5871 End If;
5872
5873 l_Res_Format_Id := l_List_Mem_Rec.Res_Format_Id;
5874
5875 Else
5876
5877 l_Res_Format_Id := P_Res_Format_Id;
5878
5879 End If;
5880
5881 Open c_Get_Fmt_Details (P_Res_Format_Id => l_Res_Format_Id);
5882 Fetch c_Get_Fmt_Details Into l_fmt_details;
5883 If c_Get_Fmt_Details%NotFound Then
5884
5885 Close c_Get_Fmt_Details;
5886 --Raise PLN_RL_FORMAT_BAD_FMT_ID;
5887 Raise UNEXPEC_ERROR;
5888
5889 End If;
5890 Close c_Get_Fmt_Details; --Fix for bug#6504988
5891
5892 If ( ( P_FC_Res_Type_Code is Null and P_Fin_Category_Name is Null ) or
5893 ( P_FC_Res_Type_Code is Not Null and P_Fin_Category_Name is Not Null ) ) Then
5894
5895
5896 Null;
5897
5898 Else
5899 Raise BAD_FC_PARAM_COMBO;
5900
5901 End If;
5902
5903 If ( ( P_Incur_By_Resource_Code is Null and P_Incur_By_Resource_Type is Null ) Or
5904 ( P_Incur_By_Resource_Code is Not Null and P_Incur_By_Resource_Type is Not Null ) ) Then
5905
5906 Null;
5907
5908 Else
5909 Raise BAD_INCUR_PARAM_COMBO;
5910
5911 End If;
5912
5913 -- Set up resource class flag
5914 x_resource_class_flag := l_fmt_details.resource_class_flag;
5915
5916 If l_fmt_details.Res_Type_Enabled_Flag = 'Y' and
5917 P_Resource_Code is Null and
5918 P_Resource_Name is Null Then
5919 Raise MISSING_RES_TYPE_VALUES;
5920
5921 ElsIf P_Resource_Code is Not Null or
5922 P_Resource_Name is Not Null Then
5923
5924 -- hr_utility.trace('P_Resource_Code IS : ' || P_Resource_Code);
5925 -- hr_utility.trace('P_Resource_Name IS : ' || P_Resource_Name);
5926 -- Populate g_job_group_id: if the resource is a job then
5927 -- need to validate against job group ID.
5928 -- Get job group ID from resource list of member
5929 -- if not passed in.
5930 l_resource_list_id := p_resource_list_id;
5931
5932 If p_resource_list_member_id is not null Then
5933
5934 open get_res_list_id(p_resource_list_member_id);
5935 fetch get_res_list_id into l_resource_list_id;
5936 close get_res_list_id;
5937
5938 End If;
5939
5940 If l_resource_list_id IS NOT NULL THEN
5941
5942 open get_job_group_id(l_resource_list_id);
5943 fetch get_job_group_id into g_job_group_id;
5944 close get_job_group_id;
5945
5946 End If;
5947
5948 -- hr_utility.trace('g_job_group_id IS : ' || g_job_group_id);
5949 -- hr_utility.trace('Before Pa_Planning_Resource_Utils.Validate_Resource');
5950 IF P_PA_DEBUG_MODE = 'Y' THEN
5951 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'p_resource_code '|| p_resource_code ,1);
5952 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'p_resource_name '|| p_resource_name ,1);
5953 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'p_resource_class_code '|| p_resource_class_code ,1);
5954 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'p_res_type_code '|| p_res_type_code ,1);
5955 END IF;
5956 Pa_Planning_Resource_Utils.Validate_Resource(
5957 P_resource_Code => P_Resource_Code,
5958 P_Resource_Name => P_Resource_Name,
5959 P_Resource_Class_Code => P_Resource_Class_Code,
5960 P_Res_Type_Code => P_Res_Type_Code,
5961 X_Person_Id => X_Person_Id,
5962 X_Bom_Resource_Id => X_Bom_Resource_Id,
5963 X_Job_Id => X_Job_Id,
5964 X_Person_Type_Code => X_Person_Type_Code,
5965 X_Non_Labor_Resource => X_Non_Labor_Resource,
5966 X_Inventory_Item_Id => X_Inventory_Item_Id,
5967 X_Item_Category_Id => X_Item_Category_Id,
5968 X_Resource_Class_Code => l_Dummy_Res_Class_Code,
5969 X_Resource_Class_Flag => X_resource_class_flag,
5970 X_Return_Status => X_Return_Status,
5971 X_Error_Msg_Code => X_Msg_Data);
5972 IF P_PA_DEBUG_MODE = 'Y' THEN
5973 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_Person_Id '|| X_Person_Id ,1);
5974 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_Bom_Resource_Id '|| X_Bom_Resource_Id ,1);
5975 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_Job_Id '|| X_Job_Id ,1);
5976 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_Person_Type_Code '|| X_Person_Type_Code ,1);
5977 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_Non_Labor_Resource '|| X_Non_Labor_Resource ,1);
5978 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_Inventory_Item_Id '|| X_Inventory_Item_Id ,1);
5979 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_Item_Category_Id '|| X_Item_Category_Id ,1);
5980 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'l_Dummy_Res_Class_Code '|| l_Dummy_Res_Class_Code ,1);
5981 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_resource_class_flag '|| X_resource_class_flag ,1);
5982 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_Return_Status '|| X_Return_Status ,1);
5983 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'X_Msg_Data '|| X_Msg_Data ,1);
5984 END IF;
5985
5986 -- hr_utility.trace('After Pa_Planning_Resource_Utils.Validate_Resource');
5987 -- hr_utility.trace('X_Return_Status IS : ' || X_Return_Status);
5988 -- hr_utility.trace('X_Msg_Data IS : ' || X_Msg_Data);
5989 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
5990
5991 Raise FAIL_VALIDATION;
5992
5993 End If;
5994
5995 End If;
5996
5997 If l_fmt_details.Orgn_Enabled_Flag = 'Y' and
5998 P_Organization_Id is Null and
5999 P_Organization_Name is Null Then
6000
6001 Raise MISSING_ORG_VALUES;
6002
6003 ElsIf P_Organization_Id is Not Null or
6004 P_Organization_Name is Not Null Then
6005 Pa_Planning_Resource_Utils.Validate_Organization(
6006 P_Organization_Name => P_Organization_Name,
6007 P_Organization_Id => P_Organization_Id,
6008 X_Organization_Id => X_Organization_Id,
6009 X_Return_Status => X_Return_Status,
6010 X_Error_Msg_Code => X_Msg_Data);
6011
6012 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
6013 Raise FAIL_VALIDATION;
6014
6015 End If;
6016
6017 End If;
6018
6019 If l_fmt_details.Fin_Cat_Enabled_Flag = 'Y' and
6020 P_FC_Res_Type_Code is Null and
6021 P_Fin_Category_Name is Null Then
6022
6023 Raise MISSING_FC_VALUES;
6024
6025 ElsIf P_FC_Res_Type_Code is Not Null or
6026 P_Fin_Category_Name is Not Null Then
6027 --Added for CBS::13535688
6028 --l_resource_class_flag:='Y';
6029 IF P_PA_DEBUG_MODE = 'Y' THEN
6030 pa_debug.write(' Before Executing Cursor resource_class_flag :'||l_resource_class_flag ,1);
6031 END IF;
6032 if P_resource_list_id is Not null then
6033
6034 open get_resource_class_flag(P_resource_list_id);
6035 FETCH get_resource_class_flag INTO l_resource_class_flag;
6036 close get_resource_class_flag;
6037
6038 IF P_PA_DEBUG_MODE = 'Y' THEN
6039 pa_debug.write(' After Executing Cursor resource_class_flag :'||l_resource_class_flag ,1);
6040 END IF;
6041
6042 END If;
6043
6044 /* Start Bug13625913 new changes*/
6045 If p_resource_list_member_id is not null Then
6046 open get_res_list_id(p_resource_list_member_id);
6047 fetch get_res_list_id into l_resource_list_id;
6048 close get_res_list_id;
6049
6050 IF l_resource_list_id is not null then
6051 IF P_PA_DEBUG_MODE = 'Y' THEN
6052 pa_debug.write(' Before Executing Cursor2 resource_class_flag :'||l_resource_class_flag ,1);
6053 END IF;
6054 open get_resource_class_flag(l_resource_list_id);
6055 FETCH get_resource_class_flag INTO l_resource_class_flag;
6056 close get_resource_class_flag;
6057 IF P_PA_DEBUG_MODE = 'Y' THEN
6058 pa_debug.write(' After Executing Cursor2 resource_class_flag :'||l_resource_class_flag ,1);
6059 END IF;
6060 END IF;
6061
6062 End If;
6063 /* End Bug13625913 */
6064 IF P_PA_DEBUG_MODE = 'Y' THEN
6065 pa_debug.write(' Before Calling Pa_Planning_Resource_Utils.Validate_Fin_Category resource_class_flag :'||l_resource_class_flag ,1);
6066 END IF;
6067
6068 Pa_Planning_Resource_Utils.Validate_Fin_Category(
6069 P_FC_Res_Type_Code => P_FC_Res_Type_Code,
6070 P_Resource_Class_Code => P_Resource_Class_Code,
6071 P_Fin_Category_Name => P_Fin_Category_Name,
6072 P_migration_code => l_migration_code,
6073 P_Resource_Class_Flag => l_resource_class_flag,--Added for CBS::13535688
6074 X_Expenditure_Type => X_Expenditure_Type,
6075 X_Expenditure_Category => X_Expenditure_Category,
6076 X_Event_Type => X_Event_Type,
6077 X_Revenue_Category => X_Revenue_Category_Code,
6078 X_Return_Status => X_Return_Status,
6079 X_Error_Message_Code => X_Msg_Data);
6080
6081 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
6082
6083 Raise FAIL_VALIDATION;
6084
6085 End If;
6086
6087 End If;
6088
6089 If l_fmt_details.Incurred_By_Enabled_Flag = 'Y' and
6090 P_Incur_By_Resource_Code is Null and
6091 P_Incur_By_Resource_Type is Null Then
6092
6093 Raise MISSING_INCUR_BY_VALUES;
6094
6095 ElsIf P_Incur_By_Resource_Code is Not Null or
6096 P_Incur_By_Resource_Type is Not Null Then
6097
6098 If P_Resource_Class_Code = 'FINANCIAL_ELEMENTS' Then
6099
6100 Pa_Planning_Resource_Utils.Validate_Incur_by_Resource(
6101 P_Resource_Class_Code => P_Resource_Class_Code,
6102 P_Res_Type_Code => P_Incur_By_Resource_Type,
6103 P_Incur_By_Res_Code => P_Incur_By_Resource_Code,
6104 X_Person_Id => l_Person_Id,
6105 X_Incur_By_Role_Id => l_Incur_By_Role_Id,
6106 X_Job_Id => l_Job_Id,
6107 X_Person_Type_Code => l_Person_Type_Code,
6108 X_Incur_By_Res_Class_Code => l_Incur_By_Res_Class_Code,
6109 X_Return_Status => X_Return_Status,
6110 X_Error_Message_Code => X_Msg_Data);
6111
6112 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
6113
6114 Raise FAIL_VALIDATION;
6115
6116 End If;
6117
6118 X_Incur_By_Res_Flag := 'Y';
6119
6120 If P_Incur_By_Resource_Type = 'NAMED_PERSON' Then
6121
6122 X_Person_Id := l_Person_Id;
6123
6124 ElsIf P_Incur_By_Resource_Type = 'ROLE' Then
6125
6126 X_Incur_By_Role_Id := l_Incur_By_Role_Id;
6127
6128 ElsIf P_Incur_By_Resource_Type = 'JOB' Then
6129
6130 X_Job_Id := l_Job_Id;
6131
6132 ElsIf P_Incur_By_Resource_Type = 'PERSON_TYPE' Then
6133
6134 X_Person_Type_Code := l_Person_Type_Code;
6135
6136 ElsIf P_Incur_By_Resource_Type = 'RESOURCE_CLASS' Then
6137
6138 X_Incur_By_Res_Class_Code := l_Incur_By_Res_Class_Code;
6139
6140 End If;
6141
6142 End If; -- P_Resource_Class_Code = 'FINANCIAL_ELEMENTS'
6143
6144 End If;
6145
6146 If l_fmt_details.Supplier_Enabled_Flag = 'Y' and
6147 P_Supplier_Id is Null and
6148 P_Supplier_Name is Null Then
6149
6150 Raise MISSING_SUPPLIER_VALUES;
6151
6152 ElsIf P_Supplier_Id is Not Null or
6153 P_Supplier_Name is Not Null Then
6154
6155 Pa_Planning_Resource_Utils.Validate_Supplier(
6156 P_Resource_Class_Code => P_Resource_Class_Code,
6157 P_Person_Id => x_person_id,
6158 P_Supplier_Id => P_Supplier_Id,
6159 P_Supplier_Name => P_Supplier_Name,
6160 X_Supplier_Id => X_Supplier_Id,
6161 X_Return_Status => X_Return_Status,
6162 X_Error_Msg_Code => X_Msg_Data);
6163
6164 -- dbms_output.put_line('- After Validate_Supplier X_Supplier_Id IS : '|| X_Supplier_Id);
6165 -- dbms_output.put_line('- After Validate_Supplier X_Return_Status IS : '|| X_Return_Status);
6166 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
6167
6168 Raise FAIL_VALIDATION;
6169
6170 End If;
6171
6172 End If;
6173 -- Team Role changes
6174 /******************************************************
6175 * Checking for combination of p_project_role_id and p_team_role
6176 * If p_project_role_id is null then p_team_role must be null.
6177 * If p_project_role_id is not null, then p_team_role must be
6178 * not null.
6179 *******************************************************/
6180 /*******************************************************
6181 * Bug - 3601619
6182 * Desc - If the p_team_role paramter is null, and the
6183 * p_Project_Role_Name is not Null or the p_project_role_id
6184 * is not Null, then we will default the p_team_role to be
6185 * the same as the P_Project_Role_Name.
6186 ************************************************************/
6187 IF p_team_role IS NULL THEN
6188 IF l_fmt_details.Role_Enabled_flag = 'Y' THEN
6189 IF P_Project_Role_Name IS NOT NULL THEN
6190 l_team_role := P_Project_Role_Name;
6191 ELSE
6192 IF p_project_role_id IS NOT NULL THEN
6193 l_team_role := Pa_Planning_Resource_Utils.Ret_Role_Name
6194 (P_Role_Id => p_project_role_id );
6195 END IF;
6196 END IF;
6197 ELSE
6198 l_team_role := NULL;
6199 END IF;
6200 ELSE
6201 -- Cannot have a team role without a role, regardless of
6202 -- whether role/team role is part of format.
6203 -- Check for Role existence.
6204 IF P_Project_Role_Name IS NULL and p_project_role_id IS NULL AND
6205 P_Task_Name IS NULL and P_Task_Number IS NULL THEN
6206 -- Added task name and number check because from TA flow,
6207 -- it is acceptable in some cases to have a team role
6208 -- without a role.
6209 RAISE MISSING_TEAM_ROLE;
6210 ELSE
6211 l_team_role := p_team_role;
6212 END IF;
6213 END IF;
6214 --3601619
6215 --p_team_role changed to l_team_role.
6216
6217 If l_fmt_details.Role_Enabled_flag = 'Y' THEN
6218 IF (p_project_role_id IS NULL AND P_Project_Role_Name is Null and
6219 l_team_role IS NOT NULL) OR
6220 ((p_project_role_id IS NOT NULL OR P_Project_Role_Name is not null)
6221 and l_team_role IS NULL)
6222 THEN
6223 RAISE MISSING_TEAM_ROLE;
6224 END IF;
6225 END IF;
6226
6227 If l_fmt_details.Role_Enabled_flag = 'Y' and
6228 P_Project_Role_Id Is Null and
6229 P_Project_Role_Name is Null Then
6230
6231 Raise MISSING_ROLE_VALUES;
6232
6233 ElsIf P_Project_Role_Id Is Not Null or
6234 P_Project_Role_Name is Not Null Then
6235
6236 Pa_Role_Utils.Check_Role_Name_Or_Id(
6237 P_Role_Id => P_Project_Role_Id,
6238 P_Role_Name => P_Project_Role_Name,
6239 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
6240 X_Role_Id => X_Project_Role_Id,
6241 X_Return_Status => X_Return_Status,
6242 X_Error_Message_Code => X_Msg_Data);
6243
6244 If X_Return_Status = Fnd_Api.G_Ret_Sts_Error Then
6245
6246 Raise FAIL_VALIDATION;
6247
6248 End If;
6249
6250 End If;
6251 -- Assign out parameter x_team_role in all cases.
6252 -- Team Role changes
6253 --3601619
6254 x_team_role := l_team_role;
6255
6256 -- Bug 4202047 - if BOM resource - Org format is used, check
6257 -- that the combination exists in BOM table - cannot override Org.
6258 IF X_Bom_Resource_Id IS NOT NULL AND
6259 X_Organization_Id IS NOT NULL THEN
6260
6261 -- Validate the combination
6262 BEGIN
6263 SELECT 'Y'
6264 INTO l_bom_combo_exists
6265 FROM bom_resources b
6266 WHERE b.resource_id = X_Bom_Resource_Id
6267 AND b.organization_id = X_Organization_Id
6268 AND ROWNUM = 1;
6269
6270 EXCEPTION
6271 WHEN NO_DATA_FOUND THEN
6272 RAISE INVALID_BOM_COMBO;
6273 END;
6274
6275 END IF;
6276
6277 IF P_PA_DEBUG_MODE = 'Y' THEN
6278 pa_debug.write('PA_PLANNING_RESOURCE_UTILS: ' || g_module_name,'Validate_Planning_Resource ',1);
6279 END IF;
6280 Exception
6281 When UNEXPEC_ERROR THEN
6282 X_Return_Status := Fnd_Api.G_Ret_Sts_UnExp_Error;
6283 --x_msg_count := x_msg_count + 1;
6284 x_msg_data := Null;
6285 Fnd_Msg_Pub.Add_Exc_Msg(
6286 P_Pkg_Name => 'PA_PLANNING_RESOURCE_UTILS',
6287 P_Procedure_Name => 'Validate_Planning_Resource');
6288
6289 /*When PARAMS_ALL_NULL Then
6290 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6291 X_Msg_Count := 1;
6292 X_Msg_Data := AddTaskAlias(
6293 P_Error_Code => 'PA_PLN_RL_PARAMS_NULL',
6294 P_Task_Number => P_Task_Number,
6295 P_Task_Name => P_Task_Name,
6296 P_Alias => P_Planning_Resource_Alias);
6297 Pa_Utils.Add_Message
6298 (P_App_Short_Name => 'PA',
6299 P_Msg_Name => 'PA_PLN_RL_PARAMS_NULL');*/
6300
6301 /*When BAD_PLAN_RES_LIST_ALIAS Then
6302 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6303 X_Msg_Count := 1;
6304 X_Msg_Data := AddTaskAlias(
6305 P_Error_Code => 'PA_PLN_RL_BAD_ALIAS',
6306 P_Task_Number => P_Task_Number,
6307 P_Task_Name => P_Task_Name,
6308 P_Alias => P_Planning_Resource_Alias);
6309 Pa_Utils.Add_Message
6310 (P_App_Short_Name => 'PA',
6311 P_Msg_Name => 'PA_PLN_RL_BAD_ALIAS');*/
6312
6313 /*When BAD_PLAN_RES_LIST_MEM_ID Then
6314 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6315 X_Msg_Count := 1;
6316 X_Msg_Data := AddTaskAlias(
6317 P_Error_Code => 'PA_PLN_BAD_RL_MEM_ID',
6318 P_Task_Number => P_Task_Number,
6319 P_Task_Name => P_Task_Name,
6320 P_Alias => P_Planning_Resource_Alias);
6321 Pa_Utils.Add_Message
6322 (P_App_Short_Name => 'PA',
6323 P_Msg_Name => 'PA_PLN_BAD_RL_MEM_ID');*/
6324
6325 /*When PLN_RL_FORMAT_BAD_FMT_ID Then
6326 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6327 X_Msg_Count := 1;
6328 X_Msg_Data := AddTaskAlias(
6329 P_Error_Code => 'PA_PLN_RL_FORMAT_BAD_FMT_ID',
6330 P_Task_Number => P_Task_Number,
6331 P_Task_Name => P_Task_Name,
6332 P_Alias => P_Planning_Resource_Alias);
6333 Pa_Utils.Add_Message
6334 (P_App_Short_Name => 'PA',
6335 P_Msg_Name => 'PA_PLN_RL_FORMAT_BAD_FMT_ID');*/
6336
6337 /*
6338 When JOB_GROUP_ERROR Then -- Error Message needs to be defined
6339 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6340 X_Msg_Count := 1;
6341 X_Msg_Data := AddTaskAlias(
6342 P_Error_Code => 'PA_JOB_NOT_IN_JOB_GROUP',
6343 P_Task_Number => P_Task_Number,
6344 P_Task_Name => P_Task_Name,
6345 P_Alias => P_Planning_Resource_Alias);
6346 Pa_Utils.Add_Message
6347 (P_App_Short_Name => 'PA',
6348 P_Msg_Name => 'PA_JOB_NOT_IN_JOB_GROUP',
6349 p_token1 => 'PLAN_RES',
6350 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6351 */
6352
6353 When BAD_FC_PARAM_COMBO Then
6354 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6355 X_Msg_Count := 1;
6356 X_Msg_Data := AddTaskAlias(
6357 P_Error_Code => 'PA_PLN_RL_USE_FC_LOV',
6358 P_Task_Number => P_Task_Number,
6359 P_Task_Name => P_Task_Name,
6360 P_Alias => P_Planning_Resource_Alias);
6361 Pa_Utils.Add_Message
6362 (P_App_Short_Name => 'PA',
6363 P_Msg_Name => 'PA_PLN_RL_USE_FC_LOV',
6364 p_token1 => 'PLAN_RES',
6365 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6366
6367 When BAD_INCUR_PARAM_COMBO Then
6368 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6369 X_Msg_Count := 1;
6370 X_Msg_Data := AddTaskAlias(
6371 P_Error_Code => 'PA_PLN_RL_USE_INCUR_RES_LOV',
6372 P_Task_Number => P_Task_Number,
6373 P_Task_Name => P_Task_Name,
6374 P_Alias => P_Planning_Resource_Alias);
6375 Pa_Utils.Add_Message
6376 (P_App_Short_Name => 'PA',
6377 P_Msg_Name => 'PA_PLN_RL_USE_INCUR_RES_LOV',
6378 p_token1 => 'PLAN_RES',
6379 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6380
6381 When MISSING_RES_TYPE_VALUES Then
6382 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6383 X_Msg_Count := 1;
6384 X_Msg_Data := AddTaskAlias(
6385 P_Error_Code => 'PA_PLN_RL_NO_RES_TYPE',
6386 P_Task_Number => P_Task_Number,
6387 P_Task_Name => P_Task_Name,
6388 P_Alias => P_Planning_Resource_Alias);
6389 Pa_Utils.Add_Message
6390 (P_App_Short_Name => 'PA',
6391 P_Msg_Name => 'PA_PLN_RL_NO_RES_TYPE',
6392 p_token1 => 'PLAN_RES',
6393 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6394
6395 When MISSING_ORG_VALUES Then
6396 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6397 X_Msg_Count := 1;
6398 X_Msg_Data := AddTaskAlias(
6399 P_Error_Code => 'PA_PLN_RL_NO_ORG',
6400 P_Task_Number => P_Task_Number,
6401 P_Task_Name => P_Task_Name,
6402 P_Alias => P_Planning_Resource_Alias);
6403 Pa_Utils.Add_Message
6404 (P_App_Short_Name => 'PA',
6405 P_Msg_Name => 'PA_PLN_RL_NO_ORG',
6406 p_token1 => 'PLAN_RES',
6407 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6408
6409 When MISSING_FC_VALUES Then
6410 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6411 X_Msg_Count := 1;
6412 X_Msg_Data := AddTaskAlias(
6413 P_Error_Code => 'PA_PLN_RL_NO_FC',
6414 P_Task_Number => P_Task_Number,
6415 P_Task_Name => P_Task_Name,
6416 P_Alias => P_Planning_Resource_Alias);
6417 Pa_Utils.Add_Message
6418 (P_App_Short_Name => 'PA',
6419 P_Msg_Name => 'PA_PLN_RL_NO_FC',
6420 p_token1 => 'PLAN_RES',
6421 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6422
6423 When MISSING_INCUR_BY_VALUES Then
6424 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6425 X_Msg_Count := 1;
6426 X_Msg_Data := AddTaskAlias(
6427 P_Error_Code => 'PA_PLN_RL_NO_INCUR_BY',
6428 P_Task_Number => P_Task_Number,
6429 P_Task_Name => P_Task_Name,
6430 P_Alias => P_Planning_Resource_Alias);
6431 Pa_Utils.Add_Message
6432 (P_App_Short_Name => 'PA',
6433 P_Msg_Name => 'PA_PLN_RL_NO_INCUR_BY',
6434 p_token1 => 'PLAN_RES',
6435 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6436
6437 When MISSING_SUPPLIER_VALUES Then
6438 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6439 X_Msg_Count := 1;
6440 X_Msg_Data := AddTaskAlias(
6441 P_Error_Code => 'PA_PLN_RL_NO_SUPPLIER',
6442 P_Task_Number => P_Task_Number,
6443 P_Task_Name => P_Task_Name,
6444 P_Alias => P_Planning_Resource_Alias);
6445 Pa_Utils.Add_Message
6446 (P_App_Short_Name => 'PA',
6447 P_Msg_Name => 'PA_PLN_RL_NO_SUPPLIER',
6448 p_token1 => 'PLAN_RES',
6449 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6450
6451 When MISSING_ROLE_VALUES Then
6452 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6453 X_Msg_Count := 1;
6454 X_Msg_Data := AddTaskAlias(
6455 P_Error_Code => 'PA_PLN_RL_NO_ROLE',
6456 P_Task_Number => P_Task_Number,
6457 P_Task_Name => P_Task_Name,
6458 P_Alias => P_Planning_Resource_Alias);
6459 Pa_Utils.Add_Message
6460 (P_App_Short_Name => 'PA',
6461 P_Msg_Name => 'PA_PLN_RL_NO_ROLE',
6462 p_token1 => 'PLAN_RES',
6463 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6464
6465 When MISSING_TEAM_ROLE Then
6466 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6467 X_Msg_Count := 1;
6468 X_Msg_Data := AddTaskAlias(
6469 P_Error_Code => 'PA_PLN_RL_TEAM_ROLE',
6470 P_Task_Number => P_Task_Number,
6471 P_Task_Name => P_Task_Name,
6472 P_Alias => P_Planning_Resource_Alias);
6473 Pa_Utils.Add_Message
6474 (P_App_Short_Name => 'PA',
6475 P_Msg_Name => 'PA_PLN_RL_TEAM_ROLE',
6476 p_token1 => 'PLAN_RES',
6477 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6478 When INVALID_BOM_COMBO Then
6479 X_Return_Status := Fnd_Api.G_Ret_Sts_Error;
6480 X_Msg_Count := 1;
6481 X_Msg_Data := AddTaskAlias(
6482 P_Error_Code => 'PA_PLN_RL_INV_BOM_ORG',
6483 P_Task_Number => P_Task_Number,
6484 P_Task_Name => P_Task_Name,
6485 P_Alias => P_Planning_Resource_Alias);
6486 Pa_Utils.Add_Message
6487 (P_App_Short_Name => 'PA',
6488 P_Msg_Name => 'PA_PLN_RL_INV_BOM_ORG',
6489 p_token1 => 'PLAN_RES',
6490 p_value1 => Pa_Planning_Resource_Pvt.g_token);
6491 When FAIL_VALIDATION Then
6492 -- return status is already set by the called procedure already
6493 X_Msg_Count := 1;
6494 X_Msg_Data := AddTaskAlias(
6495 P_Error_Code => X_Msg_Data,
6496 P_Task_Number => P_Task_Number,
6497 P_Task_Name => P_Task_Name,
6498 P_Alias => P_Planning_Resource_Alias);
6499 -- Assuming that all the called procedure already do add_message().
6500
6501 When Others Then
6502 Raise;
6503
6504 End Validate_Planning_Resource;
6505 /***************Eugene***************/
6506
6507 /**********End of Get_Plan_Res_Combination Procedure ********/
6508
6509 /*******************************************************
6510 * End Eugene's code
6511 * ***************************************************/
6512
6513 /*********************************************************
6514 * Procedure : Derive_Resource_List_Member
6515 * Description : This Procedure is used to derive a
6516 * resource list member, given a project ID
6517 * resource_format Id and a few attributes.
6518 * (1) It first Checks if the Mandatory values
6519 * are passed.
6520 * (2) It then calls the API PA_TASK_ASSIGNMENT_UTILS
6521 * Get_WP_Resource_List_Id --> which will return the
6522 * resource list ID.
6523 * (3) Then Based on the values passed Constructs a
6524 * Dynamic SQL and retrieves the values from
6525 * pa_resource_list_members table.
6526 * (4) If no rows are returned then does step 5,6
6527 * (5) Checks if the resource list is project specific
6528 * If it is then creates a new resource_list_member
6529 * Call to pa_planning_resource_pvt.create_planning_resource
6530 * And passes back the newly
6531 * created resource_list_member_id
6532 * (6) If it is a Centrally controlled resource list
6533 * Then it calls Vijays API which will return the best
6534 * Matching resource list member.
6535 * (6a) Insert into Pa_res_list_map_tmp1 and then call
6536 * Api pa_resource_mapping.map_resource_list.
6537 * which will put the correct resource_list_member_id
6538 * in pa_res_list_map_tmp4.
6539 **************************************************************/
6540 Function Derive_Resource_List_Member
6541 (p_project_id IN NUMBER,
6542 p_res_format_id IN NUMBER,
6543 p_person_id IN NUMBER DEFAULT NULL,
6544 p_job_id IN NUMBER DEFAULT NULL,
6545 p_organization_id IN NUMBER DEFAULT NULL,
6546 p_expenditure_type IN Varchar2 DEFAULT NULL,
6547 p_expenditure_category IN Varchar2 DEFAULT NULL,
6548 p_project_role_id IN Number DEFAULT NULL,
6549 p_person_type_code IN Varchar2 DEFAULT NULL,
6550 p_named_role IN Varchar2 DEFAULT NULL)
6551 RETURN NUMBER
6552 IS
6553
6554 CURSOR get_fmt_details (p_res_format_id NUMBER) IS
6555 SELECT f.Res_Type_Enabled_Flag,
6556 f.Orgn_Enabled_Flag,
6557 f.Fin_Cat_Enabled_Flag,
6558 f.Role_Enabled_Flag,
6559 f.incurred_by_enabled_flag,
6560 f.supplier_enabled_flag,
6561 f.Res_Type_Id,
6562 t.Res_Type_Code
6563 FROM Pa_Res_Formats_B f,
6564 Pa_Res_Types_B t
6565 WHERE f.Res_Type_Id = t.Res_Type_Id(+)
6566 AND f.Res_Format_Id = p_res_format_id;
6567
6568 l_resource_list_id NUMBER;
6569 l_res_list_member_id VARCHAR2(30);
6570 l_resource_list_member_id NUMBER;
6571 l_cursor INTEGER;
6572 l_rows INTEGER;
6573 l_stmt VARCHAR2(2000);
6574 l_exists VARCHAR2(1) := 'Y';
6575 l_central_control VARCHAR2(1);
6576 l_valid VARCHAR2(1);
6577 l_valid_job VARCHAR2(1);
6578 l_return_status VARCHAR2(30);
6579 l_msg_count NUMBER;
6580 l_error_msg_data VARCHAR2(200);
6581 l_record_version_number NUMBER;
6582 l_resource_class_id NUMBER;
6583
6584 l_fmt_details get_fmt_details%RowType;
6585 l_person_id NUMBER := NULL;
6586 l_job_id NUMBER := NULL;
6587 l_job_group_id NUMBER := NULL;
6588 l_organization_id NUMBER := NULL;
6589 l_project_role_id NUMBER := NULL;
6590 l_person_type_code VARCHAR2(30) := NULL;
6591 l_named_role VARCHAR2(80) := NULL;
6592 l_fin_category_name VARCHAR2(200) := NULL;
6593 l_fc_res_type_code VARCHAR2(30) := NULL;
6594
6595 BEGIN
6596 /***************************************************
6597 * The Project_ID and res_format_id are mandatory.
6598 * In case they are not passed. Raise an unexpected
6599 * error and return.
6600 ****************************************************/
6601 IF p_project_id IS NULL OR p_res_format_id IS NULL THEN
6602 l_resource_list_member_id := NULL;
6603 Return l_resource_list_member_id;
6604 END IF;
6605 /*************************************************
6606 * Call to Sheenie's API which will take in the
6607 * project_id and return back the resource_list_id.
6608 * It would get the resource_list_ID associated to the
6609 * project and for which Workplan is enabled.
6610 ****************************************************/
6611 l_resource_list_id :=
6612 Pa_Task_Assignment_Utils.Get_WP_Resource_List_Id(p_project_id);
6613
6614 IF l_resource_list_id IS NULL THEN
6615 l_resource_list_member_id := NULL;
6616 Return l_resource_list_member_id;
6617 END IF;
6618
6619 /****************************************************
6620 * Once we have got the Resource_List_ID
6621 * We need to establish if it is Project specific or
6622 * Centrally Controlled resource_list.
6623 *******************************************************/
6624 BEGIN
6625 SELECT control_flag
6626 INTO l_central_control
6627 FROM pa_resource_lists_all_bg
6628 WHERE resource_list_id = l_resource_list_id;
6629 EXCEPTION
6630 WHEN OTHERS THEN
6631 l_resource_list_member_id := NULL;
6632 Return l_resource_list_member_id;
6633 END;
6634 /********************************
6635 * Open Cursor
6636 ********************************/
6637 l_cursor := dbms_sql.open_cursor;
6638 /**************************************************************
6639 * Constructing the Select Statement based on the values passed
6640 * as parameters to this procedure.
6641 ***********************************************************/
6642 l_stmt := 'SELECT resource_list_member_id '||
6643 ' FROM pa_resource_list_members ' ||
6644 ' WHERE resource_list_id = :resource_list_id' ||
6645 ' AND enabled_flag = ''Y'' ' ||
6646 ' AND res_format_id = :res_format_id';
6647
6648 -- Get the required segments of the format and append clauses
6649 -- based on that. Fixes bug 3728941.
6650 Open get_fmt_details(p_res_format_id => p_res_format_id);
6651 Fetch get_fmt_details into l_fmt_details;
6652 Close get_fmt_details;
6653
6654 /*****************************************
6655 * If person_ID value is passed then append
6656 * it to the Where clause.
6657 *******************************************/
6658 IF -- p_person_id IS NOT NULL AND
6659 l_fmt_details.Res_Type_Enabled_Flag = 'Y' AND
6660 l_fmt_details.Res_Type_Code = 'NAMED_PERSON'
6661 THEN
6662 l_person_id := p_person_id;
6663 l_stmt := l_stmt || ' AND person_id = :person_id';
6664 END IF;
6665
6666 /*****************************************
6667 * If organization_id value is passed then append
6668 * it to the Where clause.
6669 *******************************************/
6670 IF --p_organization_id IS NOT NULL AND
6671 l_fmt_details.Orgn_Enabled_Flag = 'Y'
6672 THEN
6673 l_organization_id := p_organization_id;
6674 l_stmt := l_stmt || ' AND organization_id = :organization_id';
6675 END IF;
6676
6677 /*****************************************
6678 * If job_id value is passed then append
6679 * it to the Where clause.
6680 *******************************************/
6681 IF -- p_job_id IS NOT NULL AND
6682 l_fmt_details.Res_Type_Enabled_Flag = 'Y' AND
6683 l_fmt_details.Res_Type_Code = 'JOB'
6684 THEN
6685 l_job_id := p_job_id;
6686 l_stmt := l_stmt || ' AND job_id = :job_id';
6687 END IF;
6688
6689 /*****************************************
6690 * If expenditure_type value is passed then append
6691 * it to the Where clause.
6692 *******************************************/
6693 IF p_expenditure_type IS NOT NULL AND
6694 l_fmt_details.Fin_Cat_Enabled_Flag = 'Y'
6695 THEN
6696 l_fin_category_name := p_expenditure_type;
6697 l_fc_res_type_code := 'EXPENDITURE_TYPE';
6698 l_stmt := l_stmt || ' AND expenditure_type = :expenditure_type AND fc_res_type_code = ''EXPENDITURE_TYPE''';
6699 END IF;
6700
6701 /*****************************************
6702 * If expenditure_category value is passed then append
6703 * it to the Where clause.
6704 *******************************************/
6705 IF p_expenditure_category IS NOT NULL AND p_expenditure_type IS NULL AND
6706 l_fmt_details.Fin_Cat_Enabled_Flag = 'Y'
6707 THEN
6708 l_fin_category_name := p_expenditure_category;
6709 l_fc_res_type_code := 'EXPENDITURE_CATEGORY';
6710 l_stmt := l_stmt || ' AND expenditure_category = :expenditure_category AND fc_res_type_code = ''EXPENDITURE_CATEGORY''';
6711 END IF;
6712
6713 IF p_expenditure_category IS NULL AND p_expenditure_type IS NULL AND
6714 l_fmt_details.Fin_Cat_Enabled_Flag = 'Y'
6715 THEN
6716 l_fin_category_name := NULL;
6717 l_fc_res_type_code := NULL;
6718 l_stmt := l_stmt || ' AND expenditure_category = :expenditure_category AND fc_res_type_code = ''EXPENDITURE_CATEGORY''';
6719
6720 END IF;
6721 /*****************************************
6722 * If project_role_id value is passed then append
6723 * it to the Where clause.
6724 *******************************************/
6725 /*****************************************
6726 * If named_role value is passed then append
6727 * it to the Where clause.
6728 *******************************************/
6729 --IF p_named_role IS NOT NULL THEN
6730 --l_stmt := l_stmt || ' AND team_role = :named_role';
6731 --END IF;
6732 IF p_project_role_id IS NOT NULL AND p_named_role IS NOT NULL AND
6733 l_fmt_details.Role_Enabled_Flag = 'Y'
6734 THEN
6735 l_project_role_id := p_project_role_id;
6736 l_named_role := p_named_role;
6737 l_stmt := l_stmt || ' AND project_role_id = :project_role_id AND team_role = :named_role';
6738 END IF;
6739
6740 /*****************************************
6741 * If person_type_code value is passed then append
6742 * it to the Where clause.
6743 *******************************************/
6744 IF -- p_person_type_code IS NOT NULL AND
6745 l_fmt_details.Res_Type_Enabled_Flag = 'Y' AND
6746 l_fmt_details.Res_Type_Code = 'PERSON_TYPE'
6747 THEN
6748 l_person_type_code := p_person_type_code;
6749 l_stmt := l_stmt || ' AND person_type_code = :person_type_code';
6750 END IF;
6751
6752
6753 /********************************************
6754 * If the List is Centrally Controlled
6755 * Then need to pass the object_type = 'RESOURCE_LIST'
6756 * and object_id = resource_list_id.
6757 * IF the List is not centrally controlled the
6758 * we need to pass the object_type = 'PROJECT'
6759 * and object_id = p_project_id.
6760 ********************************************/
6761 IF l_central_control = 'Y' THEN
6762 l_stmt := l_stmt || ' AND object_type = :object_type1';
6763 l_stmt := l_stmt || ' AND object_id = :resource_list_id';
6764 ELSE
6765 l_stmt := l_stmt || ' AND object_type = :object_type2';
6766 l_stmt := l_stmt || ' AND object_id = :project_id';
6767 END IF;
6768
6769 --l_stmt := l_stmt || ';';
6770
6771 -- dbms_output.put_line('l_stmt is :' || substr(l_stmt, 1, 240));
6772 -- dbms_output.put_line('l_stmt is :' || substr(l_stmt, 240, 500));
6773 -- dbms_output.put_line('p_res_format_id is :' || p_res_format_id);
6774 -- dbms_output.put_line('l_resource_list_id is :' || l_resource_list_id);
6775 -- dbms_output.put_line('p_project_role_id is :' || p_project_role_id);
6776 -- dbms_output.put_line('p_named_role is :' || p_named_role);
6777 -- dbms_output.put_line('p_project_id is :' || p_project_id);
6778 /*************************************
6779 * Parse the Select Stmt
6780 ************************************/
6781 dbms_sql.parse(l_cursor,l_stmt,dbms_sql.native);
6782
6783 /************************************
6784 * Bind the Variables
6785 ********************************/
6786 /******************************************
6787 * Bug - 3583651
6788 * Desc - Added code to Binnd the variables
6789 * resource_list_id, res_format_id
6790 *********************************************/
6791 --Binding the resource_list_id column
6792 dbms_sql.bind_variable(l_cursor,'resource_list_id', l_resource_list_id);
6793 --Binding the res_format_id column
6794 dbms_sql.bind_variable(l_cursor,'res_format_id', p_res_format_id);
6795
6796 --Binding the person_id column when p_person_id is not null
6797 IF -- p_person_id IS NOT NULL AND
6798 l_fmt_details.Res_Type_Enabled_Flag = 'Y' AND
6799 l_fmt_details.Res_Type_Code = 'NAMED_PERSON'
6800 THEN
6801 dbms_sql.bind_variable(l_cursor,'person_id', p_person_id);
6802 END IF;
6803 --Binding the job_id column when p_job_id is not null
6804 IF -- p_job_id IS NOT NULL AND
6805 l_fmt_details.Res_Type_Enabled_Flag = 'Y' AND
6806 l_fmt_details.Res_Type_Code = 'JOB'
6807 THEN
6808 -- dbms_output.put_line('p_job_id is :' || p_job_id);
6809 dbms_sql.bind_variable(l_cursor,'job_id', p_job_id);
6810 END IF;
6811 --Binding the organization_id column when p_organization_id is not null
6812 IF -- p_organization_id IS NOT NULL AND
6813 l_fmt_details.Orgn_Enabled_Flag = 'Y'
6814 THEN
6815 -- dbms_output.put_line('p_organization_id is :' || p_organization_id);
6816 dbms_sql.bind_variable(l_cursor,'organization_id', p_organization_id);
6817 END IF;
6818 --Binding the expenditure_type column when p_expenditure_type is not null
6819 IF p_expenditure_type IS NOT NULL AND
6820 l_fmt_details.Fin_Cat_Enabled_Flag = 'Y'
6821 THEN
6822 dbms_sql.bind_variable(l_cursor,'expenditure_type', p_expenditure_type);
6823 END IF;
6824 --Binding the expenditure_category column when
6825 --p_expenditure_category is not null
6826 IF p_expenditure_category IS NOT NULL AND p_expenditure_type IS NULL AND
6827 l_fmt_details.Fin_Cat_Enabled_Flag = 'Y'
6828 THEN
6829 dbms_sql.bind_variable(l_cursor,'expenditure_category',p_expenditure_category);
6830 END IF;
6831
6832 IF p_expenditure_category IS NULL AND p_expenditure_type IS NULL AND
6833 l_fmt_details.Fin_Cat_Enabled_Flag = 'Y'
6834 THEN
6835 dbms_sql.bind_variable(l_cursor,'expenditure_category',l_fin_category_name);
6836 END IF;
6837 --Binding the project_role_id column when p_project_role_id is not null
6838 --Binding the named_role column when p_named_role is not null
6839 IF p_project_role_id IS NOT NULL AND p_named_role IS NOT NULL AND
6840 l_fmt_details.Role_Enabled_Flag = 'Y'
6841 THEN
6842 dbms_sql.bind_variable(l_cursor,'project_role_id', p_project_role_id);
6843 dbms_sql.bind_variable(l_cursor,'named_role', p_named_role);
6844 END IF;
6845 --Binding the person_type_code column when p_person_type_code is not null
6846 IF -- p_person_type_code IS NOT NULL AND
6847 l_fmt_details.Res_Type_Enabled_Flag = 'Y' AND
6848 l_fmt_details.Res_Type_Code = 'PERSON_TYPE'
6849 THEN
6850 dbms_sql.bind_variable(l_cursor,'person_type_code', p_person_type_code);
6851 END IF;
6852 --Binding the object_type1 column when l_central_control equals Y
6853 IF l_central_control = 'Y' THEN
6854 dbms_sql.bind_variable(l_cursor,'object_type1', 'RESOURCE_LIST');
6855 END IF;
6856 --Binding the object_type2 and project_id
6857 -- column when l_central_control does not equal Y
6858 IF l_central_control <> 'Y' THEN
6859 dbms_sql.bind_variable(l_cursor,'object_type2', 'PROJECT');
6860 dbms_sql.bind_variable(l_cursor,'project_id', p_project_id);
6861 END IF;
6862
6863 --Define Output Variables
6864 --dbms_sql.define_column(l_cursor,1,l_resource_list_member_id,30);
6865 dbms_sql.define_column(l_cursor,1,l_resource_list_member_id);
6866
6867 l_rows := dbms_sql.execute(l_cursor);
6868
6869 /****************************
6870 * Loop Through the Records
6871 ****************************/
6872 /********************************************
6873 * If No Values are Found we are setting the l_exists
6874 * flag to be N. If the Value is N we need to do some
6875 * logic based on the centrally controlled flag.
6876 **********************************************/
6877 IF dbms_sql.fetch_rows(l_cursor) = 0 THEN
6878 l_exists := 'N';
6879 ELSE
6880 l_exists := 'Y';
6881 END IF;
6882 /**********************************************************
6883 * If the select returns some Value then assign it to the
6884 * l_resource_list_member_id.
6885 * ********************************************************/
6886 IF l_exists = 'Y' THEN
6887 -- dbms_output.put_line('l_exists is Y');
6888 dbms_sql.column_value(l_cursor,1,l_resource_list_member_id);
6889 dbms_sql.close_cursor(l_cursor);
6890 -- dbms_output.put_line('l_resource_list_member_id is :' || l_resource_list_member_id);
6891 --Return the l_resource_list_member_id
6892 --To the calling API
6893 RETURN l_resource_list_member_id;
6894 END IF;
6895
6896 /***********************************************************
6897 * If for the resource_list_ID passed we were not able
6898 * to derive the appropriate member based on the param
6899 * passed then we have 2 options
6900 * depending on the centrally_controlled flag
6901 * on the resource_list.
6902 *************************************************************/
6903
6904 /***********************************************************
6905 * If the Centrally Controlled flag = 'Y' Then we have to do the
6906 * following.
6907 * *********************************************************/
6908 IF l_exists = 'N' and l_central_control = 'Y' THEN
6909 --Delete the temp table.
6910 DELETE FROM pa_res_list_map_tmp1;
6911 DELETE FROM pa_res_list_map_tmp4;
6912 /***************************************************
6913 * Populate the temp table with the parameters passed in.
6914 * Then we need to call the mapping API, which
6915 * would read the values from the below table and will get
6916 * the best matching resource_list_member_id.
6917 * *****************************************************/
6918 -- dbms_output.put_line('l_fc_res_type_code IS : ' || l_fc_res_type_code);
6919 -- dbms_output.put_line('p_person_id IS : ' || p_person_id);
6920 -- dbms_output.put_line('p_job_id IS : ' || p_job_id);
6921 -- dbms_output.put_line('p_organization_id IS : ' || p_organization_id);
6922 -- dbms_output.put_line('p_expenditure_type IS : ' || p_expenditure_type);
6923 -- dbms_output.put_line('p_expenditure_category IS : ' || p_expenditure_category);
6924 -- dbms_output.put_line('p_project_role_id IS : ' || p_project_role_id);
6925 -- dbms_output.put_line('p_person_type_code IS : ' || p_person_type_code);
6926
6927 -- populate fc_res_type_code for mapping.
6928 IF p_expenditure_type IS NOT NULL THEN
6929 l_fc_res_type_code := 'EXPENDITURE_TYPE';
6930 ELSIF p_expenditure_category IS NOT NULL THEN
6931 l_fc_res_type_code := 'EXPENDITURE_CATEGORY';
6932 END IF;
6933
6934 --dbms_output.put_line('l_fc_res_type_code IS : ' || l_fc_res_type_code);
6935
6936 INSERT INTO pa_res_list_map_tmp1
6937 (person_id,
6938 job_id,
6939 organization_id,
6940 expenditure_type,
6941 expenditure_category,
6942 fc_res_type_code,
6943 project_role_id,
6944 resource_class_id,
6945 resource_class_code,
6946 res_format_id,
6947 person_type_code,
6948 named_role)
6949 VALUES
6950 (p_person_id,
6951 p_job_id,
6952 p_organization_id,
6953 p_expenditure_type,
6954 p_expenditure_category,
6955 l_fc_res_type_code,
6956 p_project_role_id,
6957 1,
6958 'PEOPLE',
6959 p_res_format_id,
6960 p_person_type_code,
6961 p_named_role);
6962 /**********************************************
6963 * Call to the API passing the resource_list_ID
6964 * This API would read the values from the temp
6965 * table pa_res_list_map_tmp1 and will take in
6966 * the resource_list_id and get the best matching
6967 * resource_list_member_id and insert it into the
6968 * table pa_res_list_map_tmp4.
6969 **************************************************/
6970 -- dbms_output.put_line('Pa_Resource_Mapping.map_resource_list');
6971 -- dbms_output.put_line('l_resource_list_id IS : ' || l_resource_list_id);
6972 -- dbms_output.put_line('p_project_id IS : ' || p_project_id);
6973 Pa_Resource_Mapping.map_resource_list
6974 (p_resource_list_id => l_resource_list_id,
6975 p_project_id => p_project_id,
6976 x_return_status => l_return_status,
6977 x_msg_count => l_msg_count,
6978 x_msg_data => l_error_msg_data);
6979
6980 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6981 l_resource_list_member_id := NULL;
6982 RETURN l_resource_list_member_id;
6983 END IF;
6984
6985 /***********************************************
6986 * Get the resource_list_member_id value from
6987 * the pa_res_list_map_tmp4 table.
6988 ************************************************/
6989 BEGIN
6990 SELECT RESOURCE_LIST_MEMBER_ID
6991 INTO l_res_list_member_id
6992 FROM pa_res_list_map_tmp4
6993 WHERE rownum = 1;
6994 -- dbms_output.put_line('MAPPING l_res_list_member_id IS : ' || l_res_list_member_id);
6995 EXCEPTION
6996 WHEN OTHERS THEN
6997 l_resource_list_member_id := NULL;
6998 RETURN l_resource_list_member_id;
6999 END;
7000 /*******************************************
7001 * If the resource_list_member_id returned equals
7002 * 'PEOPLE' then we dont need to return it.
7003 * so just return Null. Else return the appr
7004 * value.
7005 *********************************************/
7006 IF l_res_list_member_id = 'PEOPLE' THEN
7007 l_resource_list_member_id := NULL;
7008 ELSE
7009 l_resource_list_member_id := l_res_list_member_id;
7010 END IF;
7011
7012 RETURN to_number(l_resource_list_member_id);
7013
7014 END IF;
7015 /*************************************************
7016 * If the Resource_list is not Centrally Controlled
7017 * then do the following
7018 **********************************************/
7019 IF l_exists = 'N' and l_central_control = 'N' THEN
7020 --dbms_output.put_line(' START *** ');
7021 /*************************************************
7022 * Call to Pa_Planning_Resource_Pvt.Create_Planning_Resource
7023 * which would create the planning resource member
7024 * for the project_id,res_format_id and resource_list_id passed
7025 * using the information passed.
7026 *****************************************************/
7027 BEGIN
7028 SELECT resource_class_id
7029 INTO l_resource_class_id
7030 FROM pa_res_formats_b
7031 WHERE res_format_id = p_res_format_id;
7032 EXCEPTION
7033 WHEN OTHERS THEN
7034 l_resource_list_member_id := NULL;
7035 END;
7036
7037 /* Validate first to ensure that all the required segments
7038 * exist before calling Create_Planning_Resource because if the
7039 * resource cannot be created just return null without any error.
7040 * Create_Planning_Resource puts any error it gets on the stack, which
7041 * then gets displayed to the user. We want to prevent that.
7042 * This is for bug fix 3818238 */
7043
7044 l_valid := 'Y';
7045 IF (l_valid = 'Y' AND
7046 l_fmt_details.Supplier_Enabled_Flag = 'Y') THEN
7047 l_valid := 'N';
7048 END IF;
7049
7050 IF (l_valid = 'Y' AND
7051 l_fmt_details.Incurred_By_Enabled_Flag = 'Y') THEN
7052 l_valid := 'N';
7053 END IF;
7054
7055 IF (l_valid = 'Y' AND
7056 l_fmt_details.Fin_Cat_Enabled_Flag = 'Y') THEN
7057 IF (l_fin_category_name IS NOT NULL AND
7058 l_fc_res_type_code IS NOT NULL) THEN
7059 l_valid := 'Y';
7060 ELSE
7061 l_valid := 'N';
7062 END IF;
7063 END IF;
7064
7065 IF (l_valid = 'Y' AND
7066 l_fmt_details.Role_Enabled_Flag = 'Y') THEN
7067 IF (l_project_role_id IS NOT NULL AND
7068 l_named_role IS NOT NULL) THEN
7069 l_valid := 'Y';
7070 ELSE
7071 l_valid := 'N';
7072 END IF;
7073 END IF;
7074
7075 IF (l_valid = 'Y' AND
7076 l_fmt_details.Orgn_Enabled_Flag = 'Y') THEN
7077 IF (l_organization_id IS NOT NULL) THEN
7078 l_valid := 'Y';
7079 ELSE
7080 l_valid := 'N';
7081 END IF;
7082 END IF;
7083
7084 IF (l_valid = 'Y' AND
7085 l_fmt_details.Res_Type_Enabled_Flag = 'Y') THEN
7086 IF ((l_fmt_details.Res_Type_Code = 'NAMED_PERSON' AND
7087 l_person_id IS NOT NULL) OR
7088 (l_fmt_details.Res_Type_Code = 'PERSON_TYPE' AND
7089 l_person_type_code IS NOT NULL) OR
7090 (l_fmt_details.Res_Type_Code = 'JOB' AND l_job_id IS NOT NULL))
7091 THEN
7092 l_valid := 'Y';
7093 ELSE
7094 l_valid := 'N';
7095 END IF;
7096 END IF;
7097
7098 IF (l_valid = 'Y' AND l_fmt_details.Res_Type_Code = 'JOB') THEN
7099 -- Check that list has job group and that job is in job group
7100 -- Added for bug 4025261
7101 BEGIN
7102 SELECT job_group_id
7103 INTO l_job_group_id
7104 FROM pa_resource_lists_all_bg
7105 WHERE resource_list_id = l_resource_list_id;
7106
7107 SELECT 'Y'
7108 INTO l_valid_job
7109 FROM per_jobs
7110 WHERE job_id = l_job_id
7111 AND job_group_id = l_job_group_id;
7112
7113 EXCEPTION WHEN NO_DATA_FOUND THEN
7114 l_valid := 'N';
7115 END;
7116
7117 END IF;
7118
7119 -- dbms_output.put_line('l_valid IS ' || l_valid);
7120 IF l_valid = 'Y' THEN
7121 -- hr_utility.trace_on(null, 'RMJOB');
7122 -- hr_utility.trace('************* START **************');
7123 -- hr_utility.trace('Call Pa_Planning_Resource_Pvt.Create_Planning_Resource');
7124 --dbms_output.put_line('Pa_Planning_Resource_Pvt.Create_Planning_Resource');
7125 Pa_Planning_Resource_Pvt.Create_Planning_Resource
7126 (p_resource_list_id => l_resource_list_id,
7127 p_res_format_id => p_res_format_id,
7128 p_resource_class_id => l_resource_class_id,
7129 p_project_id => p_project_id,
7130 p_person_id => l_person_id,
7131 p_job_id => l_job_id,
7132 p_organization_id => l_organization_id,
7133 p_project_role_id => l_project_role_id,
7134 p_person_type_code => l_person_type_code,
7135 p_team_role => l_named_role,
7136 p_fin_category_name => l_fin_category_name,
7137 p_fc_res_type_code => l_fc_res_type_code,
7138 x_resource_list_member_id => l_resource_list_member_id,
7139 x_record_version_number => l_record_version_number,
7140 x_return_status => l_return_status,
7141 x_msg_count => l_msg_count,
7142 x_error_msg_data => l_error_msg_data);
7143
7144 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7145 l_resource_list_member_id := NULL;
7146 END IF;
7147 ELSE
7148 l_resource_list_member_id := NULL;
7149 END IF;
7150 --Return the newly created resource_list_member_id.
7151 RETURN l_resource_list_member_id;
7152 END IF;
7153
7154 END Derive_Resource_List_Member;
7155 /***************************************/
7156 /*********************************************************
7157 * Procedure : Get_Res_Format_For_Team_Role
7158 * Description : This API is used to return back the correct
7159 * resource format ID to be used for Assignments
7160 * and Requirements.
7161 * The calling API would pass a resource_list_id
7162 * This API would then get all the formats
7163 * associated with the resource_list passed
7164 * from the pa_plan_rl_formats table which do not
7165 * have res_type_code
7166 * of Named_person,Bom_Labor,Resource_Class(for Req)
7167 * of Bom_Labor,Resource_Class(for asgmt)
7168 * - It then gets the format which has the highest
7169 * precedence from the list of format ID's.
7170 *
7171 * As per bug 6014706 res_type_code can be of type Resource_Class
7172 ***************************************************************/
7173 Procedure Get_Res_Format_For_Team_Role
7174 (p_resource_list_id IN NUMBER,
7175 x_asgmt_res_format_id OUT NOCOPY NUMBER,
7176 x_req_res_format_id OUT NOCOPY NUMBER,
7177 x_return_status OUT NOCOPY Varchar2)
7178
7179 IS
7180 /****************************************
7181 * Cursor c_get_asgmt_res_formats to get the
7182 * res_formats for assignments.
7183 *****************************************/
7184 Cursor c_get_asgmt_res_formats
7185 IS
7186 select a.res_format_id
7187 from pa_res_formats_b a,pa_res_types_b b, pa_plan_rl_formats c
7188 where a.resource_class_id = 1
7189 and a.res_type_id = b.res_type_id (+)
7190 and c.res_format_id = a.res_format_id
7191 and c.resource_list_id = p_resource_list_id
7192 and nvl(b.res_type_code, 'DUMMY') <> 'BOM_LABOR';
7193 /*For bug 6014706 : Removed RESOURCE_CLASS
7194 NOT IN ('BOM_LABOR','RESOURCE_CLASS');*/
7195
7196 /****************************************
7197 * Cursor c_get_asgmt_res_formats to get the
7198 * res_formats for requirement.
7199 *****************************************/
7200 Cursor c_get_req_res_formats
7201 IS
7202 select a.res_format_id
7203 from pa_res_formats_b a,pa_res_types_b b, pa_plan_rl_formats c
7204 where a.resource_class_id = 1
7205 and a.res_type_id = b.res_type_id (+)
7206 and c.res_format_id = a.res_format_id
7207 and c.resource_list_id = p_resource_list_id
7208 and nvl(b.res_type_code, 'DUMMY') NOT IN
7209 ('NAMED_PERSON','BOM_LABOR','PERSON_TYPE');
7210 -- Added person_type for Bug 4350963
7211 /*For bug 6014706 : Removed RESOURCE_CLASS
7212 ('NAMED_PERSON','BOM_LABOR','RESOURCE_CLASS', 'PERSON_TYPE');
7213 */
7214 l_return_status Varchar2(30);
7215 l_msg_code Varchar2(30);
7216 l_res_format_id Number;
7217 l_precedence Number := 0;
7218 l_precedence_temp Number := 0;
7219 l_final_asgmt_format_id Number;
7220 l_final_req_format_id Number;
7221 BEGIN
7222 x_return_status := FND_API.G_RET_STS_SUCCESS;
7223 --Using these Dummy Values for precedence
7224 --for now. Later when Vijay passes the API remove this.
7225 /************************************************
7226 * For Assignments do the following
7227 * ***********************************************/
7228 IF pa_task_assignment_utils.is_uncategorized_res_list(p_resource_list_id => p_resource_list_id) = 'Y'
7229 THEN --Added IF-ELSE for bug 5962655
7230 x_asgmt_res_format_id := Null;
7231 x_req_res_format_id := Null;
7232 ELSE
7233 OPEN c_get_asgmt_res_formats;
7234 l_precedence := 0;
7235 l_precedence_temp := 1000;
7236 LOOP
7237 FETCH c_get_asgmt_res_formats INTO l_res_format_id;
7238 IF c_get_asgmt_res_formats%ROWCOUNT = 0 THEN
7239 x_asgmt_res_format_id := Null;
7240 END IF;
7241 EXIT WHEN c_get_asgmt_res_formats%NOTFOUND;
7242 BEGIN
7243 pa_resource_mapping.get_format_precedence (
7244 p_resource_class_id => 1,
7245 p_res_format_id => l_res_format_id ,
7246 x_format_precedence => l_precedence,
7247 x_return_status => l_return_status,
7248 x_msg_code => l_msg_code );
7249
7250 IF l_precedence IS NULL THEN
7251 l_final_asgmt_format_id := Null;
7252 END IF;
7253 EXCEPTION
7254 WHEN OTHERS THEN
7255 x_asgmt_res_format_id := Null;
7256 END;
7257
7258 -- The lower the precedence the more granular the format, so
7259 -- the format with the lowest precedence is best.
7260
7261 IF l_precedence_temp >= l_precedence THEN
7262 l_precedence_temp := l_precedence;
7263 l_final_asgmt_format_id := l_res_format_id;
7264 END IF;
7265
7266 END LOOP;
7267 CLOSE c_get_asgmt_res_formats;
7268
7269
7270 /************************************************
7271 * For Requirements do the following
7272 * ***********************************************/
7273 OPEN c_get_req_res_formats;
7274 l_precedence := 0;
7275 l_precedence_temp := 1000;
7276 LOOP
7277 FETCH c_get_req_res_formats INTO l_res_format_id;
7278 IF c_get_req_res_formats%ROWCOUNT = 0 THEN
7279 x_req_res_format_id := Null;
7280 END IF;
7281 EXIT WHEN c_get_req_res_formats%NOTFOUND;
7282 BEGIN
7283 pa_resource_mapping.get_format_precedence (
7284 p_resource_class_id => 1,
7285 p_res_format_id => l_res_format_id ,
7286 x_format_precedence => l_precedence,
7287 x_return_status => l_return_status,
7288 x_msg_code => l_msg_code );
7289 IF l_precedence IS NULL THEN
7290 l_final_req_format_id := Null;
7291 END IF;
7292 EXCEPTION
7293 WHEN OTHERS THEN
7294 x_req_res_format_id := Null;
7295 END;
7296
7297 -- The lower the precedence the more granular the format, so
7298 -- the format with the lowest precedence is best.
7299
7300 IF l_precedence_temp >= l_precedence THEN
7301 l_precedence_temp := l_precedence;
7302 l_final_req_format_id := l_res_format_id;
7303 END IF;
7304
7305 END LOOP;
7306 CLOSE c_get_req_res_formats;
7307
7308 /***************************************************
7309 * Return back the final Assignment and Requirement
7310 * format ID's
7311 **************************************************/
7312 x_asgmt_res_format_id := l_final_asgmt_format_id;
7313 x_req_res_format_id := l_final_req_format_id;
7314
7315 END IF; --Added for bug 6014706
7316 END Get_Res_Format_For_Team_Role;
7317
7318 /* ----------------------------------------------------------------
7319 * API for populating a resource list into the new TL tables. This API
7320 * is called by the resource list upgrade concurrent program.
7321 * ----------------------------------------------------------------*/
7322 PROCEDURE Populate_list_into_tl(
7323 p_resource_list_id IN NUMBER,
7324 x_return_status OUT NOCOPY VARCHAR2,
7325 x_msg_count OUT NOCOPY VARCHAR2,
7326 x_msg_data OUT NOCOPY VARCHAR2 ) IS
7327
7328 BEGIN
7329 x_return_status := FND_API.G_RET_STS_SUCCESS;
7330 x_msg_count := 0;
7331 x_msg_data := NULL;
7332
7333 Insert into pa_resource_lists_tl (
7334 LAST_UPDATE_LOGIN,
7335 CREATION_DATE,
7336 CREATED_BY,
7337 LAST_UPDATE_DATE,
7338 LAST_UPDATED_BY,
7339 RESOURCE_LIST_ID,
7340 NAME,
7341 DESCRIPTION,
7342 LANGUAGE,
7343 SOURCE_LANG
7344 ) select
7345 fnd_global.login_id,
7346 sysdate,
7347 fnd_global.user_id,
7348 sysdate,
7349 fnd_global.user_id,
7350 lst.resource_list_id,
7351 lst.name,
7352 lst.description,
7353 l.language_code,
7354 userenv('LANG')
7355 from pa_resource_lists_all_bg lst,
7356 fnd_languages l
7357 where l.Installed_Flag in ('I', 'B')
7358 and lst.resource_list_id = p_resource_list_id
7359 and not exists (select 'Y'
7360 from pa_resource_lists_tl T
7361 where t.resource_list_id = lst.resource_list_id);
7362 EXCEPTION
7363 WHEN OTHERS THEN
7364 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7365 x_msg_count := 1;
7366 x_msg_data := SQLERRM;
7367 RETURN;
7368 END;
7369
7370 /*******************************************************************
7371 * Procedure : Delete_proj_specific_resource
7372 * Desc : This API is used to delete the project specific resources
7373 * once the project is deleted.
7374 *******************************************************************/
7375 PROCEDURE Delete_Proj_Specific_Resource(
7376 p_project_id IN NUMBER,
7377 x_return_status OUT NOCOPY VARCHAR2,
7378 x_msg_count OUT NOCOPY NUMBER)
7379 IS
7380 l_res_list_id pa_resource_lists_all_bg.resource_list_id%TYPE;
7381
7382 --For bug 4039707
7383 CURSOR get_resource_lists IS
7384 SELECT resource_list_id FROM pa_resource_lists_all_bg
7385 WHERE migration_code is not null;
7386
7387 BEGIN
7388 x_return_status := FND_API.G_RET_STS_SUCCESS;
7389 x_msg_count := 0;
7390
7391 OPEN get_Resource_lists;
7392
7393 LOOP
7394 FETCH get_resource_lists INTO l_res_list_id;
7395 EXIT WHEN get_resource_lists%NOTFOUND;
7396
7397 DELETE FROM pa_resource_list_members
7398 WHERE resource_list_id = l_res_list_id
7399 AND object_type = 'PROJECT'
7400 AND object_id = p_project_id;
7401 END LOOP;
7402
7403 CLOSE get_resource_lists;
7404
7405 EXCEPTION
7406 WHEN OTHERS THEN
7407 FND_MSG_PUB.add_exc_msg( p_pkg_name =>
7408 'Pa_Planning_Resource_Utils.Delete_proj_specific_resource'
7409 ,p_procedure_name => PA_DEBUG.G_Err_Stack);
7410 x_msg_count := x_msg_count+1;
7411 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7412 END Delete_Proj_Specific_Resource;
7413
7414 FUNCTION Get_class_member_id(p_project_id IN NUMBER,
7415 p_resource_list_id IN NUMBER,
7416 p_resource_class_code IN VARCHAR2) return NUMBER
7417 IS
7418
7419 l_resource_list_member_id NUMBER;
7420 l_central_control VARCHAR2(1);
7421
7422 BEGIN
7423 SELECT nvl(control_flag, 'N')
7424 INTO l_central_control
7425 FROM pa_resource_lists_all_bg
7426 WHERE resource_list_id = p_resource_list_id;
7427
7428 IF l_central_control = 'Y' THEN
7429 SELECT resource_list_member_id
7430 INTO l_resource_list_member_id
7431 FROM pa_resource_list_members
7432 WHERE resource_list_id = p_resource_list_id
7433 AND resource_class_flag = 'Y'
7434 AND resource_class_code = p_resource_class_code;
7435 ELSE
7436 SELECT resource_list_member_id
7437 INTO l_resource_list_member_id
7438 FROM pa_resource_list_members
7439 WHERE resource_list_id = p_resource_list_id
7440 AND resource_class_flag = 'Y'
7441 AND resource_class_code = p_resource_class_code
7442 AND object_type = 'PROJECT'
7443 AND object_id = p_project_id;
7444 END IF;
7445
7446 RETURN l_resource_list_member_id;
7447
7448 EXCEPTION WHEN OTHERS THEN
7449 l_resource_list_member_id := NULL;
7450 RETURN l_resource_list_member_id;
7451
7452 END Get_class_member_id;
7453
7454 /*****************************************************************
7455 * Function : get_rate_based_flag
7456 * Given a resource list member, this function returns a flag
7457 * to indicate whether the list member is rate based or not.
7458 * ************************************************************/
7459 FUNCTION Get_rate_based_flag(p_resource_list_member_id IN NUMBER)
7460 return VARCHAR2 IS
7461
7462 CURSOR get_res_details(p_resource_list_member_id IN NUMBER) IS
7463 SELECT resource_class_code, inventory_item_id, expenditure_type
7464 FROM pa_resource_list_members
7465 WHERE resource_list_member_id = p_resource_list_member_id;
7466
7467 l_rate_based_flag VARCHAR2(1) := 'N';
7468 l_res_details get_res_details%ROWTYPE;
7469
7470 BEGIN
7471 OPEN get_res_details(p_resource_list_member_id => p_resource_list_member_id);
7472 FETCH get_res_details into l_res_details;
7473 IF get_res_details%NOTFOUND THEN
7474 l_rate_based_flag := NULL;
7475 RETURN l_rate_based_flag;
7476 END IF;
7477 CLOSE get_res_details;
7478
7479 IF l_res_details.resource_class_code in ('PEOPLE','EQUIPMENT') THEN
7480 l_rate_based_flag := 'Y';
7481 ELSIF (l_res_details.resource_class_code = 'MATERIAL_ITEMS') AND
7482 (l_res_details.inventory_item_id IS NOT NULL) THEN
7483
7484 SELECT 'Y'
7485 INTO l_rate_based_flag
7486 FROM dual
7487 WHERE NOT EXISTS (select 'Y'
7488 from mtl_system_items_b item,
7489 mtl_units_of_measure meas
7490 where item.inventory_item_id =
7491 l_res_details.inventory_item_id
7492 and item.primary_uom_code = meas.uom_code
7493 and meas.uom_class = 'Currency');
7494
7495 ELSIF (l_res_details.resource_class_code in ('MATERIAL_ITEMS',
7496 'FINANCIAL_ELEMENTS')) AND
7497 (l_res_details.expenditure_type IS NOT NULL) AND
7498 (l_res_details.inventory_item_id IS NULL) THEN
7499
7500 SELECT c.cost_rate_flag
7501 INTO l_rate_based_flag
7502 FROM pa_expenditure_types c
7503 WHERE c.expenditure_type = l_res_details.expenditure_type;
7504 END IF;
7505
7506 RETURN l_rate_based_flag;
7507
7508 END Get_rate_based_flag;
7509
7510
7511 /*****************************************************************
7512 * Function : check_enable_allowed
7513 * Given a disabled resource list member, this function checks to see if
7514 * enabling it is allowed - meaning that it won't result in a duplicate
7515 * resource list member. Hence it checks to see if there are any enabled
7516 * list members with the same format and attributes. Returns Y if the
7517 * given list member is unique; and N if not.
7518 * This function called from both the planning resource lists page
7519 * and the resource list form when a list member is enabled. It is only
7520 * called for migrated resources to deal with the specific problem of
7521 * migrating list members which have financial category for both
7522 * parent and child, and the child cannot be guaranteed to be unique,
7523 * so it is migrated but disabled. Look at bugs 3682103 and 3710822 for
7524 * more detail and background.
7525 * ************************************************************/
7526 FUNCTION check_enable_allowed(p_resource_list_member_id IN NUMBER)
7527 RETURN VARCHAR2
7528 IS
7529 l_res_format_id NUMBER;
7530 l_res_list_id NUMBER;
7531 l_allowed VARCHAR2(1) := 'Y';
7532 l_enabled_flag VARCHAR2(1) := 'Y';
7533 l_expenditure_type VARCHAR2(100);
7534 l_revenue_category VARCHAR2(100);
7535 l_expenditure_category VARCHAR2(100);
7536 l_event_type VARCHAR2(100);
7537 l_object_type VARCHAR2(100);
7538 l_object_id NUMBER;
7539
7540 BEGIN
7541 SELECT res_format_id, resource_list_id, expenditure_type,
7542 expenditure_category, revenue_category, event_type, object_type,
7543 object_id, enabled_flag
7544 INTO l_res_format_id, l_res_list_id, l_expenditure_type,
7545 l_expenditure_category, l_revenue_category, l_event_type, l_object_type,
7546 l_object_id, l_enabled_flag
7547 FROM pa_resource_list_members
7548 WHERE resource_list_member_id = p_resource_list_member_id;
7549
7550 l_allowed := 'Y';
7551 IF l_res_format_id in (29, 73) AND (l_enabled_flag = 'N') THEN
7552
7553 BEGIN
7554 SELECT 'N'
7555 INTO l_allowed
7556 FROM pa_resource_list_members
7557 WHERE resource_list_id = l_res_list_id
7558 AND res_format_id = l_res_format_id
7559 AND enabled_flag = 'Y'
7560 AND resource_list_member_id <> p_resource_list_member_id
7561 AND object_type = l_object_type
7562 AND object_id = l_object_id
7563 AND nvl(expenditure_type, 'DUMMY') = nvl(l_expenditure_type, 'DUMMY')
7564 AND nvl(expenditure_category, 'DUMMY') =
7565 nvl(l_expenditure_category,'DUMMY')
7566 AND nvl(revenue_category, 'DUMMY') = nvl(l_revenue_category, 'DUMMY')
7567 AND nvl(event_type, 'DUMMY') = nvl(l_event_type, 'DUMMY');
7568
7569 EXCEPTION WHEN NO_DATA_FOUND THEN
7570 l_allowed := 'Y';
7571 END;
7572
7573 END IF;
7574
7575 RETURN l_allowed;
7576
7577 EXCEPTION WHEN OTHERS THEN
7578 l_allowed := 'N';
7579 RETURN l_allowed;
7580
7581 END check_enable_allowed;
7582
7583 /*****************************************************************
7584 * Procedure : check_list_member_on_list
7585 * Given a resource list member and a resource list, this procedure checks
7586 * to see if the list member is on the list (looking at the project specific
7587 * case as well) and returns an error message if it isn't.
7588 * If p_chk_enabled is passed in as 'Y', an additional check is done
7589 * to see whether the list member is enabled or not.
7590 * Added parameters p_alias and x_resource_list_member_id to do
7591 * name to ID conversion on alias and derive a list member ID.
7592 * ************************************************************/
7593 PROCEDURE check_list_member_on_list(
7594 p_resource_list_id IN NUMBER,
7595 p_resource_list_member_id IN NUMBER,
7596 p_project_id IN NUMBER,
7597 p_chk_enabled IN VARCHAR2 DEFAULT 'N',
7598 p_alias IN VARCHAR2 DEFAULT NULL,
7599 x_resource_list_member_id OUT NOCOPY NUMBER,
7600 x_valid_member_flag OUT NOCOPY VARCHAR2,
7601 x_return_status OUT NOCOPY VARCHAR2,
7602 x_msg_count OUT NOCOPY VARCHAR2,
7603 x_msg_data OUT NOCOPY VARCHAR2) IS
7604
7605
7606 l_central_control VARCHAR2(1) := 'Y';
7607 l_object_type VARCHAR2(30) := NULL;
7608 l_object_id NUMBER;
7609
7610 BEGIN
7611
7612 x_valid_member_flag := NULL;
7613 x_return_status := FND_API.G_RET_STS_SUCCESS;
7614 x_msg_data := NULL;
7615 x_msg_count := 0;
7616
7617 SELECT control_flag
7618 INTO l_central_control
7619 FROM pa_resource_lists_all_bg
7620 WHERE resource_list_id = p_resource_list_id;
7621
7622 IF l_central_control = 'N' THEN
7623 l_object_type := 'PROJECT';
7624 l_object_id := p_project_id;
7625 ELSE
7626 l_object_type := 'RESOURCE_LIST';
7627 l_object_id := p_resource_list_id;
7628 END IF;
7629
7630 BEGIN
7631 IF p_alias IS NOT NULL and p_resource_list_member_id IS NULL THEN
7632 SELECT resource_list_member_id
7633 INTO x_resource_list_member_id
7634 FROM pa_resource_list_members
7635 WHERE alias = p_alias
7636 AND resource_list_id = p_resource_list_id
7637 AND object_type = l_object_type
7638 AND object_id = l_object_id;
7639
7640 ELSIF p_resource_list_member_id IS NOT NULL THEN
7641 x_resource_list_member_id := p_resource_list_member_id;
7642
7643 ELSIF p_alias IS NULL and p_resource_list_member_id IS NULL THEN
7644 x_valid_member_flag := 'N';
7645 x_resource_list_member_id := NULL;
7646 x_return_status := FND_API.G_RET_STS_ERROR;
7647 x_msg_data := 'PA_MEMBER_NOT_ON_LIST';
7648 x_msg_count := 1;
7649 --Modified below for Bug fix 7291217
7650 Pa_Utils.Add_Message(P_App_Short_Name => 'PA'
7651 ,P_Msg_Name => 'PA_MEMBER_NOT_ON_LIST'
7652 ,P_TOKEN1 => 'RESOURCE_LIST_MEMBER'
7653 ,P_VALUE1 => p_alias
7654 ,P_TOKEN2 => 'RESOURCE_LIST'
7655 ,P_VALUE2 => PA_TASK_UTILS.GET_RESOURCE_LIST_NAME(p_resource_list_id));
7656 RETURN;
7657 END IF;
7658
7659 SELECT 'Y'
7660 INTO x_valid_member_flag
7661 FROM pa_resource_list_members
7662 WHERE resource_list_member_id = x_resource_list_member_id
7663 AND resource_list_id = p_resource_list_id
7664 AND object_type = l_object_type
7665 AND object_id = l_object_id;
7666
7667 EXCEPTION WHEN NO_DATA_FOUND THEN
7668 x_valid_member_flag := 'N';
7669 x_resource_list_member_id := NULL;
7670 x_return_status := FND_API.G_RET_STS_ERROR;
7671 x_msg_data := 'PA_MEMBER_NOT_ON_LIST';
7672 x_msg_count := 1;
7673 --Modified below for Bug fix 7291217
7674 Pa_Utils.Add_Message(P_App_Short_Name => 'PA'
7675 ,P_Msg_Name => 'PA_MEMBER_NOT_ON_LIST'
7676 ,P_TOKEN1 => 'RESOURCE_LIST_MEMBER'
7677 ,P_VALUE1 => p_alias
7678 ,P_TOKEN2 => 'RESOURCE_LIST'
7679 ,P_VALUE2 => PA_TASK_UTILS.GET_RESOURCE_LIST_NAME(p_resource_list_id));
7680 RETURN;
7681 END;
7682
7683 IF p_chk_enabled = 'Y' THEN
7684 BEGIN
7685 SELECT 'Y'
7686 INTO x_valid_member_flag
7687 FROM pa_resource_list_members
7688 WHERE resource_list_member_id = x_resource_list_member_id
7689 AND enabled_flag = 'Y';
7690
7691 EXCEPTION WHEN NO_DATA_FOUND THEN
7692 x_valid_member_flag := 'N';
7693 x_resource_list_member_id := NULL;
7694 x_return_status := FND_API.G_RET_STS_ERROR;
7695 x_msg_data := 'PA_MEMBER_NOT_ENABLED';
7696 x_msg_count := 1;
7697 Pa_Utils.Add_Message(P_App_Short_Name => 'PA',
7698 P_Msg_Name => 'PA_MEMBER_NOT_ENABLED');
7699 RETURN;
7700 END;
7701 END IF;
7702
7703 END check_list_member_on_list;
7704
7705 /********************************************************************
7706 * Procedure : default_other_elements
7707 * This procedure derives other segments for a planning resource, based
7708 * on the resource format, if it is possible to derive anything. For
7709 * example, if the format provided is Named Person - Organization, and
7710 * the person ID or name is specified, the person's HR Organization is derived
7711 * and passed back as X_organization_id and X_organization_name. Please
7712 * see the functional design for all the values that can be derived.
7713 * Currently, the only formats that can allow derivation are:
7714 * BOM Equipment - Organization - 48
7715 * BOM Labor - Organization - 10
7716 * Named Person - Financial Category - Organization (get Org) - 3
7717 * Named Person - Organization - 5
7718 * Projects Non-Labor Resource - Financial Category - Organization (get Fin Cat) - 43
7719 * *****************************************************************/
7720 PROCEDURE default_other_elements (
7721 P_res_format_id IN NUMBER,
7722 P_person_id IN NUMBER DEFAULT NULL,
7723 P_person_name IN VARCHAR2 DEFAULT NULL,
7724 p_bom_resource_id IN NUMBER DEFAULT NULL,
7725 p_bom_resource_name IN VARCHAR2 DEFAULT NULL,
7726 p_non_labor_resource IN VARCHAR2 DEFAULT NULL,
7727 X_organization_id OUT NOCOPY NUMBER,
7728 x_organization_name OUT NOCOPY VARCHAR2,
7729 X_expenditure_type OUT NOCOPY VARCHAR2,
7730 X_msg_data OUT NOCOPY VARCHAR2,
7731 X_msg_count OUT NOCOPY NUMBER,
7732 X_return_status OUT NOCOPY VARCHAR2) IS
7733
7734 CURSOR get_fmt_details (p_res_format_id IN NUMBER) IS
7735 SELECT f.Res_Type_Enabled_Flag,
7736 f.Orgn_Enabled_Flag,
7737 f.Fin_Cat_Enabled_Flag,
7738 f.Role_Enabled_Flag,
7739 f.Res_Type_Id,
7740 t.Res_Type_Code
7741 FROM Pa_Res_Formats_B f,
7742 Pa_Res_Types_B t
7743 WHERE f.Res_Type_Id = t.Res_Type_Id(+)
7744 AND f.Res_Format_Id = p_res_format_id;
7745
7746 l_fmt_details get_fmt_details%RowType;
7747 l_person_id NUMBER;
7748 l_bom_resource_id NUMBER;
7749
7750 BEGIN
7751
7752 x_return_status := FND_API.G_RET_STS_SUCCESS;
7753 x_msg_data := NULL;
7754 x_msg_count := 0;
7755 X_organization_id := NULL;
7756 X_organization_name := NULL;
7757 X_expenditure_type := NULL;
7758
7759 Open get_fmt_details(p_res_format_id => p_res_format_id);
7760 Fetch get_fmt_details into l_fmt_details;
7761 Close get_fmt_details;
7762
7763 IF l_fmt_details.Res_Type_Enabled_Flag = 'Y' AND
7764 (l_fmt_details.Res_Type_Code = 'NAMED_PERSON' AND
7765 (P_person_id is not NULL OR P_person_name is NOT NULL)) THEN
7766 IF l_fmt_details.Orgn_Enabled_Flag = 'Y' THEN
7767 -- Do name to ID conversion on person
7768 pa_planning_resource_utils.Check_PersonName_or_ID(
7769 p_person_id => P_person_id,
7770 p_person_name => P_person_name,
7771 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
7772 x_person_id => l_person_id,
7773 x_return_status => x_return_status,
7774 x_error_msg_code => X_msg_data);
7775
7776 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7777 PA_UTILS.Add_Message ('PA', X_msg_data, 'PLAN_RES',
7778 Pa_Planning_Resource_Pvt.g_token);
7779 Return;
7780 END IF;
7781
7782 -- Get the person's HR Org and pass back
7783 BEGIN
7784 SELECT a.organization_id, orgvl.name
7785 INTO X_organization_id, X_organization_name
7786 FROM per_assignments_x a,
7787 pa_all_organizations org,
7788 hr_all_organization_units_vl orgvl
7789 WHERE a.person_id = l_person_id
7790 AND a.organization_id = orgvl.organization_id
7791 AND a.organization_id = org.organization_id
7792 AND org.inactive_date is null
7793 AND org.pa_org_use_type = 'EXPENDITURES'
7794 AND a.assignment_type in ('C','E')
7795 AND a.primary_flag = 'Y'
7796 AND ROWNUM = 1;
7797 EXCEPTION WHEN NO_DATA_FOUND THEN
7798 X_organization_id := NULL;
7799 X_organization_name := NULL;
7800 END;
7801
7802 END IF;
7803 ELSIF l_fmt_details.Res_Type_Enabled_Flag = 'Y' AND
7804 (l_fmt_details.Res_Type_Code in ('BOM_LABOR', 'BOM_EQUIPMENT') AND
7805 (p_bom_resource_id is not NULL OR p_bom_resource_name is NOT NULL)) THEN
7806
7807 -- Do name to ID conversion on bom resource
7808 IF l_fmt_details.Res_Type_Code = 'BOM_LABOR' THEN
7809 pa_planning_resource_utils.Check_BOM_EqLabor_or_ID(
7810 p_bom_eqlabor_id => p_bom_resource_id,
7811 p_bom_eqlabor_name => p_bom_resource_name,
7812 p_res_type_code => 2,
7813 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
7814 x_bom_resource_id => l_bom_resource_id,
7815 x_return_status => x_return_status,
7816 x_error_msg_code => X_msg_data);
7817
7818 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7819 PA_UTILS.Add_Message ('PA', X_msg_data, 'PLAN_RES',
7820 Pa_Planning_Resource_Pvt.g_token);
7821 Return;
7822 END IF;
7823 ELSIF l_fmt_details.Res_Type_Code = 'BOM_EQUIPMENT' THEN
7824 pa_planning_resource_utils.Check_BOM_EqLabor_or_ID(
7825 p_bom_eqlabor_id => p_bom_resource_id,
7826 p_bom_eqlabor_name => p_bom_resource_name,
7827 p_res_type_code => 1,
7828 p_check_id_flag => PA_STARTUP.G_Check_ID_Flag,
7829 x_bom_resource_id => l_bom_resource_id,
7830 x_return_status => x_return_status,
7831 x_error_msg_code => X_msg_data);
7832
7833 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7834 PA_UTILS.Add_Message ('PA', X_msg_data, 'PLAN_RES',
7835 Pa_Planning_Resource_Pvt.g_token);
7836 Return;
7837 END IF;
7838 END IF;
7839
7840 IF (l_fmt_details.Orgn_Enabled_Flag = 'Y' AND
7841 l_bom_resource_id IS NOT NULL) THEN
7842 -- Get the Org
7843 SELECT b.organization_id, orgvl.name
7844 INTO X_organization_id, X_organization_name
7845 FROM bom_resources b,
7846 hr_all_organization_units_vl orgvl
7847 WHERE b.resource_id = l_bom_resource_id
7848 AND b.organization_id = orgvl.organization_id
7849 AND ROWNUM = 1;
7850
7851 END IF;
7852
7853 ELSIF l_fmt_details.Res_Type_Enabled_Flag = 'Y' AND
7854 (l_fmt_details.Res_Type_Code = 'NON_LABOR_RESOURCE' AND
7855 p_non_labor_resource is not NULL) THEN
7856
7857 IF l_fmt_details.Fin_Cat_Enabled_Flag = 'Y' THEN
7858 -- Get the Fin Cat
7859 SELECT n.expenditure_type
7860 INTO x_expenditure_type
7861 FROM pa_non_labor_resources n
7862 WHERE n.non_labor_resource = p_non_labor_resource
7863 AND ROWNUM = 1;
7864
7865 END IF;
7866 END IF;
7867
7868 END default_other_elements;
7869
7870 END PA_PLANNING_RESOURCE_UTILS;
7871 /******************************************************************/