| SELECT oeh.org_id ou_id, hou.NAME ou_name, mso.concatenated_segments header_number, oel.line_number || "." || oel.shipment_number || decode(oel.option_number, NULL, NULL, "." || oel.option_number) || decode(oel.component_number, NULL, NULL, "." || oel.component_number) || decode(oel.service_number, NULL, NULL, "." || oel.service_number) line, mst.segment1 item_code, oel.flow_status_code status_code, lov.meaning status_name, rsv.organization_id, ood.organization_code, ood.organization_name, rsv.subinventory_code, rsv.requirement_date, rsv.reservation_quantity, rsv.reservation_uom_code, rsv.staged_flag, oel.ordered_quantity, oel.shipped_quantity, oel.shipping_quantity FROM inv.mtl_reservations rsv, inv.mtl_system_items_b mst, apps.mtl_sales_orders_kfv mso, ont.oe_order_lines_all oel, ont.oe_order_headers_all oeh, apps.fnd_lookup_values_vl lov, apps.org_organization_definitions ood, apps.hr_operating_units hou WHERE rsv.organization_id = mst.organization_id AND rsv.inventory_item_id = mst.inventory_item_id AND rsv.demand_source_header_id = mso.sales_order_id AND rsv.demand_source_line_id = oel.line_id AND oel.header_id = oeh.header_id AND lov.lookup_type = "LINE_FLOW_STATUS" AND oel.flow_status_code = lov.lookup_code AND rsv.organization_id = ood.organization_id AND oeh.org_id = hou.organization_id AND rsv.demand_source_type_id = 2 --需求2是销售定单,具体看inv.mtl_txn_source_types AND rsv.supply_source_type_id = 13 --供应13是库存,具体看inv.mtl_txn_source_types AND rsv.reservation_quantity = 0 --数量为0 AND nvl(rsv.staged_flag, "N") <> "Y" --未到待发库 AND oel.flow_status_code = "AWAITING_SHIPPING" --状态是等待发运 AND oeh.org_id = 88 ORDER BY hou.NAME, ood.organization_code |
| DECLARE p_rsv_rec inv_reservation_global.mtl_reservation_rec_type; p_serial_number inv_reservation_global.serial_number_tbl_type; x_return_status VARCHAR2(1); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); x_serial_number inv_reservation_global.serial_number_tbl_type; x_quantity_reserved NUMBER; x_reservation_id NUMBER; Cursor Cr is Select MMT.Creation_Date - + (-15 / 24 / 60) REQUIREMENT_DATE, MMT.ORGANIZATION_ID, MMT.INVENTORY_ITEM_ID, 2 DEMAND_SOURCE_TYPE_ID, MMT.SOURCE_LINE_ID, MMT.TRANSACTION_UOM, -1 * Sum(MMT.TRANSACTION_QUANTITY) TRANSACTION_QUANTITY, 13 SUPPLY_SOURCE_TYPE_ID, MMT.SUBINVENTORY_CODE, MMT.TRANSACTION_SOURCE_ID From MTL_TRANSACTIONS_INTERFACE MMT, MTL_RESERVATIONS_ALL_V MRA Where MMT.ORGANIZATION_ID = 429 And MMT.SOURCE_CODE = "ORDER ENTRY" And MMT.ORGANIZATION_ID = MRA.ORGANIZATION_ID(+) And MMT.SOURCE_LINE_ID = MRA.DEMAND_SOURCE_LINE_ID(+) And MRA.RESERVATION_ID Is Null --And MMT.SOURCE_LINE_ID = 664042 Group By MMT.Creation_Date - + (-15 / 24 / 60), MMT.ORGANIZATION_ID, MMT.INVENTORY_ITEM_ID, MMT.SOURCE_LINE_ID, MMT.TRANSACTION_UOM, MMT.SUBINVENTORY_CODE, MMT.TRANSACTION_SOURCE_ID; ---221111040022 BEGIN For Rs In Cr Loop p_rsv_rec.reservation_id := NULL; p_rsv_rec.requirement_date := Rs.REQUIREMENT_DATE; p_rsv_rec.organization_id := Rs.ORGANIZATION_ID; p_rsv_rec.inventory_item_id := Rs.INVENTORY_ITEM_ID; p_rsv_rec.demand_source_type_id := Rs.DEMAND_SOURCE_TYPE_ID; p_rsv_rec.demand_source_name := NULL; p_rsv_rec.demand_source_header_id := Rs.TRANSACTION_SOURCE_ID; p_rsv_rec.demand_source_line_id := Rs.SOURCE_LINE_ID; p_rsv_rec.demand_source_delivery := NULL; p_rsv_rec.primary_uom_code := NULL; p_rsv_rec.primary_uom_id := NULL; p_rsv_rec.reservation_uom_code := Rs.TRANSACTION_UOM; p_rsv_rec.reservation_uom_id := NULL; p_rsv_rec.reservation_quantity := Rs.TRANSACTION_QUANTITY; p_rsv_rec.primary_reservation_quantity := NULL; p_rsv_rec.detailed_quantity := NULL; p_rsv_rec.autodetail_group_id := NULL; p_rsv_rec.external_source_code := NULL; p_rsv_rec.external_source_line_id := NULL; p_rsv_rec.supply_source_type_id := Rs.SUPPLY_SOURCE_TYPE_ID; p_rsv_rec.supply_source_header_id := NULL; p_rsv_rec.supply_source_line_id := NULL; p_rsv_rec.supply_source_name := NULL; p_rsv_rec.supply_source_line_detail := NULL; p_rsv_rec.revision := NULL; p_rsv_rec.subinventory_code := Rs.SUBINVENTORY_CODE; p_rsv_rec.subinventory_id := NULL; p_rsv_rec.locator_id := NULL; p_rsv_rec.lot_number := NULL; p_rsv_rec.lot_number_id := NULL; p_rsv_rec.pick_slip_number := NULL; p_rsv_rec.lpn_id := NULL; p_rsv_rec.ship_ready_flag := NULL; p_rsv_rec.attribute_category := NULL; p_rsv_rec.attribute1 := NULL; p_rsv_rec.attribute2 := NULL; p_rsv_rec.attribute3 := NULL; p_rsv_rec.attribute4 := NULL; p_rsv_rec.attribute5 := NULL; p_rsv_rec.attribute6 := NULL; p_rsv_rec.attribute7 := NULL; p_rsv_rec.attribute8 := NULL; p_rsv_rec.attribute9 := NULL; p_rsv_rec.attribute10 := NULL; p_rsv_rec.attribute11 := NULL; p_rsv_rec.attribute12 := NULL; p_rsv_rec.attribute13 := NULL; p_rsv_rec.attribute14 := NULL; p_rsv_rec.attribute15 := NULL; Update OE_ORDER_LINES_ALL Set open_flag = "Y" Where LINE_ID = Rs.SOURCE_LINE_ID; inv_reservation_pub.create_reservation(p_api_version_number => "1.0", p_init_msg_lst => fnd_api.g_true, x_return_status => x_return_status, x_msg_count => x_msg_count, x_msg_data => x_msg_data, p_rsv_rec => p_rsv_rec, p_serial_number => p_serial_number, x_serial_number => x_serial_number, p_partial_reservation_flag => fnd_api.g_true, p_force_reservation_flag => fnd_api.g_false, p_validation_flag => fnd_api.g_true, x_quantity_reserved => x_quantity_reserved, x_reservation_id => x_reservation_id); Update OE_ORDER_LINES_ALL Set open_flag = "N" Where LINE_ID = Rs.SOURCE_LINE_ID; IF x_return_status = fnd_api.g_ret_sts_success THEN dbms_output.put_line("Reservation Created Successfully! Reservation ID: " || x_reservation_id); ELSE ROLLBACK; dbms_output.put_line("Return Status: " || x_return_status); fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data); dbms_output.put_line("Error count : " || to_char(x_msg_count)); dbms_output.put_line(REPLACE(x_msg_data, chr(0), " ")); FOR i IN 2 .. x_msg_count LOOP x_msg_data := fnd_msg_pub.get; dbms_output.put_line(REPLACE(x_msg_data, chr(0), " ")); END LOOP; END IF; End Loop; END; |
| DECLARE p_original_rsv_rec inv_reservation_global.mtl_reservation_rec_type; p_to_rsv_rec inv_reservation_global.mtl_reservation_rec_type; p_original_serial_number inv_reservation_global.serial_number_tbl_type; p_to_serial_number inv_reservation_global.serial_number_tbl_type; x_return_status VARCHAR2(1); x_msg_count NUMBER; x_msg_data VARCHAR2(2000); x_quantity_reserved NUMBER; x_secondary_quantity_reserved Number; Cursor Cr is Select MRA.RESERVATION_ID, MMT.TRANSACTION_UOM, -1 * Sum(MMT.TRANSACTION_QUANTITY) TRANSACTION_QUANTITY, MMT.TRANSACTION_SOURCE_ID From MTL_TRANSACTIONS_INTERFACE MMT, MTL_RESERVATIONS_ALL_V MRA Where MMT.ORGANIZATION_ID = 429 And MMT.SOURCE_CODE = "ORDER ENTRY" And MMT.ORGANIZATION_ID = MRA.ORGANIZATION_ID(+) And MMT.SOURCE_LINE_ID = MRA.DEMAND_SOURCE_LINE_ID(+) And MRA.RESERVATION_ID Is Not Null ---And MMT.SOURCE_LINE_ID = 662459 Group By MRA.RESERVATION_ID, MMT.TRANSACTION_UOM,MMT.TRANSACTION_SOURCE_ID; BEGIN For Rs In Cr Loop p_original_rsv_rec.reservation_id := Rs.RESERVATION_ID; p_to_rsv_rec.reservation_uom_code := Rs.TRANSACTION_UOM; p_to_rsv_rec.reservation_quantity := Rs.TRANSACTION_QUANTITY; p_to_rsv_rec.demand_source_header_id :=Rs.TRANSACTION_SOURCE_ID; inv_reservation_pub.update_reservation(p_api_version_number => "1.0", p_init_msg_lst => fnd_api.g_true, x_return_status => x_return_status, x_msg_count => x_msg_count, x_msg_data => x_msg_data, x_quantity_reserved => x_quantity_reserved, x_secondary_quantity_reserved=>x_secondary_quantity_reserved, p_original_rsv_rec => p_original_rsv_rec, p_to_rsv_rec => p_to_rsv_rec, p_original_serial_number => p_original_serial_number, p_to_serial_number => p_to_serial_number, p_validation_flag => fnd_api.g_true, p_partial_reservation_flag => fnd_api.g_false, p_check_availability => fnd_api.g_false); IF x_return_status = fnd_api.g_ret_sts_success THEN dbms_output.put_line("Reservation Updated Successfully! New Quantity: " || x_quantity_reserved); ELSE ROLLBACK; dbms_output.put_line("Return Status: " || x_return_status); fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data); dbms_output.put_line("Error count : " || to_char(x_msg_count)); dbms_output.put_line(REPLACE(x_msg_data, chr(0), " ")); FOR i IN 2 .. x_msg_count LOOP x_msg_data := fnd_msg_pub.get; dbms_output.put_line(REPLACE(x_msg_data, chr(0), " ")); END LOOP; END IF; end loop; END; |
|
|