CREATE OR REPLACE PROCEDURE APPS.CLC_MTL_RESERVATIONS_PRG (
errbuf OUT VARCHAR2,
retcode OUT NUMBER,
p_org_code VARCHAR2
)
AS
l_rsv_old inv_reservation_global.mtl_reservation_rec_type;
l_rsv_new inv_reservation_global.mtl_reservation_rec_type;
l_msg_count NUMBER;
l_msg_data VARCHAR2 (4000);
l_rsv_id NUMBER;
l_dummy_sn inv_reservation_global.serial_number_tbl_type;
l_status VARCHAR2 (1);
l_quantity_reserved NUMBER;
l_cnt number :=0;
l_err number :=0;
v_err_msg varchar2(4000);
cursor c_resv (l_org_code number)is
select ooha.order_number,oola.header_id, oola.line_id, msi.segment1,--mr.RESERVATION_ID,mr.ORGANIZATION_ID--,wdd.RELEASED_STATUS
mr.reservation_id
, mr.requirement_date
, mr.organization_id
, mr.inventory_item_id
, mr.demand_source_type_id
, mr.demand_source_name
, mr.demand_source_header_id
, mr.demand_source_line_id
, mr.demand_source_delivery
, mr.primary_uom_code
, mr.primary_uom_id
, mr.secondary_uom_code
, mr.secondary_uom_id
, mr.reservation_uom_code
, mr.reservation_uom_id
, mr.reservation_quantity
, mr.primary_reservation_quantity
, mr.secondary_reservation_quantity
, mr.detailed_quantity
, mr.secondary_detailed_quantity
, mr.autodetail_group_id
, mr.external_source_code
, mr.external_source_line_id
, mr.supply_source_type_id
, mr.supply_source_header_id
, mr.supply_source_line_id
, mr.supply_source_name
, mr.supply_source_line_detail
, mr.revision
, mr.subinventory_code
, mr.subinventory_id
, mr.locator_id
, mr.lot_number
, mr.lot_number_id
, mr.pick_slip_number
, mr.lpn_id
, mr.attribute_category
, mr.attribute1
, mr.attribute2
, mr.attribute3
, mr.attribute4
, mr.attribute5
, mr.attribute6
, mr.attribute7
, mr.attribute8
, mr.attribute9
, mr.attribute10
, mr.attribute11
, mr.attribute12
, mr.attribute13
, mr.attribute14
, mr.attribute15
, mr.ship_ready_flag
, mr.staged_flag
, mr.crossdock_flag
, mr.crossdock_criteria_id
, mr.demand_source_line_detail
, mr.serial_reservation_quantity
, mr.supply_receipt_date
, mr.demand_ship_date
, mr.project_id
, mr.task_id
, mr.orig_supply_source_type_id
, mr.orig_supply_source_header_id
, mr.orig_supply_source_line_id
, mr.orig_supply_source_line_detail
, mr.orig_demand_source_type_id
, mr.orig_demand_source_header_id
, mr.orig_demand_source_line_id
, mr.orig_demand_source_line_detail
, mr.serial_number
from MTL_RESERVATIONS mr,
oe_order_lines_all oola,
oe_order_headers_all ooha,
mtl_system_items_b msi
--wsh_delivery_details wdd
where
ooha.header_id =oola.header_id
and ooha.org_id =oola.org_id
and oola.line_id = mr.DEMAND_SOURCE_LINE_ID
and mr.INVENTORY_ITEM_ID =msi.INVENTORY_ITEM_ID
and mr.ORGANIZATION_ID = msi.ORGANIZATION_ID
--and wdd.SOURCE_HEADER_ID = ooha.header_id
--and wdd.SOURCE_LINE_ID = oola.line_id
and mr.DEMAND_SOURCE_TYPE_ID=2
and mr.ORGANIZATION_ID =l_org_code
and mr.LOCATOR_ID is not null
and not exists (select 'A' from MTL_RESERVATIONS_TEMP mrt where mrt.RESERVATION_ID= mr.RESERVATION_ID and mrt.ORGANIZATION_ID = mr.ORGANIZATION_ID)
--and mr.RESERVATION_ID =1859071
--and mr.INVENTORY_ITEM_ID=32299
/*and (wdd.RELEASED_STATUS ='R'
or not exists (select 'A' from wsh_delivery_assignments wda, wsh_new_deliveries wnd
where wda.delivery_detail_id = wdd.delivery_detail_id
AND wda.delivery_id = wnd.delivery_id));*/
/*and wdd.RELEASED_STATUS ='R'
and not exists (select 'A' from wsh_delivery_assignments wda, wsh_new_deliveries wnd
where wda.delivery_detail_id = wdd.delivery_detail_id
AND wda.delivery_id = wnd.delivery_id);*/
and mr.SHIP_READY_FLAG is null;
/*select oola.header_id, oola.line_id, mr.RESERVATION_ID
from MTL_RESERVATIONS mr,
oe_order_lines_all oola
where
oola.line_id = mr.DEMAND_SOURCE_LINE_ID
and mr.DEMAND_SOURCE_TYPE_ID=2
and ORGANIZATION_ID =l_org_code
--and mr.INVENTORY_ITEM_ID=32299
and not exists (select 'A' from wsh_delivery_details wdd
where wdd.SOURCE_HEADER_ID =oola.HEADER_ID and
wdd.SOURCE_LINE_ID=oola.line_id);*/
BEGIN
--fnd_global.apps_initialize (10688,50606,401);
FND_FILE.PUT_LINE (FND_FILE.LOG, 'Initializing Apps');
FND_GLOBAL.Apps_Initialize (FND_GLOBAL.USER_ID,
FND_GLOBAL.RESP_ID,
FND_GLOBAL.RESP_APPL_ID);
--- Could be "located" by order_header_id, order_line_id, item and warehouse - in case Several reservations That Could be updated