现有量,在途量,可用量,可保留量

FUNCTION get_onhand_atr_qty(p_organization_id IN NUMBER,
                               p_item_id         IN NUMBER) RETURN NUMBER IS

      x_return_status VARCHAR2(1);
      x_msg_count     NUMBER;
      x_msg_data      VARCHAR2(4000);
      l_qoh           NUMBER := 0;
      l_qr            NUMBER := 0;
      l_qs            NUMBER := 0;
      l_atr           NUMBER := 0;
      l_att           NUMBER := 0;
      l_atp_qty       NUMBER := 0;

   BEGIN
      --init
      inv_quantity_tree_pub.clear_quantity_cache;

      BEGIN
         --std api
         inv_quantity_tree_pub.query_quantities(p_api_version_number  => 1.0,
                                                p_init_msg_lst        => NULL, --'F',
                                                x_return_status       => x_return_status,
                                                x_msg_count           => x_msg_count,
                                                x_msg_data            => x_msg_data,
                                                p_organization_id     => p_organization_id,
                                                p_inventory_item_id   => p_item_id,
                                                p_tree_mode           => 3,
                                                p_is_revision_control => FALSE,
                                                p_is_lot_control      => NULL,
                                                p_is_serial_control   => FALSE,
                                                p_revision            => NULL,
                                                p_lot_number          => NULL,
                                                p_lot_expiration_date => NULL,
                                                p_subinventory_code   => NULL,
                                                p_locator_id          => NULL,
                                                p_cost_group_id       => NULL,
                                                p_onhand_source       => inv_quantity_tree_pvt.g_all_subs,
                                                x_qoh                 => l_qoh,
                                                x_rqoh                => l_atp_qty,
                                                x_qr                  => l_qr,
                                                x_qs                  => l_qs,
                                                x_att                 => l_att,
                                                x_atr                 => l_atr);

      EXCEPTION
         WHEN OTHERS THEN
            RETURN 0;
      END;

      RETURN nvl(l_atr, 0);

   EXCEPTION
      WHEN OTHERS THEN
         RETURN 0;
   END get_onhand_atr_qty;

在Oracle Application中,standard 功能是调用下面API来计算Onhand Quantity的:

inv_quantity_tree_pub.query_quantities

( p_api_version_number  => 1.0,

p_init_msg_lst        => ‘F‘,

x_return_status       => x_return_status,

x_msg_count           => x_msg_count,

x_msg_data            => x_msg_data,

p_organization_id     => p_organization_id,

p_inventory_item_id   => p_inventory_item_id,

p_tree_mode           => tree_mode,

p_is_revision_control => is_revision_control,

p_is_lot_control      => is_lot_control,

p_is_serial_control   => FALSE,

p_revision            => p_revision,

p_lot_number          => p_lot_number,

p_lot_expiration_date => sysdate,

p_subinventory_code   => p_subinventory_code,

p_locator_id          => p_locator_id,

p_cost_group_id       => cg_id,

p_onhand_source       => 3,

x_qoh                 => qoh,

x_rqoh                => rqoh,

x_qr                  => qr,

x_qs                  => qs,

x_att                 => att,

x_atr                 => atr,

p_grade_code                  => p_grade_code,

x_sqoh                        => sqoh,

x_satt                        => satt,

x_satr                        => satr ,

x_srqoh                       => x_srqoh,

x_sqr                         => x_sqr,

x_sqs                         => x_sqs,

p_demand_source_type_id       => -1 ,

p_demand_source_header_id     => -1 ,

p_demand_source_line_id       => -1 ,

p_demand_source_name          => NULL ,

p_transfer_subinventory_code  => NULL ,

p_transfer_locator_id         => NULL

);

参数基本上一看能猜出大概意思,对几个特殊的参数解释说明一下:

【1】p_tree_mode

R12的standard form后台是这样解释的:

* The parameter p_tree_mode determines which values to fetch:

*   2  => Fetch both packed and loose quantities

*   3  => Fetch only loose quantities

