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. tabs高度自适应方法

    1.去掉easyui-tabs类属性,改为id=tabs 2.用js控制高度

  2. ES6基础教程一 学习笔记

    一.变量的声明 1.var 声明全局变量 在ES6中var用来声明全局变量. 2.let 声明局部变量 3.const 声明常量 二.变量的解构赋值 //1.数组赋值 let [a,b,c]=[1,2 ...

  3. JAVA与DOM解析器基础 学习笔记

    要求 必备知识 JAVA基础知识.XML基础知识. 开发环境 MyEclipse10 资料下载 源码下载   文件对象模型(Document Object Model,简称DOM),是W3C组织推荐的 ...

  4. MVC源码分析 - Error过滤器

    接 上一篇 内容, 这里先看一下错误处理过滤器. 在看此部分之前, 先看看MVC已经提供的功能吧. 一. MVC 自带功能 1. 配置方法 <system.web> <!--mode ...

  5. linux sticky

    文件的粘滞位(sticky)位是作什么用的? 普通文件的sticky位会被linux内核忽略, 目录的sticky位表示这个目录里的文件只能被owner和root删除 粘着位(Sticky bit) ...

  6. 解析Resources.arsc

    一.前言 对于APK里面的Resources.arsc文件大家应该都知道是干什么的(不知道的请看我的另一篇文章Android应用程序资源文件的编译和打包原理),它实际上就是App的资源索引表.下面我会 ...

  7. 【转】CSRF基本概念

    本文转自:http://www.cnblogs.com/hyddd/ 一.CSRF是什么? CSRF(Cross-site request forgery),中文名称:跨站请求伪造,也被称为:one ...

  8. [AHOI 2013]差异

    Description 题库链接 给定一个长度为 \(n\) 的字符串 \(S\) ,令 \(T_i\) 表示它从第 \(i\) 个字符开始的后缀.求 \[\sum_{1\leqslant i< ...

  9. GCD之同步异步

    博客地址:http://blog.csdn.net/chaoyuan899/article/details/12554603

  10. 函数表达式(JavaScript高程笔记)

    函数声明 特点:函数声明提升(执行代码之前解析器会先读取函数声明,并使其在执行任何代码之前可用,意味着可以把函数声明放在调用语句之后) function functionName(arg0,arg1) ...