Архив

Публикации с меткой ‘Purchasing’

Модуль PO – Сколько запрошенно по позициям

-- заявка на приобретение
select prl.destination_organization_id as org_id,
       prl.need_by_date                as date_val,
       prl.item_id                     as item_id,
       msi.segment1                    as item,
       msi.primary_uom_code            as uom_code,
       -- запрошенно
       prl.quantity                    as demand_qty
from po_requisition_lines_all   prl,
     po_requisition_headers_all phr,
     mtl_system_items_b         msi
where 1=1
      -- prl
       -- ! ограничиваем период
      and prl.need_by_date  >= trunc(sysdate, 'mm')
      -- phr
      and phr.requisition_header_id = prl.requisition_header_id
      and phr.authorization_status = 'APPROVED' -- утверждённые заявки
      -- msi
      and msi.inventory_item_id  = prl.item_id
      and msi.organization_id    = prl.destination_organization_id
order by prl.destination_organization_id,
         msi.inventory_item_id,
         prl.need_by_date

Модуль PO — Сколько заказано по позициям

-- заказы на приобретение
Select pll.ship_to_organization_id as org_id,
       pll.need_by_date            as date_val,
       pla.item_id                 as item_id,
       msi.segment1                as item,
       msi.primary_uom_code        as uom_code,
       -- заказано
       pla.quantity                as ordered_qty
from po_line_locations_all pll,
       po_lines_all          pla,
       po_headers_all        pha,
       mtl_system_items_b    msi
where 1=1
      -- pll
      and pll.po_line_id = pla.po_line_id
       -- ! ограничиваем период
      and pll.need_by_date >= trunc(sysdate, 'mm')
      -- msi
      and msi.inventory_item_id  = pla.item_id
      and msi.organization_id    = pll.ship_to_organization_id
      --  pha
      and pha.po_header_id = pla.po_header_id
      and pha.authorization_status = 'APPROVED' -- только утвержденные ЗП
order by pll.ship_to_organization_id, msi.inventory_item_id, pll.need_by_date