Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10298
  • 博文数量: 4
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 45
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-12 15:18
文章分类

全部博文(4)

文章存档

2013年(4)

我的朋友

分类: 信息化

2013-08-02 23:01:11

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


点击(此处)折叠或打开

  1. inv_quantity_tree_pub.query_quantities
  2.          ( p_api_version_number => 1.0,
  3.           p_init_msg_lst => 'F',
  4.           x_return_status => x_return_status,
  5.           x_msg_count => x_msg_count,
  6.           x_msg_data => x_msg_data,
  7.           p_organization_id => p_organization_id,
  8.           p_inventory_item_id => p_inventory_item_id,
  9.           p_tree_mode => tree_mode,
  10.           p_is_revision_control => is_revision_control,
  11.           p_is_lot_control => is_lot_control,
  12.           p_is_serial_control => FALSE,
  13.           p_revision => p_revision,
  14.           p_lot_number => p_lot_number,
  15.           p_lot_expiration_date => sysdate,
  16.           p_subinventory_code => p_subinventory_code,
  17.           p_locator_id => p_locator_id,
  18.           p_cost_group_id => cg_id,
  19.           p_onhand_source => 3,
  20.           x_qoh => qoh,
  21.           x_rqoh => rqoh,
  22.           x_qr => qr,
  23.           x_qs => qs,
  24.           x_att => att,
  25.           x_atr => atr,
  26.           p_grade_code => p_grade_code,
  27.           x_sqoh => sqoh,
  28.           x_satt => satt,
  29.           x_satr => satr ,
  30.           x_srqoh => x_srqoh,
  31.           x_sqr => x_sqr,
  32.           x_sqs => x_sqs,
  33.           p_demand_source_type_id => -1 ,
  34.           p_demand_source_header_id => -1 ,
  35.           p_demand_source_line_id => -1 ,
  36.           p_demand_source_name => NULL ,
  37.           p_transfer_subinventory_code => NULL ,
  38.           p_transfer_locator_id => NULL
  39.           );


参数基本上一看能猜出大概意思,对几个特殊的参数解释说明一下:
【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 : 
              计算物料的可用量
  ---------------------------------------------------------------------------- */

点击(此处)折叠或打开

  1. FUNCTION get_item_att_qty(p_item_id NUMBER,
  2.                             p_organization_id NUMBER,
  3.                             p_subinventory_code VARCHAR2) RETURN NUMBER IS
  4.     l_onhand_qty NUMBER;
  5.     l_resv_qty NUMBER;
  6.     l_qoh NUMBER;
  7.     l_rqoh NUMBER;
  8.     l_qr NUMBER;
  9.     l_qs NUMBER;
  10.     l_att NUMBER;
  11.     l_atr NUMBER;
  12.     l_tree_mode NUMBER;
  13.     l_msg_count VARCHAR2(100);
  14.     l_msg_data VARCHAR2(1000);
  15.     l_return_status VARCHAR2(1);
  16.     x_return VARCHAR2(1);
  17.   BEGIN
  18.     -- Transact mode
  19.     l_tree_mode := 2;
  20.     inv_quantity_tree_pub.clear_quantity_cache;
  21.     inv_quantity_tree_pub.query_quantities
  22.                  p_api_version_number => 1.0,
  23.                  p_init_msg_lst => 'F',
  24.                  x_return_status => l_return_status,
  25.                  x_msg_count => l_msg_count,
  26.                  x_msg_data => l_msg_data,
  27.                  p_organization_id => p_organization_id,
  28.                  p_inventory_item_id => p_item_id,
  29.                  p_tree_mode => l_tree_mode,
  30.                  p_is_revision_control => FALSE,
  31.                  p_is_lot_control => FALSE,
  32.                  p_is_serial_control => FALSE,
  33.                  p_revision => NULL,
  34.                  p_lot_number => NULL,
  35.                  p_lot_expiration_date => NULL,
  36.                  p_subinventory_code => p_subinventory_code,
  37.                  p_locator_id => NULL,
  38.                  p_onhand_source => inv_quantity_tree_pvt.g_all_subs,
  39.                  x_qoh => l_qoh,
  40.                  x_rqoh => l_rqoh,
  41.                  x_qr => l_qr,
  42.                  x_qs => l_qs,
  43.                  x_att => l_att, --可用量
  44.                  x_atr => l_atr); --可保留量
  45.     RETURN l_att;
  46.   END;


 

 



 

 在INV模块,用户查看物料数量最多的三个栏位是现用量可保留量可处理量。下面的procedure是汉得技术顾问在公司上线时候提供的。


