DBA Data[Home] [Help]

APPS.EAM_PROCESS_WO_PVT SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 49

G_UPDATE_RES_USAGE	CONSTANT NUMBER := 7;
Line: 50

G_MATERIAL_UPDATE	CONSTANT NUMBER := 8;
Line: 62

              SELECT enable_workflow
	      INTO   l_workflow_enabled
	      FROM EAM_ENABLE_WORKFLOW
	      WHERE MAINTENANCE_OBJECT_SOURCE =p_maint_obj_source;
Line: 74

               SELECT eam_wo_workflow_enabled
	       INTO l_workflow_enabled
	       FROM WIP_EAM_PARAMETERS
	       WHERE organization_id =p_organization_id;
Line: 142

										      SELECT EAM_WORKFLOW_EVENT_S.NEXTVAL
										      INTO l_wf_event_seq
										      FROM DUAL;
Line: 178

										    l_parameter_list.DELETE;
Line: 187

				OR (p_eam_wo_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE  --workorder updated
						     --and old status is not same as new status
						    AND (p_old_eam_wo_rec.user_defined_status_id <>p_eam_wo_rec.user_defined_status_id       OR    NVL(p_old_eam_wo_rec.pending_flag,'N')='Y' )
			    ))
			     AND (WF_EVENT.TEST(l_status_changed_event) <> 'NONE')  --if status change event enabled
			  ) THEN
										      SELECT EAM_WORKFLOW_EVENT_S.NEXTVAL
										      INTO l_wf_event_seq
										      FROM DUAL;
Line: 235

										    l_parameter_list.DELETE;
Line: 246

												 SELECT NVL((SUM(system_estimated_mat_cost) + SUM(system_estimated_lab_cost) + SUM(system_estimated_eqp_cost)),0)
												 INTO l_cost_estimate
												 FROM WIP_EAM_PERIOD_BALANCES
												 WHERE wip_entity_id = p_eam_wo_rec.wip_entity_id;
Line: 256

										      SELECT EAM_WORKFLOW_EVENT_S.NEXTVAL
										      INTO l_wf_event_seq
										      FROM DUAL;
Line: 266

										      INSERT INTO EAM_WO_WORKFLOWS
										     (WIP_ENTITY_ID,WF_ITEM_TYPE,WF_ITEM_KEY,LAST_UPDATE_DATE,LAST_UPDATED_BY,
										     CREATION_DATE,CREATED_BY,LAST_UPDATE_LOGIN)
										     VALUES
										     (p_eam_wo_rec.wip_entity_id,p_workflow_name,l_event_key,SYSDATE,FND_GLOBAL.user_id,
										     SYSDATE,FND_GLOBAL.user_id,FND_GLOBAL.login_id
										     );
Line: 324

										    l_parameter_list.DELETE;
Line: 340

PROCEDURE UPDATE_INTERMEDIA_INDEX
(
   p_eam_wo_rec             IN     EAM_PROCESS_WO_PUB.eam_wo_rec_type,
   p_old_eam_wo_rec     IN     EAM_PROCESS_WO_PUB.eam_wo_rec_type,
   p_eam_op_tbl               IN     EAM_PROCESS_WO_PUB.eam_op_tbl_type,
   p_eam_res_tbl              IN      EAM_PROCESS_WO_PUB.eam_res_tbl_type,
   p_eam_res_inst_tbl      IN       EAM_PROCESS_WO_PUB.eam_res_inst_tbl_type
)
IS
    l_update_index     BOOLEAN;
Line: 351

     l_update_index := FALSE;
Line: 359

										          p_event  => 'INSERT',
											  p_wip_entity_id =>p_eam_wo_rec.wip_entity_id,
											  p_organization_id =>p_eam_wo_rec.organization_id,
											  p_last_update_date  => SYSDATE,
											  p_last_updated_by  => FND_GLOBAL.user_id,
											  p_last_update_login =>FND_GLOBAL.login_id
										     );
Line: 369

         IF (p_eam_wo_rec.transaction_type = G_OPR_UPDATE AND
	     ((NVL(p_eam_wo_rec.description,'') <> NVL(p_old_eam_wo_rec.description,''))  OR
	         (p_eam_wo_rec.maintenance_object_id <> p_old_eam_wo_rec.maintenance_object_id) OR
		 (p_eam_wo_rec.user_defined_status_id <> p_old_eam_wo_rec.user_defined_status_id) OR
		 (NVL(p_eam_wo_rec.asset_activity_id,-1) <> NVL(p_old_eam_wo_rec.asset_activity_id,-1))
		 OR (NVL(p_eam_wo_rec.owning_department,-1) <> NVL(p_old_eam_wo_rec.owning_department,-1))
		 OR (NVL(p_eam_wo_rec.planner_type, -1) <> NVL(p_old_eam_wo_rec.planner_type,-1))   --vardha
		 OR (NVL(p_eam_wo_rec.project_id,-1) <> NVL(p_old_eam_wo_rec.project_id,-1))
		 OR (NVL(p_eam_wo_rec.task_id,-1) <> NVL(p_old_eam_wo_rec.task_id,-1))
		 OR (NVL(p_eam_wo_rec.priority,-1) <> NVL(p_old_eam_wo_rec.priority,-1))
		 OR (NVL(p_eam_wo_rec.work_order_type,'') <> NVL(p_old_eam_wo_rec.work_order_type,''))
		 OR (NVL(p_eam_wo_rec.activity_type,'') <> NVL(p_old_eam_wo_rec.activity_type,''))
		 OR (NVL(p_eam_wo_rec.activity_cause,'') <> NVL(p_old_eam_wo_rec.activity_cause,''))
		 OR (NVL(p_eam_wo_rec.activity_source,'') <> NVL(p_old_eam_wo_rec.activity_source,''))
	     )
	 ) THEN
	    l_update_index := TRUE;
Line: 388

      IF(l_update_index = FALSE) THEN
            IF(p_eam_op_tbl IS NOT NULL AND p_eam_op_tbl.COUNT>0) THEN
                        FOR i IN  p_eam_op_tbl.FIRST ..  p_eam_op_tbl.LAST LOOP
                                    IF(p_eam_op_tbl(i).transaction_type = EAM_PROCESS_WO_PUB.G_OPR_CREATE
				                            OR p_eam_op_tbl(i).transaction_type = EAM_PROCESS_WO_PUB.G_OPR_DELETE) THEN
							    l_update_index:=TRUE;
Line: 400

       IF(l_update_index = FALSE) THEN
            IF(p_eam_res_tbl IS NOT NULL AND p_eam_res_tbl.COUNT>0) THEN
                        FOR i IN  p_eam_res_tbl.FIRST ..  p_eam_res_tbl.LAST LOOP
                                    IF(p_eam_res_tbl(i).transaction_type = EAM_PROCESS_WO_PUB.G_OPR_CREATE
				                            OR p_eam_res_tbl(i).transaction_type = EAM_PROCESS_WO_PUB.G_OPR_DELETE) THEN
							    l_update_index:=TRUE;
Line: 412

       IF(l_update_index = FALSE) THEN
            IF(p_eam_res_inst_tbl IS NOT NULL AND p_eam_res_inst_tbl.COUNT>0) THEN
                        FOR i IN  p_eam_res_inst_tbl.FIRST ..  p_eam_res_inst_tbl.LAST LOOP
                                    IF(p_eam_res_inst_tbl(i).transaction_type = EAM_PROCESS_WO_PUB.G_OPR_CREATE
				                            OR p_eam_res_inst_tbl(i).transaction_type = EAM_PROCESS_WO_PUB.G_OPR_DELETE) THEN
							    l_update_index:=TRUE;
Line: 424

      IF(l_update_index = TRUE) THEN
										     EAM_TEXT_UTIL.PROCESS_WO_EVENT
										     (
										          p_event  => 'UPDATE',
											  p_wip_entity_id =>p_eam_wo_rec.wip_entity_id,
											  p_organization_id =>p_eam_wo_rec.organization_id,
											  p_last_update_date  => SYSDATE,
											  p_last_updated_by  => FND_GLOBAL.user_id,
											  p_last_update_login =>FND_GLOBAL.login_id
										     );
Line: 436

END UPDATE_INTERMEDIA_INDEX;
Line: 646

	/* Bug 5224748. Call Add_usage only for non firm work orders. For firm wos, Bottom Up should handle the insertions*/
	IF ( x_bottomup_scheduled = G_NON_FIRM_WORKORDER ) THEN

          EAM_RES_USAGE_UTILITY_PVT.Add_Usage
          (  p_eam_res_usage_rec   => l_eam_res_usage_rec
          ,  x_mesg_token_tbl      => l_mesg_token_tbl
          ,  x_return_status       => l_return_status
          );
Line: 697

	             OR (l_eam_res_usage_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_DELETE ) --deleted
		     OR (l_eam_res_usage_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE AND  --updating the resource usage

		       (
		       --NVL(l_eam_res_rec.schedule_seq_num,l_eam_res_rec.resource_seq_num)<>NVL(l_old_eam_res_rec.schedule_seq_num,l_old_eam_res_rec.resource_seq_num)
		        -- OR
			l_eam_res_usage_rec.start_date <> l_eam_res_usage_rec.old_start_date   --shedule_seq_num,start_date,completion_date
			OR l_eam_res_usage_rec.completion_date <> l_eam_res_usage_rec.old_completion_date
		--	OR l_eam_res_rec.resource_id <> l_old_eam_res_rec.resource_id    --resource_code,usage_rate_or_amount,scheduled_flag,assigned_units
		--	OR l_eam_res_rec.usage_rate_or_amount <> l_old_eam_res_rec.usage_rate_or_amount
		--	OR l_eam_res_rec.scheduled_flag <> l_old_eam_res_rec.scheduled_flag
		--	OR NVL(l_eam_res_rec.assigned_units,0) <> NVL(l_old_eam_res_rec.assigned_units,0)
			)
		    )
		) THEN
		     x_bottomup_scheduled := G_UPDATE_RES_USAGE;
Line: 1154

        IF l_eam_sub_res_rec.transaction_type IN (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
        THEN

           IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Populate NULL columns') ;
Line: 1868

        IF l_eam_res_inst_rec.transaction_type IN (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
        THEN

           IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Populate NULL columns') ;
Line: 2093

	    --    OR (l_eam_res_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_DELETE AND l_eam_res_rec.scheduled_flag=1) --deleted and was scheduled
		OR (l_eam_res_inst_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE AND  --updating the resource iinstance
		       (
		       --NVL(l_eam_res_rec.schedule_seq_num,l_eam_res_rec.resource_seq_num)<>NVL(l_old_eam_res_rec.schedule_seq_num,l_old_eam_res_rec.resource_seq_num)
		        -- OR
			l_eam_res_inst_rec.start_date <> l_old_eam_res_inst_rec.start_date   --shedule_seq_num,start_date,completion_date
			OR l_eam_res_inst_rec.completion_date <> l_old_eam_res_inst_rec.completion_date
		--	OR l_eam_res_rec.resource_id <> l_old_eam_res_rec.resource_id    --resource_code,usage_rate_or_amount,scheduled_flag,assigned_units
		--	OR l_eam_res_rec.usage_rate_or_amount <> l_old_eam_res_rec.usage_rate_or_amount
		--	OR l_eam_res_rec.scheduled_flag <> l_old_eam_res_rec.scheduled_flag
		--	OR NVL(l_eam_res_rec.assigned_units,0) <> NVL(l_old_eam_res_rec.assigned_units,0)
			)
		    )
		) THEN
		    x_bottomup_scheduled := G_UPDATE_RES_USAGE;
Line: 2534

        IF l_eam_op_network_rec.transaction_type IN (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
        THEN

           IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Populate NULL columns') ;
Line: 2724

		 AND l_eam_op_network_rec.transaction_type IN (EAM_PROCESS_WO_PVT.G_OPR_CREATE,EAM_PROCESS_WO_PVT.G_OPR_DELETE)
		 ) THEN     -- if op dependency is added or deleted
		    x_schedule_wo := G_SCHEDULE_WO;
Line: 2731

		 AND l_eam_op_network_rec.transaction_type IN (EAM_PROCESS_WO_PVT.G_OPR_CREATE,EAM_PROCESS_WO_PVT.G_OPR_DELETE)
		 ) THEN     -- if op dependency is added or deleted
		    x_bottomup_scheduled := G_BU_SCHEDULE_WO;
