CREATE or REPPLACE PROCEDURE CreateReservation AS 

        -- Common Declarations
l_api_version NUMBER := 1.0;
l_init_msg_list VARCHAR2(2) := FND_API.G_TRUE;
x_return_status VARCHAR2(2);
x_msg_count NUMBER := 0;
x_msg_data VARCHAR2(255); -- WHO columns
l_user_id NUMBER := -1;
l_resp_id NUMBER := -1;
l_application_id NUMBER := -1;
l_row_cnt NUMBER := 1;
l_user_name VARCHAR2(30) := 'MFG';
l_resp_name VARCHAR2(50) := 'Manufacturing and Distribution Manager'; -- API specific declarations
l_rsv_rec INV_RESERVATION_GLOBAL.MTL_RESERVATION_REC_TYPE;
l_serial_number INV_RESERVATION_GLOBAL.SERIAL_NUMBER_TBL_TYPE;
x_serial_number INV_RESERVATION_GLOBAL.SERIAL_NUMBER_TBL_TYPE;
l_partial_reservation_flag VARCHAR2(2) := FND_API.G_FALSE;
l_force_reservation_flag VARCHAR2(2) := FND_API.G_FALSE;
l_validation_flag VARCHAR2(2) := FND_API.G_TRUE;
l_partial_reservation_exists BOOLEAN := FALSE;
x_quantity_reserved NUMBER := 0;
x_reservation_id NUMBER := 0; l_primary_reservation_qty NUMBER := 2; -- total qty
l_subinventory_code VARCHAR2(40) := NULL; -- will create a hard reservation -- Load required data into cursor, the present cursor will load serial numbers for given item
CURSOR c_items IS
SELECT msi.organization_id, msi.inventory_item_id, msi.segment1, msi.primary_uom_code
FROM mtl_system_items_b msi, mtl_parameters mp
WHERE msi.organization_id = mp.organization_id
AND msi.segment1 = 'SU_TEST_STS3'
AND mp.organization_code = 'M1'; -- Load required serial numbers to be reserved
CURSOR c_serials IS
SELECT msn.inventory_item_id, msn.serial_number
FROM mtl_system_items_b msi, mtl_serial_numbers msn, mtl_parameters mp
WHERE msi.organization_id = mp.organization_id
AND msi.organization_id = msn.current_organization_id
AND msi.inventory_item_id = msn.inventory_item_id
AND msi.segment1 = 'SU_TEST_STS3'
AND mp.organization_code = 'M1'
AND msi.serial_number_control_code not in (1, 6) -- item is not serial controlled / controlled at sales order issue
AND msn.serial_number BETWEEN 'S1' AND 'S2'; -- can leave this NULL if item is not serial controlled BEGIN -- Get the user_id
SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = l_user_name; -- Get the application_id and responsibility_id
SELECT application_id, responsibility_id
INTO l_application_id, l_resp_id
FROM fnd_responsibility_vl
WHERE responsibility_name = l_resp_name; FND_GLOBAL.APPS_INITIALIZE(l_user_id, l_resp_id, l_application_id);
dbms_output.put_line('Initialized applications context: '|| l_user_id || ' '|| l_resp_id ||' '|| l_application_id ); -- Initialize Serials to be reserved (if Item is serial controlled)
BEGIN
FOR ser IN c_serials LOOP
l_serial_number(l_row_cnt).inventory_item_id := ser.inventory_item_id;
l_serial_number(l_row_cnt).serial_number := ser.serial_number;
l_row_cnt := l_row_cnt + 1;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('Item not serial controlled / serials not provided');
END; -- Initialize Reservations Record
FOR itm IN c_items LOOP -- Initialize the variables
l_rsv_rec.organization_id := itm.organization_id;
l_rsv_rec.inventory_item_id := itm.inventory_item_id;
l_rsv_rec.requirement_date := sysdate + 3;
l_rsv_rec.demand_source_type_id := INV_RESERVATION_GLOBAL.G_SOURCE_TYPE_INV;
l_rsv_rec.supply_source_type_id := INV_RESERVATION_GLOBAL.G_SOURCE_TYPE_INV;
l_rsv_rec.demand_source_name := 'INV_RSV_'||itm.segment1;
l_rsv_rec.primary_reservation_quantity := l_primary_reservation_qty;
l_rsv_rec.primary_uom_code := itm.primary_uom_code;
l_rsv_rec.subinventory_code := l_subinventory_code;
l_rsv_rec.demand_source_header_id := NULL ;
l_rsv_rec.demand_source_line_id := NULL ;
l_rsv_rec.reservation_uom_code := NULL ;
l_rsv_rec.reservation_quantity := NULL ;
l_rsv_rec.supply_source_header_id := NULL ;
l_rsv_rec.supply_source_line_id := NULL ;
l_rsv_rec.supply_source_name := NULL ;
l_rsv_rec.supply_source_line_detail := NULL ;
l_rsv_rec.lot_number := NULL ; -- optional 'EXPLOT200' ;
l_rsv_rec.serial_number := NULL ;
l_rsv_rec.ship_ready_flag := NULL ;
l_rsv_rec.attribute15 := NULL ;
l_rsv_rec.attribute14 := NULL ;
l_rsv_rec.attribute13 := NULL ;
l_rsv_rec.attribute12 := NULL ;
l_rsv_rec.attribute11 := NULL ;
l_rsv_rec.attribute10 := NULL ;
l_rsv_rec.attribute9 := NULL ;
l_rsv_rec.attribute8 := NULL ;
l_rsv_rec.attribute7 := NULL ;
l_rsv_rec.attribute6 := NULL ;
l_rsv_rec.attribute5 := NULL ;
l_rsv_rec.attribute4 := NULL ;
l_rsv_rec.attribute3 := NULL ;
l_rsv_rec.attribute2 := NULL ;
l_rsv_rec.attribute1 := NULL ;
l_rsv_rec.attribute_category := NULL ;
l_rsv_rec.lpn_id := NULL ;
l_rsv_rec.pick_slip_number := NULL ;
l_rsv_rec.lot_number_id := NULL ;
l_rsv_rec.locator_id := NULL ;
l_rsv_rec.subinventory_id := NULL ;
l_rsv_rec.revision := NULL ;
l_rsv_rec.external_source_line_id := NULL ;
l_rsv_rec.external_source_code := NULL ;
l_rsv_rec.autodetail_group_id := NULL ;
l_rsv_rec.reservation_uom_id := NULL ;
l_rsv_rec.primary_uom_id := NULL ;
l_rsv_rec.demand_source_delivery := NULL ; -- call API to create reservation
DBMS_OUTPUT.PUT_LINE('=======================================================');
DBMS_OUTPUT.PUT_LINE('Calling INV_RESERVATION_PUB.Create_Reservation API'); INV_RESERVATION_PUB.Create_Reservation(
P_API_VERSION_NUMBER => l_api_version
, P_INIT_MSG_LST => l_init_msg_list
, P_RSV_REC => l_rsv_rec
, P_SERIAL_NUMBER => l_serial_number
, P_PARTIAL_RESERVATION_FLAG => l_partial_reservation_flag
, P_FORCE_RESERVATION_FLAG => l_force_reservation_flag
, P_PARTIAL_RSV_EXISTS => l_partial_reservation_exists
, P_VALIDATION_FLAG => l_validation_flag
, X_SERIAL_NUMBER => x_serial_number
, 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_RESERVATION_ID => x_reservation_id); DBMS_OUTPUT.PUT_LINE('=======================================================');
DBMS_OUTPUT.PUT_LINE('Return Status: '||x_return_status); IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
DBMS_OUTPUT.PUT_LINE('Error Message :'||x_msg_data);
END IF; IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
DBMS_OUTPUT.PUT_LINE('Reservation ID :'||x_reservation_id||' Quantity Reserved:'||x_quantity_reserved);
FOR srl IN 1..x_serial_number.COUNT LOOP
DBMS_OUTPUT.PUT_LINE('Serial Reserved:'||x_serial_number(srl).serial_number);
END LOOP;
END IF;
DBMS_OUTPUT.PUT_LINE('======================================================='); END LOOP; EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Exception Occured :');
DBMS_OUTPUT.PUT_LINE(SQLCODE ||':'||SQLERRM);
DBMS_OUTPUT.PUT_LINE('=======================================================');
END CreateReservation;

  