点击(此处)折叠或打开

  1. CREATE OR REPLACE PROCEDURE get_inv_quantity(p_organization_id IN NUMBER
  2.                            , p_inventory_item_id IN NUMBER
  3.                            , p_lot_number IN VARCHAR2
  4.                            , p_subinventory_code IN VARCHAR2
  5.                            , p_locator_id IN NUMBER
  6.                            , x_onhand_qty OUT NUMBER
  7.                            , x_reservable_qty OUT NUMBER
  8.                            , x_transactable_qty OUT NUMBER) IS
  9.     l_return_status VARCHAR2(1) ;
  10.     l_msg_count NUMBER;
  11.     l_msg_data VARCHAR2(2000);
  12.     l_is_revision_control BOOLEAN := TRUE ;
  13.     l_is_lot_control BOOLEAN := TRUE ;
  14.     l_is_serial_control BOOLEAN := FALSE ;
  15.     p_revision VARCHAR2(100);
  16.     l_qoh NUMBER;
  17.     l_rqoh NUMBER;
  18.     l_qr NUMBER;
  19.     l_qs NUMBER;
  20.     l_att NUMBER;
  21.     l_atr NUMBER;
  22.     p_lpn_id NUMBER;
  23.   BEGIN
  24.     IF p_lot_number IS NULL THEN
  25.       l_is_lot_control := FALSE ;
  26.     END IF;
  27.     IF p_locator_id IS NULL THEN
  28.       l_is_lot_control := FALSE ;
  29.     END IF;
  30.     inv_quantity_tree_pub.query_quantities
  31.       ( p_api_version_number => 1.0
  32.        , p_init_msg_lst => 'F'
  33.        , x_return_status => l_return_status
  34.        , x_msg_count => l_msg_count
  35.        , x_msg_data => l_msg_data
  36.        , p_organization_id => p_organization_id
  37.        , p_inventory_item_id => p_inventory_item_id
  38.        , p_tree_mode => 1
  39.        , p_is_revision_control => FALSE -- No Revision Control
  40.        , p_is_lot_control => l_is_lot_control
  41.        , p_is_serial_control => l_is_serial_control
  42.        , p_demand_source_type_id => 2
  43.        , p_revision => NULL
  44.        , p_lot_number => p_lot_number
  45.        , p_lot_expiration_date => sysdate
  46.        , p_subinventory_code => p_subinventory_code
  47.        , p_locator_id => p_locator_id
  48.        , p_onhand_source => 3
  49.        , x_qoh => l_qoh
  50.        , x_rqoh => l_rqoh
  51.        , x_qr => l_qr
  52.        , x_qs => l_qs
  53.        , x_att => l_att
  54.        , x_atr => l_atr
  55.        , p_lpn_id => NULL);

  56.        IF (l_return_status = 'S') THEN
  57.           x_onhand_qty := l_qoh;
  58.           x_reservable_qty := l_atr;
  59.         ELSE
  60.           l_return_status :='F';
  61.           RETURN ;
  62.         END IF ;

  63.     inv_quantity_tree_pub.query_quantities
  64.         ( p_api_version_number => 1.0
  65.          , p_init_msg_lst => 'F'
  66.          , x_return_status => l_return_status
  67.          , x_msg_count => l_msg_count
  68.          , x_msg_data => l_msg_data
  69.          , p_organization_id => p_organization_id
  70.          , p_inventory_item_id => p_inventory_item_id
  71.          , p_tree_mode => 2
  72.          , p_is_revision_control => FALSE -- No Revision Control
  73.          , p_is_lot_control => l_is_lot_control
  74.          , p_is_serial_control => l_is_serial_control
  75.          , p_demand_source_type_id => 2
  76.          , p_revision => NULL
  77.          , p_lot_number => p_lot_number
  78.          , p_lot_expiration_date => sysdate
  79.          , p_subinventory_code => p_subinventory_code
  80.          , p_locator_id => p_locator_id
  81.          , p_onhand_source => 3
  82.          , x_qoh => l_qoh
  83.          , x_rqoh => l_rqoh
  84.          , x_qr => l_qr
  85.          , x_qs => l_qs
  86.          , x_att => l_att
  87.          , x_atr => l_atr
  88.          , p_lpn_id => NULL);
  89.     IF (l_return_status = 'S') THEN
  90.       x_onhand_qty := l_qoh;
  91.       x_transactable_qty := l_att;
  92.     ELSE
  93.       l_return_status :='F';
  94.       RETURN;
  95.     END IF ;
  96.   END get_inv_quantity ;
  97.  
  98. create or replace function get_reservable_qty(p_organization_id number,p_inventory_item_id number,p_sub varchar2) return number is
  99.       l_onhand_qty number;
  100.       l_reservable_qty number;
  101.       l_transactable_qty number;
  102. begin
  103.    --p_sub可以为空,为空时,所有库别的可保留数量
  104.        get_inv_quantity(p_organization_id => p_organization_id,
  105.             p_inventory_item_id => p_inventory_item_id,
  106.             p_lot_number => null,
  107.             p_subinventory_code => p_sub,
  108.             p_locator_id => null,
  109.             x_onhand_qty => l_onhand_qty,
  110.             x_reservable_qty => l_reservable_qty,
  111.             x_transactable_qty => l_transactable_qty);
  112.  return l_reservable_qty;
  113. end get_reservable_qty;




转自http://www.cnblogs.com/benio/archive/2010/11/23/1880684.html
阅读(1434) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~