Line: 3142

        SELECT vendor_id INTO l_eam_mat_req_rec.vendor_id
        FROM   po_suppliers_val_v
        WHERE upper(vendor_name) = upper(l_eam_mat_req_rec.suggested_vendor_name );
Line: 3204

            SELECT segment1 INTO l_inv_item_name FROM mtl_system_items WHERE inventory_item_id=l_eam_mat_req_rec.inventory_item_id AND organization_id=l_eam_mat_req_rec.organization_id;
Line: 3207

            SELECT wip_entity_name INTO l_wip_entity_name FROM wip_entities WHERE wip_entity_id=l_eam_mat_req_rec.wip_entity_id;
Line: 3229

        IF l_eam_mat_req_rec.transaction_type IN (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
        THEN

  	   IF l_eam_mat_req_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_DELETE THEN
		   x_material_shortage := G_MATERIAL_UPDATE;
Line: 3268

	   x_material_shortage := G_MATERIAL_UPDATE;
Line: 3292

	 SELECT concatenated_segments into l_token_tbl(1).token_value
	 FROM  mtl_system_items_kfv msik
	 WHERE 	 msik.inventory_item_id = l_eam_mat_req_rec.inventory_item_id
 	 AND     msik.organization_id   = l_eam_mat_req_rec.organization_id;
Line: 3366

		x_material_shortage := G_MATERIAL_UPDATE;
Line: 3461

       select primary_uom_code, stock_enabled_flag,
         purchasing_item_flag, description
         into l_uom_code, l_non_stock_flag,
         l_purch_flag, l_description
         from mtl_system_items_b_kfv
         where inventory_item_id = l_eam_mat_req_rec.inventory_item_id
         and organization_id = l_eam_mat_req_rec.organization_id;
Line: 3498

											   ((l_eam_mat_req_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
												 and l_old_eam_mat_req_rec.auto_request_material = 'N'
												 and l_eam_mat_req_rec.auto_request_material = 'Y'  -- AUTO_REQUEST_MATERIAL flag turned on
												) OR
												(l_eam_mat_req_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
												 and l_old_eam_mat_req_rec.required_quantity <> l_eam_mat_req_rec.required_quantity -- reqd qty updating
												) OR
												(l_eam_mat_req_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_CREATE
												 and l_eam_mat_req_rec.auto_request_material = 'Y' -- new mtl line adding with auto req flag on.
												)
											   )
											   THEN

														l_eam_mat_req_rec.invoke_allocations_api := 'Y';
Line: 3521

       select status_type into l_wo_status from
         wip_discrete_jobs
         where wip_entity_id = l_eam_mat_req_rec.wip_entity_id
         and organization_id = l_eam_mat_req_rec.organization_id;
Line: 3532

		select mic.category_id into l_purch_cat_id
		from mtl_item_categories mic,
		mtl_default_category_sets mdcs where
		mic.inventory_item_id = l_eam_mat_req_rec.inventory_item_id
		and mic.organization_id = l_eam_mat_req_rec.organization_id
		and mic.category_set_id = mdcs.category_set_id
		and mdcs.functional_area_id = 2;
Line: 3580

              OR (l_eam_mat_req_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
                  /*and l_old_eam_mat_req_rec.required_quantity < l_eam_mat_req_rec.required_quantity commented for #6118897*/)
              OR (l_eam_mat_req_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
                  and nvl(l_old_eam_mat_req_rec.auto_request_material,'N')='N')
       )then

		select mic.category_id into l_purch_cat_id
		from mtl_item_categories mic,
		mtl_default_category_sets mdcs where
		mic.inventory_item_id = l_eam_mat_req_rec.inventory_item_id
		and mic.organization_id = l_eam_mat_req_rec.organization_id
		and mic.category_set_id = mdcs.category_set_id
		and mdcs.functional_area_id = 2;
Line: 3610

                        SELECT SUM(nvl(req_qty,0)) INTO l_total_req_qty
                        FROM
                        (SELECT SUM(nvl(pria.quantity,0)) req_qty
                        FROM po_requisitions_interface_all pria
                        WHERE  pria.wip_entity_id = l_eam_mat_req_rec.wip_entity_id
                        AND pria.destination_organization_id = l_eam_mat_req_rec.organization_id
                        AND pria.wip_operation_seq_num = l_eam_mat_req_rec.operation_seq_num
                        AND pria.item_id = l_eam_mat_req_rec.inventory_item_id
                        AND pria.wip_resource_seq_num is null
                        AND ((process_flag is null) or (Upper(Trim(process_flag)) = 'IN PROCESS'))

                        UNION ALL
                        SELECT SUM(nvl(prla.quantity,0)) req_qty
                        FROM po_requisition_lines_all prla , po_requisition_headers_all prha
                        WHERE prla.requisition_header_id = prha.requisition_header_id(+)
                        AND upper(NVL(prha.authorization_status, 'APPROVED') ) not in ('CANCELLED', 'REJECTED','SYSTEM_SAVED')
                        AND UPPER(NVL(prla.cancel_flag,'N')) <> 'Y'
                        AND prla.wip_entity_id = l_eam_mat_req_rec.wip_entity_id
                        AND prla.destination_organization_id = l_eam_mat_req_rec.organization_id
                        AND prla.wip_operation_seq_num = l_eam_mat_req_rec.operation_seq_num
                        AND prla.item_id = l_eam_mat_req_rec.inventory_item_id
                        AND prla.wip_resource_seq_num is null

                        UNION ALL
                        SELECT SUM(nvl(pd.quantity_ordered,0)) req_qty
                        FROM po_distributions_all pd , po_headers_all ph,po_lines_all pl
                        WHERE pd.po_header_id = ph.po_header_id(+)
                        AND upper(NVL(ph.authorization_status, 'APPROVED') ) not in ('CANCELLED', 'REJECTED','SYSTEM_SAVED')
                        AND UPPER(NVL(pl.cancel_flag,'N')) <> 'Y'
                        AND pd.po_line_id = pl.po_line_id(+)
                        AND pd.wip_entity_id = l_eam_mat_req_rec.wip_entity_id
                        AND pd.destination_organization_id = l_eam_mat_req_rec.organization_id
                        AND pd.wip_operation_seq_num = l_eam_mat_req_rec.operation_seq_num
                        AND pl.item_id = l_eam_mat_req_rec.inventory_item_id
                        AND pd.wip_resource_seq_num is null
                        AND pd.line_location_id not in(
                               SELECT nvl(prla.line_location_id,0)
                               FROM po_requisition_lines_all prla , po_requisition_headers_all prha
                               WHERE prla.requisition_header_id = prha.requisition_header_id(+)
                               AND upper(NVL(prha.authorization_status, 'APPROVED') ) not in ('CANCELLED', 'REJECTED','SYSTEM_SAVED')
                               AND UPPER(NVL(prla.cancel_flag,'N')) <> 'Y'
                               AND prla.wip_entity_id =l_eam_mat_req_rec.wip_entity_id
                               AND prla.destination_organization_id = l_eam_mat_req_rec.organization_id
                               AND prla.wip_operation_seq_num = l_eam_mat_req_rec.operation_seq_num
                               AND prla.item_id = l_eam_mat_req_rec.inventory_item_id
                               AND prla.wip_resource_seq_num is null)
                        );
Line: 3668

                        SELECT SUM(nvl(req_qty,0)) INTO l_total_req_qty
                        FROM
                        (SELECT SUM(nvl(pria.quantity,0)) req_qty
                        FROM po_requisitions_interface_all pria
                        WHERE  pria.wip_entity_id = l_eam_mat_req_rec.wip_entity_id
                        AND pria.destination_organization_id = l_eam_mat_req_rec.organization_id
                        AND pria.wip_operation_seq_num = l_eam_mat_req_rec.operation_seq_num
                        AND pria.item_id = l_eam_mat_req_rec.inventory_item_id
                        AND pria.wip_resource_seq_num is null
                        AND ((process_flag is null) or (Upper(Trim(process_flag)) = 'IN PROCESS'))

                        UNION ALL
                        SELECT SUM(nvl(prla.quantity,0)) req_qty
                        FROM po_requisition_lines_all prla , po_requisition_headers_all prha
                        WHERE prla.requisition_header_id = prha.requisition_header_id(+)
                        AND upper(NVL(prha.authorization_status, 'APPROVED') ) not in ('SYSTEM_SAVED')
                        AND prla.wip_entity_id = l_eam_mat_req_rec.wip_entity_id
                        AND prla.destination_organization_id = l_eam_mat_req_rec.organization_id
                        AND prla.wip_operation_seq_num = l_eam_mat_req_rec.operation_seq_num
                        AND prla.item_id = l_eam_mat_req_rec.inventory_item_id
                        AND prla.wip_resource_seq_num is null

                        UNION ALL
                        SELECT SUM(nvl(pd.quantity_ordered,0)) req_qty
                        FROM po_distributions_all pd , po_headers_all ph,po_lines_all pl
                        WHERE pd.po_header_id = ph.po_header_id(+)
                        AND upper(NVL(ph.authorization_status, 'APPROVED') ) not in ('SYSTEM_SAVED')
                        AND pd.po_line_id = pl.po_line_id(+)
                        AND pd.wip_entity_id = l_eam_mat_req_rec.wip_entity_id
                        AND pd.destination_organization_id = l_eam_mat_req_rec.organization_id
                        AND pd.wip_operation_seq_num = l_eam_mat_req_rec.operation_seq_num
                        AND pl.item_id = l_eam_mat_req_rec.inventory_item_id
                        AND pd.wip_resource_seq_num is null
                        AND pd.line_location_id not in(
                        	SELECT nvl(prla.line_location_id,0)
                        	FROM po_requisition_lines_all prla , po_requisition_headers_all prha
                        	WHERE prla.requisition_header_id = prha.requisition_header_id(+)
                        	AND upper(NVL(prha.authorization_status, 'APPROVED') ) not in ('SYSTEM_SAVED')
                        	AND prla.wip_entity_id =l_eam_mat_req_rec.wip_entity_id
                        	AND prla.destination_organization_id = l_eam_mat_req_rec.organization_id
                        	AND prla.wip_operation_seq_num = l_eam_mat_req_rec.operation_seq_num
                        	AND prla.item_id = l_eam_mat_req_rec.inventory_item_id
                        	AND prla.wip_resource_seq_num is null)
                        );
