Архив

Архив автора

Модуль 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

Модуль INV — Приход и расход по позициям

-- транзакции с материалами: расход, приход
select msi.organization_id         as org_id,
       mmt.transaction_date        as date_val,
       msi.inventory_item_id       as item_id,
       msi.segment1                as item,
       msi.primary_uom_code        as uom_code,
       -- приход
       case when mmt.primary_quantity > 0 then mmt.primary_quantity
       end receive_qty,
       -- расход
       case when mmt.primary_quantity < 0 then abs(mmt.primary_quantity)
       end charges_qty
       -- 
from mtl_system_items_b        msi,
     mtl_material_transactions mmt
where 1 = 1
      -- msi 
      and msi.inventory_item_status_code = 'Active'
      -- mmt 
      and mmt.organization_id   = msi.organization_id
      and mmt.inventory_item_id = msi.inventory_item_id
       -- ! ограничиваем период 
      and mmt.transaction_date  >= trunc(sysdate, 'mm')
order by msi.organization_id, msi.inventory_item_id, mmt.transaction_date

Более сложный вариант, с учетом разных типов транзакций:

Читать дальше про “Модуль INV — Приход и расход по позициям” »

Заполнение пропусков в выборке

9 Июнь 2010 2 comments

Заполнение пропусков в выборке.

Пробелы в столбце VAL заполняем по следующему принципу: берем следующее значение VAL и отнимаем от него текущее значение X

Читать дальше про “Заполнение пропусков в выборке” »

Убрать пустые блоки из таблицы

Если в таблице слишком много пустых блоков, то оптимизировать данные помогут следующие действия

ALTER TABLE name_table MOVE;
ALTER INDEX name_index REBUILD;

и не забыть обновить статистику для таблицы

begin
dbms_stats.gather_table_stats(schema,table);
end;

Читать дальше про “Убрать пустые блоки из таблицы” »

Categories: SQL Tags: , , ,

Связка между плановыми и складскими позициями

SELECT mp.compile_designator as plan_name,
       msc.plan_id,
       msi.organization_id,
       msc.sr_inventory_item_id,
       msi.inventory_item_id,
       msi.segment1,
       msi.description
FROM msc_system_items   msc,
     mtl_system_items_b msi,
     msc_plans          mp
where 1 = 1
     and msi.inventory_item_id = msc.sr_inventory_item_id
     and msi.organization_id   = msc.organization_id
     -- plan
     and mp.plan_id = msc.plan_id
order by  mp.compile_designator,
          msc.plan_id,
          msi.organization_id,
          msi.inventory_item_id

Модуль GME/GMD – Связка между формулой, рецептом и правилами применимости

select msi.organization_id    as org_id,
       md.formula_id          as formula_id,
       md.formulaline_id      as formulaline_id,
       md.line_type           as line_type,
       msi.inventory_item_id  as item_id,
       msi.segment1           as item_no,
       msi.description        as item_descr,
       rr.start_date          as start_date,
       nvl(rr.end_date,to_date('01-01-2099','dd-mm-yyyy')) as end_date
/**/
from mtl_system_items_b        msi,
     fm_matl_dtl               md,
     gmd_recipes               r,
     gmd_recipe_validity_rules rr
where 1 = 1
      -- formula
      and md.organization_id   = msi.organization_id
      and md.inventory_item_id = msi.inventory_item_id
      -- recipes
      and r.formula_id    = md.formula_id
      and r.recipe_status = 700 -- Утверждено для общего использования
      and r.delete_mark   = 0   -- не помечен на удаление
      and r.owner_organization_id =  md.organization_id
      -- recepe rules
      and rr.recipe_id       = r.RECIPE_ID
      and rr.organization_id = md.organization_id
      and rr.delete_mark          = 0   -- не помечен на удаление
      and rr.validity_rule_status = 700 -- Утверждено для общего использования
      and rr.recipe_use           = 0   -- использование рецепта = Производство
order by msi.organization_id, md.formula_id, md.line_type desc, md.line_no


Модуль GME/GMD — Получить количество из формулы для строки задания

select gbh.organization_id,
       gbh.batch_no,
       gmd.inventory_item_id,
       gmd.line_type,
       md.qty
from fm_matl_dtl md, gme_material_details gmd, gme_batch_header gbh
where 1 = 1
      and gmd.batch_id = gbh.batch_id
      and gmd.organization_id = gbh.organization_id
      and md.formula_id = gbh.formula_id
      and md.formulaline_id = gmd.formulaline_id
order by gbh.organization_id,
          gbh.batch_no,
          gmd.inventory_item_id,
          gmd.line_type
Categories: Oracle e-Business Suite, SQL Tags: , ,

Получить данные о таблице по ROWID

select t.object_name,
       t.object_type,
       dbms_rowid.rowid_object('AABDKKAGRAAAOXhAAR')       as "OBJECT",
       dbms_rowid.rowid_relative_fno('AABDKKAGRAAAOXhAAR') as "FILE",
       dbms_rowid.rowid_block_number('AABDKKAGRAAAOXhAAR') as "BLOCK",
       dbms_rowid.rowid_row_number('AABDKKAGRAAAOXhAAR')   as "ROW"
from dba_objects t
where dbms_rowid.rowid_object('AABDKKAGRAAAOXhAAR') =  t.data_object_id

OBJECT_NAME     OBJECT_TYPE    OBJECT     FILE     BLOCK      ROW
--------------- -------------- ---------- -------- ---------- ----------
FM_FORM_MST_B   TABLE          275082     401      58849      17
Categories: SQL Tags: ,

Модуль GMD – Удалить строку из формулы

Модуль GMD R12.GMD.A.6 (Разработка продукции УНП; Process Manufacturing Product Development)

Процедура для удаления строки из формулы

Читать дальше про “Модуль GMD – Удалить строку из формулы” »

Модуль GMD – Добавить ингредиент в формулу

Модуль GMD R12.GMD.A.6 (Разработка продукции УНП; Process Manufacturing Product Development)

Процедура добавления ингредиента в формулу

Читать дальше про “Модуль GMD – Добавить ингредиент в формулу” »