* To determine whether ONLY loose quantities are to be displayed:

*  a) Subinventory, cost group for the current record (in QUANTITY_FOLDER block) are not NULL

*  b) QUANTITY_FOLDER.PACKED is NOT NULL (for WMS org) and is equal to 0

*  c) The current record does not have VMI or consigned stock

*  d) For a lot controlled item, the QUANTITY_FOLDER.LOT_NUMBER is not null.

* When the above conditions are TRUE, then call the quantity tree with tree_mode = 3 and default

* the on-hand quantity to :QUANTITY_FOLDER.ON_HAND.

* If the current node has VMI or consigned stock, am showing the entire quantity(both packed and loose)

【2】p_onhand_source

Used to determine which subs are included in calculation of onhand qty

有4个可选值:

inv_quantity_tree_pvt.g_atpable_only   CONSTANT NUMBER := 1;

inv_quantity_tree_pvt.g_nettable_only   CONSTANT NUMBER := 2;

inv_quantity_tree_pvt.g_all_subs   CONSTANT NUMBER := 3;

inv_quantity_tree_pvt.g_atpable_nettable_only CONSTANT NUMBER := 4;

这几个值是在Lookup code中设置的,

lookup type: MTL_ONHAND_SOURCE

【3】x_att

返回值。available to transact

【4】x_atr

返回值。available to reserve


在计算物料的可保留量的时候,我们通常的做法是MTL_ONHAND_QUANTITIES

中的TRANSACTION_QUANTITY的数量按照组织+物料+子库+货位+批次…的方式

进行累计,然后再减去物料在MTL_RESERVATIONS 中对应的保留。很多的时候没有去考

虑此时库存事务处理接口表(MTL_MATERIAL_TRANSACTIONS_TEMP)中物料数量,这样计算

出来的数量可能会不准确。以下是考虑了库存事务处理接口表的物料数量的计算方

式。大家不妨可以参考一下。

/*--------------------------------------------------------------------------------

$ Header PTAC , SKip Siman He  , 2008.03.25

* Procedure GET_ITEM_ATT_QTY

* Purpose :

计算物料的可用量

---------------------------------------------------------------------------- */

FUNCTION get_item_att_qty(p_item_id           NUMBER,

p_organization_id   NUMBER,

p_subinventory_code VARCHAR2) RETURN NUMBER IS

l_onhand_qty    NUMBER;

l_resv_qty      NUMBER;

l_qoh           NUMBER;

l_rqoh          NUMBER;

l_qr            NUMBER;

l_qs            NUMBER;

l_att           NUMBER;

l_atr           NUMBER;

l_tree_mode     NUMBER;

l_msg_count     VARCHAR2(100);

l_msg_data      VARCHAR2(1000);

l_return_status VARCHAR2(1);

x_return        VARCHAR2(1);

BEGIN

-- Transact mode

l_tree_mode := 2;

inv_quantity_tree_pub.clear_quantity_cache;

inv_quantity_tree_pub.query_quantities

p_api_version_number  => 1.0,

p_init_msg_lst        => ‘F‘,

x_return_status       => l_return_status,

x_msg_count           => l_msg_count,

x_msg_data            => l_msg_data,

p_organization_id     => p_organization_id,

p_inventory_item_id   => p_item_id,

p_tree_mode           => l_tree_mode,

p_is_revision_control => FALSE,

p_is_lot_control      => FALSE,

p_is_serial_control   => FALSE,

p_revision            => NULL,

p_lot_number          => NULL,

p_lot_expiration_date => NULL,

p_subinventory_code   => p_subinventory_code,

p_locator_id          => NULL,

p_onhand_source       => inv_quantity_tree_pvt.g_all_subs,

x_qoh                 => l_qoh,

x_rqoh                => l_rqoh,

x_qr                  => l_qr,

Oracle ERP R12实用技术开发.doc

x_qs                  => l_qs,

x_att                 => l_att, --可用量

x_atr                 => l_atr); --可保留量

RETURN l_att;

END;