Line: 4161

        SELECT vendor_id INTO l_eam_direct_items_rec.suggested_vendor_id
        FROM   po_suppliers_val_v
        WHERE upper(vendor_name) = upper(l_eam_direct_items_rec.suggested_vendor_name );
Line: 4244

        IF l_eam_direct_items_rec.transaction_type IN (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
        THEN

	IF l_eam_direct_items_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_DELETE THEN
		x_material_shortage := G_MATERIAL_UPDATE;
Line: 4283

  	   x_material_shortage := G_MATERIAL_UPDATE;
Line: 4374

		x_material_shortage := G_MATERIAL_UPDATE;
Line: 4494

       select status_type into l_wo_status from
         wip_discrete_jobs
         where wip_entity_id = l_eam_direct_items_rec.wip_entity_id
         and organization_id = l_eam_direct_items_rec.organization_id;
Line: 4501

              OR (l_eam_direct_items_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
                  /*and l_old_eam_direct_items_rec.required_quantity < l_eam_direct_items_rec.required_quantity commented for # 6118897*/)
              OR (l_eam_direct_items_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
                  and nvl(l_old_eam_direct_items_rec.auto_request_material,'N')='N'
                  and nvl(l_eam_direct_items_rec.auto_request_material,'N')='Y')
       ) then

-- query modified for bug# 3691325.

     /*Added Union for #6118897 to avoid duplicate req creation -- start --*/

             l_req_for_cancel_qty_profile := FND_PROFILE.VALUE('EAM_TRIGGER_REQ_CANCEL_QTY');  --bug 13102446
Line: 4523

                        SELECT SUM(nvl(req_qty,0)) INTO l_total_req_qty
                        FROM
                        (SELECT SUM(nvl(pria.quantity,0)) req_qty
                        FROM po_requisitions_interface_all pria
                        WHERE  pria.wip_entity_id =l_eam_direct_items_rec.wip_entity_id
                        AND pria.destination_organization_id = l_eam_direct_items_rec.organization_id
                        AND pria.wip_operation_seq_num = l_eam_direct_items_rec.operation_seq_num
                        AND pria.item_id is null
                        AND pria.wip_resource_seq_num = l_eam_direct_items_rec.direct_item_sequence_id
                        AND ((process_flag is null) or (Upper(Trim(process_flag)) = 'IN PROCESS'))

                        UNION ALL
                        SELECT SUM(nvl(prla.quantity,0)) req_qty
                        FROM po_requisition_lines_all prla , po_requisition_headers_all prha
                        WHERE prla.requisition_header_id = prha.requisition_header_id(+)
                        AND upper(NVL(prha.authorization_status, 'APPROVED') ) not in ('CANCELLED', 'REJECTED','SYSTEM_SAVED')
                        AND UPPER(NVL(prla.cancel_flag,'N')) <> 'Y'
                        AND prla.wip_entity_id =l_eam_direct_items_rec.wip_entity_id
                        AND prla.destination_organization_id = l_eam_direct_items_rec.organization_id
                        AND prla.wip_operation_seq_num = l_eam_direct_items_rec.operation_seq_num
                        AND prla.item_id is null
                        AND prla.wip_resource_seq_num = l_eam_direct_items_rec.direct_item_sequence_id

                        UNION ALL
                        SELECT SUM(nvl(pd.quantity_ordered,0)) req_qty
                        FROM po_distributions_all pd , po_headers_all ph,po_lines_all pl
                        WHERE pd.po_header_id = ph.po_header_id(+)
                        AND upper(NVL(ph.authorization_status, 'APPROVED') ) not in ('CANCELLED', 'REJECTED','SYSTEM_SAVED')
                        AND pd.po_line_id = pl.po_line_id(+)
                        AND UPPER(NVL(pl.cancel_flag,'N')) <> 'Y'
                        AND pd.wip_entity_id = l_eam_direct_items_rec.wip_entity_id
                        AND pd.destination_organization_id = l_eam_direct_items_rec.organization_id
                        AND pd.wip_operation_seq_num = l_eam_direct_items_rec.operation_seq_num
                        AND pl.item_id is null
                        AND pd.wip_resource_seq_num = l_eam_direct_items_rec.direct_item_sequence_id
                        AND pd.line_location_id not in(
	                        SELECT nvl(prla.line_location_id,0)
	                        FROM po_requisition_lines_all prla , po_requisition_headers_all prha
	                        WHERE prla.requisition_header_id = prha.requisition_header_id(+)
	                        AND upper(NVL(prha.authorization_status, 'APPROVED') ) not in ('CANCELLED', 'REJECTED','SYSTEM_SAVED')
	                        AND UPPER(NVL(prla.cancel_flag,'N')) <> 'Y'
	                        AND prla.wip_entity_id =l_eam_direct_items_rec.wip_entity_id
	                        AND prla.destination_organization_id = l_eam_direct_items_rec.organization_id
	                        AND prla.wip_operation_seq_num = l_eam_direct_items_rec.operation_seq_num
	                        AND prla.item_id is null
	                        AND prla.wip_resource_seq_num = l_eam_direct_items_rec.direct_item_sequence_id)
                        );
Line: 4579

                        SELECT SUM(nvl(req_qty,0)) INTO l_total_req_qty
                        FROM
                        (SELECT SUM(nvl(pria.quantity,0)) req_qty
                        FROM po_requisitions_interface_all pria
                        WHERE  pria.wip_entity_id =l_eam_direct_items_rec.wip_entity_id
                        AND pria.destination_organization_id = l_eam_direct_items_rec.organization_id
                        AND pria.wip_operation_seq_num = l_eam_direct_items_rec.operation_seq_num
                        AND pria.item_id is null
                        AND pria.wip_resource_seq_num = l_eam_direct_items_rec.direct_item_sequence_id
                        AND ((process_flag is null) or (Upper(Trim(process_flag)) = 'IN PROCESS'))

                        UNION ALL
                        SELECT SUM(nvl(prla.quantity,0)) req_qty
                        FROM po_requisition_lines_all prla , po_requisition_headers_all prha
                        WHERE prla.requisition_header_id = prha.requisition_header_id(+)
                        AND upper(NVL(prha.authorization_status, 'APPROVED') ) not in ('SYSTEM_SAVED')
                        AND prla.wip_entity_id =l_eam_direct_items_rec.wip_entity_id
                        AND prla.destination_organization_id = l_eam_direct_items_rec.organization_id
                        AND prla.wip_operation_seq_num = l_eam_direct_items_rec.operation_seq_num
                        AND prla.item_id is null
                        AND prla.wip_resource_seq_num = l_eam_direct_items_rec.direct_item_sequence_id

                        UNION ALL
                        SELECT SUM(nvl(pd.quantity_ordered,0)) req_qty
                        FROM po_distributions_all pd , po_headers_all ph,po_lines_all pl
                        WHERE pd.po_header_id = ph.po_header_id(+)
                        AND upper(NVL(ph.authorization_status, 'APPROVED') ) not in ('SYSTEM_SAVED')
                        AND pd.po_line_id = pl.po_line_id(+)
                        AND pd.wip_entity_id = l_eam_direct_items_rec.wip_entity_id
                        AND pd.destination_organization_id = l_eam_direct_items_rec.organization_id
                        AND pd.wip_operation_seq_num = l_eam_direct_items_rec.operation_seq_num
                        AND pl.item_id is null
                        AND pd.wip_resource_seq_num = l_eam_direct_items_rec.direct_item_sequence_id
                        AND pd.line_location_id not in(
                               SELECT nvl(prla.line_location_id,0)
                               FROM po_requisition_lines_all prla , po_requisition_headers_all prha
                               WHERE prla.requisition_header_id = prha.requisition_header_id(+)
                               AND upper(NVL(prha.authorization_status, 'APPROVED') ) not in ('SYSTEM_SAVED')
                               AND prla.wip_entity_id =l_eam_direct_items_rec.wip_entity_id
                               AND prla.destination_organization_id = l_eam_direct_items_rec.organization_id
                               AND prla.wip_operation_seq_num = l_eam_direct_items_rec.operation_seq_num
                               AND prla.item_id is null
                               AND prla.wip_resource_seq_num = l_eam_direct_items_rec.direct_item_sequence_id)
                        );
Line: 5100

        IF l_eam_res_rec.transaction_type IN (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
        THEN

           IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Populate NULL columns') ;
Line: 5306

	        OR (l_eam_res_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_DELETE AND l_eam_res_rec.scheduled_flag=1) --deleted and was scheduled
		OR (l_eam_res_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE AND  --updating the resource
		       (NVL(l_eam_res_rec.schedule_seq_num,l_eam_res_rec.resource_seq_num)<>NVL(l_old_eam_res_rec.schedule_seq_num,l_old_eam_res_rec.resource_seq_num)
		        OR l_eam_res_rec.start_date <> l_old_eam_res_rec.start_date   --shedule_seq_num,start_date,completion_date
			OR l_eam_res_rec.completion_date <> l_old_eam_res_rec.completion_date
			OR l_eam_res_rec.resource_id <> l_old_eam_res_rec.resource_id    --resource_code,usage_rate_or_amount,scheduled_flag,assigned_units
			OR l_eam_res_rec.usage_rate_or_amount <> l_old_eam_res_rec.usage_rate_or_amount
			OR l_eam_res_rec.scheduled_flag <> l_old_eam_res_rec.scheduled_flag
			OR NVL(l_eam_res_rec.assigned_units,0) <> NVL(l_old_eam_res_rec.assigned_units,0))
		    )
		) THEN
		    x_schedule_wo := G_SCHEDULE_WO;
Line: 5326

	    --    OR (l_eam_res_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_DELETE AND l_eam_res_rec.scheduled_flag=1) --deleted and was scheduled
		OR (l_eam_res_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE AND  --updating the resource
		       (
		       --NVL(l_eam_res_rec.schedule_seq_num,l_eam_res_rec.resource_seq_num)<>NVL(l_old_eam_res_rec.schedule_seq_num,l_old_eam_res_rec.resource_seq_num)
		        -- OR
			l_eam_res_rec.start_date <> l_old_eam_res_rec.start_date   --shedule_seq_num,start_date,completion_date
			OR l_eam_res_rec.completion_date <> l_old_eam_res_rec.completion_date
		--	OR l_eam_res_rec.resource_id <> l_old_eam_res_rec.resource_id    --resource_code,usage_rate_or_amount,scheduled_flag,assigned_units
		--	OR l_eam_res_rec.usage_rate_or_amount <> l_old_eam_res_rec.usage_rate_or_amount
		--	OR l_eam_res_rec.scheduled_flag <> l_old_eam_res_rec.scheduled_flag
		--	OR NVL(l_eam_res_rec.assigned_units,0) <> NVL(l_old_eam_res_rec.assigned_units,0)
			)
		    )
		) THEN
		    x_bottomup_scheduled := G_UPDATE_RES_USAGE;
