采购接收入库事务处理数据流

5 篇文章 0 订阅

--接收数量
SELECT RSH.RECEIPT_NUM
      ,RT.QUANTITY --当前接收 接收数量
      ,RT.*
  FROM RCV_SHIPMENT_HEADERS RSH
      ,RCV_SHIPMENT_LINES   RSL
      ,RCV_TRANSACTIONS     RT
 WHERE RSH.SHIPMENT_HEADER_ID = RSL.SHIPMENT_HEADER_ID
   AND RSL.SHIPMENT_LINE_ID = RT.SHIPMENT_LINE_ID
   AND RSH.RECEIPT_NUM = '255182'
   AND RSH.SHIPMENT_HEADER_ID = 1179227
   AND RT.TRANSACTION_TYPE = 'RECEIVE';
--检验数量
SELECT RT.*
  FROM RCV_SHIPMENT_HEADERS RSH
      ,RCV_SHIPMENT_LINES   RSL
      ,RCV_TRANSACTIONS     RT
 WHERE RSH.SHIPMENT_HEADER_ID = RSL.SHIPMENT_HEADER_ID
   AND RSL.SHIPMENT_LINE_ID = RT.SHIPMENT_LINE_ID
   AND RSH.RECEIPT_NUM = '255182'
   AND RSH.SHIPMENT_HEADER_ID = 1179227
   AND RT.TRANSACTION_TYPE IN ('ACCEPT'
                              ,'REJECT');
--入库数量
SELECT RT.*
  FROM RCV_SHIPMENT_HEADERS RSH
      ,RCV_SHIPMENT_LINES   RSL
      ,RCV_TRANSACTIONS     RT
 WHERE RSH.SHIPMENT_HEADER_ID = RSL.SHIPMENT_HEADER_ID
   AND RSL.SHIPMENT_LINE_ID = RT.SHIPMENT_LINE_ID
   AND RSH.RECEIPT_NUM = '255182'
   AND RSH.SHIPMENT_HEADER_ID = 1179227
   AND RT.TRANSACTION_TYPE IN ('DELIVER');
--库存退货至供应商数量
SELECT RT.*
  FROM RCV_SHIPMENT_HEADERS RSH
      ,RCV_SHIPMENT_LINES   RSL
      ,RCV_TRANSACTIONS     RT
 WHERE RSH.SHIPMENT_HEADER_ID = RSL.SHIPMENT_HEADER_ID
   AND RSL.SHIPMENT_LINE_ID = RT.SHIPMENT_LINE_ID
   AND RSH.RECEIPT_NUM = '255182'
   AND RSH.SHIPMENT_HEADER_ID = 1179227
   AND RT.TRANSACTION_TYPE IN ('RETURN TO VENDOR');
--库存退货至接收数量 (包含库存退货之接收及库存退货之供应商数量,因库存退货之供应商时先退货至接收再从接收退货之供应商)
SELECT RT.*
  FROM RCV_SHIPMENT_HEADERS RSH
      ,RCV_SHIPMENT_LINES   RSL
      ,RCV_TRANSACTIONS     RT
 WHERE RSH.SHIPMENT_HEADER_ID = RSL.SHIPMENT_HEADER_ID
   AND RSL.SHIPMENT_LINE_ID = RT.SHIPMENT_LINE_ID
   AND RSH.RECEIPT_NUM = '255182'
   AND RSH.SHIPMENT_HEADER_ID = 1179227
   AND RT.TRANSACTION_TYPE IN ('RETURN TO RECEIVING');

--接收之库存事务处理数量
SELECT MMT.*
  FROM RCV_SHIPMENT_HEADERS      RSH
      ,RCV_SHIPMENT_LINES        RSL
      ,RCV_TRANSACTIONS          RT
      ,MTL_MATERIAL_TRANSACTIONS MMT
 WHERE RSH.SHIPMENT_HEADER_ID = RSL.SHIPMENT_HEADER_ID
   AND RSL.SHIPMENT_LINE_ID = RT.SHIPMENT_LINE_ID
   AND MMT.RCV_TRANSACTION_ID = RT.TRANSACTION_ID
   AND RSH.RECEIPT_NUM = '255182'
   AND RSH.SHIPMENT_HEADER_ID = 1179227;

