25: and nvl(disable_Date, sysdate) >= sysdate;
26:
27: BEGIN
28: -- Initialize API return status to success
29: x_return_status := FND_API.G_RET_STS_SUCCESS;
30: -- test if subinventory si null;
31: if (p_subinventory_code is null ) then
32:
33: FND_MESSAGE.Set_Name('AHL', 'AHL_PRD_PC_SUBINV_MANDATORY');
32:
33: FND_MESSAGE.Set_Name('AHL', 'AHL_PRD_PC_SUBINV_MANDATORY');
34:
35: FND_MSG_PUB.ADD;
36: RAISE FND_API.G_EXC_ERROR;
37: end if;
38:
39: -- Commented the following validation as locator id need not exist in
40: -- mtl_item_locations if it is setup as dynamic entry.
44: -- CLOSE ahl_locator_csr;
45:
46:
47: /* if (l_subinv_code is null) then
48: x_return_status := FND_API.G_RET_STS_ERROR;
49: FND_MESSAGE.Set_Name('AHL','AHL_PRD_LOCATOR_INVALID');
50: FND_MSG_PUB.ADD;
51:
52: END if;*/
53:
54: --Check if the locator is attached to the subinventory if subinventory is provided
55: -- if (l_subinv_code is not null
56: -- and l_subinv_code <> p_subinventory_code ) then
57: -- x_return_status := FND_API.G_RET_STS_ERROR;
58: -- FND_MESSAGE.Set_Name('AHL','AHL_PRD_LOCATOR_SUBINV_INVALID');
59: -- FND_MSG_PUB.ADD;
60:
61: -- END if;
60:
61: -- END if;
62: EXCEPTION
63: -- WHEN NO_DATA_FOUND THEN
64: -- x_return_status := FND_API.G_RET_STS_ERROR;
65: -- FND_MESSAGE.Set_Name('AHL','AHL_PRD_LOCATOR_INVALID');
66: -- FND_MSG_PUB.ADD;
67:
68:
65: -- FND_MESSAGE.Set_Name('AHL','AHL_PRD_LOCATOR_INVALID');
66: -- FND_MSG_PUB.ADD;
67:
68:
69: WHEN FND_API.G_EXC_ERROR THEN
70: x_return_status := FND_API.G_RET_STS_ERROR;
71: WHEN OTHERS THEN
72: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
73: END;
66: -- FND_MSG_PUB.ADD;
67:
68:
69: WHEN FND_API.G_EXC_ERROR THEN
70: x_return_status := FND_API.G_RET_STS_ERROR;
71: WHEN OTHERS THEN
72: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
73: END;
74: --Validates a removal condition
68:
69: WHEN FND_API.G_EXC_ERROR THEN
70: x_return_status := FND_API.G_RET_STS_ERROR;
71: WHEN OTHERS THEN
72: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
73: END;
74: --Validates a removal condition
75: procedure validate_condition
76: (
90: and enabled_flag =1;
91: BEGIN
92:
93: -- Initialize API return status to success
94: x_return_status := FND_API.G_RET_STS_SUCCESS;
95:
96: OPEN ahl_condition_csr(p_condition_id);
97: FETCH ahl_condition_csr INTO l_junk;
98: CLOSE ahl_condition_csr;
97: FETCH ahl_condition_csr INTO l_junk;
98: CLOSE ahl_condition_csr;
99:
100: if (l_junk is null) then
101: x_return_status := FND_API.G_RET_STS_ERROR;
102: FND_MESSAGE.Set_Name('AHL','AHL_PRD_PC_CONDN_MISSING');
103: FND_MSG_PUB.ADD;
104: END if;
105: END;
122:
123: l_junk varchar2(1) := null;
124: begin
125: -- Initialize API return status to success
126: x_return_status := FND_API.G_RET_STS_SUCCESS;
127:
128: OPEN ahl_reason_csr(p_reason_id);
129: FETCH ahl_reason_csr INTO l_junk;
130: CLOSE ahl_reason_csr;
130: CLOSE ahl_reason_csr;
131:
132:
133: if (l_junk is null) then
134: x_return_status := FND_API.G_RET_STS_ERROR;
135: FND_MESSAGE.Set_Name('AHL','AHL_PRD_INVALID_REASON');
136: FND_MESSAGE.Set_Token('REASON',p_reason_id);
137:
138: FND_MSG_PUB.ADD;
164:
165:
166:
167: -- Initialize API return status to success
168: x_return_status := FND_API.G_RET_STS_SUCCESS;
169:
170: OPEN ahl_inv_status_csr(p_Organization_Id,p_Subinventory_Code);
171: FETCH ahl_inv_status_csr INTO l_status_id;
172: CLOSE ahl_inv_status_csr;
174: if l_status_id is null THEN
175: FND_MESSAGE.Set_Name('AHL','AHL_PRD_INVALID_SUBINVENTORY');
176: FND_MESSAGE.set_token('INV', p_Subinventory_Code);
177: FND_MSG_PUB.ADD;
178: x_return_status := FND_API.G_RET_STS_ERROR;
179:
180: End if;
181: --dbms_output.put_line('ahl_prd_util_pkg - Condition id'|| p_condition_id);
182: -- dbms_output.put_line('ahl_prd_util_pkg - status id'|| l_status_id);
197:
198:
199: FND_MESSAGE.Set_Name('AHL','AHL_PRD_CONDN_SUBINV_MISMATCH');
200: FND_MSG_PUB.ADD;
201: x_return_status := FND_API.G_RET_STS_ERROR;
202:
203: END IF;
204:
205: END ;--VALIDATE_MATERIAL_STATUS;
289: THEN
290: IF AHL_UTIL_UC_PKG.Is_Unit_Quarantined(
291: p_unit_header_id => null,
292: p_instance_id => l_instance_id
293: ) = FND_API.G_TRUE
294: THEN
295: RETURN FND_API.G_TRUE;
296: END IF;
297:
291: p_unit_header_id => null,
292: p_instance_id => l_instance_id
293: ) = FND_API.G_TRUE
294: THEN
295: RETURN FND_API.G_TRUE;
296: END IF;
297:
298: ELSE
299: -- If visit task has item instance info.
303: );
304: END IF;
305: END LOOP;
306:
307: RETURN FND_API.G_FALSE;
308: -- if mr header id is input to the API.
309: ELSIF p_ue_id IS NOT NULL
310: THEN
311: OPEN c_get_ue_instance_id(p_ue_id);
326: p_instance_id => nvl(l_instance_id, l_item_instance_id) );
327: END IF;
328:
329: -- Control will reach here if all inputs to the API are null. return false then.
330: RETURN FND_API.G_FALSE;
331:
332: END Is_Unit_Locked;
333:
334: ------------------------------------------------------------------------------------------------
338: -- 2. If the workorder status is any of 22, 12 and 7 then it cannot be updated.
339: ------------------------------------------------------------------------------------------------
340: FUNCTION Is_Wo_Updatable(
341: P_workorder_id IN NUMBER,
342: p_check_unit IN VARCHAR2 DEFAULT FND_API.G_TRUE
343: )
344: RETURN VARCHAR2
345: IS
346: /*
361: BEGIN
362: -- If workorder_id is null then immediately return false.
363: IF p_workorder_id IS NULL
364: THEN
365: RETURN FND_API.G_FALSE;
366: END IF;
367:
368: -- Check if the unit is locked... If so then return false to indicate
369: -- the workorder can't be updated.
366: END IF;
367:
368: -- Check if the unit is locked... If so then return false to indicate
369: -- the workorder can't be updated.
370: IF p_check_unit = FND_API.G_TRUE THEN
371: IF Is_Unit_Locked(
372: p_workorder_id => p_workorder_id,
373: P_ue_id => null,
374: P_visit_id => null,
372: p_workorder_id => p_workorder_id,
373: P_ue_id => null,
374: P_visit_id => null,
375: P_item_instance_id => null
376: ) = FND_API.G_TRUE
377: THEN
378: RETURN FND_API.G_FALSE;
379: END IF;
380: END IF;
374: P_visit_id => null,
375: P_item_instance_id => null
376: ) = FND_API.G_TRUE
377: THEN
378: RETURN FND_API.G_FALSE;
379: END IF;
380: END IF;
381:
382: -- If the unit is not locked and the workorder is in any of
386: CLOSE c_validate_wo_status;
387:
388: IF l_exists IS NOT NULL
389: THEN
390: RETURN FND_API.G_FALSE;
391: END IF;
392:
393: -- If this point is reached then neither the unit is locked nor the workorder is
394: -- in invalid status. Return true here.
391: END IF;
392:
393: -- If this point is reached then neither the unit is locked nor the workorder is
394: -- in invalid status. Return true here.
395: RETURN FND_API.G_TRUE;
396:
397: END Is_Wo_Updatable;
398:
399: ------------------------------------------------------------------------------------------------
406: ------------------------------------------------------------------------------------------------
407: FUNCTION Is_Op_Updatable(
408: p_workorder_id IN NUMBER,
409: p_operation_seq_num IN NUMBER,
410: p_check_unit IN VARCHAR2 DEFAULT FND_API.G_TRUE
411: )
412: RETURN VARCHAR2
413: IS
414:
445: -- If either of workorder_id or operation sequence number is null then
446: -- return false as it is incorrect input to this API.
447: IF p_workorder_id IS NULL OR p_operation_seq_num IS NULL
448: THEN
449: RETURN FND_API.G_FALSE;
450: END IF;
451:
452: -- If the unit associated with this workorder is locked then
453: -- operation should not be updatable.
450: END IF;
451:
452: -- If the unit associated with this workorder is locked then
453: -- operation should not be updatable.
454: IF p_check_unit = FND_API.G_TRUE THEN
455: IF Is_Unit_Locked(
456: p_workorder_id => p_workorder_id,
457: P_ue_id => null,
458: P_visit_id => null,
456: p_workorder_id => p_workorder_id,
457: P_ue_id => null,
458: P_visit_id => null,
459: P_item_instance_id => null
460: ) = FND_API.G_TRUE
461: THEN
462: RETURN FND_API.G_FALSE;
463: END IF;
464: END IF;
458: P_visit_id => null,
459: P_item_instance_id => null
460: ) = FND_API.G_TRUE
461: THEN
462: RETURN FND_API.G_FALSE;
463: END IF;
464: END IF;
465:
466: -- If the workorder status is any of 7, 12 or 22 then return false.
468: FETCH c_validate_wo_status INTO l_exists;
469: CLOSE c_validate_wo_status;
470: IF l_exists IS NOT NULL
471: THEN
472: RETURN FND_API.G_FALSE;
473: END IF;
474:
475: -- If the operation status is 'Complete' then return false
476: -- to indicate the operation is not updatable.
477: OPEN c_validate_op_status(p_workorder_id, p_operation_seq_num);
478: FETCH c_validate_op_status INTO l_exists;
479: IF l_exists IS NOT NULL
480: THEN
481: RETURN FND_API.G_FALSE;
482: END IF;
483:
484: -- Control reaching here indicates above three checks are not valid for
485: -- the input hence return true to indicate the operation is updatable.
482: END IF;
483:
484: -- Control reaching here indicates above three checks are not valid for
485: -- the input hence return true to indicate the operation is updatable.
486: RETURN FND_API.G_TRUE;
487:
488: END Is_Op_Updatable;
489:
490: ------------------------------------------------------------------------------------------------
493: -- The function returns QA Plan id or null if one is not associated with the MR.
494: ------------------------------------------------------------------------------------------------
495: FUNCTION Is_Mr_Qa_Enabled(
496: p_ue_id IN NUMBER,
497: p_check_unit IN VARCHAR2 DEFAULT FND_API.G_TRUE
498: )
499: RETURN NUMBER
500: IS
501:
592: END IF;
593:
594: -- If the unit associated with this workorder is locked then
595: -- operation should not be updatable.
596: IF p_check_unit = FND_API.G_TRUE THEN
597: IF Is_Unit_Locked(
598: p_workorder_id => null,
599: P_ue_id => l_mr_id,
600: P_visit_id => null,
598: p_workorder_id => null,
599: P_ue_id => l_mr_id,
600: P_visit_id => null,
601: P_item_instance_id => null
602: ) = FND_API.G_TRUE
603: THEN
604: RETURN NULL;
605: END IF;
606: END IF;
640: -- are not allowed.
641: ------------------------------------------------------------------------------------------------
642: FUNCTION Is_PartChange_Enabled(
643: P_workorder_id IN NUMBER,
644: p_check_unit IN VARCHAR2 DEFAULT FND_API.G_TRUE
645: )
646: RETURN VARCHAR2
647: IS
648: /*
675: BEGIN
676: -- If sole input to this API p_workorder_id is null then return false
677: IF p_workorder_id IS NULL
678: THEN
679: RETURN FND_API.G_FALSE;
680: END IF;
681:
682: -- If the Unit is locked then part changes cannot be done hence return false
683: IF p_check_unit = FND_API.G_TRUE THEN
679: RETURN FND_API.G_FALSE;
680: END IF;
681:
682: -- If the Unit is locked then part changes cannot be done hence return false
683: IF p_check_unit = FND_API.G_TRUE THEN
684: IF Is_Unit_Locked(
685: p_workorder_id => p_workorder_id,
686: P_ue_id => null,
687: P_visit_id => null,
685: p_workorder_id => p_workorder_id,
686: P_ue_id => null,
687: P_visit_id => null,
688: P_item_instance_id => null
689: ) = FND_API.G_TRUE THEN
690: RETURN FND_API.G_FALSE;
691: END IF;
692: END IF;
693:
686: P_ue_id => null,
687: P_visit_id => null,
688: P_item_instance_id => null
689: ) = FND_API.G_TRUE THEN
690: RETURN FND_API.G_FALSE;
691: END IF;
692: END IF;
693:
694: -- If workorder is in an invalid status where part changes cannot be done then
697: FETCH c_get_workorder_details INTO l_status_code, l_item_instance_id;
698: CLOSE c_get_workorder_details;
699:
700: IF l_status_code NOT IN ('3', '19') THEN
701: RETURN FND_API.G_FALSE;
702: END IF;
703:
704: AHL_PRD_PARTS_CHANGE_PVT.get_unit_config_information(
705: p_item_instance_id => l_item_instance_id,
706: p_workorder_id => null,
707: x_unit_config_id => l_unit_config_id,
708: x_unit_config_name => l_unit_config_name,
709: x_return_status => l_return_status);
710: IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
711: RETURN FND_API.G_FALSE;
712: END IF;
713:
714: -- All above conditions are false hence part changes can be done. return true.
707: x_unit_config_id => l_unit_config_id,
708: x_unit_config_name => l_unit_config_name,
709: x_return_status => l_return_status);
710: IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
711: RETURN FND_API.G_FALSE;
712: END IF;
713:
714: -- All above conditions are false hence part changes can be done. return true.
715: RETURN FND_API.G_TRUE;
711: RETURN FND_API.G_FALSE;
712: END IF;
713:
714: -- All above conditions are false hence part changes can be done. return true.
715: RETURN FND_API.G_TRUE;
716:
717: END Is_PartChange_Enabled;
718:
719:
726: ------------------------------------------------------------------------------------------------
727: FUNCTION IsDelAsg_Enabled(
728: P_assignment_id IN NUMBER,
729: P_workorder_id IN NUMBER,
730: p_check_unit IN VARCHAR2 DEFAULT FND_API.G_TRUE
731: )
732: RETURN VARCHAR2
733: IS
734:
757:
758: -- If sole input to this API p_workorder_id is null then return false
759: IF P_assignment_id IS NULL
760: THEN
761: RETURN FND_API.G_FALSE;
762: END IF;
763: -- If the Unit is locked then Assignment cant be deleted return false.
764: IF p_check_unit = FND_API.G_TRUE THEN
765: IF Is_Unit_Locked(
760: THEN
761: RETURN FND_API.G_FALSE;
762: END IF;
763: -- If the Unit is locked then Assignment cant be deleted return false.
764: IF p_check_unit = FND_API.G_TRUE THEN
765: IF Is_Unit_Locked(
766: p_workorder_id => p_workorder_id,
767: P_ue_id => null,
768: P_visit_id => null,
766: p_workorder_id => p_workorder_id,
767: P_ue_id => null,
768: P_visit_id => null,
769: P_item_instance_id => null
770: ) = FND_API.G_TRUE
771: THEN
772: Fnd_Message.Set_Name('AHL', 'AHL_PP_DEL_RESASG_UNTLCKD');
773: Fnd_Msg_Pub.ADD;
774: RETURN FND_API.G_FALSE;
770: ) = FND_API.G_TRUE
771: THEN
772: Fnd_Message.Set_Name('AHL', 'AHL_PP_DEL_RESASG_UNTLCKD');
773: Fnd_Msg_Pub.ADD;
774: RETURN FND_API.G_FALSE;
775: END IF;
776: END IF;
777:
778: OPEN c_get_ass_details(p_assignment_id);
785: FND_MESSAGE.set_token( 'RES_SEQ' , l_res_seq_num);
786: Fnd_Msg_Pub.ADD;
787:
788: CLOSE c_get_ass_details;
789: RETURN FND_API.G_FALSE;
790: END IF;
791: CLOSE c_get_ass_details;
792:
793:
794: /*IF l_login_date IS NOT NULL
795: THEN
796: -- the user is currently logged in corresponding to this resource assignment
797: -- the resource assignment cannot be deleted
798: RETURN FND_API.G_FALSE;
799: END IF;
800: */
801:
802: RETURN FND_API.G_TRUE;
798: RETURN FND_API.G_FALSE;
799: END IF;
800: */
801:
802: RETURN FND_API.G_TRUE;
803:
804: END IsDelAsg_Enabled;
805:
806: FUNCTION Is_Wo_Completable(
838: BEGIN
839: -- If workorder_id is null then immediately return false.
840: IF p_workorder_id IS NULL
841: THEN
842: RETURN FND_API.G_FALSE;
843: END IF;
844:
845: OPEN c_validate_wo_status(p_workorder_id);
846: FETCH c_validate_wo_status INTO l_exists;
847: CLOSE c_validate_wo_status;
848:
849: IF l_exists IS NOT NULL
850: THEN
851: RETURN FND_API.G_FALSE;
852: END IF;
853:
854: OPEN c_validate_op_status(p_workorder_id);
855: FETCH c_validate_op_status INTO l_exists;
856: CLOSE c_validate_op_status;
857:
858: IF l_exists IS NOT NULL
859: THEN
860: RETURN FND_API.G_FALSE;
861: END IF;
862:
863: -- If this point is reached then neither the unit is locked nor the workorder is
864: -- in invalid status. Return true here.
861: END IF;
862:
863: -- If this point is reached then neither the unit is locked nor the workorder is
864: -- in invalid status. Return true here.
865: RETURN FND_API.G_TRUE;
866:
867: END Is_Wo_Completable;
868:
869: ------------------------------------------------------------------------------------------------
873: -- Function name : Is_ResTxn_Allowed
874: -- Type : Private
875: -- Pre-reqs :
876: -- Parameters :
877: -- Return : FND_API.G_TRUE or FND_API.G_FALSE.
878: --
879: -- Standard IN Parameters :
880: -- None
881: --
897: -- End of Comments
898:
899: FUNCTION Is_ResTxn_Allowed(
900: P_workorder_id IN NUMBER,
901: p_check_unit IN VARCHAR2 DEFAULT FND_API.G_TRUE
902: )
903: RETURN VARCHAR2
904: IS
905: -- cursor to retrieve the workorder status
912: l_return_value VARCHAR2(1);
913: l_wo_status VARCHAR2(30);
914: BEGIN
915:
916: l_return_value := FND_API.G_FALSE;
917: IF p_check_unit = FND_API.G_TRUE THEN
918: l_return_value := is_unit_locked(p_workorder_id => p_workorder_id,
919: p_ue_id => NULL,
920: p_item_instance_id => NULL,
913: l_wo_status VARCHAR2(30);
914: BEGIN
915:
916: l_return_value := FND_API.G_FALSE;
917: IF p_check_unit = FND_API.G_TRUE THEN
918: l_return_value := is_unit_locked(p_workorder_id => p_workorder_id,
919: p_ue_id => NULL,
920: p_item_instance_id => NULL,
921: p_visit_id => NULL
920: p_item_instance_id => NULL,
921: p_visit_id => NULL
922: );
923: -- If the unit is locked, then resource transactions are not allowed
924: IF l_return_value = FND_API.G_TRUE THEN
925: RETURN FND_API.G_FALSE;
926: END IF;
927: END IF;
928:
921: p_visit_id => NULL
922: );
923: -- If the unit is locked, then resource transactions are not allowed
924: IF l_return_value = FND_API.G_TRUE THEN
925: RETURN FND_API.G_FALSE;
926: END IF;
927: END IF;
928:
929: OPEN get_wo_status(p_workorder_id);
932:
933: -- If the workorder is in status On Hold, Closed, Complete No Charge, Unreleased, Cancelled
934: -- then resource transactions are not allowed
935: IF l_wo_status IS NULL OR l_wo_status IN ('6','12','5','1', '7', '13') THEN
936: RETURN FND_API.G_FALSE;
937: END IF;
938:
939: RETURN FND_API.G_TRUE;
940:
935: IF l_wo_status IS NULL OR l_wo_status IN ('6','12','5','1', '7', '13') THEN
936: RETURN FND_API.G_FALSE;
937: END IF;
938:
939: RETURN FND_API.G_TRUE;
940:
941: END Is_ResTxn_Allowed;
942:
943: ------------------------------------------------------------------------------------------------
948: -- Function name : Is_Wo_Cancel_Allowed
949: -- Type : Private
950: -- Pre-reqs :
951: -- Parameters :
952: -- Return : FND_API.G_TRUE or FND_API.G_FALSE.
953: --
954: -- Standard IN Parameters :
955: -- None
956: --
985:
986: -- if no workorder ID is passed, then check for only AHL_PRD_DISALLOW_CANCEL_JOBS
987: -- function access.
988: IF (p_workorder_id IS NULL) THEN
989: return FND_API.G_TRUE;
990: ELSE
991: OPEN is_workorders_released(p_workorder_id);
992: FETCH is_workorders_released INTO l_junk;
993: IF(is_workorders_released%NOTFOUND)THEN
991: OPEN is_workorders_released(p_workorder_id);
992: FETCH is_workorders_released INTO l_junk;
993: IF(is_workorders_released%NOTFOUND)THEN
994: CLOSE is_workorders_released;
995: return FND_API.G_TRUE;
996: END IF;
997: CLOSE is_workorders_released;
998:
999: IF(FND_FUNCTION.TEST('AHL_PRD_CANCEL_REL_JOBS',null))THEN
996: END IF;
997: CLOSE is_workorders_released;
998:
999: IF(FND_FUNCTION.TEST('AHL_PRD_CANCEL_REL_JOBS',null))THEN
1000: return FND_API.G_TRUE;
1001: END IF;
1002: END IF;
1003:
1004: END IF;
1002: END IF;
1003:
1004: END IF;
1005:
1006: RETURN FND_API.G_FALSE;
1007:
1008: END Is_Wo_Cancel_Allowed;
1009:
1010: -- Start of Comments --