Line: 5918

        IF l_eam_op_rec.transaction_type IN (EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
        THEN

           IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Populate NULL columns') ;
Line: 6106

	    IF (l_eam_op_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE AND
                         (l_eam_op_rec.start_date<>l_old_eam_op_rec.start_date
                           OR l_eam_op_rec.completion_date<>l_old_eam_op_rec.completion_date)) THEN
                       /*bug 12757636 - for CMRO*/
                       BEGIN
                       select source_code into l_source_code
                       from wip_discrete_jobs where wip_entity_id=l_eam_op_rec.wip_entity_id;
Line: 6125

	    IF (l_eam_op_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE AND
                         (l_eam_op_rec.start_date<>l_old_eam_op_rec.start_date
                           OR l_eam_op_rec.completion_date<>l_old_eam_op_rec.completion_date)) THEN
			 --    l_eam_op_rec.start_date := l_old_eam_op_rec.start_date;      --set op dates to prev. dates
Line: 6837

	EAM_ERROR_MESSAGE_PVT.Write_Debug('Transaction Type          : '||p_eam_wo_rec.transaction_type ||' (1:Create / 2:Update / 3:Delete / 4:Complete / 5:UnComplete)');
Line: 7163

                select msn.current_status
                into l_current_status
                from mtl_serial_numbers msn
                where inventory_item_id = nvl(l_eam_wo_rec.rebuild_item_id, l_eam_wo_rec.asset_group_id)
                and serial_number = nvl(l_eam_wo_rec.rebuild_serial_number, l_eam_wo_rec.asset_number);
Line: 7196

       if(p_eam_wo_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE and (l_old_eam_wo_rec.asset_number <> l_eam_wo_rec.asset_number or  l_eam_wo_rec.MAINTENANCE_OBJECT_ID <> l_old_eam_wo_rec.MAINTENANCE_OBJECT_ID)) then

           l_asset_changed :='Y';
Line: 7201

       		SELECT
       	          count(*) into l_count_assetActAssoc
       		FROM
                 mtl_eam_asset_activities meaa
       		WHERE
                 meaa.maintenance_object_type = 3
                 AND  meaa.asset_activity_id = p_eam_wo_rec.asset_activity_id
                 AND  meaa.maintenance_object_id = p_eam_wo_rec.maintenance_object_id;
Line: 7219

           select estimation_status into l_estimation_staus
           from   wip_discrete_jobs
           WHERE wip_entity_id=l_eam_wo_rec.wip_entity_id
           AND organization_id=l_eam_wo_rec.organization_id;
Line: 7236

                             p_delete_only        => 'Y');
Line: 7238

            IF GET_DEBUG = 'Y' THEN    EAM_ERROR_MESSAGE_PVT.Write_Debug('EAM_PROCESS_WO_PVT.WORK_ORDER : After call CSTPECEP.Estimate_WorkOrder_Grp to delete existing estimate. status :' ||l_return_status) ; END IF;
Line: 7243

           Eam_Process_Failure_Entry_PVT.Delete_Failure_Entry
           ( p_api_version                => 1.0,
             p_init_msg_list              => fnd_api.g_false,
             p_commit                     => fnd_api.g_false,
             p_source_id                  => l_eam_wo_rec.wip_entity_id,
             x_return_status              => l_return_status,
             x_msg_count                  => l_msg_count,
             x_msg_data                   => l_err_text
           );
Line: 7256

	      x_material_shortage := G_MATERIAL_UPDATE;
Line: 7259

        IF l_eam_wo_rec.Transaction_Type IN (EAM_PROCESS_WO_PVT.G_OPR_UPDATE)
        THEN

IF GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('EAM_PROCESS_WO_PVT.WORK_ORDER : Populate Null Columns . . .'); END IF;
Line: 7272

		      x_material_shortage := G_MATERIAL_UPDATE;
Line: 7662

           (l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE and
  --fix for 3296919.added following condition so that activity is updateable
            (l_old_eam_wo_rec.asset_activity_id is null OR l_old_eam_wo_rec.asset_activity_id<>l_eam_wo_rec.asset_activity_id)))
        THEN

          IF EAM_OP_UTILITY_PVT.NUM_OF_ROW
             ( p_eam_op_tbl         => l_eam_op_tbl
             , p_wip_entity_id      => p_eam_wo_rec.wip_entity_id
             , p_organization_id    => p_eam_wo_rec.organization_id
             )
          THEN

            l_out_eam_wo_rec            := l_eam_wo_rec;
Line: 7726

IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug (' EAM_PROCESS_WO_PVT.WORK_ORDER : Calling api to update material shortage flag') ; END IF;
Line: 7757

		    OR (l_eam_wo_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE  --workorder updated
			     AND NVL(l_old_eam_wo_rec.pending_flag,'N') = 'N'   --old status is not pending
			     --and old status is not same as new status
		            AND (l_old_eam_wo_rec.status_type <>l_eam_wo_rec.status_type)
			    )
		    ) THEN
		           IF(WF_EVENT.TEST(l_status_pending_event) <> 'NONE') THEN
IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug ('Calling Wkflow required check API...') ; END IF;
Line: 7799

			and l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
			) then
	      select pm_suggested_start_date, pm_suggested_end_date into
		    l_eam_wo_rec.pm_suggested_start_date,
			l_eam_wo_rec.pm_suggested_end_date
			from eam_work_order_details
			where wip_entity_id = l_eam_wo_rec.wip_entity_id;
Line: 7871

	/* Bug # 4926626 : Disable hiearchy if automatic (replaced) rebuild WO is updated
	   with the Asset Number and parent WO is completed */
        IF (l_eam_wo_rec.parent_wip_entity_id IS NOT NULL AND
	    l_eam_wo_rec.manual_rebuild_flag = 'N' AND
	     l_eam_wo_rec.maintenance_object_type = 3 ) THEN

          IF (l_old_eam_wo_rec.maintenance_object_type = 2 AND
	      l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE) THEN

             SELECT serial_number, inventory_item_id, last_vld_organization_id
  	       INTO l_serial_number, l_inv_item_id, l_org_id
	       FROM csi_item_instances
	      WHERE instance_id = l_eam_wo_rec.maintenance_object_id;
Line: 7887

	     wip_eam_genealogy_pvt.update_eam_genealogy
	     (
		p_api_version => 1.0,
		p_object_type => 2,
		p_serial_number => l_serial_number,
		p_inventory_item_id => l_inv_item_id,
		p_organization_id => l_org_id,
		p_genealogy_type => 5,
		p_end_date_active => sysdate,
		x_return_status => l_return_status,
		x_msg_count => l_msg_count,
		x_msg_data => l_msg_data
	     );
Line: 7900

            IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug ('EAM_PROCESS_WO_PVT.WORK_ORDER : Update Genealogy completed with status '||l_return_status) ; END IF;
Line: 7906

	 	  l_other_message := 'EAM_UPDATE_GENEALOGY_FAIL';
Line: 7912

	  IF ((l_old_eam_wo_rec.maintenance_object_type = 2 AND l_eam_wo_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_UPDATE) OR
	        (l_eam_wo_rec.transaction_type=EAM_PROCESS_WO_PVT.G_OPR_CREATE )) THEN

             /* If the parent WO is complete, disable meter hierarchy and IB hierarchy */
	     SELECT status_type INTO l_current_status
	       FROM wip_discrete_jobs
	      WHERE wip_entity_id = l_eam_wo_rec.parent_wip_entity_id;
Line: 8308

   SELECT firm_planned_flag
   INTO l_firm_planned_flag
   FROM WIP_DISCRETE_JOBS
   WHERE wip_entity_id = l_wip_entity_id;
Line: 8318

         x_bottomup_scheduled := G_UPDATE_RES_USAGE;
Line: 8346

		l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_UPDATE and
		((l_eam_wo_rec.asset_activity_id <> l_old_eam_wo_rec.asset_activity_id) or l_old_eam_wo_rec.asset_activity_id is null)
		))
		then
			null ;
Line: 8363

							select
							 l_eam_op_tbl(J).wip_entity_id,
							 l_eam_op_tbl(J).operation_seq_num,
							 bsor.resource_seq_num,
							 bso.organization_id,
							 bsor.LAST_UPDATE_DATE,
							 bsor.LAST_UPDATED_BY,
							 bsor.CREATION_DATE,
							 bsor.CREATED_BY,
							 bsor.LAST_UPDATE_LOGIN,
							 bsor.REQUEST_ID,
							 bsor.PROGRAM_APPLICATION_ID,
							 bsor.PROGRAM_ID,
							 bsor.PROGRAM_UPDATE_DATE,
							 bsor.RESOURCE_ID,
							 br.unit_of_measure,
							 bsor.BASIS_TYPE,
							 bsor.USAGE_RATE_OR_AMOUNT,
							 bsor.ACTIVITY_ID,
							 bsor.SCHEDULE_FLAG,
							 bsor.ASSIGNED_UNITS,
							 DECODE(bsor.autocharge_type,1,2,4,3,2,2,3,3,2) autocharge_type,
							 bsor.STANDARD_RATE_FLAG,
							 0 APPLIED_RESOURCE_UNITS,
							 0 APPLIED_RESOURCE_VALUE,
							 nvl(l_eam_op_tbl(J).start_date,sysdate) start_date,
							 nvl(l_eam_op_tbl(J).completion_date,sysdate) completion_date,
							 bsor.ATTRIBUTE_CATEGORY,
							 bsor.ATTRIBUTE1,
							 bsor.ATTRIBUTE2,
							 bsor.ATTRIBUTE3,
							 bsor.ATTRIBUTE4,
							 bsor.ATTRIBUTE5,
							 bsor.ATTRIBUTE6,
							 bsor.ATTRIBUTE7,
							 bsor.ATTRIBUTE8,
							 bsor.ATTRIBUTE9,
							 bsor.ATTRIBUTE10,
							 bsor.ATTRIBUTE11,
							 bsor.ATTRIBUTE12,
							 bsor.ATTRIBUTE13,
							 bsor.ATTRIBUTE14,
							 bsor.ATTRIBUTE15,
							 bso.DEPARTMENT_ID,
							 decode(bsor.SCHEDULE_FLAG,2,null,bsor.resource_seq_num)  ,
							 bsor.SUBSTITUTE_GROUP_NUM
							 from bom_standard_operations bso,
							      bom_std_op_resources bsor,
							      bom_resources br
							 where bso.standard_operation_id = bsor.standard_operation_id
							 and br.resource_id = bsor.resource_id
							 and bso.standard_operation_id = l_eam_op_tbl(J).standard_operation_id
							 and bso.organization_id = l_eam_op_tbl(J).organization_id;