--常用数量
SELECT RSH.RECEIPT_NUM
      ,RT.QUANTITY --当前接收 接收数量
      
      ,NVL((SELECT SUM(RT1.QUANTITY)
             FROM RCV_TRANSACTIONS RT1
            WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
              AND RT1.TRANSACTION_TYPE = 'RETURN TO VENDOR')
          ,0) RETURN_TO_VENDOR_QTY --当前接收退货至供应商数量
      
      ,RT.QUANTITY -
       NVL((SELECT SUM(RT1.QUANTITY)
             FROM RCV_TRANSACTIONS RT1
            WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
              AND RT1.TRANSACTION_TYPE = 'RETURN TO VENDOR')
          ,0) RECEIVED_QTY --当前接收数量-当前接收退货至供应商数量=实际接收数量
      
      ,NVL((SELECT SUM(RT1.QUANTITY)
             FROM RCV_TRANSACTIONS RT1
            WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
              AND RT1.TRANSACTION_TYPE = 'ACCEPT')
          ,0) INSPECTION_ACCEPT_QTY --当前接收检验合格数量
      
      ,NVL((SELECT SUM(RT1.QUANTITY)
             FROM RCV_TRANSACTIONS RT1
            WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
              AND RT1.TRANSACTION_TYPE = 'REJECT')
          ,0) INSPECTION_REJECT_QTY --当前接收检验不合格数量
      
      ,NVL((SELECT SUM(RT1.QUANTITY)
             FROM RCV_TRANSACTIONS RT1
            WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
              AND RT1.TRANSACTION_TYPE = 'RETURN TO RECEIVING')
          ,0) RETURN_TO_RECEIVE_QTY --当前接收入库后又退货至接收 数量
      
      ,NVL((SELECT SUM(RT1.QUANTITY)
             FROM RCV_TRANSACTIONS RT1
            WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
              AND RT1.TRANSACTION_TYPE = 'RETURN TO VENDOR')
          ,0) RETURN_TO_VENDOR_QTY --当前接收入库后又退货至供应商数量
      
      ,NVL((SELECT SUM(RT1.QUANTITY)
             FROM RCV_TRANSACTIONS RT1
            WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
              AND RT1.TRANSACTION_TYPE = 'DELIVER')
          ,0) DELIVERED_QTY --已入库数量(不含入库后退货)
      
      ,NVL((SELECT SUM(RT1.QUANTITY)
             FROM RCV_TRANSACTIONS RT1
            WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
              AND RT1.TRANSACTION_TYPE = 'DELIVER')
          ,0) - NVL((SELECT SUM(RT1.QUANTITY)
                      FROM RCV_TRANSACTIONS RT1
                     WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
                       AND RT1.TRANSACTION_TYPE = 'RETURN TO RECEIVING')
                   ,0) ACTUAL_DELIVERED_QTY --入库数量 - 退货至接收数量=实际入库数量
      
      ,NVL((SELECT SUM(RT1.QUANTITY)
             FROM RCV_TRANSACTIONS RT1
            WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
              AND RT1.TRANSACTION_TYPE = 'RETURN TO RECEIVING')
          ,0) - NVL((SELECT SUM(RT1.QUANTITY)
                      FROM RCV_TRANSACTIONS RT1
                     WHERE RT1.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID
                       AND RT1.TRANSACTION_TYPE = 'RETURN TO VENDOR')
                   ,0) UNRECEIVED_QTY --退货至接收数量-退货之供应商数量
  FROM RCV_SHIPMENT_HEADERS RSH
      ,RCV_SHIPMENT_LINES   RSL
      ,RCV_TRANSACTIONS     RT
 WHERE RSH.SHIPMENT_HEADER_ID = RSL.SHIPMENT_HEADER_ID
   AND RSL.SHIPMENT_LINE_ID = RT.SHIPMENT_LINE_ID
   AND RSH.RECEIPT_NUM = '255182'
   AND RSH.SHIPMENT_HEADER_ID = 1179227
   AND RT.TRANSACTION_TYPE = 'RECEIVE';

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值