在途量

 FUNCTION get_onhand_transit_qty(p_organization_id IN NUMBER,
                                   p_item_id         IN NUMBER,
                                   p_cux_header_id   IN NUMBER) RETURN NUMBER IS
      l_receive_qty       NUMBER := 0;
      l_delivery_qty      NUMBER := 0;
      l_transit_qty       NUMBER := 0;
      l_transit_reser_qty NUMBER := 0;
   BEGIN

      --接收数量
      SELECT SUM(rt.quantity)
        INTO l_receive_qty
        FROM rcv_transactions rt
       WHERE 1 = 1
         AND rt.organization_id = p_organization_id
         AND rt.transaction_type = 'RECEIVE'
         AND EXISTS
       (SELECT 'x'
                FROM po_headers_all        poh,
                     po_lines_all          pol,
                     po_line_locations_all poll
               WHERE 1 = 1
                 AND nvl(pol.closed_code, 'OPEN') <> 'CLOSED'
                 AND poh.po_header_id = pol.po_header_id
                 AND pol.po_line_id = poll.po_line_id
                 AND pol.po_header_id = poll.po_header_id
                 AND poh.approved_flag = 'Y'
                 AND poll.approved_flag = 'Y'
                 AND pol.item_id = p_item_id
                 AND poll.po_header_id = rt.po_header_id
                 AND poll.po_line_id = rt.po_line_id
                 AND poll.line_location_id = rt.po_line_location_id);

      --接收数量
      SELECT SUM(rt.quantity)
        INTO l_delivery_qty
        FROM rcv_transactions rt
       WHERE 1 = 1
         AND rt.organization_id = p_organization_id
         AND rt.transaction_type = 'DELIVER'
         AND EXISTS
       (SELECT 'x'
                FROM po_headers_all        poh,
                     po_lines_all          pol,
                     po_line_locations_all poll
               WHERE 1 = 1
                 AND nvl(pol.closed_code, 'OPEN') <> 'CLOSED'
                 AND poh.po_header_id = pol.po_header_id
                 AND pol.po_line_id = poll.po_line_id
                 AND pol.po_header_id = poll.po_header_id
                 AND poh.approved_flag = 'Y'
                 AND poll.approved_flag = 'Y'
                 AND pol.item_id = p_item_id
                 AND poll.po_header_id = rt.po_header_id
                 AND poll.po_line_id = rt.po_line_id
                 AND poll.line_location_id = rt.po_line_location_id);

      l_transit_qty := nvl(l_receive_qty, 0) - nvl(l_delivery_qty, 0);

      --被其他订单占用的在途保留量
      SELECT SUM(cotr.reservation_quantity)
        INTO l_transit_reser_qty
        FROM cux_om_transit_reservation cotr
       WHERE 1 = 1
         AND cotr.item_id = p_item_id
         AND cotr.ship_from_org_id = p_organization_id
         AND cotr.cux_header_id <> nvl(p_cux_header_id, -9999);

      IF l_transit_reser_qty < 0 THEN
         l_transit_reser_qty := 0;
      END IF;

      RETURN l_transit_qty - nvl(l_transit_reser_qty, 0);

   EXCEPTION
      WHEN OTHERS THEN
         RETURN 0;
   END get_onhand_transit_qty;
时间: 2024-08-06 16:06:41

现有量,在途量,可用量,可保留量的相关文章

基于tcp/ip以太网通信实现0-5v,4-20ma模拟量AI采集以及模拟量AO输出控制-综科智控

ZKA-XXX-ETH 使 用 说 明 书 [ ]绝密 [ ]NDA [X]公开 版本历史 版本 修订日期 修订人 修订内容 1.0 2014-10-13 综科智控 1.0初版正式发布 1.1 2014-12-07 综科智控 填图 1.2 2015-03-01 综科智控 更新配置 1.3 2015-08-13 综科智控 修正组网图 1.4 2015-09-28 综科智控 增加ZKA型号 1.5 2016-05-22 综科智控 增加附件 1.6 2016-11-01 综科智控 修改组网图 1.7