Line: 8481

							select
							 l_eam_op_tbl(J).wip_entity_id,
							 l_eam_op_tbl(J).operation_seq_num,
							 wor.resource_seq_num,
							 wo.organization_id,
							 wor.LAST_UPDATE_DATE,
							 wor.LAST_UPDATED_BY,
							 wor.CREATION_DATE,
							 wor.CREATED_BY,
							 wor.LAST_UPDATE_LOGIN,
							 wor.REQUEST_ID,
							 wor.PROGRAM_APPLICATION_ID,
							 wor.PROGRAM_ID,
							 wor.PROGRAM_UPDATE_DATE,
							 wor.RESOURCE_ID,
							 br.unit_of_measure,
							 wor.BASIS_TYPE,
							 wor.USAGE_RATE_OR_AMOUNT,
							 wor.ACTIVITY_ID,
							 wor.SCHEDULED_FLAG,
							 wor.ASSIGNED_UNITS,
							 DECODE(wor.autocharge_type,1,2,4,3,2,2,3,3,2) autocharge_type,
							 wor.STANDARD_RATE_FLAG,
							 0 APPLIED_RESOURCE_UNITS,
							 0 APPLIED_RESOURCE_VALUE,
							 nvl(l_eam_op_tbl(J).start_date,sysdate) start_date,
							 nvl(l_eam_op_tbl(J).completion_date,sysdate) completion_date,
							 wor.ATTRIBUTE_CATEGORY,
							 wor.ATTRIBUTE1,
							 wor.ATTRIBUTE2,
							 wor.ATTRIBUTE3,
							 wor.ATTRIBUTE4,
							 wor.ATTRIBUTE5,
							 wor.ATTRIBUTE6,
							 wor.ATTRIBUTE7,
							 wor.ATTRIBUTE8,
							 wor.ATTRIBUTE9,
							 wor.ATTRIBUTE10,
							 wor.ATTRIBUTE11,
							 wor.ATTRIBUTE12,
							 wor.ATTRIBUTE13,
							 wor.ATTRIBUTE14,
							 wor.ATTRIBUTE15,
							 wo.DEPARTMENT_ID,
							 decode(wor.SCHEDULED_FLAG,2,null,wor.resource_seq_num)  ,
							 wor.SUBSTITUTE_GROUP_NUM
							 from wip_operations wo,
							      wip_OPERATION_resources wor,
							      bom_resources br
							 where wo.OPERATION_SEQ_NUM  = wor.OPERATION_SEQ_NUM
							 and br.resource_id = wor.resource_id
							 AND wo.wip_entity_id = wor.wip_entity_id
							 and wo.OPERATION_SEQ_NUM  = l_eam_op_tbl(J).OPERATION_SEQ_NUM
							 and wo.wip_entity_id = l_eam_op_tbl(J).wip_entity_id
							 and wo.organization_id = l_eam_op_tbl(J).organization_id;
Line: 8851

               (l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_UPDATE and
                l_eam_wo_rec.status_type <> l_old_eam_wo_rec.status_type
               )
              ) then
IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('EAM_PROCESS_WO_PVT.WORK_ORDER : Calling Change_Status API') ; END IF ;
Line: 8862

                     (l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE and
                      l_old_eam_wo_rec.status_type <> 3 and l_eam_wo_rec.status_type = 3)
                   )
                THEN

		                      IF(l_eam_wo_rec.date_released IS NULL OR
                                                        l_eam_wo_rec.date_released = FND_API.G_MISS_DATE) THEN

									     /*Bug#4425025 - set date_released to greatest of min open period start date
									      *and scheduled start date if scheduled start date is in past*/

									     IF (l_eam_wo_rec.scheduled_start_date < sysdate)
									     THEN
																	       select nvl(min(period_start_date),l_eam_wo_rec.scheduled_start_date)
																	       into l_min_open_period_date
																	       from org_acct_periods
																	       where organization_id=l_eam_wo_rec.organization_id
																		 and open_flag = 'Y'
																		 and period_close_date is null;
Line: 8888

		                        UPDATE WIP_DISCRETE_JOBS
                                                SET date_released = l_eam_wo_rec.date_released,
                                                         last_update_date = SYSDATE,
                                                         last_updated_by = FND_GLOBAL.User_Id,
                                                         last_update_login = FND_GLOBAL.Login_Id
                                                WHERE wip_entity_id=l_eam_wo_rec.wip_entity_id
                                               AND organization_id=l_eam_wo_rec.organization_id;
Line: 8941

	     (l_eam_wo_rec.transaction_type=EAM_PROCESS_WO_PUB.G_OPR_UPDATE and
	      l_eam_wo_rec.status_type = 3 and
	      ((l_old_eam_wo_rec.date_released is null and l_old_eam_wo_rec.status_type IN (17,6,7)) OR (l_old_eam_wo_rec.status_type=1)))
	     )
	     THEN
			update wip_requirement_operations
			set released_quantity=required_quantity,
			       last_update_date = SYSDATE,
			       last_updated_by = FND_GLOBAL.User_Id,
			       last_update_login = FND_GLOBAL.Login_Id
			where wip_entity_id=l_eam_wo_rec.wip_entity_id
			and organization_id=l_eam_wo_rec.organization_id
			and required_quantity > 0;
Line: 8970

		l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_UPDATE and
		((l_eam_wo_rec.asset_activity_id <> l_old_eam_wo_rec.asset_activity_id) or l_old_eam_wo_rec.asset_activity_id is null)
		))
		then

		x_schedule_wo := G_SCHEDULE_WO;
Line: 8978

	-- if activity is deleted then also scheduler should get call
	if (x_schedule_wo <> G_SCHEDULE_WO and  l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_UPDATE
		 and l_old_eam_wo_rec.asset_activity_id is not null
		 and (l_eam_wo_rec.asset_activity_id is null or l_eam_wo_rec.asset_activity_id = FND_API.G_MISS_NUM)) then
		 x_schedule_wo := G_SCHEDULE_WO;
Line: 8991

				(l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_UPDATE
--				  AND l_eam_wo_rec.status_type <> 6    --status not equal to on-hold
				  AND
				  ((l_eam_wo_rec.requested_start_date IS NULL AND l_old_eam_wo_rec.requested_start_date IS NOT NULL) --changing from forward to backward sched
				   OR (l_eam_wo_rec.requested_start_date IS NOT NULL AND l_old_eam_wo_rec.requested_start_date IS NULL) --changing from b/w to f/w sched
				   OR l_eam_wo_rec.requested_start_date <> l_old_eam_wo_rec.requested_start_date  --changing dates
				   OR l_eam_wo_rec.due_date <> l_old_eam_wo_rec.due_date
				   OR l_eam_wo_rec.scheduled_start_date <> l_old_eam_wo_rec.scheduled_start_date
				   OR l_eam_wo_rec.scheduled_completion_date <> l_old_eam_wo_rec.scheduled_completion_date
				   OR (l_eam_wo_rec.firm_planned_flag=1 AND l_old_eam_wo_rec.firm_planned_flag=2 ))  --changing from firm to non-firm
				)) THEN
				     x_bottomup_scheduled := G_BU_SCHEDULE_WO;
Line: 9009

            IF(l_eam_wo_rec.transaction_type=EAM_PROCESS_WO_PUB.G_OPR_UPDATE AND
	    --if changing status to cancelled,complete-no-chrg,close do not call scheduler
	        (l_eam_wo_rec.status_type IN (7,5,12,14,15)) AND (l_old_eam_wo_rec.status_type <> l_eam_wo_rec.status_type)) THEN
                        NULL;
Line: 9013

	    ELSIF(l_eam_wo_rec.transaction_type=EAM_PROCESS_WO_PUB.G_OPR_UPDATE AND
	     --if changing status from on-hold,cancelled,complete-no-chrg,close to something else .call scheduler
	        (l_old_eam_wo_rec.status_type IN (6,7,5,12,14,15)) AND (l_eam_wo_rec.status_type NOT IN (6,7,5,12,14,15))) THEN
		   x_schedule_wo := G_SCHEDULE_WO;
Line: 9020

				(l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PUB.G_OPR_UPDATE
				  --AND l_eam_wo_rec.status_type <> 6    --status not equal to on-hold
				  AND
				  ((l_eam_wo_rec.requested_start_date IS NULL AND l_old_eam_wo_rec.requested_start_date IS NOT NULL) --changing from forward to backward sched
				   OR (l_eam_wo_rec.requested_start_date IS NOT NULL AND l_old_eam_wo_rec.requested_start_date IS NULL) --changing from b/w to f/w sched
				   OR l_eam_wo_rec.requested_start_date <> l_old_eam_wo_rec.requested_start_date  --changing dates
				   OR l_eam_wo_rec.due_date <> l_old_eam_wo_rec.due_date
				   OR l_eam_wo_rec.scheduled_start_date <> l_old_eam_wo_rec.scheduled_start_date
				   OR l_eam_wo_rec.scheduled_completion_date <> l_old_eam_wo_rec.scheduled_completion_date
				   OR (l_eam_wo_rec.firm_planned_flag=2 AND l_old_eam_wo_rec.firm_planned_flag=1 ))  --changing from firm to non-firm
				)) THEN
				     x_schedule_wo := G_SCHEDULE_WO;   --3521842
Line: 9046

        select 1
		into l_count
		from wip_operations
		where wip_entity_id =  l_eam_wo_rec.wip_entity_id
		and department_id is null;
Line: 9058

		   		select count(*)
		   		into l_count
		   		from wip_eam_parameters
		   		where organization_id = l_eam_wo_rec.organization_id
		   		and default_department_id is null;
Line: 9075

                                                UPDATE WIP_DISCRETE_JOBS
                                                SET estimation_status = 2,
                                                         last_update_date = SYSDATE,
                                                         last_updated_by = FND_GLOBAL.User_Id,
                                                         last_update_login = FND_GLOBAL.Login_Id
                                                WHERE wip_entity_id=l_eam_wo_rec.wip_entity_id
                                               AND organization_id=l_eam_wo_rec.organization_id;
Line: 9416

		UPDATE_RES_USAGE_BU_ERR      EXCEPTION;
Line: 9455

        SELECT    start_date,
                  completion_date,
                  operation_seq_num,
                  resource_seq_num
        FROM      wip_operation_resources
        WHERE      wip_entity_id = c_wip_entity_id;
Line: 9466

		l_wkorder_old_op_tbl.delete;
Line: 9467

		l_wkorder_old_op_dt_tbl.delete;
Line: 9469

		l_wkorder_new_op_tbl.delete;
Line: 9470

		l_wkorder_new_op_dt_tbl.delete;
Line: 9493

        IF l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE THEN
			  EAM_WO_UTILITY_PVT.Query_Row
			  ( p_wip_entity_id       => p_eam_wo_rec.wip_entity_id
			  , p_organization_id     => p_eam_wo_rec.organization_id
			  , x_eam_wo_rec          => l_old_eam_wo_rec
			  , x_Return_status       => l_return_status
			  );
Line: 9533

		if l_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE then
				l_wip_entity_id   := l_eam_wo_rec.wip_entity_id;
Line: 9544

				select SCHEDULED_START_DATE into l_wo_old_sch_start_date
				from wip_discrete_jobs
				where wip_entity_id = l_wip_entity_id;
Line: 9566

				select operation_seq_num,first_unit_start_date
				bulk collect into l_wkorder_old_op_tbl,l_wkorder_old_op_dt_tbl
				from wip_operations
				where  organization_id = l_organization_id
				and  wip_entity_id = l_wip_entity_id ;
Line: 9693

                                          SELECT	Min(start_date), Max(completion_date)
                                          INTO l_min_res_usg_start_date,l_max_res_usg_compl_date
				                                  FROM	wip_operation_resources
				                                  WHERE	wip_entity_id = l_eam_res_inst_tbl( l_res_inst_usage_tbl_index ).WIP_ENTITY_ID
				                                  AND	operation_seq_num = l_eam_res_inst_tbl( l_res_inst_usage_tbl_index ).operation_seq_num
				                                  AND	organization_id = l_eam_res_inst_tbl( l_res_inst_usage_tbl_index ).ORGANIZATION_ID
				                                  AND	resource_seq_num = l_eam_res_inst_tbl( l_res_inst_usage_tbl_index ).resource_seq_num ;