Oracle EBS INV创建保留的更多相关文章

  1. Oracle EBS INV 创建物料搬运单

    Create or Replace PROCEDURE ProcessMoveOrder AS -- Common Declarations l_api_version NUMBER := 1.0; ...

  2. Oracle EBS INV 创建物料搬运单头

    CREATE OR REPLACE PROCEDURE XX_CreateMoveOrderHeader AS -- Common Declarations l_api_version NUMBER ...

  3. Oracle EBS INV 创建物料搬运单行

    CREATE OR REPLACE PROCEDURE CreateMoveOrderLines AS -- Common Declarations l_api_version NUMBER := 1 ...

  4. Oracle EBS INV 释放保留

    CREATE or REPPLACE PROCEDURE RelieveReservation AS -- Common Declarations l_api_version NUMBER := 1. ...

  5. Oracle EBS INV更新保留

    CREATE or REPPLACE PROCEDURE UpdateReservation AS -- Common Declarations l_api_version NUMBER := 1.0 ...

  6. Oracle EBS INV 删除保留

    DECLARE p_rsv apps.inv_reservation_global.mtl_reservation_rec_type; p_dummy_sn apps.inv_reservation_ ...

  7. Oracle EBS INV 创建货位

    create or replace PROCEDURE XX_CREATE_LOCATOR AS -- Common Declarations l_api_version NUMBER := 1.0; ...

  8. Oracle EBS OPM 创建生产批

    --创建生产批 --created by jenrry DECLARE x_message_count NUMBER; x_message_list VARCHAR2 (2000); x_return ...

  9. Oracle EBS INV 挑库发放物料搬运单

    create or replace PROCEDURE XX_TRANSACT_MO_LINE AS -- Common Declarations l_api_version NUMBER := 1. ...

