Query to find serial number material transactions details

Oracle apps query to find serial number material transactions details
join between mtl_material_transactions and serial_number
How to join mtl_material_transactions and mtl_serial_numbers
-- For serial controlled and non-lot controlled items
SELECT mmt.transaction_id,
       msn.serial_number,
       mmt.inventory_item_id,
       (SELECT segment1
          FROM mtl_system_items_b
         WHERE inventory_item_id = mmt.inventory_item_id AND ROWNUM = 1)
          item,
       (SELECT transaction_type_name
          FROM apps.mtl_transaction_types mtt
         WHERE mtt.transaction_type_id = mmt.transaction_type_id)
          transaction_type,
       (SELECT segment1
          FROM mtl_sales_orders
         WHERE sales_order_id = mmt.transaction_source_id)
          transaction_source,
       NULL              lot_number,
       mmt.creation_date transaction_creation_date,
       mmt.organization_id,
       ood.organization_code
  FROM mtl_unit_transactions        mut,
       mtl_serial_numbers           msn,
       mtl_material_transactions    mmt,
       org_organization_definitions ood
 WHERE     msn.serial_number = mut.serial_number
       AND mmt.transaction_id = mut.transaction_id
       AND ood.organization_id = mmt.organization_id
       AND mut.serial_number IN ('<Your Serial Number>')
UNION
-- For serial controlled and lot controlled items
SELECT mmt.transaction_id,
       msn.serial_number,
       mmt.inventory_item_id,
       (SELECT segment1
          FROM mtl_system_items_b
         WHERE inventory_item_id = mmt.inventory_item_id AND ROWNUM = 1)
          item,
       (SELECT transaction_type_name
          FROM apps.mtl_transaction_types mtt
         WHERE mtt.transaction_type_id = mmt.transaction_type_id)
          transaction_type,
       (SELECT segment1
          FROM mtl_sales_orders
         WHERE sales_order_id = mmt.transaction_source_id)
          transaction_source,
       mtln.lot_number,
       mmt.creation_date transaction_creation_date,
       mmt.organization_id,
       ood.organization_code
  FROM mtl_unit_transactions        mut,
       mtl_serial_numbers           msn,
       mtl_material_transactions    mmt,
       mtl_transaction_lot_numbers  mtln,
       org_organization_definitions ood
 WHERE     msn.serial_number = mut.serial_number
       AND mmt.transaction_id = mtln.transaction_id
       AND mtln.serial_transaction_id = mut.transaction_id
       AND ood.organization_id = mmt.organization_id
       AND mut.serial_number IN ('<Your Serial Number>')
ORDER BY 1 DESC

For more reusable queries, click https://tech7.in/category/technologyblog/oracle/

Related posts: Upload your own post and refer it anywhere anytime:

Leave a Reply