Line: 9723

						IF l_material_shortage = G_MATERIAL_UPDATE THEN
								IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('EAM_PROCESS_WO_PVT.PROCESS_WO :Calling the Check_Shortage procedure for materials'); END IF;
Line: 9736

										select material_shortage_check_date,
										material_shortage_flag
										into l_eam_wo_rec.material_shortage_check_date ,
										l_eam_wo_rec.material_shortage_flag
										from EAM_WORK_ORDER_DETAILS
										where wip_entity_id = l_eam_wo_rec.wip_entity_id;
Line: 9777

				ELSE IF    l_bottomup_scheduled IN ( G_BU_SCHEDULE_WO, G_UPDATE_RES_USAGE ) THEN

						IF ( l_bottomup_scheduled = G_UPDATE_RES_USAGE ) THEN
								l_out_eam_res_tbl           := l_eam_res_tbl;
Line: 9784

								IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('EAM_PROCESS_WO_PVT.PROCESS_WO :Calling update_resource_usage for firm work orders') ; END IF ;
Line: 9786

								EAM_SCHED_BOTTOM_UP_PVT.update_resource_usage(
										p_eam_res_tbl		=> l_eam_res_tbl
										, p_eam_res_inst_tbl    => l_eam_res_inst_tbl
										, p_eam_res_usage_tbl   => l_eam_res_usage_tbl
										, x_eam_res_tbl		=> l_out_eam_res_tbl
										, x_eam_res_usage_tbl   => l_out_eam_res_usage_tbl
										, x_eam_res_inst_tbl    => l_out_eam_res_inst_tbl
										, x_return_status       => l_return_status
										, x_message_name	=> l_err_text
										) ;
Line: 9798

									EAM_ERROR_MESSAGE_PVT.Write_Debug('EAM_PROCESS_WO_PVT.PROCESS_WO : update_resource_usage for firm work orders returned status is ' || l_return_status ) ;
Line: 9803

										RAISE UPDATE_RES_USAGE_BU_ERR;
Line: 9839

				--Added parameter p_woru_modified to the procedure. This is done to ensure that dates are changed correctly from summary tab in Create Update WO page

						EAM_SCHED_BOTTOM_UP_PVT.schedule_bottom_up_pvt (
								p_api_version_number    => 1.0
								, p_commit		   => FND_API.G_FALSE
								, p_wip_entity_id         => l_eam_wo_rec.wip_entity_id
								, p_org_id                => l_eam_wo_rec.organization_id
								, p_woru_modified         => l_woru_modified
								, x_return_status         => l_return_status
								, x_message_name	   => l_err_text
						) ;
Line: 9950

		IF((l_scheduled=G_SCHEDULE_WO) OR (l_bottomup_scheduled IN ( G_BU_SCHEDULE_WO, G_UPDATE_RES_USAGE ))
		OR (l_eam_res_tbl.COUNT > 0) OR (l_eam_res_usage_tbl.COUNT > 0) OR (l_eam_res_inst_tbl.COUNT > 0)
		) THEN
				l_emp_assignment := TRUE;
Line: 9960

				Update eam_work_order_details
				set  ASSIGNMENT_COMPLETE = EAM_ASSIGN_EMP_PUB.Get_Emp_Assignment_Status(l_eam_wo_rec.wip_entity_id,l_eam_wo_rec.organization_id)
				where wip_entity_id = l_eam_wo_rec.wip_entity_id;
Line: 10085

		IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('EAM_PROCESS_WO_PVT.PROCESS_WO : enters inside update'); END IF;
Line: 10086

		UPDATE_DATES(l_eam_wo_rec,
				l_eam_op_tbl,
				l_eam_res_tbl,
				l_eam_res_inst_tbl);
Line: 10104

						select operation_seq_num,first_unit_start_date
								bulk collect into l_wkorder_new_op_tbl,l_wkorder_new_op_dt_tbl
								from wip_operations
								where  organization_id = l_organization_id
								and  wip_entity_id = l_wip_entity_id;
Line: 10122

																update WIP_REQUIREMENT_OPERATIONS
																set date_required = date_required + no_of_days
																where organization_id = l_organization_id
																and wip_entity_id = l_wip_entity_id
																and operation_seq_num = l_wkorder_old_op_tbl(ii);
Line: 10135

										update WIP_REQUIREMENT_OPERATIONS
										set date_required = l_wkorder_new_op_dt_tbl(jj)
										where organization_id = l_organization_id
										and wip_entity_id = l_wip_entity_id
										and operation_seq_num = l_wkorder_new_op_tbl(jj);
Line: 10147

						select SCHEDULED_START_DATE into l_wo_new_sch_start_date
						from wip_discrete_jobs
						where wip_entity_id = l_wip_entity_id;
Line: 10153

						update wip_requirement_operations
						set date_required = date_required + (l_wo_new_sch_start_date-l_wo_old_sch_start_date)
						where operation_seq_num = 1
						and organization_id = l_organization_id
						and wip_entity_id = l_wip_entity_id ;
Line: 10165

                                                   UPDATE        wip_op_resource_instances
                                                   SET        start_date = c_opresource_rec.start_date,
                                                           completion_date=c_opresource_rec.completion_date
                                                   WHERE        wip_entity_id = l_wip_entity_id
                                                   AND        operation_seq_num = c_opresource_rec.operation_seq_num
                                                   AND        resource_seq_num = c_opresource_rec.resource_seq_num;
Line: 10272

										and l_out_eam_mat_req_tbl(kk).transaction_type = EAM_PROCESS_WO_PVT.G_OPR_DELETE
										THEN
										EAM_MATERIALISSUE_PVT.cancel_alloc_matl_del
										(
												p_api_version           => 1.0,
												p_init_msg_list         => fnd_api.g_false,
												p_commit                => fnd_api.g_false,
												p_validation_level      => fnd_api.g_valid_level_full,
												p_wip_entity_id         => l_out_eam_mat_req_tbl(kk).wip_entity_id,
												p_operation_seq_num     => l_out_eam_mat_req_tbl(kk).operation_seq_num,
												p_inventory_item_id     => l_out_eam_mat_req_tbl(kk).inventory_item_id,
												p_wip_entity_type       => WIP_CONSTANTS.EAM,
												p_repetitive_schedule_id => null,
												x_return_status         => l_return_status,
												x_msg_data              => l_err_text,
												x_msg_count             => l_msg_count
										);
Line: 10295

				IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling UPDATE_INTERMEDIA_INDEX'); END IF;
Line: 10297

				IF(l_eam_wo_rec.maintenance_object_source =1 ) THEN   --update intermedia index only for EAM workorders
				UPDATE_INTERMEDIA_INDEX
				(
						l_eam_wo_rec,
						l_old_eam_wo_rec,
						l_eam_op_tbl,
						l_eam_res_tbl,
						l_eam_res_inst_tbl
				);
Line: 10543

WHEN UPDATE_RES_USAGE_BU_ERR THEN

     l_token_tbl(1).token_name  := 'WORK_ORDER_NAME';
Line: 10780

    SELECT wip_entity_name into l_token_tbl(1).token_value
	 FROM  WIP_ENTITIES we
	 WHERE we.wip_entity_id = l_eam_wo_rec.wip_entity_id
	 AND   we.organization_id = l_eam_wo_rec.organization_id;
Line: 10863

    SELECT wip_entity_name into l_token_tbl(1).token_value
	 FROM  WIP_ENTITIES we
	 WHERE we.wip_entity_id = l_eam_wo_rec.wip_entity_id
	 AND   we.organization_id = l_eam_wo_rec.organization_id;