随机推荐

  1. Linux 数据重定向

    名称 描述 代码 表示 stdin 标准输入 0 < 或 << stdout 标准输出 1 > 或 >> stderr 标准错误输出 2 2> 或 2> ...

  2. 215. 数组中的第K个最大元素

    在未排序的数组中找到第 k 个最大的元素.请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素. 示例 1: 输入: [3,2,1,5,6,4] 和 k = 2输出: 5示 ...

  3. zk特性和场景

    zk解决什么问题 分布式一致性问题 一致性一般定义是分布式系统中状态或数据保持同步和一致.实际上就是围绕着“看见”来的.谁能看见?能否看见?什么时候看见? 举个例子:淘宝后台卖家,在后台上架一件大促的 ...

  4. linux比较文件夹的差异命令

    可以使用 diff -ruNa s1 s2 或者使用 diff -uN c1 c2 结果如下: sandbox$ tree . |-- dir1 | |-- a.txt | `-- b.txt `-- ...

  5. MySQL的视图view,视图创建后,会随着表的改变而自动改变数据

    首先是创建视图 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `new_view` A ...

  6. [Python] 震惊, 我居然用Python干这种事ꈍ .̮ ꈍ

    阅读本文只需花费你两分钟, 两分钟你买不了吃亏,你也买不了上当. 那么, 为何不静下心来看看呢? Python 海龟创意绘画, Turtle库创作精美图画 Author:Amd794     E-ma ...

  7. Servlet 监听器Listener详解

    转自:http://blog.csdn.net/u012228718/article/details/41730799 一.简介 (一)概述 1.Listener 用于监听 Javaweb程序中的事件 ...

  8. 大数据技术之_08_Hive学习_05_Hive实战之谷粒影音(ETL+TopN)+常见错误及解决方案

    第10章 Hive实战之谷粒影音10.1 需求描述10.2 项目10.2.1 数据结构10.2.2 ETL原始数据10.3 准备工作10.3.1 创建表10.3.2 导入ETL后的数据到原始表10.3 ...

  9. ElasticSearch 学习记录之Text keyword 两种基本类型区别

    ElasticSearch 系列文章 1 ES 入门之一 安装ElasticSearcha 2 ES 记录之如何创建一个索引映射 3 ElasticSearch 学习记录之Text keyword 两 ...

  10. 分布式理论(三)—— 一致性协议之 2PC

    前言 为了使系统尽量能够达到 CAP,于是有了 BASE 协议,而 BASE 协议是在可用性和一致性之间做的取舍和妥协. 人们往往需要在系统的可用性和数据一致性之间反复的权衡.于是呢,就产生我们标题中 ...