字符串字面量和逐字字符串面量

1.无后缀的实数字面量是double类型,不是float类型! 2.与c/c++不同,在c#中数字不具有布尔意义. 3.int x=5;if(x)...//x是int类型不是布尔类型. 4.委托是引用类型因此两个委托也可以进行比较,如果两个委托都是null, 或者两者的调用列表中有相同数目的成员,并且调用列表相匹配,那么比较 返回true;

阿里云轻量服务器价格及轻量与ECS服务器区别比较

https://yq.aliyun.com/articles/221647 摘要: 阿里云轻量应用服务器价格表及介绍,关于轻量应用服务器和ECS服务器的性能对比 阿里云轻量应用服务器是阿里云新推出的服务器,本文介绍阿里云轻量服务器的价格,已经何为"轻量"?轻量与阿里云ECS服务器有什么区别?轻量性能就一定不如ECS服务器吗? 什么是轻量应用服务器?轻量应用服务器是面向单机应用场景的新一代计算服务,提供精品应用一键部署,支持一站式的域名.网站.安全.运维.应用管理等服务,极大地优化了搭建

金士顿U盘PS2251-07东芝闪存白片量产CDROM成功教程-群联量产教程-U盘量产网

之前我们发布过金士顿DT100 G3的黑片量产工具教程,因为白片的MPALL量产工具无法量产,所有版本的Phison_MPALL都爆红,最近出了新的白片MPALL V5.03.0A版本,所以试了一下结果成功了,先上图 可以看到这次量产的是东芝闪存颗粒,之前的是海力士的.具体量产教程如下:1.下载MPALL_F1_7F00_DL07_v503_0A2.打开文件夹中检测工具Getinfo v3.10.7.6,发现主控是PS2251-07,颗粒是东芝的TLC 3.打开文件夹中的MPALL_F1_7F0

金士顿U盘,群联PS2251-60主控,量产还原教程

还原成一个可移动磁盘教程,只是在"分区设置"中将 "模式=21" 改为 "模式=3" 即可. 1. 打开:"MPALL_F1_9000_v329_0B"进入量产界面: 2. 点击"Setting"进入设定画面: 选择"New Seting"."Advance Setting"点"OK",进入设定画面: 3. IC_FW选项卡设定: 语言勾选&quo

【转】【Linux】 临界区,互斥量,信号量,事件的区别

原文地址:http://blog.itpub.net/10697500/viewspace-612045/ Linux中 四种进程或线程同步互斥的控制方法1.临界区:通过对多线程的串行化来访问公共资源或一段代码,速度快,适合控制数据访问. 2.互斥量:为协调共同对一个共享资源的单独访问而设计的. 3.信号量:为控制一个具有有限数量用户资源而设计. 4.事 件:用来通知线程有一些事件已发生,从而启动后继任务的开始.     临界区(Critical Section) 保证在某一时刻只有一个线程能访

JavaScript语言精粹1字符串,对象字面量

字符串 Strings JavaScript没有,字符,类型.仅包含一个字符的,字符串即可. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>testString1</title> <style type="text/css"></style> </hea

临界区,互斥量,信号量,事件的区别(线程同步)

(转)临界区,互斥量,信号量,事件的区别(线程同步) (转)临界区,互斥量,信号量,事件的区别(线程同步) . 分类: C++ windows 核心编程 2012-04-10 14:55 3321人阅读 评论(0) 收藏 举报 semaphoremfcnulleventsthreadhttp服务器 四种进程或线程同步互斥的控制方法 1.临界区:通过对多线程的串行化来访问公共资源或一段代码,速度快,适合控制数据访问. 2.互斥量:为协调共同对一个共享资源的单独访问而设计的. 3.信号量:为控制一个

四张图表让你搞懂电离辐射及常用的量

网友奇迹再现整理 一.射线与电磁波 二.辐射场量.实用量与防护量的联系\ 转自:中国辐射防护研究院学术刘立业老师演讲报告资料