Line: 11217

        AND NVL(p_transaction_type, FND_API.G_MISS_NUM) NOT IN (EAM_PROCESS_WO_PVT.G_OPR_SYNC, EAM_PROCESS_WO_PVT.G_OPR_CREATE, EAM_PROCESS_WO_PVT.G_OPR_UPDATE)
       )
       OR
       (p_entity_name IN ('OPERATION','OPERATION_RESOURCE','RESOURCE_INSTANCE','SUB_RESOURCE','DIRECT_ITEMS','MATERIAL_REQUIREMENTS')
        AND NVL(p_transaction_type, FND_API.G_MISS_NUM) NOT IN (EAM_PROCESS_WO_PVT.G_OPR_SYNC, EAM_PROCESS_WO_PVT.G_OPR_CREATE, EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
       )
       OR
       (p_entity_name IN ('OPERATION_NETWORK', 'RESOURCE_USAGE')
        AND NVL(p_transaction_type, FND_API.G_MISS_NUM) NOT IN (EAM_PROCESS_WO_PVT.G_OPR_CREATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
       )
       OR
       (p_entity_name IN ('WORK_ORDER_COMPLETEION','OPERATION_COMPLETEION')
        AND NVL(p_transaction_type, FND_API.G_MISS_NUM) NOT IN (EAM_PROCESS_WO_PVT.G_OPR_COMPLETE, EAM_PROCESS_WO_PVT.G_OPR_UNCOMPLETE)
	)
       OR
       (p_entity_name IN ('QUALITY_ENTRY','METER_READING')
        AND NVL(p_transaction_type, FND_API.G_MISS_NUM) NOT IN (EAM_PROCESS_WO_PVT.G_OPR_CREATE)
	)
       OR
       (p_entity_name IN ('WORK_ORDER_COMPL_REBUILD','W_ORDER_COMPL_METER_READING')
        AND NVL(p_transaction_type, FND_API.G_MISS_NUM) NOT IN (EAM_PROCESS_WO_PVT.G_OPR_UPDATE)
        )
       OR
       (p_entity_name IN ('WORK_SERVICE_REQUEST')
        AND NVL(p_transaction_type, FND_API.G_MISS_NUM) NOT IN (EAM_PROCESS_WO_PVT.G_OPR_CREATE,EAM_PROCESS_WO_PVT.G_OPR_UPDATE)
	)

    THEN

        IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
        THEN
            IF p_entity_name = 'WORK_ORDER'
            THEN
                l_out_mesg_token_tbl  := l_mesg_token_tbl;
Line: 11419

PROCEDURE UPDATE_DATES
        (x_eam_wo_rec IN OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_rec_type,
	 x_eam_op_tbl IN OUT NOCOPY EAM_PROCESS_WO_PUB.eam_op_tbl_type,
	 x_eam_res_tbl IN OUT NOCOPY EAM_PROCESS_WO_PUB.eam_res_tbl_type,
	 x_eam_res_inst_tbl IN OUT NOCOPY EAM_PROCESS_WO_PUB.eam_res_inst_tbl_type
)
IS
CURSOR operations
(l_wip_entity_id NUMBER,l_org_id NUMBER,l_op_seq_num NUMBER)
IS
   SELECT first_unit_start_date,
          last_unit_completion_date
   FROM wip_operations
   WHERE wip_entity_id=l_wip_entity_id
   AND organization_id=l_org_id
   AND operation_seq_num=l_op_seq_num;
Line: 11441

   SELECT start_date,
          completion_date
   FROM wip_operation_resources
   WHERE wip_entity_id=l_wip_entity_id
   AND organization_id=l_org_id
   AND operation_seq_num=l_op_seq_num
   AND resource_seq_num=l_res_seq_num;
Line: 11454

   SELECT start_date,
          completion_date
   FROM wip_op_resource_instances
   WHERE wip_entity_id=l_wip_entity_id
   AND organization_id=l_org_id
   AND operation_seq_num=l_op_seq_num
   AND resource_seq_num=l_res_seq_num
   AND instance_id=l_instance_id
   AND serial_number(+)=l_serial_number;
Line: 11472

IF(x_eam_wo_rec.TRANSACTION_TYPE IN (EAM_PROCESS_WO_PUB.G_OPR_CREATE,EAM_PROCESS_WO_PUB.G_OPR_UPDATE)) THEN
   SELECT scheduled_start_date,scheduled_completion_date
   INTO l_start_date,l_completion_date
   FROM WIP_DISCRETE_JOBS
   WHERE wip_entity_id=x_eam_wo_rec.wip_entity_id
   AND organization_id=x_eam_wo_rec.organization_id;
Line: 11488

       IF( x_eam_op_tbl(i).TRANSACTION_TYPE IN (EAM_PROCESS_WO_PUB.G_OPR_CREATE,EAM_PROCESS_WO_PUB.G_OPR_UPDATE)) THEN
              OPEN operations(x_eam_wo_rec.wip_entity_id,x_eam_wo_rec.organization_id
			     ,x_eam_op_tbl(i).operation_seq_num);
Line: 11513

      IF( x_eam_res_tbl(i).TRANSACTION_TYPE IN (EAM_PROCESS_WO_PUB.G_OPR_CREATE,EAM_PROCESS_WO_PUB.G_OPR_UPDATE)) THEN
              OPEN resources(x_eam_wo_rec.wip_entity_id,x_eam_wo_rec.organization_id
			     ,x_eam_res_tbl(i).operation_seq_num,x_eam_res_tbl(i).resource_seq_num);
Line: 11537

        IF( x_eam_res_inst_tbl(i).TRANSACTION_TYPE IN (EAM_PROCESS_WO_PUB.G_OPR_CREATE,EAM_PROCESS_WO_PUB.G_OPR_UPDATE)) THEN
              OPEN resource_instances(x_eam_wo_rec.wip_entity_id,x_eam_wo_rec.organization_id
			     ,x_eam_res_inst_tbl(i).operation_seq_num,x_eam_res_inst_tbl(i).resource_seq_num
			     ,x_eam_res_inst_tbl(i).instance_id,x_eam_res_inst_tbl(i).serial_number);
Line: 11561

END UPDATE_DATES;
Line: 11667

	l_wo_last_update_date1      DATE;  -- for FP bug of 10147896
Line: 11668

	l_wo_last_update_date2      DATE;  -- for FP bug of 10147896
Line: 11678

	SELECT  cii.inventory_item_id,
	        cii.instance_number,
		cii.instance_id,
		cii.serial_number,
		wdj.primary_item_id,
		wdj.maintenance_object_type,
		wdj.maintenance_object_id,
		wdj.maintenance_object_source,
                NVL(ewod.pending_flag,'N'),
		ewod.user_defined_status_id,
		wdj.status_type,
		ewod.workflow_type,
		eam_linear_location_id,
		owning_department
	  FROM  wip_discrete_jobs wdj,csi_item_instances cii,eam_work_order_details ewod
	 WHERE  wdj.wip_entity_id = l_eam_wo_comp_rec.wip_entity_id
	   AND  wdj.maintenance_object_type = 3
	   AND  wdj.maintenance_object_id = cii.instance_id
	   AND  wdj.wip_entity_id = ewod.wip_entity_id(+)
	 UNION
        SELECT  wdj.maintenance_object_id,
		null,
		null,
		null,
		wdj.primary_item_id,
		wdj.maintenance_object_type,
		wdj.maintenance_object_id,
		wdj.maintenance_object_source,
                NVL(ewod.pending_flag,'N'),
		ewod.user_defined_status_id,
		wdj.status_type,
		ewod.workflow_type,
		eam_linear_location_id,
		owning_department
	  FROM  wip_discrete_jobs wdj,eam_work_order_details ewod
	 WHERE  wdj.wip_entity_id = l_eam_wo_comp_rec.wip_entity_id
	   AND  wdj.maintenance_object_type = 2
	   AND  wdj.wip_entity_id = ewod.wip_entity_id(+);
Line: 11736

		SELECT wip_entity_name INTO l_wip_entity_name
		  FROM wip_entities
		 WHERE wip_entity_id = l_eam_wo_comp_rec.wip_entity_id;
Line: 11743

		-- for FP bug of bug# 10147896, Capturing WO last_update_date at starting of COMP_UNCOMP_WORKORDER procedure.
		SELECT last_update_date INTO l_wo_last_update_date1 FROM wip_discrete_jobs WHERE wip_entity_id = l_wip_entity_id FOR UPDATE;
Line: 11766

		SELECT msi.concatenated_segments
		   INTO l_asset_group_name
	           FROM mtl_system_items_kfv msi
		  WHERE msi.inventory_item_id = l_asset_group_id
		   AND rownum = 1;
Line: 11773

	  	  SELECT msi.concatenated_segments
		   INTO l_asset_activity
	           FROM mtl_system_items_kfv msi
		  WHERE msi.inventory_item_id = l_asset_activity_id
		   AND rownum = 1;
Line: 11901

								   UPDATE EAM_WORK_ORDER_DETAILS
								   SET user_defined_status_id=3,
									    pending_flag='Y',
									    last_update_date=SYSDATE,
									    last_update_login=FND_GLOBAL.login_id,
									    last_updated_by=FND_GLOBAL.user_id
								   WHERE wip_entity_id= l_eam_wo_comp_rec.wip_entity_id;
Line: 11913

												 SELECT NVL((SUM(system_estimated_mat_cost) + SUM(system_estimated_lab_cost) + SUM(system_estimated_eqp_cost)),0)
												 INTO l_cost_estimate
												 FROM WIP_EAM_PERIOD_BALANCES
												 WHERE wip_entity_id = l_eam_wo_comp_rec.wip_entity_id;
Line: 11923

										      SELECT EAM_WORKFLOW_EVENT_S.NEXTVAL
										      INTO l_wf_event_seq
										      FROM DUAL;
Line: 11933

		IF GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Inserting into EAM_WO_WORKFLOWS ...');  END IF;
Line: 11934

										     INSERT INTO EAM_WO_WORKFLOWS
										     (WIP_ENTITY_ID,WF_ITEM_TYPE,WF_ITEM_KEY,LAST_UPDATE_DATE,LAST_UPDATED_BY,
										     CREATION_DATE,CREATED_BY,LAST_UPDATE_LOGIN)
										     VALUES
										     (l_eam_wo_comp_rec.wip_entity_id,l_workflow_name,l_event_key,SYSDATE,FND_GLOBAL.user_id,
										     SYSDATE,FND_GLOBAL.user_id,FND_GLOBAL.login_id
										     );
Line: 11986

										    l_parameter_list.DELETE;
Line: 11994

														  p_event  => 'UPDATE',
														  p_wip_entity_id =>l_eam_wo_comp_rec.wip_entity_id,
														  p_organization_id =>l_eam_wo_comp_rec.organization_id,
														  p_last_update_date  => SYSDATE,
														  p_last_updated_by  => FND_GLOBAL.user_id,
														  p_last_update_login =>FND_GLOBAL.login_id
													     );
Line: 12008

		--Invoke Update_Pm_When_Uncomplete to reverse last service dates and last service reading if this is the last work order
		--This should be called before Perform_Writes as the logic to calculate if this is the last work order or not will not work if record
		-- will be inserted into Eam_Job_Completion_Txns for uncompletion transaction.
		IF l_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UNCOMPLETE THEN
			   if( l_maint_obj_source = 1) then -- added to check whether work order is of 'EAM' or 'CRMO'.'EAM=1'
			           eam_pm_utils.update_pm_when_uncomplete(l_eam_wo_comp_rec.organization_id, l_eam_wo_comp_rec.wip_entity_id);
Line: 12017

	-- for FP bug of bug# 10147896, Capturing WO last_update_date just before Writing WO Completion record to database .
		SELECT last_update_date INTO l_wo_last_update_date2  FROM wip_discrete_jobs WHERE wip_entity_id = l_wip_entity_id FOR UPDATE;
Line: 12020

	 IF  l_wo_last_update_date1 <> l_wo_last_update_date2
		  THEN
		l_other_message := 'EAM_WO_COMP_WRONG_STATUS';
Line: 12044

		IF GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling WO Completion update_row ...');  END IF;
Line: 12046

		 EAM_WO_COMP_UTILITY_PVT.update_row
		(   p_eam_wo_comp_rec       => l_eam_wo_comp_rec
		,   x_Mesg_Token_Tbl        => l_Mesg_Token_Tbl
		,   x_return_status         => l_return_status
		 );
Line: 12155

			IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Quality : Insert_Row...') ; END IF ;
Line: 12157

			 EAM_WO_QUA_UTILITY_PVT.insert_row
			   (
				   p_collection_id	=> colllection_id_temp
				 , p_eam_wo_quality_tbl  => p_eam_wo_quality_tbl
				 , x_eam_wo_quality_tbl  => l_eam_wo_quality_tbl
				 , x_return_status       => l_return_status
				 , x_mesg_token_tbl      => l_mesg_token_tbl
			   );
Line: 12166

					l_other_message := 'EAM_WOCMP_QA_INSERT_REC';
Line: 12205

	            END ; -- END For Quality Insert row
Line: 12214

				SELECT  cii.instance_number,cii.instance_id
				  into l_asset_instance_number,
				  l_asset_instance_id
				  FROM  wip_discrete_jobs wdj,csi_item_instances cii
				 WHERE  wdj.wip_entity_id = l_eam_wo_comp_rec.wip_entity_id
				   AND  wdj.maintenance_object_type = 3
				   AND  wdj.maintenance_object_id = cii.instance_id
				   AND  cii.serial_number = l_asset_number;
Line: 12291

               l_eam_failure_codes_tbl(i).transaction_type:= Eam_Process_Failure_Entry_PUB.G_FE_UPDATE;
Line: 12301

              l_eam_failure_codes_tbl.delete(i);
Line: 12308

                SELECT OWNING_DEPARTMENT_ID
                  INTO l_department_id
                  FROM eam_org_maint_defaults
                 WHERE object_id = l_maint_object_id
		   AND object_type = 60 AND organization_id = l_org_id ;
Line: 12322

                SELECT area_id
                  INTO l_eam_location_id
                  FROM eam_org_maint_defaults
                 WHERE object_id = l_maint_object_id
		   AND object_type = 60 AND organization_id = l_org_id ;
Line: 12352

             l_eam_failure_entry_record.transaction_type := Eam_Process_Failure_Entry_PUB.G_FE_UPDATE;
Line: 12398

			select qp.plan_id,name bulk collect
			into  l_plan_id_tbl,l_plan_name_tbl
			from qa_results qr,qa_plans qp
			where qr.plan_id = qp.plan_id
			and collection_id = l_eam_wo_comp_rec.qa_collection_id;
Line: 12472

			IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling EAM_METERREADING_VALIDATE_PVT.insert_row procedure...') ; END IF ;
Line: 12473

			EAM_METERREADING_UTILITY_PVT.INSERT_ROW
			(
				 p_eam_meter_reading_tbl  => p_eam_meter_reading_tbl
				, p_eam_counter_prop_tbl  => p_eam_counter_prop_tbl
				, x_eam_meter_reading_tbl => x_eam_meter_reading_tbl
				, x_eam_counter_prop_tbl  => x_eam_counter_prop_tbl
				, x_return_status         => l_return_status
				, x_mesg_token_tbl	  => l_mesg_token_tbl
			);
Line: 12535

			IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling AM_METERREADING_UTILITY_PVT.Update_Genealogy procedure...') ; END IF ;
Line: 12536

			EAM_METERREADING_UTILITY_PVT.UPDATE_GENEALOGY
			(
				p_eam_wo_comp_rebuild_tbl => p_eam_wo_comp_rebuild_tbl ,
				x_eam_wo_comp_rebuild_tbl => x_eam_wo_comp_rebuild_tbl ,
				x_return_status           => l_return_status ,
				x_mesg_token_tbl	  => l_mesg_token_tbl
			);
Line: 12545

					l_other_message := 'EAM_WOCMPL_UPDATE_GEN';
Line: 12551

			IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling AM_METERREADING_UTILITY_PVT.UPDATE_REBUILD_WORK_ORDER procedure...') ; END IF ;
Line: 12552

			EAM_METERREADING_UTILITY_PVT.UPDATE_REBUILD_WORK_ORDER
			(
				p_eam_wo_comp_rebuild_tbl => p_eam_wo_comp_rebuild_tbl ,
				x_eam_wo_comp_rebuild_tbl => x_eam_wo_comp_rebuild_tbl ,
				x_return_status           => l_return_status ,
				x_mesg_token_tbl	  => l_mesg_token_tbl
			);
Line: 12560

					l_other_message := 'EAM_WOCMPL_UPDATE_WORK';
Line: 12567

			IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling EAM_METERREADING_UTILITY_PVT.UPDATE_ACTIVITY procedure...') ; END IF ;
Line: 12568

			EAM_METERREADING_UTILITY_PVT.UPDATE_ACTIVITY
			(
				p_eam_wo_comp_rebuild_tbl => p_eam_wo_comp_rebuild_tbl ,
				x_eam_wo_comp_rebuild_tbl => x_eam_wo_comp_rebuild_tbl ,
				x_return_status           => l_return_status ,
				x_mesg_token_tbl	  => l_mesg_token_tbl
			);
Line: 12576

					l_other_message := 'EAM_WOCMPL_UPDATE_ACT';
Line: 12601

		/* -- For work order completeion call Eam_Meters_util. Update_Last_Service_Reading_Dates

		IF l_eam_wo_comp_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_COMPLETE  AND	p_eam_meter_reading_tbl.COUNT > 0 THEN

			IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling EAM_METERREADING_UTILITY_PVT.UPDATE_LAST_SERVICE_READING procedure...') ; END IF ;
Line: 12606

			EAM_METERREADING_UTILITY_PVT.UPDATE_LAST_SERVICE_READING
			(
			   p_eam_meter_reading_tbl   => p_eam_meter_reading_tbl
			 , x_eam_meter_reading_tbl   => x_eam_meter_reading_tbl
			 , x_return_status           => l_return_status
			 , x_mesg_token_tbl          => l_mesg_token_tbl
			);
Line: 12654

			select qp.plan_id,name bulk collect into l_plan_id_tbl,l_plan_name_tbl
			from qa_results qr,qa_plans qp
			where qr.plan_id = qp.plan_id
			and collection_id = l_eam_wo_comp_rec.qa_collection_id;
Line: 12661

			IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling EAM_ASSET_LOG_PVT.INSERT_ROW procedure...') ; END IF ;
Line: 12662

					EAM_ASSET_LOG_PVT.INSERT_ROW
					 (
						p_api_version		=> 1.0,
						p_event_date		=> sysdate,
						p_event_type		=> 'EAM_SYSTEM_EVENTS',
						p_event_id		=> 12,
						p_organization_id	=> l_eam_wo_comp_rec.organization_id,
						p_instance_id		=> l_maint_object_id,
						p_comments		=> null,
						p_reference		=> l_plan_name_tbl(N),
						p_ref_id		=> l_plan_id_tbl(N),
						p_operable_flag		=> null,
						p_reason_code		=> null,
						x_return_status		=> l_asset_ops_return_status,
						x_msg_count		=> l_asset_ops_msg_count,
						x_msg_data		=> l_asset_ops_msg_data
					 );
Line: 12689

										      SELECT EAM_WORKFLOW_EVENT_S.NEXTVAL
										      INTO l_wf_event_seq
										      FROM DUAL;
Line: 12731

										    l_parameter_list.DELETE;
Line: 12739

														  p_event  => 'UPDATE',
														  p_wip_entity_id =>l_eam_wo_comp_rec.wip_entity_id,
														  p_organization_id =>l_eam_wo_comp_rec.organization_id,
														  p_last_update_date  => SYSDATE,
														  p_last_updated_by  => FND_GLOBAL.user_id,
														  p_last_update_login =>FND_GLOBAL.login_id
													     );
Line: 12750

			IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling EAM_ASSET_LOG_PVT.INSERT_ROW procedure...') ; END IF ;
Line: 12751

			 EAM_ASSET_LOG_PVT.INSERT_ROW
				 (
					p_api_version		=> 1.0,
					p_event_date		=> sysdate,
					p_event_type		=> 'EAM_SYSTEM_EVENTS',
					p_event_id		=> 8,
					p_organization_id	=> l_eam_wo_comp_rec.organization_id,
					p_instance_id		=> l_maint_object_id,
					p_comments		=> null,
					p_reference		=> l_wip_entity_name,
					p_ref_id		=> l_eam_wo_comp_rec.wip_entity_id,
					p_operable_flag		=> null,
					p_reason_code		=> null,
					x_return_status		=> l_asset_ops_return_status,
					x_msg_count		=> l_asset_ops_msg_count,
					x_msg_data		=> l_asset_ops_msg_data
				 );
Line: 12769

			IF EAM_PROCESS_WO_PVT.Get_Debug = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Calling EAM_ASSET_LOG_PVT.INSERT_ROW procedure...') ; END IF ;
Line: 12770

			 EAM_ASSET_LOG_PVT.INSERT_ROW
				 (
					p_api_version		=> 1.0,
					p_event_date		=> sysdate,
					p_event_type		=> 'EAM_SYSTEM_EVENTS',
					p_event_id		=> 9,
					p_organization_id	=> l_eam_wo_comp_rec.organization_id,
					p_instance_id		=> l_maint_object_id,
					p_comments		=> null,
					p_reference		=> l_wip_entity_name,
					p_ref_id		=> l_eam_wo_comp_rec.wip_entity_id,
					p_operable_flag		=> null,
					p_reason_code		=> null,
					x_return_status		=> l_asset_ops_return_status,
					x_msg_count		=> l_asset_ops_msg_count,
					x_msg_data		=> l_asset_ops_msg_data
				 );
Line: 12798

     select system_status into i_status_type
	   from eam_wo_statuses_V
	   where status_id = p_eam_wo_comp_rec.user_status_id
	   and enabled_flag = 'Y';
Line: 12972

	SELECT wip_entity_name INTO l_wip_entity_name
	  FROM wip_entities
	 WHERE wip_entity_id = l_eam_op_comp_rec.wip_entity_id;
Line: 12976

	SELECT nvl(wdj.asset_group_id,wdj.rebuild_item_id),
	       nvl(wdj.asset_number,wdj.rebuild_serial_number),
	       wdj.primary_item_id,
	       wdj.maintenance_object_source,
               ewod.workflow_type
	  INTO l_asset_group_id,
	       l_asset_number,
	       l_asset_activity_id,
	       l_maint_obj_source,
	       l_workflow_type
          FROM wip_discrete_jobs wdj,eam_work_order_details ewod
	 WHERE wdj.wip_entity_id = l_eam_op_comp_rec.wip_entity_id
	   AND wdj.wip_entity_id = ewod.wip_entity_id(+);
Line: 12990

	SELECT msi.concatenated_segments
	   INTO l_asset_group_name
           FROM mtl_system_items_kfv msi
	  WHERE msi.inventory_item_id = l_asset_group_id
	   AND rownum = 1;
Line: 12996

  	  SELECT msi.concatenated_segments
	   INTO l_asset_activity
           FROM mtl_system_items_kfv msi
	  WHERE msi.inventory_item_id = l_asset_activity_id
	   AND rownum = 1;
Line: 13166

				   IF GET_DEBUG = 'Y' THEN EAM_ERROR_MESSAGE_PVT.Write_Debug('Operation Completeion validating Quality Record Insert Row . . .'); END IF;
Line: 13167

				   EAM_WO_QUA_UTILITY_PVT.insert_row
				   (
					   p_collection_id	=> colllection_id_temp
					 , p_eam_wo_quality_tbl  => p_eam_wo_quality_tbl
					 , x_eam_wo_quality_tbl  => l_eam_wo_quality_temp_tbl
					 , x_return_status       => l_return_status
					 , x_mesg_token_tbl      => l_mesg_token_tbl
				  );
Line: 13179

					l_other_message := 'EAM_OP_QUAINSERT_CSEV_SKIP';
Line: 13192

				SELECT  cii.instance_number,cii.instance_id into l_asset_instance_number,
				  l_asset_instance_id
				  FROM  wip_discrete_jobs wdj,csi_item_instances cii
				 WHERE  wdj.wip_entity_id = l_eam_op_comp_rec.wip_entity_id
				   AND  wdj.maintenance_object_type = 3
				   AND  wdj.maintenance_object_id = cii.instance_id
				   AND  cii.serial_number = l_asset_number;
Line: 13298

			                                                            SELECT last_unit_completion_date
										    INTO l_op_sched_end_date
										    FROM WIP_OPERATIONS
										    WHERE wip_entity_id= l_eam_op_comp_rec.wip_entity_id
										    AND operation_seq_num = l_eam_op_comp_rec.operation_seq_num;
Line: 13305

										    select DECODE(count(won.next_operation),0,'Y','N')
										    INTO l_is_last_operation
										    from wip_operation_networks won
										    where won.wip_entity_id =  l_eam_op_comp_rec.wip_entity_id and
										    won.prior_operation = l_eam_op_comp_rec.operation_seq_num;
Line: 13311

										      SELECT EAM_WORKFLOW_EVENT_S.NEXTVAL
										      INTO l_wf_event_seq
										      FROM DUAL;
Line: 13348

										    l_parameter_list.DELETE;
Line: 13532

				EAM_REQUEST_UTILITY_PVT.INSERT_ROW
				(  p_eam_request_rec   => l_eam_request_rec
				 , x_return_status     => l_return_status
				 , x_mesg_token_tbl    => l_mesg_token_tbl
				 );
Line: 13539

			IF l_eam_request_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE THEN
				EAM_REQUEST_UTILITY_PVT.DELETE_ROW
				(  p_eam_request_rec   => l_eam_request_rec
				 , x_return_status     => l_return_status
				 , x_mesg_token_tbl    => l_mesg_token_tbl
				 );
Line: 13550

					l_other_message := 'EAM_WR_INSERT_REC';