Production Floor to Distribution Transfer query SQL
select
forg.organization_code giver_org, forg.organization_name giver_org_name,
torg.organization_code recever_org,
torg.organization_name recever_org_name, itm.segment1 item,
itm.description item_name,
SUM (DECODE (mmt.transaction_type_id, 62, mmt.transaction_quantity)
) issue_qty,
SUM (DECODE (mmt.transaction_type_id, 61, mmt.transaction_quantity)
) received_qty
FROM mtl_system_items_b itm, mtl_material_transactions mmt, org_organization_definitions forg, org_organization_definitions torg
WHERE itm.ORGANIZATION_ID=mmt.ORGANIZATION_ID and itm.INVENTORY_ITEM_ID=mmt.INVENTORY_ITEM_ID and
mmt.transaction_date BETWEEN TO_DATE ('01/12/22 00:00:00', 'DD/mm/yy HH24:MI:SS' ) AND TO_DATE ('31/12/22 23:59:59', 'DD/mm/yy HH24:MI:SS' )
AND mmt.transaction_type_id IN (61, 62)
and exists (SELECT o.organization_id
FROM org_organization_definitions o, mtl_parameters p
WHERE o.organization_id = p.organization_id
---- AND p.process_enabled_flag = 'Y'
---- AND o.operating_unit <> xx123 AND o.organization_id = mmt.organization_id )
AND exists (SELECT organization_id FROM org_organization_definitions ouk
WHERE ouk.operating_unit = 148 and ouk.organization_id= mmt.transfer_organization_id)
and mmt.ORGANIZATION_ID=forg.ORGANIZATION_ID and mmt.TRANSFER_ORGANIZATION_ID=torg.ORGANIZATION_ID
GROUP BY forg.organization_code,
forg.organization_name,
torg.organization_code,
torg.organization_name,
itm.segment1,
itm.description