The following lines contain the word 'select', 'insert', 'update' or 'delete':
* transaction type is Update and the record
* does not exist then the return status would be an
* error as well. Mesg_Token_Table will carry the
* error messsage and the tokens associated with the
* message.
*********************************************************************/
PROCEDURE Check_Existence
( p_eam_wo_rec IN EAM_PROCESS_WO_PUB.eam_wo_rec_type
, x_old_eam_wo_rec OUT NOCOPY EAM_PROCESS_WO_PUB.eam_wo_rec_type
, x_Mesg_Token_Tbl OUT NOCOPY EAM_ERROR_MESSAGE_PVT.Mesg_Token_Tbl_Type
, x_return_status OUT NOCOPY VARCHAR2
)
IS
l_token_tbl EAM_ERROR_MESSAGE_PVT.Token_Tbl_Type;
(EAM_PROCESS_WO_PVT.G_OPR_UPDATE, EAM_PROCESS_WO_PVT.G_OPR_DELETE)
THEN
l_token_tbl(1).token_name := 'WIP_ENTITY_NAME';
x_old_eam_wo_rec.transaction_type := EAM_PROCESS_WO_PVT.G_OPR_UPDATE;
select 1
into g_dummy
from mtl_parameters mp
where mp.organization_id = p_eam_wo_rec.organization_id;
select nvl(hou.date_to,sysdate+1)
into l_disable_date
from hr_organization_units hou
where organization_id = p_eam_wo_rec.organization_id;
select 1
into g_dummy
from wip_eam_parameters wep, mtl_parameters mp
where wep.organization_id = mp.organization_id
and mp.eam_enabled_flag = 'Y'
and wep.organization_id = p_eam_wo_rec.organization_id;
select 1 into g_dummy from
mfg_lookups where lookup_type = g_obj_source
and lookup_code = p_eam_wo_rec.maintenance_object_source;
select 1 into g_dummy from
mfg_lookups where lookup_type = g_obj_type
and lookup_code = p_eam_wo_rec.maintenance_object_type;
select maintenance_object_id into l_old_eam_wo_moid
from wip_discrete_jobs
where wip_entity_id = p_eam_wo_rec.wip_entity_id
and organization_id = p_eam_wo_rec.organization_id
and rownum = 1;
select 1 into g_dummy
from csi_item_instances cii, mtl_parameters mp
where cii.last_vld_organization_id = mp.organization_id
and mp.maint_organization_id = p_eam_wo_rec.organization_id
and cii.instance_id = p_eam_wo_rec.maintenance_object_id
and cii.inventory_item_id = nvl(p_eam_wo_rec.asset_group_id, p_eam_wo_rec.rebuild_item_id)
and rownum = 1;
select 1 into g_dummy from mtl_system_items msi, mtl_parameters mp where
msi.organization_id = mp.organization_id
and mp.maint_organization_id = p_eam_wo_rec.organization_id
and msi.inventory_item_id = p_eam_wo_rec.maintenance_object_id
and rownum = 1;
select 1 into g_dummy from mtl_system_items where
organization_id = p_eam_wo_rec.organization_id
and inventory_item_id = p_eam_wo_rec.maintenance_object_id;
select 1
into g_dummy
from mtl_parameters mp
where mp.organization_id = p_eam_wo_rec.organization_id;
select nvl(hou.date_to,sysdate+1)
into l_disable_date
from hr_organization_units hou
where organization_id = p_eam_wo_rec.organization_id;
select 1
into g_dummy
from wip_eam_parameters wep, mtl_parameters mp
where wep.organization_id = mp.organization_id
and mp.eam_enabled_flag = 'Y'
and wep.organization_id = p_eam_wo_rec.organization_id;
select 1
into g_dummy
from mfg_lookups
where lookup_type = g_obj_type
and lookup_code = p_eam_wo_rec.maintenance_object_type;
select 1 into g_dummy
from csi_item_instances cii, mtl_parameters mp
where cii.last_vld_organization_id = mp.organization_id
and mp.maint_organization_id = p_eam_wo_rec.organization_id
and cii.instance_id = p_eam_wo_rec.maintenance_object_id;
select 1
into g_dummy
from mtl_system_items msi, mtl_parameters mp
where msi.organization_id = mp.organization_id
and mp.maint_organization_id = p_eam_wo_rec.organization_id
and inventory_item_id = p_eam_wo_rec.maintenance_object_id
and rownum = 1;
select 1
into g_dummy
from mtl_system_items
where organization_id = p_eam_wo_rec.organization_id
and inventory_item_id = p_eam_wo_rec.maintenance_object_id;
select 1
into g_dummy
from mtl_system_items msi, csi_item_instances cii, mtl_parameters mp
where cii.inventory_item_id = p_eam_wo_rec.asset_group_id
and cii.inventory_item_id = msi.inventory_item_id
and cii.last_vld_organization_id = mp.organization_id
and msi.organization_id = mp.organization_id
and mp.maint_organization_id = p_eam_wo_rec.organization_id
and cii.serial_number = p_eam_wo_rec.asset_number
and msi.eam_item_type = 1
and ROWNUM =1 ;
if (p_eam_wo_rec.transaction_type in (EAM_PROCESS_WO_PVT.G_OPR_CREATE,EAM_PROCESS_WO_PVT.G_OPR_UPDATE) and p_eam_wo_rec.asset_number is not null) then
/* In update mode do not check the current maintenance organization*/
select 1
into g_dummy
from csi_item_instances cii
where cii.inventory_item_id = p_eam_wo_rec.asset_group_id
and cii.serial_number = p_eam_wo_rec.asset_number
and nvl(cii.maintainable_flag, 'Y') = 'Y'
and nvl(cii.active_start_date, sysdate-1) <= sysdate
and nvl(cii.active_end_date, sysdate+1) >= sysdate ;
EAM_PROCESS_WO_PVT.G_OPR_UPDATE)
and p_eam_wo_rec.eam_linear_location_id is not null) then
select 1
into g_dummy
from eam_linear_locations
where eam_linear_id = p_eam_wo_rec.eam_linear_location_id;
select 1
into g_dummy
from mtl_system_items msi, mtl_parameters mp
where msi.inventory_item_id = p_eam_wo_rec.rebuild_item_id
and msi.organization_id = mp.organization_id
and mp.maint_organization_id = p_eam_wo_rec.organization_id
and msi.eam_item_type = 3
and rownum = 1;
select 1
into g_dummy
from csi_item_instances cii, mtl_parameters mp
where cii.inventory_item_id = p_eam_wo_rec.rebuild_item_id
and cii.last_vld_organization_id = mp.organization_id
and mp.maint_organization_id = p_eam_wo_rec.organization_id
and cii.serial_number = p_eam_wo_rec.rebuild_serial_number
and nvl(cii.maintainable_flag, 'Y') = 'Y'
and nvl(cii.active_start_date, sysdate-1) <= sysdate
and nvl(cii.active_end_date, sysdate+1) >= sysdate;
updateable if the WO is in status Released */
/***** Enahancement No. : 2943473 ******/
IF ( p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
and p_eam_wo_rec.rebuild_item_id is not null
and p_eam_wo_rec.rebuild_serial_number is not null
and nvl(p_old_eam_wo_rec.rebuild_serial_number,'null_old_serial_number') <>
nvl(p_eam_wo_rec.rebuild_serial_number,'null_old_serial_number') )
THEN
IF ( p_eam_wo_rec.status_type = WIP_CONSTANTS.RELEASED
and p_old_eam_wo_rec.status_type = WIP_CONSTANTS.RELEASED )
THEN
EAM_WORKORDER_UTIL_PKG.CK_MATERIAL_ALLOC_ON_HOLD(X_Org_Id => p_eam_wo_rec.organization_id,
X_Wip_Id => p_eam_wo_rec.wip_entity_id,
X_Rep_Id => -1,
X_Line_Id => -1,
X_Ent_Type=> 6,
X_Return_Status=>l_trans_exist);
select serial_number_control_code
into g_dummy
from mtl_system_items msi, mtl_parameters mp
where msi.inventory_item_id = p_eam_wo_rec.rebuild_item_id
and msi.organization_id = mp.organization_id
and mp.maint_organization_id = p_eam_wo_rec.organization_id and rownum = 1;
SELECT 1
INTO g_dummy
FROM mtl_object_genealogy mog, mtl_serial_numbers msn, wip_discrete_jobs wdj,
mtl_serial_numbers msn1, csi_item_instances cii, mtl_parameters mp, csi_item_instances cii1
WHERE p_eam_wo_rec.rebuild_item_id is not null
and cii.instance_id = p_eam_wo_rec.maintenance_object_id
and cii.last_vld_organization_id = mp.organization_id
and mp.maint_organization_id = p_eam_wo_rec.organization_id
and nvl(cii.network_asset_flag,'N') = 'N'
and msn.current_organization_id = cii.last_vld_organization_id
and msn.serial_number = cii.serial_number
and msn.inventory_item_id = cii.inventory_item_id
and mog.object_id = msn.gen_object_id
and mog.parent_object_id = msn1.gen_object_id
and msn1.current_organization_id = mp.organization_id
and cii1.serial_number = msn1.serial_number
and cii1.inventory_item_id = msn1.inventory_item_id
and cii1.last_vld_organization_id = msn1.current_organization_id
and cii1.instance_id = wdj.maintenance_object_id
and wdj.maintenance_object_type=3
and wdj.status_type not in (5,12,14)
and wdj.wip_entity_id = p_eam_wo_rec.parent_wip_entity_id
and wdj.organization_id = p_eam_wo_rec.organization_id
and mog.genealogy_type = 5
and nvl(mog.start_date_active,sysdate) <= sysdate
and nvl(mog.end_date_active,sysdate+1) > sysdate ;
SELECT 1 INTO
g_dummy
FROM wip_discrete_jobs
WHERE
p_eam_wo_rec.rebuild_item_id is not null
and organization_id = p_eam_wo_rec.organization_id
and wip_entity_id = p_eam_wo_rec.parent_wip_entity_id
and status_type not in (5,12,14);
IF ( p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
AND p_old_eam_wo_rec.parent_wip_entity_id <> p_eam_wo_rec.parent_wip_entity_id )
THEN
EAM_WORKORDER_UTIL_PKG.CK_MATERIAL_ALLOC_ON_HOLD(X_Org_Id => p_eam_wo_rec.organization_id,
X_Wip_Id => p_eam_wo_rec.wip_entity_id,
X_Rep_Id => -1,
X_Line_Id => -1,
X_Ent_Type=> 6,
X_Return_Status=>l_trans_exist);
select count(*)
into l_count
from wip_entities
where wip_entity_name = p_eam_wo_rec.wip_entity_name
and organization_id = p_eam_wo_rec.organization_id;
select count(*)
into l_count
from wip_entities
where wip_entity_id = p_eam_wo_rec.wip_entity_id;
select 1
into g_dummy
from wip_schedule_groups_val_v
where schedule_group_id = p_eam_wo_rec.schedule_group_id
and organization_id = p_eam_wo_rec.organization_id;
IF ( p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE )
AND (p_eam_wo_rec.status_type IN (5,7,12,14,15)) --if status is complete-no-chrg,cancelled,closed,pending-close and failed-close
AND (p_eam_wo_rec.status_type=p_old_eam_wo_rec.status_type) --status is same
AND ( p_eam_wo_rec.description<>p_old_eam_wo_rec.description
OR p_eam_wo_rec.asset_number<>p_old_eam_wo_rec.asset_number
OR p_eam_wo_rec.asset_group_id<>p_old_eam_wo_rec.asset_group_id
OR p_eam_wo_rec.rebuild_item_id<>p_old_eam_wo_rec.rebuild_item_id
OR p_eam_wo_rec.rebuild_serial_number<>p_old_eam_wo_rec.rebuild_serial_number
OR p_eam_wo_rec.maintenance_object_id<>p_old_eam_wo_rec.maintenance_object_id
OR p_eam_wo_rec.maintenance_object_type<>p_old_eam_wo_rec.maintenance_object_type
OR p_eam_wo_rec.maintenance_object_source<>p_old_eam_wo_rec.maintenance_object_source
OR p_eam_wo_rec.eam_linear_location_id<>p_old_eam_wo_rec.eam_linear_location_id
OR p_eam_wo_rec.notification_required<>p_old_eam_wo_rec.notification_required
OR p_eam_wo_rec.class_code<>p_old_eam_wo_rec.class_code
OR p_eam_wo_rec.asset_activity_id<>p_old_eam_wo_rec.asset_activity_id
OR p_eam_wo_rec.activity_type<>p_old_eam_wo_rec.activity_type
OR p_eam_wo_rec.activity_source<>p_old_eam_wo_rec.activity_source
OR p_eam_wo_rec.activity_cause<>p_old_eam_wo_rec.activity_cause
OR p_eam_wo_rec.work_order_type<>p_old_eam_wo_rec.work_order_type
OR p_eam_wo_rec.status_type<>p_old_eam_wo_rec.status_type
OR p_eam_wo_rec.job_quantity<>p_old_eam_wo_rec.job_quantity
OR p_eam_wo_rec.date_released<>p_old_eam_wo_rec.date_released
OR p_eam_wo_rec.owning_department<>p_old_eam_wo_rec.owning_department
OR p_eam_wo_rec.priority<>p_old_eam_wo_rec.priority
OR p_eam_wo_rec.requested_start_date<>p_old_eam_wo_rec.requested_start_date
OR p_eam_wo_rec.due_date<>p_old_eam_wo_rec.due_date
OR p_eam_wo_rec.shutdown_type<>p_old_eam_wo_rec.shutdown_type
OR p_eam_wo_rec.firm_planned_flag<>p_old_eam_wo_rec.firm_planned_flag
OR p_eam_wo_rec.tagout_required<>p_old_eam_wo_rec.tagout_required
OR p_eam_wo_rec.plan_maintenance<>p_old_eam_wo_rec.plan_maintenance
OR p_eam_wo_rec.project_id<>p_old_eam_wo_rec.project_id
OR p_eam_wo_rec.task_id<>p_old_eam_wo_rec.task_id
OR p_eam_wo_rec.end_item_unit_number<>p_old_eam_wo_rec.end_item_unit_number
OR p_eam_wo_rec.schedule_group_id<>p_old_eam_wo_rec.schedule_group_id
OR p_eam_wo_rec.bom_revision_date<>p_old_eam_wo_rec.bom_revision_date
OR p_eam_wo_rec.routing_revision_date<>p_old_eam_wo_rec.routing_revision_date
OR p_eam_wo_rec.alternate_bom_designator<>p_old_eam_wo_rec.alternate_bom_designator
OR p_eam_wo_rec.alternate_routing_designator<>p_old_eam_wo_rec.alternate_routing_designator
OR p_eam_wo_rec.bom_revision<>p_old_eam_wo_rec.bom_revision
OR p_eam_wo_rec.routing_revision<>p_old_eam_wo_rec.routing_revision
OR p_eam_wo_rec.parent_wip_entity_id<>p_old_eam_wo_rec.parent_wip_entity_id
OR p_eam_wo_rec.manual_rebuild_flag<>p_old_eam_wo_rec.manual_rebuild_flag
OR p_eam_wo_rec.pm_schedule_id<>p_old_eam_wo_rec.pm_schedule_id
OR p_eam_wo_rec.wip_supply_type<>p_old_eam_wo_rec.wip_supply_type
OR p_eam_wo_rec.material_account<>p_old_eam_wo_rec.material_account
OR p_eam_wo_rec.material_overhead_account<>p_old_eam_wo_rec.material_overhead_account
OR p_eam_wo_rec.resource_account<>p_old_eam_wo_rec.resource_account
OR p_eam_wo_rec.outside_processing_account<>p_old_eam_wo_rec.outside_processing_account
OR p_eam_wo_rec.material_variance_account<>p_old_eam_wo_rec.material_variance_account
OR p_eam_wo_rec.resource_variance_account<>p_old_eam_wo_rec.resource_variance_account
OR p_eam_wo_rec.outside_proc_variance_account<>p_old_eam_wo_rec.outside_proc_variance_account
OR p_eam_wo_rec.std_cost_adjustment_account<>p_old_eam_wo_rec.std_cost_adjustment_account
OR p_eam_wo_rec.overhead_account<>p_old_eam_wo_rec.overhead_account
OR p_eam_wo_rec.overhead_variance_account<>p_old_eam_wo_rec.overhead_variance_account
OR p_eam_wo_rec.scheduled_start_date<>p_old_eam_wo_rec.scheduled_start_date
OR p_eam_wo_rec.scheduled_completion_date<>p_old_eam_wo_rec.scheduled_completion_date
OR p_eam_wo_rec.common_bom_sequence_id<>p_old_eam_wo_rec.common_bom_sequence_id
OR p_eam_wo_rec.common_routing_sequence_id<>p_old_eam_wo_rec.common_routing_sequence_id
OR p_eam_wo_rec.po_creation_time<>p_old_eam_wo_rec.po_creation_time
OR p_eam_wo_rec.gen_object_id<>p_old_eam_wo_rec.gen_object_id
OR p_eam_wo_rec.attribute_category<>p_old_eam_wo_rec.attribute_category
OR p_eam_wo_rec.attribute1<>p_old_eam_wo_rec.attribute1
OR p_eam_wo_rec.attribute2<>p_old_eam_wo_rec.attribute2
OR p_eam_wo_rec.attribute3<>p_old_eam_wo_rec.attribute3
OR p_eam_wo_rec.attribute4<>p_old_eam_wo_rec.attribute4
OR p_eam_wo_rec.attribute5<>p_old_eam_wo_rec.attribute5
OR p_eam_wo_rec.attribute6<>p_old_eam_wo_rec.attribute6
OR p_eam_wo_rec.attribute7<>p_old_eam_wo_rec.attribute7
OR p_eam_wo_rec.attribute8<>p_old_eam_wo_rec.attribute8
OR p_eam_wo_rec.attribute9<>p_old_eam_wo_rec.attribute9
OR p_eam_wo_rec.attribute10<>p_old_eam_wo_rec.attribute10
OR p_eam_wo_rec.attribute11<>p_old_eam_wo_rec.attribute11
OR p_eam_wo_rec.attribute12<>p_old_eam_wo_rec.attribute12
OR p_eam_wo_rec.attribute13<>p_old_eam_wo_rec.attribute13
OR p_eam_wo_rec.attribute14<>p_old_eam_wo_rec.attribute14
OR p_eam_wo_rec.attribute15<>p_old_eam_wo_rec.attribute15
OR p_eam_wo_rec.material_issue_by_mo<>p_old_eam_wo_rec.material_issue_by_mo
OR p_eam_wo_rec.issue_zero_cost_flag<>p_old_eam_wo_rec.issue_zero_cost_flag
) THEN
raise fnd_api.g_exc_unexpected_error;
elsif (p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE) then
if(p_eam_wo_rec.status_type not in (wip_constants.unreleased, wip_constants.released, wip_constants.comp_chrg,wip_constants.comp_nochrg, wip_constants.closed,
wip_constants.hold, wip_constants.cancelled, wip_constants.pend_sched, wip_constants.draft)
OR ( p_eam_wo_rec.status_type in (wip_constants.draft) and p_old_eam_wo_rec.status_type not in (wip_constants.draft))
/* Added the check so that status will not be updated to status Draft */
--fix for 3389850.cannot change status from complete_no_charges to any status other than complete,closed.cannot change to complete_no_charges from status other than
--complete
OR (p_old_eam_wo_rec.status_type=wip_constants.comp_nochrg AND p_eam_wo_rec.status_type NOT IN (wip_constants.comp_chrg,wip_constants.closed,wip_constants.comp_nochrg) )
/* Bug 3431204 - Should be able to link a Complete No charges WO to another
Complete NO Charges WO */
OR (p_eam_wo_rec.status_type=wip_constants.comp_nochrg
AND p_old_eam_wo_rec.status_type NOT IN
(wip_constants.comp_chrg, wip_constants.comp_nochrg,wip_constants.closed,wip_constants.fail_close))) then
raise fnd_api.g_exc_unexpected_error;
select 1
into g_dummy
from mtl_system_items
where organization_id = p_eam_wo_rec.organization_id
and inventory_item_id = p_eam_wo_rec.asset_activity_id
and eam_item_type = 2;
select count(*) into l_mat_req_exists from wip_requirement_operations
where wip_entity_id = p_eam_wo_rec.wip_entity_id
and organization_id = p_eam_wo_rec.organization_id;
and p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
and (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) = false
or l_mat_req_exists <> 0) then
raise fnd_api.g_exc_unexpected_error;
( p_message_name => 'EAM_CANT_UPDATE_ACTIVITY'
, p_token_tbl => l_token_tbl
, p_mesg_token_tbl => l_mesg_token_tbl
, x_mesg_token_tbl => l_out_mesg_token_tbl
);
select meaa.start_date_active, meaa.end_date_active
into l_start_date, l_end_date
from mtl_eam_asset_activities meaa, mtl_system_items msi
where meaa.asset_activity_id = p_eam_wo_rec.asset_activity_id
and meaa.maintenance_object_type = 3
and nvl(meaa.tmpl_flag, 'N') = 'N'
and meaa.maintenance_object_id = p_eam_wo_rec.maintenance_object_id
and msi.inventory_item_id = p_eam_wo_rec.asset_activity_id
and msi.organization_id = p_eam_wo_rec.organization_id;
select min(meaa.start_date_active), min(meaa.end_date_active)
into l_start_date, l_end_date
from mtl_eam_asset_activities meaa,mtl_system_items msi
where meaa.asset_activity_id = p_eam_wo_rec.asset_activity_id
and meaa.maintenance_object_type = 2
and meaa.maintenance_object_id = p_eam_wo_rec.maintenance_object_id
and msi.organization_id = p_eam_wo_rec.organization_id
and msi.inventory_item_id = p_eam_wo_rec.asset_activity_id
and nvl(meaa.tmpl_flag, 'N') = 'N';
select 1
into g_dummy
from bom_routing_alternates_v
where assembly_item_id = p_eam_wo_rec.asset_activity_id
and alternate_routing_designator = p_eam_wo_rec.alternate_routing_designator
and organization_id = p_eam_wo_rec.organization_id
and routing_type = 1;
select 1
into g_dummy
from bom_bill_alternates_v
where assembly_item_id = p_eam_wo_rec.asset_activity_id
and alternate_bom_designator = p_eam_wo_rec.alternate_bom_designator
and organization_id = p_eam_wo_rec.organization_id
and assembly_type = 1;
SELECT distinct mpv.project_id --this query will return multiple rows if the project has tasks
INTO g_dummy
FROM mtl_project_v mpv, pjm_project_parameters_v ppp, mtl_parameters mp
WHERE mpv.project_id = ppp.project_id
AND mpv.project_id = p_eam_wo_rec.project_id
AND ppp.organization_id = p_eam_wo_rec.organization_id
AND ppp.organization_id = mp.organization_id
AND nvl(mp.project_reference_enabled, 2) = wip_constants.yes
/* Commented for bug#5346213 Start
AND (mpv.completion_date IS NULL OR mpv.completion_date >= l_min_date)
AND (ppp.end_date_active IS NULL OR ppp.end_date_active >= l_min_date);
SELECT 1
INTO g_dummy
FROM pjm_tasks_v
WHERE project_id = p_eam_wo_rec.project_id
AND task_id = p_eam_wo_rec.task_id;
SELECT 1
INTO g_dummy
FROM pjm_tasks_v
WHERE project_id = p_eam_wo_rec.project_id
AND task_id = p_eam_wo_rec.task_id
/* AND (completion_date IS NULL OR completion_date >= l_min_date); Commented for bug#5346213 */
select 1
into g_dummy
from bom_calendar_dates bcd, mtl_parameters mp
where mp.organization_id = p_eam_wo_rec.organization_id
and mp.calendar_code = bcd.calendar_code
and mp.calendar_exception_set_id = bcd.exception_set_id
and bcd.calendar_date = trunc(p_eam_wo_rec.requested_start_date);
select 1
into g_dummy
from bom_calendar_dates bcd, mtl_parameters mp
where mp.organization_id = p_eam_wo_rec.organization_id
and mp.calendar_code = bcd.calendar_code
and mp.calendar_exception_set_id = bcd.exception_set_id
and bcd.calendar_date = trunc(p_eam_wo_rec.due_date);
select 1
into g_dummy
from pjm_unit_numbers_lov_v pun,
mtl_parameters mp
where pun.unit_number = p_eam_wo_rec.end_item_unit_number
and mp.organization_id = p_eam_wo_rec.organization_id
and mp.master_organization_id = pun.master_organization_id;
select disable_date
into l_disable_date
from wip_accounting_classes
where class_code = p_eam_wo_rec.class_code
and class_type = wip_constants.eam
and organization_id = p_eam_wo_rec.organization_id;
select count(*)
into l_count
from bom_operational_routings
where assembly_item_id = p_eam_wo_rec.asset_activity_id
and organization_id = p_eam_wo_rec.organization_id
and nvl(alternate_routing_designator, '@@') = nvl(p_eam_wo_rec.alternate_routing_designator, '@@');
select disable_date
into l_disable_date
from bom_departments
where department_id = p_eam_wo_rec.owning_department
and organization_id = p_eam_wo_rec.organization_id;
SELECT bd.department_code into l_token_tbl(1).token_value
FROM bom_departments bd
WHERE bd.DEPARTMENT_ID = p_eam_wo_rec.owning_department
AND bd.organization_id = p_eam_wo_rec.organization_id;
select 1
into g_dummy
from mfg_lookups
where lookup_type = g_shutdown_type
and lookup_code = p_eam_wo_rec.shutdown_type
and enabled_flag = 'Y';
select 1
into g_dummy
from mfg_lookups
where lookup_type = g_wo_type
and lookup_code = p_eam_wo_rec.work_order_type
and enabled_flag = 'Y';
select 1
into g_dummy
from mfg_lookups
where lookup_type = g_act_type
and lookup_code = p_eam_wo_rec.activity_type
and enabled_flag = 'Y';
select 1
into g_dummy
from mfg_lookups
where lookup_type = g_act_cause
and lookup_code = p_eam_wo_rec.activity_cause
and enabled_flag = 'Y';
select 1
into g_dummy
from mfg_lookups
where lookup_type = g_act_source
and lookup_code = p_eam_wo_rec.activity_source
and enabled_flag = 'Y';
select nvl(min(period_start_date),p_eam_wo_rec.scheduled_start_date)
into l_min_open_period_date
from org_acct_periods
where organization_id=p_eam_wo_rec.organization_id
and open_flag = 'Y'
and period_close_date is null;
select 1
into g_dummy
from org_acct_periods
where organization_id = p_eam_wo_rec.organization_id
and trunc(l_date_released_calc)
between period_start_date and schedule_close_date
and period_close_date is NULL;
select 1
into g_dummy
from mfg_lookups
where lookup_type = g_obj_source
and lookup_code = p_eam_wo_rec.maintenance_object_source;
select 1
into g_dummy
from fnd_user
where user_id = p_eam_wo_rec.user_id;
select 1
into g_dummy
from fnd_responsibility
where responsibility_id = p_eam_wo_rec.responsibility_id;
SELECT enabled_flag
INTO l_enabled_flag
FROM EAM_WO_STATUSES_B
WHERE status_id = p_eam_wo_rec.user_defined_status_id;
if p_eam_wo_rec.transaction_type = EAM_PROCESS_WO_PVT.G_OPR_UPDATE
and p_eam_wo_rec.status_type not in (WIP_CONSTANTS.DRAFT,WIP_CONSTANTS.UNRELEASED) /* Bug no 3349197 */
and not(p_eam_wo_rec.status_type=WIP_CONSTANTS.RELEASED and (p_old_eam_wo_rec.status_type IN (WIP_CONSTANTS.DRAFT,WIP_CONSTANTS.UNRELEASED,WIP_CONSTANTS.CANCELLED))) /*Bug No 3476156*/
and p_eam_wo_rec.material_issue_by_mo <> p_old_eam_wo_rec.material_issue_by_mo then
IF EAM_PROCESS_WO_PVT.GET_DEBUG = 'Y' THEN
EAM_ERROR_MESSAGE_PVT.Write_Debug('Validating material_issue_by_mo flag . .wip_entity_id' || p_eam_wo_rec.wip_entity_id);